@@ -126,13 +126,22 @@ def _inner_call(
126
126
)
127
127
except Exception as e :
128
128
if len (calls_with_calldata ) == 1 :
129
- print (f"Multicall with single call got Exception '{ repr (e )} ', retrying in 1 sec " )
129
+ print (f"Multicall with single call got Exception '{ repr (e )} ', last retry " )
130
130
sleep (1 )
131
- return self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata )
132
- print (f"Multicall got Exception '{ repr (e )} ', splitting and retrying" )
133
- left_results , left_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [:len (calls_with_calldata ) // 2 ])
134
- right_results , right_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [len (calls_with_calldata ) // 2 :])
135
- return left_results + right_results , left_gas_usages + right_gas_usages
131
+ try :
132
+ raw_returns , gas_usages = self ._call_multicall (
133
+ multicall_call = multicall_call ,
134
+ retry = len (calls_with_calldata ) == 1
135
+ )
136
+ except Exception as e :
137
+ print (f"Multicall with single call got Exception '{ repr (e )} ', returning Exception" )
138
+ raw_returns = [e ]
139
+ gas_usages = [None ]
140
+ else :
141
+ print (f"Multicall got Exception '{ repr (e )} ', splitting and retrying" )
142
+ left_results , left_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [:len (calls_with_calldata ) // 2 ])
143
+ right_results , right_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [len (calls_with_calldata ) // 2 :])
144
+ return left_results + right_results , left_gas_usages + right_gas_usages
136
145
results = self .decode_contract_function_results (raw_returns = raw_returns , contract_functions = [call for call , _ in calls_with_calldata ])
137
146
if len (results ) == len (calls_with_calldata ):
138
147
return results , gas_usages
0 commit comments