@aztec/aztec.js 3.0.3 → 4.0.0-devnet.1-patch.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 (197) hide show
  1. package/dest/account/account.d.ts +25 -40
  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 +8 -9
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +19 -7
  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 +3 -2
  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 +5 -6
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/account.d.ts +2 -4
  16. package/dest/api/account.d.ts.map +1 -1
  17. package/dest/api/account.js +1 -3
  18. package/dest/api/authorization.d.ts +2 -2
  19. package/dest/api/authorization.d.ts.map +1 -1
  20. package/dest/api/authorization.js +1 -1
  21. package/dest/api/contract.d.ts +18 -12
  22. package/dest/api/contract.d.ts.map +1 -1
  23. package/dest/api/contract.js +16 -10
  24. package/dest/api/deployment.d.ts +1 -2
  25. package/dest/api/deployment.d.ts.map +1 -1
  26. package/dest/api/deployment.js +0 -1
  27. package/dest/api/events.d.ts +10 -6
  28. package/dest/api/events.d.ts.map +1 -1
  29. package/dest/api/events.js +30 -20
  30. package/dest/api/fields.d.ts +2 -1
  31. package/dest/api/fields.d.ts.map +1 -1
  32. package/dest/api/fields.js +1 -0
  33. package/dest/api/keys.d.ts +1 -1
  34. package/dest/api/keys.js +1 -1
  35. package/dest/api/node.d.ts +8 -4
  36. package/dest/api/node.d.ts.map +1 -1
  37. package/dest/api/node.js +7 -3
  38. package/dest/api/protocol.d.ts +7 -1
  39. package/dest/api/protocol.d.ts.map +1 -1
  40. package/dest/api/protocol.js +6 -0
  41. package/dest/api/tx.d.ts +2 -2
  42. package/dest/api/tx.d.ts.map +1 -1
  43. package/dest/api/tx.js +1 -1
  44. package/dest/api/wallet.d.ts +3 -2
  45. package/dest/api/wallet.d.ts.map +1 -1
  46. package/dest/api/wallet.js +2 -1
  47. package/dest/authorization/call_authorization_request.d.ts +22 -1
  48. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  49. package/dest/contract/base_contract_interaction.d.ts +8 -10
  50. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  51. package/dest/contract/base_contract_interaction.js +5 -17
  52. package/dest/contract/batch_call.d.ts +1 -1
  53. package/dest/contract/batch_call.d.ts.map +1 -1
  54. package/dest/contract/batch_call.js +3 -1
  55. package/dest/contract/contract_base.d.ts +4 -1
  56. package/dest/contract/contract_base.d.ts.map +1 -1
  57. package/dest/contract/contract_function_interaction.d.ts +3 -12
  58. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  59. package/dest/contract/contract_function_interaction.js +6 -6
  60. package/dest/contract/deploy_method.d.ts +63 -16
  61. package/dest/contract/deploy_method.d.ts.map +1 -1
  62. package/dest/contract/deploy_method.js +41 -23
  63. package/dest/contract/interaction_options.d.ts +42 -5
  64. package/dest/contract/interaction_options.d.ts.map +1 -1
  65. package/dest/contract/interaction_options.js +8 -1
  66. package/dest/contract/protocol_contracts/auth-registry.d.ts +27 -0
  67. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  68. package/dest/contract/protocol_contracts/auth-registry.js +558 -0
  69. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
  70. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  71. package/dest/contract/protocol_contracts/contract-class-registry.js +127 -0
  72. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
  73. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  74. package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
  75. package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
  76. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  77. package/dest/contract/protocol_contracts/fee-juice.js +426 -0
  78. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  79. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  80. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +585 -0
  81. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  82. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  83. package/dest/contract/protocol_contracts/public-checks.js +593 -0
  84. package/dest/contract/wait_for_proven.d.ts +2 -2
  85. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  86. package/dest/contract/wait_for_proven.js +1 -1
  87. package/dest/contract/wait_opts.d.ts +16 -0
  88. package/dest/contract/wait_opts.d.ts.map +1 -0
  89. package/dest/contract/wait_opts.js +5 -0
  90. package/dest/deployment/publish_class.js +2 -2
  91. package/dest/deployment/publish_instance.d.ts +2 -2
  92. package/dest/deployment/publish_instance.d.ts.map +1 -1
  93. package/dest/deployment/publish_instance.js +3 -3
  94. package/dest/ethereum/portal_manager.d.ts +7 -4
  95. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  96. package/dest/ethereum/portal_manager.js +15 -16
  97. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
  98. package/dest/fee/private_fee_payment_method.js +10 -10
  99. package/dest/fee/public_fee_payment_method.js +10 -10
  100. package/dest/fee/sponsored_fee_payment.js +3 -3
  101. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  102. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  103. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  104. package/dest/utils/authwit.d.ts +8 -6
  105. package/dest/utils/authwit.d.ts.map +1 -1
  106. package/dest/utils/authwit.js +5 -9
  107. package/dest/utils/node.d.ts +12 -1
  108. package/dest/utils/node.d.ts.map +1 -1
  109. package/dest/utils/node.js +46 -0
  110. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
  111. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  112. package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
  113. package/dest/wallet/account_manager.d.ts +5 -8
  114. package/dest/wallet/account_manager.d.ts.map +1 -1
  115. package/dest/wallet/account_manager.js +5 -11
  116. package/dest/wallet/capabilities.d.ts +444 -0
  117. package/dest/wallet/capabilities.d.ts.map +1 -0
  118. package/dest/wallet/capabilities.js +3 -0
  119. package/dest/wallet/deploy_account_method.d.ts +34 -6
  120. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  121. package/dest/wallet/deploy_account_method.js +7 -5
  122. package/dest/wallet/index.d.ts +2 -1
  123. package/dest/wallet/index.d.ts.map +1 -1
  124. package/dest/wallet/index.js +1 -0
  125. package/dest/wallet/wallet.d.ts +1642 -1007
  126. package/dest/wallet/wallet.d.ts.map +1 -1
  127. package/dest/wallet/wallet.js +201 -107
  128. package/package.json +24 -13
  129. package/src/account/account.ts +34 -58
  130. package/src/account/account_contract.ts +6 -7
  131. package/src/account/account_with_secret_key.ts +33 -8
  132. package/src/account/index.ts +2 -1
  133. package/src/account/signerless_account.ts +13 -12
  134. package/src/api/account.ts +9 -3
  135. package/src/api/authorization.ts +1 -0
  136. package/src/api/contract.ts +24 -9
  137. package/src/api/deployment.ts +0 -1
  138. package/src/api/events.ts +35 -27
  139. package/src/api/fields.ts +1 -0
  140. package/src/api/keys.ts +2 -2
  141. package/src/api/node.ts +7 -3
  142. package/src/api/protocol.ts +7 -0
  143. package/src/api/tx.ts +2 -0
  144. package/src/api/wallet.ts +47 -3
  145. package/src/contract/base_contract_interaction.ts +27 -15
  146. package/src/contract/batch_call.ts +4 -2
  147. package/src/contract/contract_function_interaction.ts +13 -6
  148. package/src/contract/deploy_method.ts +122 -29
  149. package/src/contract/interaction_options.ts +49 -4
  150. package/src/contract/protocol_contracts/auth-registry.ts +351 -0
  151. package/src/contract/protocol_contracts/contract-class-registry.ts +96 -0
  152. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  153. package/src/contract/protocol_contracts/fee-juice.ts +264 -0
  154. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +332 -0
  155. package/src/contract/protocol_contracts/public-checks.ts +316 -0
  156. package/src/contract/wait_for_proven.ts +1 -1
  157. package/src/contract/wait_opts.ts +21 -0
  158. package/src/deployment/publish_class.ts +2 -2
  159. package/src/deployment/publish_instance.ts +3 -6
  160. package/src/ethereum/portal_manager.ts +17 -21
  161. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
  162. package/src/fee/private_fee_payment_method.ts +7 -7
  163. package/src/fee/public_fee_payment_method.ts +8 -8
  164. package/src/fee/sponsored_fee_payment.ts +3 -3
  165. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  166. package/src/utils/authwit.ts +19 -7
  167. package/src/utils/node.ts +62 -0
  168. package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
  169. package/src/wallet/account_manager.ts +5 -13
  170. package/src/wallet/capabilities.ts +491 -0
  171. package/src/wallet/deploy_account_method.ts +37 -13
  172. package/src/wallet/index.ts +1 -0
  173. package/src/wallet/wallet.ts +319 -118
  174. package/dest/account/interface.d.ts +0 -19
  175. package/dest/account/interface.d.ts.map +0 -1
  176. package/dest/account/interface.js +0 -5
  177. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  178. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  179. package/dest/contract/deploy_sent_tx.js +0 -46
  180. package/dest/contract/protocol_contracts.d.ts +0 -9
  181. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  182. package/dest/contract/protocol_contracts.js +0 -26
  183. package/dest/contract/sent_tx.d.ts +0 -50
  184. package/dest/contract/sent_tx.d.ts.map +0 -1
  185. package/dest/contract/sent_tx.js +0 -90
  186. package/dest/contract/unsafe_contract.d.ts +0 -15
  187. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  188. package/dest/contract/unsafe_contract.js +0 -6
  189. package/dest/deployment/broadcast_function.d.ts +0 -24
  190. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  191. package/dest/deployment/broadcast_function.js +0 -74
  192. package/src/account/interface.ts +0 -25
  193. package/src/contract/deploy_sent_tx.ts +0 -75
  194. package/src/contract/protocol_contracts.ts +0 -35
  195. package/src/contract/sent_tx.ts +0 -129
  196. package/src/contract/unsafe_contract.ts +0 -19
  197. package/src/deployment/broadcast_function.ts +0 -148
@@ -1,48 +0,0 @@
1
- import type { FieldsOf } from '@aztec/foundation/types';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
4
- import type { Wallet } from '../wallet/wallet.js';
5
- import type { ContractBase } from './contract_base.js';
6
- import { SentTx, type WaitOpts } from './sent_tx.js';
7
- /** Options related to waiting for a deployment tx. */
8
- export type DeployedWaitOpts = WaitOpts & {
9
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
10
- wallet?: Wallet;
11
- };
12
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
13
- export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
14
- /** Instance of the newly deployed contract. */
15
- contract: TContract;
16
- /** The deployed contract instance with address and metadata. */
17
- instance: ContractInstanceWithAddress;
18
- };
19
- /**
20
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
21
- */
22
- export declare class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
23
- private postDeployCtor;
24
- /** A getter for the deployed contract instance */
25
- private instanceGetter;
26
- private log;
27
- constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
28
- /** A getter for the deployed contract instance */
29
- instanceGetter: () => Promise<ContractInstanceWithAddress>);
30
- /**
31
- * Returns the contract instance for this deployment.
32
- * @returns The deployed contract instance with address and metadata.
33
- */
34
- getInstance(): Promise<ContractInstanceWithAddress>;
35
- /**
36
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
37
- * @param opts - Options for configuring the waiting for the tx to be mined.
38
- * @returns The deployed contract instance.
39
- */
40
- deployed(opts?: DeployedWaitOpts): Promise<TContract>;
41
- /**
42
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
43
- * @param opts - Options for configuring the waiting for the tx to be mined.
44
- * @returns The transaction receipt with the deployed contract instance.
45
- */
46
- wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
47
- }
48
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X3NlbnRfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC9kZXBsb3lfc2VudF90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUxRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUN2RCxPQUFPLEVBQUUsTUFBTSxFQUFFLEtBQUssUUFBUSxFQUFFLE1BQU0sY0FBYyxDQUFDO0FBRXJELHNEQUFzRDtBQUN0RCxNQUFNLE1BQU0sZ0JBQWdCLEdBQUcsUUFBUSxHQUFHO0lBQ3hDLCtHQUErRztJQUMvRyxNQUFNLENBQ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AE,MAAM,OAAO,CAAC,2BAA2B,CAAC,EAGnE;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAE/D;IAED;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAIjE;IAED;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAUvF;CACF"}
@@ -1,46 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { SentTx } from './sent_tx.js';
3
- /**
4
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
5
- */ export class DeploySentTx extends SentTx {
6
- postDeployCtor;
7
- instanceGetter;
8
- log;
9
- constructor(wallet, sendTx, postDeployCtor, /** A getter for the deployed contract instance */ instanceGetter){
10
- super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
11
- }
12
- /**
13
- * Returns the contract instance for this deployment.
14
- * @returns The deployed contract instance with address and metadata.
15
- */ async getInstance() {
16
- return await this.instanceGetter();
17
- }
18
- /**
19
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
20
- * @param opts - Options for configuring the waiting for the tx to be mined.
21
- * @returns The deployed contract instance.
22
- */ async deployed(opts) {
23
- const receipt = await this.wait(opts);
24
- this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
25
- return receipt.contract;
26
- }
27
- /**
28
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
29
- * @param opts - Options for configuring the waiting for the tx to be mined.
30
- * @returns The transaction receipt with the deployed contract instance.
31
- */ async wait(opts) {
32
- const receipt = await super.wait(opts);
33
- // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
34
- const contractWallet = opts?.wallet ?? this.walletOrNode;
35
- if (!contractWallet) {
36
- throw new Error(`A wallet is required for creating a contract instance`);
37
- }
38
- const instance = await this.instanceGetter();
39
- const contract = this.postDeployCtor(instance, contractWallet);
40
- return {
41
- ...receipt,
42
- contract,
43
- instance
44
- };
45
- }
46
- }
@@ -1,9 +0,0 @@
1
- import type { Wallet } from '../wallet/wallet.js';
2
- import { UnsafeContract } from './unsafe_contract.js';
3
- /** Returns a Contract wrapper for the contract class registry. */
4
- export declare function getClassRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
5
- /** Returns a Contract wrapper for the contract instance registry. */
6
- export declare function getInstanceRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
7
- /** Returns a Contract wrapper for the fee juice contract */
8
- export declare function getFeeJuice(wallet: Wallet): Promise<UnsafeContract>;
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdG9jb2xfY29udHJhY3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvcHJvdG9jb2xfY29udHJhY3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ2xELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxrRUFBa0U7QUFDbEUsd0JBQXNCLHdCQUF3QixDQUFDLE1BQU0sRUFBRSxNQUFNLDJCQVE1RDtBQUVELHFFQUFxRTtBQUNyRSx3QkFBc0IsMkJBQTJCLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9EO0FBRUQsNERBQTREO0FBQzVELHdCQUFzQixXQUFXLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9DIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,2BAQ5D;AAED,qEAAqE;AACrE,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,2BAO/D;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,2BAO/C"}
@@ -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,50 +0,0 @@
1
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
2
- import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
3
- import type { Wallet } from '../wallet/wallet.js';
4
- /** Options related to waiting for a tx. */
5
- export type WaitOpts = {
6
- /** 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. */
7
- ignoreDroppedReceiptsFor?: number;
8
- /** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
9
- timeout?: number;
10
- /** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
11
- interval?: number;
12
- /** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
13
- dontThrowOnRevert?: boolean;
14
- };
15
- export declare const DefaultWaitOpts: WaitOpts;
16
- /**
17
- * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
18
- * its hash, receipt, and mining status.
19
- */
20
- export declare class SentTx {
21
- protected walletOrNode: Wallet | AztecNode;
22
- protected sendTxPromise: Promise<void>;
23
- protected sendTxError?: Error;
24
- protected txHash?: TxHash;
25
- constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
26
- /**
27
- * Retrieves the transaction hash of the SentTx instance.
28
- * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
29
- *
30
- * @returns A promise that resolves to the transaction hash of the SentTx instance.
31
- * TODO(#7717): Don't throw here.
32
- */
33
- getTxHash(): Promise<TxHash>;
34
- /**
35
- * Retrieve the transaction receipt associated with the current SentTx instance.
36
- * The function fetches the transaction hash using 'getTxHash' and then queries
37
- * the PXE to get the corresponding transaction receipt.
38
- *
39
- * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
40
- */
41
- getReceipt(): Promise<TxReceipt>;
42
- /**
43
- * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
44
- * @param opts - Options for configuring the waiting for the tx to be mined.
45
- * @returns The transaction receipt.
46
- */
47
- wait(opts?: WaitOpts): Promise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AM,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;IAE1B,YACY,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAc9B;IAED;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAWxC;IAED;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAG5C;IAED;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAQrD;IAED,UAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CA4BlE;CACF"}
@@ -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: 300,
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=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5zYWZlX2NvbnRyYWN0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvdW5zYWZlX2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUUxRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsaUhBQWlIO0FBQ2pILHFCQUFhLGNBQWUsU0FBUSxZQUFZO0lBQzlDO0lBQ0UsaURBQWlEO0lBQ2pELFFBQVEsRUFBRSwyQkFBMkI7SUFDckMseURBQXlEO0lBQ3pELFFBQVEsRUFBRSxnQkFBZ0I7SUFDMUIsMERBQTBEO0lBQzFELE1BQU0sRUFBRSxNQUFNLEVBR2Y7Q0FDRiJ9
@@ -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;IAC9C;IACE,iDAAiD;IACjD,QAAQ,EAAE,2BAA2B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAGf;CACF"}
@@ -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.address, artifact, wallet);
5
- }
6
- }
@@ -1,24 +0,0 @@
1
- import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
2
- import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
3
- import type { Wallet } from '../wallet/index.js';
4
- /**
5
- * Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
6
- * Note that this is not required for users to call the function, but is rather a convenience to make
7
- * this code publicly available so dapps or wallets do not need to redistribute it.
8
- * @param wallet - Wallet to send the transaction.
9
- * @param artifact - Contract artifact that contains the function to be broadcast.
10
- * @param selector - Selector of the function to be broadcast.
11
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
12
- */
13
- export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
14
- /**
15
- * Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
16
- * Note that this is not required for users to call the function, but is rather a convenience to make
17
- * this code publicly available so dapps or wallets do not need to redistribute it.
18
- * @param wallet - Wallet to send the transaction.
19
- * @param artifact - Contract artifact that contains the function to be broadcast.
20
- * @param selector - Selector of the function to be broadcast.
21
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
22
- */
23
- export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvYWRjYXN0X2Z1bmN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVwbG95bWVudC9icm9hZGNhc3RfZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQWdDLE1BQU0sbUJBQW1CLENBQUM7QUFTMUcsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSw4Q0FBOEMsQ0FBQztBQUVoRyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVqRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFzQix3QkFBd0IsQ0FDNUMsTUFBTSxFQUFFLE1BQU0sRUFDZCxRQUFRLEVBQUUsZ0JBQWdCLEVBQzFCLFFBQVEsRUFBRSxnQkFBZ0IsR0FDekIsT0FBTyxDQUFDLDJCQUEyQixDQUFDLENBb0R0QztBQUVEOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxNQUFNLEVBQUUsTUFBTSxFQUNkLFFBQVEsRUFBRSxnQkFBZ0IsRUFDMUIsUUFBUSxFQUFFLGdCQUFnQixHQUN6QixPQUFPLENBQUMsMkJBQTJCLENBQUMsQ0E4Q3RDIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CA8CtC"}
@@ -1,74 +0,0 @@
1
- import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS } from '@aztec/constants';
2
- import { padArrayEnd } from '@aztec/foundation/collection';
3
- import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
- import { FunctionSelector, FunctionType, bufferAsFields } from '@aztec/stdlib/abi';
6
- import { computeVerificationKeyHash, createPrivateFunctionMembershipProof, createUtilityFunctionMembershipProof, getContractClassFromArtifact } from '@aztec/stdlib/contract';
7
- import { Capsule } from '@aztec/stdlib/tx';
8
- import { getClassRegistryContract } from '../contract/protocol_contracts.js';
9
- /**
10
- * Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
11
- * Note that this is not required for users to call the function, but is rather a convenience to make
12
- * this code publicly available so dapps or wallets do not need to redistribute it.
13
- * @param wallet - Wallet to send the transaction.
14
- * @param artifact - Contract artifact that contains the function to be broadcast.
15
- * @param selector - Selector of the function to be broadcast.
16
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
17
- */ export async function broadcastPrivateFunction(wallet, artifact, selector) {
18
- const contractClass = await getContractClassFromArtifact(artifact);
19
- const privateFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE);
20
- const functionsAndSelectors = await Promise.all(privateFunctions.map(async (fn)=>({
21
- f: fn,
22
- selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
23
- })));
24
- const privateFunctionArtifact = functionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
25
- if (!privateFunctionArtifact) {
26
- throw new Error(`Private function with selector ${selector.toString()} not found`);
27
- }
28
- const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex } = await createPrivateFunctionMembershipProof(selector, artifact);
29
- const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
30
- const classRegistry = await getClassRegistryContract(wallet);
31
- const bytecode = bufferAsFields(privateFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
32
- return classRegistry.methods.broadcast_private_function(contractClass.id, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
33
- {
34
- selector,
35
- metadata_hash: functionMetadataHash,
36
- vk_hash: vkHash
37
- }).with({
38
- capsules: [
39
- new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
40
- ]
41
- });
42
- }
43
- /**
44
- * Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
45
- * Note that this is not required for users to call the function, but is rather a convenience to make
46
- * this code publicly available so dapps or wallets do not need to redistribute it.
47
- * @param wallet - Wallet to send the transaction.
48
- * @param artifact - Contract artifact that contains the function to be broadcast.
49
- * @param selector - Selector of the function to be broadcast.
50
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
51
- */ export async function broadcastUtilityFunction(wallet, artifact, selector) {
52
- const contractClass = await getContractClassFromArtifact(artifact);
53
- const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
54
- const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
55
- f: fn,
56
- selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
57
- })));
58
- const utilityFunctionArtifact = utilityFunctionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
59
- if (!utilityFunctionArtifact) {
60
- throw new Error(`Utility function with selector ${selector.toString()} not found`);
61
- }
62
- const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await createUtilityFunctionMembershipProof(selector, artifact);
63
- const classRegistry = await getClassRegistryContract(wallet);
64
- const bytecode = bufferAsFields(utilityFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
65
- return classRegistry.methods.broadcast_utility_function(contractClass.id, artifactMetadataHash, privateFunctionsArtifactTreeRoot, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
66
- {
67
- selector,
68
- metadata_hash: functionMetadataHash
69
- }).with({
70
- capsules: [
71
- new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
72
- ]
73
- });
74
- }
@@ -1,25 +0,0 @@
1
- import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
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,75 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
-
6
- import type { Wallet } from '../wallet/wallet.js';
7
- import type { ContractBase } from './contract_base.js';
8
- import { SentTx, type WaitOpts } from './sent_tx.js';
9
-
10
- /** Options related to waiting for a deployment tx. */
11
- export type DeployedWaitOpts = WaitOpts & {
12
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
13
- wallet?: Wallet;
14
- };
15
-
16
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
17
- export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
18
- /** Instance of the newly deployed contract. */
19
- contract: TContract;
20
- /** The deployed contract instance with address and metadata. */
21
- instance: ContractInstanceWithAddress;
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 ContractBase = ContractBase> extends SentTx {
28
- private log = createLogger('aztecjs:deploy_sent_tx');
29
-
30
- constructor(
31
- wallet: Wallet,
32
- sendTx: () => Promise<TxHash>,
33
- private postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
34
- /** A getter for the deployed contract instance */
35
- private instanceGetter: () => Promise<ContractInstanceWithAddress>,
36
- ) {
37
- super(wallet, sendTx);
38
- }
39
-
40
- /**
41
- * Returns the contract instance for this deployment.
42
- * @returns The deployed contract instance with address and metadata.
43
- */
44
- public async getInstance(): Promise<ContractInstanceWithAddress> {
45
- return await this.instanceGetter();
46
- }
47
-
48
- /**
49
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
50
- * @param opts - Options for configuring the waiting for the tx to be mined.
51
- * @returns The deployed contract instance.
52
- */
53
- public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
54
- const receipt = await this.wait(opts);
55
- this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
56
- return receipt.contract;
57
- }
58
-
59
- /**
60
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
61
- * @param opts - Options for configuring the waiting for the tx to be mined.
62
- * @returns The transaction receipt with the deployed contract instance.
63
- */
64
- public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
65
- const receipt = await super.wait(opts);
66
- // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
67
- const contractWallet = opts?.wallet ?? (this.walletOrNode as Wallet);
68
- if (!contractWallet) {
69
- throw new Error(`A wallet is required for creating a contract instance`);
70
- }
71
- const instance = await this.instanceGetter();
72
- const contract = this.postDeployCtor(instance, contractWallet) as TContract;
73
- return { ...receipt, contract, instance };
74
- }
75
- }
@@ -1,35 +0,0 @@
1
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
-
3
- import type { Wallet } from '../wallet/wallet.js';
4
- import { UnsafeContract } from './unsafe_contract.js';
5
-
6
- /** Returns a Contract wrapper for the contract class registry. */
7
- export async function getClassRegistryContract(wallet: Wallet) {
8
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
9
- if (!contractInstance) {
10
- throw new Error("ContractClassRegistry is not registered in this wallet's instance");
11
- }
12
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
13
-
14
- return new UnsafeContract(contractInstance!, artifact!, wallet);
15
- }
16
-
17
- /** Returns a Contract wrapper for the contract instance registry. */
18
- export async function getInstanceRegistryContract(wallet: Wallet) {
19
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
20
- if (!contractInstance) {
21
- throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
22
- }
23
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
24
- return new UnsafeContract(contractInstance!, artifact!, wallet);
25
- }
26
-
27
- /** Returns a Contract wrapper for the fee juice contract */
28
- export async function getFeeJuice(wallet: Wallet) {
29
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
30
- if (!contractInstance) {
31
- throw new Error("FeeJuice is not registered in this wallet's instance");
32
- }
33
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
34
- return new UnsafeContract(contractInstance!, artifact!, wallet);
35
- }