@@ -112,16 +112,23 @@ export async function run(args = []) {
112112 } ) ;
113113 const data = await res . json ( ) ;
114114 if ( data . result ) {
115- // Tempo faucet is instant — re-read balance once
116- try {
117- const raw = await client . readContract ( { address : PATH_USD , abi : USDC_ABI , functionName : "balanceOf" , args : [ allowance . address ] } ) ;
118- balance = Number ( raw ) ;
119- } catch { }
115+ // Tempo faucet is "instant" on-chain, but the client RPC read can be
116+ // racy relative to faucet settlement — poll up to 30s (GH-81), mirroring
117+ // the x402 path below.
118+ for ( let i = 0 ; i < 30 ; i ++ ) {
119+ await new Promise ( r => setTimeout ( r , 1000 ) ) ;
120+ try {
121+ const raw = await client . readContract ( { address : PATH_USD , abi : USDC_ABI , functionName : "balanceOf" , args : [ allowance . address ] } ) ;
122+ balance = Number ( raw ) ;
123+ if ( balance > 0 ) break ;
124+ } catch { }
125+ }
120126 saveAllowance ( { ...allowance , funded : true , lastFaucet : new Date ( ) . toISOString ( ) } ) ;
127+ summary . allowance . funded = true ;
121128 if ( balance > 0 ) {
122129 line ( "Balance" , `${ ( balance / 1e6 ) . toFixed ( 2 ) } pathUSD (funded)` ) ;
123130 } else {
124- line ( "Balance" , "faucet sent — checking balance... " ) ;
131+ line ( "Balance" , "faucet sent — not yet confirmed on-chain " ) ;
125132 }
126133 } else {
127134 line ( "Balance" , `faucet failed: ${ data . error ?. message || "unknown error" } ` ) ;
@@ -131,6 +138,7 @@ export async function run(args = []) {
131138 }
132139 } else {
133140 line ( "Balance" , `${ ( balance / 1e6 ) . toFixed ( 2 ) } pathUSD` ) ;
141+ summary . allowance . funded = balance > 0 ;
134142 }
135143 summary . balance = { symbol : "pathUSD" , usd_micros : balance } ;
136144 } else {
@@ -162,6 +170,7 @@ export async function run(args = []) {
162170 } catch { }
163171 }
164172 saveAllowance ( { ...allowance , funded : true , lastFaucet : new Date ( ) . toISOString ( ) } ) ;
173+ summary . allowance . funded = true ;
165174 if ( balance > 0 ) {
166175 line ( "Balance" , `${ ( balance / 1e6 ) . toFixed ( 2 ) } USDC (funded)` ) ;
167176 } else {
@@ -174,6 +183,7 @@ export async function run(args = []) {
174183 }
175184 } else {
176185 line ( "Balance" , `${ ( balance / 1e6 ) . toFixed ( 2 ) } USDC` ) ;
186+ summary . allowance . funded = balance > 0 ;
177187 }
178188 summary . balance = { symbol : "USDC" , usd_micros : balance } ;
179189 }
0 commit comments