@@ -106,6 +106,7 @@ export class LightClientVerifier {
106106 private elRpcUrl : string ;
107107 public provider : Web3jsProvider | undefined ;
108108 public proofProvider : ProofProvider | undefined ;
109+ private multicall : Multicall | undefined ;
109110
110111 constructor ( { network, elRpcUrl, beaconApiUrl, initialCheckpoint } : LightClientVerifierInitArgs ) {
111112 this . elRpcUrl = elRpcUrl ;
@@ -209,6 +210,11 @@ export class LightClientVerifier {
209210 this . provider = provider ;
210211 this . proofProvider = proofProvider ;
211212 this . web3 = new Web3 ( provider ) ;
213+ this . multicall = new Multicall ( {
214+ web3Instance : this . web3 ,
215+ tryAggregate : true ,
216+ multicallCustomContractAddress : '0xca11bde05977b3631167028862be2a173976ca11' , // Getting multicall address from network fails
217+ } ) ;
212218 await this . waitForClientToStart ( ) ;
213219 }
214220
@@ -244,23 +250,17 @@ export class LightClientVerifier {
244250 let ethBalance ;
245251 try {
246252 let balance = await this . web3 ! . eth . getBalance ( address ) ;
247- console . log ( 'eth' , balance ) ;
248253 ethBalance = {
249254 balance : Number ( this . web3 ! . utils . fromWei ( balance , 'ether' ) ) ,
250255 verified : true ,
251256 } ;
252257 } catch ( e ) {
253- console . log ( 'ERROR eth balance' , e ) ;
254258 ethBalance = {
255259 balance : 0 ,
256260 verified : false ,
257261 } ;
258262 }
259- const multicall = new Multicall ( {
260- web3Instance : this . web3 ,
261- tryAggregate : true ,
262- multicallCustomContractAddress : '0xca11bde05977b3631167028862be2a173976ca11' , // Getting multicall address from network fails
263- } ) ;
263+ const erc20Balances : Record < string , VerifiedBalance > = { } ;
264264
265265 const contractCallContext : ContractCallContext [ ] = erc20Contracts . map ( ( erc20ContractAddress ) => {
266266 return {
@@ -273,13 +273,12 @@ export class LightClientVerifier {
273273 ] ,
274274 } ;
275275 } ) ;
276- const erc20Balances : Record < string , VerifiedBalance > = { } ;
277- const results : ContractCallResults = await multicall . call ( contractCallContext ) ;
276+
277+ const results : ContractCallResults = await this . multicall ! . call ( contractCallContext ) ;
278278
279279 for ( const key of Object . keys ( results . results ) ) {
280280 const result = results . results [ key ] ;
281281 const erc20ContractAddress = key ;
282- console . log ( erc20ContractAddress , result ) ;
283282 if ( result && result . callsReturnContext ) {
284283 // @ts -ignore
285284 const balanceResult = result . callsReturnContext . find ( ( call ) => call . reference === 'balanceOf' ) ;
@@ -289,7 +288,6 @@ export class LightClientVerifier {
289288 if ( balanceResult ?. success && decimalsResult ?. success ) {
290289 const decimals = decimalsResult ?. returnValues [ 0 ] ;
291290 const balance = parseFloat ( formatUnits ( hexToNumberString ( balanceResult ?. returnValues [ 0 ] . hex ) , decimals ) ) ;
292- console . log ( 'contract' , erc20ContractAddress , balance ) ;
293291 erc20Balances [ erc20ContractAddress ] = { balance : balance , verified : true } ;
294292 } else {
295293 erc20Balances [ erc20ContractAddress ] = { balance : 0 , verified : false } ;
0 commit comments