@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +21 -3
- package/dest/config.d.ts +71 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +138 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +25 -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 +67 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +209 -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 +17 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +46 -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 +221 -41
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +549 -81
- 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 +140 -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_aztec_l1_contracts.d.ts +245 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +335 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- 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/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +77364 -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 +25 -21
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +14 -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 +96 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -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/fee-strategies/index.d.ts +9 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +11 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +18 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +111 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +32 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +173 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +64 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +24 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +12 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +12 -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_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -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 +623 -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 +87 -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 +360 -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 +75 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +214 -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 +560 -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 +275 -0
- package/dest/test/start_anvil.d.ts +9 -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 +97 -20
- 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 +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +61 -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 +50 -23
- package/src/account.ts +5 -0
- package/src/client.ts +43 -5
- package/src/config.ts +188 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +270 -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 +71 -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 +624 -78
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +318 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +556 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +49 -34
- package/src/l1_reader.ts +17 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +161 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +159 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +241 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +88 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +14 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +458 -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 +245 -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 +312 -0
- package/src/test/start_anvil.ts +24 -5
- package/src/test/tx_delayer.ts +130 -27
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +79 -91
- 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/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- 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/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- 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/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import type { ViemClient } from '../../types.js';
|
|
4
|
+
import type { L1TxUtilsConfig } from '../config.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Historical block count for fee history queries
|
|
8
|
+
*/
|
|
9
|
+
export const HISTORICAL_BLOCK_COUNT = 5;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Result from a priority fee strategy calculation
|
|
13
|
+
*/
|
|
14
|
+
export interface PriorityFeeStrategyResult {
|
|
15
|
+
/** The calculated priority fee in wei */
|
|
16
|
+
priorityFee: bigint;
|
|
17
|
+
/** Optional debug info about how the fee was calculated */
|
|
18
|
+
debugInfo?: Record<string, string | number>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Context passed to the strategy calculation function (excluding promise results)
|
|
23
|
+
*/
|
|
24
|
+
export interface PriorityFeeStrategyContext {
|
|
25
|
+
/** Gas configuration */
|
|
26
|
+
gasConfig: L1TxUtilsConfig;
|
|
27
|
+
/** Whether this is for a blob transaction */
|
|
28
|
+
isBlobTx: boolean;
|
|
29
|
+
/** Logger for debugging */
|
|
30
|
+
logger?: Logger;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A strategy for calculating the priority fee for L1 transactions.
|
|
35
|
+
* Each strategy defines what promises it needs and how to calculate the fee from their results.
|
|
36
|
+
* This design allows strategies to be plugged into both L1FeeAnalyzer and ReadOnlyL1TxUtils.
|
|
37
|
+
*/
|
|
38
|
+
export interface PriorityFeeStrategy<TPromises extends Record<string, Promise<any>> = Record<string, Promise<any>>> {
|
|
39
|
+
/** Human-readable name for logging */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Unique identifier for metrics */
|
|
42
|
+
id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the promises that need to be executed for this strategy.
|
|
45
|
+
* These will be run in parallel with Promise.allSettled.
|
|
46
|
+
* @param client - The viem client to use for RPC calls
|
|
47
|
+
* @returns An object of promises keyed by name
|
|
48
|
+
*/
|
|
49
|
+
getRequiredPromises(client: ViemClient, opts: Partial<PriorityFeeStrategyContext>): TPromises;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate the priority fee based on the settled promise results.
|
|
52
|
+
* @param results - The settled results of the promises from getRequiredPromises
|
|
53
|
+
* @param context - Contains gas config, whether it's a blob tx, and logger
|
|
54
|
+
* @returns The calculated priority fee result
|
|
55
|
+
*/
|
|
56
|
+
calculate(
|
|
57
|
+
results: { [K in keyof TPromises]: PromiseSettledResult<Awaited<TPromises[K]>> },
|
|
58
|
+
context: PriorityFeeStrategyContext,
|
|
59
|
+
): PriorityFeeStrategyResult;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Helper function to execute a strategy's promises and calculate the result.
|
|
64
|
+
* This can be used by both L1FeeAnalyzer and ReadOnlyL1TxUtils.
|
|
65
|
+
* @param strategy - The strategy to execute
|
|
66
|
+
* @param client - The viem client to use for RPC calls
|
|
67
|
+
* @param context - The context for calculation
|
|
68
|
+
* @returns The strategy result
|
|
69
|
+
*/
|
|
70
|
+
export async function executeStrategy<TPromises extends Record<string, Promise<any>>>(
|
|
71
|
+
strategy: PriorityFeeStrategy<TPromises>,
|
|
72
|
+
client: ViemClient,
|
|
73
|
+
context: PriorityFeeStrategyContext,
|
|
74
|
+
): Promise<PriorityFeeStrategyResult> {
|
|
75
|
+
const promises = strategy.getRequiredPromises(client, { isBlobTx: context.isBlobTx });
|
|
76
|
+
const keys = Object.keys(promises) as Array<keyof TPromises>;
|
|
77
|
+
const promiseArray = keys.map(k => promises[k]);
|
|
78
|
+
|
|
79
|
+
const settledResults = await Promise.allSettled(promiseArray);
|
|
80
|
+
|
|
81
|
+
// Reconstruct the results object with the same keys, preserving the type mapping
|
|
82
|
+
const results = {} as { [K in keyof TPromises]: PromiseSettledResult<Awaited<TPromises[K]>> };
|
|
83
|
+
keys.forEach((key, index) => {
|
|
84
|
+
results[key] = settledResults[index] as PromiseSettledResult<Awaited<TPromises[typeof key]>>;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return strategy.calculate(results, context);
|
|
88
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
|
|
5
|
+
import { type Hex, encodeFunctionData } from 'viem';
|
|
6
|
+
|
|
7
|
+
import type { EthSigner } from '../eth-signer/eth-signer.js';
|
|
8
|
+
import { FORWARDER_ABI } from '../forwarder_proxy.js';
|
|
9
|
+
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
10
|
+
import type { L1TxUtilsConfig } from './config.js';
|
|
11
|
+
import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
|
|
12
|
+
import { L1TxUtilsWithBlobs } from './l1_tx_utils_with_blobs.js';
|
|
13
|
+
import { createViemSigner } from './signer.js';
|
|
14
|
+
import type { L1BlobInputs, L1TxConfig, L1TxRequest, SigningCallback } from './types.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Extends L1TxUtilsWithBlobs to wrap all transactions through a forwarder contract.
|
|
18
|
+
* This is mainly used for testing the archiver's ability to decode transactions that go through proxies.
|
|
19
|
+
*/
|
|
20
|
+
export class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
|
|
21
|
+
constructor(
|
|
22
|
+
client: ViemClient | ExtendedViemWalletClient,
|
|
23
|
+
senderAddress: EthAddress,
|
|
24
|
+
signingCallback: SigningCallback,
|
|
25
|
+
logger: Logger | undefined,
|
|
26
|
+
dateProvider: DateProvider | undefined,
|
|
27
|
+
config: Partial<L1TxUtilsConfig>,
|
|
28
|
+
debugMaxGasLimit: boolean,
|
|
29
|
+
store: IL1TxStore | undefined,
|
|
30
|
+
metrics: IL1TxMetrics | undefined,
|
|
31
|
+
private readonly forwarderAddress: EthAddress,
|
|
32
|
+
) {
|
|
33
|
+
super(client, senderAddress, signingCallback, logger, dateProvider, config, debugMaxGasLimit, store, metrics);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wraps the transaction request in a call to the forwarder contract.
|
|
38
|
+
*/
|
|
39
|
+
private wrapInForwarder(request: L1TxRequest): L1TxRequest {
|
|
40
|
+
const forwarderCalldata = encodeFunctionData({
|
|
41
|
+
abi: FORWARDER_ABI,
|
|
42
|
+
functionName: 'forward',
|
|
43
|
+
args: [request.to as Hex, request.data as Hex],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
to: this.forwarderAddress.toString() as Hex,
|
|
48
|
+
data: forwarderCalldata,
|
|
49
|
+
value: request.value,
|
|
50
|
+
abi: request.abi, // Preserve the original ABI for error decoding
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Override sendAndMonitorTransaction to wrap the request in a forwarder call.
|
|
56
|
+
*/
|
|
57
|
+
public override sendAndMonitorTransaction(request: L1TxRequest, gasConfig?: L1TxConfig, blobInputs?: L1BlobInputs) {
|
|
58
|
+
this.logger.debug(`Wrapping transaction to ${request.to} in forwarder at ${this.forwarderAddress.toString()}`);
|
|
59
|
+
const wrappedRequest = this.wrapInForwarder(request);
|
|
60
|
+
return super.sendAndMonitorTransaction(wrappedRequest, gasConfig, blobInputs);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function createForwarderL1TxUtilsFromViemWallet(
|
|
65
|
+
client: ExtendedViemWalletClient,
|
|
66
|
+
forwarderAddress: EthAddress,
|
|
67
|
+
deps: {
|
|
68
|
+
logger?: Logger;
|
|
69
|
+
dateProvider?: DateProvider;
|
|
70
|
+
store?: IL1TxStore;
|
|
71
|
+
metrics?: IL1TxMetrics;
|
|
72
|
+
} = {},
|
|
73
|
+
config: Partial<L1TxUtilsConfig> = {},
|
|
74
|
+
debugMaxGasLimit: boolean = false,
|
|
75
|
+
) {
|
|
76
|
+
return new ForwarderL1TxUtils(
|
|
77
|
+
client,
|
|
78
|
+
EthAddress.fromString(client.account.address),
|
|
79
|
+
createViemSigner(client),
|
|
80
|
+
deps.logger,
|
|
81
|
+
deps.dateProvider,
|
|
82
|
+
config,
|
|
83
|
+
debugMaxGasLimit,
|
|
84
|
+
deps.store,
|
|
85
|
+
deps.metrics,
|
|
86
|
+
forwarderAddress,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createForwarderL1TxUtilsFromEthSigner(
|
|
91
|
+
client: ViemClient,
|
|
92
|
+
signer: EthSigner,
|
|
93
|
+
forwarderAddress: EthAddress,
|
|
94
|
+
deps: {
|
|
95
|
+
logger?: Logger;
|
|
96
|
+
dateProvider?: DateProvider;
|
|
97
|
+
store?: IL1TxStore;
|
|
98
|
+
metrics?: IL1TxMetrics;
|
|
99
|
+
} = {},
|
|
100
|
+
config: Partial<L1TxUtilsConfig> = {},
|
|
101
|
+
debugMaxGasLimit: boolean = false,
|
|
102
|
+
) {
|
|
103
|
+
const callback: SigningCallback = async (transaction, _signingAddress) => {
|
|
104
|
+
return (await signer.signTransaction(transaction)).toViemTransactionSignature();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return new ForwarderL1TxUtils(
|
|
108
|
+
client,
|
|
109
|
+
signer.address,
|
|
110
|
+
callback,
|
|
111
|
+
deps.logger,
|
|
112
|
+
deps.dateProvider,
|
|
113
|
+
config,
|
|
114
|
+
debugMaxGasLimit,
|
|
115
|
+
deps.store,
|
|
116
|
+
deps.metrics,
|
|
117
|
+
forwarderAddress,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './config.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './factory.js';
|
|
4
|
+
export * from './fee-strategies/index.js';
|
|
5
|
+
export * from './interfaces.js';
|
|
6
|
+
export * from './l1_fee_analyzer.js';
|
|
7
|
+
export * from './l1_tx_utils.js';
|
|
8
|
+
export * from './readonly_l1_tx_utils.js';
|
|
9
|
+
export * from './signer.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export * from './utils.js';
|
|
12
|
+
|
|
13
|
+
// Note: We intentionally do not export l1_tx_utils_with_blobs.js
|
|
14
|
+
// 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
|
+
}
|