@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.21caa21
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/dest/account.d.ts +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +16 -2
- package/dest/config.d.ts +111 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +462 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +24 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/empire_slashing_proposer.d.ts +66 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +200 -0
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +19 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +57 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +43 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +87 -84
- package/dest/contracts/governance_proposer.d.ts +16 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +37 -17
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +26 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +45 -0
- package/dest/contracts/index.d.ts +9 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +8 -2
- package/dest/contracts/multicall.d.ts +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +156 -0
- package/dest/contracts/registry.d.ts +10 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +44 -16
- package/dest/contracts/rollup.d.ts +204 -40
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +529 -79
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +139 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +313 -0
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_l1_contracts.d.ts +577 -21114
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +1225 -421
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/index.d.ts +7 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +6 -2
- package/dest/l1_artifacts.d.ts +77344 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +166 -0
- package/dest/l1_contract_addresses.d.ts +24 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +22 -18
- package/dest/l1_reader.d.ts +2 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +8 -8
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +82 -0
- package/dest/l1_tx_utils/constants.d.ts +6 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +14 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- package/dest/l1_tx_utils/index.d.ts +10 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +10 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +610 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +430 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +15 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +4 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +53 -12
- package/dest/test/chain_monitor.d.ts +73 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +215 -0
- package/dest/test/delayed_tx_utils.d.ts +8 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +13 -6
- package/dest/test/eth_cheat_codes.d.ts +217 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +558 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -0
- package/dest/test/rollup_cheat_codes.d.ts +87 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +266 -0
- package/dest/test/start_anvil.d.ts +7 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -7
- package/dest/test/tx_delayer.d.ts +18 -7
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +95 -19
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +7 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +43 -88
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +28 -19
- package/src/account.ts +5 -0
- package/src/client.ts +42 -4
- package/src/config.ts +592 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +265 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +63 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +80 -77
- package/src/contracts/governance_proposer.ts +66 -24
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +8 -2
- package/src/contracts/multicall.ts +155 -0
- package/src/contracts/registry.ts +51 -26
- package/src/contracts/rollup.ts +596 -74
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +316 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_l1_contracts.ts +1459 -538
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/index.ts +6 -2
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +32 -19
- package/src/l1_reader.ts +9 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +143 -0
- package/src/l1_tx_utils/constants.ts +18 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/index.ts +12 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +558 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +106 -0
- package/src/queries.ts +73 -15
- package/src/test/chain_monitor.ts +243 -0
- package/src/test/delayed_tx_utils.ts +34 -6
- package/src/test/eth_cheat_codes.ts +588 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -0
- package/src/test/rollup_cheat_codes.ts +307 -0
- package/src/test/start_anvil.ts +22 -5
- package/src/test/tx_delayer.ts +127 -26
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +10 -8
- package/src/utils.ts +49 -90
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/contracts/slashing_proposer.d.ts +0 -21
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.js +0 -47
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/eth_cheat_codes.ts +0 -314
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ConfigMappingsType,
|
|
3
|
+
booleanConfigHelper,
|
|
4
|
+
floatConfigHelper,
|
|
5
|
+
getConfigFromMappings,
|
|
6
|
+
getDefaultConfig,
|
|
7
|
+
numberConfigHelper,
|
|
8
|
+
} from '@aztec/foundation/config';
|
|
9
|
+
|
|
10
|
+
export interface L1TxUtilsConfig {
|
|
11
|
+
/**
|
|
12
|
+
* How much to increase calculated gas limit.
|
|
13
|
+
*/
|
|
14
|
+
gasLimitBufferPercentage?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum gas price in gwei
|
|
17
|
+
*/
|
|
18
|
+
maxGwei?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum blob fee per gas in gwei
|
|
21
|
+
*/
|
|
22
|
+
maxBlobGwei?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Priority fee bump percentage
|
|
25
|
+
*/
|
|
26
|
+
priorityFeeBumpPercentage?: number;
|
|
27
|
+
/**
|
|
28
|
+
* How much to increase priority fee by each attempt (percentage)
|
|
29
|
+
*/
|
|
30
|
+
priorityFeeRetryBumpPercentage?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Fixed priority fee per gas in Gwei. Overrides any priority fee bump percentage config
|
|
33
|
+
*/
|
|
34
|
+
fixedPriorityFeePerGas?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of speed-up attempts
|
|
37
|
+
*/
|
|
38
|
+
maxSpeedUpAttempts?: number;
|
|
39
|
+
/**
|
|
40
|
+
* How often to check tx status
|
|
41
|
+
*/
|
|
42
|
+
checkIntervalMs?: number;
|
|
43
|
+
/**
|
|
44
|
+
* How long before considering tx stalled
|
|
45
|
+
*/
|
|
46
|
+
stallTimeMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* How long to wait for a tx to be mined before giving up
|
|
49
|
+
*/
|
|
50
|
+
txTimeoutMs?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether to attempt to cancel a tx if it's not mined after txTimeoutMs
|
|
53
|
+
*/
|
|
54
|
+
cancelTxOnTimeout?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* How long to wait for a cancellation tx to be mined after its last attempt before giving up
|
|
57
|
+
*/
|
|
58
|
+
txCancellationFinalTimeoutMs?: number;
|
|
59
|
+
/**
|
|
60
|
+
* How long a tx nonce can be unseen in the mempool before considering it dropped
|
|
61
|
+
*/
|
|
62
|
+
txUnseenConsideredDroppedMs?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
66
|
+
gasLimitBufferPercentage: {
|
|
67
|
+
description: 'How much to increase calculated gas limit by (percentage)',
|
|
68
|
+
env: 'L1_GAS_LIMIT_BUFFER_PERCENTAGE',
|
|
69
|
+
...numberConfigHelper(20),
|
|
70
|
+
},
|
|
71
|
+
maxGwei: {
|
|
72
|
+
description: 'Maximum gas price in gwei to be used for transactions.',
|
|
73
|
+
env: 'L1_GAS_PRICE_MAX',
|
|
74
|
+
fallback: ['L1_FEE_PER_GAS_GWEI_MAX'],
|
|
75
|
+
...floatConfigHelper(2000),
|
|
76
|
+
},
|
|
77
|
+
maxBlobGwei: {
|
|
78
|
+
description: 'Maximum blob fee per gas in gwei',
|
|
79
|
+
env: 'L1_BLOB_FEE_PER_GAS_MAX',
|
|
80
|
+
fallback: ['L1_BLOB_FEE_PER_GAS_GWEI_MAX'],
|
|
81
|
+
...floatConfigHelper(3000),
|
|
82
|
+
},
|
|
83
|
+
priorityFeeBumpPercentage: {
|
|
84
|
+
description: 'How much to increase priority fee by each attempt (percentage)',
|
|
85
|
+
env: 'L1_PRIORITY_FEE_BUMP_PERCENTAGE',
|
|
86
|
+
...numberConfigHelper(20),
|
|
87
|
+
},
|
|
88
|
+
priorityFeeRetryBumpPercentage: {
|
|
89
|
+
description: 'How much to increase priority fee by each retry attempt (percentage)',
|
|
90
|
+
env: 'L1_PRIORITY_FEE_RETRY_BUMP_PERCENTAGE',
|
|
91
|
+
...numberConfigHelper(50),
|
|
92
|
+
},
|
|
93
|
+
fixedPriorityFeePerGas: {
|
|
94
|
+
description: 'Fixed priority fee per gas in Gwei. Overrides any priority fee bump percentage',
|
|
95
|
+
env: 'L1_FIXED_PRIORITY_FEE_PER_GAS',
|
|
96
|
+
fallback: ['L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI'],
|
|
97
|
+
...floatConfigHelper(0),
|
|
98
|
+
},
|
|
99
|
+
maxSpeedUpAttempts: {
|
|
100
|
+
description: 'Maximum number of speed-up attempts',
|
|
101
|
+
env: 'L1_TX_MONITOR_MAX_ATTEMPTS',
|
|
102
|
+
...numberConfigHelper(3),
|
|
103
|
+
},
|
|
104
|
+
checkIntervalMs: {
|
|
105
|
+
description: 'How often to check tx status',
|
|
106
|
+
env: 'L1_TX_MONITOR_CHECK_INTERVAL_MS',
|
|
107
|
+
...numberConfigHelper(1_000),
|
|
108
|
+
},
|
|
109
|
+
stallTimeMs: {
|
|
110
|
+
description: 'How long before considering tx stalled',
|
|
111
|
+
env: 'L1_TX_MONITOR_STALL_TIME_MS',
|
|
112
|
+
...numberConfigHelper(12_000), // 12s, 1 ethereum slot
|
|
113
|
+
},
|
|
114
|
+
txTimeoutMs: {
|
|
115
|
+
description: 'How long to wait for a tx to be mined before giving up. Set to 0 to disable.',
|
|
116
|
+
env: 'L1_TX_MONITOR_TX_TIMEOUT_MS',
|
|
117
|
+
...numberConfigHelper(120_000), // 2 mins
|
|
118
|
+
},
|
|
119
|
+
cancelTxOnTimeout: {
|
|
120
|
+
description: "Whether to attempt to cancel a tx if it's not mined after txTimeoutMs",
|
|
121
|
+
env: 'L1_TX_MONITOR_CANCEL_TX_ON_TIMEOUT',
|
|
122
|
+
...booleanConfigHelper(true),
|
|
123
|
+
},
|
|
124
|
+
txCancellationFinalTimeoutMs: {
|
|
125
|
+
description: 'How long to wait for a cancellation tx after its last attempt before giving up',
|
|
126
|
+
env: 'L1_TX_MONITOR_TX_CANCELLATION_TIMEOUT_MS',
|
|
127
|
+
...numberConfigHelper(24 * 12 * 1000), // 24 L1 blocks
|
|
128
|
+
},
|
|
129
|
+
txUnseenConsideredDroppedMs: {
|
|
130
|
+
description: 'How long a tx nonce can be unseen in the mempool before considering it dropped',
|
|
131
|
+
env: 'L1_TX_MONITOR_TX_UNSEEN_CONSIDERED_DROPPED_MS',
|
|
132
|
+
...numberConfigHelper(6 * 12 * 1000), // 6 L1 blocks
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// We abuse the fact that all mappings above have a non null default value and force-type this to Required
|
|
137
|
+
export const defaultL1TxUtilsConfig = getDefaultConfig<L1TxUtilsConfig>(
|
|
138
|
+
l1TxUtilsConfigMappings,
|
|
139
|
+
) as Required<L1TxUtilsConfig>;
|
|
140
|
+
|
|
141
|
+
export function getL1TxUtilsConfigEnvVars(): L1TxUtilsConfig {
|
|
142
|
+
return getConfigFromMappings(l1TxUtilsConfigMappings);
|
|
143
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// 1_000_000_000 Gwei = 1 ETH
|
|
2
|
+
// 1_000_000_000 Wei = 1 Gwei
|
|
3
|
+
// 1_000_000_000_000_000_000 Wei = 1 ETH
|
|
4
|
+
export const WEI_CONST = 1_000_000_000n;
|
|
5
|
+
|
|
6
|
+
// @note using this large gas limit to avoid the issue of `gas limit too low` when estimating gas in reth
|
|
7
|
+
export const LARGE_GAS_LIMIT = 12_000_000n;
|
|
8
|
+
|
|
9
|
+
// setting a minimum bump percentage to 10% due to geth's implementation
|
|
10
|
+
// https://github.com/ethereum/go-ethereum/blob/e3d61e6db028c412f74bc4d4c7e117a9e29d0de0/core/txpool/legacypool/list.go#L298
|
|
11
|
+
export const MIN_REPLACEMENT_BUMP_PERCENTAGE = 10;
|
|
12
|
+
|
|
13
|
+
// setting a minimum bump percentage to 100% due to geth's implementation
|
|
14
|
+
// https://github.com/ethereum/go-ethereum/blob/e3d61e6db028c412f74bc4d4c7e117a9e29d0de0/core/txpool/blobpool/config.go#L34
|
|
15
|
+
export const MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE = 100;
|
|
16
|
+
|
|
17
|
+
// Avg ethereum block time is ~12s
|
|
18
|
+
export const BLOCK_TIME_MS = 12_000;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
|
|
5
|
+
import type { TransactionSerializable } from 'viem';
|
|
6
|
+
|
|
7
|
+
import type { EthSigner } from '../eth-signer/eth-signer.js';
|
|
8
|
+
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
9
|
+
import type { L1TxUtilsConfig } from './config.js';
|
|
10
|
+
import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
|
|
11
|
+
import { L1TxUtils } from './l1_tx_utils.js';
|
|
12
|
+
import { createViemSigner } from './signer.js';
|
|
13
|
+
import type { SigningCallback } from './types.js';
|
|
14
|
+
|
|
15
|
+
export function createL1TxUtilsFromViemWallet(
|
|
16
|
+
client: ExtendedViemWalletClient,
|
|
17
|
+
deps?: {
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
dateProvider?: DateProvider;
|
|
20
|
+
store?: IL1TxStore;
|
|
21
|
+
metrics?: IL1TxMetrics;
|
|
22
|
+
},
|
|
23
|
+
config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
|
|
24
|
+
): L1TxUtils {
|
|
25
|
+
return new L1TxUtils(
|
|
26
|
+
client,
|
|
27
|
+
EthAddress.fromString(client.account.address),
|
|
28
|
+
createViemSigner(client),
|
|
29
|
+
deps?.logger,
|
|
30
|
+
deps?.dateProvider,
|
|
31
|
+
config,
|
|
32
|
+
config?.debugMaxGasLimit ?? false,
|
|
33
|
+
deps?.store,
|
|
34
|
+
deps?.metrics,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createL1TxUtilsFromEthSigner(
|
|
39
|
+
client: ViemClient,
|
|
40
|
+
signer: EthSigner,
|
|
41
|
+
deps?: {
|
|
42
|
+
logger?: Logger;
|
|
43
|
+
dateProvider?: DateProvider;
|
|
44
|
+
store?: IL1TxStore;
|
|
45
|
+
metrics?: IL1TxMetrics;
|
|
46
|
+
},
|
|
47
|
+
config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
|
|
48
|
+
): L1TxUtils {
|
|
49
|
+
const callback: SigningCallback = async (transaction: TransactionSerializable, _signingAddress) => {
|
|
50
|
+
return (await signer.signTransaction(transaction)).toViemTransactionSignature();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return new L1TxUtils(
|
|
54
|
+
client,
|
|
55
|
+
signer.address,
|
|
56
|
+
callback,
|
|
57
|
+
deps?.logger,
|
|
58
|
+
deps?.dateProvider,
|
|
59
|
+
config,
|
|
60
|
+
config?.debugMaxGasLimit ?? false,
|
|
61
|
+
deps?.store,
|
|
62
|
+
deps?.metrics,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './config.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './factory.js';
|
|
4
|
+
export * from './interfaces.js';
|
|
5
|
+
export * from './l1_tx_utils.js';
|
|
6
|
+
export * from './readonly_l1_tx_utils.js';
|
|
7
|
+
export * from './signer.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
export * from './utils.js';
|
|
10
|
+
|
|
11
|
+
// Note: We intentionally do not export l1_tx_utils_with_blobs.js
|
|
12
|
+
// to avoid accidentally importing blob-lib dependency.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { L1BlobInputs, L1TxState } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface for L1 transaction state storage.
|
|
5
|
+
* Implementations handle persistence of transaction states across restarts.
|
|
6
|
+
*/
|
|
7
|
+
export interface IL1TxStore {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the next available state ID for an account.
|
|
10
|
+
*/
|
|
11
|
+
consumeNextStateId(account: string): Promise<number>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Saves a single transaction state for a specific account.
|
|
15
|
+
* Does not save blob data (see saveBlobs).
|
|
16
|
+
* @param account - The sender account address
|
|
17
|
+
* @param state - Transaction state to save
|
|
18
|
+
*/
|
|
19
|
+
saveState(account: string, state: L1TxState): Promise<L1TxState>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Saves blobs for a given state.
|
|
23
|
+
* @param account - The sender account address
|
|
24
|
+
* @param stateId - The state ID
|
|
25
|
+
* @param blobInputs - Blob inputs to save
|
|
26
|
+
*/
|
|
27
|
+
saveBlobs(account: string, stateId: number, blobInputs: L1BlobInputs | undefined): Promise<void>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Loads all transaction states for a specific account.
|
|
31
|
+
* @param account - The sender account address
|
|
32
|
+
* @returns Array of transaction states with their IDs
|
|
33
|
+
*/
|
|
34
|
+
loadStates(account: string): Promise<L1TxState[]>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Loads a single state by ID.
|
|
38
|
+
* @param account - The sender account address
|
|
39
|
+
* @param stateId - The state ID
|
|
40
|
+
* @returns The transaction state or undefined if not found
|
|
41
|
+
*/
|
|
42
|
+
loadState(account: string, stateId: number): Promise<L1TxState | undefined>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Deletes a specific state and its associated blobs.
|
|
46
|
+
* @param account - The sender account address
|
|
47
|
+
* @param stateId - The state ID to delete
|
|
48
|
+
*/
|
|
49
|
+
deleteState(account: string, stateId: number): Promise<void>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Clears all transaction states for a specific account.
|
|
53
|
+
* @param account - The sender account address
|
|
54
|
+
*/
|
|
55
|
+
clearStates(account: string): Promise<void>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Gets all accounts that have stored states.
|
|
59
|
+
* @returns Array of account addresses
|
|
60
|
+
*/
|
|
61
|
+
getAllAccounts(): Promise<string[]>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Closes the store.
|
|
65
|
+
*/
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Interface for L1 transaction metrics recording.
|
|
71
|
+
* Implementations handle tracking of transaction lifecycle and gas costs.
|
|
72
|
+
*/
|
|
73
|
+
export interface IL1TxMetrics {
|
|
74
|
+
/**
|
|
75
|
+
* Records metrics when a transaction is mined
|
|
76
|
+
* @param state - The L1 transaction state
|
|
77
|
+
* @param l1Timestamp - The current L1 timestamp
|
|
78
|
+
*/
|
|
79
|
+
recordMinedTx(state: L1TxState, l1Timestamp: Date): void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Records metrics when a transaction is dropped
|
|
83
|
+
* @param state - The L1 transaction state
|
|
84
|
+
*/
|
|
85
|
+
recordDroppedTx(state: L1TxState): void;
|
|
86
|
+
}
|