@@ -21,13 +21,14 @@ pub fn handle_call_request<LoggerErrorT: Debug>(
21
21
block_spec : Option < BlockSpec > ,
22
22
state_overrides : Option < StateOverrideOptions > ,
23
23
) -> Result < ( Bytes , Trace ) , ProviderError < LoggerErrorT > > {
24
+ let block_spec = resolve_block_spec_for_call_request ( block_spec) ;
24
25
validate_call_request ( data. spec_id ( ) , & request, & block_spec) ?;
25
26
26
27
let state_overrides =
27
28
state_overrides. map_or ( Ok ( StateOverrides :: default ( ) ) , StateOverrides :: try_from) ?;
28
29
29
- let transaction = resolve_call_request ( data, request, block_spec. as_ref ( ) , & state_overrides) ?;
30
- let result = data. run_call ( transaction. clone ( ) , block_spec. as_ref ( ) , & state_overrides) ?;
30
+ let transaction = resolve_call_request ( data, request, & block_spec, & state_overrides) ?;
31
+ let result = data. run_call ( transaction. clone ( ) , & block_spec, & state_overrides) ?;
31
32
32
33
let spec_id = data. spec_id ( ) ;
33
34
data. logger_mut ( )
@@ -51,10 +52,14 @@ pub fn handle_call_request<LoggerErrorT: Debug>(
51
52
Ok ( ( output, result. trace ) )
52
53
}
53
54
55
+ pub ( crate ) fn resolve_block_spec_for_call_request ( block_spec : Option < BlockSpec > ) -> BlockSpec {
56
+ block_spec. unwrap_or_else ( BlockSpec :: latest)
57
+ }
58
+
54
59
pub ( crate ) fn resolve_call_request < LoggerErrorT : Debug > (
55
60
data : & mut ProviderData < LoggerErrorT > ,
56
61
request : CallRequest ,
57
- block_spec : Option < & BlockSpec > ,
62
+ block_spec : & BlockSpec ,
58
63
state_overrides : & StateOverrides ,
59
64
) -> Result < ExecutableTransaction , ProviderError < LoggerErrorT > > {
60
65
resolve_call_request_inner (
@@ -78,7 +83,7 @@ pub(crate) fn resolve_call_request<LoggerErrorT: Debug>(
78
83
pub ( crate ) fn resolve_call_request_inner < LoggerErrorT : Debug > (
79
84
data : & mut ProviderData < LoggerErrorT > ,
80
85
request : CallRequest ,
81
- block_spec : Option < & BlockSpec > ,
86
+ block_spec : & BlockSpec ,
82
87
state_overrides : & StateOverrides ,
83
88
default_gas_price_fn : impl FnOnce (
84
89
& ProviderData < LoggerErrorT > ,
@@ -108,7 +113,7 @@ pub(crate) fn resolve_call_request_inner<LoggerErrorT: Debug>(
108
113
let from = from. unwrap_or_else ( || data. default_caller ( ) ) ;
109
114
let gas_limit = gas. unwrap_or_else ( || data. block_gas_limit ( ) ) ;
110
115
let input = input. map_or ( Bytes :: new ( ) , Bytes :: from) ;
111
- let nonce = data. nonce ( & from, block_spec, state_overrides) ?;
116
+ let nonce = data. nonce ( & from, Some ( block_spec) , state_overrides) ?;
112
117
let value = value. unwrap_or ( U256 :: ZERO ) ;
113
118
114
119
let transaction = if data. spec_id ( ) < SpecId :: LONDON || gas_price. is_some ( ) {
@@ -179,7 +184,7 @@ mod tests {
179
184
let resolved = resolve_call_request_inner (
180
185
& mut fixture. provider_data ,
181
186
request,
182
- Some ( & BlockSpec :: pending ( ) ) ,
187
+ & BlockSpec :: pending ( ) ,
183
188
& StateOverrides :: default ( ) ,
184
189
|_data| unreachable ! ( "gas_price is set" ) ,
185
190
|_, _, _| unreachable ! ( "gas_price is set" ) ,
@@ -208,7 +213,7 @@ mod tests {
208
213
let resolved = resolve_call_request_inner (
209
214
& mut fixture. provider_data ,
210
215
request,
211
- Some ( & BlockSpec :: pending ( ) ) ,
216
+ & BlockSpec :: pending ( ) ,
212
217
& StateOverrides :: default ( ) ,
213
218
|_data| unreachable ! ( "max fees are set" ) ,
214
219
|_, max_fee_per_gas, max_priority_fee_per_gas| {
0 commit comments