@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.21caa21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dest/account.d.ts +2 -0
  2. package/dest/account.d.ts.map +1 -0
  3. package/dest/account.js +4 -0
  4. package/dest/chain.d.ts +1 -1
  5. package/dest/client.d.ts +6 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +16 -2
  8. package/dest/config.d.ts +111 -17
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +462 -22
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +24 -8
  13. package/dest/contracts/empire_base.d.ts.map +1 -1
  14. package/dest/contracts/empire_base.js +75 -2
  15. package/dest/contracts/empire_slashing_proposer.d.ts +66 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +200 -0
  18. package/dest/contracts/errors.d.ts +7 -0
  19. package/dest/contracts/errors.d.ts.map +1 -0
  20. package/dest/contracts/errors.js +12 -0
  21. package/dest/contracts/fee_asset_handler.d.ts +19 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +57 -0
  24. package/dest/contracts/fee_juice.d.ts +6 -7
  25. package/dest/contracts/fee_juice.d.ts.map +1 -1
  26. package/dest/contracts/fee_juice.js +27 -20
  27. package/dest/contracts/governance.d.ts +43 -32
  28. package/dest/contracts/governance.d.ts.map +1 -1
  29. package/dest/contracts/governance.js +87 -84
  30. package/dest/contracts/governance_proposer.d.ts +16 -13
  31. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  32. package/dest/contracts/governance_proposer.js +37 -17
  33. package/dest/contracts/gse.d.ts +32 -0
  34. package/dest/contracts/gse.d.ts.map +1 -0
  35. package/dest/contracts/gse.js +72 -0
  36. package/dest/contracts/inbox.d.ts +26 -0
  37. package/dest/contracts/inbox.d.ts.map +1 -0
  38. package/dest/contracts/inbox.js +45 -0
  39. package/dest/contracts/index.d.ts +9 -3
  40. package/dest/contracts/index.d.ts.map +1 -1
  41. package/dest/contracts/index.js +8 -2
  42. package/dest/contracts/multicall.d.ts +21 -0
  43. package/dest/contracts/multicall.d.ts.map +1 -0
  44. package/dest/contracts/multicall.js +156 -0
  45. package/dest/contracts/registry.d.ts +10 -5
  46. package/dest/contracts/registry.d.ts.map +1 -1
  47. package/dest/contracts/registry.js +44 -16
  48. package/dest/contracts/rollup.d.ts +204 -40
  49. package/dest/contracts/rollup.d.ts.map +1 -1
  50. package/dest/contracts/rollup.js +529 -79
  51. package/dest/contracts/slasher_contract.d.ts +44 -0
  52. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  53. package/dest/contracts/slasher_contract.js +75 -0
  54. package/dest/contracts/tally_slashing_proposer.d.ts +139 -0
  55. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  56. package/dest/contracts/tally_slashing_proposer.js +313 -0
  57. package/dest/contracts/utils.d.ts +3 -0
  58. package/dest/contracts/utils.d.ts.map +1 -0
  59. package/dest/contracts/utils.js +11 -0
  60. package/dest/deploy_l1_contracts.d.ts +577 -21114
  61. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  62. package/dest/deploy_l1_contracts.js +1225 -421
  63. package/dest/eth-signer/eth-signer.d.ts +21 -0
  64. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  65. package/dest/eth-signer/eth-signer.js +5 -0
  66. package/dest/eth-signer/index.d.ts +2 -0
  67. package/dest/eth-signer/index.d.ts.map +1 -0
  68. package/dest/eth-signer/index.js +1 -0
  69. package/dest/index.d.ts +7 -3
  70. package/dest/index.d.ts.map +1 -1
  71. package/dest/index.js +6 -2
  72. package/dest/l1_artifacts.d.ts +77344 -0
  73. package/dest/l1_artifacts.d.ts.map +1 -0
  74. package/dest/l1_artifacts.js +166 -0
  75. package/dest/l1_contract_addresses.d.ts +24 -4
  76. package/dest/l1_contract_addresses.d.ts.map +1 -1
  77. package/dest/l1_contract_addresses.js +22 -18
  78. package/dest/l1_reader.d.ts +2 -2
  79. package/dest/l1_reader.d.ts.map +1 -1
  80. package/dest/l1_reader.js +8 -8
  81. package/dest/l1_tx_utils/config.d.ts +59 -0
  82. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  83. package/dest/l1_tx_utils/config.js +82 -0
  84. package/dest/l1_tx_utils/constants.d.ts +6 -0
  85. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  86. package/dest/l1_tx_utils/constants.js +14 -0
  87. package/dest/l1_tx_utils/factory.d.ts +24 -0
  88. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  89. package/dest/l1_tx_utils/factory.js +12 -0
  90. package/dest/l1_tx_utils/index.d.ts +10 -0
  91. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  92. package/dest/l1_tx_utils/index.js +10 -0
  93. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  94. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/interfaces.js +4 -0
  96. package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
  97. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/l1_tx_utils.js +610 -0
  99. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  100. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  102. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +94 -0
  103. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +430 -0
  105. package/dest/l1_tx_utils/signer.d.ts +4 -0
  106. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/signer.js +16 -0
  108. package/dest/l1_tx_utils/types.d.ts +67 -0
  109. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/types.js +26 -0
  111. package/dest/l1_tx_utils/utils.d.ts +4 -0
  112. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/utils.js +14 -0
  114. package/dest/l1_types.d.ts +6 -0
  115. package/dest/l1_types.d.ts.map +1 -0
  116. package/dest/l1_types.js +1 -0
  117. package/dest/publisher_manager.d.ts +15 -0
  118. package/dest/publisher_manager.d.ts.map +1 -0
  119. package/dest/publisher_manager.js +88 -0
  120. package/dest/queries.d.ts +4 -2
  121. package/dest/queries.d.ts.map +1 -1
  122. package/dest/queries.js +53 -12
  123. package/dest/test/chain_monitor.d.ts +73 -0
  124. package/dest/test/chain_monitor.d.ts.map +1 -0
  125. package/dest/test/chain_monitor.js +215 -0
  126. package/dest/test/delayed_tx_utils.d.ts +8 -3
  127. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  128. package/dest/test/delayed_tx_utils.js +13 -6
  129. package/dest/test/eth_cheat_codes.d.ts +217 -0
  130. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  131. package/dest/test/eth_cheat_codes.js +558 -0
  132. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  133. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  134. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  135. package/dest/test/index.d.ts +4 -1
  136. package/dest/test/index.d.ts.map +1 -1
  137. package/dest/test/index.js +3 -0
  138. package/dest/test/rollup_cheat_codes.d.ts +87 -0
  139. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  140. package/dest/test/rollup_cheat_codes.js +266 -0
  141. package/dest/test/start_anvil.d.ts +7 -1
  142. package/dest/test/start_anvil.d.ts.map +1 -1
  143. package/dest/test/start_anvil.js +16 -7
  144. package/dest/test/tx_delayer.d.ts +18 -7
  145. package/dest/test/tx_delayer.d.ts.map +1 -1
  146. package/dest/test/tx_delayer.js +95 -19
  147. package/dest/test/upgrade_utils.d.ts +6 -5
  148. package/dest/test/upgrade_utils.d.ts.map +1 -1
  149. package/dest/test/upgrade_utils.js +23 -16
  150. package/dest/types.d.ts +7 -8
  151. package/dest/types.d.ts.map +1 -1
  152. package/dest/types.js +3 -1
  153. package/dest/utils.d.ts +2 -1
  154. package/dest/utils.d.ts.map +1 -1
  155. package/dest/utils.js +43 -88
  156. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  157. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  158. package/dest/zkPassportVerifierAddress.js +11 -0
  159. package/package.json +28 -19
  160. package/src/account.ts +5 -0
  161. package/src/client.ts +42 -4
  162. package/src/config.ts +592 -31
  163. package/src/contracts/empire_base.ts +77 -7
  164. package/src/contracts/empire_slashing_proposer.ts +265 -0
  165. package/src/contracts/errors.ts +13 -0
  166. package/src/contracts/fee_asset_handler.ts +63 -0
  167. package/src/contracts/fee_juice.ts +29 -15
  168. package/src/contracts/governance.ts +80 -77
  169. package/src/contracts/governance_proposer.ts +66 -24
  170. package/src/contracts/gse.ts +88 -0
  171. package/src/contracts/inbox.ts +63 -0
  172. package/src/contracts/index.ts +8 -2
  173. package/src/contracts/multicall.ts +155 -0
  174. package/src/contracts/registry.ts +51 -26
  175. package/src/contracts/rollup.ts +596 -74
  176. package/src/contracts/slasher_contract.ts +89 -0
  177. package/src/contracts/tally_slashing_proposer.ts +316 -0
  178. package/src/contracts/utils.ts +14 -0
  179. package/src/deploy_l1_contracts.ts +1459 -538
  180. package/src/eth-signer/eth-signer.ts +25 -0
  181. package/src/eth-signer/index.ts +1 -0
  182. package/src/index.ts +6 -2
  183. package/src/l1_artifacts.ts +254 -0
  184. package/src/l1_contract_addresses.ts +32 -19
  185. package/src/l1_reader.ts +9 -9
  186. package/src/l1_tx_utils/README.md +177 -0
  187. package/src/l1_tx_utils/config.ts +143 -0
  188. package/src/l1_tx_utils/constants.ts +18 -0
  189. package/src/l1_tx_utils/factory.ts +64 -0
  190. package/src/l1_tx_utils/index.ts +12 -0
  191. package/src/l1_tx_utils/interfaces.ts +86 -0
  192. package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
  193. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  194. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +558 -0
  195. package/src/l1_tx_utils/signer.ts +28 -0
  196. package/src/l1_tx_utils/types.ts +85 -0
  197. package/src/l1_tx_utils/utils.ts +16 -0
  198. package/src/l1_types.ts +6 -0
  199. package/src/publisher_manager.ts +106 -0
  200. package/src/queries.ts +73 -15
  201. package/src/test/chain_monitor.ts +243 -0
  202. package/src/test/delayed_tx_utils.ts +34 -6
  203. package/src/test/eth_cheat_codes.ts +588 -0
  204. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  205. package/src/test/index.ts +3 -0
  206. package/src/test/rollup_cheat_codes.ts +307 -0
  207. package/src/test/start_anvil.ts +22 -5
  208. package/src/test/tx_delayer.ts +127 -26
  209. package/src/test/upgrade_utils.ts +30 -21
  210. package/src/types.ts +10 -8
  211. package/src/utils.ts +49 -90
  212. package/src/zkPassportVerifierAddress.ts +15 -0
  213. package/dest/contracts/forwarder.d.ts +0 -24
  214. package/dest/contracts/forwarder.d.ts.map +0 -1
  215. package/dest/contracts/forwarder.js +0 -101
  216. package/dest/contracts/slashing_proposer.d.ts +0 -21
  217. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  218. package/dest/contracts/slashing_proposer.js +0 -47
  219. package/dest/eth_cheat_codes.d.ts +0 -147
  220. package/dest/eth_cheat_codes.d.ts.map +0 -1
  221. package/dest/eth_cheat_codes.js +0 -303
  222. package/dest/l1_tx_utils.d.ts +0 -192
  223. package/dest/l1_tx_utils.d.ts.map +0 -1
  224. package/dest/l1_tx_utils.js +0 -641
  225. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  226. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  227. package/dest/l1_tx_utils_with_blobs.js +0 -64
  228. package/src/contracts/forwarder.ts +0 -132
  229. package/src/contracts/slashing_proposer.ts +0 -51
  230. package/src/eth_cheat_codes.ts +0 -314
  231. package/src/l1_tx_utils.ts +0 -847
  232. package/src/l1_tx_utils_with_blobs.ts +0 -86
@@ -1,36 +1,37 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
- import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts';
2
+ import { DateProvider } from '@aztec/foundation/timer';
3
3
  import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
4
+ import { TestERC20Abi as StakingAssetAbi } from '@aztec/l1-artifacts/TestERC20Abi';
4
5
 
5
6
  import { type GetContractReturnType, type PrivateKeyAccount, getContract } from 'viem';
6
7
 
7
- import { EthCheatCodes } from '../eth_cheat_codes.js';
8
+ import { extractProposalIdFromLogs } from '../contracts/governance.js';
8
9
  import type { L1ContractAddresses } from '../l1_contract_addresses.js';
9
- import type { L1Clients } from '../types.js';
10
+ import { createL1TxUtilsFromViemWallet } from '../l1_tx_utils/index.js';
11
+ import type { ExtendedViemWalletClient, ViemPublicClient } from '../types.js';
12
+ import { EthCheatCodes } from './eth_cheat_codes.js';
10
13
 
11
14
  export async function executeGovernanceProposal(
12
15
  proposalId: bigint,
13
- governance: GetContractReturnType<typeof GovernanceAbi, L1Clients['publicClient']>,
16
+ governance: GetContractReturnType<typeof GovernanceAbi, ViemPublicClient>,
14
17
  voteAmount: bigint,
15
18
  privateKey: PrivateKeyAccount,
16
- publicClient: L1Clients['publicClient'],
17
- walletClient: L1Clients['walletClient'],
19
+ l1Client: ExtendedViemWalletClient,
18
20
  rpcUrls: string[],
19
21
  logger: Logger,
20
22
  ) {
21
23
  const proposal = await governance.read.getProposal([proposalId]);
22
24
 
25
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
26
+
23
27
  const waitL1Block = async () => {
24
- await publicClient.waitForTransactionReceipt({
25
- hash: await walletClient.sendTransaction({
26
- to: privateKey.address,
27
- value: 1n,
28
- account: privateKey,
29
- }),
28
+ await l1TxUtils.sendAndMonitorTransaction({
29
+ to: l1Client.account.address,
30
+ value: 1n,
30
31
  });
31
32
  };
32
33
 
33
- const cheatCodes = new EthCheatCodes(rpcUrls, logger);
34
+ const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), logger);
34
35
 
35
36
  const timeToActive = proposal.creation + proposal.config.votingDelay;
36
37
  logger.info(`Warping to ${timeToActive + 1n}`);
@@ -40,7 +41,7 @@ export async function executeGovernanceProposal(
40
41
 
41
42
  logger.info(`Voting`);
42
43
  const voteTx = await governance.write.vote([proposalId, voteAmount, true], { account: privateKey });
43
- await publicClient.waitForTransactionReceipt({ hash: voteTx });
44
+ await l1Client.waitForTransactionReceipt({ hash: voteTx });
44
45
  logger.info(`Voted`);
45
46
 
46
47
  const timeToExecutable = timeToActive + proposal.config.votingDuration + proposal.config.executionDelay + 1n;
@@ -50,7 +51,7 @@ export async function executeGovernanceProposal(
50
51
  await waitL1Block();
51
52
 
52
53
  const executeTx = await governance.write.execute([proposalId], { account: privateKey });
53
- await publicClient.waitForTransactionReceipt({ hash: executeTx });
54
+ await l1Client.waitForTransactionReceipt({ hash: executeTx });
54
55
  logger.info(`Executed proposal`);
55
56
  }
56
57
 
@@ -58,12 +59,16 @@ export async function createGovernanceProposal(
58
59
  payloadAddress: `0x${string}`,
59
60
  addresses: L1ContractAddresses,
60
61
  privateKey: PrivateKeyAccount,
61
- publicClient: L1Clients['publicClient'],
62
+ publicClient: ViemPublicClient,
62
63
  logger: Logger,
63
- ): Promise<{ governance: GetContractReturnType<typeof GovernanceAbi, L1Clients['publicClient']>; voteAmount: bigint }> {
64
+ ): Promise<{
65
+ governance: GetContractReturnType<typeof GovernanceAbi, ViemPublicClient>;
66
+ voteAmount: bigint;
67
+ proposalId: bigint;
68
+ }> {
64
69
  const token = getContract({
65
- address: addresses.feeJuiceAddress.toString(),
66
- abi: FeeJuiceAbi,
70
+ address: addresses.stakingAssetAddress.toString(),
71
+ abi: StakingAssetAbi,
67
72
  client: publicClient,
68
73
  });
69
74
 
@@ -92,9 +97,13 @@ export async function createGovernanceProposal(
92
97
  await publicClient.waitForTransactionReceipt({ hash: depositTx });
93
98
  logger.info(`Deposited tokens`);
94
99
 
95
- await governance.write.proposeWithLock([payloadAddress, privateKey.address], {
100
+ const proposeTx = await governance.write.proposeWithLock([payloadAddress, privateKey.address], {
96
101
  account: privateKey,
97
102
  });
103
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: proposeTx });
104
+ logger.info(`Proposed upgrade`);
105
+
106
+ const proposalId = extractProposalIdFromLogs(receipt.logs);
98
107
 
99
- return { governance, voteAmount };
108
+ return { governance, voteAmount, proposalId };
100
109
  }
package/src/types.ts CHANGED
@@ -1,22 +1,21 @@
1
1
  import type {
2
+ Abi,
2
3
  Account,
3
4
  Chain,
4
5
  Client,
5
6
  FallbackTransport,
7
+ GetContractReturnType,
6
8
  HttpTransport,
7
9
  PublicActions,
8
10
  PublicClient,
9
11
  PublicRpcSchema,
10
12
  WalletActions,
11
- WalletClient,
12
13
  WalletRpcSchema,
13
14
  } from 'viem';
14
15
 
15
16
  /** Type for a viem public client */
16
17
  export type ViemPublicClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain>;
17
18
 
18
- export type SimpleViemWalletClient = WalletClient<FallbackTransport<HttpTransport[]>, Chain, Account>;
19
-
20
19
  export type ExtendedViemWalletClient = Client<
21
20
  FallbackTransport<readonly HttpTransport[]>,
22
21
  Chain,
@@ -25,9 +24,12 @@ export type ExtendedViemWalletClient = Client<
25
24
  PublicActions<FallbackTransport<readonly HttpTransport[]>, Chain> & WalletActions<Chain, Account>
26
25
  >;
27
26
 
28
- export type ViemWalletClient = SimpleViemWalletClient | ExtendedViemWalletClient;
27
+ /** Type for a viem client that can be either public or extended with wallet capabilities */
28
+ export type ViemClient = ViemPublicClient | ExtendedViemWalletClient;
29
+
30
+ /** Type for a viem contract that can be used with an extended viem client */
31
+ export type ViemContract<TAbi extends Abi> = GetContractReturnType<TAbi, ExtendedViemWalletClient>;
29
32
 
30
- export type L1Clients = {
31
- publicClient: ViemPublicClient;
32
- walletClient: ExtendedViemWalletClient;
33
- };
33
+ export function isExtendedClient(client: ViemClient): client is ExtendedViemWalletClient {
34
+ return 'account' in client && client.account !== undefined;
35
+ }
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
- import { ErrorsAbi } from '@aztec/l1-artifacts';
3
+ import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
4
4
 
5
5
  import {
6
6
  type Abi,
@@ -50,7 +50,7 @@ export function extractEvent<
50
50
  return event;
51
51
  }
52
52
 
53
- function tryExtractEvent<
53
+ export function tryExtractEvent<
54
54
  const TAbi extends Abi | readonly unknown[],
55
55
  TEventName extends ContractEventName<TAbi>,
56
56
  TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>,
@@ -158,106 +158,65 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem
158
158
  return new FormattedViemError(`${errorName}${args}`, error?.metaMessages);
159
159
  }
160
160
  }
161
- } catch (decodeErr) {
161
+ } catch {
162
162
  // If decoding fails, we fall back to the original formatting
163
163
  }
164
164
 
165
- // If it's a regular Error instance, return it with its message
166
- if (error instanceof Error) {
167
- return error;
168
- }
169
-
170
- // Original formatting logic for non-custom errors
171
- const truncateHex = (hex: string, length = 100) => {
172
- if (!hex || typeof hex !== 'string') {
173
- return hex;
174
- }
175
- if (!hex.startsWith('0x')) {
176
- return hex;
177
- }
178
- if (hex.length <= length * 2) {
179
- return hex;
180
- }
181
- return `${hex.slice(0, length)}...${hex.slice(-length)}`;
182
- };
165
+ // Strip ABI from the error object before formatting
166
+ if (error && typeof error === 'object') {
167
+ // Create a clone to avoid modifying the original
168
+ const errorClone = structuredClone(error);
183
169
 
184
- const formatRequestBody = (body: string) => {
185
- try {
186
- const parsed = JSON.parse(body);
170
+ // Helper function to recursively remove ABI properties
187
171
 
188
- // Recursively process all parameters that might contain hex strings
189
- const processParams = (obj: any): any => {
190
- if (Array.isArray(obj)) {
191
- return obj.map(item => processParams(item));
192
- }
193
- if (typeof obj === 'object' && obj !== null) {
194
- const result: any = {};
195
- for (const [key, value] of Object.entries(obj)) {
196
- result[key] = processParams(value);
197
- }
198
- return result;
199
- }
200
- if (typeof obj === 'string') {
201
- if (obj.startsWith('0x')) {
202
- return truncateHex(obj);
203
- }
204
- }
205
- return obj;
206
- };
172
+ // Strip ABIs from the clone
173
+ stripAbis(errorClone);
207
174
 
208
- // Process the entire request body
209
- const processed = processParams(parsed);
210
- return JSON.stringify(processed, null, 2);
211
- } catch {
212
- return body;
213
- }
214
- };
175
+ // Use the cleaned clone for further processing
176
+ error = errorClone;
177
+ }
215
178
 
216
- const truncateHexStringsInText = (text: string): string => {
217
- const hexRegex = /\b0x[a-fA-F0-9]{10,}/g;
218
- return text.replace(hexRegex, hex => truncateHex(hex));
219
- };
179
+ // If it's a regular Error instance, return it with its message
180
+ if (error instanceof Error) {
181
+ return new FormattedViemError(error.message, (error as any)?.metaMessages);
182
+ }
220
183
 
221
- const extractAndFormatRequestBody = (message: string): string => {
222
- // First handle Request body JSON
223
- const requestBodyRegex = /Request body: ({[\s\S]*?})\n/g;
224
- let result = message.replace(requestBodyRegex, (match, body) => {
225
- return `Request body: ${formatRequestBody(body)}\n`;
226
- });
184
+ const body = String(error);
185
+ const length = body.length;
186
+ // LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
187
+ // Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
188
+ if (length > 2000) {
189
+ const chunk = 950;
190
+ const truncated = length - 2 * chunk;
191
+ return new FormattedViemError(
192
+ body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk),
193
+ );
194
+ }
227
195
 
228
- // Then handle Arguments section
229
- const argsRegex = /((?:Request |Estimate Gas )?Arguments:[\s\S]*?(?=\n\n|$))/g;
230
- result = result.replace(argsRegex, section => {
231
- const lines = section.split('\n');
232
- const processedLines = lines.map(line => {
233
- // Check if line contains a colon followed by content
234
- const colonIndex = line.indexOf(':');
235
- if (colonIndex !== -1) {
236
- const [prefix, content] = [line.slice(0, colonIndex + 1), line.slice(colonIndex + 1).trim()];
237
- // If content contains a hex string, truncate it
238
- if (content.includes('0x')) {
239
- const hexMatches = content.match(/0x[a-fA-F0-9]+/g) || [];
240
- let processedContent = content;
241
- hexMatches.forEach(hex => {
242
- processedContent = processedContent.replace(hex, truncateHex(hex));
243
- });
244
- return `${prefix} ${processedContent}`;
245
- }
246
- }
247
- return line;
248
- });
249
- return processedLines.join('\n');
250
- });
196
+ return new FormattedViemError(body);
197
+ }
251
198
 
252
- // Finally, catch any remaining hex strings in the message
253
- result = truncateHexStringsInText(result);
199
+ function stripAbis(obj: any) {
200
+ if (!obj || typeof obj !== 'object') {
201
+ return;
202
+ }
254
203
 
255
- return result;
256
- };
204
+ // Delete ABI property at current level
205
+ if ('abi' in obj) {
206
+ delete obj.abi;
207
+ }
257
208
 
258
- const formattedRes = extractAndFormatRequestBody(error?.message || String(error));
209
+ // Process cause property
210
+ if (obj.cause) {
211
+ stripAbis(obj.cause);
212
+ }
259
213
 
260
- return new FormattedViemError(formattedRes.replace(/\\n/g, '\n'), error?.metaMessages);
214
+ // Process arrays and objects
215
+ Object.values(obj).forEach(value => {
216
+ if (value && typeof value === 'object') {
217
+ stripAbis(value);
218
+ }
219
+ });
261
220
  }
262
221
 
263
222
  export function tryGetCustomErrorName(err: any) {
@@ -270,7 +229,7 @@ export function tryGetCustomErrorName(err: any) {
270
229
  return (revertError as ContractFunctionRevertedError).data?.errorName;
271
230
  }
272
231
  }
273
- } catch (_e) {
232
+ } catch {
274
233
  return undefined;
275
234
  }
276
235
  }
@@ -0,0 +1,15 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+
3
+ /**
4
+ * The address of the zk passport verifier on sepolia
5
+ * get address from: ROOT/l1-contracts/lib/circuits/src/solidity/deployments/deployment-11155111.json
6
+ */
7
+ export const ZK_PASSPORT_VERIFIER_ADDRESS = EthAddress.fromString('0x3101Bad9eA5fACadA5554844a1a88F7Fe48D4DE0');
8
+ /**
9
+ * The default domain of the zk passport site
10
+ */
11
+ export const ZK_PASSPORT_DOMAIN = 'testnet.aztec.network';
12
+ /**
13
+ * The default scope of the zk passport proofs
14
+ */
15
+ export const ZK_PASSPORT_SCOPE = 'personhood';
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,101 +0,0 @@
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
- }
@@ -1,21 +0,0 @@
1
- import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { type Hex } from 'viem';
3
- import type { L1TxRequest } from '../l1_tx_utils.js';
4
- import type { ViemPublicClient } from '../types.js';
5
- import { type IEmpireBase } from './empire_base.js';
6
- export declare class SlashingProposerContract implements IEmpireBase {
7
- readonly client: ViemPublicClient;
8
- private readonly proposer;
9
- constructor(client: ViemPublicClient, address: Hex);
10
- get address(): EthAddress;
11
- getQuorumSize(): Promise<bigint>;
12
- getRoundSize(): Promise<bigint>;
13
- computeRound(slot: bigint): Promise<bigint>;
14
- getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
15
- lastVote: bigint;
16
- leader: Hex;
17
- executed: boolean;
18
- }>;
19
- createVoteRequest(payload: Hex): L1TxRequest;
20
- }
21
- //# sourceMappingURL=slashing_proposer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/slashing_proposer.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,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,kBAAkB,CAAC;AAEhE,qBAAa,wBAAyB,YAAW,WAAW;aAG9B,MAAM,EAAE,gBAAgB;IAFpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsE;gBAEnE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG;IAIlE,IAAW,OAAO,eAEjB;IAEM,aAAa;IAIb,YAAY;IAIZ,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrC,YAAY,CACvB,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IASzD,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;CAMpD"}
@@ -1,47 +0,0 @@
1
- import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { SlashingProposerAbi } from '@aztec/l1-artifacts';
3
- import { getContract } from 'viem';
4
- import { encodeVote } from './empire_base.js';
5
- export class SlashingProposerContract {
6
- client;
7
- proposer;
8
- constructor(client, address){
9
- this.client = client;
10
- this.proposer = getContract({
11
- address,
12
- abi: SlashingProposerAbi,
13
- client
14
- });
15
- }
16
- get address() {
17
- return EthAddress.fromString(this.proposer.address);
18
- }
19
- getQuorumSize() {
20
- return this.proposer.read.N();
21
- }
22
- getRoundSize() {
23
- return this.proposer.read.M();
24
- }
25
- computeRound(slot) {
26
- return this.proposer.read.computeRound([
27
- slot
28
- ]);
29
- }
30
- async getRoundInfo(rollupAddress, round) {
31
- const roundInfo = await this.proposer.read.rounds([
32
- rollupAddress,
33
- round
34
- ]);
35
- return {
36
- lastVote: roundInfo[0],
37
- leader: roundInfo[1],
38
- executed: roundInfo[2]
39
- };
40
- }
41
- createVoteRequest(payload) {
42
- return {
43
- to: this.address.toString(),
44
- data: encodeVote(payload)
45
- };
46
- }
47
- }