@@ -104,9 +104,7 @@ where
104
104
{
105
105
Preparing {
106
106
caller : Arc < dyn Caller < N , Resp > > ,
107
- data : & ' req N :: TransactionRequest ,
108
- overrides : Option < & ' req StateOverride > ,
109
- block : Option < BlockId > ,
107
+ params : EthCallParams < ' req , N > ,
110
108
method : & ' static str ,
111
109
map : Map ,
112
110
} ,
@@ -126,13 +124,9 @@ where
126
124
{
127
125
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
128
126
match self {
129
- Self :: Preparing { caller : _, data, overrides, block, method, map : _ } => f
130
- . debug_struct ( "Preparing" )
131
- . field ( "data" , data)
132
- . field ( "overrides" , overrides)
133
- . field ( "block" , block)
134
- . field ( "method" , method)
135
- . finish ( ) ,
127
+ Self :: Preparing { caller : _, params, method, map : _ } => {
128
+ f. debug_struct ( "Preparing" ) . field ( "params" , params) . field ( "method" , method) . finish ( )
129
+ }
136
130
Self :: Running { .. } => f. debug_tuple ( "Running" ) . finish ( ) ,
137
131
Self :: Polling => f. debug_tuple ( "Polling" ) . finish ( ) ,
138
132
}
@@ -157,18 +151,12 @@ where
157
151
}
158
152
159
153
fn poll_preparing ( & mut self , cx : & mut std:: task:: Context < ' _ > ) -> Poll < TransportResult < Output > > {
160
- let EthCallFutInner :: Preparing { caller, data , overrides , block , method, map } =
154
+ let EthCallFutInner :: Preparing { caller, params , method, map } =
161
155
std:: mem:: replace ( & mut self . inner , EthCallFutInner :: Polling )
162
156
else {
163
157
unreachable ! ( "bad state" )
164
158
} ;
165
159
166
- let params = EthCallParams {
167
- data : Cow :: Borrowed ( data) ,
168
- block,
169
- overrides : overrides. map ( Cow :: Borrowed ) ,
170
- } ;
171
-
172
160
let fut =
173
161
if method. eq ( "eth_call" ) { caller. call ( params) } else { caller. estimate_gas ( params) } ?;
174
162
@@ -223,9 +211,7 @@ where
223
211
Map : Fn ( Resp ) -> Output ,
224
212
{
225
213
caller : Arc < dyn Caller < N , Resp > > ,
226
- data : & ' req N :: TransactionRequest ,
227
- overrides : Option < & ' req StateOverride > ,
228
- block : Option < BlockId > ,
214
+ params : EthCallParams < ' req , N > ,
229
215
method : & ' static str ,
230
216
map : Map ,
231
217
_pd : PhantomData < fn ( ) -> ( Resp , Output ) > ,
@@ -238,10 +224,8 @@ where
238
224
{
239
225
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
240
226
f. debug_struct ( "EthCall" )
227
+ . field ( "params" , & self . params )
241
228
. field ( "method" , & self . method )
242
- . field ( "data" , & self . data )
243
- . field ( "block" , & self . block )
244
- . field ( "overrides" , & self . overrides )
245
229
. finish ( )
246
230
}
247
231
}
@@ -251,33 +235,32 @@ where
251
235
N : Network ,
252
236
Resp : RpcReturn ,
253
237
{
254
- /// Create a new CallBuilder.
255
- pub fn new ( caller : impl Caller < N , Resp > + ' static , data : & ' req N :: TransactionRequest ) -> Self {
238
+ /// Create a new [`EthCall`].
239
+ pub fn new (
240
+ caller : impl Caller < N , Resp > + ' static ,
241
+ method : & ' static str ,
242
+ data : & ' req N :: TransactionRequest ,
243
+ ) -> Self {
256
244
Self {
257
245
caller : Arc :: new ( caller) ,
258
- data,
259
- overrides : None ,
260
- block : None ,
261
- method : "eth_call" ,
246
+ params : EthCallParams :: new ( data) ,
247
+ method,
262
248
map : std:: convert:: identity,
263
249
_pd : PhantomData ,
264
250
}
265
251
}
266
252
267
- /// Create new EthCall for gas estimates.
253
+ /// Create a new [`EthCall`] with method set to `"eth_call"`.
254
+ pub fn call ( caller : impl Caller < N , Resp > + ' static , data : & ' req N :: TransactionRequest ) -> Self {
255
+ Self :: new ( caller, "eth_call" , data)
256
+ }
257
+
258
+ /// Create a new [`EthCall`] with method set to `"eth_estimateGas"`.
268
259
pub fn gas_estimate (
269
260
caller : impl Caller < N , Resp > + ' static ,
270
261
data : & ' req N :: TransactionRequest ,
271
262
) -> Self {
272
- Self {
273
- caller : Arc :: new ( caller) ,
274
- data,
275
- overrides : None ,
276
- block : None ,
277
- method : "eth_estimateGas" ,
278
- map : std:: convert:: identity,
279
- _pd : PhantomData ,
280
- }
263
+ Self :: new ( caller, "eth_estimateGas" , data)
281
264
}
282
265
}
283
266
@@ -307,24 +290,22 @@ where
307
290
{
308
291
EthCall {
309
292
caller : self . caller ,
310
- data : self . data ,
311
- overrides : self . overrides ,
312
- block : self . block ,
293
+ params : self . params ,
313
294
method : self . method ,
314
295
map,
315
296
_pd : PhantomData ,
316
297
}
317
298
}
318
299
319
300
/// Set the state overrides for this call.
320
- pub const fn overrides ( mut self , overrides : & ' req StateOverride ) -> Self {
321
- self . overrides = Some ( overrides) ;
301
+ pub fn overrides ( mut self , overrides : & ' req StateOverride ) -> Self {
302
+ self . params . overrides = Some ( Cow :: Borrowed ( overrides) ) ;
322
303
self
323
304
}
324
305
325
306
/// Set the block to use for this call.
326
307
pub const fn block ( mut self , block : BlockId ) -> Self {
327
- self . block = Some ( block) ;
308
+ self . params . block = Some ( block) ;
328
309
self
329
310
}
330
311
}
@@ -344,9 +325,7 @@ where
344
325
EthCallFut {
345
326
inner : EthCallFutInner :: Preparing {
346
327
caller : self . caller ,
347
- data : self . data ,
348
- overrides : self . overrides ,
349
- block : self . block ,
328
+ params : self . params ,
350
329
method : self . method ,
351
330
map : self . map ,
352
331
} ,
0 commit comments