@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.023c3e5

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 (285) 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 +21 -3
  8. package/dest/config.d.ts +68 -23
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +145 -32
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +25 -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 +67 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +207 -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 +20 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +59 -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 +45 -32
  28. package/dest/contracts/governance.d.ts.map +1 -1
  29. package/dest/contracts/governance.js +98 -85
  30. package/dest/contracts/governance_proposer.d.ts +17 -13
  31. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  32. package/dest/contracts/governance_proposer.js +432 -26
  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 +47 -0
  37. package/dest/contracts/inbox.d.ts.map +1 -0
  38. package/dest/contracts/inbox.js +80 -0
  39. package/dest/contracts/index.d.ts +11 -3
  40. package/dest/contracts/index.d.ts.map +1 -1
  41. package/dest/contracts/index.js +10 -2
  42. package/dest/contracts/log.d.ts +13 -0
  43. package/dest/contracts/log.d.ts.map +1 -0
  44. package/dest/contracts/log.js +1 -0
  45. package/dest/contracts/multicall.d.ts +21 -0
  46. package/dest/contracts/multicall.d.ts.map +1 -0
  47. package/dest/contracts/multicall.js +157 -0
  48. package/dest/contracts/outbox.d.ts +41 -0
  49. package/dest/contracts/outbox.d.ts.map +1 -0
  50. package/dest/contracts/outbox.js +86 -0
  51. package/dest/contracts/registry.d.ts +10 -5
  52. package/dest/contracts/registry.d.ts.map +1 -1
  53. package/dest/contracts/registry.js +44 -16
  54. package/dest/contracts/rollup.d.ts +297 -53
  55. package/dest/contracts/rollup.d.ts.map +1 -1
  56. package/dest/contracts/rollup.js +1127 -116
  57. package/dest/contracts/slasher_contract.d.ts +44 -0
  58. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  59. package/dest/contracts/slasher_contract.js +75 -0
  60. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  61. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  62. package/dest/contracts/tally_slashing_proposer.js +320 -0
  63. package/dest/contracts/utils.d.ts +3 -0
  64. package/dest/contracts/utils.d.ts.map +1 -0
  65. package/dest/contracts/utils.js +11 -0
  66. package/dest/deploy_aztec_l1_contracts.d.ts +260 -0
  67. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  68. package/dest/deploy_aztec_l1_contracts.js +398 -0
  69. package/dest/deploy_l1_contract.d.ts +68 -0
  70. package/dest/deploy_l1_contract.d.ts.map +1 -0
  71. package/dest/deploy_l1_contract.js +312 -0
  72. package/dest/eth-signer/eth-signer.d.ts +21 -0
  73. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  74. package/dest/eth-signer/eth-signer.js +5 -0
  75. package/dest/eth-signer/index.d.ts +2 -0
  76. package/dest/eth-signer/index.d.ts.map +1 -0
  77. package/dest/eth-signer/index.js +1 -0
  78. package/dest/forwarder_proxy.d.ts +32 -0
  79. package/dest/forwarder_proxy.d.ts.map +1 -0
  80. package/dest/forwarder_proxy.js +93 -0
  81. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  82. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  83. package/dest/generated/l1-contracts-defaults.js +30 -0
  84. package/dest/l1_artifacts.d.ts +80735 -0
  85. package/dest/l1_artifacts.d.ts.map +1 -0
  86. package/dest/l1_artifacts.js +166 -0
  87. package/dest/l1_contract_addresses.d.ts +24 -4
  88. package/dest/l1_contract_addresses.d.ts.map +1 -1
  89. package/dest/l1_contract_addresses.js +25 -21
  90. package/dest/l1_reader.d.ts +4 -2
  91. package/dest/l1_reader.d.ts.map +1 -1
  92. package/dest/l1_reader.js +14 -8
  93. package/dest/l1_tx_utils/config.d.ts +59 -0
  94. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/config.js +96 -0
  96. package/dest/l1_tx_utils/constants.d.ts +12 -0
  97. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/constants.js +39 -0
  99. package/dest/l1_tx_utils/factory.d.ts +24 -0
  100. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/factory.js +12 -0
  102. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  103. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  105. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  106. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  108. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  109. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  111. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  112. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  114. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  115. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  117. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  118. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/index-blobs.js +2 -0
  120. package/dest/l1_tx_utils/index.d.ts +12 -0
  121. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/index.js +12 -0
  123. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  124. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/interfaces.js +4 -0
  126. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  127. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  129. package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
  130. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
  132. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  133. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  135. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
  136. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  137. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +323 -0
  138. package/dest/l1_tx_utils/signer.d.ts +4 -0
  139. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  140. package/dest/l1_tx_utils/signer.js +16 -0
  141. package/dest/l1_tx_utils/types.d.ts +67 -0
  142. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  143. package/dest/l1_tx_utils/types.js +26 -0
  144. package/dest/l1_tx_utils/utils.d.ts +4 -0
  145. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  146. package/dest/l1_tx_utils/utils.js +14 -0
  147. package/dest/l1_types.d.ts +6 -0
  148. package/dest/l1_types.d.ts.map +1 -0
  149. package/dest/l1_types.js +1 -0
  150. package/dest/publisher_manager.d.ts +16 -0
  151. package/dest/publisher_manager.d.ts.map +1 -0
  152. package/dest/publisher_manager.js +88 -0
  153. package/dest/queries.d.ts +5 -3
  154. package/dest/queries.d.ts.map +1 -1
  155. package/dest/queries.js +61 -12
  156. package/dest/test/chain_monitor.d.ts +75 -0
  157. package/dest/test/chain_monitor.d.ts.map +1 -0
  158. package/dest/test/chain_monitor.js +213 -0
  159. package/dest/test/delayed_tx_utils.d.ts +8 -3
  160. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  161. package/dest/test/delayed_tx_utils.js +13 -6
  162. package/dest/test/eth_cheat_codes.d.ts +229 -0
  163. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  164. package/dest/test/eth_cheat_codes.js +560 -0
  165. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  166. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  167. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  168. package/dest/test/index.d.ts +4 -1
  169. package/dest/test/index.d.ts.map +1 -1
  170. package/dest/test/index.js +3 -0
  171. package/dest/test/rollup_cheat_codes.d.ts +90 -0
  172. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  173. package/dest/test/rollup_cheat_codes.js +292 -0
  174. package/dest/test/start_anvil.d.ts +9 -1
  175. package/dest/test/start_anvil.d.ts.map +1 -1
  176. package/dest/test/start_anvil.js +16 -7
  177. package/dest/test/tx_delayer.d.ts +18 -7
  178. package/dest/test/tx_delayer.d.ts.map +1 -1
  179. package/dest/test/tx_delayer.js +97 -20
  180. package/dest/test/upgrade_utils.d.ts +6 -5
  181. package/dest/test/upgrade_utils.d.ts.map +1 -1
  182. package/dest/test/upgrade_utils.js +23 -16
  183. package/dest/types.d.ts +62 -8
  184. package/dest/types.d.ts.map +1 -1
  185. package/dest/types.js +3 -1
  186. package/dest/utils.d.ts +17 -3
  187. package/dest/utils.d.ts.map +1 -1
  188. package/dest/utils.js +107 -88
  189. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  190. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  191. package/dest/zkPassportVerifierAddress.js +11 -0
  192. package/package.json +51 -23
  193. package/src/account.ts +5 -0
  194. package/src/client.ts +43 -5
  195. package/src/config.ts +207 -41
  196. package/src/contracts/README.md +157 -0
  197. package/src/contracts/empire_base.ts +77 -7
  198. package/src/contracts/empire_slashing_proposer.ts +259 -0
  199. package/src/contracts/errors.ts +13 -0
  200. package/src/contracts/fee_asset_handler.ts +66 -0
  201. package/src/contracts/fee_juice.ts +29 -15
  202. package/src/contracts/governance.ts +90 -78
  203. package/src/contracts/governance_proposer.ts +75 -25
  204. package/src/contracts/gse.ts +88 -0
  205. package/src/contracts/inbox.ts +115 -0
  206. package/src/contracts/index.ts +10 -2
  207. package/src/contracts/log.ts +13 -0
  208. package/src/contracts/multicall.ts +158 -0
  209. package/src/contracts/outbox.ts +98 -0
  210. package/src/contracts/registry.ts +51 -26
  211. package/src/contracts/rollup.ts +879 -89
  212. package/src/contracts/slasher_contract.ts +89 -0
  213. package/src/contracts/tally_slashing_proposer.ts +322 -0
  214. package/src/contracts/utils.ts +14 -0
  215. package/src/deploy_aztec_l1_contracts.ts +619 -0
  216. package/src/deploy_l1_contract.ts +362 -0
  217. package/src/eth-signer/eth-signer.ts +25 -0
  218. package/src/eth-signer/index.ts +1 -0
  219. package/src/forwarder_proxy.ts +108 -0
  220. package/src/generated/l1-contracts-defaults.ts +32 -0
  221. package/src/l1_artifacts.ts +254 -0
  222. package/src/l1_contract_addresses.ts +49 -34
  223. package/src/l1_reader.ts +17 -9
  224. package/src/l1_tx_utils/README.md +177 -0
  225. package/src/l1_tx_utils/config.ts +161 -0
  226. package/src/l1_tx_utils/constants.ts +29 -0
  227. package/src/l1_tx_utils/factory.ts +64 -0
  228. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  229. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  230. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  231. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  232. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  233. package/src/l1_tx_utils/index-blobs.ts +2 -0
  234. package/src/l1_tx_utils/index.ts +14 -0
  235. package/src/l1_tx_utils/interfaces.ts +86 -0
  236. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  237. package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
  238. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  239. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +419 -0
  240. package/src/l1_tx_utils/signer.ts +28 -0
  241. package/src/l1_tx_utils/types.ts +85 -0
  242. package/src/l1_tx_utils/utils.ts +16 -0
  243. package/src/l1_types.ts +6 -0
  244. package/src/publisher_manager.ts +108 -0
  245. package/src/queries.ts +82 -16
  246. package/src/test/chain_monitor.ts +245 -0
  247. package/src/test/delayed_tx_utils.ts +34 -6
  248. package/src/test/eth_cheat_codes.ts +588 -0
  249. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  250. package/src/test/index.ts +3 -0
  251. package/src/test/rollup_cheat_codes.ts +330 -0
  252. package/src/test/start_anvil.ts +24 -5
  253. package/src/test/tx_delayer.ts +130 -27
  254. package/src/test/upgrade_utils.ts +30 -21
  255. package/src/types.ts +71 -7
  256. package/src/utils.ts +133 -92
  257. package/src/zkPassportVerifierAddress.ts +15 -0
  258. package/dest/contracts/forwarder.d.ts +0 -24
  259. package/dest/contracts/forwarder.d.ts.map +0 -1
  260. package/dest/contracts/forwarder.js +0 -101
  261. package/dest/contracts/slashing_proposer.d.ts +0 -21
  262. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  263. package/dest/contracts/slashing_proposer.js +0 -47
  264. package/dest/deploy_l1_contracts.d.ts +0 -21210
  265. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  266. package/dest/deploy_l1_contracts.js +0 -687
  267. package/dest/eth_cheat_codes.d.ts +0 -147
  268. package/dest/eth_cheat_codes.d.ts.map +0 -1
  269. package/dest/eth_cheat_codes.js +0 -303
  270. package/dest/index.d.ts +0 -14
  271. package/dest/index.d.ts.map +0 -1
  272. package/dest/index.js +0 -13
  273. package/dest/l1_tx_utils.d.ts +0 -192
  274. package/dest/l1_tx_utils.d.ts.map +0 -1
  275. package/dest/l1_tx_utils.js +0 -641
  276. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  277. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  278. package/dest/l1_tx_utils_with_blobs.js +0 -64
  279. package/src/contracts/forwarder.ts +0 -132
  280. package/src/contracts/slashing_proposer.ts +0 -51
  281. package/src/deploy_l1_contracts.ts +0 -948
  282. package/src/eth_cheat_codes.ts +0 -314
  283. package/src/index.ts +0 -13
  284. package/src/l1_tx_utils.ts +0 -847
  285. package/src/l1_tx_utils_with_blobs.ts +0 -86
package/dest/utils.js CHANGED
@@ -1,5 +1,6 @@
1
- import { ErrorsAbi } from '@aztec/l1-artifacts';
1
+ import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
2
2
  import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEventLog } from 'viem';
3
+ import { formatAbiItem, formatAbiParams } from 'viem/utils';
3
4
  export class FormattedViemError extends Error {
4
5
  metaMessages;
5
6
  constructor(message, metaMessages){
@@ -15,7 +16,7 @@ export function extractEvent(logs, address, abi, eventName, filter, logger) {
15
16
  }
16
17
  return event;
17
18
  }
18
- function tryExtractEvent(logs, address, abi, eventName, filter, logger) {
19
+ export function tryExtractEvent(logs, address, abi, eventName, filter, logger) {
19
20
  for (const log of logs){
20
21
  if (log.address.toLowerCase() === address.toLowerCase()) {
21
22
  try {
@@ -46,6 +47,51 @@ export function prettyLogViemErrorMsg(err) {
46
47
  }
47
48
  return err?.message ?? err;
48
49
  }
50
+ export function mergeAbis(abis) {
51
+ let merged = [];
52
+ const seen = new Set();
53
+ for (const abi of abis){
54
+ for (const item of abi){
55
+ const key = getAbiItemKey(item);
56
+ if (!seen.has(key)) {
57
+ seen.add(key);
58
+ merged = [
59
+ ...merged,
60
+ item
61
+ ];
62
+ }
63
+ }
64
+ }
65
+ return merged;
66
+ }
67
+ function getAbiItemKey(item) {
68
+ if (item.type === 'function') {
69
+ const signature = formatAbiItem(item);
70
+ const outputs = formatAbiParams(item.outputs);
71
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
72
+ return `function:${signature}:${outputs}:${stateMutability}`;
73
+ }
74
+ if (item.type === 'event') {
75
+ const signature = formatAbiItem(item);
76
+ const indexed = (item.inputs ?? []).map((input)=>input.indexed ? '1' : '0').join('');
77
+ const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
78
+ return `event:${signature}:${indexed}:${anonymous}`;
79
+ }
80
+ if (item.type === 'error') {
81
+ const signature = formatAbiItem(item);
82
+ return `error:${signature}`;
83
+ }
84
+ if (item.type === 'constructor') {
85
+ const inputs = formatAbiParams(item.inputs);
86
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
87
+ return `constructor::${inputs}:${stateMutability}`;
88
+ }
89
+ if (item.type === 'fallback' || item.type === 'receive') {
90
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
91
+ return `${item.type}:::${stateMutability}`;
92
+ }
93
+ return 'unknown';
94
+ }
49
95
  function getNestedErrorData(error) {
50
96
  // If nothing, bail
51
97
  if (!error) {
@@ -101,97 +147,52 @@ function getNestedErrorData(error) {
101
147
  return new FormattedViemError(`${errorName}${args}`, error?.metaMessages);
102
148
  }
103
149
  }
104
- } catch (decodeErr) {
150
+ } catch {
105
151
  // If decoding fails, we fall back to the original formatting
106
152
  }
153
+ // Strip ABI from the error object before formatting
154
+ if (error && typeof error === 'object') {
155
+ // Create a clone to avoid modifying the original
156
+ const errorClone = structuredClone(error);
157
+ // Helper function to recursively remove ABI properties
158
+ // Strip ABIs from the clone
159
+ stripAbis(errorClone);
160
+ // Use the cleaned clone for further processing
161
+ error = errorClone;
162
+ }
107
163
  // If it's a regular Error instance, return it with its message
108
164
  if (error instanceof Error) {
109
- return error;
165
+ return new FormattedViemError(error.message, error?.metaMessages);
110
166
  }
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;
167
+ const body = String(error);
168
+ const length = body.length;
169
+ // LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
170
+ // Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
171
+ if (length > 2000) {
172
+ const chunk = 950;
173
+ const truncated = length - 2 * chunk;
174
+ return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
175
+ }
176
+ return new FormattedViemError(body);
177
+ }
178
+ function stripAbis(obj) {
179
+ if (!obj || typeof obj !== 'object') {
180
+ return;
181
+ }
182
+ // Delete ABI property at current level
183
+ if ('abi' in obj) {
184
+ delete obj.abi;
185
+ }
186
+ // Process cause property
187
+ if (obj.cause) {
188
+ stripAbis(obj.cause);
189
+ }
190
+ // Process arrays and objects
191
+ Object.values(obj).forEach((value)=>{
192
+ if (value && typeof value === 'object') {
193
+ stripAbis(value);
151
194
  }
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);
195
+ });
195
196
  }
196
197
  export function tryGetCustomErrorName(err) {
197
198
  try {
@@ -203,7 +204,25 @@ export function tryGetCustomErrorName(err) {
203
204
  return revertError.data?.errorName;
204
205
  }
205
206
  }
206
- } catch (_e) {
207
+ } catch {
207
208
  return undefined;
208
209
  }
209
210
  }
211
+ /**
212
+ * Type guard to check if a transaction is a blob transaction (EIP-4844).
213
+ * Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
214
+ */ export function isBlobTransaction(tx) {
215
+ return 'maxFeePerBlobGas' in tx && tx.maxFeePerBlobGas !== undefined && 'blobVersionedHashes' in tx && tx.blobVersionedHashes !== undefined;
216
+ }
217
+ /**
218
+ * Calculates a percentile from an array of bigints
219
+ */ export function calculatePercentile(values, percentile) {
220
+ if (values.length === 0) {
221
+ return 0n;
222
+ }
223
+ const sorted = [
224
+ ...values
225
+ ].sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
226
+ const index = Math.ceil((sorted.length - 1) * (percentile / 100));
227
+ return sorted[index];
228
+ }
@@ -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=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiemtQYXNzcG9ydFZlcmlmaWVyQWRkcmVzcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3prUGFzc3BvcnRWZXJpZmllckFkZHJlc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNEOzs7R0FHRztBQUNILGVBQU8sTUFBTSw0QkFBNEIsWUFBc0UsQ0FBQztBQUNoSDs7R0FFRztBQUNILGVBQU8sTUFBTSxrQkFBa0IsMEJBQTBCLENBQUM7QUFDMUQ7O0dBRUc7QUFDSCxlQUFPLE1BQU0saUJBQWlCLGVBQWUsQ0FBQyJ9
@@ -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,32 @@
1
1
  {
2
2
  "name": "@aztec/ethereum",
3
- "version": "0.0.0-test.0",
3
+ "version": "0.0.1-commit.023c3e5",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": "./dest/index.js",
7
- "./eth-cheatcodes": "./dest/eth_cheat_codes.js",
8
- "./test": "./dest/test/index.js",
6
+ "./account": "./dest/account.js",
7
+ "./chain": "./dest/chain.js",
8
+ "./client": "./dest/client.js",
9
+ "./config": "./dest/config.js",
10
+ "./constants": "./dest/constants.js",
9
11
  "./contracts": "./dest/contracts/index.js",
10
- "./deploy-l1-contracts": "./dest/deploy_l1_contracts.js",
12
+ "./deploy-aztec-l1-contracts": "./dest/deploy_aztec_l1_contracts.js",
13
+ "./deploy-l1-contract": "./dest/deploy_l1_contract.js",
14
+ "./contracts/registry": "./dest/contracts/registry.js",
15
+ "./contracts/rollup": "./dest/contracts/rollup.js",
16
+ "./eth-signer": "./dest/eth-signer/index.js",
17
+ "./forwarder-proxy": "./dest/forwarder_proxy.js",
18
+ "./l1-artifacts": "./dest/l1_artifacts.js",
11
19
  "./l1-contract-addresses": "./dest/l1_contract_addresses.js",
12
- "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils_with_blobs.js",
20
+ "./l1-fee-analysis": "./dest/l1_tx_utils/l1_fee_analyzer.js",
21
+ "./l1-reader": "./dest/l1_reader.js",
22
+ "./l1-tx-utils": "./dest/l1_tx_utils/index.js",
23
+ "./l1-tx-utils-with-blobs": "./dest/l1_tx_utils/index-blobs.js",
24
+ "./l1-tx-utils/config": "./dest/l1_tx_utils/config.js",
25
+ "./l1-types": "./dest/l1_types.js",
26
+ "./publisher-manager": "./dest/publisher_manager.js",
27
+ "./queries": "./dest/queries.js",
28
+ "./test": "./dest/test/index.js",
29
+ "./types": "./dest/types.js",
13
30
  "./utils": "./dest/utils.js"
14
31
  },
15
32
  "typedocOptions": {
@@ -20,45 +37,52 @@
20
37
  "tsconfig": "./tsconfig.json"
21
38
  },
22
39
  "scripts": {
23
- "build": "yarn clean && tsc -b",
24
- "build:dev": "tsc -b --watch",
40
+ "build": "yarn clean && ../scripts/tsc.sh",
41
+ "build:dev": "../scripts/tsc.sh --watch",
25
42
  "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
- "start:dev": "tsc-watch -p tsconfig.json --onSuccess 'yarn start'",
43
+ "generate": "./scripts/generate.sh",
44
+ "start:dev": "concurrently -k \"../scripts/tsc.sh --watch\" \"nodemon --watch dest --exec yarn start\"",
29
45
  "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}"
46
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
47
+ "proposer-address": "node ./dest/cli/forwarder_address.js"
31
48
  },
32
49
  "inherits": [
33
50
  "../package.common.json"
34
51
  ],
35
52
  "dependencies": {
36
- "@aztec/blob-lib": "0.0.0-test.0",
37
- "@aztec/foundation": "0.0.0-test.0",
38
- "@aztec/l1-artifacts": "0.0.0-test.0",
53
+ "@aztec/blob-lib": "0.0.1-commit.023c3e5",
54
+ "@aztec/constants": "0.0.1-commit.023c3e5",
55
+ "@aztec/foundation": "0.0.1-commit.023c3e5",
56
+ "@aztec/l1-artifacts": "0.0.1-commit.023c3e5",
39
57
  "@viem/anvil": "^0.0.10",
40
58
  "dotenv": "^16.0.3",
59
+ "lodash.chunk": "^4.2.0",
60
+ "lodash.pickby": "^4.5.0",
41
61
  "tslib": "^2.4.0",
42
- "viem": "2.22.8",
62
+ "viem": "npm:@aztec/viem@2.38.2",
43
63
  "zod": "^3.23.8"
44
64
  },
45
65
  "devDependencies": {
46
- "@jest/globals": "^29.5.0",
47
- "@types/jest": "^29.5.0",
48
- "@types/node": "^18.14.6",
66
+ "@jest/globals": "^30.0.0",
67
+ "@noble/curves": "=1.7.0",
68
+ "@types/jest": "^30.0.0",
69
+ "@types/lodash.pickby": "^4",
70
+ "@types/node": "^22.15.17",
71
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
49
72
  "@viem/anvil": "^0.0.10",
50
73
  "get-port": "^7.1.0",
51
- "jest": "^29.5.0",
74
+ "jest": "^30.0.0",
75
+ "jest-mock-extended": "^4.0.0",
52
76
  "lodash.omit": "^4.5.0",
53
77
  "ts-node": "^10.9.1",
54
- "typescript": "^5.0.4"
78
+ "typescript": "^5.3.3"
55
79
  },
56
80
  "files": [
57
81
  "dest",
58
82
  "src",
59
83
  "!*.test.*"
60
84
  ],
61
- "types": "./dest/index.d.ts",
85
+ "types": "./dest/types.d.ts",
62
86
  "jest": {
63
87
  "moduleNameMapper": {
64
88
  "^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
@@ -90,9 +114,13 @@
90
114
  "testTimeout": 120000,
91
115
  "setupFiles": [
92
116
  "../../foundation/src/jest/setup.mjs"
117
+ ],
118
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
119
+ "setupFilesAfterEnv": [
120
+ "../../foundation/src/jest/setupAfterEnv.mjs"
93
121
  ]
94
122
  },
95
123
  "engines": {
96
- "node": ">=18"
124
+ "node": ">=20.10"
97
125
  }
98
126
  }
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. */
@@ -22,7 +36,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
22
36
  const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
23
37
  return createPublicClient({
24
38
  chain: chain.chainInfo,
25
- transport: fallback(config.l1RpcUrls.map(url => http(url))),
39
+ transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
26
40
  pollingInterval: config.viemPollingIntervalMS,
27
41
  });
28
42
  }
@@ -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, { batch: false }))),
92
+ pollingInterval: pollingIntervalMS,
93
+ }).extend(publicActions);
94
+
95
+ return extendedClient;
96
+ }