@aztec/aztec.js 0.0.0-test.0

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 (299) hide show
  1. package/README.md +44 -0
  2. package/dest/account/contract.d.ts +37 -0
  3. package/dest/account/contract.d.ts.map +1 -0
  4. package/dest/account/contract.js +16 -0
  5. package/dest/account/index.d.ts +15 -0
  6. package/dest/account/index.d.ts.map +1 -0
  7. package/dest/account/index.js +9 -0
  8. package/dest/account/interface.d.ts +31 -0
  9. package/dest/account/interface.d.ts.map +1 -0
  10. package/dest/account/interface.js +4 -0
  11. package/dest/account/wallet.d.ts +11 -0
  12. package/dest/account/wallet.d.ts.map +1 -0
  13. package/dest/account/wallet.js +3 -0
  14. package/dest/account_manager/deploy_account_method.d.ts +15 -0
  15. package/dest/account_manager/deploy_account_method.d.ts.map +1 -0
  16. package/dest/account_manager/deploy_account_method.js +43 -0
  17. package/dest/account_manager/deploy_account_sent_tx.d.ts +30 -0
  18. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -0
  19. package/dest/account_manager/deploy_account_sent_tx.js +29 -0
  20. package/dest/account_manager/index.d.ts +108 -0
  21. package/dest/account_manager/index.d.ts.map +1 -0
  22. package/dest/account_manager/index.js +159 -0
  23. package/dest/api/abi.d.ts +3 -0
  24. package/dest/api/abi.d.ts.map +1 -0
  25. package/dest/api/abi.js +1 -0
  26. package/dest/api/account.d.ts +3 -0
  27. package/dest/api/account.d.ts.map +1 -0
  28. package/dest/api/account.js +2 -0
  29. package/dest/api/addresses.d.ts +3 -0
  30. package/dest/api/addresses.d.ts.map +1 -0
  31. package/dest/api/addresses.js +2 -0
  32. package/dest/api/cheat_codes.d.ts +26 -0
  33. package/dest/api/cheat_codes.d.ts.map +1 -0
  34. package/dest/api/cheat_codes.js +25 -0
  35. package/dest/api/deployment.d.ts +4 -0
  36. package/dest/api/deployment.d.ts.map +1 -0
  37. package/dest/api/deployment.js +3 -0
  38. package/dest/api/entrypoint.d.ts +2 -0
  39. package/dest/api/entrypoint.d.ts.map +1 -0
  40. package/dest/api/entrypoint.js +1 -0
  41. package/dest/api/eth_address.d.ts +2 -0
  42. package/dest/api/eth_address.d.ts.map +1 -0
  43. package/dest/api/eth_address.js +1 -0
  44. package/dest/api/ethereum/anvil_test_watcher.d.ts +32 -0
  45. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -0
  46. package/dest/api/ethereum/anvil_test_watcher.js +133 -0
  47. package/dest/api/ethereum/chain_monitor.d.ts +25 -0
  48. package/dest/api/ethereum/chain_monitor.d.ts.map +1 -0
  49. package/dest/api/ethereum/chain_monitor.js +74 -0
  50. package/dest/api/ethereum/cheat_codes.d.ts +63 -0
  51. package/dest/api/ethereum/cheat_codes.d.ts.map +1 -0
  52. package/dest/api/ethereum/cheat_codes.js +162 -0
  53. package/dest/api/ethereum/index.d.ts +7 -0
  54. package/dest/api/ethereum/index.d.ts.map +1 -0
  55. package/dest/api/ethereum/index.js +6 -0
  56. package/dest/api/ethereum/l1_contracts.d.ts +3 -0
  57. package/dest/api/ethereum/l1_contracts.d.ts.map +1 -0
  58. package/dest/api/ethereum/l1_contracts.js +13 -0
  59. package/dest/api/ethereum/portal_manager.d.ts +136 -0
  60. package/dest/api/ethereum/portal_manager.d.ts.map +1 -0
  61. package/dest/api/ethereum/portal_manager.js +286 -0
  62. package/dest/api/fee.d.ts +6 -0
  63. package/dest/api/fee.d.ts.map +1 -0
  64. package/dest/api/fee.js +4 -0
  65. package/dest/api/fields.d.ts +2 -0
  66. package/dest/api/fields.d.ts.map +1 -0
  67. package/dest/api/fields.js +1 -0
  68. package/dest/api/interfaces/pxe.d.ts +2 -0
  69. package/dest/api/interfaces/pxe.d.ts.map +1 -0
  70. package/dest/api/interfaces/pxe.js +1 -0
  71. package/dest/api/log.d.ts +2 -0
  72. package/dest/api/log.d.ts.map +1 -0
  73. package/dest/api/log.js +1 -0
  74. package/dest/api/log_id.d.ts +2 -0
  75. package/dest/api/log_id.d.ts.map +1 -0
  76. package/dest/api/log_id.js +1 -0
  77. package/dest/api/tx_hash.d.ts +2 -0
  78. package/dest/api/tx_hash.d.ts.map +1 -0
  79. package/dest/api/tx_hash.js +1 -0
  80. package/dest/api/wallet.d.ts +2 -0
  81. package/dest/api/wallet.d.ts.map +1 -0
  82. package/dest/api/wallet.js +1 -0
  83. package/dest/contract/base_contract_interaction.d.ts +98 -0
  84. package/dest/contract/base_contract_interaction.d.ts.map +1 -0
  85. package/dest/contract/base_contract_interaction.js +149 -0
  86. package/dest/contract/batch_call.d.ts +28 -0
  87. package/dest/contract/batch_call.d.ts.map +1 -0
  88. package/dest/contract/batch_call.js +91 -0
  89. package/dest/contract/checker.d.ts +11 -0
  90. package/dest/contract/checker.d.ts.map +1 -0
  91. package/dest/contract/checker.js +107 -0
  92. package/dest/contract/contract.d.ts +41 -0
  93. package/dest/contract/contract.d.ts.map +1 -0
  94. package/dest/contract/contract.js +52 -0
  95. package/dest/contract/contract_base.d.ts +61 -0
  96. package/dest/contract/contract_base.d.ts.map +1 -0
  97. package/dest/contract/contract_base.js +45 -0
  98. package/dest/contract/contract_function_interaction.d.ts +68 -0
  99. package/dest/contract/contract_function_interaction.d.ts.map +1 -0
  100. package/dest/contract/contract_function_interaction.js +122 -0
  101. package/dest/contract/deploy_method.d.ts +113 -0
  102. package/dest/contract/deploy_method.d.ts.map +1 -0
  103. package/dest/contract/deploy_method.js +212 -0
  104. package/dest/contract/deploy_proven_tx.d.ts +21 -0
  105. package/dest/contract/deploy_proven_tx.d.ts.map +1 -0
  106. package/dest/contract/deploy_proven_tx.js +19 -0
  107. package/dest/contract/deploy_sent_tx.d.ts +45 -0
  108. package/dest/contract/deploy_sent_tx.d.ts.map +1 -0
  109. package/dest/contract/deploy_sent_tx.js +43 -0
  110. package/dest/contract/get_gas_limits.d.ts +18 -0
  111. package/dest/contract/get_gas_limits.d.ts.map +1 -0
  112. package/dest/contract/get_gas_limits.js +10 -0
  113. package/dest/contract/index.d.ts +45 -0
  114. package/dest/contract/index.d.ts.map +1 -0
  115. package/dest/contract/index.js +43 -0
  116. package/dest/contract/protocol_contracts.d.ts +9 -0
  117. package/dest/contract/protocol_contracts.d.ts.map +1 -0
  118. package/dest/contract/protocol_contracts.js +26 -0
  119. package/dest/contract/proven_tx.d.ts +17 -0
  120. package/dest/contract/proven_tx.d.ts.map +1 -0
  121. package/dest/contract/proven_tx.js +22 -0
  122. package/dest/contract/sent_tx.d.ts +61 -0
  123. package/dest/contract/sent_tx.d.ts.map +1 -0
  124. package/dest/contract/sent_tx.js +102 -0
  125. package/dest/contract/unsafe_contract.d.ts +15 -0
  126. package/dest/contract/unsafe_contract.d.ts.map +1 -0
  127. package/dest/contract/unsafe_contract.js +6 -0
  128. package/dest/deployment/broadcast_function.d.ts +24 -0
  129. package/dest/deployment/broadcast_function.d.ts.map +1 -0
  130. package/dest/deployment/broadcast_function.js +70 -0
  131. package/dest/deployment/contract_deployer.d.ts +27 -0
  132. package/dest/deployment/contract_deployer.d.ts.map +1 -0
  133. package/dest/deployment/contract_deployer.js +30 -0
  134. package/dest/deployment/deploy_instance.d.ts +10 -0
  135. package/dest/deployment/deploy_instance.d.ts.map +1 -0
  136. package/dest/deployment/deploy_instance.js +14 -0
  137. package/dest/deployment/index.d.ts +2 -0
  138. package/dest/deployment/index.d.ts.map +1 -0
  139. package/dest/deployment/index.js +1 -0
  140. package/dest/deployment/register_class.d.ts +6 -0
  141. package/dest/deployment/register_class.d.ts.map +1 -0
  142. package/dest/deployment/register_class.js +22 -0
  143. package/dest/entrypoint/default_entrypoint.d.ts +12 -0
  144. package/dest/entrypoint/default_entrypoint.d.ts.map +1 -0
  145. package/dest/entrypoint/default_entrypoint.js +28 -0
  146. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +15 -0
  147. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -0
  148. package/dest/entrypoint/default_multi_call_entrypoint.js +130 -0
  149. package/dest/entrypoint/entrypoint.d.ts +35 -0
  150. package/dest/entrypoint/entrypoint.d.ts.map +1 -0
  151. package/dest/entrypoint/entrypoint.js +4 -0
  152. package/dest/entrypoint/payload.d.ts +128 -0
  153. package/dest/entrypoint/payload.d.ts.map +1 -0
  154. package/dest/entrypoint/payload.js +143 -0
  155. package/dest/fee/fee_juice_payment_method.d.ts +14 -0
  156. package/dest/fee/fee_juice_payment_method.d.ts.map +1 -0
  157. package/dest/fee/fee_juice_payment_method.js +20 -0
  158. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +18 -0
  159. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
  160. package/dest/fee/fee_juice_payment_method_with_claim.js +37 -0
  161. package/dest/fee/fee_payment_method.d.ts +22 -0
  162. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  163. package/dest/fee/fee_payment_method.js +3 -0
  164. package/dest/fee/private_fee_payment_method.d.ts +51 -0
  165. package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
  166. package/dest/fee/private_fee_payment_method.js +103 -0
  167. package/dest/fee/public_fee_payment_method.d.ts +41 -0
  168. package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
  169. package/dest/fee/public_fee_payment_method.js +97 -0
  170. package/dest/index.d.ts +66 -0
  171. package/dest/index.d.ts.map +1 -0
  172. package/dest/index.js +69 -0
  173. package/dest/rpc_clients/index.d.ts +3 -0
  174. package/dest/rpc_clients/index.d.ts.map +1 -0
  175. package/dest/rpc_clients/index.js +2 -0
  176. package/dest/rpc_clients/node/index.d.ts +12 -0
  177. package/dest/rpc_clients/node/index.d.ts.map +1 -0
  178. package/dest/rpc_clients/node/index.js +78 -0
  179. package/dest/rpc_clients/pxe_client.d.ts +10 -0
  180. package/dest/rpc_clients/pxe_client.d.ts.map +1 -0
  181. package/dest/rpc_clients/pxe_client.js +23 -0
  182. package/dest/utils/abi_types.d.ts +29 -0
  183. package/dest/utils/abi_types.d.ts.map +1 -0
  184. package/dest/utils/abi_types.js +1 -0
  185. package/dest/utils/authwit.d.ts +60 -0
  186. package/dest/utils/authwit.d.ts.map +1 -0
  187. package/dest/utils/authwit.js +74 -0
  188. package/dest/utils/aztec_cheatcodes.d.ts +59 -0
  189. package/dest/utils/aztec_cheatcodes.d.ts.map +1 -0
  190. package/dest/utils/aztec_cheatcodes.js +62 -0
  191. package/dest/utils/fee_juice.d.ts +7 -0
  192. package/dest/utils/fee_juice.d.ts.map +1 -0
  193. package/dest/utils/fee_juice.js +9 -0
  194. package/dest/utils/field_compressed_string.d.ts +17 -0
  195. package/dest/utils/field_compressed_string.d.ts.map +1 -0
  196. package/dest/utils/field_compressed_string.js +15 -0
  197. package/dest/utils/index.d.ts +8 -0
  198. package/dest/utils/index.d.ts.map +1 -0
  199. package/dest/utils/index.js +6 -0
  200. package/dest/utils/node.d.ts +5 -0
  201. package/dest/utils/node.d.ts.map +1 -0
  202. package/dest/utils/node.js +15 -0
  203. package/dest/utils/pub_key.d.ts +9 -0
  204. package/dest/utils/pub_key.d.ts.map +1 -0
  205. package/dest/utils/pub_key.js +9 -0
  206. package/dest/utils/pxe.d.ts +4 -0
  207. package/dest/utils/pxe.d.ts.map +1 -0
  208. package/dest/utils/pxe.js +14 -0
  209. package/dest/wallet/account_wallet.d.ts +76 -0
  210. package/dest/wallet/account_wallet.d.ts.map +1 -0
  211. package/dest/wallet/account_wallet.js +231 -0
  212. package/dest/wallet/account_wallet_with_private_key.d.ts +26 -0
  213. package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -0
  214. package/dest/wallet/account_wallet_with_private_key.js +22 -0
  215. package/dest/wallet/base_wallet.d.ts +73 -0
  216. package/dest/wallet/base_wallet.d.ts.map +1 -0
  217. package/dest/wallet/base_wallet.js +123 -0
  218. package/dest/wallet/index.d.ts +17 -0
  219. package/dest/wallet/index.d.ts.map +1 -0
  220. package/dest/wallet/index.js +20 -0
  221. package/dest/wallet/signerless_wallet.d.ts +25 -0
  222. package/dest/wallet/signerless_wallet.d.ts.map +1 -0
  223. package/dest/wallet/signerless_wallet.js +36 -0
  224. package/package.json +116 -0
  225. package/src/account/contract.ts +56 -0
  226. package/src/account/index.ts +16 -0
  227. package/src/account/interface.ts +36 -0
  228. package/src/account/wallet.ts +13 -0
  229. package/src/account_manager/deploy_account_method.ts +86 -0
  230. package/src/account_manager/deploy_account_sent_tx.ts +42 -0
  231. package/src/account_manager/index.ts +229 -0
  232. package/src/api/README.md +7 -0
  233. package/src/api/abi.ts +10 -0
  234. package/src/api/account.ts +10 -0
  235. package/src/api/addresses.ts +2 -0
  236. package/src/api/cheat_codes.ts +35 -0
  237. package/src/api/deployment.ts +3 -0
  238. package/src/api/entrypoint.ts +1 -0
  239. package/src/api/eth_address.ts +1 -0
  240. package/src/api/ethereum/anvil_test_watcher.ts +158 -0
  241. package/src/api/ethereum/chain_monitor.ts +88 -0
  242. package/src/api/ethereum/cheat_codes.ts +184 -0
  243. package/src/api/ethereum/index.ts +19 -0
  244. package/src/api/ethereum/l1_contracts.ts +21 -0
  245. package/src/api/ethereum/portal_manager.ts +410 -0
  246. package/src/api/fee.ts +5 -0
  247. package/src/api/fields.ts +1 -0
  248. package/src/api/interfaces/pxe.ts +1 -0
  249. package/src/api/log.ts +1 -0
  250. package/src/api/log_id.ts +1 -0
  251. package/src/api/tx_hash.ts +1 -0
  252. package/src/api/wallet.ts +7 -0
  253. package/src/contract/base_contract_interaction.ts +192 -0
  254. package/src/contract/batch_call.ts +95 -0
  255. package/src/contract/checker.ts +117 -0
  256. package/src/contract/contract.ts +69 -0
  257. package/src/contract/contract_base.ts +90 -0
  258. package/src/contract/contract_function_interaction.ts +173 -0
  259. package/src/contract/deploy_method.ts +271 -0
  260. package/src/contract/deploy_proven_tx.ts +34 -0
  261. package/src/contract/deploy_sent_tx.ts +74 -0
  262. package/src/contract/get_gas_limits.ts +26 -0
  263. package/src/contract/index.ts +48 -0
  264. package/src/contract/protocol_contracts.ts +35 -0
  265. package/src/contract/proven_tx.ts +42 -0
  266. package/src/contract/sent_tx.ts +141 -0
  267. package/src/contract/unsafe_contract.ts +19 -0
  268. package/src/deployment/broadcast_function.ts +148 -0
  269. package/src/deployment/contract_deployer.ts +41 -0
  270. package/src/deployment/deploy_instance.ts +31 -0
  271. package/src/deployment/index.ts +1 -0
  272. package/src/deployment/register_class.ts +44 -0
  273. package/src/entrypoint/default_entrypoint.ts +39 -0
  274. package/src/entrypoint/default_multi_call_entrypoint.ts +93 -0
  275. package/src/entrypoint/entrypoint.ts +39 -0
  276. package/src/entrypoint/payload.ts +238 -0
  277. package/src/fee/fee_juice_payment_method.ts +26 -0
  278. package/src/fee/fee_juice_payment_method_with_claim.ts +49 -0
  279. package/src/fee/fee_payment_method.ts +22 -0
  280. package/src/fee/private_fee_payment_method.ts +118 -0
  281. package/src/fee/public_fee_payment_method.ts +114 -0
  282. package/src/index.ts +106 -0
  283. package/src/rpc_clients/index.ts +2 -0
  284. package/src/rpc_clients/node/index.ts +77 -0
  285. package/src/rpc_clients/pxe_client.ts +25 -0
  286. package/src/utils/abi_types.ts +25 -0
  287. package/src/utils/authwit.ts +110 -0
  288. package/src/utils/aztec_cheatcodes.ts +77 -0
  289. package/src/utils/fee_juice.ts +14 -0
  290. package/src/utils/field_compressed_string.ts +27 -0
  291. package/src/utils/index.ts +21 -0
  292. package/src/utils/node.ts +19 -0
  293. package/src/utils/pub_key.ts +13 -0
  294. package/src/utils/pxe.ts +17 -0
  295. package/src/wallet/account_wallet.ts +242 -0
  296. package/src/wallet/account_wallet_with_private_key.ts +40 -0
  297. package/src/wallet/base_wallet.ts +198 -0
  298. package/src/wallet/index.ts +33 -0
  299. package/src/wallet/signerless_wallet.ts +52 -0
@@ -0,0 +1,136 @@
1
+ import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import type { Logger } from '@aztec/foundation/log';
5
+ import type { SiblingPath } from '@aztec/foundation/trees';
6
+ import { TokenPortalAbi } from '@aztec/l1-artifacts';
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';
10
+ /** L1 to L2 message info to claim it on L2. */
11
+ export type L2Claim = {
12
+ /** Secret for claiming. */
13
+ claimSecret: Fr;
14
+ /** Hash of the secret for claiming. */
15
+ claimSecretHash: Fr;
16
+ /** Hash of the message. */
17
+ messageHash: Hex;
18
+ /** Leaf index in the L1 to L2 message tree. */
19
+ messageLeafIndex: bigint;
20
+ };
21
+ /** L1 to L2 message info that corresponds to an amount to claim. */
22
+ export type L2AmountClaim = L2Claim & {
23
+ claimAmount: bigint;
24
+ };
25
+ /** L1 to L2 message info that corresponds to an amount to claim with associated recipient. */
26
+ export type L2AmountClaimWithRecipient = L2AmountClaim & {
27
+ /** Address that will receive the newly minted notes. */ recipient: AztecAddress;
28
+ };
29
+ /** Generates a pair secret and secret hash */
30
+ export declare function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]>;
31
+ /** Helper for managing an ERC20 on L1. */
32
+ export declare class L1TokenManager {
33
+ /** Address of the ERC20 contract. */
34
+ readonly address: EthAddress;
35
+ private publicClient;
36
+ private walletClient;
37
+ private logger;
38
+ private contract;
39
+ constructor(
40
+ /** Address of the ERC20 contract. */
41
+ address: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
42
+ /**
43
+ * Returns the balance of the given address.
44
+ * @param address - Address to get the balance of.
45
+ */
46
+ getL1TokenBalance(address: Hex): Promise<bigint>;
47
+ /**
48
+ * Mints tokens for the given address. Returns once the tx has been mined.
49
+ * @param amount - Amount to mint.
50
+ * @param address - Address to mint the tokens for.
51
+ * @param addressName - Optional name of the address for logging.
52
+ */
53
+ mint(amount: bigint, address: Hex, addressName?: string): Promise<void>;
54
+ /**
55
+ * Approves tokens for the given address. Returns once the tx has been mined.
56
+ * @param amount - Amount to approve.
57
+ * @param address - Address to approve the tokens for.
58
+ * @param addressName - Optional name of the address for logging.
59
+ */
60
+ approve(amount: bigint, address: Hex, addressName?: string): Promise<void>;
61
+ }
62
+ /** Helper for interacting with the FeeJuicePortal on L1. */
63
+ export declare class L1FeeJuicePortalManager {
64
+ private readonly publicClient;
65
+ private readonly walletClient;
66
+ private readonly logger;
67
+ private readonly tokenManager;
68
+ private readonly contract;
69
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
70
+ /** Returns the associated token manager for the L1 ERC20. */
71
+ getTokenManager(): L1TokenManager;
72
+ /**
73
+ * Bridges fee juice from L1 to L2 publicly. Handles L1 ERC20 approvals. Returns once the tx has been mined.
74
+ * @param to - Address to send the tokens to on L2.
75
+ * @param amount - Amount of tokens to send.
76
+ * @param mint - Whether to mint the tokens before sending (only during testing).
77
+ */
78
+ bridgeTokensPublic(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaim>;
79
+ /**
80
+ * 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.
84
+ * @param logger - Logger.
85
+ */
86
+ static new(pxe: PXE, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
87
+ }
88
+ /** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
89
+ export declare class L1ToL2TokenPortalManager {
90
+ protected publicClient: ViemPublicClient;
91
+ protected walletClient: ViemWalletClient;
92
+ protected logger: Logger;
93
+ protected readonly portal: GetContractReturnType<typeof TokenPortalAbi, ViemWalletClient>;
94
+ protected readonly tokenManager: L1TokenManager;
95
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
96
+ /** Returns the token manager for the underlying L1 token. */
97
+ getTokenManager(): L1TokenManager;
98
+ /**
99
+ * Bridges tokens from L1 to L2. Handles token approvals. Returns once the tx has been mined.
100
+ * @param to - Address to send the tokens to on L2.
101
+ * @param amount - Amount of tokens to send.
102
+ * @param mint - Whether to mint the tokens before sending (only during testing).
103
+ */
104
+ bridgeTokensPublic(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaim>;
105
+ /**
106
+ * Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
107
+ * @param to - Address to send the tokens to on L2.
108
+ * @param amount - Amount of tokens to send.
109
+ * @param mint - Whether to mint the tokens before sending (only during testing).
110
+ */
111
+ bridgeTokensPrivate(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaimWithRecipient>;
112
+ private bridgeSetup;
113
+ }
114
+ /** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
115
+ export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
116
+ private readonly outbox;
117
+ constructor(portalAddress: EthAddress, tokenAddress: EthAddress, outboxAddress: EthAddress, publicClient: ViemPublicClient, walletClient: ViemWalletClient, logger: Logger);
118
+ /**
119
+ * Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
120
+ * @param amount - Amount to withdraw.
121
+ * @param recipient - Who will receive the funds.
122
+ * @param blockNumber - L2 block number of the message.
123
+ * @param messageIndex - Index of the message.
124
+ * @param siblingPath - Sibling path of the message.
125
+ */
126
+ withdrawFunds(amount: bigint, recipient: EthAddress, blockNumber: bigint, messageIndex: bigint, siblingPath: SiblingPath<number>): Promise<void>;
127
+ /**
128
+ * Computes the L2 to L1 message leaf for the given parameters.
129
+ * @param amount - Amount to bridge.
130
+ * @param recipient - Recipient on L1.
131
+ * @param l2Bridge - Address of the L2 bridge.
132
+ * @param callerOnL1 - Caller address on L1.
133
+ */
134
+ getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Fr;
135
+ }
136
+ //# sourceMappingURL=portal_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal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rB,QAAQ,EAAE,YAAY,EACtB,UAAU,GAAE,UAA4B,GACvC,EAAE;CAiBN"}
@@ -0,0 +1,286 @@
1
+ import { extractEvent } from '@aztec/ethereum/utils';
2
+ import { sha256ToField } from '@aztec/foundation/crypto';
3
+ import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { Fr } from '@aztec/foundation/fields';
5
+ import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';
6
+ import { computeSecretHash } from '@aztec/stdlib/hash';
7
+ import { getContract, toFunctionSelector } from 'viem';
8
+ /** Stringifies an eth address for logging. */ function stringifyEthAddress(address, name) {
9
+ return name ? `${name} (${address.toString()})` : address.toString();
10
+ }
11
+ /** Generates a pair secret and secret hash */ export async function generateClaimSecret(logger) {
12
+ const secret = Fr.random();
13
+ const secretHash = await computeSecretHash(secret);
14
+ logger?.verbose(`Generated claim secret=${secret.toString()} hash=${secretHash.toString()}`);
15
+ return [
16
+ secret,
17
+ secretHash
18
+ ];
19
+ }
20
+ /** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
21
+ address;
22
+ publicClient;
23
+ walletClient;
24
+ logger;
25
+ contract;
26
+ constructor(/** Address of the ERC20 contract. */ address, publicClient, walletClient, logger){
27
+ this.address = address;
28
+ this.publicClient = publicClient;
29
+ this.walletClient = walletClient;
30
+ this.logger = logger;
31
+ this.contract = getContract({
32
+ address: this.address.toString(),
33
+ abi: TestERC20Abi,
34
+ client: this.walletClient
35
+ });
36
+ }
37
+ /**
38
+ * Returns the balance of the given address.
39
+ * @param address - Address to get the balance of.
40
+ */ async getL1TokenBalance(address) {
41
+ return await this.contract.read.balanceOf([
42
+ address
43
+ ]);
44
+ }
45
+ /**
46
+ * Mints tokens for the given address. Returns once the tx has been mined.
47
+ * @param amount - Amount to mint.
48
+ * @param address - Address to mint the tokens for.
49
+ * @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
+ });
58
+ }
59
+ /**
60
+ * Approves tokens for the given address. Returns once the tx has been mined.
61
+ * @param amount - Amount to approve.
62
+ * @param address - Address to approve the tokens for.
63
+ * @param addressName - Optional name of the address for logging.
64
+ */ async approve(amount, address, addressName = '') {
65
+ this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
66
+ await this.publicClient.waitForTransactionReceipt({
67
+ hash: await this.contract.write.approve([
68
+ address,
69
+ amount
70
+ ])
71
+ });
72
+ }
73
+ }
74
+ /** Helper for interacting with the FeeJuicePortal on L1. */ export class L1FeeJuicePortalManager {
75
+ publicClient;
76
+ walletClient;
77
+ logger;
78
+ tokenManager;
79
+ contract;
80
+ constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
81
+ this.publicClient = publicClient;
82
+ this.walletClient = walletClient;
83
+ this.logger = logger;
84
+ this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
85
+ this.contract = getContract({
86
+ address: portalAddress.toString(),
87
+ abi: FeeJuicePortalAbi,
88
+ client: this.walletClient
89
+ });
90
+ }
91
+ /** Returns the associated token manager for the L1 ERC20. */ getTokenManager() {
92
+ return this.tokenManager;
93
+ }
94
+ /**
95
+ * Bridges fee juice from L1 to L2 publicly. Handles L1 ERC20 approvals. Returns once the tx has been mined.
96
+ * @param to - Address to send the tokens to on L2.
97
+ * @param amount - Amount of tokens to send.
98
+ * @param mint - Whether to mint the tokens before sending (only during testing).
99
+ */ async bridgeTokensPublic(to, amount, mint = false) {
100
+ const [claimSecret, claimSecretHash] = await generateClaimSecret();
101
+ if (mint) {
102
+ await this.tokenManager.mint(amount, this.walletClient.account.address);
103
+ }
104
+ await this.tokenManager.approve(amount, this.contract.address, 'FeeJuice Portal');
105
+ this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
106
+ const args = [
107
+ to.toString(),
108
+ amount,
109
+ claimSecretHash.toString()
110
+ ];
111
+ await this.contract.simulate.depositToAztecPublic(args);
112
+ const txReceipt = await this.publicClient.waitForTransactionReceipt({
113
+ hash: await this.contract.write.depositToAztecPublic(args)
114
+ });
115
+ 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);
117
+ return {
118
+ claimAmount: amount,
119
+ claimSecret,
120
+ claimSecretHash,
121
+ messageHash: log.args.key,
122
+ messageLeafIndex: log.args.index
123
+ };
124
+ }
125
+ /**
126
+ * 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.
130
+ * @param logger - Logger.
131
+ */ static async new(pxe, publicClient, walletClient, logger) {
132
+ const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress } } = await pxe.getNodeInfo();
133
+ if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
134
+ throw new Error('Portal or token not deployed on L1');
135
+ }
136
+ return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, publicClient, walletClient, logger);
137
+ }
138
+ }
139
+ /** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
140
+ publicClient;
141
+ walletClient;
142
+ logger;
143
+ portal;
144
+ tokenManager;
145
+ constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
146
+ this.publicClient = publicClient;
147
+ this.walletClient = walletClient;
148
+ this.logger = logger;
149
+ this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
150
+ this.portal = getContract({
151
+ address: portalAddress.toString(),
152
+ abi: TokenPortalAbi,
153
+ client: this.walletClient
154
+ });
155
+ }
156
+ /** Returns the token manager for the underlying L1 token. */ getTokenManager() {
157
+ return this.tokenManager;
158
+ }
159
+ /**
160
+ * Bridges tokens from L1 to L2. Handles token approvals. Returns once the tx has been mined.
161
+ * @param to - Address to send the tokens to on L2.
162
+ * @param amount - Amount of tokens to send.
163
+ * @param mint - Whether to mint the tokens before sending (only during testing).
164
+ */ async bridgeTokensPublic(to, amount, mint = false) {
165
+ const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
166
+ this.logger.info('Sending L1 tokens to L2 to be claimed publicly');
167
+ const { request } = await this.portal.simulate.depositToAztecPublic([
168
+ to.toString(),
169
+ amount,
170
+ claimSecretHash.toString()
171
+ ]);
172
+ const txReceipt = await this.publicClient.waitForTransactionReceipt({
173
+ hash: await this.walletClient.writeContract(request)
174
+ });
175
+ 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
+ return {
177
+ claimAmount: amount,
178
+ claimSecret,
179
+ claimSecretHash,
180
+ messageHash: log.args.key,
181
+ messageLeafIndex: log.args.index
182
+ };
183
+ }
184
+ /**
185
+ * Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
186
+ * @param to - Address to send the tokens to on L2.
187
+ * @param amount - Amount of tokens to send.
188
+ * @param mint - Whether to mint the tokens before sending (only during testing).
189
+ */ async bridgeTokensPrivate(to, amount, mint = false) {
190
+ const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
191
+ this.logger.info('Sending L1 tokens to L2 to be claimed privately');
192
+ const { request } = await this.portal.simulate.depositToAztecPrivate([
193
+ amount,
194
+ claimSecretHash.toString()
195
+ ]);
196
+ const txReceipt = await this.publicClient.waitForTransactionReceipt({
197
+ hash: await this.walletClient.writeContract(request)
198
+ });
199
+ 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
+ this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
201
+ return {
202
+ claimAmount: amount,
203
+ claimSecret,
204
+ claimSecretHash,
205
+ recipient: to,
206
+ messageHash: log.args.key,
207
+ messageLeafIndex: log.args.index
208
+ };
209
+ }
210
+ async bridgeSetup(amount, mint) {
211
+ if (mint) {
212
+ await this.tokenManager.mint(amount, this.walletClient.account.address);
213
+ }
214
+ await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
215
+ return generateClaimSecret();
216
+ }
217
+ }
218
+ /** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
219
+ outbox;
220
+ constructor(portalAddress, tokenAddress, outboxAddress, publicClient, walletClient, logger){
221
+ super(portalAddress, tokenAddress, publicClient, walletClient, logger);
222
+ this.outbox = getContract({
223
+ address: outboxAddress.toString(),
224
+ abi: OutboxAbi,
225
+ client: walletClient
226
+ });
227
+ }
228
+ /**
229
+ * Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
230
+ * @param amount - Amount to withdraw.
231
+ * @param recipient - Who will receive the funds.
232
+ * @param blockNumber - L2 block number of the message.
233
+ * @param messageIndex - Index of the message.
234
+ * @param siblingPath - Sibling path of the message.
235
+ */ async withdrawFunds(amount, recipient, blockNumber, messageIndex, siblingPath) {
236
+ 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([
238
+ blockNumber,
239
+ messageIndex
240
+ ]);
241
+ if (isConsumedBefore) {
242
+ throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} has already been consumed`);
243
+ }
244
+ // Call function on L1 contract to consume the message
245
+ const { request: withdrawRequest } = await this.portal.simulate.withdraw([
246
+ recipient.toString(),
247
+ amount,
248
+ false,
249
+ BigInt(blockNumber),
250
+ messageIndex,
251
+ siblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
252
+ ]);
253
+ await this.publicClient.waitForTransactionReceipt({
254
+ hash: await this.walletClient.writeContract(withdrawRequest)
255
+ });
256
+ const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlockAndIndex([
257
+ blockNumber,
258
+ messageIndex
259
+ ]);
260
+ if (!isConsumedAfter) {
261
+ throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} not consumed after withdrawal`);
262
+ }
263
+ }
264
+ /**
265
+ * Computes the L2 to L1 message leaf for the given parameters.
266
+ * @param amount - Amount to bridge.
267
+ * @param recipient - Recipient on L1.
268
+ * @param l2Bridge - Address of the L2 bridge.
269
+ * @param callerOnL1 - Caller address on L1.
270
+ */ getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
271
+ const content = sha256ToField([
272
+ Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
273
+ recipient.toBuffer32(),
274
+ new Fr(amount).toBuffer(),
275
+ callerOnL1.toBuffer32()
276
+ ]);
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;
285
+ }
286
+ }
@@ -0,0 +1,6 @@
1
+ export type { FeePaymentMethod } from '../fee/fee_payment_method.js';
2
+ export { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
3
+ export { PrivateFeePaymentMethod } from '../fee/private_fee_payment_method.js';
4
+ export { PublicFeePaymentMethod } from '../fee/public_fee_payment_method.js';
5
+ export { FeeJuicePaymentMethodWithClaim } from '../fee/fee_juice_payment_method_with_claim.js';
6
+ //# sourceMappingURL=fee.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../../src/api/fee.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
2
+ export { PrivateFeePaymentMethod } from '../fee/private_fee_payment_method.js';
3
+ export { PublicFeePaymentMethod } from '../fee/public_fee_payment_method.js';
4
+ export { FeeJuicePaymentMethodWithClaim } from '../fee/fee_juice_payment_method_with_claim.js';
@@ -0,0 +1,2 @@
1
+ export { Point, Fr, Fq, GrumpkinScalar } from '@aztec/foundation/fields';
2
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/api/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export { Point, Fr, Fq, GrumpkinScalar } from '@aztec/foundation/fields';
@@ -0,0 +1,2 @@
1
+ export type { PXE } from '@aztec/stdlib/interfaces/client';
2
+ //# sourceMappingURL=pxe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pxe.d.ts","sourceRoot":"","sources":["../../../src/api/interfaces/pxe.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ export { createLogger, type Logger } from '@aztec/foundation/log';
2
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/api/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export { createLogger } from '@aztec/foundation/log';
@@ -0,0 +1,2 @@
1
+ export { LogId } from '@aztec/stdlib/logs';
2
+ //# sourceMappingURL=log_id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log_id.d.ts","sourceRoot":"","sources":["../../src/api/log_id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export { LogId } from '@aztec/stdlib/logs';
@@ -0,0 +1,2 @@
1
+ export { TxHash } from '@aztec/stdlib/tx';
2
+ //# sourceMappingURL=tx_hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tx_hash.d.ts","sourceRoot":"","sources":["../../src/api/tx_hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export { TxHash } from '@aztec/stdlib/tx';
@@ -0,0 +1,2 @@
1
+ export { AccountWallet, AccountWalletWithSecretKey as AccountWalletWithSecretKey, SignerlessWallet, type Wallet, getWallet, } from '../wallet/index.js';
2
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,0BAA0B,IAAI,0BAA0B,EACxD,gBAAgB,EAChB,KAAK,MAAM,EACX,SAAS,GACV,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export { AccountWallet, AccountWalletWithSecretKey as AccountWalletWithSecretKey, SignerlessWallet, getWallet } from '../wallet/index.js';
@@ -0,0 +1,98 @@
1
+ import type { Fr } from '@aztec/foundation/fields';
2
+ import { GasSettings } from '@aztec/stdlib/gas';
3
+ import type { Capsule, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib/tx';
4
+ import type { Wallet } from '../account/wallet.js';
5
+ import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
6
+ import type { FeeOptions, UserFeeOptions } from '../entrypoint/payload.js';
7
+ import { ProvenTx } from './proven_tx.js';
8
+ import { SentTx } from './sent_tx.js';
9
+ /**
10
+ * Represents options for calling a (constrained) function in a contract.
11
+ * Allows the user to specify the sender address and nonce for a transaction.
12
+ */
13
+ export type SendMethodOptions = {
14
+ /** Wether to skip the simulation of the public part of the transaction. */
15
+ skipPublicSimulation?: boolean;
16
+ /** The fee options for the transaction. */
17
+ fee?: UserFeeOptions;
18
+ /** Custom nonce to inject into the app payload of the transaction. Useful when trying to cancel an ongoing transaction by creating a new one with a higher fee */
19
+ nonce?: Fr;
20
+ /** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
21
+ cancellable?: boolean;
22
+ };
23
+ /**
24
+ * Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
25
+ * Implements the sequence create/simulate/send.
26
+ */
27
+ export declare abstract class BaseContractInteraction {
28
+ protected wallet: Wallet;
29
+ protected log: import("@aztec/foundation/log").Logger;
30
+ private capsules;
31
+ constructor(wallet: Wallet);
32
+ /**
33
+ * Create a transaction execution request ready to be simulated.
34
+ * @param options - An optional object containing additional configuration for the transaction.
35
+ * @returns A transaction execution request.
36
+ */
37
+ abstract create(options?: SendMethodOptions): Promise<TxExecutionRequest>;
38
+ /**
39
+ * Creates a transaction execution request, simulates and proves it. Differs from .prove in
40
+ * that its result does not include the wallet nor the composed tx object, but only the proving result.
41
+ * This object can then be used to either create a ProvenTx ready to be sent, or directly send the transaction.
42
+ * @param options - optional arguments to be used in the creation of the transaction
43
+ * @returns The proving result.
44
+ */
45
+ protected proveInternal(options?: SendMethodOptions): Promise<TxProvingResult>;
46
+ /**
47
+ * Proves a transaction execution request and returns a tx object ready to be sent.
48
+ * @param options - optional arguments to be used in the creation of the transaction
49
+ * @returns The resulting transaction
50
+ */
51
+ prove(options?: SendMethodOptions): Promise<ProvenTx>;
52
+ /**
53
+ * Sends a transaction to the contract function with the specified options.
54
+ * This function throws an error if called on an unconstrained function.
55
+ * It creates and signs the transaction if necessary, and returns a SentTx instance,
56
+ * which can be used to track the transaction status, receipt, and events.
57
+ * @param options - An optional object containing 'from' property representing
58
+ * the AztecAddress of the sender. If not provided, the default address is used.
59
+ * @returns A SentTx instance for tracking the transaction status and information.
60
+ */
61
+ send(options?: SendMethodOptions): SentTx;
62
+ /**
63
+ * Estimates gas for a given tx request and returns gas limits for it.
64
+ * @param opts - Options.
65
+ * @param pad - Percentage to pad the suggested gas limits by, if empty, defaults to 10%.
66
+ * @returns Gas limits.
67
+ */
68
+ estimateGas(opts?: Omit<SendMethodOptions, 'estimateGas' | 'skipPublicSimulation'>): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>>;
69
+ /**
70
+ * Returns default fee options based on the user opts without running a simulation for gas estimation.
71
+ * @param fee - User-provided fee options.
72
+ */
73
+ protected getDefaultFeeOptions(fee: UserFeeOptions | undefined): Promise<FeeOptions>;
74
+ /**
75
+ * Return fee options based on the user opts, estimating tx gas if needed.
76
+ * @param request - Request to execute for this interaction.
77
+ * @param pad - Percentage to pad the suggested gas limits by, as decimal (e.g., 0.10 for 10%).
78
+ * @returns Fee options for the actual transaction.
79
+ */
80
+ protected getFeeOptions(request: Omit<ExecutionRequestInit, 'fee'> & {
81
+ fee?: UserFeeOptions;
82
+ }): Promise<FeeOptions>;
83
+ /**
84
+ * Add data passed to the oracle calls during this contract interaction.
85
+ * @param capsule - Data passed to oracle calls.
86
+ */
87
+ addCapsule(capsule: Capsule): void;
88
+ /**
89
+ * Add data passed to the oracle calls during this contract interaction.
90
+ * @param capsules - Data passed to oracle calls.
91
+ */
92
+ addCapsules(capsules: Capsule[]): void;
93
+ /**
94
+ * Return all capsules added for this function interaction.
95
+ */
96
+ getCapsules(): Capsule[];
97
+ }
98
+ //# sourceMappingURL=base_contract_interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base_contract_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/base_contract_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2EAA2E;IAC3E,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,2CAA2C;IAC3C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,kKAAkK;IAClK,KAAK,CAAC,EAAE,EAAE,CAAC;IACX,qIAAqI;IACrI,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,8BAAsB,uBAAuB;IAK/B,SAAS,CAAC,MAAM,EAAE,MAAM;IAJpC,SAAS,CAAC,GAAG,yCAAgD;IAE7D,OAAO,CAAC,QAAQ,CAAiB;gBAEX,MAAM,EAAE,MAAM;IAEpC;;;;OAIG;aACa,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,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