@aztec/aztec.js 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 (392) hide show
  1. package/README.md +1 -1
  2. package/dest/account/account.d.ts +60 -0
  3. package/dest/account/account.d.ts.map +1 -0
  4. package/dest/account/account.js +59 -0
  5. package/dest/account/{contract.d.ts → account_contract.d.ts} +16 -10
  6. package/dest/account/account_contract.d.ts.map +1 -0
  7. package/dest/account/{contract.js → account_contract.js} +7 -4
  8. package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
  9. package/dest/account/account_with_secret_key.d.ts.map +1 -0
  10. package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
  11. package/dest/account/index.d.ts +3 -7
  12. package/dest/account/index.d.ts.map +1 -1
  13. package/dest/account/index.js +2 -6
  14. package/dest/account/interface.d.ts +1 -13
  15. package/dest/account/interface.d.ts.map +1 -1
  16. package/dest/account/interface.js +1 -0
  17. package/dest/account/signerless_account.d.ts +24 -0
  18. package/dest/account/signerless_account.d.ts.map +1 -0
  19. package/dest/account/signerless_account.js +27 -0
  20. package/dest/api/abi.d.ts +2 -1
  21. package/dest/api/abi.d.ts.map +1 -1
  22. package/dest/api/abi.js +1 -1
  23. package/dest/api/account.d.ts +5 -2
  24. package/dest/api/account.d.ts.map +1 -1
  25. package/dest/api/account.js +3 -1
  26. package/dest/api/addresses.d.ts +1 -0
  27. package/dest/api/addresses.d.ts.map +1 -1
  28. package/dest/api/addresses.js +1 -0
  29. package/dest/api/authorization.d.ts +5 -0
  30. package/dest/api/authorization.d.ts.map +1 -0
  31. package/dest/api/authorization.js +4 -0
  32. package/dest/api/block.d.ts +3 -0
  33. package/dest/api/block.d.ts.map +1 -0
  34. package/dest/api/block.js +2 -0
  35. package/dest/{contract/index.d.ts → api/contract.d.ts} +15 -11
  36. package/dest/api/contract.d.ts.map +1 -0
  37. package/dest/{contract/index.js → api/contract.js} +14 -10
  38. package/dest/api/crypto.d.ts +2 -0
  39. package/dest/api/crypto.d.ts.map +1 -0
  40. package/dest/api/crypto.js +1 -0
  41. package/dest/api/deployment.d.ts +4 -3
  42. package/dest/api/deployment.d.ts.map +1 -1
  43. package/dest/api/deployment.js +4 -3
  44. package/dest/api/ethereum.d.ts +2 -0
  45. package/dest/api/ethereum.d.ts.map +1 -0
  46. package/dest/api/ethereum.js +1 -0
  47. package/dest/api/events.d.ts +12 -0
  48. package/dest/api/events.d.ts.map +1 -0
  49. package/dest/api/events.js +30 -0
  50. package/dest/api/fee.d.ts +1 -1
  51. package/dest/api/fee.d.ts.map +1 -1
  52. package/dest/api/fee.js +1 -1
  53. package/dest/api/fee_testing.d.ts +2 -0
  54. package/dest/api/fee_testing.d.ts.map +1 -0
  55. package/dest/api/fee_testing.js +1 -0
  56. package/dest/api/keys.d.ts +4 -0
  57. package/dest/api/keys.d.ts.map +1 -0
  58. package/dest/api/keys.js +3 -0
  59. package/dest/api/log.d.ts +1 -0
  60. package/dest/api/log.d.ts.map +1 -1
  61. package/dest/api/log.js +1 -0
  62. package/dest/api/messaging.d.ts +3 -0
  63. package/dest/api/messaging.d.ts.map +1 -0
  64. package/dest/api/messaging.js +2 -0
  65. package/dest/api/node.d.ts +21 -0
  66. package/dest/api/node.d.ts.map +1 -0
  67. package/dest/api/node.js +18 -0
  68. package/dest/api/note.d.ts +2 -0
  69. package/dest/api/note.d.ts.map +1 -0
  70. package/dest/api/note.js +1 -0
  71. package/dest/api/protocol.d.ts +3 -0
  72. package/dest/api/protocol.d.ts.map +1 -0
  73. package/dest/api/protocol.js +2 -0
  74. package/dest/api/trees.d.ts +3 -0
  75. package/dest/api/trees.d.ts.map +1 -0
  76. package/dest/api/trees.js +2 -0
  77. package/dest/api/tx.d.ts +2 -0
  78. package/dest/api/tx.d.ts.map +1 -0
  79. package/dest/api/tx.js +1 -0
  80. package/dest/api/utils.d.ts +13 -0
  81. package/dest/api/utils.d.ts.map +1 -0
  82. package/dest/api/utils.js +12 -0
  83. package/dest/api/wallet.d.ts +4 -1
  84. package/dest/api/wallet.d.ts.map +1 -1
  85. package/dest/api/wallet.js +4 -1
  86. package/dest/authorization/call_authorization_request.d.ts +67 -0
  87. package/dest/authorization/call_authorization_request.d.ts.map +1 -0
  88. package/dest/authorization/call_authorization_request.js +49 -0
  89. package/dest/contract/base_contract_interaction.d.ts +16 -79
  90. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  91. package/dest/contract/base_contract_interaction.js +15 -128
  92. package/dest/contract/batch_call.d.ts +13 -14
  93. package/dest/contract/batch_call.d.ts.map +1 -1
  94. package/dest/contract/batch_call.js +60 -60
  95. package/dest/contract/checker.d.ts +1 -1
  96. package/dest/contract/checker.d.ts.map +1 -1
  97. package/dest/contract/checker.js +2 -2
  98. package/dest/contract/contract.d.ts +7 -6
  99. package/dest/contract/contract.d.ts.map +1 -1
  100. package/dest/contract/contract.js +7 -16
  101. package/dest/contract/contract_base.d.ts +3 -9
  102. package/dest/contract/contract_base.d.ts.map +1 -1
  103. package/dest/contract/contract_base.js +2 -2
  104. package/dest/contract/contract_function_interaction.d.ts +52 -44
  105. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  106. package/dest/contract/contract_function_interaction.js +75 -74
  107. package/dest/contract/deploy_method.d.ts +102 -57
  108. package/dest/contract/deploy_method.d.ts.map +1 -1
  109. package/dest/contract/deploy_method.js +122 -132
  110. package/dest/contract/deploy_sent_tx.d.ts +3 -5
  111. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  112. package/dest/contract/deploy_sent_tx.js +10 -13
  113. package/dest/contract/get_gas_limits.d.ts +5 -6
  114. package/dest/contract/get_gas_limits.d.ts.map +1 -1
  115. package/dest/contract/get_gas_limits.js +9 -3
  116. package/dest/contract/interaction_options.d.ts +114 -0
  117. package/dest/contract/interaction_options.d.ts.map +1 -0
  118. package/dest/contract/interaction_options.js +52 -0
  119. package/dest/contract/protocol_contracts.d.ts +6 -6
  120. package/dest/contract/protocol_contracts.d.ts.map +1 -1
  121. package/dest/contract/protocol_contracts.js +7 -7
  122. package/dest/contract/sent_tx.d.ts +8 -18
  123. package/dest/contract/sent_tx.d.ts.map +1 -1
  124. package/dest/contract/sent_tx.js +30 -42
  125. package/dest/contract/unsafe_contract.d.ts +1 -1
  126. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  127. package/dest/contract/wait_for_proven.d.ts +17 -0
  128. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  129. package/dest/contract/wait_for_proven.js +17 -0
  130. package/dest/deployment/broadcast_function.d.ts +3 -3
  131. package/dest/deployment/broadcast_function.d.ts.map +1 -1
  132. package/dest/deployment/broadcast_function.js +27 -23
  133. package/dest/deployment/contract_deployer.d.ts +1 -1
  134. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  135. package/dest/deployment/publish_class.d.ts +6 -0
  136. package/dest/deployment/publish_class.d.ts.map +1 -0
  137. package/dest/deployment/publish_class.js +17 -0
  138. package/dest/deployment/publish_instance.d.ts +10 -0
  139. package/dest/deployment/publish_instance.d.ts.map +1 -0
  140. package/dest/deployment/publish_instance.js +11 -0
  141. package/dest/{api/ethereum → ethereum}/portal_manager.d.ts +29 -25
  142. package/dest/ethereum/portal_manager.d.ts.map +1 -0
  143. package/dest/{api/ethereum → ethereum}/portal_manager.js +106 -73
  144. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +16 -11
  145. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  146. package/dest/fee/fee_juice_payment_method_with_claim.js +26 -16
  147. package/dest/fee/fee_payment_method.d.ts +11 -7
  148. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  149. package/dest/fee/private_fee_payment_method.d.ts +25 -8
  150. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  151. package/dest/fee/private_fee_payment_method.js +43 -21
  152. package/dest/fee/public_fee_payment_method.d.ts +26 -9
  153. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  154. package/dest/fee/public_fee_payment_method.js +45 -23
  155. package/dest/fee/sponsored_fee_payment.d.ts +17 -0
  156. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
  157. package/dest/fee/sponsored_fee_payment.js +34 -0
  158. package/dest/utils/abi_types.d.ts +0 -2
  159. package/dest/utils/abi_types.d.ts.map +1 -1
  160. package/dest/utils/authwit.d.ts +81 -24
  161. package/dest/utils/authwit.d.ts.map +1 -1
  162. package/dest/utils/authwit.js +226 -40
  163. package/dest/utils/cross_chain.d.ts +24 -0
  164. package/dest/utils/cross_chain.d.ts.map +1 -0
  165. package/dest/utils/cross_chain.js +30 -0
  166. package/dest/utils/fee_juice.d.ts +3 -2
  167. package/dest/utils/fee_juice.d.ts.map +1 -1
  168. package/dest/utils/fee_juice.js +3 -2
  169. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  170. package/dest/utils/node.d.ts.map +1 -1
  171. package/dest/utils/node.js +1 -1
  172. package/dest/utils/pub_key.d.ts.map +1 -1
  173. package/dest/utils/pub_key.js +1 -2
  174. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +34 -0
  175. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  176. package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
  177. package/dest/wallet/account_manager.d.ts +69 -0
  178. package/dest/wallet/account_manager.d.ts.map +1 -0
  179. package/dest/wallet/account_manager.js +113 -0
  180. package/dest/wallet/base_wallet.d.ts +81 -63
  181. package/dest/wallet/base_wallet.d.ts.map +1 -1
  182. package/dest/wallet/base_wallet.js +221 -106
  183. package/dest/wallet/deploy_account_method.d.ts +52 -0
  184. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  185. package/dest/wallet/deploy_account_method.js +77 -0
  186. package/dest/wallet/index.d.ts +3 -16
  187. package/dest/wallet/index.d.ts.map +1 -1
  188. package/dest/wallet/index.js +3 -20
  189. package/dest/wallet/wallet.d.ts +2478 -0
  190. package/dest/wallet/wallet.d.ts.map +1 -0
  191. package/dest/wallet/wallet.js +202 -0
  192. package/package.json +40 -32
  193. package/src/account/account.ts +97 -0
  194. package/src/account/{contract.ts → account_contract.ts} +24 -13
  195. package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
  196. package/src/account/index.ts +3 -7
  197. package/src/account/interface.ts +1 -12
  198. package/src/account/signerless_account.ts +46 -0
  199. package/src/api/abi.ts +26 -0
  200. package/src/api/account.ts +5 -9
  201. package/src/api/addresses.ts +1 -0
  202. package/src/api/authorization.ts +14 -0
  203. package/src/api/block.ts +2 -0
  204. package/src/{contract/index.ts → api/contract.ts} +37 -13
  205. package/src/api/crypto.ts +1 -0
  206. package/src/api/deployment.ts +4 -3
  207. package/src/api/ethereum.ts +10 -0
  208. package/src/api/events.ts +44 -0
  209. package/src/api/fee.ts +1 -1
  210. package/src/api/fee_testing.ts +1 -0
  211. package/src/api/keys.ts +8 -0
  212. package/src/api/log.ts +1 -0
  213. package/src/api/messaging.ts +2 -0
  214. package/src/api/node.ts +20 -0
  215. package/src/api/note.ts +1 -0
  216. package/src/api/protocol.ts +2 -0
  217. package/src/api/trees.ts +2 -0
  218. package/src/api/tx.ts +11 -0
  219. package/src/api/utils.ts +14 -0
  220. package/src/api/wallet.ts +33 -5
  221. package/src/authorization/call_authorization_request.ts +63 -0
  222. package/src/contract/base_contract_interaction.ts +24 -166
  223. package/src/contract/batch_call.ts +81 -49
  224. package/src/contract/checker.ts +8 -3
  225. package/src/contract/contract.ts +8 -17
  226. package/src/contract/contract_base.ts +4 -11
  227. package/src/contract/contract_function_interaction.ts +136 -106
  228. package/src/contract/deploy_method.ts +199 -129
  229. package/src/contract/deploy_sent_tx.ts +9 -15
  230. package/src/contract/get_gas_limits.ts +15 -8
  231. package/src/contract/interaction_options.ts +169 -0
  232. package/src/contract/protocol_contracts.ts +10 -10
  233. package/src/contract/sent_tx.ts +40 -51
  234. package/src/contract/unsafe_contract.ts +1 -1
  235. package/src/contract/wait_for_proven.ts +38 -0
  236. package/src/deployment/broadcast_function.ts +57 -57
  237. package/src/deployment/contract_deployer.ts +1 -1
  238. package/src/deployment/publish_class.ts +34 -0
  239. package/src/deployment/publish_instance.ts +26 -0
  240. package/src/{api/ethereum → ethereum}/portal_manager.ts +120 -74
  241. package/src/fee/fee_juice_payment_method_with_claim.ts +46 -33
  242. package/src/fee/fee_payment_method.ts +11 -7
  243. package/src/fee/private_fee_payment_method.ts +77 -57
  244. package/src/fee/public_fee_payment_method.ts +91 -67
  245. package/src/fee/sponsored_fee_payment.ts +44 -0
  246. package/src/utils/authwit.ts +255 -53
  247. package/src/utils/cross_chain.ts +53 -0
  248. package/src/utils/fee_juice.ts +4 -4
  249. package/src/utils/node.ts +1 -1
  250. package/src/utils/pub_key.ts +1 -2
  251. package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
  252. package/src/wallet/account_manager.ts +154 -0
  253. package/src/wallet/base_wallet.ts +295 -143
  254. package/src/wallet/deploy_account_method.ts +125 -0
  255. package/src/wallet/index.ts +3 -33
  256. package/src/wallet/wallet.ts +362 -0
  257. package/dest/account/contract.d.ts.map +0 -1
  258. package/dest/account/wallet.d.ts +0 -11
  259. package/dest/account/wallet.d.ts.map +0 -1
  260. package/dest/account/wallet.js +0 -3
  261. package/dest/account_manager/deploy_account_method.d.ts +0 -15
  262. package/dest/account_manager/deploy_account_method.d.ts.map +0 -1
  263. package/dest/account_manager/deploy_account_method.js +0 -43
  264. package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
  265. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
  266. package/dest/account_manager/deploy_account_sent_tx.js +0 -29
  267. package/dest/account_manager/index.d.ts +0 -108
  268. package/dest/account_manager/index.d.ts.map +0 -1
  269. package/dest/account_manager/index.js +0 -159
  270. package/dest/api/cheat_codes.d.ts +0 -26
  271. package/dest/api/cheat_codes.d.ts.map +0 -1
  272. package/dest/api/cheat_codes.js +0 -25
  273. package/dest/api/entrypoint.d.ts +0 -2
  274. package/dest/api/entrypoint.d.ts.map +0 -1
  275. package/dest/api/entrypoint.js +0 -1
  276. package/dest/api/ethereum/anvil_test_watcher.d.ts +0 -32
  277. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +0 -1
  278. package/dest/api/ethereum/anvil_test_watcher.js +0 -133
  279. package/dest/api/ethereum/chain_monitor.d.ts +0 -25
  280. package/dest/api/ethereum/chain_monitor.d.ts.map +0 -1
  281. package/dest/api/ethereum/chain_monitor.js +0 -74
  282. package/dest/api/ethereum/cheat_codes.d.ts +0 -63
  283. package/dest/api/ethereum/cheat_codes.d.ts.map +0 -1
  284. package/dest/api/ethereum/cheat_codes.js +0 -162
  285. package/dest/api/ethereum/index.d.ts +0 -7
  286. package/dest/api/ethereum/index.d.ts.map +0 -1
  287. package/dest/api/ethereum/index.js +0 -6
  288. package/dest/api/ethereum/l1_contracts.d.ts +0 -3
  289. package/dest/api/ethereum/l1_contracts.d.ts.map +0 -1
  290. package/dest/api/ethereum/l1_contracts.js +0 -13
  291. package/dest/api/ethereum/portal_manager.d.ts.map +0 -1
  292. package/dest/api/interfaces/pxe.d.ts +0 -2
  293. package/dest/api/interfaces/pxe.d.ts.map +0 -1
  294. package/dest/api/interfaces/pxe.js +0 -1
  295. package/dest/api/log_id.d.ts +0 -2
  296. package/dest/api/log_id.d.ts.map +0 -1
  297. package/dest/api/log_id.js +0 -1
  298. package/dest/api/tx_hash.d.ts +0 -2
  299. package/dest/api/tx_hash.d.ts.map +0 -1
  300. package/dest/api/tx_hash.js +0 -1
  301. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  302. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  303. package/dest/contract/deploy_proven_tx.js +0 -19
  304. package/dest/contract/index.d.ts.map +0 -1
  305. package/dest/contract/proven_tx.d.ts +0 -17
  306. package/dest/contract/proven_tx.d.ts.map +0 -1
  307. package/dest/contract/proven_tx.js +0 -22
  308. package/dest/deployment/deploy_instance.d.ts +0 -10
  309. package/dest/deployment/deploy_instance.d.ts.map +0 -1
  310. package/dest/deployment/deploy_instance.js +0 -14
  311. package/dest/deployment/index.d.ts +0 -2
  312. package/dest/deployment/index.d.ts.map +0 -1
  313. package/dest/deployment/index.js +0 -1
  314. package/dest/deployment/register_class.d.ts +0 -6
  315. package/dest/deployment/register_class.d.ts.map +0 -1
  316. package/dest/deployment/register_class.js +0 -22
  317. package/dest/entrypoint/default_entrypoint.d.ts +0 -12
  318. package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
  319. package/dest/entrypoint/default_entrypoint.js +0 -28
  320. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +0 -15
  321. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +0 -1
  322. package/dest/entrypoint/default_multi_call_entrypoint.js +0 -130
  323. package/dest/entrypoint/entrypoint.d.ts +0 -35
  324. package/dest/entrypoint/entrypoint.d.ts.map +0 -1
  325. package/dest/entrypoint/entrypoint.js +0 -4
  326. package/dest/entrypoint/payload.d.ts +0 -128
  327. package/dest/entrypoint/payload.d.ts.map +0 -1
  328. package/dest/entrypoint/payload.js +0 -143
  329. package/dest/fee/fee_juice_payment_method.d.ts +0 -14
  330. package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
  331. package/dest/fee/fee_juice_payment_method.js +0 -20
  332. package/dest/index.d.ts +0 -66
  333. package/dest/index.d.ts.map +0 -1
  334. package/dest/index.js +0 -69
  335. package/dest/rpc_clients/index.d.ts +0 -3
  336. package/dest/rpc_clients/index.d.ts.map +0 -1
  337. package/dest/rpc_clients/index.js +0 -2
  338. package/dest/rpc_clients/node/index.d.ts +0 -12
  339. package/dest/rpc_clients/node/index.d.ts.map +0 -1
  340. package/dest/rpc_clients/node/index.js +0 -78
  341. package/dest/rpc_clients/pxe_client.d.ts +0 -10
  342. package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
  343. package/dest/rpc_clients/pxe_client.js +0 -23
  344. package/dest/utils/aztec_cheatcodes.d.ts +0 -59
  345. package/dest/utils/aztec_cheatcodes.d.ts.map +0 -1
  346. package/dest/utils/aztec_cheatcodes.js +0 -62
  347. package/dest/utils/index.d.ts +0 -8
  348. package/dest/utils/index.d.ts.map +0 -1
  349. package/dest/utils/index.js +0 -6
  350. package/dest/utils/pxe.d.ts +0 -4
  351. package/dest/utils/pxe.d.ts.map +0 -1
  352. package/dest/utils/pxe.js +0 -14
  353. package/dest/wallet/account_wallet.d.ts +0 -76
  354. package/dest/wallet/account_wallet.d.ts.map +0 -1
  355. package/dest/wallet/account_wallet.js +0 -231
  356. package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
  357. package/dest/wallet/signerless_wallet.d.ts +0 -25
  358. package/dest/wallet/signerless_wallet.d.ts.map +0 -1
  359. package/dest/wallet/signerless_wallet.js +0 -36
  360. package/src/account/wallet.ts +0 -13
  361. package/src/account_manager/deploy_account_method.ts +0 -86
  362. package/src/account_manager/deploy_account_sent_tx.ts +0 -42
  363. package/src/account_manager/index.ts +0 -229
  364. package/src/api/cheat_codes.ts +0 -35
  365. package/src/api/entrypoint.ts +0 -1
  366. package/src/api/ethereum/anvil_test_watcher.ts +0 -158
  367. package/src/api/ethereum/chain_monitor.ts +0 -88
  368. package/src/api/ethereum/cheat_codes.ts +0 -184
  369. package/src/api/ethereum/index.ts +0 -19
  370. package/src/api/ethereum/l1_contracts.ts +0 -21
  371. package/src/api/interfaces/pxe.ts +0 -1
  372. package/src/api/log_id.ts +0 -1
  373. package/src/api/tx_hash.ts +0 -1
  374. package/src/contract/deploy_proven_tx.ts +0 -34
  375. package/src/contract/proven_tx.ts +0 -42
  376. package/src/deployment/deploy_instance.ts +0 -31
  377. package/src/deployment/index.ts +0 -1
  378. package/src/deployment/register_class.ts +0 -44
  379. package/src/entrypoint/default_entrypoint.ts +0 -39
  380. package/src/entrypoint/default_multi_call_entrypoint.ts +0 -93
  381. package/src/entrypoint/entrypoint.ts +0 -39
  382. package/src/entrypoint/payload.ts +0 -238
  383. package/src/fee/fee_juice_payment_method.ts +0 -26
  384. package/src/index.ts +0 -106
  385. package/src/rpc_clients/index.ts +0 -2
  386. package/src/rpc_clients/node/index.ts +0 -77
  387. package/src/rpc_clients/pxe_client.ts +0 -25
  388. package/src/utils/aztec_cheatcodes.ts +0 -77
  389. package/src/utils/index.ts +0 -21
  390. package/src/utils/pxe.ts +0 -17
  391. package/src/wallet/account_wallet.ts +0 -242
  392. package/src/wallet/signerless_wallet.ts +0 -52
@@ -1,12 +1,12 @@
1
- import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
1
+ import type { ExtendedViemWalletClient, ViemContract } from '@aztec/ethereum';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import type { Logger } from '@aztec/foundation/log';
5
5
  import type { SiblingPath } from '@aztec/foundation/trees';
6
- import { TokenPortalAbi } from '@aztec/l1-artifacts';
6
+ import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
7
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import type { PXE } from '@aztec/stdlib/interfaces/client';
9
- import { type GetContractReturnType, type Hex } from 'viem';
8
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
9
+ import { type Hex } from 'viem';
10
10
  /** L1 to L2 message info to claim it on L2. */
11
11
  export type L2Claim = {
12
12
  /** Secret for claiming. */
@@ -31,26 +31,33 @@ export declare function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]>;
31
31
  /** Helper for managing an ERC20 on L1. */
32
32
  export declare class L1TokenManager {
33
33
  /** Address of the ERC20 contract. */
34
- readonly address: EthAddress;
35
- private publicClient;
36
- private walletClient;
34
+ readonly tokenAddress: EthAddress;
35
+ /** Address of the handler/faucet contract. */
36
+ readonly handlerAddress: EthAddress | undefined;
37
+ private readonly extendedClient;
37
38
  private logger;
38
39
  private contract;
40
+ private handler;
39
41
  constructor(
40
42
  /** Address of the ERC20 contract. */
41
- address: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
43
+ tokenAddress: EthAddress,
44
+ /** Address of the handler/faucet contract. */
45
+ handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
46
+ /** Returns the amount of tokens available to mint via the handler.
47
+ * @throws if the handler is not provided.
48
+ */
49
+ getMintAmount(): Promise<bigint>;
42
50
  /**
43
51
  * Returns the balance of the given address.
44
52
  * @param address - Address to get the balance of.
45
53
  */
46
54
  getL1TokenBalance(address: Hex): Promise<bigint>;
47
55
  /**
48
- * Mints tokens for the given address. Returns once the tx has been mined.
49
- * @param amount - Amount to mint.
56
+ * Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
50
57
  * @param address - Address to mint the tokens for.
51
58
  * @param addressName - Optional name of the address for logging.
52
59
  */
53
- mint(amount: bigint, address: Hex, addressName?: string): Promise<void>;
60
+ mint(address: Hex, addressName?: string): Promise<void>;
54
61
  /**
55
62
  * Approves tokens for the given address. Returns once the tx has been mined.
56
63
  * @param amount - Amount to approve.
@@ -61,12 +68,11 @@ export declare class L1TokenManager {
61
68
  }
62
69
  /** Helper for interacting with the FeeJuicePortal on L1. */
63
70
  export declare class L1FeeJuicePortalManager {
64
- private readonly publicClient;
65
- private readonly walletClient;
71
+ private readonly extendedClient;
66
72
  private readonly logger;
67
73
  private readonly tokenManager;
68
74
  private readonly contract;
69
- constructor(portalAddress: EthAddress, tokenAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
75
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
70
76
  /** Returns the associated token manager for the L1 ERC20. */
71
77
  getTokenManager(): L1TokenManager;
72
78
  /**
@@ -75,24 +81,22 @@ export declare class L1FeeJuicePortalManager {
75
81
  * @param amount - Amount of tokens to send.
76
82
  * @param mint - Whether to mint the tokens before sending (only during testing).
77
83
  */
78
- bridgeTokensPublic(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaim>;
84
+ bridgeTokensPublic(to: AztecAddress, amount: bigint | undefined, mint?: boolean): Promise<L2AmountClaim>;
79
85
  /**
80
86
  * Creates a new instance
81
- * @param pxe - PXE client used for retrieving the L1 contract addresses.
82
- * @param publicClient - L1 public client.
83
- * @param walletClient - L1 wallet client.
87
+ * @param node - Aztec node client used for retrieving the L1 contract addresses.
88
+ * @param extendedClient - Wallet client, extended with public actions.
84
89
  * @param logger - Logger.
85
90
  */
86
- static new(pxe: PXE, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
91
+ static new(node: AztecNode, extendedClient: ExtendedViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
87
92
  }
88
93
  /** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
89
94
  export declare class L1ToL2TokenPortalManager {
90
- protected publicClient: ViemPublicClient;
91
- protected walletClient: ViemWalletClient;
95
+ protected extendedClient: ExtendedViemWalletClient;
92
96
  protected logger: Logger;
93
- protected readonly portal: GetContractReturnType<typeof TokenPortalAbi, ViemWalletClient>;
97
+ protected readonly portal: ViemContract<typeof TokenPortalAbi>;
94
98
  protected readonly tokenManager: L1TokenManager;
95
- constructor(portalAddress: EthAddress, tokenAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
99
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
96
100
  /** Returns the token manager for the underlying L1 token. */
97
101
  getTokenManager(): L1TokenManager;
98
102
  /**
@@ -114,7 +118,7 @@ export declare class L1ToL2TokenPortalManager {
114
118
  /** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
115
119
  export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
116
120
  private readonly outbox;
117
- constructor(portalAddress: EthAddress, tokenAddress: EthAddress, outboxAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
121
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, outboxAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
118
122
  /**
119
123
  * Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
120
124
  * @param amount - Amount to withdraw.
@@ -131,6 +135,6 @@ export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
131
135
  * @param l2Bridge - Address of the L2 bridge.
132
136
  * @param callerOnL1 - Caller address on L1.
133
137
  */
134
- getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Fr;
138
+ getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Promise<Fr>;
135
139
  }
136
140
  //# sourceMappingURL=portal_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal_manager.d.ts","sourceRoot":"","sources":["../../src/ethereum/portal_manager.ts"],"names":[],"mappings":"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"}
@@ -2,8 +2,13 @@ import { extractEvent } from '@aztec/ethereum/utils';
2
2
  import { sha256ToField } from '@aztec/foundation/crypto';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
- import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';
6
- import { computeSecretHash } from '@aztec/stdlib/hash';
5
+ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
6
+ import { FeeJuicePortalAbi } from '@aztec/l1-artifacts/FeeJuicePortalAbi';
7
+ import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
8
+ import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
9
+ import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
10
+ import { computeL2ToL1MessageHash, computeSecretHash } from '@aztec/stdlib/hash';
11
+ import { getL2ToL1MessageLeafId } from '@aztec/stdlib/messaging';
7
12
  import { getContract, toFunctionSelector } from 'viem';
8
13
  /** Stringifies an eth address for logging. */ function stringifyEthAddress(address, name) {
9
14
  return name ? `${name} (${address.toString()})` : address.toString();
@@ -18,21 +23,37 @@ import { getContract, toFunctionSelector } from 'viem';
18
23
  ];
19
24
  }
20
25
  /** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
21
- address;
22
- publicClient;
23
- walletClient;
26
+ tokenAddress;
27
+ handlerAddress;
28
+ extendedClient;
24
29
  logger;
25
30
  contract;
26
- constructor(/** Address of the ERC20 contract. */ address, publicClient, walletClient, logger){
27
- this.address = address;
28
- this.publicClient = publicClient;
29
- this.walletClient = walletClient;
31
+ handler;
32
+ constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, extendedClient, logger){
33
+ this.tokenAddress = tokenAddress;
34
+ this.handlerAddress = handlerAddress;
35
+ this.extendedClient = extendedClient;
30
36
  this.logger = logger;
31
37
  this.contract = getContract({
32
- address: this.address.toString(),
38
+ address: this.tokenAddress.toString(),
33
39
  abi: TestERC20Abi,
34
- client: this.walletClient
40
+ client: this.extendedClient
35
41
  });
42
+ if (this.handlerAddress) {
43
+ this.handler = getContract({
44
+ address: this.handlerAddress.toString(),
45
+ abi: FeeAssetHandlerAbi,
46
+ client: this.extendedClient
47
+ });
48
+ }
49
+ }
50
+ /** Returns the amount of tokens available to mint via the handler.
51
+ * @throws if the handler is not provided.
52
+ */ async getMintAmount() {
53
+ if (!this.handler) {
54
+ throw new Error('Minting handler was not provided');
55
+ }
56
+ return await this.handler.read.mintAmount();
36
57
  }
37
58
  /**
38
59
  * Returns the balance of the given address.
@@ -43,18 +64,19 @@ import { getContract, toFunctionSelector } from 'viem';
43
64
  ]);
44
65
  }
45
66
  /**
46
- * Mints tokens for the given address. Returns once the tx has been mined.
47
- * @param amount - Amount to mint.
67
+ * Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
48
68
  * @param address - Address to mint the tokens for.
49
69
  * @param addressName - Optional name of the address for logging.
50
- */ async mint(amount, address, addressName) {
51
- this.logger.info(`Minting ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
52
- await this.publicClient.waitForTransactionReceipt({
53
- hash: await this.contract.write.mint([
54
- address,
55
- amount
56
- ])
57
- });
70
+ */ async mint(address, addressName) {
71
+ if (!this.handler) {
72
+ throw new Error('Minting handler was not provided');
73
+ }
74
+ const mintAmount = await this.getMintAmount();
75
+ this.logger.info(`Minting ${mintAmount} tokens for ${stringifyEthAddress(address, addressName)}`);
76
+ // NOTE: the handler mints a fixed amount.
77
+ await this.handler.write.mint([
78
+ address
79
+ ]);
58
80
  }
59
81
  /**
60
82
  * Approves tokens for the given address. Returns once the tx has been mined.
@@ -63,7 +85,7 @@ import { getContract, toFunctionSelector } from 'viem';
63
85
  * @param addressName - Optional name of the address for logging.
64
86
  */ async approve(amount, address, addressName = '') {
65
87
  this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
66
- await this.publicClient.waitForTransactionReceipt({
88
+ await this.extendedClient.waitForTransactionReceipt({
67
89
  hash: await this.contract.write.approve([
68
90
  address,
69
91
  amount
@@ -72,20 +94,18 @@ import { getContract, toFunctionSelector } from 'viem';
72
94
  }
73
95
  }
74
96
  /** Helper for interacting with the FeeJuicePortal on L1. */ export class L1FeeJuicePortalManager {
75
- publicClient;
76
- walletClient;
97
+ extendedClient;
77
98
  logger;
78
99
  tokenManager;
79
100
  contract;
80
- constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
81
- this.publicClient = publicClient;
82
- this.walletClient = walletClient;
101
+ constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
102
+ this.extendedClient = extendedClient;
83
103
  this.logger = logger;
84
- this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
104
+ this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
85
105
  this.contract = getContract({
86
106
  address: portalAddress.toString(),
87
107
  abi: FeeJuicePortalAbi,
88
- client: this.walletClient
108
+ client: extendedClient
89
109
  });
90
110
  }
91
111
  /** Returns the associated token manager for the L1 ERC20. */ getTokenManager() {
@@ -98,24 +118,29 @@ import { getContract, toFunctionSelector } from 'viem';
98
118
  * @param mint - Whether to mint the tokens before sending (only during testing).
99
119
  */ async bridgeTokensPublic(to, amount, mint = false) {
100
120
  const [claimSecret, claimSecretHash] = await generateClaimSecret();
121
+ const mintableAmount = await this.tokenManager.getMintAmount();
122
+ const amountToBridge = amount ?? mintableAmount;
101
123
  if (mint) {
102
- await this.tokenManager.mint(amount, this.walletClient.account.address);
124
+ if (amountToBridge !== mintableAmount) {
125
+ throw new Error(`Minting amount must be ${mintableAmount}`);
126
+ }
127
+ await this.tokenManager.mint(this.extendedClient.account.address);
103
128
  }
104
- await this.tokenManager.approve(amount, this.contract.address, 'FeeJuice Portal');
129
+ await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
105
130
  this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
106
131
  const args = [
107
132
  to.toString(),
108
- amount,
133
+ amountToBridge,
109
134
  claimSecretHash.toString()
110
135
  ];
111
136
  await this.contract.simulate.depositToAztecPublic(args);
112
- const txReceipt = await this.publicClient.waitForTransactionReceipt({
137
+ const txReceipt = await this.extendedClient.waitForTransactionReceipt({
113
138
  hash: await this.contract.write.depositToAztecPublic(args)
114
139
  });
115
140
  this.logger.info('Deposited to Aztec public successfully');
116
- const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amount && log.args.to === to.toString(), this.logger);
141
+ const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amountToBridge && log.args.to === to.toString(), this.logger);
117
142
  return {
118
- claimAmount: amount,
143
+ claimAmount: amountToBridge,
119
144
  claimSecret,
120
145
  claimSecretHash,
121
146
  messageHash: log.args.key,
@@ -124,33 +149,33 @@ import { getContract, toFunctionSelector } from 'viem';
124
149
  }
125
150
  /**
126
151
  * Creates a new instance
127
- * @param pxe - PXE client used for retrieving the L1 contract addresses.
128
- * @param publicClient - L1 public client.
129
- * @param walletClient - L1 wallet client.
152
+ * @param node - Aztec node client used for retrieving the L1 contract addresses.
153
+ * @param extendedClient - Wallet client, extended with public actions.
130
154
  * @param logger - Logger.
131
- */ static async new(pxe, publicClient, walletClient, logger) {
132
- const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress } } = await pxe.getNodeInfo();
155
+ */ static async new(node, extendedClient, logger) {
156
+ const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await node.getNodeInfo();
133
157
  if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
134
158
  throw new Error('Portal or token not deployed on L1');
135
159
  }
136
- return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, publicClient, walletClient, logger);
160
+ if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
161
+ throw new Error('Handler not deployed on L1, or handler address is zero');
162
+ }
163
+ return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress, extendedClient, logger);
137
164
  }
138
165
  }
139
166
  /** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
140
- publicClient;
141
- walletClient;
167
+ extendedClient;
142
168
  logger;
143
169
  portal;
144
170
  tokenManager;
145
- constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
146
- this.publicClient = publicClient;
147
- this.walletClient = walletClient;
171
+ constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
172
+ this.extendedClient = extendedClient;
148
173
  this.logger = logger;
149
- this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
174
+ this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
150
175
  this.portal = getContract({
151
176
  address: portalAddress.toString(),
152
177
  abi: TokenPortalAbi,
153
- client: this.walletClient
178
+ client: extendedClient
154
179
  });
155
180
  }
156
181
  /** Returns the token manager for the underlying L1 token. */ getTokenManager() {
@@ -169,8 +194,8 @@ import { getContract, toFunctionSelector } from 'viem';
169
194
  amount,
170
195
  claimSecretHash.toString()
171
196
  ]);
172
- const txReceipt = await this.publicClient.waitForTransactionReceipt({
173
- hash: await this.walletClient.writeContract(request)
197
+ const txReceipt = await this.extendedClient.waitForTransactionReceipt({
198
+ hash: await this.extendedClient.writeContract(request)
174
199
  });
175
200
  const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amount && log.args.to === to.toString(), this.logger);
176
201
  return {
@@ -193,8 +218,8 @@ import { getContract, toFunctionSelector } from 'viem';
193
218
  amount,
194
219
  claimSecretHash.toString()
195
220
  ]);
196
- const txReceipt = await this.publicClient.waitForTransactionReceipt({
197
- hash: await this.walletClient.writeContract(request)
221
+ const txReceipt = await this.extendedClient.waitForTransactionReceipt({
222
+ hash: await this.extendedClient.writeContract(request)
198
223
  });
199
224
  const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>log.args.amount === amount && log.args.secretHashForL2MessageConsumption === claimSecretHash.toString(), this.logger);
200
225
  this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
@@ -209,7 +234,11 @@ import { getContract, toFunctionSelector } from 'viem';
209
234
  }
210
235
  async bridgeSetup(amount, mint) {
211
236
  if (mint) {
212
- await this.tokenManager.mint(amount, this.walletClient.account.address);
237
+ const mintableAmount = await this.tokenManager.getMintAmount();
238
+ if (amount !== mintableAmount) {
239
+ throw new Error(`Minting amount must be ${mintableAmount} for testing`);
240
+ }
241
+ await this.tokenManager.mint(this.extendedClient.account.address);
213
242
  }
214
243
  await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
215
244
  return generateClaimSecret();
@@ -217,12 +246,12 @@ import { getContract, toFunctionSelector } from 'viem';
217
246
  }
218
247
  /** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
219
248
  outbox;
220
- constructor(portalAddress, tokenAddress, outboxAddress, publicClient, walletClient, logger){
221
- super(portalAddress, tokenAddress, publicClient, walletClient, logger);
249
+ constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, extendedClient, logger){
250
+ super(portalAddress, tokenAddress, handlerAddress, extendedClient, logger);
222
251
  this.outbox = getContract({
223
252
  address: outboxAddress.toString(),
224
253
  abi: OutboxAbi,
225
- client: walletClient
254
+ client: extendedClient
226
255
  });
227
256
  }
228
257
  /**
@@ -234,12 +263,16 @@ import { getContract, toFunctionSelector } from 'viem';
234
263
  * @param siblingPath - Sibling path of the message.
235
264
  */ async withdrawFunds(amount, recipient, blockNumber, messageIndex, siblingPath) {
236
265
  this.logger.info(`Sending L1 tx to consume message at block ${blockNumber} index ${messageIndex} to withdraw ${amount}`);
237
- const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtBlockAndIndex([
266
+ const messageLeafId = getL2ToL1MessageLeafId({
267
+ leafIndex: messageIndex,
268
+ siblingPath
269
+ });
270
+ const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtBlock([
238
271
  blockNumber,
239
- messageIndex
272
+ messageLeafId
240
273
  ]);
241
274
  if (isConsumedBefore) {
242
- throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} has already been consumed`);
275
+ throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} has already been consumed`);
243
276
  }
244
277
  // Call function on L1 contract to consume the message
245
278
  const { request: withdrawRequest } = await this.portal.simulate.withdraw([
@@ -250,15 +283,15 @@ import { getContract, toFunctionSelector } from 'viem';
250
283
  messageIndex,
251
284
  siblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
252
285
  ]);
253
- await this.publicClient.waitForTransactionReceipt({
254
- hash: await this.walletClient.writeContract(withdrawRequest)
286
+ await this.extendedClient.waitForTransactionReceipt({
287
+ hash: await this.extendedClient.writeContract(withdrawRequest)
255
288
  });
256
- const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlockAndIndex([
289
+ const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlock([
257
290
  blockNumber,
258
- messageIndex
291
+ messageLeafId
259
292
  ]);
260
293
  if (!isConsumedAfter) {
261
- throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} not consumed after withdrawal`);
294
+ throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} not consumed after withdrawal`);
262
295
  }
263
296
  }
264
297
  /**
@@ -267,20 +300,20 @@ import { getContract, toFunctionSelector } from 'viem';
267
300
  * @param recipient - Recipient on L1.
268
301
  * @param l2Bridge - Address of the L2 bridge.
269
302
  * @param callerOnL1 - Caller address on L1.
270
- */ getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
303
+ */ async getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
304
+ const version = await this.outbox.read.VERSION();
271
305
  const content = sha256ToField([
272
306
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
273
307
  recipient.toBuffer32(),
274
308
  new Fr(amount).toBuffer(),
275
309
  callerOnL1.toBuffer32()
276
310
  ]);
277
- const leaf = sha256ToField([
278
- l2Bridge.toBuffer(),
279
- new Fr(1).toBuffer(),
280
- EthAddress.fromString(this.portal.address).toBuffer32() ?? Buffer.alloc(32, 0),
281
- new Fr(this.publicClient.chain.id).toBuffer(),
282
- content.toBuffer()
283
- ]);
284
- return leaf;
311
+ return computeL2ToL1MessageHash({
312
+ l2Sender: l2Bridge,
313
+ l1Recipient: EthAddress.fromString(this.portal.address),
314
+ content,
315
+ rollupVersion: new Fr(version),
316
+ chainId: new Fr(this.extendedClient.chain.id)
317
+ });
285
318
  }
286
319
  }
@@ -1,18 +1,23 @@
1
- import type { FunctionCall } from '@aztec/stdlib/abi';
2
- import type { L2AmountClaim } from '../api/ethereum/portal_manager.js';
3
- import type { Wallet } from '../wallet/index.js';
4
- import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { GasSettings } from '@aztec/stdlib/gas';
4
+ import type { L2AmountClaim } from '../ethereum/portal_manager.js';
5
+ import type { FeePaymentMethod } from './fee_payment_method.js';
5
6
  /**
6
- * Pay fee directly with Fee Juice claimed on the same tx.
7
+ * Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
8
+ * the fee juice bridged from L1.
7
9
  */
8
- export declare class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
9
- private senderWallet;
10
+ export declare class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
11
+ private sender;
10
12
  private claim;
11
- constructor(senderWallet: Wallet, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
13
+ constructor(sender: AztecAddress, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
12
14
  /**
13
- * Creates a function call to pay the fee in Fee Juice.
14
- * @returns A function call
15
+ * Creates an execution payload to pay the fee in Fee Juice.
16
+ * @returns An execution payload that just contains the `claim_and_end_setup` function call.
15
17
  */
16
- getFunctionCalls(): Promise<FunctionCall[]>;
18
+ getExecutionPayload(): Promise<ExecutionPayload>;
19
+ getAsset(): Promise<AztecAddress>;
20
+ getFeePayer(): Promise<AztecAddress>;
21
+ getGasSettings(): GasSettings | undefined;
17
22
  }
18
23
  //# sourceMappingURL=fee_juice_payment_method_with_claim.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IAErE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;gBADL,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAKxF;;;OAGG;IACY,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAuB3D"}
1
+ {"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,gBAAgB;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;gBADL,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAGxF;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0BtD,QAAQ;IAIR,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC,cAAc,IAAI,WAAW,GAAG,SAAS;CAG1C"}
@@ -1,30 +1,31 @@
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
4
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
4
- import { getFeeJuice } from '../contract/protocol_contracts.js';
5
- import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
6
5
  /**
7
- * Pay fee directly with Fee Juice claimed on the same tx.
8
- */ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
9
- senderWallet;
6
+ * Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
7
+ * the fee juice bridged from L1.
8
+ */ export class FeeJuicePaymentMethodWithClaim {
9
+ sender;
10
10
  claim;
11
- constructor(senderWallet, claim){
12
- super(senderWallet.getAddress()), this.senderWallet = senderWallet, this.claim = claim;
11
+ constructor(sender, claim){
12
+ this.sender = sender;
13
+ this.claim = claim;
13
14
  }
14
15
  /**
15
- * Creates a function call to pay the fee in Fee Juice.
16
- * @returns A function call
17
- */ async getFunctionCalls() {
18
- const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
19
- const selector = await FunctionSelector.fromNameAndParameters(canonicalFeeJuice.artifact.functions.find((f)=>f.name === 'claim'));
20
- return Promise.resolve([
16
+ * Creates an execution payload to pay the fee in Fee Juice.
17
+ * @returns An execution payload that just contains the `claim_and_end_setup` function call.
18
+ */ async getExecutionPayload() {
19
+ const selector = await FunctionSelector.fromSignature('claim_and_end_setup((Field),u128,Field,Field)');
20
+ return new ExecutionPayload([
21
21
  {
22
22
  to: ProtocolContractAddress.FeeJuice,
23
- name: 'claim',
23
+ name: 'claim_and_end_setup',
24
24
  selector,
25
+ hideMsgSender: false,
25
26
  isStatic: false,
26
27
  args: [
27
- this.senderWallet.getAddress().toField(),
28
+ this.sender.toField(),
28
29
  new Fr(this.claim.claimAmount),
29
30
  this.claim.claimSecret,
30
31
  new Fr(this.claim.messageLeafIndex)
@@ -32,6 +33,15 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
32
33
  returnTypes: [],
33
34
  type: FunctionType.PRIVATE
34
35
  }
35
- ]);
36
+ ], [], []);
37
+ }
38
+ getAsset() {
39
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
40
+ }
41
+ getFeePayer() {
42
+ return Promise.resolve(this.sender);
43
+ }
44
+ getGasSettings() {
45
+ return;
36
46
  }
37
47
  }
@@ -1,4 +1,4 @@
1
- import type { FunctionCall } from '@aztec/stdlib/abi';
1
+ import type { ExecutionPayload } from '@aztec/entrypoints/payload';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import type { GasSettings } from '@aztec/stdlib/gas';
4
4
  /**
@@ -8,15 +8,19 @@ export interface FeePaymentMethod {
8
8
  /** The asset used to pay the fee. */
9
9
  getAsset(): Promise<AztecAddress>;
10
10
  /**
11
- * Creates a function call to pay the fee in the given asset.
12
- * @param gasSettings - The gas limits and max fees.
13
- * @returns The function call to pay the fee.
11
+ * Returns the data to be added to the final execution request
12
+ * to pay the fee in the given asset
13
+ * @returns The function calls to pay the fee.
14
14
  */
15
- getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
15
+ getExecutionPayload(): Promise<ExecutionPayload>;
16
16
  /**
17
17
  * The expected fee payer for this tx.
18
- * @param gasSettings - The gas limits and max fees.
19
18
  */
20
- getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
19
+ getFeePayer(): Promise<AztecAddress>;
20
+ /**
21
+ * The gas settings (if any) used to compute the
22
+ * execution payload of the payment method
23
+ */
24
+ getGasSettings(): GasSettings | undefined;
21
25
  }
22
26
  //# sourceMappingURL=fee_payment_method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D"}
1
+ {"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC;;;OAGG;IACH,cAAc,IAAI,WAAW,GAAG,SAAS,CAAC;CAC3C"}