@@ -88,7 +88,10 @@ func GetAllMegapoolValidators(rp *rocketpool.RocketPool, contracts *NetworkContr
8888 }
8989 var dummy * big.Int
9090 for j := i ; j < max ; j ++ {
91- mc .AddCall (megapoolManagerContract , & dummy , "getValidatorInfo" , big .NewInt (int64 (j )))
91+ err = mc .AddCall (megapoolManagerContract , & dummy , "getValidatorInfo" , big .NewInt (int64 (j )))
92+ if err != nil {
93+ return fmt .Errorf ("error adding validator info call for global index %d: %w" , j , err )
94+ }
9295 }
9396 responses , err := mc .Execute (true , opts )
9497 if err != nil {
@@ -228,7 +231,10 @@ func GetBulkMegapoolDetails(rp *rocketpool.RocketPool, contracts *NetworkContrac
228231 megapoolDetails [j ].NodeDebt = big .NewInt (0 )
229232 megapoolDetails [j ].BondRequirement = big .NewInt (0 )
230233 megapoolDetails [j ].EthBalance = big .NewInt (0 )
231- addMegapoolDetailsCalls (mc , megaContracts [j ], & megapoolDetails [j ], & lastDistributionTimes [j ])
234+ err = addMegapoolDetailsCalls (mc , megaContracts [j ], & megapoolDetails [j ], & lastDistributionTimes [j ])
235+ if err != nil {
236+ return fmt .Errorf ("error adding megapool details calls: %w" , err )
237+ }
232238 }
233239 _ , err = mc .FlexibleCall (true , opts )
234240 if err != nil {
@@ -265,8 +271,14 @@ func GetBulkMegapoolDetails(rp *rocketpool.RocketPool, contracts *NetworkContrac
265271 if megapoolDetails [j ].DelegateExpired {
266272 continue
267273 }
268- mc .AddCall (megapoolFactory , & delegateExpiries [j ], "getDelegateExpiry" , megapoolDetails [j ].DelegateAddress )
269- mc .AddCall (nodeDeposit , & megapoolDetails [j ].BondRequirement , "getBondRequirement" , big .NewInt (int64 (megapoolDetails [j ].ActiveValidatorCount )))
274+ err = mc .AddCall (megapoolFactory , & delegateExpiries [j ], "getDelegateExpiry" , megapoolDetails [j ].DelegateAddress )
275+ if err != nil {
276+ return fmt .Errorf ("error adding delegate expiry call for megapool %s: %w" , megapoolDetails [j ].Address .Hex (), err )
277+ }
278+ err = mc .AddCall (nodeDeposit , & megapoolDetails [j ].BondRequirement , "getBondRequirement" , big .NewInt (int64 (megapoolDetails [j ].ActiveValidatorCount )))
279+ if err != nil {
280+ return fmt .Errorf ("error adding bond requirement call for megapool %s: %w" , megapoolDetails [j ].Address .Hex (), err )
281+ }
270282 callCount += 2
271283 }
272284 if callCount == 0 {
@@ -295,20 +307,31 @@ func GetBulkMegapoolDetails(rp *rocketpool.RocketPool, contracts *NetworkContrac
295307}
296308
297309// Add all independent multicall entries for a single megapool's details
298- func addMegapoolDetailsCalls (mc * multicall.MultiCaller , megaContract * rocketpool.Contract , details * NativeMegapoolDetails , lastDistributionTime * * big.Int ) {
299- mc .AddCall (megaContract , & details .EffectiveDelegateAddress , "getEffectiveDelegate" )
300- mc .AddCall (megaContract , & details .DelegateAddress , "getDelegate" )
301- mc .AddCall (megaContract , & details .DelegateExpired , "getDelegateExpired" )
302- mc .AddCall (megaContract , lastDistributionTime , "getLastDistributionTime" )
303- mc .AddCall (megaContract , & details .NodeDebt , "getDebt" )
304- mc .AddCall (megaContract , & details .PendingRewards , "getPendingRewards" )
305- mc .AddCall (megaContract , & details .RefundValue , "getRefundValue" )
306- mc .AddCall (megaContract , & details .ValidatorCount , "getValidatorCount" )
307- mc .AddCall (megaContract , & details .ActiveValidatorCount , "getActiveValidatorCount" )
308- mc .AddCall (megaContract , & details .LockedValidatorCount , "getLockedValidatorCount" )
309- mc .AddCall (megaContract , & details .UseLatestDelegate , "getUseLatestDelegate" )
310- mc .AddCall (megaContract , & details .AssignedValue , "getAssignedValue" )
311- mc .AddCall (megaContract , & details .NodeBond , "getNodeBond" )
312- mc .AddCall (megaContract , & details .UserCapital , "getUserCapital" )
313- mc .AddCall (megaContract , & details .NodeQueuedBond , "getNodeQueuedBond" )
310+ func addMegapoolDetailsCalls (mc * multicall.MultiCaller , megaContract * rocketpool.Contract , details * NativeMegapoolDetails , lastDistributionTime * * big.Int ) error {
311+ allErrors := make ([]error , 0 )
312+ addCall := func (contract * rocketpool.Contract , out any , method string , args ... any ) {
313+ allErrors = append (allErrors , mc .AddCall (contract , out , method , args ... ))
314+ }
315+
316+ addCall (megaContract , & details .EffectiveDelegateAddress , "getEffectiveDelegate" )
317+ addCall (megaContract , & details .DelegateAddress , "getDelegate" )
318+ addCall (megaContract , & details .DelegateExpired , "getDelegateExpired" )
319+ addCall (megaContract , lastDistributionTime , "getLastDistributionTime" )
320+ addCall (megaContract , & details .NodeDebt , "getDebt" )
321+ addCall (megaContract , & details .PendingRewards , "getPendingRewards" )
322+ addCall (megaContract , & details .RefundValue , "getRefundValue" )
323+ addCall (megaContract , & details .ValidatorCount , "getValidatorCount" )
324+ addCall (megaContract , & details .ActiveValidatorCount , "getActiveValidatorCount" )
325+ addCall (megaContract , & details .LockedValidatorCount , "getLockedValidatorCount" )
326+ addCall (megaContract , & details .UseLatestDelegate , "getUseLatestDelegate" )
327+ addCall (megaContract , & details .AssignedValue , "getAssignedValue" )
328+ addCall (megaContract , & details .NodeBond , "getNodeBond" )
329+ addCall (megaContract , & details .UserCapital , "getUserCapital" )
330+ addCall (megaContract , & details .NodeQueuedBond , "getNodeQueuedBond" )
331+ for _ , err := range allErrors {
332+ if err != nil {
333+ return fmt .Errorf ("error adding megapool details calls: %w" , err )
334+ }
335+ }
336+ return nil
314337}
0 commit comments