@aztec/aztec.js 0.0.1-commit.b655e406 → 0.0.1-commit.c31f2472

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 (246) hide show
  1. package/dest/account/account.d.ts +26 -42
  2. package/dest/account/account.d.ts.map +1 -1
  3. package/dest/account/account.js +19 -47
  4. package/dest/account/account_contract.d.ts +9 -10
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +20 -9
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/account_with_secret_key.js +21 -4
  9. package/dest/account/index.d.ts +4 -3
  10. package/dest/account/index.d.ts.map +1 -1
  11. package/dest/account/index.js +2 -0
  12. package/dest/account/signerless_account.d.ts +7 -9
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/abi.d.ts +1 -1
  16. package/dest/api/account.d.ts +3 -4
  17. package/dest/api/account.d.ts.map +1 -1
  18. package/dest/api/account.js +2 -3
  19. package/dest/api/addresses.d.ts +1 -1
  20. package/dest/api/authorization.d.ts +2 -2
  21. package/dest/api/authorization.d.ts.map +1 -1
  22. package/dest/api/authorization.js +1 -1
  23. package/dest/api/block.d.ts +1 -1
  24. package/dest/api/contract.d.ts +17 -11
  25. package/dest/api/contract.d.ts.map +1 -1
  26. package/dest/api/contract.js +15 -9
  27. package/dest/api/crypto.d.ts +1 -1
  28. package/dest/api/deployment.d.ts +1 -1
  29. package/dest/api/eth_address.d.ts +1 -1
  30. package/dest/api/ethereum.d.ts +1 -1
  31. package/dest/api/events.d.ts +1 -1
  32. package/dest/api/fee.d.ts +1 -1
  33. package/dest/api/fee_testing.d.ts +1 -1
  34. package/dest/api/fields.d.ts +3 -2
  35. package/dest/api/fields.d.ts.map +1 -1
  36. package/dest/api/fields.js +2 -1
  37. package/dest/api/keys.d.ts +1 -1
  38. package/dest/api/log.d.ts +1 -1
  39. package/dest/api/messaging.d.ts +1 -1
  40. package/dest/api/node.d.ts +8 -4
  41. package/dest/api/node.d.ts.map +1 -1
  42. package/dest/api/node.js +7 -3
  43. package/dest/api/note.d.ts +2 -2
  44. package/dest/api/note.d.ts.map +1 -1
  45. package/dest/api/note.js +1 -1
  46. package/dest/api/protocol.d.ts +7 -1
  47. package/dest/api/protocol.d.ts.map +1 -1
  48. package/dest/api/protocol.js +6 -0
  49. package/dest/api/trees.d.ts +1 -1
  50. package/dest/api/tx.d.ts +2 -2
  51. package/dest/api/tx.d.ts.map +1 -1
  52. package/dest/api/tx.js +1 -1
  53. package/dest/api/utils.d.ts +1 -1
  54. package/dest/api/wallet.d.ts +2 -3
  55. package/dest/api/wallet.d.ts.map +1 -1
  56. package/dest/api/wallet.js +1 -2
  57. package/dest/authorization/call_authorization_request.d.ts +2 -2
  58. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  59. package/dest/contract/base_contract_interaction.d.ts +8 -11
  60. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  61. package/dest/contract/base_contract_interaction.js +5 -17
  62. package/dest/contract/batch_call.d.ts +8 -9
  63. package/dest/contract/batch_call.d.ts.map +1 -1
  64. package/dest/contract/batch_call.js +54 -34
  65. package/dest/contract/checker.d.ts +1 -1
  66. package/dest/contract/contract.d.ts +2 -2
  67. package/dest/contract/contract.d.ts.map +1 -1
  68. package/dest/contract/contract.js +4 -5
  69. package/dest/contract/contract_base.d.ts +6 -10
  70. package/dest/contract/contract_base.d.ts.map +1 -1
  71. package/dest/contract/contract_base.js +5 -12
  72. package/dest/contract/contract_function_interaction.d.ts +3 -3
  73. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  74. package/dest/contract/contract_function_interaction.js +9 -6
  75. package/dest/contract/deploy_method.d.ts +71 -23
  76. package/dest/contract/deploy_method.d.ts.map +1 -1
  77. package/dest/contract/deploy_method.js +49 -29
  78. package/dest/contract/get_gas_limits.d.ts +1 -1
  79. package/dest/contract/interaction_options.d.ts +44 -7
  80. package/dest/contract/interaction_options.d.ts.map +1 -1
  81. package/dest/contract/interaction_options.js +12 -11
  82. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  83. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  84. package/dest/contract/protocol_contracts/auth-registry.js +963 -0
  85. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
  86. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  87. package/dest/contract/protocol_contracts/contract-class-registry.js +784 -0
  88. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
  89. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  90. package/dest/contract/protocol_contracts/contract-instance-registry.js +866 -0
  91. package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
  92. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  93. package/dest/contract/protocol_contracts/fee-juice.js +827 -0
  94. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  95. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  96. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +563 -0
  97. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  98. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  99. package/dest/contract/protocol_contracts/public-checks.js +579 -0
  100. package/dest/contract/wait_for_proven.d.ts +2 -2
  101. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  102. package/dest/contract/wait_for_proven.js +1 -1
  103. package/dest/contract/wait_opts.d.ts +16 -0
  104. package/dest/contract/wait_opts.d.ts.map +1 -0
  105. package/dest/contract/wait_opts.js +5 -0
  106. package/dest/deployment/broadcast_function.d.ts +1 -1
  107. package/dest/deployment/broadcast_function.js +4 -4
  108. package/dest/deployment/contract_deployer.d.ts +1 -1
  109. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  110. package/dest/deployment/contract_deployer.js +1 -1
  111. package/dest/deployment/publish_class.d.ts +1 -1
  112. package/dest/deployment/publish_class.js +3 -3
  113. package/dest/deployment/publish_instance.d.ts +2 -2
  114. package/dest/deployment/publish_instance.d.ts.map +1 -1
  115. package/dest/deployment/publish_instance.js +3 -3
  116. package/dest/ethereum/portal_manager.d.ts +7 -6
  117. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  118. package/dest/ethereum/portal_manager.js +48 -22
  119. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
  120. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  121. package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
  122. package/dest/fee/fee_payment_method.d.ts +2 -2
  123. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  124. package/dest/fee/private_fee_payment_method.d.ts +2 -2
  125. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  126. package/dest/fee/private_fee_payment_method.js +4 -4
  127. package/dest/fee/public_fee_payment_method.d.ts +2 -2
  128. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  129. package/dest/fee/public_fee_payment_method.js +4 -4
  130. package/dest/fee/sponsored_fee_payment.d.ts +2 -2
  131. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  132. package/dest/fee/sponsored_fee_payment.js +2 -2
  133. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  134. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  135. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  136. package/dest/utils/abi_types.d.ts +2 -2
  137. package/dest/utils/abi_types.d.ts.map +1 -1
  138. package/dest/utils/authwit.d.ts +14 -12
  139. package/dest/utils/authwit.d.ts.map +1 -1
  140. package/dest/utils/authwit.js +27 -20
  141. package/dest/utils/cross_chain.d.ts +2 -2
  142. package/dest/utils/cross_chain.d.ts.map +1 -1
  143. package/dest/utils/fee_juice.d.ts +2 -2
  144. package/dest/utils/fee_juice.js +2 -2
  145. package/dest/utils/field_compressed_string.d.ts +1 -1
  146. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  147. package/dest/utils/field_compressed_string.js +1 -1
  148. package/dest/utils/node.d.ts +13 -2
  149. package/dest/utils/node.d.ts.map +1 -1
  150. package/dest/utils/node.js +46 -0
  151. package/dest/utils/pub_key.d.ts +2 -2
  152. package/dest/utils/pub_key.d.ts.map +1 -1
  153. package/dest/utils/pub_key.js +1 -1
  154. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
  155. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  156. package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
  157. package/dest/wallet/account_manager.d.ts +3 -9
  158. package/dest/wallet/account_manager.d.ts.map +1 -1
  159. package/dest/wallet/account_manager.js +6 -12
  160. package/dest/wallet/deploy_account_method.d.ts +37 -9
  161. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  162. package/dest/wallet/deploy_account_method.js +9 -7
  163. package/dest/wallet/index.d.ts +1 -2
  164. package/dest/wallet/index.d.ts.map +1 -1
  165. package/dest/wallet/index.js +0 -1
  166. package/dest/wallet/wallet.d.ts +323 -1504
  167. package/dest/wallet/wallet.d.ts.map +1 -1
  168. package/dest/wallet/wallet.js +85 -115
  169. package/package.json +16 -13
  170. package/src/account/account.ts +35 -60
  171. package/src/account/account_contract.ts +7 -8
  172. package/src/account/account_with_secret_key.ts +34 -9
  173. package/src/account/index.ts +3 -2
  174. package/src/account/signerless_account.ts +15 -15
  175. package/src/api/account.ts +10 -3
  176. package/src/api/authorization.ts +1 -0
  177. package/src/api/contract.ts +24 -8
  178. package/src/api/fields.ts +2 -1
  179. package/src/api/node.ts +7 -3
  180. package/src/api/note.ts +1 -1
  181. package/src/api/protocol.ts +7 -0
  182. package/src/api/tx.ts +4 -0
  183. package/src/api/wallet.ts +10 -9
  184. package/src/authorization/call_authorization_request.ts +1 -1
  185. package/src/contract/base_contract_interaction.ts +27 -16
  186. package/src/contract/batch_call.ts +67 -48
  187. package/src/contract/contract.ts +7 -5
  188. package/src/contract/contract_base.ts +5 -15
  189. package/src/contract/contract_function_interaction.ts +10 -11
  190. package/src/contract/deploy_method.ts +134 -40
  191. package/src/contract/interaction_options.ts +52 -13
  192. package/src/contract/protocol_contracts/auth-registry.ts +545 -0
  193. package/src/contract/protocol_contracts/contract-class-registry.ts +433 -0
  194. package/src/contract/protocol_contracts/contract-instance-registry.ts +495 -0
  195. package/src/contract/protocol_contracts/fee-juice.ts +457 -0
  196. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +329 -0
  197. package/src/contract/protocol_contracts/public-checks.ts +315 -0
  198. package/src/contract/wait_for_proven.ts +1 -1
  199. package/src/contract/wait_opts.ts +21 -0
  200. package/src/deployment/broadcast_function.ts +4 -4
  201. package/src/deployment/contract_deployer.ts +3 -2
  202. package/src/deployment/publish_class.ts +3 -3
  203. package/src/deployment/publish_instance.ts +3 -6
  204. package/src/ethereum/portal_manager.ts +65 -34
  205. package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
  206. package/src/fee/fee_payment_method.ts +1 -1
  207. package/src/fee/private_fee_payment_method.ts +5 -3
  208. package/src/fee/public_fee_payment_method.ts +5 -3
  209. package/src/fee/sponsored_fee_payment.ts +3 -1
  210. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  211. package/src/utils/abi_types.ts +1 -1
  212. package/src/utils/authwit.ts +40 -22
  213. package/src/utils/cross_chain.ts +1 -1
  214. package/src/utils/fee_juice.ts +2 -2
  215. package/src/utils/field_compressed_string.ts +1 -1
  216. package/src/utils/node.ts +62 -0
  217. package/src/utils/pub_key.ts +2 -2
  218. package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
  219. package/src/wallet/account_manager.ts +7 -15
  220. package/src/wallet/deploy_account_method.ts +41 -16
  221. package/src/wallet/index.ts +0 -1
  222. package/src/wallet/wallet.ts +207 -152
  223. package/dest/account/interface.d.ts +0 -19
  224. package/dest/account/interface.d.ts.map +0 -1
  225. package/dest/account/interface.js +0 -5
  226. package/dest/contract/deploy_sent_tx.d.ts +0 -43
  227. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  228. package/dest/contract/deploy_sent_tx.js +0 -40
  229. package/dest/contract/protocol_contracts.d.ts +0 -9
  230. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  231. package/dest/contract/protocol_contracts.js +0 -26
  232. package/dest/contract/sent_tx.d.ts +0 -51
  233. package/dest/contract/sent_tx.d.ts.map +0 -1
  234. package/dest/contract/sent_tx.js +0 -90
  235. package/dest/contract/unsafe_contract.d.ts +0 -15
  236. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  237. package/dest/contract/unsafe_contract.js +0 -6
  238. package/dest/wallet/base_wallet.d.ts +0 -91
  239. package/dest/wallet/base_wallet.d.ts.map +0 -1
  240. package/dest/wallet/base_wallet.js +0 -238
  241. package/src/account/interface.ts +0 -25
  242. package/src/contract/deploy_sent_tx.ts +0 -68
  243. package/src/contract/protocol_contracts.ts +0 -35
  244. package/src/contract/sent_tx.ts +0 -130
  245. package/src/contract/unsafe_contract.ts +0 -19
  246. package/src/wallet/base_wallet.ts +0 -350
@@ -1,26 +0,0 @@
1
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
- import { UnsafeContract } from './unsafe_contract.js';
3
- /** Returns a Contract wrapper for the contract class registry. */ export async function getClassRegistryContract(wallet) {
4
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
5
- if (!contractInstance) {
6
- throw new Error("ContractClassRegistry is not registered in this wallet's instance");
7
- }
8
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
9
- return new UnsafeContract(contractInstance, artifact, wallet);
10
- }
11
- /** Returns a Contract wrapper for the contract instance registry. */ export async function getInstanceRegistryContract(wallet) {
12
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
13
- if (!contractInstance) {
14
- throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
15
- }
16
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
17
- return new UnsafeContract(contractInstance, artifact, wallet);
18
- }
19
- /** Returns a Contract wrapper for the fee juice contract */ export async function getFeeJuice(wallet) {
20
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
21
- if (!contractInstance) {
22
- throw new Error("FeeJuice is not registered in this wallet's instance");
23
- }
24
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
25
- return new UnsafeContract(contractInstance, artifact, wallet);
26
- }
@@ -1,51 +0,0 @@
1
- import type { FieldsOf } from '@aztec/foundation/types';
2
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
- import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
4
- import type { Wallet } from '../wallet/wallet.js';
5
- /** Options related to waiting for a tx. */
6
- export type WaitOpts = {
7
- /** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
8
- ignoreDroppedReceiptsFor?: number;
9
- /** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
10
- timeout?: number;
11
- /** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
12
- interval?: number;
13
- /** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
14
- dontThrowOnRevert?: boolean;
15
- };
16
- export declare const DefaultWaitOpts: WaitOpts;
17
- /**
18
- * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
19
- * its hash, receipt, and mining status.
20
- */
21
- export declare class SentTx {
22
- protected walletOrNode: Wallet | AztecNode;
23
- protected sendTxPromise: Promise<void>;
24
- protected sendTxError?: Error;
25
- protected txHash?: TxHash;
26
- constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
27
- /**
28
- * Retrieves the transaction hash of the SentTx instance.
29
- * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
30
- *
31
- * @returns A promise that resolves to the transaction hash of the SentTx instance.
32
- * TODO(#7717): Don't throw here.
33
- */
34
- getTxHash(): Promise<TxHash>;
35
- /**
36
- * Retrieve the transaction receipt associated with the current SentTx instance.
37
- * The function fetches the transaction hash using 'getTxHash' and then queries
38
- * the PXE to get the corresponding transaction receipt.
39
- *
40
- * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
41
- */
42
- getReceipt(): Promise<TxReceipt>;
43
- /**
44
- * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
45
- * @param opts - Options for configuring the waiting for the tx to be mined.
46
- * @returns The transaction receipt.
47
- */
48
- wait(opts?: WaitOpts): Promise<FieldsOf<TxReceipt>>;
49
- protected waitForReceipt(opts?: WaitOpts): Promise<TxReceipt>;
50
- }
51
- //# sourceMappingURL=sent_tx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,gKAAgK;IAChK,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAMf,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAL5C,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGd,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAgB/B;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAazC;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IAK7C;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;cAUhD,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CA6BpE"}
@@ -1,90 +0,0 @@
1
- import { promiseWithResolvers } from '@aztec/foundation/promise';
2
- import { retryUntil } from '@aztec/foundation/retry';
3
- import { TxStatus } from '@aztec/stdlib/tx';
4
- export const DefaultWaitOpts = {
5
- ignoreDroppedReceiptsFor: 5,
6
- timeout: 60,
7
- interval: 1
8
- };
9
- /**
10
- * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
11
- * its hash, receipt, and mining status.
12
- */ export class SentTx {
13
- walletOrNode;
14
- sendTxPromise;
15
- sendTxError;
16
- txHash;
17
- constructor(walletOrNode, sendTx){
18
- this.walletOrNode = walletOrNode;
19
- const { promise, resolve } = promiseWithResolvers();
20
- this.sendTxPromise = promise;
21
- sendTx().then((txHash)=>{
22
- this.txHash = txHash;
23
- resolve();
24
- }).catch((err)=>{
25
- this.sendTxError = err;
26
- // Calling resolve instead of reject here because we want to throw the error when getTxHash is called.
27
- resolve();
28
- });
29
- }
30
- /**
31
- * Retrieves the transaction hash of the SentTx instance.
32
- * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
33
- *
34
- * @returns A promise that resolves to the transaction hash of the SentTx instance.
35
- * TODO(#7717): Don't throw here.
36
- */ async getTxHash() {
37
- // Make sure sendTx has been resolved, which can be triggered when it returns a txHash or when it throws an error.
38
- await this.sendTxPromise;
39
- // If sendTx threw an error, throw it.
40
- if (this.sendTxError) {
41
- throw this.sendTxError;
42
- }
43
- // sendTx returned a txHash if it's been resolved and no error was set.
44
- return Promise.resolve(this.txHash);
45
- }
46
- /**
47
- * Retrieve the transaction receipt associated with the current SentTx instance.
48
- * The function fetches the transaction hash using 'getTxHash' and then queries
49
- * the PXE to get the corresponding transaction receipt.
50
- *
51
- * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
52
- */ async getReceipt() {
53
- const txHash = await this.getTxHash();
54
- return await this.walletOrNode.getTxReceipt(txHash);
55
- }
56
- /**
57
- * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
58
- * @param opts - Options for configuring the waiting for the tx to be mined.
59
- * @returns The transaction receipt.
60
- */ async wait(opts) {
61
- const receipt = await this.waitForReceipt(opts);
62
- if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) {
63
- throw new Error(`Transaction ${(await this.getTxHash()).toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
64
- }
65
- return receipt;
66
- }
67
- async waitForReceipt(opts) {
68
- const txHash = await this.getTxHash();
69
- const startTime = Date.now();
70
- const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
71
- return await retryUntil(async ()=>{
72
- const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
73
- // If receipt is not yet available, try again
74
- if (txReceipt.status === TxStatus.PENDING) {
75
- return undefined;
76
- }
77
- // If the tx was "dropped", either return it or ignore based on timing.
78
- // 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.
79
- // If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
80
- if (txReceipt.status === TxStatus.DROPPED) {
81
- const elapsedSeconds = (Date.now() - startTime) / 1000;
82
- if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
83
- return txReceipt;
84
- }
85
- return undefined;
86
- }
87
- return txReceipt;
88
- }, 'isMined', opts?.timeout ?? DefaultWaitOpts.timeout, opts?.interval ?? DefaultWaitOpts.interval);
89
- }
90
- }
@@ -1,15 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/stdlib/abi';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { Wallet } from '../wallet/wallet.js';
4
- import { ContractBase } from './contract_base.js';
5
- /** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
6
- export declare class UnsafeContract extends ContractBase {
7
- constructor(
8
- /** The deployed contract instance definition. */
9
- instance: ContractInstanceWithAddress,
10
- /** The Application Binary Interface for the contract. */
11
- artifact: ContractArtifact,
12
- /** The wallet used for interacting with this contract. */
13
- wallet: Wallet);
14
- }
15
- //# sourceMappingURL=unsafe_contract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsafe_contract.d.ts","sourceRoot":"","sources":["../../src/contract/unsafe_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,iHAAiH;AACjH,qBAAa,cAAe,SAAQ,YAAY;;IAE5C,iDAAiD;IACjD,QAAQ,EAAE,2BAA2B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM;CAIjB"}
@@ -1,6 +0,0 @@
1
- import { ContractBase } from './contract_base.js';
2
- /** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */ export class UnsafeContract extends ContractBase {
3
- constructor(/** The deployed contract instance definition. */ instance, /** The Application Binary Interface for the contract. */ artifact, /** The wallet used for interacting with this contract. */ wallet){
4
- super(instance, artifact, wallet);
5
- }
6
- }
@@ -1,91 +0,0 @@
1
- import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
2
- import type { ChainInfo } from '@aztec/entrypoints/interfaces';
3
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import type { ContractArtifact, EventMetadataDefinition } from '@aztec/stdlib/abi';
6
- import type { AuthWitness } from '@aztec/stdlib/auth-witness';
7
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import { type ContractClassMetadata, type ContractInstanceWithAddress, type ContractInstantiationData, type ContractMetadata } from '@aztec/stdlib/contract';
9
- import { GasSettings } from '@aztec/stdlib/gas';
10
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
11
- import type { TxExecutionRequest, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
12
- import type { Account } from '../account/account.js';
13
- import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
14
- import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
15
- import type { Aliased, BatchResults, BatchableMethods, BatchedMethod, ContractInstanceAndArtifact, ProfileOptions, SendOptions, SimulateOptions, UserFeeOptions, Wallet } from './wallet.js';
16
- /**
17
- * Options to configure fee payment for a transaction
18
- */
19
- export type FeeOptions = {
20
- /**
21
- * A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
22
- * doesn't already include one
23
- */
24
- walletFeePaymentMethod?: FeePaymentMethod;
25
- /** Configuration options for the account to properly handle the selected fee payment method */
26
- accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
27
- /** The gas settings to use for the transaction */
28
- gasSettings: GasSettings;
29
- };
30
- /**
31
- * A base class for Wallet implementations
32
- */
33
- export declare abstract class BaseWallet implements Wallet {
34
- protected readonly pxe: any;
35
- protected readonly aztecNode: AztecNode;
36
- protected log: import("@aztec/foundation/log").Logger;
37
- protected baseFeePadding: number;
38
- protected cancellableTransactions: boolean;
39
- protected constructor(pxe: any, aztecNode: AztecNode);
40
- protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
41
- abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
42
- /**
43
- * Returns the list of aliased contacts associated with the wallet.
44
- * This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
45
- * - Senders: Addresses we check during synching in case they sent us notes,
46
- * - Contacts: more general concept akin to a phone's contact list.
47
- * @returns The aliased collection of AztecAddresses that form this wallet's address book
48
- */
49
- getAddressBook(): Promise<Aliased<AztecAddress>[]>;
50
- getChainInfo(): Promise<ChainInfo>;
51
- protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
52
- createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent): Promise<AuthWitness>;
53
- batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
54
- /**
55
- * Returns default values for the transaction fee options
56
- * if they were omitted by the user.
57
- * @param from - The address where the transaction is being sent from
58
- * @param userFeeOptions - User-provided fee options, which might be incomplete
59
- * @returns - Populated fee options that can be used to create a transaction execution request
60
- */
61
- protected getDefaultFeeOptions(from: AztecAddress, userFeeOptions?: UserFeeOptions): Promise<FeeOptions>;
62
- /**
63
- * Returns unreasonably high gas limits in order to execute a simulation
64
- * with the goal of estimating its gas cost. It will otherwise try to respect
65
- * the user-specified fee options, filling the gaps with default values as needed.
66
- * @param from - The address where the transaction is being sent from
67
- * @param userFeeOptions - User-provided fee options to use as a basis for the fully populated `FeeOptions` type.
68
- */
69
- protected getFeeOptionsForGasEstimation(from: AztecAddress, userFeeOptions?: UserFeeOptions): Promise<{
70
- gasSettings: GasSettings;
71
- /**
72
- * A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
73
- * doesn't already include one
74
- */
75
- walletFeePaymentMethod?: FeePaymentMethod;
76
- /** Configuration options for the account to properly handle the selected fee payment method */
77
- accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
78
- }>;
79
- registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
80
- registerContract(instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
81
- simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
82
- profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
83
- sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
84
- protected contextualizeError(err: Error, ...context: string[]): Error;
85
- simulateUtility(functionName: string, args: any[], to: AztecAddress, authwits?: AuthWitness[], from?: AztecAddress): Promise<UtilitySimulationResult>;
86
- getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
87
- getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
88
- getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
89
- getPrivateEvents<T>(contractAddress: AztecAddress, event: EventMetadataDefinition, from: number, limit: number, recipients?: AztecAddress[]): Promise<T[]>;
90
- }
91
- //# sourceMappingURL=base_wallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/base_wallet.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AACtF,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,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@@
1
- import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
2
- import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
3
- import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import { createLogger } from '@aztec/foundation/log';
6
- import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
7
- import { SimulationError } from '@aztec/stdlib/errors';
8
- import { Gas, GasSettings } from '@aztec/stdlib/gas';
9
- import { inspect } from 'util';
10
- /**
11
- * A base class for Wallet implementations
12
- */ export class BaseWallet {
13
- pxe;
14
- aztecNode;
15
- log;
16
- baseFeePadding;
17
- cancellableTransactions;
18
- // Protected because we want to force wallets to instantiate their own PXE.
19
- constructor(// TODO: We cannot type here pxe because we cannot import that package as that would result in a circular
20
- // dependency. This will eventually get resolved by the introduction of @aztec/wallet-sdk package.
21
- pxe, aztecNode){
22
- this.pxe = pxe;
23
- this.aztecNode = aztecNode;
24
- this.log = createLogger('aztecjs:base_wallet');
25
- this.baseFeePadding = 0.5;
26
- this.cancellableTransactions = false;
27
- }
28
- /**
29
- * Returns the list of aliased contacts associated with the wallet.
30
- * This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
31
- * - Senders: Addresses we check during synching in case they sent us notes,
32
- * - Contacts: more general concept akin to a phone's contact list.
33
- * @returns The aliased collection of AztecAddresses that form this wallet's address book
34
- */ async getAddressBook() {
35
- const senders = await this.pxe.getSenders();
36
- return senders.map((sender)=>({
37
- item: sender,
38
- alias: ''
39
- }));
40
- }
41
- async getChainInfo() {
42
- const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
43
- return {
44
- chainId: new Fr(l1ChainId),
45
- version: new Fr(rollupVersion)
46
- };
47
- }
48
- async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
49
- const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
50
- const executionOptions = {
51
- txNonce: Fr.random(),
52
- cancellable: this.cancellableTransactions,
53
- feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
54
- };
55
- const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
56
- feeExecutionPayload,
57
- executionPayload
58
- ]) : executionPayload;
59
- const fromAccount = await this.getAccountFromAddress(from);
60
- return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
61
- }
62
- async createAuthWit(from, messageHashOrIntent) {
63
- const account = await this.getAccountFromAddress(from);
64
- return account.createAuthWit(messageHashOrIntent);
65
- }
66
- async batch(methods) {
67
- const results = [];
68
- for (const method of methods){
69
- const { name, args } = method;
70
- // Type safety is guaranteed by the BatchedMethod type, which ensures that:
71
- // 1. `name` is a valid batchable method name
72
- // 2. `args` matches the parameter types of that specific method
73
- // 3. The return type is correctly mapped in BatchResults<T>
74
- // We use dynamic dispatch here for simplicity, but the types are enforced at the call site.
75
- const fn = this[name];
76
- const result = await fn.apply(this, args);
77
- // Wrap result with method name for discriminated union deserialization
78
- results.push({
79
- name,
80
- result
81
- });
82
- }
83
- return results;
84
- }
85
- /**
86
- * Returns default values for the transaction fee options
87
- * if they were omitted by the user.
88
- * @param from - The address where the transaction is being sent from
89
- * @param userFeeOptions - User-provided fee options, which might be incomplete
90
- * @returns - Populated fee options that can be used to create a transaction execution request
91
- */ async getDefaultFeeOptions(from, userFeeOptions) {
92
- const maxFeesPerGas = userFeeOptions?.gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentBaseFees()).mul(1 + this.baseFeePadding);
93
- let accountFeePaymentMethodOptions;
94
- // The transaction does not include a fee payment method, so we set the flag
95
- // for the account to use its fee juice balance
96
- if (!userFeeOptions?.embeddedPaymentMethodFeePayer) {
97
- accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
98
- } else {
99
- // The transaction includes fee payment method, so we check if we are the fee payer for it
100
- // (this can only happen if the embedded payment method is FeeJuiceWithClaim)
101
- accountFeePaymentMethodOptions = from.equals(userFeeOptions.embeddedPaymentMethodFeePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
102
- }
103
- const gasSettings = GasSettings.default({
104
- ...userFeeOptions?.gasSettings,
105
- maxFeesPerGas
106
- });
107
- this.log.debug(`Using L2 gas settings`, gasSettings);
108
- return {
109
- gasSettings,
110
- walletFeePaymentMethod: undefined,
111
- accountFeePaymentMethodOptions
112
- };
113
- }
114
- /**
115
- * Returns unreasonably high gas limits in order to execute a simulation
116
- * with the goal of estimating its gas cost. It will otherwise try to respect
117
- * the user-specified fee options, filling the gaps with default values as needed.
118
- * @param from - The address where the transaction is being sent from
119
- * @param userFeeOptions - User-provided fee options to use as a basis for the fully populated `FeeOptions` type.
120
- */ async getFeeOptionsForGasEstimation(from, userFeeOptions) {
121
- const defaultFeeOptions = await this.getDefaultFeeOptions(from, userFeeOptions);
122
- const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
123
- // Use unrealistically high gas limits for estimation to avoid running out of gas.
124
- // They will be tuned down after the simulation.
125
- const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
126
- return {
127
- ...defaultFeeOptions,
128
- gasSettings: gasSettingsForEstimation
129
- };
130
- }
131
- registerSender(address, _alias = '') {
132
- return this.pxe.registerSender(address);
133
- }
134
- async registerContract(instanceData, artifact, secretKey) {
135
- /** Determines if the provided instance data is already a contract instance with an address. */ function isInstanceWithAddress(instanceData) {
136
- return instanceData.address !== undefined;
137
- }
138
- /** Determines if the provided instance data is contract instantiation data */ function isContractInstantiationData(instanceData) {
139
- return instanceData.salt !== undefined;
140
- }
141
- /** Determines if the provided instance data is already a contract */ function isContractInstanceAndArtifact(instanceData) {
142
- return instanceData.instance !== undefined && instanceData.artifact !== undefined;
143
- }
144
- let instance;
145
- if (isContractInstanceAndArtifact(instanceData)) {
146
- instance = instanceData.instance;
147
- await this.pxe.registerContract(instanceData);
148
- } else if (isInstanceWithAddress(instanceData)) {
149
- instance = instanceData;
150
- await this.pxe.registerContract({
151
- artifact,
152
- instance
153
- });
154
- } else if (isContractInstantiationData(instanceData)) {
155
- if (!artifact) {
156
- throw new Error(`Contract artifact must be provided when registering a contract using instantiation data`);
157
- }
158
- instance = await getContractInstanceFromInstantiationParams(artifact, instanceData);
159
- await this.pxe.registerContract({
160
- artifact,
161
- instance
162
- });
163
- } else {
164
- if (!artifact) {
165
- throw new Error(`Contract artifact must be provided when registering a contract using an address`);
166
- }
167
- const { contractInstance: maybeContractInstance } = await this.pxe.getContractMetadata(instanceData);
168
- if (!maybeContractInstance) {
169
- throw new Error(`Contract instance at ${instanceData.toString()} has not been registered in the wallet's PXE`);
170
- }
171
- instance = maybeContractInstance;
172
- const thisContractClass = await getContractClassFromArtifact(artifact);
173
- if (!thisContractClass.id.equals(instance.currentContractClassId)) {
174
- // wallet holds an outdated version of this contract
175
- await this.pxe.updateContract(instance.address, artifact);
176
- instance.currentContractClassId = thisContractClass.id;
177
- }
178
- }
179
- if (secretKey) {
180
- await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
181
- }
182
- return instance;
183
- }
184
- async simulateTx(executionPayload, opts) {
185
- const feeOptions = opts.fee?.estimateGas ? await this.getFeeOptionsForGasEstimation(opts.from, opts.fee) : await this.getDefaultFeeOptions(opts.from, opts.fee);
186
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
187
- return this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
188
- }
189
- async profileTx(executionPayload, opts) {
190
- const fee = await this.getDefaultFeeOptions(opts.from, opts.fee);
191
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, fee);
192
- return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
193
- }
194
- async sendTx(executionPayload, opts) {
195
- const fee = await this.getDefaultFeeOptions(opts.from, opts.fee);
196
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, fee);
197
- const provenTx = await this.pxe.proveTx(txRequest);
198
- const tx = await provenTx.toTx();
199
- const txHash = tx.getTxHash();
200
- if (await this.aztecNode.getTxEffect(txHash)) {
201
- throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
202
- }
203
- this.log.debug(`Sending transaction ${txHash}`);
204
- await this.aztecNode.sendTx(tx).catch((err)=>{
205
- throw this.contextualizeError(err, inspect(tx));
206
- });
207
- this.log.info(`Sent transaction ${txHash}`);
208
- return txHash;
209
- }
210
- contextualizeError(err, ...context) {
211
- let contextStr = '';
212
- if (context.length > 0) {
213
- contextStr = `\nContext:\n${context.join('\n')}`;
214
- }
215
- if (err instanceof SimulationError) {
216
- err.setAztecContext(contextStr);
217
- } else {
218
- this.log.error(err.name, err);
219
- this.log.debug(contextStr);
220
- }
221
- return err;
222
- }
223
- simulateUtility(functionName, args, to, authwits, from) {
224
- return this.pxe.simulateUtility(functionName, args, to, authwits, from);
225
- }
226
- getContractClassMetadata(id, includeArtifact = false) {
227
- return this.pxe.getContractClassMetadata(id, includeArtifact);
228
- }
229
- getContractMetadata(address) {
230
- return this.pxe.getContractMetadata(address);
231
- }
232
- getTxReceipt(txHash) {
233
- return this.aztecNode.getTxReceipt(txHash);
234
- }
235
- getPrivateEvents(contractAddress, event, from, limit, recipients = []) {
236
- return this.pxe.getPrivateEvents(contractAddress, event, from, limit, recipients);
237
- }
238
- }
@@ -1,25 +0,0 @@
1
- import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import type { CompleteAddress } from '@aztec/stdlib/contract';
5
-
6
- // docs:start:account-interface
7
-
8
- /**
9
- * Handler for interfacing with an account. Knows how to create transaction execution
10
- * requests and authorize actions for its corresponding account.
11
- */
12
- export interface AccountInterface extends EntrypointInterface, AuthWitnessProvider {
13
- /** Returns the complete address for this account. */
14
- getCompleteAddress(): CompleteAddress;
15
-
16
- /** Returns the address for this account. */
17
- getAddress(): AztecAddress;
18
-
19
- /** Returns the chain id for this account */
20
- getChainId(): Fr;
21
-
22
- /** Returns the rollup version for this account */
23
- getVersion(): Fr;
24
- }
25
- // docs:end:account-interface
@@ -1,68 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
6
-
7
- import type { Wallet } from '../wallet/wallet.js';
8
- import type { Contract } from './contract.js';
9
- import type { ContractBase } from './contract_base.js';
10
- import { SentTx, type WaitOpts } from './sent_tx.js';
11
-
12
- /** Options related to waiting for a deployment tx. */
13
- export type DeployedWaitOpts = WaitOpts & {
14
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
15
- wallet?: Wallet;
16
- };
17
-
18
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
19
- export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsOf<TxReceipt> & {
20
- /** Instance of the newly deployed contract. */
21
- contract: TContract;
22
- };
23
-
24
- /**
25
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
26
- */
27
- export class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
28
- private log = createLogger('aztecjs:deploy_sent_tx');
29
-
30
- constructor(
31
- wallet: Wallet,
32
- sendTx: () => Promise<TxHash>,
33
- private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
34
- /** A getter for the deployed contract instance */
35
- public instanceGetter: () => Promise<ContractInstanceWithAddress>,
36
- ) {
37
- super(wallet, sendTx);
38
- }
39
-
40
- /**
41
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
42
- * @param opts - Options for configuring the waiting for the tx to be mined.
43
- * @returns The deployed contract instance.
44
- */
45
- public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
46
- const receipt = await this.wait(opts);
47
- const instance = await this.instanceGetter();
48
- this.log.info(`Contract ${instance.address.toString()} successfully deployed.`);
49
- return receipt.contract;
50
- }
51
-
52
- /**
53
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
54
- * @param opts - Options for configuring the waiting for the tx to be mined.
55
- * @returns The transaction receipt with the deployed contract instance.
56
- */
57
- public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
58
- const receipt = await super.wait(opts);
59
- // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
60
- const contractWallet = opts?.wallet ?? (this.walletOrNode as Wallet);
61
- if (!contractWallet) {
62
- throw new Error(`A wallet is required for creating a contract instance`);
63
- }
64
- const instance = await this.instanceGetter();
65
- const contract = (await this.postDeployCtor(instance.address, contractWallet)) as TContract;
66
- return { ...receipt, contract };
67
- }
68
- }