@nomicfoundation/edr 0.12.0-next.4 → 0.12.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +27 -11
- package/package.json +8 -8
- package/src/account.rs +1 -1
- package/src/chains/generic.rs +21 -17
- package/src/chains/l1.rs +81 -76
- package/src/chains/op.rs +37 -31
- package/src/config.rs +111 -6
- package/src/context.rs +37 -56
- package/src/log.rs +2 -2
- package/src/mock/time.rs +55 -63
- package/src/mock.rs +2 -1
- package/src/provider/response.rs +4 -4
- package/src/result.rs +24 -69
- package/src/solidity_tests/l1.rs +6 -6
- package/src/solidity_tests/op.rs +4 -4
- package/src/solidity_tests/runner.rs +1 -1
- package/src/trace/exit.rs +9 -8
- package/src/trace/return_data.rs +16 -2
- package/src/trace.rs +5 -4
package/index.d.ts
CHANGED
|
@@ -162,6 +162,20 @@ export const FJORD: string
|
|
|
162
162
|
export const GRANITE: string
|
|
163
163
|
export const HOLOCENE: string
|
|
164
164
|
export const ISTHMUS: string
|
|
165
|
+
/** Configuration for EIP-1559 parameters */
|
|
166
|
+
export interface BaseFeeParamActivation {
|
|
167
|
+
activation: BaseFeeActivationByBlockNumber | BaseFeeActivationByHardfork
|
|
168
|
+
maxChangeDenominator: bigint
|
|
169
|
+
elasticityMultiplier: bigint
|
|
170
|
+
}
|
|
171
|
+
export interface BaseFeeActivationByBlockNumber {
|
|
172
|
+
/** The block number at which the base_fee_params is activated */
|
|
173
|
+
blockNumber: bigint
|
|
174
|
+
}
|
|
175
|
+
export interface BaseFeeActivationByHardfork {
|
|
176
|
+
/** The hardfork at which the base_fee_params is activated */
|
|
177
|
+
hardfork: string
|
|
178
|
+
}
|
|
165
179
|
/** Specification of a chain with possible overrides. */
|
|
166
180
|
export interface ChainOverride {
|
|
167
181
|
/** The chain ID */
|
|
@@ -255,6 +269,17 @@ export interface ProviderConfig {
|
|
|
255
269
|
bailOnCallFailure: boolean
|
|
256
270
|
/** Whether to return an `Err` when a `eth_sendTransaction` fails */
|
|
257
271
|
bailOnTransactionFailure: boolean
|
|
272
|
+
/**
|
|
273
|
+
* EIP-1559 base fee parameters activations to be used to calculate the
|
|
274
|
+
* block base fee.
|
|
275
|
+
*
|
|
276
|
+
* Provide an ordered list of base_fee_params to be
|
|
277
|
+
* used starting from the specified activation point (hardfork or block
|
|
278
|
+
* number).
|
|
279
|
+
* If not provided, the default values from the chain spec
|
|
280
|
+
* will be used.
|
|
281
|
+
*/
|
|
282
|
+
baseFeeConfig?: Array<BaseFeeParamActivation>
|
|
258
283
|
/** The gas limit of each block */
|
|
259
284
|
blockGasLimit: bigint
|
|
260
285
|
/** The chain ID of the blockchain */
|
|
@@ -405,8 +430,7 @@ export enum SuccessReason {
|
|
|
405
430
|
/** The opcode `RETURN` was called */
|
|
406
431
|
Return = 1,
|
|
407
432
|
/** The opcode `SELFDESTRUCT` was called */
|
|
408
|
-
SelfDestruct = 2
|
|
409
|
-
EofReturnContract = 3
|
|
433
|
+
SelfDestruct = 2
|
|
410
434
|
}
|
|
411
435
|
export interface CallOutput {
|
|
412
436
|
/** Return value */
|
|
@@ -459,15 +483,7 @@ export enum ExceptionalHalt {
|
|
|
459
483
|
/** Error on created contract that begins with EF */
|
|
460
484
|
CreateContractStartingWithEF = 12,
|
|
461
485
|
/** EIP-3860: Limit and meter initcode. Initcode size limit exceeded. */
|
|
462
|
-
CreateInitCodeSizeLimit = 13
|
|
463
|
-
/** Aux data overflow, new aux data is larger tha u16 max size. */
|
|
464
|
-
EofAuxDataOverflow = 14,
|
|
465
|
-
/** Aud data is smaller then already present data size. */
|
|
466
|
-
EofAuxDataTooSmall = 15,
|
|
467
|
-
/** EOF Subroutine stack overflow */
|
|
468
|
-
SubRoutineStackOverflow = 16,
|
|
469
|
-
/** Check for target address validity is only done inside subcall. */
|
|
470
|
-
InvalidEXTCALLTarget = 17
|
|
486
|
+
CreateInitCodeSizeLimit = 13
|
|
471
487
|
}
|
|
472
488
|
/** The result when the EVM terminates due to an exceptional halt. */
|
|
473
489
|
export interface HaltResult {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/edr",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.6",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@napi-rs/cli": "^2.18.4",
|
|
6
6
|
"@nomicfoundation/ethereumjs-util": "^9.0.4",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"repository": "NomicFoundation/edr.git",
|
|
60
60
|
"types": "index.d.ts",
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.
|
|
63
|
-
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.
|
|
64
|
-
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.
|
|
65
|
-
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.
|
|
66
|
-
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.
|
|
67
|
-
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.
|
|
68
|
-
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.
|
|
62
|
+
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.6",
|
|
63
|
+
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.6",
|
|
64
|
+
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.6",
|
|
65
|
+
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.6",
|
|
66
|
+
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.6",
|
|
67
|
+
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.6",
|
|
68
|
+
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.6"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"artifacts": "napi artifacts",
|
package/src/account.rs
CHANGED
|
@@ -53,7 +53,7 @@ impl TryFrom<AccountOverride> for (edr_eth::Address, edr_provider::AccountOverri
|
|
|
53
53
|
.into_iter()
|
|
54
54
|
.map(|StorageSlot { index, value }| {
|
|
55
55
|
let value = value.try_cast()?;
|
|
56
|
-
let slot = edr_evm::state::EvmStorageSlot::new(value);
|
|
56
|
+
let slot = edr_evm::state::EvmStorageSlot::new(value, 0);
|
|
57
57
|
|
|
58
58
|
let index: edr_eth::U256 = index.try_cast()?;
|
|
59
59
|
Ok((index, slot))
|
package/src/chains/generic.rs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
use std::sync::Arc;
|
|
2
2
|
|
|
3
|
-
use edr_eth::l1;
|
|
4
3
|
use edr_generic::GenericChainSpec;
|
|
5
4
|
use edr_napi_core::{
|
|
6
|
-
logger::
|
|
7
|
-
provider::{
|
|
8
|
-
subscription,
|
|
5
|
+
logger::Logger,
|
|
6
|
+
provider::{SyncProvider, SyncProviderFactory},
|
|
7
|
+
subscription::subscriber_callback_for_chain_spec,
|
|
9
8
|
};
|
|
10
9
|
use edr_provider::time::CurrentTime;
|
|
11
10
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
11
|
+
use napi::tokio::runtime;
|
|
12
12
|
use napi_derive::napi;
|
|
13
13
|
|
|
14
14
|
use crate::provider::ProviderFactory;
|
|
@@ -16,31 +16,35 @@ use crate::provider::ProviderFactory;
|
|
|
16
16
|
pub struct GenericChainProviderFactory;
|
|
17
17
|
|
|
18
18
|
impl SyncProviderFactory for GenericChainProviderFactory {
|
|
19
|
-
fn
|
|
19
|
+
fn create_provider(
|
|
20
20
|
&self,
|
|
21
|
-
|
|
21
|
+
runtime: runtime::Handle,
|
|
22
22
|
provider_config: edr_napi_core::provider::Config,
|
|
23
|
-
logger_config: logger::Config,
|
|
24
|
-
|
|
23
|
+
logger_config: edr_napi_core::logger::Config,
|
|
24
|
+
subscription_callback: edr_napi_core::subscription::Callback,
|
|
25
25
|
contract_decoder: Arc<ContractDecoder>,
|
|
26
|
-
) -> napi::Result<
|
|
26
|
+
) -> napi::Result<Arc<dyn SyncProvider>> {
|
|
27
27
|
let logger = Logger::<GenericChainSpec, CurrentTime>::new(
|
|
28
28
|
logger_config,
|
|
29
29
|
Arc::clone(&contract_decoder),
|
|
30
30
|
)?;
|
|
31
31
|
|
|
32
32
|
let provider_config =
|
|
33
|
-
edr_provider::ProviderConfig::<
|
|
33
|
+
edr_provider::ProviderConfig::<edr_chain_l1::Hardfork>::try_from(provider_config)?;
|
|
34
34
|
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Ok(Box::new(ProviderBuilder::new(
|
|
39
|
-
contract_decoder,
|
|
35
|
+
let provider = edr_provider::Provider::<GenericChainSpec>::new(
|
|
36
|
+
runtime.clone(),
|
|
40
37
|
Box::new(logger),
|
|
38
|
+
subscriber_callback_for_chain_spec::<GenericChainSpec, CurrentTime>(
|
|
39
|
+
subscription_callback,
|
|
40
|
+
),
|
|
41
41
|
provider_config,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
contract_decoder,
|
|
43
|
+
CurrentTime,
|
|
44
|
+
)
|
|
45
|
+
.map_err(|error| napi::Error::new(napi::Status::GenericFailure, error.to_string()))?;
|
|
46
|
+
|
|
47
|
+
Ok(Arc::new(provider))
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
|
package/src/chains/l1.rs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
use std::{str::FromStr, sync::Arc};
|
|
2
2
|
|
|
3
|
-
use
|
|
3
|
+
use edr_chain_l1::L1ChainSpec;
|
|
4
4
|
use edr_evm::eips::{
|
|
5
5
|
eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_UNSUPPORTED_BYTECODE},
|
|
6
6
|
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_BYTECODE},
|
|
7
7
|
};
|
|
8
8
|
use edr_napi_core::{
|
|
9
9
|
logger::Logger,
|
|
10
|
-
provider::{
|
|
11
|
-
subscription,
|
|
10
|
+
provider::{SyncProvider, SyncProviderFactory},
|
|
11
|
+
subscription::subscriber_callback_for_chain_spec,
|
|
12
12
|
};
|
|
13
13
|
use edr_provider::time::CurrentTime;
|
|
14
14
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
15
|
-
use napi::
|
|
15
|
+
use napi::{
|
|
16
|
+
bindgen_prelude::{BigInt, Uint8Array},
|
|
17
|
+
tokio::runtime,
|
|
18
|
+
};
|
|
16
19
|
use napi_derive::napi;
|
|
17
20
|
|
|
18
21
|
use crate::{account::AccountOverride, provider::ProviderFactory};
|
|
@@ -20,34 +23,36 @@ use crate::{account::AccountOverride, provider::ProviderFactory};
|
|
|
20
23
|
pub struct L1ProviderFactory;
|
|
21
24
|
|
|
22
25
|
impl SyncProviderFactory for L1ProviderFactory {
|
|
23
|
-
fn
|
|
26
|
+
fn create_provider(
|
|
24
27
|
&self,
|
|
25
|
-
|
|
28
|
+
runtime: runtime::Handle,
|
|
26
29
|
provider_config: edr_napi_core::provider::Config,
|
|
27
30
|
logger_config: edr_napi_core::logger::Config,
|
|
28
|
-
|
|
31
|
+
subscription_callback: edr_napi_core::subscription::Callback,
|
|
29
32
|
contract_decoder: Arc<ContractDecoder>,
|
|
30
|
-
) -> napi::Result<
|
|
33
|
+
) -> napi::Result<Arc<dyn SyncProvider>> {
|
|
31
34
|
let logger =
|
|
32
35
|
Logger::<L1ChainSpec, CurrentTime>::new(logger_config, Arc::clone(&contract_decoder))?;
|
|
33
36
|
|
|
34
37
|
let provider_config =
|
|
35
|
-
edr_provider::ProviderConfig::<
|
|
36
|
-
|
|
37
|
-
let subscription_callback =
|
|
38
|
-
subscription::Callback::new(env, subscription_config.subscription_callback)?;
|
|
38
|
+
edr_provider::ProviderConfig::<edr_chain_l1::Hardfork>::try_from(provider_config)?;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
let provider = edr_provider::Provider::<L1ChainSpec>::new(
|
|
41
|
+
runtime.clone(),
|
|
42
42
|
Box::new(logger),
|
|
43
|
+
subscriber_callback_for_chain_spec::<L1ChainSpec, CurrentTime>(subscription_callback),
|
|
43
44
|
provider_config,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
contract_decoder,
|
|
46
|
+
CurrentTime,
|
|
47
|
+
)
|
|
48
|
+
.map_err(|error| napi::Error::new(napi::Status::GenericFailure, error.to_string()))?;
|
|
49
|
+
|
|
50
|
+
Ok(Arc::new(provider))
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
#[napi]
|
|
50
|
-
pub const L1_CHAIN_TYPE: &str =
|
|
55
|
+
pub const L1_CHAIN_TYPE: &str = edr_chain_l1::CHAIN_TYPE;
|
|
51
56
|
|
|
52
57
|
#[napi(catch_unwind)]
|
|
53
58
|
pub fn l1_genesis_state(hardfork: SpecId) -> Vec<AccountOverride> {
|
|
@@ -137,25 +142,25 @@ impl FromStr for SpecId {
|
|
|
137
142
|
|
|
138
143
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
139
144
|
match s {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
edr_chain_l1::hardfork::name::FRONTIER => Ok(SpecId::Frontier),
|
|
146
|
+
edr_chain_l1::hardfork::name::FRONTIER_THAWING => Ok(SpecId::FrontierThawing),
|
|
147
|
+
edr_chain_l1::hardfork::name::HOMESTEAD => Ok(SpecId::Homestead),
|
|
148
|
+
edr_chain_l1::hardfork::name::DAO_FORK => Ok(SpecId::DaoFork),
|
|
149
|
+
edr_chain_l1::hardfork::name::TANGERINE => Ok(SpecId::Tangerine),
|
|
150
|
+
edr_chain_l1::hardfork::name::SPURIOUS_DRAGON => Ok(SpecId::SpuriousDragon),
|
|
151
|
+
edr_chain_l1::hardfork::name::BYZANTIUM => Ok(SpecId::Byzantium),
|
|
152
|
+
edr_chain_l1::hardfork::name::CONSTANTINOPLE => Ok(SpecId::Constantinople),
|
|
153
|
+
edr_chain_l1::hardfork::name::PETERSBURG => Ok(SpecId::Petersburg),
|
|
154
|
+
edr_chain_l1::hardfork::name::ISTANBUL => Ok(SpecId::Istanbul),
|
|
155
|
+
edr_chain_l1::hardfork::name::MUIR_GLACIER => Ok(SpecId::MuirGlacier),
|
|
156
|
+
edr_chain_l1::hardfork::name::BERLIN => Ok(SpecId::Berlin),
|
|
157
|
+
edr_chain_l1::hardfork::name::LONDON => Ok(SpecId::London),
|
|
158
|
+
edr_chain_l1::hardfork::name::ARROW_GLACIER => Ok(SpecId::ArrowGlacier),
|
|
159
|
+
edr_chain_l1::hardfork::name::GRAY_GLACIER => Ok(SpecId::GrayGlacier),
|
|
160
|
+
edr_chain_l1::hardfork::name::MERGE => Ok(SpecId::Merge),
|
|
161
|
+
edr_chain_l1::hardfork::name::SHANGHAI => Ok(SpecId::Shanghai),
|
|
162
|
+
edr_chain_l1::hardfork::name::CANCUN => Ok(SpecId::Cancun),
|
|
163
|
+
edr_chain_l1::hardfork::name::PRAGUE => Ok(SpecId::Prague),
|
|
159
164
|
_ => Err(napi::Error::new(
|
|
160
165
|
napi::Status::InvalidArg,
|
|
161
166
|
format!("The provided hardfork `{s}` is not supported."),
|
|
@@ -164,28 +169,28 @@ impl FromStr for SpecId {
|
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
impl From<SpecId> for
|
|
172
|
+
impl From<SpecId> for edr_chain_l1::Hardfork {
|
|
168
173
|
fn from(value: SpecId) -> Self {
|
|
169
174
|
match value {
|
|
170
|
-
SpecId::Frontier =>
|
|
171
|
-
SpecId::FrontierThawing =>
|
|
172
|
-
SpecId::Homestead =>
|
|
173
|
-
SpecId::DaoFork =>
|
|
174
|
-
SpecId::Tangerine =>
|
|
175
|
-
SpecId::SpuriousDragon =>
|
|
176
|
-
SpecId::Byzantium =>
|
|
177
|
-
SpecId::Constantinople =>
|
|
178
|
-
SpecId::Petersburg =>
|
|
179
|
-
SpecId::Istanbul =>
|
|
180
|
-
SpecId::MuirGlacier =>
|
|
181
|
-
SpecId::Berlin =>
|
|
182
|
-
SpecId::London =>
|
|
183
|
-
SpecId::ArrowGlacier =>
|
|
184
|
-
SpecId::GrayGlacier =>
|
|
185
|
-
SpecId::Merge =>
|
|
186
|
-
SpecId::Shanghai =>
|
|
187
|
-
SpecId::Cancun =>
|
|
188
|
-
SpecId::Prague =>
|
|
175
|
+
SpecId::Frontier => edr_chain_l1::Hardfork::FRONTIER,
|
|
176
|
+
SpecId::FrontierThawing => edr_chain_l1::Hardfork::FRONTIER_THAWING,
|
|
177
|
+
SpecId::Homestead => edr_chain_l1::Hardfork::HOMESTEAD,
|
|
178
|
+
SpecId::DaoFork => edr_chain_l1::Hardfork::DAO_FORK,
|
|
179
|
+
SpecId::Tangerine => edr_chain_l1::Hardfork::TANGERINE,
|
|
180
|
+
SpecId::SpuriousDragon => edr_chain_l1::Hardfork::SPURIOUS_DRAGON,
|
|
181
|
+
SpecId::Byzantium => edr_chain_l1::Hardfork::BYZANTIUM,
|
|
182
|
+
SpecId::Constantinople => edr_chain_l1::Hardfork::CONSTANTINOPLE,
|
|
183
|
+
SpecId::Petersburg => edr_chain_l1::Hardfork::PETERSBURG,
|
|
184
|
+
SpecId::Istanbul => edr_chain_l1::Hardfork::ISTANBUL,
|
|
185
|
+
SpecId::MuirGlacier => edr_chain_l1::Hardfork::MUIR_GLACIER,
|
|
186
|
+
SpecId::Berlin => edr_chain_l1::Hardfork::BERLIN,
|
|
187
|
+
SpecId::London => edr_chain_l1::Hardfork::LONDON,
|
|
188
|
+
SpecId::ArrowGlacier => edr_chain_l1::Hardfork::ARROW_GLACIER,
|
|
189
|
+
SpecId::GrayGlacier => edr_chain_l1::Hardfork::GRAY_GLACIER,
|
|
190
|
+
SpecId::Merge => edr_chain_l1::Hardfork::MERGE,
|
|
191
|
+
SpecId::Shanghai => edr_chain_l1::Hardfork::SHANGHAI,
|
|
192
|
+
SpecId::Cancun => edr_chain_l1::Hardfork::CANCUN,
|
|
193
|
+
SpecId::Prague => edr_chain_l1::Hardfork::PRAGUE,
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
196
|
}
|
|
@@ -201,25 +206,25 @@ pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result<SpecId> {
|
|
|
201
206
|
#[napi(catch_unwind)]
|
|
202
207
|
pub fn l1_hardfork_to_string(harfork: SpecId) -> &'static str {
|
|
203
208
|
match harfork {
|
|
204
|
-
SpecId::Frontier =>
|
|
205
|
-
SpecId::FrontierThawing =>
|
|
206
|
-
SpecId::Homestead =>
|
|
207
|
-
SpecId::DaoFork =>
|
|
208
|
-
SpecId::Tangerine =>
|
|
209
|
-
SpecId::SpuriousDragon =>
|
|
210
|
-
SpecId::Byzantium =>
|
|
211
|
-
SpecId::Constantinople =>
|
|
212
|
-
SpecId::Petersburg =>
|
|
213
|
-
SpecId::Istanbul =>
|
|
214
|
-
SpecId::MuirGlacier =>
|
|
215
|
-
SpecId::Berlin =>
|
|
216
|
-
SpecId::London =>
|
|
217
|
-
SpecId::ArrowGlacier =>
|
|
218
|
-
SpecId::GrayGlacier =>
|
|
219
|
-
SpecId::Merge =>
|
|
220
|
-
SpecId::Shanghai =>
|
|
221
|
-
SpecId::Cancun =>
|
|
222
|
-
SpecId::Prague =>
|
|
209
|
+
SpecId::Frontier => edr_chain_l1::hardfork::name::FRONTIER,
|
|
210
|
+
SpecId::FrontierThawing => edr_chain_l1::hardfork::name::FRONTIER_THAWING,
|
|
211
|
+
SpecId::Homestead => edr_chain_l1::hardfork::name::HOMESTEAD,
|
|
212
|
+
SpecId::DaoFork => edr_chain_l1::hardfork::name::DAO_FORK,
|
|
213
|
+
SpecId::Tangerine => edr_chain_l1::hardfork::name::TANGERINE,
|
|
214
|
+
SpecId::SpuriousDragon => edr_chain_l1::hardfork::name::SPURIOUS_DRAGON,
|
|
215
|
+
SpecId::Byzantium => edr_chain_l1::hardfork::name::BYZANTIUM,
|
|
216
|
+
SpecId::Constantinople => edr_chain_l1::hardfork::name::CONSTANTINOPLE,
|
|
217
|
+
SpecId::Petersburg => edr_chain_l1::hardfork::name::PETERSBURG,
|
|
218
|
+
SpecId::Istanbul => edr_chain_l1::hardfork::name::ISTANBUL,
|
|
219
|
+
SpecId::MuirGlacier => edr_chain_l1::hardfork::name::MUIR_GLACIER,
|
|
220
|
+
SpecId::Berlin => edr_chain_l1::hardfork::name::BERLIN,
|
|
221
|
+
SpecId::London => edr_chain_l1::hardfork::name::LONDON,
|
|
222
|
+
SpecId::ArrowGlacier => edr_chain_l1::hardfork::name::ARROW_GLACIER,
|
|
223
|
+
SpecId::GrayGlacier => edr_chain_l1::hardfork::name::GRAY_GLACIER,
|
|
224
|
+
SpecId::Merge => edr_chain_l1::hardfork::name::MERGE,
|
|
225
|
+
SpecId::Shanghai => edr_chain_l1::hardfork::name::SHANGHAI,
|
|
226
|
+
SpecId::Cancun => edr_chain_l1::hardfork::name::CANCUN,
|
|
227
|
+
SpecId::Prague => edr_chain_l1::hardfork::name::PRAGUE,
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
|
|
@@ -235,7 +240,7 @@ macro_rules! export_spec_id {
|
|
|
235
240
|
($($variant:ident),*) => {
|
|
236
241
|
$(
|
|
237
242
|
#[napi]
|
|
238
|
-
pub const $variant: &str =
|
|
243
|
+
pub const $variant: &str = edr_chain_l1::hardfork::name::$variant;
|
|
239
244
|
)*
|
|
240
245
|
};
|
|
241
246
|
}
|
package/src/chains/op.rs
CHANGED
|
@@ -2,14 +2,17 @@ use std::{str::FromStr, sync::Arc};
|
|
|
2
2
|
|
|
3
3
|
use edr_eth::hex;
|
|
4
4
|
use edr_napi_core::{
|
|
5
|
-
logger::
|
|
6
|
-
provider::{
|
|
7
|
-
subscription,
|
|
5
|
+
logger::Logger,
|
|
6
|
+
provider::{SyncProvider, SyncProviderFactory},
|
|
7
|
+
subscription::subscriber_callback_for_chain_spec,
|
|
8
8
|
};
|
|
9
|
-
use edr_op::{predeploys::GAS_PRICE_ORACLE_ADDRESS, OpChainSpec
|
|
9
|
+
use edr_op::{predeploys::GAS_PRICE_ORACLE_ADDRESS, OpChainSpec};
|
|
10
10
|
use edr_provider::time::CurrentTime;
|
|
11
11
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
12
|
-
use napi::
|
|
12
|
+
use napi::{
|
|
13
|
+
bindgen_prelude::{BigInt, Uint8Array},
|
|
14
|
+
tokio::runtime,
|
|
15
|
+
};
|
|
13
16
|
use napi_derive::napi;
|
|
14
17
|
|
|
15
18
|
use crate::{
|
|
@@ -20,28 +23,31 @@ use crate::{
|
|
|
20
23
|
pub struct OpProviderFactory;
|
|
21
24
|
|
|
22
25
|
impl SyncProviderFactory for OpProviderFactory {
|
|
23
|
-
fn
|
|
26
|
+
fn create_provider(
|
|
24
27
|
&self,
|
|
25
|
-
|
|
26
|
-
provider_config: provider::Config,
|
|
27
|
-
logger_config: logger::Config,
|
|
28
|
-
|
|
28
|
+
runtime: runtime::Handle,
|
|
29
|
+
provider_config: edr_napi_core::provider::Config,
|
|
30
|
+
logger_config: edr_napi_core::logger::Config,
|
|
31
|
+
subscription_callback: edr_napi_core::subscription::Callback,
|
|
29
32
|
contract_decoder: Arc<ContractDecoder>,
|
|
30
|
-
) -> napi::Result<
|
|
33
|
+
) -> napi::Result<Arc<dyn SyncProvider>> {
|
|
31
34
|
let logger =
|
|
32
35
|
Logger::<OpChainSpec, CurrentTime>::new(logger_config, Arc::clone(&contract_decoder))?;
|
|
33
36
|
|
|
34
|
-
let provider_config =
|
|
35
|
-
|
|
36
|
-
let subscription_callback =
|
|
37
|
-
subscription::Callback::new(env, subscription_config.subscription_callback)?;
|
|
37
|
+
let provider_config =
|
|
38
|
+
edr_provider::ProviderConfig::<edr_op::Hardfork>::try_from(provider_config)?;
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
let provider = edr_provider::Provider::<OpChainSpec>::new(
|
|
41
|
+
runtime.clone(),
|
|
41
42
|
Box::new(logger),
|
|
43
|
+
subscriber_callback_for_chain_spec::<OpChainSpec, CurrentTime>(subscription_callback),
|
|
42
44
|
provider_config,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
contract_decoder,
|
|
46
|
+
CurrentTime,
|
|
47
|
+
)
|
|
48
|
+
.map_err(|error| napi::Error::new(napi::Status::GenericFailure, error.to_string()))?;
|
|
49
|
+
|
|
50
|
+
Ok(Arc::new(provider))
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -58,17 +64,17 @@ pub enum OpHardfork {
|
|
|
58
64
|
Isthmus = 107,
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
impl From<OpHardfork> for
|
|
67
|
+
impl From<OpHardfork> for edr_op::Hardfork {
|
|
62
68
|
fn from(hardfork: OpHardfork) -> Self {
|
|
63
69
|
match hardfork {
|
|
64
|
-
OpHardfork::Bedrock =>
|
|
65
|
-
OpHardfork::Regolith =>
|
|
66
|
-
OpHardfork::Canyon =>
|
|
67
|
-
OpHardfork::Ecotone =>
|
|
68
|
-
OpHardfork::Fjord =>
|
|
69
|
-
OpHardfork::Granite =>
|
|
70
|
-
OpHardfork::Holocene =>
|
|
71
|
-
OpHardfork::Isthmus =>
|
|
70
|
+
OpHardfork::Bedrock => edr_op::Hardfork::BEDROCK,
|
|
71
|
+
OpHardfork::Regolith => edr_op::Hardfork::REGOLITH,
|
|
72
|
+
OpHardfork::Canyon => edr_op::Hardfork::CANYON,
|
|
73
|
+
OpHardfork::Ecotone => edr_op::Hardfork::ECOTONE,
|
|
74
|
+
OpHardfork::Fjord => edr_op::Hardfork::FJORD,
|
|
75
|
+
OpHardfork::Granite => edr_op::Hardfork::GRANITE,
|
|
76
|
+
OpHardfork::Holocene => edr_op::Hardfork::HOLOCENE,
|
|
77
|
+
OpHardfork::Isthmus => edr_op::Hardfork::ISTHMUS,
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -330,10 +336,10 @@ pub fn op_provider_factory() -> ProviderFactory {
|
|
|
330
336
|
factory.into()
|
|
331
337
|
}
|
|
332
338
|
|
|
333
|
-
fn gas_price_oracle_override(hardfork:
|
|
334
|
-
if hardfork >=
|
|
339
|
+
fn gas_price_oracle_override(hardfork: edr_op::Hardfork) -> AccountOverride {
|
|
340
|
+
if hardfork >= edr_op::Hardfork::ISTHMUS {
|
|
335
341
|
gas_price_oracle_isthmus()
|
|
336
|
-
} else if hardfork >=
|
|
342
|
+
} else if hardfork >= edr_op::Hardfork::FJORD {
|
|
337
343
|
gas_price_oracle_fjord()
|
|
338
344
|
} else {
|
|
339
345
|
gas_price_oracle_ecotone()
|