@aztec/ethereum 2.1.8 → 2.1.9

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.
@@ -0,0 +1,33 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { Logger } from '@aztec/foundation/log';
3
+ import { type Hex } from 'viem';
4
+ import type { ExtendedViemWalletClient } from './types.js';
5
+ export declare const FORWARDER_SOLIDITY_SOURCE = "\ncontract ForwarderProxy {\n function forward(address target, bytes calldata data) external payable returns (bytes memory) {\n (bool success, bytes memory result) = target.call{value: msg.value}(data);\n require(success, \"call failed\");\n return result;\n }\n}";
6
+ export declare const FORWARDER_ABI: readonly [{
7
+ readonly inputs: readonly [{
8
+ readonly internalType: "address";
9
+ readonly name: "target";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly internalType: "bytes";
13
+ readonly name: "data";
14
+ readonly type: "bytes";
15
+ }];
16
+ readonly name: "forward";
17
+ readonly outputs: readonly [{
18
+ readonly internalType: "bytes";
19
+ readonly name: "";
20
+ readonly type: "bytes";
21
+ }];
22
+ readonly stateMutability: "payable";
23
+ readonly type: "function";
24
+ }];
25
+ export declare const FORWARDER_BYTECODE: Hex;
26
+ /**
27
+ * Deploys the forwarder proxy contract to L1.
28
+ * @param client - The L1 client to use for deployment
29
+ * @param logger - Optional logger
30
+ * @returns The deployed forwarder contract address
31
+ */
32
+ export declare function deployForwarderProxy(client: ExtendedViemWalletClient, logger?: Logger): Promise<EthAddress>;
33
+ //# sourceMappingURL=forwarder_proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forwarder_proxy.d.ts","sourceRoot":"","sources":["../src/forwarder_proxy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAAE,KAAK,GAAG,EAAgB,MAAM,MAAM,CAAC;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,eAAO,MAAM,yBAAyB,uRAOpC,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAyBhB,CAAC;AAEX,eAAO,MAAM,kBAAkB,EACi6D,GAAG,CAAC;AAQp8D;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAUjH"}
@@ -0,0 +1,93 @@
1
+ /* eslint-disable no-console */ import { createLogger } from '@aztec/foundation/log';
2
+ import { DateProvider } from '@aztec/foundation/timer';
3
+ import { extractChain } from 'viem';
4
+ import { anvil, mainnet, sepolia } from 'viem/chains';
5
+ import { L1Deployer } from './deploy_l1_contracts.js';
6
+ export const FORWARDER_SOLIDITY_SOURCE = `
7
+ contract ForwarderProxy {
8
+ function forward(address target, bytes calldata data) external payable returns (bytes memory) {
9
+ (bool success, bytes memory result) = target.call{value: msg.value}(data);
10
+ require(success, "call failed");
11
+ return result;
12
+ }
13
+ }`;
14
+ export const FORWARDER_ABI = [
15
+ {
16
+ inputs: [
17
+ {
18
+ internalType: 'address',
19
+ name: 'target',
20
+ type: 'address'
21
+ },
22
+ {
23
+ internalType: 'bytes',
24
+ name: 'data',
25
+ type: 'bytes'
26
+ }
27
+ ],
28
+ name: 'forward',
29
+ outputs: [
30
+ {
31
+ internalType: 'bytes',
32
+ name: '',
33
+ type: 'bytes'
34
+ }
35
+ ],
36
+ stateMutability: 'payable',
37
+ type: 'function'
38
+ }
39
+ ];
40
+ export const FORWARDER_BYTECODE = '0x6080604052348015600e575f5ffd5b506103bf8061001c5f395ff3fe60806040526004361061001d575f3560e01c80636fadcf7214610021575b5f5ffd5b61003b600480360381019061003691906101d0565b610051565b604051610048919061029d565b60405180910390f35b60605f5f8573ffffffffffffffffffffffffffffffffffffffff1634868660405161007d9291906102f9565b5f6040518083038185875af1925050503d805f81146100b7576040519150601f19603f3d011682016040523d82523d5f602084013e6100bc565b606091505b509150915081610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f89061036b565b60405180910390fd5b80925050509392505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61013e82610115565b9050919050565b61014e81610134565b8114610158575f5ffd5b50565b5f8135905061016981610145565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126101905761018f61016f565b5b8235905067ffffffffffffffff8111156101ad576101ac610173565b5b6020830191508360018202830111156101c9576101c8610177565b5b9250929050565b5f5f5f604084860312156101e7576101e661010d565b5b5f6101f48682870161015b565b935050602084013567ffffffffffffffff81111561021557610214610111565b5b6102218682870161017b565b92509250509250925092565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61026f8261022d565b6102798185610237565b9350610289818560208601610247565b61029281610255565b840191505092915050565b5f6020820190508181035f8301526102b58184610265565b905092915050565b5f81905092915050565b828183375f83830152505050565b5f6102e083856102bd565b93506102ed8385846102c7565b82840190509392505050565b5f6103058284866102d5565b91508190509392505050565b5f82825260208201905092915050565b7f63616c6c206661696c65640000000000000000000000000000000000000000005f82015250565b5f610355600b83610311565b915061036082610321565b602082019050919050565b5f6020820190508181035f83015261038281610349565b905091905056fea26469706673582212209a1c8cf638cf1569450a731ef9457b862f9e153b0a46e5555429bcf4dffd999564736f6c634300081e0033';
41
+ const FORWARDER_ARTIFACT = {
42
+ name: 'Forwarder',
43
+ contractAbi: FORWARDER_ABI,
44
+ contractBytecode: FORWARDER_BYTECODE
45
+ };
46
+ /**
47
+ * Deploys the forwarder proxy contract to L1.
48
+ * @param client - The L1 client to use for deployment
49
+ * @param logger - Optional logger
50
+ * @returns The deployed forwarder contract address
51
+ */ export async function deployForwarderProxy(client, logger) {
52
+ const log = logger ?? createLogger('ethereum:forwarder');
53
+ const nonce = await client.getTransactionCount({
54
+ address: client.account.address
55
+ });
56
+ const deployer = new L1Deployer(client, nonce, new DateProvider(), false, log, undefined, false);
57
+ log.info('Deploying forwarder proxy contract');
58
+ const deployment = await deployer.deploy(FORWARDER_ARTIFACT, []);
59
+ log.info(`Forwarder proxy deployed at ${deployment.address.toString()}`);
60
+ return deployment.address;
61
+ }
62
+ /**
63
+ * Main function for deploying the forwarder proxy from command line.
64
+ * Usage: node forwarder_proxy.js <private_key> <rpc_url>
65
+ */ async function main() {
66
+ const args = process.argv.slice(2);
67
+ if (args.length < 3) {
68
+ console.error('Usage: node forwarder_proxy.js <private_key> <rpc_url> <chain_id>');
69
+ process.exit(1);
70
+ }
71
+ const [privateKey, rpcUrl, chainId] = args;
72
+ // Dynamic import to avoid pulling in dependencies at module load time
73
+ const { createExtendedL1Client } = await import('./client.js');
74
+ const client = createExtendedL1Client([
75
+ rpcUrl
76
+ ], privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`, extractChain({
77
+ chains: [
78
+ mainnet,
79
+ sepolia,
80
+ anvil
81
+ ],
82
+ id: parseInt(chainId)
83
+ }));
84
+ const address = await deployForwarderProxy(client);
85
+ console.log(`Forwarder proxy deployed at: ${address.toString()}`);
86
+ }
87
+ // Only run main if this is the entry point
88
+ if (import.meta.url === `file://${process.argv[1]}`) {
89
+ main().catch((err)=>{
90
+ console.error('Failed to deploy forwarder proxy:', err);
91
+ process.exit(1);
92
+ });
93
+ }
package/dest/index.d.ts CHANGED
@@ -15,4 +15,5 @@ export * from './l1_types.js';
15
15
  export * from './l1_artifacts.js';
16
16
  export * from './publisher_manager.js';
17
17
  export * from './eth-signer/index.js';
18
+ export * from './forwarder_proxy.js';
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
package/dest/index.js CHANGED
@@ -15,3 +15,4 @@ export * from './l1_types.js';
15
15
  export * from './l1_artifacts.js';
16
16
  export * from './publisher_manager.js';
17
17
  export * from './eth-signer/index.js';
18
+ export * from './forwarder_proxy.js';
@@ -4,6 +4,8 @@ import { type L1ContractAddresses } from './l1_contract_addresses.js';
4
4
  export interface L1ReaderConfig {
5
5
  /** The RPC Url of the ethereum host. */
6
6
  l1RpcUrls: string[];
7
+ /** The RPC Url of the ethereum debug host for trace and debug methods. */
8
+ l1DebugRpcUrls: string[];
7
9
  /** The chain ID of the ethereum host. */
8
10
  l1ChainId: number;
9
11
  /** The deployed l1 contract addresses */
@@ -1 +1 @@
1
- {"version":3,"file":"l1_reader.d.ts","sourceRoot":"","sources":["../src/l1_reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAE9G,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,4BAA4B,CAAC;AAElG,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IACjC,2CAA2C;IAC3C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAqBrE,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
1
+ {"version":3,"file":"l1_reader.d.ts","sourceRoot":"","sources":["../src/l1_reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAE9G,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,4BAA4B,CAAC;AAElG,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0EAA0E;IAC1E,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,mBAAmB,CAAC;IACjC,2CAA2C;IAC3C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CA2BrE,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
package/dest/l1_reader.js CHANGED
@@ -16,6 +16,12 @@ export const l1ReaderConfigMappings = {
16
16
  parseEnv: (val)=>val.split(',').map((url)=>url.trim()),
17
17
  defaultValue: []
18
18
  },
19
+ l1DebugRpcUrls: {
20
+ env: 'ETHEREUM_DEBUG_HOSTS',
21
+ description: 'The RPC Url of the ethereum debug host for trace and debug methods.',
22
+ parseEnv: (val)=>val.split(',').map((url)=>url.trim()),
23
+ defaultValue: []
24
+ },
19
25
  viemPollingIntervalMS: {
20
26
  env: 'L1_READER_VIEM_POLLING_INTERVAL_MS',
21
27
  description: 'The polling interval viem uses in ms',
@@ -0,0 +1,41 @@
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
+ import type { EthSigner } from '../eth-signer/eth-signer.js';
5
+ import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
6
+ import type { L1TxUtilsConfig } from './config.js';
7
+ import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
8
+ import { L1TxUtilsWithBlobs } from './l1_tx_utils_with_blobs.js';
9
+ import type { L1BlobInputs, L1TxConfig, L1TxRequest, SigningCallback } from './types.js';
10
+ /**
11
+ * Extends L1TxUtilsWithBlobs to wrap all transactions through a forwarder contract.
12
+ * This is mainly used for testing the archiver's ability to decode transactions that go through proxies.
13
+ */
14
+ export declare class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
15
+ private readonly forwarderAddress;
16
+ constructor(client: ViemClient | ExtendedViemWalletClient, senderAddress: EthAddress, signingCallback: SigningCallback, logger: Logger | undefined, dateProvider: DateProvider | undefined, config: Partial<L1TxUtilsConfig>, debugMaxGasLimit: boolean, store: IL1TxStore | undefined, metrics: IL1TxMetrics | undefined, forwarderAddress: EthAddress);
17
+ /**
18
+ * Wraps the transaction request in a call to the forwarder contract.
19
+ */
20
+ private wrapInForwarder;
21
+ /**
22
+ * Override sendAndMonitorTransaction to wrap the request in a forwarder call.
23
+ */
24
+ sendAndMonitorTransaction(request: L1TxRequest, gasConfig?: L1TxConfig, blobInputs?: L1BlobInputs): Promise<{
25
+ receipt: import("viem").TransactionReceipt;
26
+ state: import("./types.js").L1TxState;
27
+ }>;
28
+ }
29
+ export declare function createForwarderL1TxUtilsFromViemWallet(client: ExtendedViemWalletClient, forwarderAddress: EthAddress, deps?: {
30
+ logger?: Logger;
31
+ dateProvider?: DateProvider;
32
+ store?: IL1TxStore;
33
+ metrics?: IL1TxMetrics;
34
+ }, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): ForwarderL1TxUtils;
35
+ export declare function createForwarderL1TxUtilsFromEthSigner(client: ViemClient, signer: EthSigner, forwarderAddress: EthAddress, deps?: {
36
+ logger?: Logger;
37
+ dateProvider?: DateProvider;
38
+ store?: IL1TxStore;
39
+ metrics?: IL1TxMetrics;
40
+ }, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): ForwarderL1TxUtils;
41
+ //# sourceMappingURL=forwarder_l1_tx_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forwarder_l1_tx_utils.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/forwarder_l1_tx_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,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AE,YAAY,CAAC;CACnB,EACN,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,gBAAgB,GAAE,OAAe,sBAkBlC"}
@@ -0,0 +1,48 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { encodeFunctionData } from 'viem';
3
+ import { FORWARDER_ABI } from '../forwarder_proxy.js';
4
+ import { L1TxUtilsWithBlobs } from './l1_tx_utils_with_blobs.js';
5
+ import { createViemSigner } from './signer.js';
6
+ /**
7
+ * Extends L1TxUtilsWithBlobs to wrap all transactions through a forwarder contract.
8
+ * This is mainly used for testing the archiver's ability to decode transactions that go through proxies.
9
+ */ export class ForwarderL1TxUtils extends L1TxUtilsWithBlobs {
10
+ forwarderAddress;
11
+ constructor(client, senderAddress, signingCallback, logger, dateProvider, config, debugMaxGasLimit, store, metrics, forwarderAddress){
12
+ super(client, senderAddress, signingCallback, logger, dateProvider, config, debugMaxGasLimit, store, metrics), this.forwarderAddress = forwarderAddress;
13
+ }
14
+ /**
15
+ * Wraps the transaction request in a call to the forwarder contract.
16
+ */ wrapInForwarder(request) {
17
+ const forwarderCalldata = encodeFunctionData({
18
+ abi: FORWARDER_ABI,
19
+ functionName: 'forward',
20
+ args: [
21
+ request.to,
22
+ request.data
23
+ ]
24
+ });
25
+ return {
26
+ to: this.forwarderAddress.toString(),
27
+ data: forwarderCalldata,
28
+ value: request.value,
29
+ abi: request.abi
30
+ };
31
+ }
32
+ /**
33
+ * Override sendAndMonitorTransaction to wrap the request in a forwarder call.
34
+ */ sendAndMonitorTransaction(request, gasConfig, blobInputs) {
35
+ this.logger.debug(`Wrapping transaction to ${request.to} in forwarder at ${this.forwarderAddress.toString()}`);
36
+ const wrappedRequest = this.wrapInForwarder(request);
37
+ return super.sendAndMonitorTransaction(wrappedRequest, gasConfig, blobInputs);
38
+ }
39
+ }
40
+ export function createForwarderL1TxUtilsFromViemWallet(client, forwarderAddress, deps = {}, config = {}, debugMaxGasLimit = false) {
41
+ return new ForwarderL1TxUtils(client, EthAddress.fromString(client.account.address), createViemSigner(client), deps.logger, deps.dateProvider, config, debugMaxGasLimit, deps.store, deps.metrics, forwarderAddress);
42
+ }
43
+ export function createForwarderL1TxUtilsFromEthSigner(client, signer, forwarderAddress, deps = {}, config = {}, debugMaxGasLimit = false) {
44
+ const callback = async (transaction, _signingAddress)=>{
45
+ return (await signer.signTransaction(transaction)).toViemTransactionSignature();
46
+ };
47
+ return new ForwarderL1TxUtils(client, signer.address, callback, deps.logger, deps.dateProvider, config, debugMaxGasLimit, deps.store, deps.metrics, forwarderAddress);
48
+ }
@@ -0,0 +1,3 @@
1
+ export * from './forwarder_l1_tx_utils.js';
2
+ export * from './l1_tx_utils_with_blobs.js';
3
+ //# sourceMappingURL=index-blobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-blobs.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/index-blobs.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './forwarder_l1_tx_utils.js';
2
+ export * from './l1_tx_utils_with_blobs.js';
@@ -40,7 +40,7 @@ export interface IL1TxStore {
40
40
  * @param account - The sender account address
41
41
  * @param stateId - The state ID to delete
42
42
  */
43
- deleteState(account: string, stateId: number): Promise<void>;
43
+ deleteState(account: string, ...stateId: number[]): Promise<void>;
44
44
  /**
45
45
  * Clears all transaction states for a specific account.
46
46
  * @param account - The sender account address
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAErD;;;;;OAKG;IAC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cACa,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IA8EtE,4CAA4C;YAC9B,cAAc;IAK5B,+FAA+F;IAC/F,SAAS,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC;CAGjF"}
@@ -75,11 +75,24 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
75
75
  this.logger.debug(`No states to rehydrate for account ${account}`);
76
76
  return;
77
77
  }
78
- // Convert loaded states (which have id) to the txs format
79
- this.txs = loadedStates;
80
- this.logger.info(`Rehydrated ${loadedStates.length} tx states for account ${account}`);
78
+ // Clean up excess states if we have more than MAX_L1_TX_STATES
79
+ if (loadedStates.length > MAX_L1_TX_STATES) {
80
+ this.logger.warn(`Found ${loadedStates.length} tx states for account ${account}, pruning to most recent ${MAX_L1_TX_STATES}`);
81
+ // Keep only the most recent MAX_L1_TX_STATES
82
+ const statesToKeep = loadedStates.slice(-MAX_L1_TX_STATES);
83
+ const statesToDelete = loadedStates.slice(0, -MAX_L1_TX_STATES);
84
+ // Batch delete old states in a transaction for efficiency
85
+ const idsToDelete = statesToDelete.map((s)=>s.id);
86
+ await this.store.deleteState(account, ...idsToDelete);
87
+ this.txs = statesToKeep;
88
+ this.logger.info(`Cleaned up ${statesToDelete.length} old tx states, kept ${statesToKeep.length} for account ${account}`);
89
+ } else {
90
+ // Convert loaded states (which have id) to the txs format
91
+ this.txs = loadedStates;
92
+ this.logger.info(`Rehydrated ${loadedStates.length} tx states for account ${account}`);
93
+ }
81
94
  // Find all pending states and resume monitoring
82
- const pendingStates = loadedStates.filter((state)=>!TerminalTxUtilsState.includes(state.status));
95
+ const pendingStates = this.txs.filter((state)=>!TerminalTxUtilsState.includes(state.status));
83
96
  if (pendingStates.length === 0) {
84
97
  return;
85
98
  }
package/dest/types.d.ts CHANGED
@@ -1,6 +1,61 @@
1
- import type { Abi, Account, Chain, Client, FallbackTransport, GetContractReturnType, HttpTransport, PublicActions, PublicClient, PublicRpcSchema, WalletActions, WalletRpcSchema } from 'viem';
1
+ import type { Abi, Account, Chain, Client, FallbackTransport, GetContractReturnType, Hex, HttpTransport, PublicActions, PublicClient, PublicRpcSchema, WalletActions, WalletRpcSchema } from 'viem';
2
2
  /** Type for a viem public client */
3
3
  export type ViemPublicClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain>;
4
+ export type PublicRpcDebugSchema = [
5
+ {
6
+ Method: 'debug_traceTransaction';
7
+ Parameters: [txHash: `0x${string}`, options: {
8
+ tracer: 'callTracer';
9
+ }];
10
+ ReturnType: DebugCallTrace;
11
+ },
12
+ {
13
+ Method: 'trace_transaction';
14
+ Parameters: [txHash: `0x${string}`];
15
+ ReturnType: TraceTransactionResponse[];
16
+ }
17
+ ];
18
+ /** Return type for a debug_traceTransaction call */
19
+ export type DebugCallTrace = {
20
+ from: Hex;
21
+ to?: Hex;
22
+ type: string;
23
+ input?: Hex;
24
+ output?: Hex;
25
+ gas?: Hex;
26
+ gasUsed?: Hex;
27
+ value?: Hex;
28
+ error?: string;
29
+ calls?: DebugCallTrace[];
30
+ };
31
+ /** Action object for a trace_transaction call */
32
+ export type TraceAction = {
33
+ from: Hex;
34
+ to?: Hex;
35
+ callType: string;
36
+ gas?: Hex;
37
+ input?: Hex;
38
+ value?: Hex;
39
+ };
40
+ /** Result object for a trace_transaction call */
41
+ export type TraceResult = {
42
+ gasUsed?: Hex;
43
+ output?: Hex;
44
+ };
45
+ /** Return type for a single trace in trace_transaction response */
46
+ export type TraceTransactionResponse = {
47
+ action: TraceAction;
48
+ result?: TraceResult;
49
+ error?: string;
50
+ subtraces: number;
51
+ traceAddress: number[];
52
+ type: string;
53
+ };
54
+ /** Type for a viem public client with support for debug methods */
55
+ export type ViemPublicDebugClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain, undefined, [
56
+ ...PublicRpcSchema,
57
+ ...PublicRpcDebugSchema
58
+ ]>;
4
59
  export type ExtendedViemWalletClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account, [
5
60
  ...PublicRpcSchema,
6
61
  ...WalletRpcSchema
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,OAAO,EACP,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,MAAM,CAAC;AAEd,oCAAoC;AACpC,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAEvF,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAC3C,iBAAiB,CAAC,SAAS,aAAa,EAAE,CAAC,EAC3C,KAAK,EACL,OAAO,EACP;IAAC,GAAG,eAAe;IAAE,GAAG,eAAe;CAAC,EACxC,aAAa,CAAC,iBAAiB,CAAC,SAAS,aAAa,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAClG,CAAC;AAEF,4FAA4F;AAC5F,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,wBAAwB,CAAC;AAErE,6EAA6E;AAC7E,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,GAAG,IAAI,qBAAqB,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;AAEnG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,wBAAwB,CAEvF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,OAAO,EACP,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,GAAG,EACH,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAA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/index.js",
@@ -8,7 +8,7 @@
8
8
  "./contracts": "./dest/contracts/index.js",
9
9
  "./deploy-l1-contracts": "./dest/deploy_l1_contracts.js",
10
10
  "./l1-contract-addresses": "./dest/l1_contract_addresses.js",
11
- "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils/l1_tx_utils_with_blobs.js",
11
+ "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils/index-blobs.js",
12
12
  "./utils": "./dest/utils.js"
13
13
  },
14
14
  "typedocOptions": {
@@ -31,10 +31,10 @@
31
31
  "../package.common.json"
32
32
  ],
33
33
  "dependencies": {
34
- "@aztec/blob-lib": "2.1.8",
35
- "@aztec/constants": "2.1.8",
36
- "@aztec/foundation": "2.1.8",
37
- "@aztec/l1-artifacts": "2.1.8",
34
+ "@aztec/blob-lib": "2.1.9",
35
+ "@aztec/constants": "2.1.9",
36
+ "@aztec/foundation": "2.1.9",
37
+ "@aztec/l1-artifacts": "2.1.9",
38
38
  "@viem/anvil": "^0.0.10",
39
39
  "dotenv": "^16.0.3",
40
40
  "lodash.chunk": "^4.2.0",
@@ -0,0 +1,108 @@
1
+ /* eslint-disable no-console */
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Logger } from '@aztec/foundation/log';
4
+ import { createLogger } from '@aztec/foundation/log';
5
+ import { DateProvider } from '@aztec/foundation/timer';
6
+
7
+ import { type Hex, extractChain } from 'viem';
8
+ import { anvil, mainnet, sepolia } from 'viem/chains';
9
+
10
+ import { L1Deployer } from './deploy_l1_contracts.js';
11
+ import type { ExtendedViemWalletClient } from './types.js';
12
+
13
+ export const FORWARDER_SOLIDITY_SOURCE = `
14
+ contract ForwarderProxy {
15
+ function forward(address target, bytes calldata data) external payable returns (bytes memory) {
16
+ (bool success, bytes memory result) = target.call{value: msg.value}(data);
17
+ require(success, "call failed");
18
+ return result;
19
+ }
20
+ }`;
21
+
22
+ export const FORWARDER_ABI = [
23
+ {
24
+ inputs: [
25
+ {
26
+ internalType: 'address',
27
+ name: 'target',
28
+ type: 'address',
29
+ },
30
+ {
31
+ internalType: 'bytes',
32
+ name: 'data',
33
+ type: 'bytes',
34
+ },
35
+ ],
36
+ name: 'forward',
37
+ outputs: [
38
+ {
39
+ internalType: 'bytes',
40
+ name: '',
41
+ type: 'bytes',
42
+ },
43
+ ],
44
+ stateMutability: 'payable',
45
+ type: 'function',
46
+ },
47
+ ] as const;
48
+
49
+ export const FORWARDER_BYTECODE =
50
+ '0x6080604052348015600e575f5ffd5b506103bf8061001c5f395ff3fe60806040526004361061001d575f3560e01c80636fadcf7214610021575b5f5ffd5b61003b600480360381019061003691906101d0565b610051565b604051610048919061029d565b60405180910390f35b60605f5f8573ffffffffffffffffffffffffffffffffffffffff1634868660405161007d9291906102f9565b5f6040518083038185875af1925050503d805f81146100b7576040519150601f19603f3d011682016040523d82523d5f602084013e6100bc565b606091505b509150915081610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f89061036b565b60405180910390fd5b80925050509392505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61013e82610115565b9050919050565b61014e81610134565b8114610158575f5ffd5b50565b5f8135905061016981610145565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126101905761018f61016f565b5b8235905067ffffffffffffffff8111156101ad576101ac610173565b5b6020830191508360018202830111156101c9576101c8610177565b5b9250929050565b5f5f5f604084860312156101e7576101e661010d565b5b5f6101f48682870161015b565b935050602084013567ffffffffffffffff81111561021557610214610111565b5b6102218682870161017b565b92509250509250925092565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61026f8261022d565b6102798185610237565b9350610289818560208601610247565b61029281610255565b840191505092915050565b5f6020820190508181035f8301526102b58184610265565b905092915050565b5f81905092915050565b828183375f83830152505050565b5f6102e083856102bd565b93506102ed8385846102c7565b82840190509392505050565b5f6103058284866102d5565b91508190509392505050565b5f82825260208201905092915050565b7f63616c6c206661696c65640000000000000000000000000000000000000000005f82015250565b5f610355600b83610311565b915061036082610321565b602082019050919050565b5f6020820190508181035f83015261038281610349565b905091905056fea26469706673582212209a1c8cf638cf1569450a731ef9457b862f9e153b0a46e5555429bcf4dffd999564736f6c634300081e0033' as Hex;
51
+
52
+ const FORWARDER_ARTIFACT = {
53
+ name: 'Forwarder',
54
+ contractAbi: FORWARDER_ABI,
55
+ contractBytecode: FORWARDER_BYTECODE,
56
+ };
57
+
58
+ /**
59
+ * Deploys the forwarder proxy contract to L1.
60
+ * @param client - The L1 client to use for deployment
61
+ * @param logger - Optional logger
62
+ * @returns The deployed forwarder contract address
63
+ */
64
+ export async function deployForwarderProxy(client: ExtendedViemWalletClient, logger?: Logger): Promise<EthAddress> {
65
+ const log = logger ?? createLogger('ethereum:forwarder');
66
+ const nonce = await client.getTransactionCount({ address: client.account.address });
67
+ const deployer = new L1Deployer(client, nonce, new DateProvider(), false, log, undefined, false);
68
+
69
+ log.info('Deploying forwarder proxy contract');
70
+ const deployment = await deployer.deploy(FORWARDER_ARTIFACT, []);
71
+ log.info(`Forwarder proxy deployed at ${deployment.address.toString()}`);
72
+
73
+ return deployment.address;
74
+ }
75
+
76
+ /**
77
+ * Main function for deploying the forwarder proxy from command line.
78
+ * Usage: node forwarder_proxy.js <private_key> <rpc_url>
79
+ */
80
+ async function main() {
81
+ const args = process.argv.slice(2);
82
+ if (args.length < 3) {
83
+ console.error('Usage: node forwarder_proxy.js <private_key> <rpc_url> <chain_id>');
84
+ process.exit(1);
85
+ }
86
+
87
+ const [privateKey, rpcUrl, chainId] = args;
88
+
89
+ // Dynamic import to avoid pulling in dependencies at module load time
90
+ const { createExtendedL1Client } = await import('./client.js');
91
+
92
+ const client = createExtendedL1Client(
93
+ [rpcUrl],
94
+ privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`,
95
+ extractChain({ chains: [mainnet, sepolia, anvil], id: parseInt(chainId) as any }),
96
+ );
97
+ const address = await deployForwarderProxy(client);
98
+
99
+ console.log(`Forwarder proxy deployed at: ${address.toString()}`);
100
+ }
101
+
102
+ // Only run main if this is the entry point
103
+ if (import.meta.url === `file://${process.argv[1]}`) {
104
+ main().catch(err => {
105
+ console.error('Failed to deploy forwarder proxy:', err);
106
+ process.exit(1);
107
+ });
108
+ }
package/src/index.ts CHANGED
@@ -15,3 +15,4 @@ export * from './l1_types.js';
15
15
  export * from './l1_artifacts.js';
16
16
  export * from './publisher_manager.js';
17
17
  export * from './eth-signer/index.js';
18
+ export * from './forwarder_proxy.js';
package/src/l1_reader.ts CHANGED
@@ -6,6 +6,8 @@ import { type L1ContractAddresses, l1ContractAddressesMapping } from './l1_contr
6
6
  export interface L1ReaderConfig {
7
7
  /** The RPC Url of the ethereum host. */
8
8
  l1RpcUrls: string[];
9
+ /** The RPC Url of the ethereum debug host for trace and debug methods. */
10
+ l1DebugRpcUrls: string[];
9
11
  /** The chain ID of the ethereum host. */
10
12
  l1ChainId: number;
11
13
  /** The deployed l1 contract addresses */
@@ -30,6 +32,12 @@ export const l1ReaderConfigMappings: ConfigMappingsType<L1ReaderConfig> = {
30
32
  parseEnv: (val: string) => val.split(',').map(url => url.trim()),
31
33
  defaultValue: [],
32
34
  },
35
+ l1DebugRpcUrls: {
36
+ env: 'ETHEREUM_DEBUG_HOSTS',
37
+ description: 'The RPC Url of the ethereum debug host for trace and debug methods.',
38
+ parseEnv: (val: string) => val.split(',').map(url => url.trim()),
39
+ defaultValue: [],
40
+ },
33
41
  viemPollingIntervalMS: {
34
42
  env: 'L1_READER_VIEM_POLLING_INTERVAL_MS',
35
43
  description: 'The polling interval viem uses in ms',
@@ -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,2 @@
1
+ export * from './forwarder_l1_tx_utils.js';
2
+ export * from './l1_tx_utils_with_blobs.js';
@@ -46,7 +46,7 @@ export interface IL1TxStore {
46
46
  * @param account - The sender account address
47
47
  * @param stateId - The state ID to delete
48
48
  */
49
- deleteState(account: string, stateId: number): Promise<void>;
49
+ deleteState(account: string, ...stateId: number[]): Promise<void>;
50
50
 
51
51
  /**
52
52
  * Clears all transaction states for a specific account.
@@ -130,12 +130,32 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
130
130
  return;
131
131
  }
132
132
 
133
- // Convert loaded states (which have id) to the txs format
134
- this.txs = loadedStates;
135
- this.logger.info(`Rehydrated ${loadedStates.length} tx states for account ${account}`);
133
+ // Clean up excess states if we have more than MAX_L1_TX_STATES
134
+ if (loadedStates.length > MAX_L1_TX_STATES) {
135
+ this.logger.warn(
136
+ `Found ${loadedStates.length} tx states for account ${account}, pruning to most recent ${MAX_L1_TX_STATES}`,
137
+ );
138
+
139
+ // Keep only the most recent MAX_L1_TX_STATES
140
+ const statesToKeep = loadedStates.slice(-MAX_L1_TX_STATES);
141
+ const statesToDelete = loadedStates.slice(0, -MAX_L1_TX_STATES);
142
+
143
+ // Batch delete old states in a transaction for efficiency
144
+ const idsToDelete = statesToDelete.map(s => s.id);
145
+ await this.store.deleteState(account, ...idsToDelete);
146
+
147
+ this.txs = statesToKeep;
148
+ this.logger.info(
149
+ `Cleaned up ${statesToDelete.length} old tx states, kept ${statesToKeep.length} for account ${account}`,
150
+ );
151
+ } else {
152
+ // Convert loaded states (which have id) to the txs format
153
+ this.txs = loadedStates;
154
+ this.logger.info(`Rehydrated ${loadedStates.length} tx states for account ${account}`);
155
+ }
136
156
 
137
157
  // Find all pending states and resume monitoring
138
- const pendingStates = loadedStates.filter(state => !TerminalTxUtilsState.includes(state.status));
158
+ const pendingStates = this.txs.filter(state => !TerminalTxUtilsState.includes(state.status));
139
159
  if (pendingStates.length === 0) {
140
160
  return;
141
161
  }
package/src/types.ts CHANGED
@@ -5,6 +5,7 @@ import type {
5
5
  Client,
6
6
  FallbackTransport,
7
7
  GetContractReturnType,
8
+ Hex,
8
9
  HttpTransport,
9
10
  PublicActions,
10
11
  PublicClient,
@@ -16,6 +17,67 @@ import type {
16
17
  /** Type for a viem public client */
17
18
  export type ViemPublicClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain>;
18
19
 
20
+ export type PublicRpcDebugSchema = [
21
+ {
22
+ Method: 'debug_traceTransaction';
23
+ Parameters: [txHash: `0x${string}`, options: { tracer: 'callTracer' }];
24
+ ReturnType: DebugCallTrace;
25
+ },
26
+ {
27
+ Method: 'trace_transaction';
28
+ Parameters: [txHash: `0x${string}`];
29
+ ReturnType: TraceTransactionResponse[];
30
+ },
31
+ ];
32
+
33
+ /** Return type for a debug_traceTransaction call */
34
+ export type DebugCallTrace = {
35
+ from: Hex;
36
+ to?: Hex;
37
+ type: string;
38
+ input?: Hex;
39
+ output?: Hex;
40
+ gas?: Hex;
41
+ gasUsed?: Hex;
42
+ value?: Hex;
43
+ error?: string;
44
+ calls?: DebugCallTrace[];
45
+ };
46
+
47
+ /** Action object for a trace_transaction call */
48
+ export type TraceAction = {
49
+ from: Hex;
50
+ to?: Hex;
51
+ callType: string;
52
+ gas?: Hex;
53
+ input?: Hex;
54
+ value?: Hex;
55
+ };
56
+
57
+ /** Result object for a trace_transaction call */
58
+ export type TraceResult = {
59
+ gasUsed?: Hex;
60
+ output?: Hex;
61
+ };
62
+
63
+ /** Return type for a single trace in trace_transaction response */
64
+ export type TraceTransactionResponse = {
65
+ action: TraceAction;
66
+ result?: TraceResult;
67
+ error?: string;
68
+ subtraces: number;
69
+ traceAddress: number[];
70
+ type: string;
71
+ };
72
+
73
+ /** Type for a viem public client with support for debug methods */
74
+ export type ViemPublicDebugClient = PublicClient<
75
+ FallbackTransport<HttpTransport[]>,
76
+ Chain,
77
+ undefined,
78
+ [...PublicRpcSchema, ...PublicRpcDebugSchema]
79
+ >;
80
+
19
81
  export type ExtendedViemWalletClient = Client<
20
82
  FallbackTransport<readonly HttpTransport[]>,
21
83
  Chain,