@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.001888fc

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 (289) 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 +14 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +27 -3
  8. package/dest/config.d.ts +70 -23
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +155 -34
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +27 -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 +69 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +216 -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_asset_price_oracle.d.ts +101 -0
  25. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  26. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  27. package/dest/contracts/fee_juice.d.ts +6 -7
  28. package/dest/contracts/fee_juice.d.ts.map +1 -1
  29. package/dest/contracts/fee_juice.js +27 -20
  30. package/dest/contracts/governance.d.ts +45 -32
  31. package/dest/contracts/governance.d.ts.map +1 -1
  32. package/dest/contracts/governance.js +98 -85
  33. package/dest/contracts/governance_proposer.d.ts +19 -13
  34. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  35. package/dest/contracts/governance_proposer.js +441 -26
  36. package/dest/contracts/gse.d.ts +32 -0
  37. package/dest/contracts/gse.d.ts.map +1 -0
  38. package/dest/contracts/gse.js +72 -0
  39. package/dest/contracts/inbox.d.ts +47 -0
  40. package/dest/contracts/inbox.d.ts.map +1 -0
  41. package/dest/contracts/inbox.js +80 -0
  42. package/dest/contracts/index.d.ts +12 -3
  43. package/dest/contracts/index.d.ts.map +1 -1
  44. package/dest/contracts/index.js +11 -2
  45. package/dest/contracts/log.d.ts +13 -0
  46. package/dest/contracts/log.d.ts.map +1 -0
  47. package/dest/contracts/log.js +1 -0
  48. package/dest/contracts/multicall.d.ts +21 -0
  49. package/dest/contracts/multicall.d.ts.map +1 -0
  50. package/dest/contracts/multicall.js +157 -0
  51. package/dest/contracts/outbox.d.ts +41 -0
  52. package/dest/contracts/outbox.d.ts.map +1 -0
  53. package/dest/contracts/outbox.js +86 -0
  54. package/dest/contracts/registry.d.ts +12 -5
  55. package/dest/contracts/registry.d.ts.map +1 -1
  56. package/dest/contracts/registry.js +74 -17
  57. package/dest/contracts/rollup.d.ts +311 -53
  58. package/dest/contracts/rollup.d.ts.map +1 -1
  59. package/dest/contracts/rollup.js +1180 -116
  60. package/dest/contracts/slasher_contract.d.ts +44 -0
  61. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  62. package/dest/contracts/slasher_contract.js +75 -0
  63. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  64. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  65. package/dest/contracts/tally_slashing_proposer.js +320 -0
  66. package/dest/contracts/utils.d.ts +3 -0
  67. package/dest/contracts/utils.d.ts.map +1 -0
  68. package/dest/contracts/utils.js +11 -0
  69. package/dest/deploy_aztec_l1_contracts.d.ts +259 -0
  70. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  71. package/dest/deploy_aztec_l1_contracts.js +413 -0
  72. package/dest/deploy_l1_contract.d.ts +68 -0
  73. package/dest/deploy_l1_contract.d.ts.map +1 -0
  74. package/dest/deploy_l1_contract.js +312 -0
  75. package/dest/eth-signer/eth-signer.d.ts +21 -0
  76. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  77. package/dest/eth-signer/eth-signer.js +5 -0
  78. package/dest/eth-signer/index.d.ts +2 -0
  79. package/dest/eth-signer/index.d.ts.map +1 -0
  80. package/dest/eth-signer/index.js +1 -0
  81. package/dest/forwarder_proxy.d.ts +32 -0
  82. package/dest/forwarder_proxy.d.ts.map +1 -0
  83. package/dest/forwarder_proxy.js +93 -0
  84. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  85. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  86. package/dest/generated/l1-contracts-defaults.js +30 -0
  87. package/dest/l1_artifacts.d.ts +81744 -0
  88. package/dest/l1_artifacts.d.ts.map +1 -0
  89. package/dest/l1_artifacts.js +166 -0
  90. package/dest/l1_contract_addresses.d.ts +24 -4
  91. package/dest/l1_contract_addresses.d.ts.map +1 -1
  92. package/dest/l1_contract_addresses.js +25 -21
  93. package/dest/l1_reader.d.ts +6 -2
  94. package/dest/l1_reader.d.ts.map +1 -1
  95. package/dest/l1_reader.js +20 -9
  96. package/dest/l1_tx_utils/config.d.ts +65 -0
  97. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/config.js +109 -0
  99. package/dest/l1_tx_utils/constants.d.ts +12 -0
  100. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/constants.js +39 -0
  102. package/dest/l1_tx_utils/factory.d.ts +32 -0
  103. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/factory.js +22 -0
  105. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  106. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  108. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  109. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  111. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  112. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  114. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  115. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  117. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  118. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
  120. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  121. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/index-blobs.js +2 -0
  123. package/dest/l1_tx_utils/index.d.ts +13 -0
  124. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/index.js +13 -0
  126. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  127. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/interfaces.js +4 -0
  129. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  130. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  132. package/dest/l1_tx_utils/l1_tx_utils.d.ts +105 -0
  133. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/l1_tx_utils.js +639 -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 +327 -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/tx_delayer.d.ts +56 -0
  142. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  143. package/dest/l1_tx_utils/tx_delayer.js +221 -0
  144. package/dest/l1_tx_utils/types.d.ts +67 -0
  145. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  146. package/dest/l1_tx_utils/types.js +26 -0
  147. package/dest/l1_tx_utils/utils.d.ts +4 -0
  148. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  149. package/dest/l1_tx_utils/utils.js +14 -0
  150. package/dest/l1_types.d.ts +6 -0
  151. package/dest/l1_types.d.ts.map +1 -0
  152. package/dest/l1_types.js +1 -0
  153. package/dest/publisher_manager.d.ts +16 -0
  154. package/dest/publisher_manager.d.ts.map +1 -0
  155. package/dest/publisher_manager.js +88 -0
  156. package/dest/queries.d.ts +5 -3
  157. package/dest/queries.d.ts.map +1 -1
  158. package/dest/queries.js +61 -12
  159. package/dest/test/chain_monitor.d.ts +94 -0
  160. package/dest/test/chain_monitor.d.ts.map +1 -0
  161. package/dest/test/chain_monitor.js +244 -0
  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 -3
  169. package/dest/test/index.d.ts.map +1 -1
  170. package/dest/test/index.js +3 -2
  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 +23 -2
  175. package/dest/test/start_anvil.d.ts.map +1 -1
  176. package/dest/test/start_anvil.js +133 -24
  177. package/dest/test/upgrade_utils.d.ts +6 -5
  178. package/dest/test/upgrade_utils.d.ts.map +1 -1
  179. package/dest/test/upgrade_utils.js +23 -16
  180. package/dest/types.d.ts +62 -8
  181. package/dest/types.d.ts.map +1 -1
  182. package/dest/types.js +3 -1
  183. package/dest/utils.d.ts +17 -3
  184. package/dest/utils.d.ts.map +1 -1
  185. package/dest/utils.js +111 -88
  186. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  187. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  188. package/dest/zkPassportVerifierAddress.js +11 -0
  189. package/package.json +51 -25
  190. package/src/account.ts +5 -0
  191. package/src/client.ts +51 -5
  192. package/src/config.ts +222 -43
  193. package/src/contracts/README.md +157 -0
  194. package/src/contracts/empire_base.ts +79 -7
  195. package/src/contracts/empire_slashing_proposer.ts +265 -0
  196. package/src/contracts/errors.ts +13 -0
  197. package/src/contracts/fee_asset_handler.ts +66 -0
  198. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  199. package/src/contracts/fee_juice.ts +29 -15
  200. package/src/contracts/governance.ts +90 -78
  201. package/src/contracts/governance_proposer.ts +81 -25
  202. package/src/contracts/gse.ts +88 -0
  203. package/src/contracts/inbox.ts +115 -0
  204. package/src/contracts/index.ts +11 -2
  205. package/src/contracts/log.ts +13 -0
  206. package/src/contracts/multicall.ts +158 -0
  207. package/src/contracts/outbox.ts +98 -0
  208. package/src/contracts/registry.ts +81 -26
  209. package/src/contracts/rollup.ts +940 -89
  210. package/src/contracts/slasher_contract.ts +89 -0
  211. package/src/contracts/tally_slashing_proposer.ts +322 -0
  212. package/src/contracts/utils.ts +14 -0
  213. package/src/deploy_aztec_l1_contracts.ts +650 -0
  214. package/src/deploy_l1_contract.ts +362 -0
  215. package/src/eth-signer/eth-signer.ts +25 -0
  216. package/src/eth-signer/index.ts +1 -0
  217. package/src/forwarder_proxy.ts +108 -0
  218. package/src/generated/l1-contracts-defaults.ts +32 -0
  219. package/src/l1_artifacts.ts +254 -0
  220. package/src/l1_contract_addresses.ts +49 -34
  221. package/src/l1_reader.ts +30 -10
  222. package/src/l1_tx_utils/README.md +177 -0
  223. package/src/l1_tx_utils/config.ts +181 -0
  224. package/src/l1_tx_utils/constants.ts +29 -0
  225. package/src/l1_tx_utils/factory.ts +64 -0
  226. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  227. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  228. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  229. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  230. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
  231. package/src/l1_tx_utils/index-blobs.ts +2 -0
  232. package/src/l1_tx_utils/index.ts +15 -0
  233. package/src/l1_tx_utils/interfaces.ts +86 -0
  234. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  235. package/src/l1_tx_utils/l1_tx_utils.ts +766 -0
  236. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +423 -0
  237. package/src/l1_tx_utils/signer.ts +28 -0
  238. package/src/l1_tx_utils/tx_delayer.ts +294 -0
  239. package/src/l1_tx_utils/types.ts +85 -0
  240. package/src/l1_tx_utils/utils.ts +16 -0
  241. package/src/l1_types.ts +6 -0
  242. package/src/publisher_manager.ts +108 -0
  243. package/src/queries.ts +82 -16
  244. package/src/test/chain_monitor.ts +302 -0
  245. package/src/test/eth_cheat_codes.ts +588 -0
  246. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  247. package/src/test/index.ts +3 -2
  248. package/src/test/rollup_cheat_codes.ts +330 -0
  249. package/src/test/start_anvil.ts +166 -22
  250. package/src/test/upgrade_utils.ts +30 -21
  251. package/src/types.ts +71 -7
  252. package/src/utils.ts +137 -93
  253. package/src/zkPassportVerifierAddress.ts +15 -0
  254. package/dest/contracts/forwarder.d.ts +0 -24
  255. package/dest/contracts/forwarder.d.ts.map +0 -1
  256. package/dest/contracts/forwarder.js +0 -101
  257. package/dest/contracts/slashing_proposer.d.ts +0 -21
  258. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  259. package/dest/contracts/slashing_proposer.js +0 -47
  260. package/dest/deploy_l1_contracts.d.ts +0 -21210
  261. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  262. package/dest/deploy_l1_contracts.js +0 -687
  263. package/dest/eth_cheat_codes.d.ts +0 -147
  264. package/dest/eth_cheat_codes.d.ts.map +0 -1
  265. package/dest/eth_cheat_codes.js +0 -303
  266. package/dest/index.d.ts +0 -14
  267. package/dest/index.d.ts.map +0 -1
  268. package/dest/index.js +0 -13
  269. package/dest/l1_tx_utils.d.ts +0 -192
  270. package/dest/l1_tx_utils.d.ts.map +0 -1
  271. package/dest/l1_tx_utils.js +0 -641
  272. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  273. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  274. package/dest/l1_tx_utils_with_blobs.js +0 -64
  275. package/dest/test/delayed_tx_utils.d.ts +0 -8
  276. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  277. package/dest/test/delayed_tx_utils.js +0 -21
  278. package/dest/test/tx_delayer.d.ts +0 -25
  279. package/dest/test/tx_delayer.d.ts.map +0 -1
  280. package/dest/test/tx_delayer.js +0 -116
  281. package/src/contracts/forwarder.ts +0 -132
  282. package/src/contracts/slashing_proposer.ts +0 -51
  283. package/src/deploy_l1_contracts.ts +0 -948
  284. package/src/eth_cheat_codes.ts +0 -314
  285. package/src/index.ts +0 -13
  286. package/src/l1_tx_utils.ts +0 -847
  287. package/src/l1_tx_utils_with_blobs.ts +0 -86
  288. package/src/test/delayed_tx_utils.ts +0 -24
  289. package/src/test/tx_delayer.ts +0 -163
@@ -0,0 +1,265 @@
1
+ import { SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { retryUntil } from '@aztec/foundation/retry';
5
+ import { EmpireSlashingProposerAbi } from '@aztec/l1-artifacts/EmpireSlashingProposerAbi';
6
+
7
+ import EventEmitter from 'events';
8
+ import {
9
+ type GetContractReturnType,
10
+ type Hex,
11
+ type Log,
12
+ type TypedDataDefinition,
13
+ encodeFunctionData,
14
+ getContract,
15
+ } from 'viem';
16
+
17
+ import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
18
+ import type { ViemClient } from '../types.js';
19
+ import { FormattedViemError, tryExtractEvent } from '../utils.js';
20
+ import { type IEmpireBase, encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
21
+
22
+ export class ProposalAlreadyExecutedError extends Error {
23
+ constructor(round: bigint) {
24
+ super(`Proposal already executed: ${round}`);
25
+ }
26
+ }
27
+
28
+ export class EmpireSlashingProposerContract extends EventEmitter implements IEmpireBase {
29
+ private readonly logger = createLogger('ethereum:contracts:empire_slashing_proposer');
30
+ private readonly proposer: GetContractReturnType<typeof EmpireSlashingProposerAbi, ViemClient>;
31
+
32
+ public readonly type = 'empire' as const;
33
+
34
+ constructor(
35
+ public readonly client: ViemClient,
36
+ address: Hex | EthAddress,
37
+ ) {
38
+ super();
39
+ this.proposer = getContract({
40
+ address: typeof address === 'string' ? address : address.toString(),
41
+ abi: EmpireSlashingProposerAbi,
42
+ client,
43
+ });
44
+ }
45
+
46
+ public get address() {
47
+ return EthAddress.fromString(this.proposer.address);
48
+ }
49
+
50
+ public getQuorumSize() {
51
+ return this.proposer.read.QUORUM_SIZE();
52
+ }
53
+
54
+ public getRoundSize() {
55
+ return this.proposer.read.ROUND_SIZE();
56
+ }
57
+
58
+ public getLifetimeInRounds() {
59
+ return this.proposer.read.LIFETIME_IN_ROUNDS();
60
+ }
61
+
62
+ public getExecutionDelayInRounds() {
63
+ return this.proposer.read.EXECUTION_DELAY_IN_ROUNDS();
64
+ }
65
+
66
+ public getCurrentRound() {
67
+ return this.proposer.read.getCurrentRound();
68
+ }
69
+
70
+ public computeRound(slot: SlotNumber): Promise<bigint> {
71
+ return this.proposer.read.computeRound([BigInt(slot)]);
72
+ }
73
+
74
+ public getInstance() {
75
+ return this.proposer.read.getInstance();
76
+ }
77
+
78
+ public async getRoundInfo(
79
+ rollupAddress: Hex,
80
+ round: bigint,
81
+ ): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }> {
82
+ const result = await this.proposer.read.getRoundData([rollupAddress, round]);
83
+ const [signalCount, quorum] = await Promise.all([
84
+ this.proposer.read.signalCount([rollupAddress, round, result.payloadWithMostSignals]),
85
+ this.getQuorumSize(),
86
+ ]);
87
+ return {
88
+ lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
89
+ payloadWithMostSignals: result.payloadWithMostSignals,
90
+ quorumReached: signalCount >= quorum,
91
+ executed: result.executed,
92
+ };
93
+ }
94
+
95
+ public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
96
+ return this.proposer.read.signalCount([rollupAddress, round, payload]);
97
+ }
98
+
99
+ public createSignalRequest(payload: Hex): L1TxRequest {
100
+ return {
101
+ to: this.address.toString(),
102
+ abi: EmpireSlashingProposerAbi,
103
+ data: encodeSignal(payload),
104
+ };
105
+ }
106
+
107
+ public async createSignalRequestWithSignature(
108
+ payload: Hex,
109
+ slot: SlotNumber,
110
+ chainId: number,
111
+ signerAddress: Hex,
112
+ signer: (msg: TypedDataDefinition) => Promise<Hex>,
113
+ ): Promise<L1TxRequest> {
114
+ const signature = await signSignalWithSig(
115
+ signer,
116
+ payload,
117
+ slot,
118
+ await this.getInstance(),
119
+ this.address.toString(),
120
+ chainId,
121
+ );
122
+ return {
123
+ to: this.address.toString(),
124
+ abi: EmpireSlashingProposerAbi,
125
+ data: encodeSignalWithSignature(payload, signature),
126
+ };
127
+ }
128
+
129
+ /** Checks if a payload was ever submitted to governance via submitRoundWinner. */
130
+ public async hasPayloadBeenProposed(payload: Hex, fromBlock: bigint): Promise<boolean> {
131
+ const events = await this.proposer.getEvents.PayloadSubmitted({ payload }, { fromBlock, strict: true });
132
+ return events.length > 0;
133
+ }
134
+
135
+ public listenToSubmittablePayloads(callback: (args: { payload: `0x${string}`; round: bigint }) => unknown) {
136
+ return this.proposer.watchEvent.PayloadSubmittable(
137
+ {},
138
+ {
139
+ strict: true,
140
+ onLogs: logs => {
141
+ for (const log of logs) {
142
+ const { payload, round } = log.args;
143
+ if (payload && round) {
144
+ callback({ payload, round });
145
+ }
146
+ }
147
+ },
148
+ },
149
+ );
150
+ }
151
+
152
+ public listenToPayloadSubmitted(callback: (args: { round: bigint; payload: `0x${string}` }) => unknown) {
153
+ return this.proposer.watchEvent.PayloadSubmitted(
154
+ {},
155
+ {
156
+ onLogs: logs => {
157
+ for (const log of logs) {
158
+ const { payload, round } = log.args;
159
+ if (round && payload) {
160
+ callback({ round, payload });
161
+ }
162
+ }
163
+ },
164
+ },
165
+ );
166
+ }
167
+
168
+ public listenToSignalCasted(
169
+ callback: (args: { round: bigint; payload: `0x${string}`; signaler: `0x${string}` }) => unknown,
170
+ ) {
171
+ return this.proposer.watchEvent.SignalCast(
172
+ {},
173
+ {
174
+ onLogs: logs => {
175
+ for (const log of logs) {
176
+ const { round, payload, signaler } = log.args;
177
+ if (round && payload && signaler) {
178
+ callback({ round, payload, signaler });
179
+ }
180
+ }
181
+ },
182
+ },
183
+ );
184
+ }
185
+
186
+ /** Creates an L1TxRequest to submit the round winner for the given round. */
187
+ public buildExecuteRoundRequest(round: bigint): L1TxRequest {
188
+ return {
189
+ to: this.address.toString(),
190
+ abi: EmpireSlashingProposerAbi,
191
+ data: encodeFunctionData({
192
+ abi: EmpireSlashingProposerAbi,
193
+ functionName: 'submitRoundWinner',
194
+ args: [round],
195
+ }),
196
+ };
197
+ }
198
+
199
+ /** Tries to extract a PayloadSubmitted event from the given logs. */
200
+ public tryExtractPayloadSubmittedEvent(logs: Log[]) {
201
+ return tryExtractEvent(logs, this.address.toString(), EmpireSlashingProposerAbi, 'PayloadSubmitted');
202
+ }
203
+
204
+ /**
205
+ * Wait for a round to be reached.
206
+ *
207
+ * @param round - The round to wait for.
208
+ * @param pollingIntervalSeconds - The interval in seconds to poll for the round.
209
+ * @returns True if the round was reached, false otherwise.
210
+ */
211
+ public waitForRound(round: bigint, pollingIntervalSeconds: number = 1): Promise<boolean> {
212
+ return retryUntil(
213
+ async () => {
214
+ const currentRound = await this.proposer.read.getCurrentRound().catch(e => {
215
+ this.logger.error('Error getting current round', e);
216
+ return undefined;
217
+ });
218
+ return currentRound !== undefined && currentRound >= round;
219
+ },
220
+ `Waiting for round ${round} to be reached`,
221
+ 0, // no timeout
222
+ pollingIntervalSeconds,
223
+ ).catch(() => false);
224
+ }
225
+
226
+ public async executeRound(
227
+ txUtils: L1TxUtils,
228
+ round: bigint | number,
229
+ ): ReturnType<typeof txUtils.sendAndMonitorTransaction> {
230
+ if (typeof round === 'number') {
231
+ round = BigInt(round);
232
+ }
233
+ const request = this.buildExecuteRoundRequest(round);
234
+ const response = await txUtils
235
+ .sendAndMonitorTransaction(request, {
236
+ // Gas estimation is way off for this, likely because we are creating the contract/selector to call
237
+ // for the actual slashing dynamically.
238
+ gasLimitBufferPercentage: 50, // +50% gas
239
+ })
240
+ .catch(err => {
241
+ if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
242
+ throw new ProposalAlreadyExecutedError(round);
243
+ }
244
+ throw err;
245
+ });
246
+
247
+ if (response.receipt.status === 'reverted') {
248
+ const args = {
249
+ abi: EmpireSlashingProposerAbi,
250
+ functionName: 'submitRoundWinner' as const,
251
+ args: [round] as const,
252
+ address: this.address.toString(),
253
+ };
254
+ const error = await txUtils.tryGetErrorFromRevertedTx(request.data!, args, undefined, []);
255
+ if (error?.includes('ProposalAlreadyExecuted')) {
256
+ throw new ProposalAlreadyExecutedError(round);
257
+ }
258
+ const errorMessage = `Failed to execute round ${round}, TxHash: ${response.receipt.transactionHash}, Error: ${
259
+ error ?? 'Unknown error'
260
+ }`;
261
+ throw new Error(errorMessage);
262
+ }
263
+ return response;
264
+ }
265
+ }
@@ -0,0 +1,13 @@
1
+ export class BlockTagTooOldError extends Error {
2
+ constructor(blockTag: bigint | number, latestBlock: bigint | number) {
3
+ super(`Block tag ${blockTag} is more than 128 blocks behind the latest block ${latestBlock}`);
4
+ this.name = 'BlockTagTooOldError';
5
+ }
6
+ }
7
+
8
+ export class NoCommitteeError extends Error {
9
+ constructor() {
10
+ super('The committee does not exist on L1');
11
+ this.name = 'NoCommitteeError';
12
+ }
13
+ }
@@ -0,0 +1,66 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
3
+
4
+ import { type Hex, encodeFunctionData, getContract } from 'viem';
5
+
6
+ import type { L1TxUtils } from '../l1_tx_utils/index.js';
7
+ import type { ViemClient } from '../types.js';
8
+
9
+ export class FeeAssetHandlerContract {
10
+ public address: EthAddress;
11
+
12
+ constructor(
13
+ public readonly client: ViemClient,
14
+ address: Hex | EthAddress,
15
+ ) {
16
+ if (address instanceof EthAddress) {
17
+ address = address.toString();
18
+ }
19
+ this.address = EthAddress.fromString(address);
20
+ }
21
+
22
+ public async getOwner(): Promise<EthAddress> {
23
+ const contract = getContract({
24
+ abi: FeeAssetHandlerAbi,
25
+ address: this.address.toString(),
26
+ client: this.client,
27
+ });
28
+ return EthAddress.fromString(await contract.read.owner());
29
+ }
30
+
31
+ public getMintAmount() {
32
+ const contract = getContract({
33
+ abi: FeeAssetHandlerAbi,
34
+ address: this.address.toString(),
35
+ client: this.client,
36
+ });
37
+ return contract.read.mintAmount();
38
+ }
39
+
40
+ public mint(txUtils: L1TxUtils, recipient: Hex | EthAddress) {
41
+ if (recipient instanceof EthAddress) {
42
+ recipient = recipient.toString();
43
+ }
44
+ return txUtils.sendAndMonitorTransaction({
45
+ to: this.address.toString(),
46
+ abi: FeeAssetHandlerAbi,
47
+ data: encodeFunctionData({
48
+ abi: FeeAssetHandlerAbi,
49
+ functionName: 'mint',
50
+ args: [recipient],
51
+ }),
52
+ });
53
+ }
54
+
55
+ public setMintAmount(txUtils: L1TxUtils, amount: bigint) {
56
+ return txUtils.sendAndMonitorTransaction({
57
+ to: this.address.toString(),
58
+ abi: FeeAssetHandlerAbi,
59
+ data: encodeFunctionData({
60
+ abi: FeeAssetHandlerAbi,
61
+ functionName: 'setMintAmount',
62
+ args: [amount],
63
+ }),
64
+ });
65
+ }
66
+ }
@@ -0,0 +1,280 @@
1
+ import { memoize } from '@aztec/foundation/decorators';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { type Logger, createLogger } from '@aztec/foundation/log';
4
+
5
+ import { type Hex, encodeAbiParameters, getContract, keccak256, parseAbiParameters } from 'viem';
6
+
7
+ import type { ViemClient } from '../types.js';
8
+ import { RollupContract } from './rollup.js';
9
+
10
+ /** Maximum price modifier per checkpoint in basis points. ±100 bps = ±1% */
11
+ export const MAX_FEE_ASSET_PRICE_MODIFIER_BPS = 100n;
12
+
13
+ /**
14
+ * Validates that a fee asset price modifier is within the allowed range.
15
+ * Validators should call this before attesting to a checkpoint proposal.
16
+ *
17
+ * @param modifier - The fee asset price modifier in basis points
18
+ * @returns true if the modifier is valid (between -100 and +100 bps)
19
+ */
20
+ export function validateFeeAssetPriceModifier(modifier: bigint): boolean {
21
+ return modifier >= -MAX_FEE_ASSET_PRICE_MODIFIER_BPS && modifier <= MAX_FEE_ASSET_PRICE_MODIFIER_BPS;
22
+ }
23
+
24
+ /**
25
+ * Oracle for computing fee asset price modifiers based on Uniswap V4 pool prices.
26
+ * Only active on Ethereum mainnet - returns 0 on other chains.
27
+ */
28
+ export class FeeAssetPriceOracle {
29
+ constructor(
30
+ private client: ViemClient,
31
+ private readonly rollupContract: RollupContract,
32
+ private log: Logger = createLogger('fee-asset-price-oracle'),
33
+ ) {}
34
+
35
+ @memoize
36
+ async getUniswapOracle(): Promise<UniswapPriceOracle | undefined> {
37
+ const code = await this.client.getCode({ address: STATE_VIEW_ADDRESS.toString() });
38
+ if (code === undefined || code === '0x') {
39
+ this.log.warn('Uniswap V4 StateView contract not found, skipping fee asset price oracle');
40
+ return undefined;
41
+ }
42
+ this.log.info('Uniswap V4 StateView contract found, initializing fee asset price oracle');
43
+ const oracle = new UniswapPriceOracle(this.client, this.log);
44
+
45
+ try {
46
+ if (!(await oracle.isPoolInitialized())) {
47
+ this.log.warn('Uniswap V4 pool not initialized, skipping fee asset price oracle');
48
+ return undefined;
49
+ }
50
+ } catch (err) {
51
+ this.log.warn(`Failed to check if Uniswap V4 pool is initialized: ${err}`);
52
+ return undefined;
53
+ }
54
+
55
+ return oracle;
56
+ }
57
+
58
+ /**
59
+ * Computes the fee asset price modifier to be used in the next checkpoint proposal.
60
+ *
61
+ * The modifier adjusts the on-chain fee asset price toward the oracle price,
62
+ * clamped to ±1% (±100 basis points) per checkpoint.
63
+ *
64
+ * Returns 0 if not on mainnet or if the oracle query fails.
65
+ *
66
+ * @returns The price modifier in basis points (positive to increase price, negative to decrease)
67
+ */
68
+ async computePriceModifier(): Promise<bigint> {
69
+ const uniswapOracle = await this.getUniswapOracle();
70
+ if (!uniswapOracle) {
71
+ return 0n;
72
+ }
73
+
74
+ try {
75
+ // Get current on-chain price (ETH per fee asset, E12)
76
+ const currentPriceE12 = await this.rollupContract.getEthPerFeeAsset();
77
+
78
+ // Get oracle price (median of last N blocks, ETH per fee asset, E12)
79
+ const oraclePriceE12 = await uniswapOracle.getMeanEthPerFeeAssetE12();
80
+
81
+ // Compute modifier in basis points
82
+ const modifier = this.computePriceModifierBps(currentPriceE12, oraclePriceE12);
83
+
84
+ this.log.debug('Computed price modifier', {
85
+ currentPriceE12: currentPriceE12.toString(),
86
+ oraclePriceE12: oraclePriceE12.toString(),
87
+ modifierBps: modifier.toString(),
88
+ });
89
+
90
+ return modifier;
91
+ } catch (err) {
92
+ this.log.warn(`Failed to compute price modifier, using 0: ${err}`);
93
+ return 0n;
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Gets the current oracle price (ETH per fee asset, scaled by 1e12).
99
+ * Returns undefined if not on mainnet or if the oracle query fails.
100
+ */
101
+ async getOraclePrice(): Promise<bigint | undefined> {
102
+ const uniswapOracle = await this.getUniswapOracle();
103
+ if (!uniswapOracle) {
104
+ return undefined;
105
+ }
106
+
107
+ try {
108
+ return await uniswapOracle.getMeanEthPerFeeAssetE12();
109
+ } catch (err) {
110
+ this.log.warn(`Failed to get oracle price: ${err}`);
111
+ return undefined;
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Computes the basis points modifier needed to move from current price toward target price.
117
+ *
118
+ * @param currentPrice - Current ETH per fee asset (E12 scale)
119
+ * @param targetPrice - Target ETH per fee asset (E12 scale)
120
+ * @returns Basis points modifier clamped to ±100 (±1%)
121
+ */
122
+ computePriceModifierBps(currentPrice: bigint, targetPrice: bigint): bigint {
123
+ if (currentPrice === 0n) {
124
+ return MAX_FEE_ASSET_PRICE_MODIFIER_BPS;
125
+ }
126
+
127
+ // Calculate percentage difference in basis points
128
+ // modifierBps = ((targetPrice - currentPrice) / currentPrice) * 10000
129
+ const diff = targetPrice - currentPrice;
130
+ const rawModifierBps = (diff * 10_000n) / currentPrice;
131
+
132
+ // Clamp to ±MAX_FEE_ASSET_PRICE_MODIFIER_BPS
133
+ if (rawModifierBps > MAX_FEE_ASSET_PRICE_MODIFIER_BPS) {
134
+ return MAX_FEE_ASSET_PRICE_MODIFIER_BPS;
135
+ }
136
+ if (rawModifierBps < -MAX_FEE_ASSET_PRICE_MODIFIER_BPS) {
137
+ return -MAX_FEE_ASSET_PRICE_MODIFIER_BPS;
138
+ }
139
+ return rawModifierBps;
140
+ }
141
+ }
142
+
143
+ /** Mainnet Uniswap V4 StateView contract address */
144
+ export const STATE_VIEW_ADDRESS = EthAddress.fromString('0x7ffe42c4a5deea5b0fec41c94c136cf115597227');
145
+
146
+ const PRECISION_Q192 = 10n ** 12n * 2n ** 192n;
147
+
148
+ /**
149
+ * Converts Uniswap's sqrtPriceX96 directly to ETH per FeeAsset (E12).
150
+ *
151
+ * For an ETH/FeeAsset pool where ETH is currency0 and FeeAsset is currency1:
152
+ * - Uniswap's sqrtPriceX96 = sqrt(FeeAsset/ETH) * 2^96
153
+ * - We need: ETH/FeeAsset with 1e12 precision
154
+ *
155
+ * Math:
156
+ * price = (sqrtPriceX96 / 2^96)^2 = sqrtPriceX96^2 / 2^192 (FeeAsset per ETH)
157
+ * ethPerFeeAsset = 1 / price = 2^192 / sqrtPriceX96^2
158
+ * ethPerFeeAssetE12 = ethPerFeeAsset * 1e12 = 1e12 * 2^192 / sqrtPriceX96^2
159
+ */
160
+ export function sqrtPriceX96ToEthPerFeeAssetE12(sqrtPriceX96: bigint): bigint {
161
+ if (sqrtPriceX96 === 0n) {
162
+ throw new Error('Cannot convert zero sqrtPriceX96');
163
+ }
164
+ return PRECISION_Q192 / (sqrtPriceX96 * sqrtPriceX96);
165
+ }
166
+ /**
167
+ * Uniswap V4 StateView ABI - only the functions we need
168
+ */
169
+ const StateViewAbi = [
170
+ {
171
+ type: 'function',
172
+ name: 'getSlot0',
173
+ inputs: [{ name: 'poolId', type: 'bytes32', internalType: 'PoolId' }],
174
+ outputs: [
175
+ { name: 'sqrtPriceX96', type: 'uint160', internalType: 'uint160' },
176
+ { name: 'tick', type: 'int24', internalType: 'int24' },
177
+ { name: 'protocolFee', type: 'uint24', internalType: 'uint24' },
178
+ { name: 'lpFee', type: 'uint24', internalType: 'uint24' },
179
+ ],
180
+ stateMutability: 'view',
181
+ },
182
+ ] as const;
183
+
184
+ /**
185
+ * Client for querying the ETH/FeeAsset price from Uniswap V4.
186
+ * Returns prices in ETH per FeeAsset format (E12) to match the rollup contract.
187
+ */
188
+ class UniswapPriceOracle {
189
+ private readonly stateView;
190
+ private readonly poolId: Hex;
191
+ private readonly log: Logger;
192
+
193
+ constructor(
194
+ private readonly client: ViemClient,
195
+ log?: Logger,
196
+ ) {
197
+ this.log = log ?? createLogger('uniswap-price-oracle');
198
+ this.stateView = getContract({
199
+ address: STATE_VIEW_ADDRESS.toString(),
200
+ abi: StateViewAbi,
201
+ client,
202
+ });
203
+ this.poolId = this.computePoolId();
204
+ this.log.debug(`Initialized UniswapPriceOracle with poolId: ${this.poolId}`);
205
+ }
206
+
207
+ /**
208
+ * Computes the PoolId from the pool configuration by hashing its components.
209
+ * PoolId = keccak256(abi.encode(currency0, currency1, fee, tickSpacing, hooks))
210
+ * For mainnet, the value is expected to be: 0xce2899b16743cfd5a954d8122d5e07f410305b1aebee39fd73d9f3b9ebf10c2f
211
+ * Derived anyway to make it simpler to change if needed.
212
+ */
213
+ @memoize
214
+ computePoolId(): Hex {
215
+ /** ETH/FeeAsset pool configuration (hardcoded for mainnet) */
216
+ const encoded = encodeAbiParameters(parseAbiParameters('address, address, uint24, int24, address'), [
217
+ EthAddress.ZERO.toString(),
218
+ EthAddress.fromString('0xA27EC0006e59f245217Ff08CD52A7E8b169E62D2').toString(),
219
+ 500, // 0.05%
220
+ 10,
221
+ EthAddress.fromString('0xd53006d1e3110fD319a79AEEc4c527a0d265E080').toString(),
222
+ ]);
223
+ return keccak256(encoded);
224
+ }
225
+
226
+ async isPoolInitialized(): Promise<boolean> {
227
+ const [sqrtPriceX96] = await this.stateView.read.getSlot0([this.poolId], undefined);
228
+ return sqrtPriceX96 !== 0n;
229
+ }
230
+
231
+ /**
232
+ * Gets the price as ETH per FeeAsset, scaled by 1e12.
233
+ * This is the format expected by the rollup contract.
234
+ *
235
+ * @param blockNumber - Optional block number to query at (defaults to latest)
236
+ */
237
+ async getEthPerFeeAssetE12(blockNumber?: bigint): Promise<bigint> {
238
+ const [sqrtPriceX96] = await this.stateView.read.getSlot0(
239
+ [this.poolId],
240
+ blockNumber !== undefined ? { blockNumber } : undefined,
241
+ );
242
+ return sqrtPriceX96ToEthPerFeeAssetE12(sqrtPriceX96);
243
+ }
244
+
245
+ /**
246
+ * Gets the median price over the last N blocks as ETH per FeeAsset (E12).
247
+ * Using median helps protect against single-block manipulation.
248
+ *
249
+ * @param numBlocks - Number of recent blocks to sample (default: 5)
250
+ * @returns Median price as ETH per FeeAsset, scaled by 1e12
251
+ */
252
+ async getMeanEthPerFeeAssetE12(numBlocks: number = 5): Promise<bigint> {
253
+ const currentBlock = await this.client.getBlockNumber();
254
+ const prices: bigint[] = [];
255
+
256
+ for (let i = 0; i < numBlocks; i++) {
257
+ const blockNumber = currentBlock - BigInt(i);
258
+ if (blockNumber < 0n) {
259
+ break;
260
+ }
261
+
262
+ try {
263
+ const price = await this.getEthPerFeeAssetE12(blockNumber);
264
+ prices.push(price);
265
+ } catch (err) {
266
+ this.log.warn(`Failed to get price at block ${blockNumber}: ${err}`);
267
+ // Continue with fewer samples
268
+ }
269
+ }
270
+
271
+ const filteredPrices = prices.filter(price => price !== 0n);
272
+
273
+ if (filteredPrices.length === 0) {
274
+ throw new Error('Failed to get any price samples from Uniswap oracle');
275
+ }
276
+
277
+ const mean = filteredPrices.reduce((a, b) => a + b, 0n) / BigInt(filteredPrices.length);
278
+ return mean;
279
+ }
280
+ }
@@ -1,43 +1,57 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts';
2
+ import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts/TestERC20Abi';
3
3
 
4
4
  import { type GetContractReturnType, type Hex, getContract } from 'viem';
5
5
 
6
- import type { L1Clients } from '../types.js';
6
+ import { type ExtendedViemWalletClient, type ViemClient, isExtendedClient } from '../types.js';
7
7
 
8
8
  export class FeeJuiceContract {
9
- private readonly publicFeeJuice: GetContractReturnType<typeof FeeJuiceAbi, L1Clients['publicClient']>;
10
- private readonly walletFeeJuice: GetContractReturnType<typeof FeeJuiceAbi, L1Clients['walletClient']> | undefined;
9
+ private readonly feeJuiceContract: GetContractReturnType<typeof FeeJuiceAbi, ViemClient>;
11
10
 
12
11
  constructor(
13
- address: Hex,
14
- public readonly publicClient: L1Clients['publicClient'],
15
- public readonly walletClient: L1Clients['walletClient'] | undefined,
12
+ address: Hex | EthAddress,
13
+ public readonly client: ViemClient,
16
14
  ) {
17
- this.publicFeeJuice = getContract({ address, abi: FeeJuiceAbi, client: publicClient });
18
- this.walletFeeJuice = walletClient ? getContract({ address, abi: FeeJuiceAbi, client: walletClient }) : undefined;
15
+ if (address instanceof EthAddress) {
16
+ address = address.toString();
17
+ }
18
+ this.feeJuiceContract = getContract({ address, abi: FeeJuiceAbi, client });
19
19
  }
20
20
 
21
21
  public get address() {
22
- return EthAddress.fromString(this.publicFeeJuice.address);
22
+ return EthAddress.fromString(this.feeJuiceContract.address);
23
+ }
24
+
25
+ public async getOwner(): Promise<EthAddress> {
26
+ return EthAddress.fromString(await this.feeJuiceContract.read.owner());
23
27
  }
24
28
 
25
- private assertWalletFeeJuice() {
26
- if (!this.walletFeeJuice) {
29
+ private assertWalletFeeJuice(): GetContractReturnType<typeof FeeJuiceAbi, ExtendedViemWalletClient> {
30
+ if (!isExtendedClient(this.client)) {
27
31
  throw new Error('Wallet client is required for this operation');
28
32
  }
29
- return this.walletFeeJuice;
33
+ return this.feeJuiceContract as GetContractReturnType<typeof FeeJuiceAbi, ExtendedViemWalletClient>;
30
34
  }
31
35
 
32
36
  public async mint(to: Hex, amount: bigint) {
33
37
  const walletFeeJuice = this.assertWalletFeeJuice();
34
38
  const tx = await walletFeeJuice.write.mint([to, amount]);
35
- await this.publicClient.waitForTransactionReceipt({ hash: tx });
39
+ const receipt = await this.client.waitForTransactionReceipt({ hash: tx });
40
+
41
+ if (receipt.status === 'success') {
42
+ return;
43
+ }
44
+ throw new Error('Mint failed');
36
45
  }
37
46
 
38
47
  public async approve(spender: Hex, amount: bigint) {
39
48
  const walletFeeJuice = this.assertWalletFeeJuice();
40
49
  const tx = await walletFeeJuice.write.approve([spender, amount]);
41
- await this.publicClient.waitForTransactionReceipt({ hash: tx });
50
+ const receipt = await this.client.waitForTransactionReceipt({ hash: tx });
51
+
52
+ if (receipt.status === 'success') {
53
+ return;
54
+ }
55
+ throw new Error('Approve failed');
42
56
  }
43
57
  }