@ -376,12 +376,21 @@ class ContextFunder {
async ( [ chain , keys ] ) = > {
if ( keys . length > 0 ) {
if ( ! this . skipIgpClaim ) {
await this . attemptToClaimFromIgp ( chain as ChainName ) ;
failureOccurred || = await gracefullyHandleError (
( ) = > this . attemptToClaimFromIgp ( chain ) ,
chain ,
'Error claiming from IGP' ,
) ;
}
await this . bridgeIfL2 ( chain as ChainName ) ;
failureOccurred || = await gracefullyHandleError (
( ) = > this . bridgeIfL2 ( chain ) ,
chain ,
'Error bridging to L2' ,
) ;
}
for ( const key of keys ) {
const failure = await this . attemptToFundKey ( key , chain as ChainName ) ;
const failure = await this . attemptToFundKey ( key , chain ) ;
failureOccurred || = failure ;
}
} ,
@ -492,15 +501,20 @@ class ContextFunder {
const igpBalance = await provider . getBalance ( igp . address ) ;
log ( 'Checking IGP balance' , {
chain ,
igpBalance : ethers.utils.formatEther ( igpBalance ) ,
igpClaimThreshold : ethers.utils.formatEther ( igpClaimThreshold ) ,
} ) ;
if ( igpBalance . gt ( igpClaimThreshold ) ) {
log ( 'IGP balance exceeds claim threshold, claiming' ) ;
log ( 'IGP balance exceeds claim threshold, claiming' , {
chain ,
} ) ;
await this . multiProvider . handleTx ( chain , igp . contract . claim ( ) ) ;
} else {
log ( 'IGP balance does not exceed claim threshold, skipping' ) ;
log ( 'IGP balance does not exceed claim threshold, skipping' , {
chain ,
} ) ;
}
}
@ -744,6 +758,24 @@ function parseContextAndRoles(str: string): ContextAndRoles {
} ;
}
// Returns whether an error occurred
async function gracefullyHandleError (
fn : ( ) = > Promise < void > ,
chain : ChainName ,
errorMessage : string ,
) : Promise < boolean > {
try {
await fn ( ) ;
return false ;
} catch ( err ) {
error ( errorMessage , {
chain ,
error : format ( err ) ,
} ) ;
}
return true ;
}
main ( ) . catch ( ( err ) = > {
error ( 'Error occurred in main' , {
// JSON.stringifying an Error returns '{}'.