@aztec/ethereum 0.0.0-test.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.
Files changed (118) hide show
  1. package/README.md +3 -0
  2. package/dest/chain.d.ts +25 -0
  3. package/dest/chain.d.ts.map +1 -0
  4. package/dest/chain.js +53 -0
  5. package/dest/client.d.ts +16 -0
  6. package/dest/client.d.ts.map +1 -0
  7. package/dest/client.js +31 -0
  8. package/dest/config.d.ts +39 -0
  9. package/dest/config.d.ts.map +1 -0
  10. package/dest/config.js +70 -0
  11. package/dest/constants.d.ts +4 -0
  12. package/dest/constants.d.ts.map +1 -0
  13. package/dest/constants.js +2 -0
  14. package/dest/contracts/empire_base.d.ts +13 -0
  15. package/dest/contracts/empire_base.d.ts.map +1 -0
  16. package/dest/contracts/empire_base.js +11 -0
  17. package/dest/contracts/fee_juice.d.ts +15 -0
  18. package/dest/contracts/fee_juice.d.ts.map +1 -0
  19. package/dest/contracts/fee_juice.js +52 -0
  20. package/dest/contracts/forwarder.d.ts +24 -0
  21. package/dest/contracts/forwarder.d.ts.map +1 -0
  22. package/dest/contracts/forwarder.js +101 -0
  23. package/dest/contracts/governance.d.ts +79 -0
  24. package/dest/contracts/governance.d.ts.map +1 -0
  25. package/dest/contracts/governance.js +247 -0
  26. package/dest/contracts/governance_proposer.d.ts +28 -0
  27. package/dest/contracts/governance_proposer.d.ts.map +1 -0
  28. package/dest/contracts/governance_proposer.js +82 -0
  29. package/dest/contracts/index.d.ts +9 -0
  30. package/dest/contracts/index.d.ts.map +1 -0
  31. package/dest/contracts/index.js +8 -0
  32. package/dest/contracts/registry.d.ts +24 -0
  33. package/dest/contracts/registry.d.ts.map +1 -0
  34. package/dest/contracts/registry.js +85 -0
  35. package/dest/contracts/rollup.d.ts +92 -0
  36. package/dest/contracts/rollup.d.ts.map +1 -0
  37. package/dest/contracts/rollup.js +234 -0
  38. package/dest/contracts/slashing_proposer.d.ts +21 -0
  39. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  40. package/dest/contracts/slashing_proposer.js +47 -0
  41. package/dest/deploy_l1_contracts.d.ts +21210 -0
  42. package/dest/deploy_l1_contracts.d.ts.map +1 -0
  43. package/dest/deploy_l1_contracts.js +687 -0
  44. package/dest/eth_cheat_codes.d.ts +147 -0
  45. package/dest/eth_cheat_codes.d.ts.map +1 -0
  46. package/dest/eth_cheat_codes.js +303 -0
  47. package/dest/index.d.ts +14 -0
  48. package/dest/index.d.ts.map +1 -0
  49. package/dest/index.js +13 -0
  50. package/dest/l1_contract_addresses.d.ts +57 -0
  51. package/dest/l1_contract_addresses.d.ts.map +1 -0
  52. package/dest/l1_contract_addresses.js +97 -0
  53. package/dest/l1_reader.d.ts +16 -0
  54. package/dest/l1_reader.d.ts.map +1 -0
  55. package/dest/l1_reader.js +27 -0
  56. package/dest/l1_tx_utils.d.ts +192 -0
  57. package/dest/l1_tx_utils.d.ts.map +1 -0
  58. package/dest/l1_tx_utils.js +641 -0
  59. package/dest/l1_tx_utils_with_blobs.d.ts +12 -0
  60. package/dest/l1_tx_utils_with_blobs.d.ts.map +1 -0
  61. package/dest/l1_tx_utils_with_blobs.js +64 -0
  62. package/dest/queries.d.ts +12 -0
  63. package/dest/queries.d.ts.map +1 -0
  64. package/dest/queries.js +35 -0
  65. package/dest/test/delayed_tx_utils.d.ts +8 -0
  66. package/dest/test/delayed_tx_utils.d.ts.map +1 -0
  67. package/dest/test/delayed_tx_utils.js +21 -0
  68. package/dest/test/eth_cheat_codes_with_state.d.ts +18 -0
  69. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -0
  70. package/dest/test/eth_cheat_codes_with_state.js +34 -0
  71. package/dest/test/index.d.ts +6 -0
  72. package/dest/test/index.d.ts.map +1 -0
  73. package/dest/test/index.js +5 -0
  74. package/dest/test/start_anvil.d.ts +12 -0
  75. package/dest/test/start_anvil.d.ts.map +1 -0
  76. package/dest/test/start_anvil.js +46 -0
  77. package/dest/test/tx_delayer.d.ts +25 -0
  78. package/dest/test/tx_delayer.d.ts.map +1 -0
  79. package/dest/test/tx_delayer.js +116 -0
  80. package/dest/test/upgrade_utils.d.ts +11 -0
  81. package/dest/test/upgrade_utils.d.ts.map +1 -0
  82. package/dest/test/upgrade_utils.js +104 -0
  83. package/dest/types.d.ts +14 -0
  84. package/dest/types.d.ts.map +1 -0
  85. package/dest/types.js +1 -0
  86. package/dest/utils.d.ts +24 -0
  87. package/dest/utils.d.ts.map +1 -0
  88. package/dest/utils.js +209 -0
  89. package/package.json +98 -0
  90. package/src/chain.ts +71 -0
  91. package/src/client.ts +58 -0
  92. package/src/config.ts +103 -0
  93. package/src/constants.ts +4 -0
  94. package/src/contracts/empire_base.ts +19 -0
  95. package/src/contracts/fee_juice.ts +43 -0
  96. package/src/contracts/forwarder.ts +132 -0
  97. package/src/contracts/governance.ts +285 -0
  98. package/src/contracts/governance_proposer.ts +82 -0
  99. package/src/contracts/index.ts +8 -0
  100. package/src/contracts/registry.ts +106 -0
  101. package/src/contracts/rollup.ts +274 -0
  102. package/src/contracts/slashing_proposer.ts +51 -0
  103. package/src/deploy_l1_contracts.ts +948 -0
  104. package/src/eth_cheat_codes.ts +314 -0
  105. package/src/index.ts +13 -0
  106. package/src/l1_contract_addresses.ts +109 -0
  107. package/src/l1_reader.ts +42 -0
  108. package/src/l1_tx_utils.ts +847 -0
  109. package/src/l1_tx_utils_with_blobs.ts +86 -0
  110. package/src/queries.ts +58 -0
  111. package/src/test/delayed_tx_utils.ts +24 -0
  112. package/src/test/eth_cheat_codes_with_state.ts +38 -0
  113. package/src/test/index.ts +5 -0
  114. package/src/test/start_anvil.ts +52 -0
  115. package/src/test/tx_delayer.ts +163 -0
  116. package/src/test/upgrade_utils.ts +100 -0
  117. package/src/types.ts +33 -0
  118. package/src/utils.ts +276 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Ethereum
2
+
3
+ This package provides configuration and code for common chain operations such as contract deployment etc.
@@ -0,0 +1,25 @@
1
+ import type { Chain } from 'viem';
2
+ /**
3
+ * Interface containing the connection and chain properties to interact with a blockchain.
4
+ */
5
+ export interface EthereumChain {
6
+ /**
7
+ * An instance of the viem chain data.
8
+ */
9
+ chainInfo: Chain;
10
+ /**
11
+ * The list of actual urls to be used.
12
+ */
13
+ rpcUrls: string[];
14
+ }
15
+ /**
16
+ * Helper function to create an instance of Aztec Chain from an rpc url and chain id.
17
+ * @param rpcUrls - The rpc url of the chain or a chain identifier (e.g. 'http://localhost:8545')
18
+ * @param chainId - The chain id of the chain or a chain identifier (e.g. 1337)
19
+ */
20
+ export declare function createEthereumChain(rpcUrls: string[], _chainId: number | string): EthereumChain;
21
+ /**
22
+ * Helper function to determine if a chain id is an instance of Anvil
23
+ */
24
+ export declare function isAnvilTestChain(_chainId: number | string): boolean;
25
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAKlC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,SAAS,EAAE,KAAK,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CA+B/F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CASnE"}
package/dest/chain.js ADDED
@@ -0,0 +1,53 @@
1
+ import { foundry } from 'viem/chains';
2
+ import { AZTEC_TEST_CHAIN_ID } from './constants.js';
3
+ /**
4
+ * Helper function to create an instance of Aztec Chain from an rpc url and chain id.
5
+ * @param rpcUrls - The rpc url of the chain or a chain identifier (e.g. 'http://localhost:8545')
6
+ * @param chainId - The chain id of the chain or a chain identifier (e.g. 1337)
7
+ */ export function createEthereumChain(rpcUrls, _chainId) {
8
+ let chainId;
9
+ if (typeof _chainId === 'string') {
10
+ chainId = +_chainId;
11
+ } else {
12
+ chainId = _chainId;
13
+ }
14
+ if (chainId) {
15
+ return {
16
+ chainInfo: {
17
+ id: chainId,
18
+ name: 'Ethereum',
19
+ rpcUrls: {
20
+ default: {
21
+ http: rpcUrls
22
+ }
23
+ },
24
+ nativeCurrency: {
25
+ decimals: 18,
26
+ name: 'Ether',
27
+ symbol: 'ETH'
28
+ }
29
+ },
30
+ rpcUrls
31
+ };
32
+ } else {
33
+ return {
34
+ chainInfo: foundry,
35
+ rpcUrls
36
+ };
37
+ }
38
+ }
39
+ /**
40
+ * Helper function to determine if a chain id is an instance of Anvil
41
+ */ export function isAnvilTestChain(_chainId) {
42
+ let chainId;
43
+ if (typeof _chainId === 'string') {
44
+ chainId = +_chainId;
45
+ } else {
46
+ chainId = _chainId;
47
+ }
48
+ const testChains = [
49
+ foundry.id,
50
+ AZTEC_TEST_CHAIN_ID
51
+ ];
52
+ return testChains.includes(chainId);
53
+ }
@@ -0,0 +1,16 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import type { ViemPublicClient } from './types.js';
3
+ type Config = {
4
+ /** The RPC Url of the ethereum host. */
5
+ l1RpcUrls: string[];
6
+ /** The chain ID of the ethereum host. */
7
+ l1ChainId: number;
8
+ /** The polling interval viem uses in ms */
9
+ viemPollingIntervalMS?: number;
10
+ };
11
+ /** Returns a viem public client given the L1 config. */
12
+ export declare function getPublicClient(config: Config): ViemPublicClient;
13
+ /** Returns a viem public client after waiting for the L1 RPC node to become available. */
14
+ export declare function waitForPublicClient(config: Config, logger?: Logger): Promise<ViemPublicClient>;
15
+ export {};
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAMpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,KAAK,MAAM,GAAG;IACZ,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAIF,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAOhE;AAED,0FAA0F;AAC1F,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAIpG"}
package/dest/client.js ADDED
@@ -0,0 +1,31 @@
1
+ import { retryUntil } from '@aztec/foundation/retry';
2
+ import { createPublicClient, fallback, http } from 'viem';
3
+ import { createEthereumChain } from './chain.js';
4
+ // TODO: Use these methods to abstract the creation of viem clients.
5
+ /** Returns a viem public client given the L1 config. */ export function getPublicClient(config) {
6
+ const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
7
+ return createPublicClient({
8
+ chain: chain.chainInfo,
9
+ transport: fallback(config.l1RpcUrls.map((url)=>http(url))),
10
+ pollingInterval: config.viemPollingIntervalMS
11
+ });
12
+ }
13
+ /** Returns a viem public client after waiting for the L1 RPC node to become available. */ export async function waitForPublicClient(config, logger) {
14
+ const client = getPublicClient(config);
15
+ await waitForRpc(client, config, logger);
16
+ return client;
17
+ }
18
+ async function waitForRpc(client, config, logger) {
19
+ const l1ChainId = await retryUntil(async ()=>{
20
+ let chainId = 0;
21
+ try {
22
+ chainId = await client.getChainId();
23
+ } catch (err) {
24
+ logger?.warn(`Failed to connect to Ethereum node at ${config.l1RpcUrls.join(', ')}. Retrying...`);
25
+ }
26
+ return chainId;
27
+ }, `L1 RPC url at ${config.l1RpcUrls.join(', ')}`, 600, 1);
28
+ if (l1ChainId !== config.l1ChainId) {
29
+ throw new Error(`Ethereum node at ${config.l1RpcUrls.join(', ')} has chain ID ${l1ChainId} but expected ${config.l1ChainId}`);
30
+ }
31
+ }
@@ -0,0 +1,39 @@
1
+ import { type ConfigMappingsType } from '@aztec/foundation/config';
2
+ import { type L1TxUtilsConfig } from './l1_tx_utils.js';
3
+ export type L1ContractsConfig = {
4
+ /** How many seconds an L1 slot lasts. */
5
+ ethereumSlotDuration: number;
6
+ /** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
7
+ aztecSlotDuration: number;
8
+ /** How many L2 slots an epoch lasts. */
9
+ aztecEpochDuration: number;
10
+ /** The target validator committee size. */
11
+ aztecTargetCommitteeSize: number;
12
+ /** The number of L2 slots that we can wait for a proof of an epoch to be produced. */
13
+ aztecProofSubmissionWindow: number;
14
+ /** The minimum stake for a validator. */
15
+ minimumStake: bigint;
16
+ /** The slashing quorum */
17
+ slashingQuorum: number;
18
+ /** The slashing round size */
19
+ slashingRoundSize: number;
20
+ /** Governance proposing quorum */
21
+ governanceProposerQuorum: number;
22
+ /** Governance proposing round size */
23
+ governanceProposerRoundSize: number;
24
+ } & L1TxUtilsConfig;
25
+ export declare const DefaultL1ContractsConfig: {
26
+ ethereumSlotDuration: number;
27
+ aztecSlotDuration: number;
28
+ aztecEpochDuration: number;
29
+ aztecTargetCommitteeSize: number;
30
+ aztecProofSubmissionWindow: number;
31
+ minimumStake: bigint;
32
+ slashingQuorum: number;
33
+ slashingRoundSize: number;
34
+ governanceProposerQuorum: number;
35
+ governanceProposerRoundSize: number;
36
+ };
37
+ export declare const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig>;
38
+ export declare function getL1ContractsConfigEnvVars(): L1ContractsConfig;
39
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,kBAAkB,CAAC;AAEjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yCAAyC;IACzC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uFAAuF;IACvF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wCAAwC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,wBAAwB,EAAE,MAAM,CAAC;IACjC,sFAAsF;IACtF,0BAA0B,EAAE,MAAM,CAAC;IACnC,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,8BAA8B;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,wBAAwB,EAAE,MAAM,CAAC;IACjC,sCAAsC;IACtC,2BAA2B,EAAE,MAAM,CAAC;CACrC,GAAG,eAAe,CAAC;AAEpB,eAAO,MAAM,wBAAwB;;;;;;;;;;;CAWR,CAAC;AAE9B,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,iBAAiB,CAqD3E,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,iBAAiB,CAE/D"}
package/dest/config.js ADDED
@@ -0,0 +1,70 @@
1
+ import { bigintConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
2
+ import { l1TxUtilsConfigMappings } from './l1_tx_utils.js';
3
+ export const DefaultL1ContractsConfig = {
4
+ ethereumSlotDuration: 12,
5
+ aztecSlotDuration: 24,
6
+ aztecEpochDuration: 16,
7
+ aztecTargetCommitteeSize: 48,
8
+ aztecProofSubmissionWindow: 31,
9
+ minimumStake: BigInt(100e18),
10
+ slashingQuorum: 6,
11
+ slashingRoundSize: 10,
12
+ governanceProposerQuorum: 6,
13
+ governanceProposerRoundSize: 10
14
+ };
15
+ export const l1ContractsConfigMappings = {
16
+ ethereumSlotDuration: {
17
+ env: 'ETHEREUM_SLOT_DURATION',
18
+ description: 'How many seconds an L1 slot lasts.',
19
+ ...numberConfigHelper(DefaultL1ContractsConfig.ethereumSlotDuration)
20
+ },
21
+ aztecSlotDuration: {
22
+ env: 'AZTEC_SLOT_DURATION',
23
+ description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
24
+ ...numberConfigHelper(DefaultL1ContractsConfig.aztecSlotDuration)
25
+ },
26
+ aztecEpochDuration: {
27
+ env: 'AZTEC_EPOCH_DURATION',
28
+ description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
29
+ ...numberConfigHelper(DefaultL1ContractsConfig.aztecEpochDuration)
30
+ },
31
+ aztecTargetCommitteeSize: {
32
+ env: 'AZTEC_TARGET_COMMITTEE_SIZE',
33
+ description: 'The target validator committee size.',
34
+ ...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize)
35
+ },
36
+ aztecProofSubmissionWindow: {
37
+ env: 'AZTEC_PROOF_SUBMISSION_WINDOW',
38
+ description: 'The number of L2 slots that a proof for an epoch can be submitted in, starting from the beginning of the epoch.',
39
+ ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionWindow)
40
+ },
41
+ minimumStake: {
42
+ env: 'AZTEC_MINIMUM_STAKE',
43
+ description: 'The minimum stake for a validator.',
44
+ ...bigintConfigHelper(DefaultL1ContractsConfig.minimumStake)
45
+ },
46
+ slashingQuorum: {
47
+ env: 'AZTEC_SLASHING_QUORUM',
48
+ description: 'The slashing quorum',
49
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingQuorum)
50
+ },
51
+ slashingRoundSize: {
52
+ env: 'AZTEC_SLASHING_ROUND_SIZE',
53
+ description: 'The slashing round size',
54
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSize)
55
+ },
56
+ governanceProposerQuorum: {
57
+ env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
58
+ description: 'The governance proposing quorum',
59
+ ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerQuorum)
60
+ },
61
+ governanceProposerRoundSize: {
62
+ env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
63
+ description: 'The governance proposing round size',
64
+ ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerRoundSize)
65
+ },
66
+ ...l1TxUtilsConfigMappings
67
+ };
68
+ export function getL1ContractsConfigEnvVars() {
69
+ return getConfigFromMappings(l1ContractsConfigMappings);
70
+ }
@@ -0,0 +1,4 @@
1
+ import type { Hex } from 'viem';
2
+ export declare const NULL_KEY: Hex;
3
+ export declare const AZTEC_TEST_CHAIN_ID = 677692;
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,eAAO,MAAM,QAAQ,EAAE,GAA+E,CAAC;AACvG,eAAO,MAAM,mBAAmB,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const NULL_KEY = `0x${'0000000000000000000000000000000000000000000000000000000000000000'}`;
2
+ export const AZTEC_TEST_CHAIN_ID = 677692;
@@ -0,0 +1,13 @@
1
+ import { type Hex } from 'viem';
2
+ import type { L1TxRequest } from '../l1_tx_utils.js';
3
+ export interface IEmpireBase {
4
+ getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
5
+ lastVote: bigint;
6
+ leader: Hex;
7
+ executed: boolean;
8
+ }>;
9
+ computeRound(slot: bigint): Promise<bigint>;
10
+ createVoteRequest(payload: Hex): L1TxRequest;
11
+ }
12
+ export declare function encodeVote(payload: Hex): Hex;
13
+ //# sourceMappingURL=empire_base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empire_base.d.ts","sourceRoot":"","sources":["../../src/contracts/empire_base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAsB,MAAM,MAAM,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/G,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,CAAC;CAC9C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAM5C"}
@@ -0,0 +1,11 @@
1
+ import { EmpireBaseAbi } from '@aztec/l1-artifacts/EmpireBaseAbi';
2
+ import { encodeFunctionData } from 'viem';
3
+ export function encodeVote(payload) {
4
+ return encodeFunctionData({
5
+ abi: EmpireBaseAbi,
6
+ functionName: 'vote',
7
+ args: [
8
+ payload
9
+ ]
10
+ });
11
+ }
@@ -0,0 +1,15 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { type Hex } from 'viem';
3
+ import type { L1Clients } from '../types.js';
4
+ export declare class FeeJuiceContract {
5
+ readonly publicClient: L1Clients['publicClient'];
6
+ readonly walletClient: L1Clients['walletClient'] | undefined;
7
+ private readonly publicFeeJuice;
8
+ private readonly walletFeeJuice;
9
+ constructor(address: Hex, publicClient: L1Clients['publicClient'], walletClient: L1Clients['walletClient'] | undefined);
10
+ get address(): EthAddress;
11
+ private assertWalletFeeJuice;
12
+ mint(to: Hex, amount: bigint): Promise<void>;
13
+ approve(spender: Hex, amount: bigint): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=fee_juice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee_juice.d.ts","sourceRoot":"","sources":["../../src/contracts/fee_juice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,gBAAgB;aAMT,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC;aACvC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS;IANrE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuE;IACtG,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmF;gBAGhH,OAAO,EAAE,GAAG,EACI,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,EACvC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS;IAMrE,IAAW,OAAO,eAEjB;IAED,OAAO,CAAC,oBAAoB;IAOf,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAM5B,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;CAKlD"}
@@ -0,0 +1,52 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts';
3
+ import { getContract } from 'viem';
4
+ export class FeeJuiceContract {
5
+ publicClient;
6
+ walletClient;
7
+ publicFeeJuice;
8
+ walletFeeJuice;
9
+ constructor(address, publicClient, walletClient){
10
+ this.publicClient = publicClient;
11
+ this.walletClient = walletClient;
12
+ this.publicFeeJuice = getContract({
13
+ address,
14
+ abi: FeeJuiceAbi,
15
+ client: publicClient
16
+ });
17
+ this.walletFeeJuice = walletClient ? getContract({
18
+ address,
19
+ abi: FeeJuiceAbi,
20
+ client: walletClient
21
+ }) : undefined;
22
+ }
23
+ get address() {
24
+ return EthAddress.fromString(this.publicFeeJuice.address);
25
+ }
26
+ assertWalletFeeJuice() {
27
+ if (!this.walletFeeJuice) {
28
+ throw new Error('Wallet client is required for this operation');
29
+ }
30
+ return this.walletFeeJuice;
31
+ }
32
+ async mint(to, amount) {
33
+ const walletFeeJuice = this.assertWalletFeeJuice();
34
+ const tx = await walletFeeJuice.write.mint([
35
+ to,
36
+ amount
37
+ ]);
38
+ await this.publicClient.waitForTransactionReceipt({
39
+ hash: tx
40
+ });
41
+ }
42
+ async approve(spender, amount) {
43
+ const walletFeeJuice = this.assertWalletFeeJuice();
44
+ const tx = await walletFeeJuice.write.approve([
45
+ spender,
46
+ amount
47
+ ]);
48
+ await this.publicClient.waitForTransactionReceipt({
49
+ hash: tx
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,24 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import { type Hex } from 'viem';
3
+ import type { L1BlobInputs, L1GasConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
4
+ import type { L1Clients, ViemPublicClient, ViemWalletClient } from '../types.js';
5
+ export declare class ForwarderContract {
6
+ readonly client: L1Clients['publicClient'];
7
+ readonly rollupAddress: Hex;
8
+ private readonly forwarder;
9
+ constructor(client: L1Clients['publicClient'], address: Hex, rollupAddress: Hex);
10
+ static create(owner: Hex, walletClient: ViemWalletClient, publicClient: ViemPublicClient, logger: Logger, rollupAddress: Hex): Promise<ForwarderContract>;
11
+ getAddress(): `0x${string}`;
12
+ forward(requests: L1TxRequest[], l1TxUtils: L1TxUtils, gasConfig: L1GasConfig | undefined, blobConfig: L1BlobInputs | undefined, logger: Logger): Promise<{
13
+ receipt: import("viem").TransactionReceipt;
14
+ gasPrice: import("../l1_tx_utils.js").GasPrice;
15
+ stats: import("../l1_tx_utils.js").TransactionStats | undefined;
16
+ errorMsg?: undefined;
17
+ } | {
18
+ receipt: import("viem").TransactionReceipt;
19
+ gasPrice: import("../l1_tx_utils.js").GasPrice;
20
+ errorMsg: string | undefined;
21
+ stats?: undefined;
22
+ }>;
23
+ }
24
+ //# sourceMappingURL=forwarder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/contracts/forwarder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGjF,qBAAa,iBAAiB;aAGA,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC;aAAgC,aAAa,EAAE,GAAG;IAF/G,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+D;gBAE7D,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,EAAkB,aAAa,EAAE,GAAG;WAIlG,MAAM,CACjB,KAAK,EAAE,GAAG,EACV,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,GAAG;IAwBb,UAAU;IAIJ,OAAO,CAClB,QAAQ,EAAE,WAAW,EAAE,EACvB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,WAAW,GAAG,SAAS,EAClC,UAAU,EAAE,YAAY,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM;;;;;;;;;;;CAqEjB"}
@@ -0,0 +1,101 @@
1
+ import { toHex } from '@aztec/foundation/bigint-buffer';
2
+ import { ForwarderAbi, ForwarderBytecode } from '@aztec/l1-artifacts';
3
+ import { encodeFunctionData, getContract } from 'viem';
4
+ import { deployL1Contract } from '../deploy_l1_contracts.js';
5
+ import { RollupContract } from './rollup.js';
6
+ export class ForwarderContract {
7
+ client;
8
+ rollupAddress;
9
+ forwarder;
10
+ constructor(client, address, rollupAddress){
11
+ this.client = client;
12
+ this.rollupAddress = rollupAddress;
13
+ this.forwarder = getContract({
14
+ address,
15
+ abi: ForwarderAbi,
16
+ client
17
+ });
18
+ }
19
+ static async create(owner, walletClient, publicClient, logger, rollupAddress) {
20
+ logger.info('Deploying forwarder contract');
21
+ const { address, txHash } = await deployL1Contract(walletClient, publicClient, ForwarderAbi, ForwarderBytecode, [
22
+ owner
23
+ ], owner, undefined, logger);
24
+ if (txHash) {
25
+ await publicClient.waitForTransactionReceipt({
26
+ hash: txHash
27
+ });
28
+ }
29
+ logger.info(`Forwarder contract deployed at ${address} with owner ${owner}`);
30
+ return new ForwarderContract(publicClient, address.toString(), rollupAddress);
31
+ }
32
+ getAddress() {
33
+ return this.forwarder.address;
34
+ }
35
+ async forward(requests, l1TxUtils, gasConfig, blobConfig, logger) {
36
+ requests = requests.filter((request)=>request.to !== null);
37
+ const toArgs = requests.map((request)=>request.to);
38
+ const dataArgs = requests.map((request)=>request.data);
39
+ const forwarderFunctionData = {
40
+ abi: ForwarderAbi,
41
+ functionName: 'forward',
42
+ args: [
43
+ toArgs,
44
+ dataArgs
45
+ ]
46
+ };
47
+ const encodedForwarderData = encodeFunctionData(forwarderFunctionData);
48
+ const { receipt, gasPrice } = await l1TxUtils.sendAndMonitorTransaction({
49
+ to: this.forwarder.address,
50
+ data: encodedForwarderData
51
+ }, gasConfig, blobConfig);
52
+ if (receipt.status === 'success') {
53
+ const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
54
+ return {
55
+ receipt,
56
+ gasPrice,
57
+ stats
58
+ };
59
+ } else {
60
+ logger.error('Forwarder transaction failed', undefined, {
61
+ receipt
62
+ });
63
+ const args = {
64
+ ...forwarderFunctionData,
65
+ address: this.forwarder.address
66
+ };
67
+ let errorMsg;
68
+ if (blobConfig) {
69
+ const maxFeePerBlobGas = blobConfig.maxFeePerBlobGas ?? gasPrice.maxFeePerBlobGas;
70
+ if (maxFeePerBlobGas === undefined) {
71
+ errorMsg = 'maxFeePerBlobGas is required to get the error message';
72
+ } else {
73
+ logger.debug('Trying to get error from reverted tx with blob config');
74
+ errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedForwarderData, args, {
75
+ blobs: blobConfig.blobs,
76
+ kzg: blobConfig.kzg,
77
+ maxFeePerBlobGas
78
+ }, [
79
+ {
80
+ address: this.rollupAddress,
81
+ stateDiff: [
82
+ {
83
+ slot: toHex(RollupContract.checkBlobStorageSlot, true),
84
+ value: toHex(0n, true)
85
+ }
86
+ ]
87
+ }
88
+ ]);
89
+ }
90
+ } else {
91
+ logger.debug('Trying to get error from reverted tx without blob config');
92
+ errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedForwarderData, args, undefined, []);
93
+ }
94
+ return {
95
+ receipt,
96
+ gasPrice,
97
+ errorMsg
98
+ };
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,79 @@
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 { L1ContractAddresses } from '../l1_contract_addresses.js';
5
+ import type { ViemPublicClient, ViemWalletClient } from '../types.js';
6
+ import { GovernanceProposerContract } from './governance_proposer.js';
7
+ export type L1GovernanceContractAddresses = Pick<L1ContractAddresses, 'governanceAddress' | 'rollupAddress' | 'registryAddress' | 'governanceProposerAddress'>;
8
+ export declare enum ProposalState {
9
+ Pending = 0,
10
+ Active = 1,
11
+ Queued = 2,
12
+ Executable = 3,
13
+ Rejected = 4,
14
+ Executed = 5,
15
+ Dropped = 6,
16
+ Expired = 7
17
+ }
18
+ export declare class GovernanceContract {
19
+ readonly publicClient: ViemPublicClient;
20
+ readonly walletClient: ViemWalletClient | undefined;
21
+ private readonly publicGovernance;
22
+ private readonly walletGovernance;
23
+ constructor(address: Hex, publicClient: ViemPublicClient, walletClient: ViemWalletClient | undefined);
24
+ get address(): EthAddress;
25
+ getProposer(): Promise<GovernanceProposerContract>;
26
+ getGovernanceAddresses(): Promise<L1GovernanceContractAddresses>;
27
+ getProposal(proposalId: bigint): Promise<{
28
+ config: {
29
+ proposeConfig: {
30
+ lockDelay: bigint;
31
+ lockAmount: bigint;
32
+ };
33
+ votingDelay: bigint;
34
+ votingDuration: bigint;
35
+ executionDelay: bigint;
36
+ gracePeriod: bigint;
37
+ quorum: bigint;
38
+ voteDifferential: bigint;
39
+ minimumVotes: bigint;
40
+ };
41
+ state: number;
42
+ payload: `0x${string}`;
43
+ governanceProposer: `0x${string}`;
44
+ creation: bigint;
45
+ summedBallot: {
46
+ yea: bigint;
47
+ nea: bigint;
48
+ };
49
+ }>;
50
+ getProposalState(proposalId: bigint): Promise<ProposalState>;
51
+ private assertWalletGovernance;
52
+ deposit(onBehalfOf: Hex, amount: bigint): Promise<void>;
53
+ proposeWithLock({ payloadAddress, withdrawAddress, }: {
54
+ payloadAddress: Hex;
55
+ withdrawAddress: Hex;
56
+ }): Promise<number>;
57
+ awaitProposalActive({ proposalId, logger }: {
58
+ proposalId: bigint;
59
+ logger: Logger;
60
+ }): Promise<void>;
61
+ awaitProposalExecutable({ proposalId, logger }: {
62
+ proposalId: bigint;
63
+ logger: Logger;
64
+ }): Promise<void>;
65
+ getPower(): Promise<bigint>;
66
+ vote({ proposalId, voteAmount, inFavor, retries, logger, }: {
67
+ proposalId: bigint;
68
+ voteAmount: bigint | undefined;
69
+ inFavor: boolean;
70
+ retries: number;
71
+ logger: Logger;
72
+ }): Promise<void>;
73
+ executeProposal({ proposalId, retries, logger, }: {
74
+ proposalId: bigint;
75
+ retries: number;
76
+ logger: Logger;
77
+ }): Promise<void>;
78
+ }
79
+ //# sourceMappingURL=governance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/contracts/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,mBAAmB,EACnB,mBAAmB,GAAG,eAAe,GAAG,iBAAiB,GAAG,2BAA2B,CACxF,CAAC;AAGF,oBAAY,aAAa;IACvB,OAAO,IAAA;IACP,MAAM,IAAA;IACN,MAAM,IAAA;IACN,UAAU,IAAA;IACV,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,qBAAa,kBAAkB;aAMX,YAAY,EAAE,gBAAgB;aAC9B,YAAY,EAAE,gBAAgB,GAAG,SAAS;IAN5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAgE;IACjG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4E;gBAG3G,OAAO,EAAE,GAAG,EACI,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,GAAG,SAAS;IAQ5D,IAAW,OAAO,eAEjB;IAEY,WAAW;IAKX,sBAAsB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IActE,WAAW,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;IAIxB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQzE,OAAO,CAAC,sBAAsB;IAOjB,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAMvC,eAAe,CAAC,EAC3B,cAAc,EACd,eAAe,GAChB,EAAE;QACD,cAAc,EAAE,GAAG,CAAC;QACpB,eAAe,EAAE,GAAG,CAAC;KACtB,GAAG,OAAO,CAAC,MAAM,CAAC;IAYN,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAsBlF,uBAAuB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IA2BtF,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3B,IAAI,CAAC,EAChB,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;IAkDY,eAAe,CAAC,EAC3B,UAAU,EACV,OAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;CA2CF"}