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

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 (229) 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/client.d.ts +5 -3
  5. package/dest/client.d.ts.map +1 -1
  6. package/dest/client.js +16 -2
  7. package/dest/config.d.ts +107 -16
  8. package/dest/config.d.ts.map +1 -1
  9. package/dest/config.js +456 -22
  10. package/dest/contracts/empire_base.d.ts +21 -6
  11. package/dest/contracts/empire_base.d.ts.map +1 -1
  12. package/dest/contracts/empire_base.js +75 -2
  13. package/dest/contracts/empire_slashing_proposer.d.ts +65 -0
  14. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  15. package/dest/contracts/empire_slashing_proposer.js +194 -0
  16. package/dest/contracts/errors.d.ts +7 -0
  17. package/dest/contracts/errors.d.ts.map +1 -0
  18. package/dest/contracts/errors.js +12 -0
  19. package/dest/contracts/fee_asset_handler.d.ts +19 -0
  20. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  21. package/dest/contracts/fee_asset_handler.js +57 -0
  22. package/dest/contracts/fee_juice.d.ts +5 -6
  23. package/dest/contracts/fee_juice.d.ts.map +1 -1
  24. package/dest/contracts/fee_juice.js +27 -20
  25. package/dest/contracts/governance.d.ts +36 -25
  26. package/dest/contracts/governance.d.ts.map +1 -1
  27. package/dest/contracts/governance.js +87 -84
  28. package/dest/contracts/governance_proposer.d.ts +13 -11
  29. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  30. package/dest/contracts/governance_proposer.js +32 -18
  31. package/dest/contracts/gse.d.ts +32 -0
  32. package/dest/contracts/gse.d.ts.map +1 -0
  33. package/dest/contracts/gse.js +72 -0
  34. package/dest/contracts/inbox.d.ts +26 -0
  35. package/dest/contracts/inbox.d.ts.map +1 -0
  36. package/dest/contracts/inbox.js +45 -0
  37. package/dest/contracts/index.d.ts +8 -2
  38. package/dest/contracts/index.d.ts.map +1 -1
  39. package/dest/contracts/index.js +8 -2
  40. package/dest/contracts/multicall.d.ts +21 -0
  41. package/dest/contracts/multicall.d.ts.map +1 -0
  42. package/dest/contracts/multicall.js +156 -0
  43. package/dest/contracts/registry.d.ts +9 -4
  44. package/dest/contracts/registry.d.ts.map +1 -1
  45. package/dest/contracts/registry.js +44 -16
  46. package/dest/contracts/rollup.d.ts +202 -29
  47. package/dest/contracts/rollup.d.ts.map +1 -1
  48. package/dest/contracts/rollup.js +500 -55
  49. package/dest/contracts/slasher_contract.d.ts +44 -0
  50. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  51. package/dest/contracts/slasher_contract.js +75 -0
  52. package/dest/contracts/tally_slashing_proposer.d.ts +138 -0
  53. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  54. package/dest/contracts/tally_slashing_proposer.js +313 -0
  55. package/dest/contracts/utils.d.ts +3 -0
  56. package/dest/contracts/utils.d.ts.map +1 -0
  57. package/dest/contracts/utils.js +11 -0
  58. package/dest/deploy_l1_contracts.d.ts +128 -21112
  59. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  60. package/dest/deploy_l1_contracts.js +1204 -418
  61. package/dest/eth-signer/eth-signer.d.ts +21 -0
  62. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  63. package/dest/eth-signer/eth-signer.js +5 -0
  64. package/dest/eth-signer/index.d.ts +2 -0
  65. package/dest/eth-signer/index.d.ts.map +1 -0
  66. package/dest/eth-signer/index.js +1 -0
  67. package/dest/index.d.ts +6 -2
  68. package/dest/index.d.ts.map +1 -1
  69. package/dest/index.js +6 -2
  70. package/dest/l1_artifacts.d.ts +76184 -0
  71. package/dest/l1_artifacts.d.ts.map +1 -0
  72. package/dest/l1_artifacts.js +166 -0
  73. package/dest/l1_contract_addresses.d.ts +21 -1
  74. package/dest/l1_contract_addresses.d.ts.map +1 -1
  75. package/dest/l1_contract_addresses.js +22 -18
  76. package/dest/l1_reader.d.ts +1 -1
  77. package/dest/l1_reader.d.ts.map +1 -1
  78. package/dest/l1_reader.js +8 -8
  79. package/dest/l1_tx_utils/config.d.ts +59 -0
  80. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  81. package/dest/l1_tx_utils/config.js +73 -0
  82. package/dest/l1_tx_utils/constants.d.ts +6 -0
  83. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  84. package/dest/l1_tx_utils/constants.js +14 -0
  85. package/dest/l1_tx_utils/factory.d.ts +24 -0
  86. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  87. package/dest/l1_tx_utils/factory.js +12 -0
  88. package/dest/l1_tx_utils/index.d.ts +10 -0
  89. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  90. package/dest/l1_tx_utils/index.js +10 -0
  91. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  92. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  93. package/dest/l1_tx_utils/interfaces.js +4 -0
  94. package/dest/l1_tx_utils/l1_tx_utils.d.ts +95 -0
  95. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  96. package/dest/l1_tx_utils/l1_tx_utils.js +610 -0
  97. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  98. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  99. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  100. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +94 -0
  101. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  102. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +431 -0
  103. package/dest/l1_tx_utils/signer.d.ts +4 -0
  104. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  105. package/dest/l1_tx_utils/signer.js +16 -0
  106. package/dest/l1_tx_utils/types.d.ts +67 -0
  107. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  108. package/dest/l1_tx_utils/types.js +26 -0
  109. package/dest/l1_tx_utils/utils.d.ts +4 -0
  110. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  111. package/dest/l1_tx_utils/utils.js +14 -0
  112. package/dest/l1_types.d.ts +6 -0
  113. package/dest/l1_types.d.ts.map +1 -0
  114. package/dest/l1_types.js +1 -0
  115. package/dest/publisher_manager.d.ts +15 -0
  116. package/dest/publisher_manager.d.ts.map +1 -0
  117. package/dest/publisher_manager.js +88 -0
  118. package/dest/queries.d.ts +3 -1
  119. package/dest/queries.d.ts.map +1 -1
  120. package/dest/queries.js +51 -12
  121. package/dest/test/chain_monitor.d.ts +72 -0
  122. package/dest/test/chain_monitor.d.ts.map +1 -0
  123. package/dest/test/chain_monitor.js +216 -0
  124. package/dest/test/delayed_tx_utils.d.ts +7 -2
  125. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  126. package/dest/test/delayed_tx_utils.js +13 -6
  127. package/dest/{eth_cheat_codes.d.ts → test/eth_cheat_codes.d.ts} +87 -13
  128. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  129. package/dest/test/eth_cheat_codes.js +552 -0
  130. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  131. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  132. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  133. package/dest/test/index.d.ts +3 -0
  134. package/dest/test/index.d.ts.map +1 -1
  135. package/dest/test/index.js +3 -0
  136. package/dest/test/rollup_cheat_codes.d.ts +86 -0
  137. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  138. package/dest/test/rollup_cheat_codes.js +268 -0
  139. package/dest/test/start_anvil.d.ts +5 -0
  140. package/dest/test/start_anvil.d.ts.map +1 -1
  141. package/dest/test/start_anvil.js +15 -7
  142. package/dest/test/tx_delayer.d.ts +17 -6
  143. package/dest/test/tx_delayer.d.ts.map +1 -1
  144. package/dest/test/tx_delayer.js +95 -19
  145. package/dest/test/upgrade_utils.d.ts +5 -4
  146. package/dest/test/upgrade_utils.d.ts.map +1 -1
  147. package/dest/test/upgrade_utils.js +23 -16
  148. package/dest/types.d.ts +6 -7
  149. package/dest/types.d.ts.map +1 -1
  150. package/dest/types.js +3 -1
  151. package/dest/utils.d.ts +1 -0
  152. package/dest/utils.d.ts.map +1 -1
  153. package/dest/utils.js +43 -88
  154. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  155. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  156. package/dest/zkPassportVerifierAddress.js +11 -0
  157. package/package.json +24 -16
  158. package/src/account.ts +5 -0
  159. package/src/client.ts +42 -4
  160. package/src/config.ts +584 -31
  161. package/src/contracts/empire_base.ts +75 -6
  162. package/src/contracts/empire_slashing_proposer.ts +259 -0
  163. package/src/contracts/errors.ts +13 -0
  164. package/src/contracts/fee_asset_handler.ts +63 -0
  165. package/src/contracts/fee_juice.ts +29 -15
  166. package/src/contracts/governance.ts +80 -77
  167. package/src/contracts/governance_proposer.ts +60 -24
  168. package/src/contracts/gse.ts +88 -0
  169. package/src/contracts/inbox.ts +63 -0
  170. package/src/contracts/index.ts +8 -2
  171. package/src/contracts/multicall.ts +155 -0
  172. package/src/contracts/registry.ts +51 -26
  173. package/src/contracts/rollup.ts +585 -56
  174. package/src/contracts/slasher_contract.ts +89 -0
  175. package/src/contracts/tally_slashing_proposer.ts +315 -0
  176. package/src/contracts/utils.ts +14 -0
  177. package/src/deploy_l1_contracts.ts +1467 -566
  178. package/src/eth-signer/eth-signer.ts +25 -0
  179. package/src/eth-signer/index.ts +1 -0
  180. package/src/index.ts +6 -2
  181. package/src/l1_artifacts.ts +254 -0
  182. package/src/l1_contract_addresses.ts +32 -19
  183. package/src/l1_reader.ts +9 -9
  184. package/src/l1_tx_utils/README.md +177 -0
  185. package/src/l1_tx_utils/config.ts +140 -0
  186. package/src/l1_tx_utils/constants.ts +18 -0
  187. package/src/l1_tx_utils/factory.ts +64 -0
  188. package/src/l1_tx_utils/index.ts +12 -0
  189. package/src/l1_tx_utils/interfaces.ts +86 -0
  190. package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
  191. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  192. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +559 -0
  193. package/src/l1_tx_utils/signer.ts +28 -0
  194. package/src/l1_tx_utils/types.ts +85 -0
  195. package/src/l1_tx_utils/utils.ts +16 -0
  196. package/src/l1_types.ts +6 -0
  197. package/src/publisher_manager.ts +106 -0
  198. package/src/queries.ts +70 -15
  199. package/src/test/chain_monitor.ts +243 -0
  200. package/src/test/delayed_tx_utils.ts +34 -6
  201. package/src/test/eth_cheat_codes.ts +582 -0
  202. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  203. package/src/test/index.ts +3 -0
  204. package/src/test/rollup_cheat_codes.ts +310 -0
  205. package/src/test/start_anvil.ts +20 -5
  206. package/src/test/tx_delayer.ts +127 -26
  207. package/src/test/upgrade_utils.ts +30 -21
  208. package/src/types.ts +10 -8
  209. package/src/utils.ts +49 -90
  210. package/src/zkPassportVerifierAddress.ts +15 -0
  211. package/dest/contracts/forwarder.d.ts +0 -24
  212. package/dest/contracts/forwarder.d.ts.map +0 -1
  213. package/dest/contracts/forwarder.js +0 -101
  214. package/dest/contracts/slashing_proposer.d.ts +0 -21
  215. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  216. package/dest/contracts/slashing_proposer.js +0 -47
  217. package/dest/eth_cheat_codes.d.ts.map +0 -1
  218. package/dest/eth_cheat_codes.js +0 -303
  219. package/dest/l1_tx_utils.d.ts +0 -192
  220. package/dest/l1_tx_utils.d.ts.map +0 -1
  221. package/dest/l1_tx_utils.js +0 -641
  222. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  223. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  224. package/dest/l1_tx_utils_with_blobs.js +0 -64
  225. package/src/contracts/forwarder.ts +0 -132
  226. package/src/contracts/slashing_proposer.ts +0 -51
  227. package/src/eth_cheat_codes.ts +0 -314
  228. package/src/l1_tx_utils.ts +0 -847
  229. package/src/l1_tx_utils_with_blobs.ts +0 -86
@@ -1,21 +1,22 @@
1
- import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts';
1
+ import { DateProvider } from '@aztec/foundation/timer';
2
2
  import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
3
+ import { TestERC20Abi as StakingAssetAbi } from '@aztec/l1-artifacts/TestERC20Abi';
3
4
  import { getContract } from 'viem';
4
- import { EthCheatCodes } from '../eth_cheat_codes.js';
5
- export async function executeGovernanceProposal(proposalId, governance, voteAmount, privateKey, publicClient, walletClient, rpcUrls, logger) {
5
+ import { extractProposalIdFromLogs } from '../contracts/governance.js';
6
+ import { createL1TxUtilsFromViemWallet } from '../l1_tx_utils/index.js';
7
+ import { EthCheatCodes } from './eth_cheat_codes.js';
8
+ export async function executeGovernanceProposal(proposalId, governance, voteAmount, privateKey, l1Client, rpcUrls, logger) {
6
9
  const proposal = await governance.read.getProposal([
7
10
  proposalId
8
11
  ]);
12
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
9
13
  const waitL1Block = async ()=>{
10
- await publicClient.waitForTransactionReceipt({
11
- hash: await walletClient.sendTransaction({
12
- to: privateKey.address,
13
- value: 1n,
14
- account: privateKey
15
- })
14
+ await l1TxUtils.sendAndMonitorTransaction({
15
+ to: l1Client.account.address,
16
+ value: 1n
16
17
  });
17
18
  };
18
- const cheatCodes = new EthCheatCodes(rpcUrls, logger);
19
+ const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), logger);
19
20
  const timeToActive = proposal.creation + proposal.config.votingDelay;
20
21
  logger.info(`Warping to ${timeToActive + 1n}`);
21
22
  await cheatCodes.warp(Number(timeToActive + 1n));
@@ -29,7 +30,7 @@ export async function executeGovernanceProposal(proposalId, governance, voteAmou
29
30
  ], {
30
31
  account: privateKey
31
32
  });
32
- await publicClient.waitForTransactionReceipt({
33
+ await l1Client.waitForTransactionReceipt({
33
34
  hash: voteTx
34
35
  });
35
36
  logger.info(`Voted`);
@@ -43,15 +44,15 @@ export async function executeGovernanceProposal(proposalId, governance, voteAmou
43
44
  ], {
44
45
  account: privateKey
45
46
  });
46
- await publicClient.waitForTransactionReceipt({
47
+ await l1Client.waitForTransactionReceipt({
47
48
  hash: executeTx
48
49
  });
49
50
  logger.info(`Executed proposal`);
50
51
  }
51
52
  export async function createGovernanceProposal(payloadAddress, addresses, privateKey, publicClient, logger) {
52
53
  const token = getContract({
53
- address: addresses.feeJuiceAddress.toString(),
54
- abi: FeeJuiceAbi,
54
+ address: addresses.stakingAssetAddress.toString(),
55
+ abi: StakingAssetAbi,
55
56
  client: publicClient
56
57
  });
57
58
  const governance = getContract({
@@ -91,14 +92,20 @@ export async function createGovernanceProposal(payloadAddress, addresses, privat
91
92
  hash: depositTx
92
93
  });
93
94
  logger.info(`Deposited tokens`);
94
- await governance.write.proposeWithLock([
95
+ const proposeTx = await governance.write.proposeWithLock([
95
96
  payloadAddress,
96
97
  privateKey.address
97
98
  ], {
98
99
  account: privateKey
99
100
  });
101
+ const receipt = await publicClient.waitForTransactionReceipt({
102
+ hash: proposeTx
103
+ });
104
+ logger.info(`Proposed upgrade`);
105
+ const proposalId = extractProposalIdFromLogs(receipt.logs);
100
106
  return {
101
107
  governance,
102
- voteAmount
108
+ voteAmount,
109
+ proposalId
103
110
  };
104
111
  }
package/dest/types.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import type { Account, Chain, Client, FallbackTransport, HttpTransport, PublicActions, PublicClient, PublicRpcSchema, WalletActions, WalletClient, WalletRpcSchema } from 'viem';
1
+ import type { Abi, Account, Chain, Client, FallbackTransport, GetContractReturnType, 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 SimpleViemWalletClient = WalletClient<FallbackTransport<HttpTransport[]>, Chain, Account>;
5
4
  export type ExtendedViemWalletClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account, [
6
5
  ...PublicRpcSchema,
7
6
  ...WalletRpcSchema
8
7
  ], PublicActions<FallbackTransport<readonly HttpTransport[]>, Chain> & WalletActions<Chain, Account>>;
9
- export type ViemWalletClient = SimpleViemWalletClient | ExtendedViemWalletClient;
10
- export type L1Clients = {
11
- publicClient: ViemPublicClient;
12
- walletClient: ExtendedViemWalletClient;
13
- };
8
+ /** Type for a viem client that can be either public or extended with wallet capabilities */
9
+ export type ViemClient = ViemPublicClient | ExtendedViemWalletClient;
10
+ /** Type for a viem contract that can be used with an extended viem client */
11
+ export type ViemContract<TAbi extends Abi> = GetContractReturnType<TAbi, ExtendedViemWalletClient>;
12
+ export declare function isExtendedClient(client: ViemClient): client is ExtendedViemWalletClient;
14
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,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,sBAAsB,GAAG,YAAY,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAEtG,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,C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1 +1,3 @@
1
- export { };
1
+ export function isExtendedClient(client) {
2
+ return 'account' in client && client.account !== undefined;
3
+ }
package/dest/utils.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare class FormattedViemError extends Error {
12
12
  constructor(message: string, metaMessages?: any[]);
13
13
  }
14
14
  export declare function extractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType;
15
+ export declare function tryExtractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType | undefined;
15
16
  export declare function prettyLogViemErrorMsg(err: any): any;
16
17
  /**
17
18
  * Formats a Viem error into a FormattedViemError instance.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,EAER,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,GAAG,EACR,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAEd,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;gBAET,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,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acts';
1
+ import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
2
2
  import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEventLog } from 'viem';
3
3
  export class FormattedViemError extends Error {
4
4
  metaMessages;
@@ -15,7 +15,7 @@ export function extractEvent(logs, address, abi, eventName, filter, logger) {
15
15
  }
16
16
  return event;
17
17
  }
18
- function tryExtractEvent(logs, address, abi, eventName, filter, logger) {
18
+ export function tryExtractEvent(logs, address, abi, eventName, filter, logger) {
19
19
  for (const log of logs){
20
20
  if (log.address.toLowerCase() === address.toLowerCase()) {
21
21
  try {
@@ -101,97 +101,52 @@ function getNestedErrorData(error) {
101
101
  return new FormattedViemError(`${errorName}${args}`, error?.metaMessages);
102
102
  }
103
103
  }
104
- } catch (decodeErr) {
104
+ } catch {
105
105
  // If decoding fails, we fall back to the original formatting
106
106
  }
107
+ // Strip ABI from the error object before formatting
108
+ if (error && typeof error === 'object') {
109
+ // Create a clone to avoid modifying the original
110
+ const errorClone = structuredClone(error);
111
+ // Helper function to recursively remove ABI properties
112
+ // Strip ABIs from the clone
113
+ stripAbis(errorClone);
114
+ // Use the cleaned clone for further processing
115
+ error = errorClone;
116
+ }
107
117
  // If it's a regular Error instance, return it with its message
108
118
  if (error instanceof Error) {
109
- return error;
119
+ return new FormattedViemError(error.message, error?.metaMessages);
110
120
  }
111
- // Original formatting logic for non-custom errors
112
- const truncateHex = (hex, length = 100)=>{
113
- if (!hex || typeof hex !== 'string') {
114
- return hex;
115
- }
116
- if (!hex.startsWith('0x')) {
117
- return hex;
118
- }
119
- if (hex.length <= length * 2) {
120
- return hex;
121
- }
122
- return `${hex.slice(0, length)}...${hex.slice(-length)}`;
123
- };
124
- const formatRequestBody = (body)=>{
125
- try {
126
- const parsed = JSON.parse(body);
127
- // Recursively process all parameters that might contain hex strings
128
- const processParams = (obj)=>{
129
- if (Array.isArray(obj)) {
130
- return obj.map((item)=>processParams(item));
131
- }
132
- if (typeof obj === 'object' && obj !== null) {
133
- const result = {};
134
- for (const [key, value] of Object.entries(obj)){
135
- result[key] = processParams(value);
136
- }
137
- return result;
138
- }
139
- if (typeof obj === 'string') {
140
- if (obj.startsWith('0x')) {
141
- return truncateHex(obj);
142
- }
143
- }
144
- return obj;
145
- };
146
- // Process the entire request body
147
- const processed = processParams(parsed);
148
- return JSON.stringify(processed, null, 2);
149
- } catch {
150
- return body;
121
+ const body = String(error);
122
+ const length = body.length;
123
+ // LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
124
+ // Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
125
+ if (length > 2000) {
126
+ const chunk = 950;
127
+ const truncated = length - 2 * chunk;
128
+ return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
129
+ }
130
+ return new FormattedViemError(body);
131
+ }
132
+ function stripAbis(obj) {
133
+ if (!obj || typeof obj !== 'object') {
134
+ return;
135
+ }
136
+ // Delete ABI property at current level
137
+ if ('abi' in obj) {
138
+ delete obj.abi;
139
+ }
140
+ // Process cause property
141
+ if (obj.cause) {
142
+ stripAbis(obj.cause);
143
+ }
144
+ // Process arrays and objects
145
+ Object.values(obj).forEach((value)=>{
146
+ if (value && typeof value === 'object') {
147
+ stripAbis(value);
151
148
  }
152
- };
153
- const truncateHexStringsInText = (text)=>{
154
- const hexRegex = /\b0x[a-fA-F0-9]{10,}/g;
155
- return text.replace(hexRegex, (hex)=>truncateHex(hex));
156
- };
157
- const extractAndFormatRequestBody = (message)=>{
158
- // First handle Request body JSON
159
- const requestBodyRegex = /Request body: ({[\s\S]*?})\n/g;
160
- let result = message.replace(requestBodyRegex, (match, body)=>{
161
- return `Request body: ${formatRequestBody(body)}\n`;
162
- });
163
- // Then handle Arguments section
164
- const argsRegex = /((?:Request |Estimate Gas )?Arguments:[\s\S]*?(?=\n\n|$))/g;
165
- result = result.replace(argsRegex, (section)=>{
166
- const lines = section.split('\n');
167
- const processedLines = lines.map((line)=>{
168
- // Check if line contains a colon followed by content
169
- const colonIndex = line.indexOf(':');
170
- if (colonIndex !== -1) {
171
- const [prefix, content] = [
172
- line.slice(0, colonIndex + 1),
173
- line.slice(colonIndex + 1).trim()
174
- ];
175
- // If content contains a hex string, truncate it
176
- if (content.includes('0x')) {
177
- const hexMatches = content.match(/0x[a-fA-F0-9]+/g) || [];
178
- let processedContent = content;
179
- hexMatches.forEach((hex)=>{
180
- processedContent = processedContent.replace(hex, truncateHex(hex));
181
- });
182
- return `${prefix} ${processedContent}`;
183
- }
184
- }
185
- return line;
186
- });
187
- return processedLines.join('\n');
188
- });
189
- // Finally, catch any remaining hex strings in the message
190
- result = truncateHexStringsInText(result);
191
- return result;
192
- };
193
- const formattedRes = extractAndFormatRequestBody(error?.message || String(error));
194
- return new FormattedViemError(formattedRes.replace(/\\n/g, '\n'), error?.metaMessages);
149
+ });
195
150
  }
196
151
  export function tryGetCustomErrorName(err) {
197
152
  try {
@@ -203,7 +158,7 @@ export function tryGetCustomErrorName(err) {
203
158
  return revertError.data?.errorName;
204
159
  }
205
160
  }
206
- } catch (_e) {
161
+ } catch {
207
162
  return undefined;
208
163
  }
209
164
  }
@@ -0,0 +1,15 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ /**
3
+ * The address of the zk passport verifier on sepolia
4
+ * get address from: ROOT/l1-contracts/lib/circuits/src/solidity/deployments/deployment-11155111.json
5
+ */
6
+ export declare const ZK_PASSPORT_VERIFIER_ADDRESS: EthAddress;
7
+ /**
8
+ * The default domain of the zk passport site
9
+ */
10
+ export declare const ZK_PASSPORT_DOMAIN = "testnet.aztec.network";
11
+ /**
12
+ * The default scope of the zk passport proofs
13
+ */
14
+ export declare const ZK_PASSPORT_SCOPE = "personhood";
15
+ //# sourceMappingURL=zkPassportVerifierAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zkPassportVerifierAddress.d.ts","sourceRoot":"","sources":["../src/zkPassportVerifierAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,YAAsE,CAAC;AAChH;;GAEG;AACH,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ /**
3
+ * The address of the zk passport verifier on sepolia
4
+ * get address from: ROOT/l1-contracts/lib/circuits/src/solidity/deployments/deployment-11155111.json
5
+ */ export const ZK_PASSPORT_VERIFIER_ADDRESS = EthAddress.fromString('0x3101Bad9eA5fACadA5554844a1a88F7Fe48D4DE0');
6
+ /**
7
+ * The default domain of the zk passport site
8
+ */ export const ZK_PASSPORT_DOMAIN = 'testnet.aztec.network';
9
+ /**
10
+ * The default scope of the zk passport proofs
11
+ */ export const ZK_PASSPORT_SCOPE = 'personhood';
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@aztec/ethereum",
3
- "version": "0.0.0-test.1",
3
+ "version": "0.0.1-commit.b655e406",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
- "./eth-cheatcodes": "./dest/eth_cheat_codes.js",
8
7
  "./test": "./dest/test/index.js",
9
8
  "./contracts": "./dest/contracts/index.js",
10
9
  "./deploy-l1-contracts": "./dest/deploy_l1_contracts.js",
11
10
  "./l1-contract-addresses": "./dest/l1_contract_addresses.js",
12
- "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils_with_blobs.js",
11
+ "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils/l1_tx_utils_with_blobs.js",
13
12
  "./utils": "./dest/utils.js"
14
13
  },
15
14
  "typedocOptions": {
@@ -23,35 +22,40 @@
23
22
  "build": "yarn clean && tsc -b",
24
23
  "build:dev": "tsc -b --watch",
25
24
  "clean": "rm -rf ./dest .tsbuildinfo",
26
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
27
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
28
25
  "start:dev": "tsc-watch -p tsconfig.json --onSuccess 'yarn start'",
29
26
  "start": "node ./dest/index.js",
30
- "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
27
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
28
+ "proposer-address": "node ./dest/cli/forwarder_address.js"
31
29
  },
32
30
  "inherits": [
33
31
  "../package.common.json"
34
32
  ],
35
33
  "dependencies": {
36
- "@aztec/blob-lib": "0.0.0-test.1",
37
- "@aztec/foundation": "0.0.0-test.1",
38
- "@aztec/l1-artifacts": "0.0.0-test.1",
34
+ "@aztec/blob-lib": "0.0.1-commit.b655e406",
35
+ "@aztec/constants": "0.0.1-commit.b655e406",
36
+ "@aztec/foundation": "0.0.1-commit.b655e406",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.b655e406",
39
38
  "@viem/anvil": "^0.0.10",
40
39
  "dotenv": "^16.0.3",
40
+ "lodash.chunk": "^4.2.0",
41
+ "lodash.pickby": "^4.5.0",
41
42
  "tslib": "^2.4.0",
42
- "viem": "2.22.8",
43
+ "viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
43
44
  "zod": "^3.23.8"
44
45
  },
45
46
  "devDependencies": {
46
- "@jest/globals": "^29.5.0",
47
- "@types/jest": "^29.5.0",
48
- "@types/node": "^18.14.6",
47
+ "@jest/globals": "^30.0.0",
48
+ "@noble/curves": "=1.7.0",
49
+ "@types/jest": "^30.0.0",
50
+ "@types/lodash.pickby": "^4",
51
+ "@types/node": "^22.15.17",
49
52
  "@viem/anvil": "^0.0.10",
50
53
  "get-port": "^7.1.0",
51
- "jest": "^29.5.0",
54
+ "jest": "^30.0.0",
55
+ "jest-mock-extended": "^4.0.0",
52
56
  "lodash.omit": "^4.5.0",
53
57
  "ts-node": "^10.9.1",
54
- "typescript": "^5.0.4"
58
+ "typescript": "^5.3.3"
55
59
  },
56
60
  "files": [
57
61
  "dest",
@@ -90,9 +94,13 @@
90
94
  "testTimeout": 120000,
91
95
  "setupFiles": [
92
96
  "../../foundation/src/jest/setup.mjs"
97
+ ],
98
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
99
+ "setupFilesAfterEnv": [
100
+ "../../foundation/src/jest/setupAfterEnv.mjs"
93
101
  ]
94
102
  },
95
103
  "engines": {
96
- "node": ">=18"
104
+ "node": ">=20.10"
97
105
  }
98
106
  }
package/src/account.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { privateKeyToAccount } from 'viem/accounts';
2
+
3
+ export function getAddressFromPrivateKey(privateKey: `0x${string}`): `0x${string}` {
4
+ return privateKeyToAccount(privateKey).address;
5
+ }
package/src/client.ts CHANGED
@@ -1,13 +1,25 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
 
4
- import { createPublicClient, fallback, http } from 'viem';
4
+ import {
5
+ type Chain,
6
+ type HDAccount,
7
+ type LocalAccount,
8
+ type PrivateKeyAccount,
9
+ createPublicClient,
10
+ createWalletClient,
11
+ fallback,
12
+ http,
13
+ publicActions,
14
+ } from 'viem';
15
+ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
16
+ import { foundry } from 'viem/chains';
5
17
 
6
18
  import { createEthereumChain } from './chain.js';
7
- import type { ViemPublicClient } from './types.js';
19
+ import type { ExtendedViemWalletClient, ViemPublicClient } from './types.js';
8
20
 
9
21
  type Config = {
10
- /** The RPC Url of the ethereum host. */
22
+ /** List of URLs of Ethereum RPC nodes that services will connect to (comma separated). */
11
23
  l1RpcUrls: string[];
12
24
  /** The chain ID of the ethereum host. */
13
25
  l1ChainId: number;
@@ -15,6 +27,8 @@ type Config = {
15
27
  viemPollingIntervalMS?: number;
16
28
  };
17
29
 
30
+ export type { Config as EthereumClientConfig };
31
+
18
32
  // TODO: Use these methods to abstract the creation of viem clients.
19
33
 
20
34
  /** Returns a viem public client given the L1 config. */
@@ -40,7 +54,7 @@ async function waitForRpc(client: ViemPublicClient, config: Config, logger?: Log
40
54
  let chainId = 0;
41
55
  try {
42
56
  chainId = await client.getChainId();
43
- } catch (err) {
57
+ } catch {
44
58
  logger?.warn(`Failed to connect to Ethereum node at ${config.l1RpcUrls.join(', ')}. Retrying...`);
45
59
  }
46
60
  return chainId;
@@ -56,3 +70,27 @@ async function waitForRpc(client: ViemPublicClient, config: Config, logger?: Log
56
70
  );
57
71
  }
58
72
  }
73
+
74
+ export function createExtendedL1Client(
75
+ rpcUrls: string[],
76
+ mnemonicOrPrivateKeyOrHdAccount: string | HDAccount | PrivateKeyAccount | LocalAccount,
77
+ chain: Chain = foundry,
78
+ pollingIntervalMS?: number,
79
+ addressIndex?: number,
80
+ ): ExtendedViemWalletClient {
81
+ const hdAccount =
82
+ typeof mnemonicOrPrivateKeyOrHdAccount === 'string'
83
+ ? mnemonicOrPrivateKeyOrHdAccount.startsWith('0x')
84
+ ? privateKeyToAccount(mnemonicOrPrivateKeyOrHdAccount as `0x${string}`)
85
+ : mnemonicToAccount(mnemonicOrPrivateKeyOrHdAccount, { addressIndex })
86
+ : mnemonicOrPrivateKeyOrHdAccount;
87
+
88
+ const extendedClient = createWalletClient({
89
+ account: hdAccount,
90
+ chain,
91
+ transport: fallback(rpcUrls.map(url => http(url))),
92
+ pollingInterval: pollingIntervalMS,
93
+ }).extend(publicActions);
94
+
95
+ return extendedClient;
96
+ }