1- import { BigNumber } from 'ethers ' ;
1+ import chalk from 'chalk ' ;
22import { formatEther , parseEther } from 'ethers/lib/utils.js' ;
33
44import { HyperlaneIgp } from '@hyperlane-xyz/sdk' ;
5- import { objMap , promiseObjAll } from '@hyperlane-xyz/utils' ;
5+ import { objMap , promiseObjAll , rootLogger } from '@hyperlane-xyz/utils' ;
66
77import { getEnvAddresses } from '../../config/registry.js' ;
88import { getKeyFunderConfig } from '../../src/funding/key-funder.js' ;
@@ -20,11 +20,11 @@ function withForce<T>(args: any) {
2020}
2121
2222const ReclaimStatus = {
23- SUCCESS : 'SUCCESS ' ,
24- BELOW_THRESHOLD : 'BELOW_THRESHOLD ' ,
25- INSUFFICIENT_FOR_GAS : 'INSUFFICIENT_FOR_GAS ' ,
26- NO_GAS_PRICE : 'NO_GAS_PRICE ' ,
27- ERROR : 'ERROR ' ,
23+ SUCCESS : '🟢 ' ,
24+ BELOW_THRESHOLD : '🔵 ' ,
25+ INSUFFICIENT_FOR_GAS : '🟡 ' ,
26+ NO_GAS_PRICE : '🟡 ' ,
27+ ERROR : '🔴 ' ,
2828} as const ;
2929type ReclaimStatus = ( typeof ReclaimStatus ) [ keyof typeof ReclaimStatus ] ;
3030
@@ -141,10 +141,12 @@ async function main() {
141141 } ;
142142 }
143143
144- console . log ( `Claiming from IGP on ${ chain } ...` ) ;
144+ rootLogger . debug ( `Claiming from IGP on ${ chain } ...` ) ;
145145 const tx = await paymaster . claim ( ) ;
146146 const explorerUrl = multiProvider . tryGetExplorerTxUrl ( chain , tx ) ;
147- console . log ( ` ✓ ${ explorerUrl || tx . hash } ` ) ;
147+ rootLogger . info (
148+ `Claimed from IGP on ${ chain } : ${ explorerUrl || tx . hash } ` ,
149+ ) ;
148150
149151 return {
150152 chain,
@@ -164,7 +166,9 @@ async function main() {
164166 const errorMsg = error instanceof Error ? error . message : String ( error ) ;
165167 // Extract just the key error info, not the full stack
166168 const shortError = errorMsg . split ( '\n' ) [ 0 ] ;
167- console . log ( ` ✗ ${ chain } : ${ shortError } ` ) ;
169+ rootLogger . error (
170+ chalk . red ( `Error claiming from IGP on ${ chain } : ${ shortError } ` ) ,
171+ ) ;
168172 return {
169173 chain,
170174 balance,
@@ -186,7 +190,6 @@ async function main() {
186190 ) ;
187191
188192 if ( interestingResults . length > 0 ) {
189- console . log ( '\n=== Summary ===\n' ) ;
190193 const tableData = interestingResults . map ( ( r ) => ( {
191194 chain : r . chain ,
192195 balance : r . balance ,
@@ -206,21 +209,34 @@ async function main() {
206209 ( r ) => r . status === ReclaimStatus . BELOW_THRESHOLD ,
207210 ) . length ;
208211
209- console . log ( `\n✓ Successfully claimed from ${ successCount } chain(s)` ) ;
212+ rootLogger . info (
213+ chalk . green ( `\nSuccessfully claimed from ${ successCount } chain(s)` ) ,
214+ ) ;
210215 if ( errorCount > 0 ) {
211- console . log ( `✗ ${ errorCount } chain(s) encountered errors` ) ;
216+ rootLogger . error (
217+ chalk . red (
218+ `Encountered ${ errorCount } errors on: ${ results
219+ . filter ( ( r ) => r . status === ReclaimStatus . ERROR )
220+ . map ( ( r ) => r . chain )
221+ . join ( ', ' ) } `,
222+ ) ,
223+ ) ;
212224 }
213225 if ( belowThresholdCount > 0 ) {
214- console . log ( `- ${ belowThresholdCount } chain(s) below threshold (skipped)` ) ;
226+ rootLogger . info (
227+ chalk . yellow ( `${ belowThresholdCount } chain(s) below threshold (skipped)` ) ,
228+ ) ;
215229 }
216230 if ( force ) {
217- console . log ( '\n(--force mode: bypassed threshold and gas checks)' ) ;
231+ rootLogger . info (
232+ chalk . yellow ( '\n(--force mode: bypassed threshold and gas checks)' ) ,
233+ ) ;
218234 }
219235}
220236
221237main ( )
222238 . then ( ( ) => process . exit ( 0 ) )
223239 . catch ( ( error ) => {
224- console . error ( 'Fatal error:' , error . message ) ;
240+ rootLogger . error ( chalk . red ( 'Fatal error:' , error . message ) ) ;
225241 process . exit ( 1 ) ;
226242 } ) ;
0 commit comments