hardhat 2.20.0 → 2.21.0-dev.0
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/internal/core/jsonrpc/types/input/blockTag.d.ts +3 -3
- package/internal/core/jsonrpc/types/input/filterRequest.d.ts +6 -6
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +28 -4
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -0
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +2 -1
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts +0 -2
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +0 -16
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +9 -1
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.d.ts +5 -5
- package/internal/hardhat-network/provider/BlockchainData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.js +10 -10
- package/internal/hardhat-network/provider/BlockchainData.js.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +0 -7
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.js +2 -14
- package/internal/hardhat-network/provider/HardhatBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/TxPool.d.ts +3 -2
- package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
- package/internal/hardhat-network/provider/TxPool.js +16 -16
- package/internal/hardhat-network/provider/TxPool.js.map +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +1 -1
- package/internal/hardhat-network/provider/filter.d.ts +6 -5
- package/internal/hardhat-network/provider/filter.d.ts.map +1 -1
- package/internal/hardhat-network/provider/filter.js +2 -2
- package/internal/hardhat-network/provider/filter.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +0 -7
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +4 -21
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +13 -19
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.js +61 -59
- package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js +0 -3
- package/internal/hardhat-network/provider/fork/rpcToBlockData.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +2 -2
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +1 -1
- package/internal/hardhat-network/provider/modules/base.js +4 -4
- package/internal/hardhat-network/provider/modules/base.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +9 -16
- package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.d.ts +6 -84
- package/internal/hardhat-network/provider/modules/logger.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.js +3 -530
- package/internal/hardhat-network/provider/modules/logger.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +2 -65
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node-types.js +0 -5
- package/internal/hardhat-network/provider/node-types.js.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +2 -6
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +79 -148
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +0 -14
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/output.js +0 -264
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +26 -25
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +342 -186
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +10 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +10 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +9 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +10 -9
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +7 -6
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +6 -5
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +5 -4
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +8 -7
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts +8 -7
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +5 -4
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts +14 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.js +191 -0
- package/internal/hardhat-network/provider/utils/convertToEdr.js.map +1 -0
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.d.ts +0 -1
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.js +1 -5
- package/internal/hardhat-network/provider/utils/getCurrentTimestamp.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.js +1 -3
- package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +2 -2
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +1 -15
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts +10 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.js +38 -18
- package/internal/hardhat-network/provider/utils/makeForkClient.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.js +2 -2
- package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +3 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -6
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/utils/random.d.ts +1 -0
- package/internal/hardhat-network/provider/utils/random.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/random.js +7 -1
- package/internal/hardhat-network/provider/utils/random.js.map +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/reorgs-protection.js +5 -5
- package/internal/hardhat-network/provider/utils/reorgs-protection.js.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts +22 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.js +93 -0
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts +29 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.js +46 -0
- package/internal/hardhat-network/provider/vm/minimal-vm.js.map +1 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts +36 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.js +73 -0
- package/internal/hardhat-network/provider/vm/proxy-vm.js.map +1 -0
- package/internal/hardhat-network/provider/vm/types.d.ts +27 -0
- package/internal/hardhat-network/provider/vm/types.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/types.js +3 -0
- package/internal/hardhat-network/provider/vm/types.js.map +1 -0
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts +6 -0
- package/internal/hardhat-network/stack-traces/consoleLogger.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js +33 -16
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts +1 -2
- package/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js +6 -7
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +6 -6
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +13 -7
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +8 -3
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.js +22 -1
- package/internal/hardhat-network/stack-traces/message-trace.js.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +8 -0
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +52 -0
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/opcodes.d.ts +1 -0
- package/internal/hardhat-network/stack-traces/opcodes.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/opcodes.js +5 -1
- package/internal/hardhat-network/stack-traces/opcodes.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +2 -2
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +5 -5
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +28 -34
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts +7 -0
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js +69 -2
- package/internal/hardhat-network/stack-traces/vm-trace-decoder.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +7 -12
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +46 -65
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/internal/util/date.d.ts +1 -0
- package/internal/util/date.d.ts.map +1 -1
- package/internal/util/date.js +5 -1
- package/internal/util/date.js.map +1 -1
- package/internal/util/hardforks.d.ts +2 -0
- package/internal/util/hardforks.d.ts.map +1 -1
- package/internal/util/hardforks.js +27 -1
- package/internal/util/hardforks.js.map +1 -1
- package/package.json +18 -16
- package/src/internal/core/providers/construction.ts +7 -9
- package/src/internal/core/providers/http.ts +3 -1
- package/src/internal/core/runtime-environment.ts +2 -1
- package/src/internal/hardhat-network/jsonrpc/client.ts +1 -28
- package/src/internal/hardhat-network/jsonrpc/handler.ts +9 -1
- package/src/internal/hardhat-network/provider/modules/logger.ts +6 -801
- package/src/internal/hardhat-network/provider/node-types.ts +2 -89
- package/src/internal/hardhat-network/provider/output.ts +0 -352
- package/src/internal/hardhat-network/provider/provider.ts +482 -263
- package/src/internal/hardhat-network/provider/utils/convertToEdr.ts +228 -0
- package/src/internal/hardhat-network/provider/utils/getCurrentTimestamp.ts +0 -4
- package/src/internal/hardhat-network/provider/utils/makeCommon.ts +1 -12
- package/src/internal/hardhat-network/provider/utils/makeForkClient.ts +63 -24
- package/src/internal/hardhat-network/provider/utils/random.ts +8 -1
- package/src/internal/hardhat-network/provider/utils/reorgs-protection.ts +5 -5
- package/src/internal/hardhat-network/provider/vm/exit.ts +101 -0
- package/src/internal/hardhat-network/provider/vm/minimal-vm.ts +101 -0
- package/src/internal/hardhat-network/provider/vm/types.ts +31 -0
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +40 -21
- package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +10 -12
- package/src/internal/hardhat-network/stack-traces/debug.ts +6 -6
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +15 -8
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +40 -4
- package/src/internal/hardhat-network/stack-traces/model.ts +61 -0
- package/src/internal/hardhat-network/stack-traces/opcodes.ts +4 -0
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +6 -5
- package/src/internal/hardhat-network/stack-traces/vm-trace-decoder.ts +113 -4
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +67 -95
- package/src/internal/util/date.ts +4 -0
- package/src/internal/util/hardforks.ts +52 -0
- package/src/internal/hardhat-network/provider/BlockchainBase.ts +0 -185
- package/src/internal/hardhat-network/provider/BlockchainData.ts +0 -261
- package/src/internal/hardhat-network/provider/HardhatBlockchain.ts +0 -140
- package/src/internal/hardhat-network/provider/PoolState.ts +0 -48
- package/src/internal/hardhat-network/provider/TransactionQueue.ts +0 -158
- package/src/internal/hardhat-network/provider/TxPool.ts +0 -715
- package/src/internal/hardhat-network/provider/ethereumjs-workarounds.ts +0 -21
- package/src/internal/hardhat-network/provider/filter.ts +0 -142
- package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +0 -433
- package/src/internal/hardhat-network/provider/fork/ForkStateManager.ts +0 -480
- package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +0 -35
- package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +0 -44
- package/src/internal/hardhat-network/provider/modules/base.ts +0 -156
- package/src/internal/hardhat-network/provider/modules/debug.ts +0 -104
- package/src/internal/hardhat-network/provider/modules/eth.ts +0 -1781
- package/src/internal/hardhat-network/provider/modules/evm.ts +0 -249
- package/src/internal/hardhat-network/provider/modules/hardhat.ts +0 -481
- package/src/internal/hardhat-network/provider/modules/net.ts +0 -60
- package/src/internal/hardhat-network/provider/modules/personal.ts +0 -40
- package/src/internal/hardhat-network/provider/modules/web3.ts +0 -49
- package/src/internal/hardhat-network/provider/node.ts +0 -2993
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +0 -226
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +0 -224
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +0 -216
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +0 -143
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +0 -144
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +0 -171
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts +0 -169
- package/src/internal/hardhat-network/provider/types/HardhatBlockchainInterface.ts +0 -25
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +0 -60
- package/src/internal/hardhat-network/provider/utils/makeStateTrie.ts +0 -29
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +0 -61
- package/src/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.ts +0 -45
- package/src/internal/hardhat-network/provider/utils/txMapToArray.ts +0 -7
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +0 -630
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EVMStateManagerInterface,
|
|
3
|
-
Proof,
|
|
4
|
-
StorageRange,
|
|
5
|
-
} from "@nomicfoundation/ethereumjs-common";
|
|
6
|
-
import {
|
|
7
|
-
Account,
|
|
8
|
-
bigIntToHex,
|
|
9
|
-
bytesToBigInt,
|
|
10
|
-
Address,
|
|
11
|
-
bytesToHex as bufferToHex,
|
|
12
|
-
equalsBytes,
|
|
13
|
-
KECCAK256_NULL,
|
|
14
|
-
toBytes,
|
|
15
|
-
unpadBytes,
|
|
16
|
-
} from "@nomicfoundation/ethereumjs-util";
|
|
17
|
-
import { Map as ImmutableMap, Record as ImmutableRecord } from "immutable";
|
|
18
|
-
|
|
19
|
-
import { assertHardhatInvariant } from "../../../core/errors";
|
|
20
|
-
import { InternalError } from "../../../core/providers/errors";
|
|
21
|
-
import { keccak256 } from "../../../util/keccak";
|
|
22
|
-
import { JsonRpcClient } from "../../jsonrpc/client";
|
|
23
|
-
import { GenesisAccount } from "../node-types";
|
|
24
|
-
import { makeAccount } from "../utils/makeAccount";
|
|
25
|
-
import { randomHash } from "../utils/random";
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
AccountState,
|
|
29
|
-
makeAccountState,
|
|
30
|
-
makeEmptyAccountState,
|
|
31
|
-
} from "./AccountState";
|
|
32
|
-
|
|
33
|
-
const encodeStorageKey = (
|
|
34
|
-
address: Uint8Array,
|
|
35
|
-
position: Uint8Array
|
|
36
|
-
): string => {
|
|
37
|
-
return `${Buffer.from(address).toString("hex")}${Buffer.from(
|
|
38
|
-
unpadBytes(position)
|
|
39
|
-
).toString("hex")}`;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
43
|
-
|
|
44
|
-
type State = ImmutableMap<string, ImmutableRecord<AccountState>>;
|
|
45
|
-
|
|
46
|
-
const checkpointedError = (method: string) =>
|
|
47
|
-
new Error(`${method} called when checkpointed`);
|
|
48
|
-
|
|
49
|
-
const notCheckpointedError = (method: string) =>
|
|
50
|
-
new Error(`${method} called when not checkpointed`);
|
|
51
|
-
|
|
52
|
-
const notSupportedError = (method: string) =>
|
|
53
|
-
new Error(`${method} is not supported when forking from remote network`);
|
|
54
|
-
|
|
55
|
-
export class ForkStateManager implements EVMStateManagerInterface {
|
|
56
|
-
private _state: State = ImmutableMap<string, ImmutableRecord<AccountState>>();
|
|
57
|
-
private _initialStateRoot: string = randomHash();
|
|
58
|
-
private _stateRoot: string = this._initialStateRoot;
|
|
59
|
-
private _stateRootToState: Map<string, State> = new Map();
|
|
60
|
-
private _originalStorageCache: Map<string, Uint8Array> = new Map();
|
|
61
|
-
private _stateCheckpoints: string[] = [];
|
|
62
|
-
private _contextBlockNumber = this._forkBlockNumber;
|
|
63
|
-
private _contextChanged = false;
|
|
64
|
-
|
|
65
|
-
public originalStorageCache: {
|
|
66
|
-
get(address: Address, key: Uint8Array): Promise<Uint8Array>;
|
|
67
|
-
clear(): void;
|
|
68
|
-
} = {
|
|
69
|
-
get: async (address: Address, key: Uint8Array): Promise<Uint8Array> => {
|
|
70
|
-
return this.getOriginalContractStorage(address, key);
|
|
71
|
-
},
|
|
72
|
-
clear: (): void => {
|
|
73
|
-
this.clearOriginalStorageCache();
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
constructor(
|
|
78
|
-
private readonly _jsonRpcClient: JsonRpcClient,
|
|
79
|
-
private readonly _forkBlockNumber: bigint
|
|
80
|
-
) {
|
|
81
|
-
this._state = ImmutableMap<string, ImmutableRecord<AccountState>>();
|
|
82
|
-
|
|
83
|
-
this._stateRootToState.set(this._initialStateRoot, this._state);
|
|
84
|
-
}
|
|
85
|
-
public dumpStorageRange(
|
|
86
|
-
_address: Address,
|
|
87
|
-
_startKey: bigint,
|
|
88
|
-
_limit: number
|
|
89
|
-
): Promise<StorageRange> {
|
|
90
|
-
throw new Error("Method not implemented.");
|
|
91
|
-
}
|
|
92
|
-
public getProof(
|
|
93
|
-
_address: Address,
|
|
94
|
-
_storageSlots?: Uint8Array[] | undefined
|
|
95
|
-
): Promise<Proof> {
|
|
96
|
-
throw new Error("Method not implemented.");
|
|
97
|
-
}
|
|
98
|
-
public shallowCopy(
|
|
99
|
-
_downlevelCaches?: boolean | undefined
|
|
100
|
-
): EVMStateManagerInterface {
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public async initializeGenesisAccounts(genesisAccounts: GenesisAccount[]) {
|
|
105
|
-
const accounts: Array<{ address: Address; account: Account }> = [];
|
|
106
|
-
const noncesPromises: Array<Promise<bigint>> = [];
|
|
107
|
-
|
|
108
|
-
for (const ga of genesisAccounts) {
|
|
109
|
-
const account = makeAccount(ga);
|
|
110
|
-
accounts.push(account);
|
|
111
|
-
|
|
112
|
-
const noncePromise = this._jsonRpcClient.getTransactionCount(
|
|
113
|
-
account.address.toBytes(),
|
|
114
|
-
this._forkBlockNumber
|
|
115
|
-
);
|
|
116
|
-
noncesPromises.push(noncePromise);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const nonces = await Promise.all(noncesPromises);
|
|
120
|
-
|
|
121
|
-
assertHardhatInvariant(
|
|
122
|
-
accounts.length === nonces.length,
|
|
123
|
-
"Nonces and accounts should have the same length"
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
for (const [index, { address, account }] of accounts.entries()) {
|
|
127
|
-
const nonce = nonces[index];
|
|
128
|
-
account.nonce = nonce;
|
|
129
|
-
this._putAccount(address, account);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this._stateRootToState.set(this._initialStateRoot, this._state);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public copy(): ForkStateManager {
|
|
136
|
-
const fsm = new ForkStateManager(
|
|
137
|
-
this._jsonRpcClient,
|
|
138
|
-
this._forkBlockNumber
|
|
139
|
-
);
|
|
140
|
-
fsm._state = this._state;
|
|
141
|
-
fsm._stateRoot = this._stateRoot;
|
|
142
|
-
|
|
143
|
-
// because this map is append-only we don't need to copy it
|
|
144
|
-
fsm._stateRootToState = this._stateRootToState;
|
|
145
|
-
return fsm;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public async getAccount(address: Address): Promise<Account> {
|
|
149
|
-
const localAccount = this._state.get(address.toString());
|
|
150
|
-
|
|
151
|
-
const localNonce = localAccount?.get("nonce");
|
|
152
|
-
const localBalance = localAccount?.get("balance");
|
|
153
|
-
const localCode = localAccount?.get("code");
|
|
154
|
-
|
|
155
|
-
let nonce: Uint8Array | bigint | undefined =
|
|
156
|
-
localNonce !== undefined ? toBytes(localNonce) : undefined;
|
|
157
|
-
|
|
158
|
-
let balance: Uint8Array | bigint | undefined =
|
|
159
|
-
localBalance !== undefined ? toBytes(localBalance) : undefined;
|
|
160
|
-
|
|
161
|
-
let code: Uint8Array | undefined =
|
|
162
|
-
localCode !== undefined ? toBytes(localCode) : undefined;
|
|
163
|
-
|
|
164
|
-
if (balance === undefined || nonce === undefined || code === undefined) {
|
|
165
|
-
const accountData = await this._jsonRpcClient.getAccountData(
|
|
166
|
-
address,
|
|
167
|
-
this._contextBlockNumber
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
if (nonce === undefined) {
|
|
171
|
-
nonce = accountData.transactionCount;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (balance === undefined) {
|
|
175
|
-
balance = accountData.balance;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (code === undefined) {
|
|
179
|
-
code = accountData.code;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const codeHash = keccak256(code);
|
|
184
|
-
// We ignore stateRoot since we found that it is not used anywhere of interest to us
|
|
185
|
-
return Account.fromAccountData({ nonce, balance, codeHash });
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public async putAccount(address: Address, account: Account): Promise<void> {
|
|
189
|
-
this._putAccount(address, account);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public touchAccount(_address: Address): void {
|
|
193
|
-
// We don't do anything here. See cleanupTouchedAccounts for explanation
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
public async putContractCode(address: Address, value: Buffer): Promise<void> {
|
|
197
|
-
const hexAddress = address.toString();
|
|
198
|
-
const account = (this._state.get(hexAddress) ?? makeAccountState()).set(
|
|
199
|
-
"code",
|
|
200
|
-
bufferToHex(value)
|
|
201
|
-
);
|
|
202
|
-
this._state = this._state.set(hexAddress, account);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public async getContractCode(address: Address): Promise<Uint8Array> {
|
|
206
|
-
const localCode = this._state.get(address.toString())?.get("code");
|
|
207
|
-
if (localCode !== undefined) {
|
|
208
|
-
return toBytes(localCode);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const accountData = await this._jsonRpcClient.getAccountData(
|
|
212
|
-
address,
|
|
213
|
-
this._contextBlockNumber
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
return accountData.code;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public async getContractStorage(
|
|
220
|
-
address: Address,
|
|
221
|
-
key: Uint8Array
|
|
222
|
-
): Promise<Uint8Array> {
|
|
223
|
-
if (key.length !== 32) {
|
|
224
|
-
throw new Error("Storage key must be 32 bytes long");
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const account = this._state.get(address.toString());
|
|
228
|
-
const contractStorageCleared = account?.get("storageCleared") ?? false;
|
|
229
|
-
const localValue = account?.get("storage").get(bufferToHex(key));
|
|
230
|
-
|
|
231
|
-
if (localValue !== undefined) {
|
|
232
|
-
return toBytes(localValue);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const slotCleared = localValue === null;
|
|
236
|
-
if (contractStorageCleared || slotCleared) {
|
|
237
|
-
return toBytes([]);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const remoteValue = await this._jsonRpcClient.getStorageAt(
|
|
241
|
-
address,
|
|
242
|
-
bytesToBigInt(key),
|
|
243
|
-
this._contextBlockNumber
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
return unpadBytes(remoteValue);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
public async putContractStorage(
|
|
250
|
-
address: Address,
|
|
251
|
-
key: Buffer,
|
|
252
|
-
value: Buffer
|
|
253
|
-
): Promise<void> {
|
|
254
|
-
if (key.length !== 32) {
|
|
255
|
-
throw new Error("Storage key must be 32 bytes long");
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (value.length > 32) {
|
|
259
|
-
throw new Error("Storage value cannot be longer than 32 bytes");
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const unpaddedValue = unpadBytes(value);
|
|
263
|
-
|
|
264
|
-
const hexAddress = address.toString();
|
|
265
|
-
let account = this._state.get(hexAddress) ?? makeAccountState();
|
|
266
|
-
const currentStorage = account.get("storage");
|
|
267
|
-
|
|
268
|
-
let newValue: string | null;
|
|
269
|
-
if (unpaddedValue.length === 0) {
|
|
270
|
-
// if the value is an empty array or only zeros, the storage is deleted
|
|
271
|
-
newValue = null;
|
|
272
|
-
} else {
|
|
273
|
-
newValue = bufferToHex(unpaddedValue);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const newStorage = currentStorage.set(bufferToHex(key), newValue);
|
|
277
|
-
|
|
278
|
-
account = account.set("storage", newStorage);
|
|
279
|
-
|
|
280
|
-
this._state = this._state.set(hexAddress, account);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
public async clearContractStorage(address: Address): Promise<void> {
|
|
284
|
-
const hexAddress = address.toString();
|
|
285
|
-
let account = this._state.get(hexAddress) ?? makeAccountState();
|
|
286
|
-
account = account
|
|
287
|
-
.set("storageCleared", true)
|
|
288
|
-
.set("storage", ImmutableMap<string, string | null>());
|
|
289
|
-
this._state = this._state.set(hexAddress, account);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
public async checkpoint(): Promise<void> {
|
|
293
|
-
const stateRoot = await this.getStateRoot();
|
|
294
|
-
this._stateCheckpoints.push(bufferToHex(stateRoot));
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
public async commit(): Promise<void> {
|
|
298
|
-
if (this._stateCheckpoints.length === 0) {
|
|
299
|
-
throw notCheckpointedError("commit");
|
|
300
|
-
}
|
|
301
|
-
this._stateCheckpoints.pop();
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
public async revert(): Promise<void> {
|
|
305
|
-
const checkpointedRoot = this._stateCheckpoints.pop();
|
|
306
|
-
if (checkpointedRoot === undefined) {
|
|
307
|
-
throw notCheckpointedError("revert");
|
|
308
|
-
}
|
|
309
|
-
await this.setStateRoot(toBytes(checkpointedRoot));
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
public async getStateRoot(): Promise<Uint8Array> {
|
|
313
|
-
if (this._stateRootToState.get(this._stateRoot) !== this._state) {
|
|
314
|
-
this._stateRoot = randomHash();
|
|
315
|
-
this._stateRootToState.set(this._stateRoot, this._state);
|
|
316
|
-
}
|
|
317
|
-
return toBytes(this._stateRoot);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public async setStateRoot(stateRoot: Uint8Array): Promise<void> {
|
|
321
|
-
this._setStateRoot(stateRoot);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
public async dumpStorage(_address: Address): Promise<Record<string, string>> {
|
|
325
|
-
throw notSupportedError("dumpStorage");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
public async hasGenesisState(): Promise<boolean> {
|
|
329
|
-
throw notSupportedError("hasGenesisState");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
public async generateCanonicalGenesis(): Promise<void> {
|
|
333
|
-
throw notSupportedError("generateCanonicalGenesis");
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
public async generateGenesis(_initState: any): Promise<void> {
|
|
337
|
-
throw notSupportedError("generateGenesis");
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
public async accountIsEmpty(address: Address): Promise<boolean> {
|
|
341
|
-
const account = await this.getAccount(address);
|
|
342
|
-
// From https://eips.ethereum.org/EIPS/eip-161
|
|
343
|
-
// An account is considered empty when it has no code and zero nonce and zero balance.
|
|
344
|
-
return (
|
|
345
|
-
account.nonce === 0n &&
|
|
346
|
-
account.balance === 0n &&
|
|
347
|
-
equalsBytes(account.codeHash, KECCAK256_NULL)
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
public async cleanupTouchedAccounts(): Promise<void> {
|
|
352
|
-
// We do not do anything here, because cleaning accounts only affects the
|
|
353
|
-
// stateRoot. Since the stateRoot is fake anyway there is no need to
|
|
354
|
-
// perform this operation.
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
public setBlockContext(
|
|
358
|
-
stateRoot: Uint8Array,
|
|
359
|
-
blockNumber: bigint,
|
|
360
|
-
irregularState?: Uint8Array
|
|
361
|
-
) {
|
|
362
|
-
if (this._stateCheckpoints.length !== 0) {
|
|
363
|
-
throw checkpointedError("setBlockContext");
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (irregularState !== undefined) {
|
|
367
|
-
this._setStateRoot(irregularState);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (blockNumber === this._forkBlockNumber) {
|
|
372
|
-
this._setStateRoot(toBytes(this._initialStateRoot));
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if (blockNumber > this._forkBlockNumber) {
|
|
376
|
-
this._setStateRoot(stateRoot);
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
this._contextChanged = true;
|
|
380
|
-
this._state = ImmutableMap<string, ImmutableRecord<AccountState>>();
|
|
381
|
-
this._stateRoot = bufferToHex(stateRoot);
|
|
382
|
-
this._stateRootToState.set(this._stateRoot, this._state);
|
|
383
|
-
this._contextBlockNumber = blockNumber;
|
|
384
|
-
// Note that we don't need to clear the original storage cache here
|
|
385
|
-
// because the VM does it before executing a message anyway.
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
public restoreForkBlockContext(stateRoot: Uint8Array) {
|
|
389
|
-
if (this._stateCheckpoints.length !== 0) {
|
|
390
|
-
throw checkpointedError("restoreForkBlockContext");
|
|
391
|
-
}
|
|
392
|
-
this._setStateRoot(stateRoot);
|
|
393
|
-
if (this._contextChanged) {
|
|
394
|
-
this._contextChanged = false;
|
|
395
|
-
this._contextBlockNumber = this._forkBlockNumber;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
public accountExists(_address: Address): never {
|
|
400
|
-
throw new InternalError(
|
|
401
|
-
"Hardhat Network can't fork from networks running a hardfork older than Spurious Dragon"
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
public async deleteAccount(address: Address): Promise<void> {
|
|
406
|
-
// we set an empty account instead of deleting it to avoid
|
|
407
|
-
// re-fetching the state from the remote node.
|
|
408
|
-
// This is only valid post spurious dragon, but we don't support older hardforks when forking.
|
|
409
|
-
const emptyAccount = makeEmptyAccountState();
|
|
410
|
-
this._state = this._state.set(address.toString(), emptyAccount);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
public clearOriginalStorageCache(): void {
|
|
414
|
-
this._originalStorageCache = new Map();
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
public async getOriginalContractStorage(
|
|
418
|
-
address: Address,
|
|
419
|
-
key: Uint8Array
|
|
420
|
-
): Promise<Uint8Array> {
|
|
421
|
-
const storageKey = encodeStorageKey(Buffer.from(address.toBytes()), key);
|
|
422
|
-
const cachedValue = this._originalStorageCache.get(storageKey);
|
|
423
|
-
if (cachedValue !== undefined) {
|
|
424
|
-
return cachedValue;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
const value = await this.getContractStorage(address, key);
|
|
428
|
-
this._originalStorageCache.set(storageKey, value);
|
|
429
|
-
|
|
430
|
-
return value;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
private _putAccount(address: Address, account: Account): void {
|
|
434
|
-
// Because the vm only ever modifies the nonce, balance and codeHash using this
|
|
435
|
-
// method we ignore the stateRoot property
|
|
436
|
-
const hexAddress = address.toString();
|
|
437
|
-
let localAccount = this._state.get(hexAddress) ?? makeAccountState();
|
|
438
|
-
localAccount = localAccount
|
|
439
|
-
.set("nonce", bigIntToHex(account.nonce))
|
|
440
|
-
.set("balance", bigIntToHex(account.balance));
|
|
441
|
-
|
|
442
|
-
// Code is set to empty string here to prevent unnecessary
|
|
443
|
-
// JsonRpcClient.getCode calls in getAccount method
|
|
444
|
-
if (equalsBytes(account.codeHash, KECCAK256_NULL)) {
|
|
445
|
-
localAccount = localAccount.set("code", "0x");
|
|
446
|
-
}
|
|
447
|
-
this._state = this._state.set(hexAddress, localAccount);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private _setStateRoot(stateRoot: Uint8Array) {
|
|
451
|
-
const newRoot = bufferToHex(stateRoot);
|
|
452
|
-
const state = this._stateRootToState.get(newRoot);
|
|
453
|
-
if (state === undefined) {
|
|
454
|
-
throw new Error("Unknown state root");
|
|
455
|
-
}
|
|
456
|
-
this._stateRoot = newRoot;
|
|
457
|
-
this._state = state;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
public async hasStateRoot(root: Buffer): Promise<boolean> {
|
|
461
|
-
return this._state.has(bufferToHex(root));
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
public async flush(): Promise<void> {
|
|
465
|
-
// not implemented
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
public async modifyAccountFields(
|
|
469
|
-
address: Address,
|
|
470
|
-
accountFields: any
|
|
471
|
-
): Promise<void> {
|
|
472
|
-
// copied from BaseStateManager
|
|
473
|
-
const account = await this.getAccount(address);
|
|
474
|
-
account.nonce = accountFields.nonce ?? account.nonce;
|
|
475
|
-
account.balance = accountFields.balance ?? account.balance;
|
|
476
|
-
account.storageRoot = accountFields.storageRoot ?? account.storageRoot;
|
|
477
|
-
account.codeHash = accountFields.codeHash ?? account.codeHash;
|
|
478
|
-
await this.putAccount(address, account);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BlockData } from "@nomicfoundation/ethereumjs-block";
|
|
2
|
-
|
|
3
|
-
import { RpcBlockWithTransactions } from "../../../core/jsonrpc/types/output/block";
|
|
4
|
-
|
|
5
|
-
import { rpcToTxData } from "./rpcToTxData";
|
|
6
|
-
|
|
7
|
-
export function rpcToBlockData(rpcBlock: RpcBlockWithTransactions): BlockData {
|
|
8
|
-
return {
|
|
9
|
-
header: {
|
|
10
|
-
parentHash: rpcBlock.parentHash,
|
|
11
|
-
uncleHash: rpcBlock.sha3Uncles,
|
|
12
|
-
coinbase: rpcBlock.miner,
|
|
13
|
-
stateRoot: rpcBlock.stateRoot,
|
|
14
|
-
transactionsTrie: rpcBlock.transactionsRoot,
|
|
15
|
-
receiptTrie: rpcBlock.receiptsRoot,
|
|
16
|
-
logsBloom: rpcBlock.logsBloom,
|
|
17
|
-
difficulty: rpcBlock.difficulty,
|
|
18
|
-
number: rpcBlock.number ?? undefined,
|
|
19
|
-
gasLimit: rpcBlock.gasLimit,
|
|
20
|
-
gasUsed: rpcBlock.gasUsed,
|
|
21
|
-
timestamp: rpcBlock.timestamp,
|
|
22
|
-
extraData: rpcBlock.extraData,
|
|
23
|
-
mixHash: rpcBlock.mixHash,
|
|
24
|
-
nonce: rpcBlock.nonce,
|
|
25
|
-
baseFeePerGas: rpcBlock.baseFeePerGas,
|
|
26
|
-
withdrawalsRoot: rpcBlock.withdrawalsRoot,
|
|
27
|
-
parentBeaconBlockRoot: rpcBlock.parentBeaconBlockRoot,
|
|
28
|
-
blobGasUsed: rpcBlock.blobGasUsed,
|
|
29
|
-
excessBlobGas: rpcBlock.excessBlobGas,
|
|
30
|
-
},
|
|
31
|
-
transactions: rpcBlock.transactions.map(rpcToTxData),
|
|
32
|
-
withdrawals: rpcBlock.withdrawals,
|
|
33
|
-
// uncleHeaders are not fetched and set here as provider methods for getting them are not supported
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { BigIntLike } from "@nomicfoundation/ethereumjs-util";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AccessListEIP2930TxData,
|
|
5
|
-
LegacyTxData,
|
|
6
|
-
} from "@nomicfoundation/ethereumjs-tx";
|
|
7
|
-
|
|
8
|
-
import { RpcTransaction } from "../../../core/jsonrpc/types/output/transaction";
|
|
9
|
-
|
|
10
|
-
// the FeeMarketEIP1559TxData interface from ethereum js also has a
|
|
11
|
-
// `gasPrice?: never | null` property, which causes a compilation
|
|
12
|
-
// error in the latest version of typescript
|
|
13
|
-
interface FeeMarketEIP1559TxData extends AccessListEIP2930TxData {
|
|
14
|
-
maxPriorityFeePerGas?: BigIntLike;
|
|
15
|
-
maxFeePerGas?: BigIntLike;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function rpcToTxData(
|
|
19
|
-
rpcTransaction: RpcTransaction
|
|
20
|
-
): LegacyTxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData {
|
|
21
|
-
const isEip1559 = rpcTransaction.type === 2n;
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
gasLimit: rpcTransaction.gas,
|
|
25
|
-
// NOTE: RPC EIP-1559 txs still have this field for backwards compatibility,
|
|
26
|
-
// but FeeMarketEIP1559TxData doesn't.
|
|
27
|
-
gasPrice: isEip1559 ? undefined : rpcTransaction.gasPrice,
|
|
28
|
-
to: rpcTransaction.to ?? undefined,
|
|
29
|
-
nonce: rpcTransaction.nonce,
|
|
30
|
-
data: rpcTransaction.input,
|
|
31
|
-
v: rpcTransaction.v,
|
|
32
|
-
r: rpcTransaction.r,
|
|
33
|
-
s: rpcTransaction.s,
|
|
34
|
-
value: rpcTransaction.value,
|
|
35
|
-
type: rpcTransaction.type,
|
|
36
|
-
chainId: rpcTransaction.chainId ?? undefined,
|
|
37
|
-
maxFeePerGas: rpcTransaction.maxFeePerGas,
|
|
38
|
-
maxPriorityFeePerGas: rpcTransaction.maxPriorityFeePerGas,
|
|
39
|
-
accessList: rpcTransaction.accessList?.map((item) => [
|
|
40
|
-
item.address,
|
|
41
|
-
item.storageKeys ?? [],
|
|
42
|
-
]),
|
|
43
|
-
};
|
|
44
|
-
}
|