@aztec/aztec.js 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (446) hide show
  1. package/README.md +1 -1
  2. package/dest/account/account.d.ts +44 -0
  3. package/dest/account/account.d.ts.map +1 -0
  4. package/dest/account/account.js +31 -0
  5. package/dest/account/account_contract.d.ts +42 -0
  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/account/account_with_secret_key.d.ts +36 -0
  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} +22 -5
  11. package/dest/account/index.d.ts +6 -9
  12. package/dest/account/index.d.ts.map +1 -1
  13. package/dest/account/index.js +4 -6
  14. package/dest/account/signerless_account.d.ts +22 -0
  15. package/dest/account/signerless_account.d.ts.map +1 -0
  16. package/dest/account/signerless_account.js +24 -0
  17. package/dest/api/abi.d.ts +3 -2
  18. package/dest/api/abi.d.ts.map +1 -1
  19. package/dest/api/abi.js +1 -1
  20. package/dest/api/account.d.ts +5 -3
  21. package/dest/api/account.d.ts.map +1 -1
  22. package/dest/api/account.js +3 -2
  23. package/dest/api/addresses.d.ts +2 -1
  24. package/dest/api/addresses.d.ts.map +1 -1
  25. package/dest/api/addresses.js +1 -0
  26. package/dest/api/authorization.d.ts +5 -0
  27. package/dest/api/authorization.d.ts.map +1 -0
  28. package/dest/api/authorization.js +4 -0
  29. package/dest/api/block.d.ts +3 -0
  30. package/dest/api/block.d.ts.map +1 -0
  31. package/dest/api/block.js +2 -0
  32. package/dest/api/contract.d.ts +55 -0
  33. package/dest/api/contract.d.ts.map +1 -0
  34. package/dest/api/contract.js +53 -0
  35. package/dest/api/crypto.d.ts +2 -0
  36. package/dest/api/crypto.d.ts.map +1 -0
  37. package/dest/api/crypto.js +1 -0
  38. package/dest/api/deployment.d.ts +5 -4
  39. package/dest/api/deployment.d.ts.map +1 -1
  40. package/dest/api/deployment.js +4 -3
  41. package/dest/api/eth_address.d.ts +1 -1
  42. package/dest/api/ethereum.d.ts +2 -0
  43. package/dest/api/ethereum.d.ts.map +1 -0
  44. package/dest/api/ethereum.js +1 -0
  45. package/dest/api/events.d.ts +12 -0
  46. package/dest/api/events.d.ts.map +1 -0
  47. package/dest/api/events.js +30 -0
  48. package/dest/api/fee.d.ts +2 -2
  49. package/dest/api/fee.d.ts.map +1 -1
  50. package/dest/api/fee.js +1 -1
  51. package/dest/api/fee_testing.d.ts +2 -0
  52. package/dest/api/fee_testing.d.ts.map +1 -0
  53. package/dest/api/fee_testing.js +1 -0
  54. package/dest/api/fields.d.ts +3 -2
  55. package/dest/api/fields.d.ts.map +1 -1
  56. package/dest/api/fields.js +2 -1
  57. package/dest/api/keys.d.ts +4 -0
  58. package/dest/api/keys.d.ts.map +1 -0
  59. package/dest/api/keys.js +3 -0
  60. package/dest/api/log.d.ts +2 -1
  61. package/dest/api/log.d.ts.map +1 -1
  62. package/dest/api/log.js +1 -0
  63. package/dest/api/messaging.d.ts +3 -0
  64. package/dest/api/messaging.d.ts.map +1 -0
  65. package/dest/api/messaging.js +2 -0
  66. package/dest/api/node.d.ts +25 -0
  67. package/dest/api/node.d.ts.map +1 -0
  68. package/dest/api/node.js +22 -0
  69. package/dest/api/note.d.ts +2 -0
  70. package/dest/api/note.d.ts.map +1 -0
  71. package/dest/api/note.js +1 -0
  72. package/dest/api/protocol.d.ts +9 -0
  73. package/dest/api/protocol.d.ts.map +1 -0
  74. package/dest/api/protocol.js +8 -0
  75. package/dest/api/trees.d.ts +3 -0
  76. package/dest/api/trees.d.ts.map +1 -0
  77. package/dest/api/trees.js +2 -0
  78. package/dest/api/tx.d.ts +2 -0
  79. package/dest/api/tx.d.ts.map +1 -0
  80. package/dest/api/tx.js +1 -0
  81. package/dest/api/utils.d.ts +13 -0
  82. package/dest/api/utils.d.ts.map +1 -0
  83. package/dest/api/utils.js +12 -0
  84. package/dest/api/wallet.d.ts +4 -2
  85. package/dest/api/wallet.d.ts.map +1 -1
  86. package/dest/api/wallet.js +3 -1
  87. package/dest/authorization/call_authorization_request.d.ts +67 -0
  88. package/dest/authorization/call_authorization_request.d.ts.map +1 -0
  89. package/dest/authorization/call_authorization_request.js +49 -0
  90. package/dest/contract/base_contract_interaction.d.ts +18 -84
  91. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  92. package/dest/contract/base_contract_interaction.js +11 -136
  93. package/dest/contract/batch_call.d.ts +19 -21
  94. package/dest/contract/batch_call.d.ts.map +1 -1
  95. package/dest/contract/batch_call.js +89 -69
  96. package/dest/contract/checker.d.ts +2 -2
  97. package/dest/contract/checker.d.ts.map +1 -1
  98. package/dest/contract/checker.js +2 -2
  99. package/dest/contract/contract.d.ts +9 -8
  100. package/dest/contract/contract.d.ts.map +1 -1
  101. package/dest/contract/contract.js +10 -20
  102. package/dest/contract/contract_base.d.ts +8 -18
  103. package/dest/contract/contract_base.d.ts.map +1 -1
  104. package/dest/contract/contract_base.js +7 -14
  105. package/dest/contract/contract_function_interaction.d.ts +53 -45
  106. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  107. package/dest/contract/contract_function_interaction.js +78 -74
  108. package/dest/contract/deploy_method.d.ts +155 -62
  109. package/dest/contract/deploy_method.d.ts.map +1 -1
  110. package/dest/contract/deploy_method.js +152 -142
  111. package/dest/contract/get_gas_limits.d.ts +6 -7
  112. package/dest/contract/get_gas_limits.d.ts.map +1 -1
  113. package/dest/contract/get_gas_limits.js +9 -3
  114. package/dest/contract/interaction_options.d.ts +151 -0
  115. package/dest/contract/interaction_options.d.ts.map +1 -0
  116. package/dest/contract/interaction_options.js +53 -0
  117. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  118. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  119. package/dest/contract/protocol_contracts/auth-registry.js +963 -0
  120. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
  121. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  122. package/dest/contract/protocol_contracts/contract-class-registry.js +784 -0
  123. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
  124. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  125. package/dest/contract/protocol_contracts/contract-instance-registry.js +858 -0
  126. package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
  127. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  128. package/dest/contract/protocol_contracts/fee-juice.js +827 -0
  129. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  130. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  131. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +563 -0
  132. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  133. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  134. package/dest/contract/protocol_contracts/public-checks.js +579 -0
  135. package/dest/contract/wait_for_proven.d.ts +17 -0
  136. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  137. package/dest/contract/wait_for_proven.js +17 -0
  138. package/dest/contract/wait_opts.d.ts +16 -0
  139. package/dest/contract/wait_opts.d.ts.map +1 -0
  140. package/dest/contract/wait_opts.js +5 -0
  141. package/dest/deployment/broadcast_function.d.ts +4 -4
  142. package/dest/deployment/broadcast_function.d.ts.map +1 -1
  143. package/dest/deployment/broadcast_function.js +28 -24
  144. package/dest/deployment/contract_deployer.d.ts +2 -2
  145. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  146. package/dest/deployment/contract_deployer.js +1 -1
  147. package/dest/deployment/publish_class.d.ts +6 -0
  148. package/dest/deployment/publish_class.d.ts.map +1 -0
  149. package/dest/deployment/publish_class.js +17 -0
  150. package/dest/deployment/publish_instance.d.ts +10 -0
  151. package/dest/deployment/publish_instance.d.ts.map +1 -0
  152. package/dest/deployment/publish_instance.js +11 -0
  153. package/dest/ethereum/portal_manager.d.ts +141 -0
  154. package/dest/ethereum/portal_manager.d.ts.map +1 -0
  155. package/dest/ethereum/portal_manager.js +345 -0
  156. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +17 -12
  157. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  158. package/dest/fee/fee_juice_payment_method_with_claim.js +27 -17
  159. package/dest/fee/fee_payment_method.d.ts +12 -8
  160. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  161. package/dest/fee/private_fee_payment_method.d.ts +26 -9
  162. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  163. package/dest/fee/private_fee_payment_method.js +45 -23
  164. package/dest/fee/public_fee_payment_method.d.ts +27 -10
  165. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  166. package/dest/fee/public_fee_payment_method.js +47 -25
  167. package/dest/fee/sponsored_fee_payment.d.ts +17 -0
  168. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
  169. package/dest/fee/sponsored_fee_payment.js +34 -0
  170. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  171. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  172. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  173. package/dest/utils/abi_types.d.ts +2 -4
  174. package/dest/utils/abi_types.d.ts.map +1 -1
  175. package/dest/utils/authwit.d.ts +85 -26
  176. package/dest/utils/authwit.d.ts.map +1 -1
  177. package/dest/utils/authwit.js +234 -41
  178. package/dest/utils/cross_chain.d.ts +24 -0
  179. package/dest/utils/cross_chain.d.ts.map +1 -0
  180. package/dest/utils/cross_chain.js +30 -0
  181. package/dest/utils/fee_juice.d.ts +4 -3
  182. package/dest/utils/fee_juice.d.ts.map +1 -1
  183. package/dest/utils/fee_juice.js +4 -3
  184. package/dest/utils/field_compressed_string.d.ts +1 -1
  185. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  186. package/dest/utils/field_compressed_string.js +1 -1
  187. package/dest/utils/node.d.ts +13 -2
  188. package/dest/utils/node.d.ts.map +1 -1
  189. package/dest/utils/node.js +47 -1
  190. package/dest/utils/pub_key.d.ts +2 -2
  191. package/dest/utils/pub_key.d.ts.map +1 -1
  192. package/dest/utils/pub_key.js +2 -3
  193. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +31 -0
  194. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  195. package/dest/wallet/account_entrypoint_meta_payment_method.js +61 -0
  196. package/dest/wallet/account_manager.d.ts +63 -0
  197. package/dest/wallet/account_manager.d.ts.map +1 -0
  198. package/dest/wallet/account_manager.js +107 -0
  199. package/dest/wallet/deploy_account_method.d.ts +80 -0
  200. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  201. package/dest/wallet/deploy_account_method.js +79 -0
  202. package/dest/wallet/index.d.ts +3 -17
  203. package/dest/wallet/index.d.ts.map +1 -1
  204. package/dest/wallet/index.js +2 -20
  205. package/dest/wallet/wallet.d.ts +1297 -0
  206. package/dest/wallet/wallet.d.ts.map +1 -0
  207. package/dest/wallet/wallet.js +172 -0
  208. package/package.json +47 -36
  209. package/src/account/account.ts +72 -0
  210. package/src/account/account_contract.ts +66 -0
  211. package/src/account/account_with_secret_key.ts +63 -0
  212. package/src/account/index.ts +5 -8
  213. package/src/account/signerless_account.ts +46 -0
  214. package/src/api/abi.ts +26 -0
  215. package/src/api/account.ts +8 -5
  216. package/src/api/addresses.ts +1 -0
  217. package/src/api/authorization.ts +15 -0
  218. package/src/api/block.ts +2 -0
  219. package/src/api/contract.ts +88 -0
  220. package/src/api/crypto.ts +1 -0
  221. package/src/api/deployment.ts +4 -3
  222. package/src/api/ethereum.ts +10 -0
  223. package/src/api/events.ts +44 -0
  224. package/src/api/fee.ts +1 -1
  225. package/src/api/fee_testing.ts +1 -0
  226. package/src/api/fields.ts +2 -1
  227. package/src/api/keys.ts +8 -0
  228. package/src/api/log.ts +1 -0
  229. package/src/api/messaging.ts +2 -0
  230. package/src/api/node.ts +24 -0
  231. package/src/api/note.ts +1 -0
  232. package/src/api/protocol.ts +9 -0
  233. package/src/api/trees.ts +2 -0
  234. package/src/api/tx.ts +15 -0
  235. package/src/api/utils.ts +14 -0
  236. package/src/api/wallet.ts +34 -5
  237. package/src/authorization/call_authorization_request.ts +63 -0
  238. package/src/contract/base_contract_interaction.ts +40 -171
  239. package/src/contract/batch_call.ts +108 -57
  240. package/src/contract/checker.ts +8 -3
  241. package/src/contract/contract.ts +14 -21
  242. package/src/contract/contract_base.ts +9 -26
  243. package/src/contract/contract_function_interaction.ts +135 -106
  244. package/src/contract/deploy_method.ts +307 -143
  245. package/src/contract/get_gas_limits.ts +15 -8
  246. package/src/contract/interaction_options.ts +208 -0
  247. package/src/contract/protocol_contracts/auth-registry.ts +545 -0
  248. package/src/contract/protocol_contracts/contract-class-registry.ts +433 -0
  249. package/src/contract/protocol_contracts/contract-instance-registry.ts +493 -0
  250. package/src/contract/protocol_contracts/fee-juice.ts +457 -0
  251. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +329 -0
  252. package/src/contract/protocol_contracts/public-checks.ts +315 -0
  253. package/src/contract/wait_for_proven.ts +38 -0
  254. package/src/contract/wait_opts.ts +21 -0
  255. package/src/deployment/broadcast_function.ts +58 -58
  256. package/src/deployment/contract_deployer.ts +4 -3
  257. package/src/deployment/publish_class.ts +34 -0
  258. package/src/deployment/publish_instance.ts +23 -0
  259. package/src/{api/ethereum → ethereum}/portal_manager.ts +166 -89
  260. package/src/fee/fee_juice_payment_method_with_claim.ts +49 -34
  261. package/src/fee/fee_payment_method.ts +11 -7
  262. package/src/fee/private_fee_payment_method.ts +80 -58
  263. package/src/fee/public_fee_payment_method.ts +94 -68
  264. package/src/fee/sponsored_fee_payment.ts +46 -0
  265. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  266. package/src/utils/abi_types.ts +1 -1
  267. package/src/utils/authwit.ts +274 -54
  268. package/src/utils/cross_chain.ts +53 -0
  269. package/src/utils/fee_juice.ts +5 -5
  270. package/src/utils/field_compressed_string.ts +1 -1
  271. package/src/utils/node.ts +63 -1
  272. package/src/utils/pub_key.ts +3 -4
  273. package/src/wallet/account_entrypoint_meta_payment_method.ts +74 -0
  274. package/src/wallet/account_manager.ts +146 -0
  275. package/src/wallet/deploy_account_method.ts +150 -0
  276. package/src/wallet/index.ts +2 -33
  277. package/src/wallet/wallet.ts +417 -0
  278. package/dest/account/contract.d.ts +0 -37
  279. package/dest/account/contract.d.ts.map +0 -1
  280. package/dest/account/interface.d.ts +0 -31
  281. package/dest/account/interface.d.ts.map +0 -1
  282. package/dest/account/interface.js +0 -4
  283. package/dest/account/wallet.d.ts +0 -11
  284. package/dest/account/wallet.d.ts.map +0 -1
  285. package/dest/account/wallet.js +0 -3
  286. package/dest/account_manager/deploy_account_method.d.ts +0 -15
  287. package/dest/account_manager/deploy_account_method.d.ts.map +0 -1
  288. package/dest/account_manager/deploy_account_method.js +0 -43
  289. package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
  290. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
  291. package/dest/account_manager/deploy_account_sent_tx.js +0 -29
  292. package/dest/account_manager/index.d.ts +0 -108
  293. package/dest/account_manager/index.d.ts.map +0 -1
  294. package/dest/account_manager/index.js +0 -159
  295. package/dest/api/cheat_codes.d.ts +0 -26
  296. package/dest/api/cheat_codes.d.ts.map +0 -1
  297. package/dest/api/cheat_codes.js +0 -25
  298. package/dest/api/entrypoint.d.ts +0 -2
  299. package/dest/api/entrypoint.d.ts.map +0 -1
  300. package/dest/api/entrypoint.js +0 -1
  301. package/dest/api/ethereum/anvil_test_watcher.d.ts +0 -32
  302. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +0 -1
  303. package/dest/api/ethereum/anvil_test_watcher.js +0 -133
  304. package/dest/api/ethereum/chain_monitor.d.ts +0 -25
  305. package/dest/api/ethereum/chain_monitor.d.ts.map +0 -1
  306. package/dest/api/ethereum/chain_monitor.js +0 -74
  307. package/dest/api/ethereum/cheat_codes.d.ts +0 -63
  308. package/dest/api/ethereum/cheat_codes.d.ts.map +0 -1
  309. package/dest/api/ethereum/cheat_codes.js +0 -162
  310. package/dest/api/ethereum/index.d.ts +0 -7
  311. package/dest/api/ethereum/index.d.ts.map +0 -1
  312. package/dest/api/ethereum/index.js +0 -6
  313. package/dest/api/ethereum/l1_contracts.d.ts +0 -3
  314. package/dest/api/ethereum/l1_contracts.d.ts.map +0 -1
  315. package/dest/api/ethereum/l1_contracts.js +0 -13
  316. package/dest/api/ethereum/portal_manager.d.ts +0 -136
  317. package/dest/api/ethereum/portal_manager.d.ts.map +0 -1
  318. package/dest/api/ethereum/portal_manager.js +0 -286
  319. package/dest/api/interfaces/pxe.d.ts +0 -2
  320. package/dest/api/interfaces/pxe.d.ts.map +0 -1
  321. package/dest/api/interfaces/pxe.js +0 -1
  322. package/dest/api/log_id.d.ts +0 -2
  323. package/dest/api/log_id.d.ts.map +0 -1
  324. package/dest/api/log_id.js +0 -1
  325. package/dest/api/tx_hash.d.ts +0 -2
  326. package/dest/api/tx_hash.d.ts.map +0 -1
  327. package/dest/api/tx_hash.js +0 -1
  328. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  329. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  330. package/dest/contract/deploy_proven_tx.js +0 -19
  331. package/dest/contract/deploy_sent_tx.d.ts +0 -45
  332. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  333. package/dest/contract/deploy_sent_tx.js +0 -43
  334. package/dest/contract/index.d.ts +0 -45
  335. package/dest/contract/index.d.ts.map +0 -1
  336. package/dest/contract/index.js +0 -43
  337. package/dest/contract/protocol_contracts.d.ts +0 -9
  338. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  339. package/dest/contract/protocol_contracts.js +0 -26
  340. package/dest/contract/proven_tx.d.ts +0 -17
  341. package/dest/contract/proven_tx.d.ts.map +0 -1
  342. package/dest/contract/proven_tx.js +0 -22
  343. package/dest/contract/sent_tx.d.ts +0 -61
  344. package/dest/contract/sent_tx.d.ts.map +0 -1
  345. package/dest/contract/sent_tx.js +0 -102
  346. package/dest/contract/unsafe_contract.d.ts +0 -15
  347. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  348. package/dest/contract/unsafe_contract.js +0 -6
  349. package/dest/deployment/deploy_instance.d.ts +0 -10
  350. package/dest/deployment/deploy_instance.d.ts.map +0 -1
  351. package/dest/deployment/deploy_instance.js +0 -14
  352. package/dest/deployment/index.d.ts +0 -2
  353. package/dest/deployment/index.d.ts.map +0 -1
  354. package/dest/deployment/index.js +0 -1
  355. package/dest/deployment/register_class.d.ts +0 -6
  356. package/dest/deployment/register_class.d.ts.map +0 -1
  357. package/dest/deployment/register_class.js +0 -22
  358. package/dest/entrypoint/default_entrypoint.d.ts +0 -12
  359. package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
  360. package/dest/entrypoint/default_entrypoint.js +0 -28
  361. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +0 -15
  362. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +0 -1
  363. package/dest/entrypoint/default_multi_call_entrypoint.js +0 -130
  364. package/dest/entrypoint/entrypoint.d.ts +0 -35
  365. package/dest/entrypoint/entrypoint.d.ts.map +0 -1
  366. package/dest/entrypoint/entrypoint.js +0 -4
  367. package/dest/entrypoint/payload.d.ts +0 -128
  368. package/dest/entrypoint/payload.d.ts.map +0 -1
  369. package/dest/entrypoint/payload.js +0 -143
  370. package/dest/fee/fee_juice_payment_method.d.ts +0 -14
  371. package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
  372. package/dest/fee/fee_juice_payment_method.js +0 -20
  373. package/dest/index.d.ts +0 -66
  374. package/dest/index.d.ts.map +0 -1
  375. package/dest/index.js +0 -69
  376. package/dest/rpc_clients/index.d.ts +0 -3
  377. package/dest/rpc_clients/index.d.ts.map +0 -1
  378. package/dest/rpc_clients/index.js +0 -2
  379. package/dest/rpc_clients/node/index.d.ts +0 -12
  380. package/dest/rpc_clients/node/index.d.ts.map +0 -1
  381. package/dest/rpc_clients/node/index.js +0 -78
  382. package/dest/rpc_clients/pxe_client.d.ts +0 -10
  383. package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
  384. package/dest/rpc_clients/pxe_client.js +0 -23
  385. package/dest/utils/aztec_cheatcodes.d.ts +0 -59
  386. package/dest/utils/aztec_cheatcodes.d.ts.map +0 -1
  387. package/dest/utils/aztec_cheatcodes.js +0 -62
  388. package/dest/utils/index.d.ts +0 -8
  389. package/dest/utils/index.d.ts.map +0 -1
  390. package/dest/utils/index.js +0 -6
  391. package/dest/utils/pxe.d.ts +0 -4
  392. package/dest/utils/pxe.d.ts.map +0 -1
  393. package/dest/utils/pxe.js +0 -14
  394. package/dest/wallet/account_wallet.d.ts +0 -76
  395. package/dest/wallet/account_wallet.d.ts.map +0 -1
  396. package/dest/wallet/account_wallet.js +0 -231
  397. package/dest/wallet/account_wallet_with_private_key.d.ts +0 -26
  398. package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
  399. package/dest/wallet/base_wallet.d.ts +0 -73
  400. package/dest/wallet/base_wallet.d.ts.map +0 -1
  401. package/dest/wallet/base_wallet.js +0 -123
  402. package/dest/wallet/signerless_wallet.d.ts +0 -25
  403. package/dest/wallet/signerless_wallet.d.ts.map +0 -1
  404. package/dest/wallet/signerless_wallet.js +0 -36
  405. package/src/account/contract.ts +0 -56
  406. package/src/account/interface.ts +0 -36
  407. package/src/account/wallet.ts +0 -13
  408. package/src/account_manager/deploy_account_method.ts +0 -86
  409. package/src/account_manager/deploy_account_sent_tx.ts +0 -42
  410. package/src/account_manager/index.ts +0 -229
  411. package/src/api/cheat_codes.ts +0 -35
  412. package/src/api/entrypoint.ts +0 -1
  413. package/src/api/ethereum/anvil_test_watcher.ts +0 -158
  414. package/src/api/ethereum/chain_monitor.ts +0 -88
  415. package/src/api/ethereum/cheat_codes.ts +0 -184
  416. package/src/api/ethereum/index.ts +0 -19
  417. package/src/api/ethereum/l1_contracts.ts +0 -21
  418. package/src/api/interfaces/pxe.ts +0 -1
  419. package/src/api/log_id.ts +0 -1
  420. package/src/api/tx_hash.ts +0 -1
  421. package/src/contract/deploy_proven_tx.ts +0 -34
  422. package/src/contract/deploy_sent_tx.ts +0 -74
  423. package/src/contract/index.ts +0 -48
  424. package/src/contract/protocol_contracts.ts +0 -35
  425. package/src/contract/proven_tx.ts +0 -42
  426. package/src/contract/sent_tx.ts +0 -141
  427. package/src/contract/unsafe_contract.ts +0 -19
  428. package/src/deployment/deploy_instance.ts +0 -31
  429. package/src/deployment/index.ts +0 -1
  430. package/src/deployment/register_class.ts +0 -44
  431. package/src/entrypoint/default_entrypoint.ts +0 -39
  432. package/src/entrypoint/default_multi_call_entrypoint.ts +0 -93
  433. package/src/entrypoint/entrypoint.ts +0 -39
  434. package/src/entrypoint/payload.ts +0 -238
  435. package/src/fee/fee_juice_payment_method.ts +0 -26
  436. package/src/index.ts +0 -106
  437. package/src/rpc_clients/index.ts +0 -2
  438. package/src/rpc_clients/node/index.ts +0 -77
  439. package/src/rpc_clients/pxe_client.ts +0 -25
  440. package/src/utils/aztec_cheatcodes.ts +0 -77
  441. package/src/utils/index.ts +0 -21
  442. package/src/utils/pxe.ts +0 -17
  443. package/src/wallet/account_wallet.ts +0 -242
  444. package/src/wallet/account_wallet_with_private_key.ts +0 -40
  445. package/src/wallet/base_wallet.ts +0 -198
  446. package/src/wallet/signerless_wallet.ts +0 -52
@@ -1,37 +1,59 @@
1
- import { GeneratorIndex } from '@aztec/constants';
2
- import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
3
- import { Fr } from '@aztec/foundation/fields';
4
- import type { FunctionCall } from '@aztec/stdlib/abi';
1
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
+ import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
5
+ import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
5
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import { HashedValues } from '@aztec/stdlib/tx';
7
+ import { computeVarArgsHash } from '@aztec/stdlib/hash';
8
+ import type { TxHash, TxProfileResult, TxReceipt } from '@aztec/stdlib/tx';
7
9
 
8
10
  import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
9
-
10
- /** Metadata for the intent */
11
- export type IntentMetadata = {
12
- /** The chain id to approve */
13
- chainId: Fr;
14
- /** The version to approve */
15
- version: Fr;
16
- };
11
+ import type {
12
+ InteractionWaitOptions,
13
+ ProfileInteractionOptions,
14
+ SendInteractionOptions,
15
+ SendInteractionOptionsWithoutWait,
16
+ SendReturn,
17
+ SimulateInteractionOptions,
18
+ SimulationReturn,
19
+ } from '../contract/interaction_options.js';
20
+ import type { Wallet } from '../wallet/index.js';
17
21
 
18
22
  /** Intent with an inner hash */
19
23
  export type IntentInnerHash = {
20
24
  /** The consumer */
21
25
  consumer: AztecAddress;
22
26
  /** The action to approve */
23
- innerHash: Buffer | Fr;
27
+ innerHash: Fr;
24
28
  };
25
29
 
26
- /** Intent with an action */
27
- export type IntentAction = {
30
+ /** Intent with a call */
31
+ export type CallIntent = {
32
+ /** The caller to approve */
33
+ caller: AztecAddress;
34
+ /** The call to approve */
35
+ call: FunctionCall;
36
+ };
37
+
38
+ /** Intent with a ContractFunctionInteraction */
39
+ export type ContractFunctionInteractionCallIntent = {
28
40
  /** The caller to approve */
29
41
  caller: AztecAddress;
30
42
  /** The action to approve */
31
- action: ContractFunctionInteraction | FunctionCall;
43
+ action: ContractFunctionInteraction;
32
44
  };
33
45
 
34
- // docs:start:authwit_computeAuthWitMessageHash
46
+ /** Identifies ContractFunctionInteractionCallIntents */
47
+ export function isContractFunctionInteractionCallIntent(
48
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
49
+ ): messageHashOrIntent is ContractFunctionInteractionCallIntent {
50
+ return (
51
+ 'caller' in messageHashOrIntent &&
52
+ 'action' in messageHashOrIntent &&
53
+ messageHashOrIntent.action instanceof ContractFunctionInteraction
54
+ );
55
+ }
56
+
35
57
  /**
36
58
  * Compute an authentication witness message hash from an intent and metadata
37
59
  *
@@ -42,7 +64,7 @@ export type IntentAction = {
42
64
  * and use it for the authentication check.
43
65
  * Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
44
66
  *
45
- * If using the `IntentAction`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
67
+ * If using the `CallIntent`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
46
68
  * The action is then used along with the `caller` to compute the `innerHash` and the consumer.
47
69
  *
48
70
  *
@@ -53,58 +75,256 @@ export type IntentAction = {
53
75
  * @param metadata - The metadata for the intent (chainId, version)
54
76
  * @returns The message hash for the action
55
77
  */
56
- export const computeAuthWitMessageHash = async (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => {
78
+ export const computeAuthWitMessageHash = async (
79
+ intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
80
+ metadata: ChainInfo,
81
+ ) => {
57
82
  const chainId = metadata.chainId;
58
83
  const version = metadata.version;
59
84
 
60
85
  if ('caller' in intent) {
61
- const action = intent.action instanceof ContractFunctionInteraction ? await intent.action.request() : intent.action;
86
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
62
87
  return computeOuterAuthWitHash(
63
- action.to,
88
+ call.to,
64
89
  chainId,
65
90
  version,
66
- await computeInnerAuthWitHashFromAction(intent.caller, action),
91
+ await computeInnerAuthWitHashFromAction(intent.caller, call),
67
92
  );
68
93
  } else {
69
94
  const inner = Buffer.isBuffer(intent.innerHash) ? Fr.fromBuffer(intent.innerHash) : intent.innerHash;
70
95
  return computeOuterAuthWitHash(intent.consumer, chainId, version, inner);
71
96
  }
72
97
  };
73
- // docs:end:authwit_computeAuthWitMessageHash
74
-
75
- export const computeInnerAuthWitHashFromAction = async (caller: AztecAddress, action: FunctionCall) =>
76
- computeInnerAuthWitHash([
77
- caller.toField(),
78
- action.selector.toField(),
79
- (await HashedValues.fromValues(action.args)).hash,
80
- ]);
81
98
 
82
99
  /**
83
- * Compute the inner hash for an authentication witness.
84
- * This is the "intent" of the message, before siloed with the consumer.
85
- * It is used as part of the `computeAuthWitMessageHash` but can also be used
86
- * in case the message is not a "call" to a function, but arbitrary data.
87
- * @param args - The arguments to hash
88
- * @returns The inner hash for the witness
100
+ * Compute an authentication witness message hash from an intent and metadata. This is just
101
+ * a wrapper around computeAuthwitMessageHash that allows receiving an already computed messageHash as input
102
+ * @param messageHashOrIntent - The precomputed messageHash or intent to approve (consumer and innerHash or caller and call/action)
103
+ * @param metadata - The metadata for the intent (chainId, version)
104
+ * @returns The message hash for the intent
89
105
  */
90
- export const computeInnerAuthWitHash = (args: Fr[]) => {
91
- return poseidon2HashWithSeparator(args, GeneratorIndex.AUTHWIT_INNER);
106
+ export async function getMessageHashFromIntent(
107
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
108
+ chainInfo: ChainInfo,
109
+ ) {
110
+ let messageHash: Fr;
111
+ const { chainId, version } = chainInfo;
112
+ if (messageHashOrIntent instanceof Fr) {
113
+ messageHash = messageHashOrIntent;
114
+ } else {
115
+ messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
116
+ }
117
+ return messageHash;
118
+ }
119
+
120
+ /**
121
+ * Computes the inner authwitness hash for either a function call or an action, for it to later be combined with the metadata
122
+ * required for the outer hash and eventually the full AuthWitness.
123
+ * @param caller - Who is going to be calling the function
124
+ * @param action - The action to compute the inner hash from
125
+ * @returns The inner hash for the action
126
+ **/
127
+ export const computeInnerAuthWitHashFromAction = async (
128
+ caller: AztecAddress,
129
+ action: FunctionCall | ContractFunctionInteraction,
130
+ ) => {
131
+ const call = action instanceof ContractFunctionInteraction ? await action.getFunctionCall() : action;
132
+ return computeInnerAuthWitHash([caller.toField(), call.selector.toField(), await computeVarArgsHash(call.args)]);
92
133
  };
93
134
 
94
135
  /**
95
- * Compute the outer hash for an authentication witness.
96
- * This is the value siloed with its "consumer" and what the `on_behalf_of`
97
- * should be signing.
98
- * The consumer is who will be consuming the message, for token approvals it
99
- * is the token contract itself (because the token makes the call to check the approval).
100
- * It is used as part of the `computeAuthWitMessageHash` but can also be used
101
- * in case the message is not a "call" to a function, but arbitrary data.
102
- * @param consumer - The address that can "consume" the authwit
103
- * @param chainId - The chain id that can "consume" the authwit
104
- * @param version - The version that can "consume" the authwit
105
- * @param innerHash - The inner hash for the witness
106
- * @returns The outer hash for the witness
136
+ * Lookup the validity of an authwit in private and public contexts.
137
+ *
138
+ * Uses the chain id and version of the wallet.
139
+ *
140
+ * @param wallet - The wallet use to simulate and read the public data
141
+ * @param onBehalfOf - The address of the "approver"
142
+ * @param intent - The consumer and inner hash or the caller and action to lookup
143
+ * @param witness - The computed authentication witness to check
144
+ * @returns - A struct containing the validity of the authwit in private and public contexts.
107
145
  */
108
- const computeOuterAuthWitHash = (consumer: AztecAddress, chainId: Fr, version: Fr, innerHash: Fr) => {
109
- return poseidon2HashWithSeparator([consumer.toField(), chainId, version, innerHash], GeneratorIndex.AUTHWIT_OUTER);
110
- };
146
+ export async function lookupValidity(
147
+ wallet: Wallet,
148
+ onBehalfOf: AztecAddress,
149
+ intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
150
+ witness: AuthWitness,
151
+ ): Promise<{
152
+ /** boolean flag indicating if the authwit is valid in private context */
153
+ isValidInPrivate: boolean;
154
+ /** boolean flag indicating if the authwit is valid in public context */
155
+ isValidInPublic: boolean;
156
+ }> {
157
+ let innerHash, consumer;
158
+ if ('caller' in intent) {
159
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
160
+ innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
161
+ consumer = call.to;
162
+ } else {
163
+ ({ innerHash, consumer } = intent);
164
+ }
165
+ const chainInfo = await wallet.getChainInfo();
166
+ const messageHash = await getMessageHashFromIntent(intent, chainInfo);
167
+ const results = { isValidInPrivate: false, isValidInPublic: false };
168
+
169
+ // Check private
170
+ const lookupValidityAbi = {
171
+ name: 'lookup_validity',
172
+ isInitializer: false,
173
+ functionType: FunctionType.UTILITY,
174
+ isOnlySelf: false,
175
+ isStatic: false,
176
+ parameters: [
177
+ {
178
+ name: 'consumer',
179
+ type: {
180
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
181
+ kind: 'struct',
182
+ path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
183
+ },
184
+ visibility: 'private' as ABIParameterVisibility,
185
+ },
186
+ { name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
187
+ ],
188
+ returnTypes: [{ kind: 'boolean' }],
189
+ errorTypes: {},
190
+ } as FunctionAbi;
191
+ try {
192
+ results.isValidInPrivate = (await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [
193
+ consumer,
194
+ innerHash,
195
+ ]).simulate({ from: onBehalfOf, authWitnesses: [witness] })) as boolean;
196
+ // TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
197
+ // eslint-disable-next-line no-empty
198
+ } catch {}
199
+
200
+ // check public
201
+ const isConsumableAbi = {
202
+ name: 'utility_is_consumable',
203
+ isInitializer: false,
204
+ functionType: FunctionType.UTILITY,
205
+ isOnlySelf: false,
206
+ isStatic: false,
207
+ parameters: [
208
+ {
209
+ name: 'address',
210
+ type: {
211
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
212
+ kind: 'struct',
213
+ path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
214
+ },
215
+ visibility: 'private' as ABIParameterVisibility,
216
+ },
217
+ { name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
218
+ ],
219
+ returnTypes: [{ kind: 'boolean' }],
220
+ errorTypes: {},
221
+ } as FunctionAbi;
222
+ results.isValidInPublic = (await new ContractFunctionInteraction(
223
+ wallet,
224
+ ProtocolContractAddress.AuthRegistry,
225
+ isConsumableAbi,
226
+ [onBehalfOf, messageHash],
227
+ ).simulate({ from: onBehalfOf })) as boolean;
228
+
229
+ return results;
230
+ }
231
+
232
+ /**
233
+ * Convenience class designed to wrap the very common interaction of setting a public authwit in the AuthRegistry contract
234
+ */
235
+ export class SetPublicAuthwitContractInteraction extends ContractFunctionInteraction {
236
+ private constructor(
237
+ wallet: Wallet,
238
+ private from: AztecAddress,
239
+ messageHash: Fr,
240
+ authorized: boolean,
241
+ ) {
242
+ super(wallet, ProtocolContractAddress.AuthRegistry, SetPublicAuthwitContractInteraction.getSetAuthorizedAbi(), [
243
+ messageHash,
244
+ authorized,
245
+ ]);
246
+ }
247
+
248
+ static async create(
249
+ wallet: Wallet,
250
+ from: AztecAddress,
251
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
252
+ authorized: boolean,
253
+ ) {
254
+ const chainInfo = await wallet.getChainInfo();
255
+ const messageHash = await getMessageHashFromIntent(messageHashOrIntent, chainInfo);
256
+ return new SetPublicAuthwitContractInteraction(wallet, from, messageHash, authorized);
257
+ }
258
+
259
+ /**
260
+ * Overrides the simulate method, adding the sender of the authwit (authorizer) as from
261
+ * and preventing misuse
262
+ * @param options - An optional object containing additional configuration for the transaction.
263
+ * @returns The result of the transaction as returned by the contract function.
264
+ */
265
+ public override simulate<T extends SimulateInteractionOptions>(
266
+ options: Omit<T, 'from'>,
267
+ ): Promise<SimulationReturn<T['includeMetadata']>>;
268
+ // eslint-disable-next-line jsdoc/require-jsdoc
269
+ public override simulate(
270
+ options: Omit<SimulateInteractionOptions, 'from'> = {},
271
+ ): Promise<SimulationReturn<typeof options.includeMetadata>> {
272
+ return super.simulate({ ...options, from: this.from });
273
+ }
274
+
275
+ /**
276
+ * Overrides the profile method, adding the sender of the authwit (authorizer) as from
277
+ * and preventing misuse
278
+ * @param options - Same options as `simulate`, plus profiling method
279
+ * @returns An object containing the function return value and profile result.
280
+ */
281
+ public override profile(
282
+ options: Omit<ProfileInteractionOptions, 'from'> = { profileMode: 'gates' },
283
+ ): Promise<TxProfileResult> {
284
+ return super.profile({ ...options, from: this.from });
285
+ }
286
+
287
+ /**
288
+ * Overrides the send method, adding the sender of the authwit (authorizer) as from
289
+ * and preventing misuse
290
+ * @param options - An optional object containing 'fee' options information
291
+ * @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
292
+ */
293
+ // Overload for when wait is not specified at all - returns TxReceipt
294
+ public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
295
+ // Generic overload for explicit wait values
296
+ // eslint-disable-next-line jsdoc/require-jsdoc
297
+ public override send<W extends InteractionWaitOptions>(
298
+ options?: Omit<SendInteractionOptions<W>, 'from'>,
299
+ ): Promise<SendReturn<W>>;
300
+ // eslint-disable-next-line jsdoc/require-jsdoc
301
+ public override send(
302
+ options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
303
+ ): Promise<TxReceipt | TxHash> {
304
+ return super.send({ ...options, from: this.from });
305
+ }
306
+
307
+ private static getSetAuthorizedAbi(): FunctionAbi {
308
+ return {
309
+ name: 'set_authorized',
310
+ isInitializer: false,
311
+ functionType: FunctionType.PUBLIC,
312
+ isOnlySelf: true,
313
+ isStatic: false,
314
+ parameters: [
315
+ {
316
+ name: 'message_hash',
317
+ type: { kind: 'field' },
318
+ visibility: 'private' as ABIParameterVisibility,
319
+ },
320
+ {
321
+ name: 'authorize',
322
+ type: { kind: 'boolean' },
323
+ visibility: 'private' as ABIParameterVisibility,
324
+ },
325
+ ],
326
+ returnTypes: [],
327
+ errorTypes: {},
328
+ };
329
+ }
330
+ }
@@ -0,0 +1,53 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { retryUntil } from '@aztec/foundation/retry';
3
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
+
5
+ /**
6
+ * Waits for the L1 to L2 message to be ready to be consumed.
7
+ * @param node - Aztec node instance used to obtain the information about the message
8
+ * @param l1ToL2MessageHash - Hash of the L1 to L2 message
9
+ * @param opts - Options
10
+ */
11
+ export async function waitForL1ToL2MessageReady(
12
+ node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
13
+ l1ToL2MessageHash: Fr,
14
+ opts: {
15
+ /** Timeout for the operation in seconds */ timeoutSeconds: number;
16
+ /** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
17
+ },
18
+ ) {
19
+ const messageBlockNumber = await node.getL1ToL2MessageBlock(l1ToL2MessageHash);
20
+ return retryUntil(
21
+ () => isL1ToL2MessageReady(node, l1ToL2MessageHash, { ...opts, messageBlockNumber }),
22
+ `L1 to L2 message ${l1ToL2MessageHash.toString()} ready`,
23
+ opts.timeoutSeconds,
24
+ 1,
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Returns whether the L1 to L2 message is ready to be consumed.
30
+ * @param node - Aztec node instance used to obtain the information about the message
31
+ * @param l1ToL2MessageHash - Hash of the L1 to L2 message
32
+ * @param opts - Options
33
+ * @returns True if the message is ready to be consumed, false otherwise
34
+ */
35
+ export async function isL1ToL2MessageReady(
36
+ node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
37
+ l1ToL2MessageHash: Fr,
38
+ opts: {
39
+ /** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
40
+ /** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
41
+ },
42
+ ): Promise<boolean> {
43
+ const blockNumber = await node.getBlockNumber();
44
+ const messageBlockNumber = opts.messageBlockNumber ?? (await node.getL1ToL2MessageBlock(l1ToL2MessageHash));
45
+ if (messageBlockNumber === undefined) {
46
+ return false;
47
+ }
48
+
49
+ // Note that public messages can be consumed 1 block earlier, since the sequencer will include the messages
50
+ // in the L1 to L2 message tree before executing the txs for the block. In private, however, we need to wait
51
+ // until the message is included so we can make use of the membership witness.
52
+ return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
53
+ }
@@ -1,14 +1,14 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
5
-
6
- import type { PXE } from '../api/interfaces/pxe.js';
5
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
6
 
8
7
  /**
9
8
  * Returns the owner's fee juice balance.
9
+ * Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
10
10
  */
11
- export async function getFeeJuiceBalance(owner: AztecAddress, pxe: PXE): Promise<bigint> {
11
+ export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
12
12
  const slot = await deriveStorageSlotInMap(new Fr(1), owner);
13
- return (await pxe.getPublicStorageAt(ProtocolContractAddress.FeeJuice, slot)).toBigInt();
13
+ return (await node.getPublicStorageAt('latest', ProtocolContractAddress.FeeJuice, slot)).toBigInt();
14
14
  }
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  /**
4
4
  * The representation of a FieldCompressedString in aztec.nr
package/src/utils/node.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
+ import { SortedTxStatuses, TxStatus } from '@aztec/stdlib/tx';
6
+
7
+ import { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
4
8
 
5
9
  export const waitForNode = async (node: AztecNode, logger?: Logger) => {
6
10
  await retryUntil(async () => {
@@ -9,11 +13,69 @@ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
9
13
  await node.getNodeInfo();
10
14
  logger?.verbose('Contacted Aztec node');
11
15
  return true;
12
- } catch (error) {
16
+ } catch {
13
17
  logger?.verbose('Failed to contact Aztec Node');
14
18
  }
15
19
  return undefined;
16
20
  }, 'RPC Get Node Info');
17
21
  };
18
22
 
23
+ /** Returns true if the receipt status is at least the desired status level. */
24
+ function hasReachedStatus(receipt: TxReceipt, desiredStatus: TxStatus): boolean {
25
+ return SortedTxStatuses.indexOf(receipt.status) >= SortedTxStatuses.indexOf(desiredStatus);
26
+ }
27
+
28
+ /**
29
+ * Waits for a transaction to be mined and returns its receipt.
30
+ * @param node - The Aztec node to query for transaction status
31
+ * @param txHash - The hash of the transaction to wait for
32
+ * @param opts - Optional configuration for waiting behavior
33
+ * @returns The transaction receipt
34
+ * @throws If the transaction fails and dontThrowOnRevert is not set
35
+ */
36
+ export async function waitForTx(node: AztecNode, txHash: TxHash, opts?: WaitOpts): Promise<TxReceipt> {
37
+ const startTime = Date.now();
38
+ const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
39
+ const waitForStatus = opts?.waitForStatus ?? TxStatus.CHECKPOINTED;
40
+
41
+ const receipt = await retryUntil(
42
+ async () => {
43
+ const txReceipt = await node.getTxReceipt(txHash);
44
+ // If receipt is not yet available, try again
45
+ if (txReceipt.isPending()) {
46
+ return undefined;
47
+ }
48
+ // If the tx was "dropped", either return it or ignore based on timing.
49
+ // We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
50
+ // If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
51
+ if (txReceipt.isDropped()) {
52
+ const elapsedSeconds = (Date.now() - startTime) / 1000;
53
+ if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
54
+ return txReceipt;
55
+ }
56
+ return undefined;
57
+ }
58
+ // Check if the receipt has reached the desired status level
59
+ if (!hasReachedStatus(txReceipt, waitForStatus)) {
60
+ return undefined;
61
+ }
62
+ return txReceipt;
63
+ },
64
+ 'isMined',
65
+ opts?.timeout ?? DefaultWaitOpts.timeout,
66
+ opts?.interval ?? DefaultWaitOpts.interval,
67
+ );
68
+
69
+ if (!receipt.isMined()) {
70
+ throw new Error(`Transaction ${txHash.toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
71
+ }
72
+ if (!receipt.hasExecutionSucceeded() && !opts?.dontThrowOnRevert) {
73
+ throw new Error(
74
+ `Transaction ${txHash.toString()} reverted: ${receipt.executionResult}. Reason: ${receipt.error ?? 'unknown'}`,
75
+ );
76
+ }
77
+
78
+ return receipt;
79
+ }
80
+
19
81
  export { createAztecNodeClient, type AztecNode } from '@aztec/stdlib/interfaces/client';
@@ -1,5 +1,5 @@
1
- import { Grumpkin } from '@aztec/foundation/crypto';
2
- import type { GrumpkinScalar } from '@aztec/foundation/fields';
1
+ import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
2
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
3
3
  import type { PublicKey } from '@aztec/stdlib/keys';
4
4
 
5
5
  /**
@@ -8,6 +8,5 @@ import type { PublicKey } from '@aztec/stdlib/keys';
8
8
  * @returns The generated public key.
9
9
  */
10
10
  export function generatePublicKey(privateKey: GrumpkinScalar): Promise<PublicKey> {
11
- const grumpkin = new Grumpkin();
12
- return grumpkin.mul(grumpkin.generator(), privateKey);
11
+ return Grumpkin.mul(Grumpkin.generator, privateKey);
13
12
  }
@@ -0,0 +1,74 @@
1
+ import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
2
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { GasSettings } from '@aztec/stdlib/gas';
5
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
6
+
7
+ import type { Account } from '../account/account.js';
8
+ import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
9
+
10
+ /**
11
+ * Fee payment method that allows an account contract to pay for its own deployment
12
+ * It works by rerouting the provided fee payment method through the account's entrypoint,
13
+ * which sets itself as fee payer. If no payment method is provided, it is assumed the
14
+ * account will pay with its own fee juice balance.
15
+ *
16
+ * Usually, in order to pay fees it is necessary to obtain an ExecutionPayload that encodes the necessary information
17
+ * that is sent to the user's account entrypoint, that has plumbing to handle it.
18
+ * If there's no account contract yet (it's being deployed) a MultiCallContract is used, which doesn't have a concept of fees or
19
+ * how to handle this payload.
20
+ * HOWEVER, the account contract's entrypoint does, so this method reshapes that fee payload into a call to the account contract entrypoint
21
+ * being deployed with the original fee payload.
22
+ *
23
+ * This class can be seen in action in DeployAccountMethod.ts#getSelfPaymentMethod
24
+ */
25
+ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
26
+ constructor(
27
+ private account: Account,
28
+ private paymentMethod?: FeePaymentMethod,
29
+ private feeEntrypointOptions?: any,
30
+ ) {}
31
+
32
+ getAsset(): Promise<AztecAddress> {
33
+ return this.paymentMethod?.getAsset() ?? Promise.resolve(ProtocolContractAddress.FeeJuice);
34
+ }
35
+
36
+ async getExecutionPayload(): Promise<ExecutionPayload> {
37
+ // Get the execution payload for the fee
38
+ const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
39
+
40
+ // If no fee entrypoint options were provided, compute them based on the wrapped payment method
41
+ // This mimics how the actual account contract works when invoked directly:
42
+ // - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
43
+ // only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
44
+ // - If we are the fee payer, but there are no calls, then we assume the account already has
45
+ // fee juice and can pay directly with PREEXISTING_FEE_JUICE
46
+ // - If we are not the fee payer, then EXTERNAL is used
47
+ let options = this.feeEntrypointOptions;
48
+ if (!options) {
49
+ const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
50
+ const isFeePayer = feePayer.equals(this.account.getAddress());
51
+
52
+ let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
53
+ if (isFeePayer) {
54
+ accountFeePaymentMethodOptions =
55
+ innerPayload.calls.length === 0
56
+ ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
57
+ : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
58
+ }
59
+
60
+ options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
61
+ }
62
+
63
+ // Use the generic wrapping mechanism from the account interface
64
+ return this.account.wrapExecutionPayload(innerPayload, options);
65
+ }
66
+
67
+ getFeePayer(): Promise<AztecAddress> {
68
+ return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
69
+ }
70
+
71
+ getGasSettings(): GasSettings | undefined {
72
+ return this.paymentMethod?.getGasSettings();
73
+ }
74
+ }