@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,23 +1,48 @@
1
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
1
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { CompleteAddress } from '@aztec/stdlib/contract';
6
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
7
  import { computeAddressSecret, deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
8
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
3
9
 
4
- import { BaseAccount } from './account.js';
5
- import type { Salt } from './index.js';
6
- import type { AccountInterface } from './interface.js';
10
+ import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
11
+ import type { Account, Salt } from './index.js';
7
12
 
8
13
  /**
9
- * Extends {@link Account} with the encryption private key. Not required for
14
+ * Extends {@link BaseAccount} with the encryption private key. Not required for
10
15
  * implementing the wallet interface but useful for testing purposes or exporting
11
16
  * an account to another pxe.
12
17
  */
13
- export class AccountWithSecretKey extends BaseAccount {
18
+ export class AccountWithSecretKey implements Account {
14
19
  constructor(
15
- account: AccountInterface,
20
+ private account: Account,
16
21
  private secretKey: Fr,
17
22
  /** Deployment salt for this account contract. */
18
23
  public readonly salt: Salt,
19
- ) {
20
- super(account);
24
+ ) {}
25
+
26
+ createTxExecutionRequest(
27
+ exec: ExecutionPayload,
28
+ gasSettings: GasSettings,
29
+ chainInfo: ChainInfo,
30
+ options?: any,
31
+ ): Promise<TxExecutionRequest> {
32
+ return this.account.createTxExecutionRequest(exec, gasSettings, chainInfo, options);
33
+ }
34
+
35
+ wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload> {
36
+ return this.account.wrapExecutionPayload(exec, options);
37
+ }
38
+ createAuthWit(intent: IntentInnerHash | CallIntent, chainInfo: ChainInfo): Promise<AuthWitness> {
39
+ return this.account.createAuthWit(intent, chainInfo);
40
+ }
41
+ getCompleteAddress(): CompleteAddress {
42
+ return this.account.getCompleteAddress();
43
+ }
44
+ getAddress(): AztecAddress {
45
+ return this.account.getAddress();
21
46
  }
22
47
 
23
48
  /** Returns the encryption private key associated with this account. */
@@ -6,7 +6,8 @@
6
6
  import type { Fr } from '@aztec/foundation/curves/bn254';
7
7
 
8
8
  export { type AccountContract, getAccountContractAddress } from './account_contract.js';
9
- export { type AccountInterface } from './interface.js';
9
+ export { type Account, BaseAccount, type AuthorizationProvider } from './account.js';
10
+ export { AccountWithSecretKey } from './account_with_secret_key.js';
10
11
 
11
12
  /** A contract deployment salt. */
12
13
  export type Salt = Fr | number | bigint;
@@ -15,20 +15,25 @@ import type { Account } from './account.js';
15
15
  */
16
16
  export class SignerlessAccount implements Account {
17
17
  private entrypoint: EntrypointInterface;
18
- constructor(chainInfo: ChainInfo) {
19
- this.entrypoint = new DefaultMultiCallEntrypoint(chainInfo.chainId.toNumber(), chainInfo.version.toNumber());
18
+
19
+ constructor() {
20
+ this.entrypoint = new DefaultMultiCallEntrypoint();
20
21
  }
21
22
 
22
- createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
23
- return this.entrypoint.createTxExecutionRequest(exec, gasSettings);
23
+ createTxExecutionRequest(
24
+ exec: ExecutionPayload,
25
+ gasSettings: GasSettings,
26
+ chainInfo: ChainInfo,
27
+ ): Promise<TxExecutionRequest> {
28
+ return this.entrypoint.createTxExecutionRequest(exec, gasSettings, chainInfo);
24
29
  }
25
30
 
26
- getChainId(): Fr {
27
- throw new Error('SignerlessAccount: Method getChainId not implemented.');
31
+ wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload> {
32
+ return this.entrypoint.wrapExecutionPayload(exec, options);
28
33
  }
29
34
 
30
- getVersion(): Fr {
31
- throw new Error('SignerlessAccount: Method getVersion not implemented.');
35
+ createAuthWit(_intent: Fr | Buffer | IntentInnerHash | CallIntent): Promise<AuthWitness> {
36
+ throw new Error('SignerlessAccount: Method createAuthWit not implemented.');
32
37
  }
33
38
 
34
39
  getCompleteAddress(): CompleteAddress {
@@ -38,8 +43,4 @@ export class SignerlessAccount implements Account {
38
43
  getAddress(): AztecAddress {
39
44
  throw new Error('SignerlessAccount: Method getAddress not implemented.');
40
45
  }
41
-
42
- createAuthWit(_intent: Fr | Buffer | IntentInnerHash | CallIntent): Promise<AuthWitness> {
43
- throw new Error('SignerlessAccount: Method createAuthWit not implemented.');
44
- }
45
46
  }
@@ -1,7 +1,13 @@
1
- export { type AccountContract, type AccountInterface, type Salt, getAccountContractAddress } from '../account/index.js';
1
+ export {
2
+ type Account,
3
+ type AccountContract,
4
+ AccountWithSecretKey,
5
+ BaseAccount,
6
+ type AuthorizationProvider,
7
+ getAccountContractAddress,
8
+ type Salt,
9
+ } from '../account/index.js';
2
10
  export type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
3
11
  export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
4
12
 
5
- export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
6
- export { type Account, BaseAccount } from '../account/account.js';
7
13
  export { SignerlessAccount } from '../account/signerless_account.js';
@@ -2,6 +2,7 @@ export { AuthWitness } from '@aztec/stdlib/auth-witness';
2
2
  export {
3
3
  SetPublicAuthwitContractInteraction,
4
4
  type ContractFunctionInteractionCallIntent,
5
+ isContractFunctionInteractionCallIntent,
5
6
  getMessageHashFromIntent,
6
7
  computeAuthWitMessageHash,
7
8
  computeInnerAuthWitHashFromAction,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `contract` module provides utilities for deploying and interacting with contracts, based on a
3
3
  * `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid
4
- * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract | Compiling contracts}
4
+ * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts | Compiling contracts}
5
5
  * section of the documentation for how to generate an artifact out of your Noir source code.
6
6
  *
7
7
  * The {@link Contract} class is the main class in this module, and provides static methods for deploying
@@ -10,13 +10,21 @@
10
10
  * or can be queried via `simulate()`.
11
11
  *
12
12
  * ```ts
13
- * const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send().deployed();
13
+ * // Deploy and get the contract instance directly (default behavior)
14
+ * const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({ from: accountAddress });
14
15
  * console.log(`Contract deployed at ${contract.address}`);
16
+ *
17
+ * // Or get the full receipt with contract and instance
18
+ * const receipt = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({
19
+ * from: accountAddress,
20
+ * wait: { returnReceipt: true }
21
+ * });
22
+ * console.log(`Contract deployed at ${receipt.contract.address}`);
15
23
  * ```
16
24
  *
17
25
  * ```ts
18
26
  * const contract = Contract.at(address, MyContractArtifact, wallet);
19
- * await contract.methods.mint(1000, owner).send().wait();
27
+ * await contract.methods.mint(1000, owner).send({ from: accountAddress });
20
28
  * console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
21
29
  * ```
22
30
  *
@@ -25,12 +33,11 @@
25
33
  * a transaction to the network via the `send` method, but you can also `simulate` it without sending,
26
34
  * or obtaining the `request` for aggregating into a {@link BatchCall}.
27
35
  *
28
- * The result of `send`ing a transaction is a {@link SentTx} object, from which you can get the
29
- * transaction hash, or simply `wait` until the transaction is mined and the local PXE
30
- * has synchronized its changes.
36
+ * The `send` method returns a {@link TxReceipt} by default (waits for the transaction to be mined).
37
+ * If you pass `wait: NO_WAIT` in the options, it will return a {@link TxHash} immediately without waiting.
31
38
  *
32
39
  * @remarks If you are using typescript, consider using the
33
- * {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract#use-generated-interfaces | autogenerated type-safe interfaces}
40
+ * {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts#use-generated-interfaces | autogenerated type-safe interfaces}
34
41
  * for interacting with your contracts.
35
42
  *
36
43
  * @packageDocumentation
@@ -39,27 +46,35 @@ export { Contract } from '../contract/contract.js';
39
46
  export { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
40
47
 
41
48
  export {
49
+ NO_WAIT,
50
+ type NoWait,
42
51
  type RequestInteractionOptions,
43
52
  type SendInteractionOptions,
44
53
  type ProfileInteractionOptions,
45
54
  type SimulateInteractionOptions,
46
55
  type InteractionFeeOptions,
56
+ type InteractionWaitOptions,
47
57
  type GasSettingsOption,
58
+ type SendReturn,
59
+ type SimulationReturn,
48
60
  toProfileOptions,
49
61
  toSendOptions,
50
62
  toSimulateOptions,
51
63
  } from '../contract/interaction_options.js';
52
64
 
53
- export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
65
+ export { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
54
66
  export { ContractBase, type ContractMethod, type ContractStorageLayout } from '../contract/contract_base.js';
55
67
  export { BatchCall } from '../contract/batch_call.js';
56
68
  export {
57
69
  type DeployOptions,
70
+ type DeployReturn,
71
+ type DeployTxReceipt,
72
+ type DeployWaitOptions,
73
+ type DeployInteractionWaitOptions,
58
74
  DeployMethod,
59
75
  type RequestDeployOptions,
60
76
  type SimulateDeployOptions,
61
77
  } from '../contract/deploy_method.js';
62
- export { DeploySentTx } from '../contract/deploy_sent_tx.js';
63
78
  export { waitForProven, type WaitForProvenOpts, DefaultWaitForProvenOpts } from '../contract/wait_for_proven.js';
64
79
  export { getGasLimits } from '../contract/get_gas_limits.js';
65
80
 
@@ -1,4 +1,3 @@
1
1
  export { publishContractClass } from '../deployment/publish_class.js';
2
- export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
3
2
  export { publishInstance } from '../deployment/publish_instance.js';
4
3
  export { ContractDeployer } from '../deployment/contract_deployer.js';
package/src/api/events.ts CHANGED
@@ -1,44 +1,52 @@
1
1
  import { type EventMetadataDefinition, EventSelector, decodeFromAbi } from '@aztec/stdlib/abi';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
3
 
4
+ import type { PublicEvent, PublicEventFilter } from '../wallet/wallet.js';
5
+
4
6
  /**
5
7
  * Returns decoded public events given search parameters.
6
8
  * @param node - The node to request events from
7
- * @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
8
- * @param from - The block number to search from.
9
- * @param limit - The amount of blocks to search.
10
- * @returns - The deserialized events.
9
+ * @param eventMetadataDef - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
10
+ * @param filter - Filter options for the event query:
11
+ * - `contractAddress`: The address of the contract that emitted the events.
12
+ * - `txHash`: Transaction in which the events were emitted.
13
+ * - `fromBlock`: The block number from which to start fetching events (inclusive). Defaults to 1.
14
+ * - `toBlock`: The block number until which to fetch events (not inclusive). Defaults to latest + 1.
15
+ * @returns - The decoded events with metadata.
11
16
  */
12
- export async function getDecodedPublicEvents<T>(
17
+ export async function getPublicEvents<T>(
13
18
  node: AztecNode,
14
19
  eventMetadataDef: EventMetadataDefinition,
15
- from: number,
16
- limit: number,
17
- ): Promise<T[]> {
20
+ filter: PublicEventFilter,
21
+ ): Promise<PublicEvent<T>[]> {
18
22
  const { logs } = await node.getPublicLogs({
19
- fromBlock: from,
20
- toBlock: from + limit,
23
+ fromBlock: filter.fromBlock ? Number(filter.fromBlock) : undefined,
24
+ toBlock: filter.toBlock ? Number(filter.toBlock) : undefined,
25
+ txHash: filter.txHash,
26
+ contractAddress: filter.contractAddress,
21
27
  });
22
28
 
23
- const decodedEvents = logs
24
- .map(log => {
25
- // +1 for the event selector
26
- const expectedLength = eventMetadataDef.fieldNames.length + 1;
27
- if (log.log.fields.length !== expectedLength) {
28
- throw new Error(
29
- `Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.fields.length}.`,
30
- );
31
- }
29
+ const decodedEvents: PublicEvent<T>[] = [];
30
+
31
+ for (const log of logs) {
32
+ const logFields = log.log.getEmittedFields();
33
+ // Event selector is at the last position of the emitted fields
34
+ const logEventSelector = EventSelector.fromField(logFields[logFields.length - 1]);
32
35
 
33
- const logFields = log.log.getEmittedFields();
34
- // We are assuming here that event logs are the last 4 bytes of the event. This is not enshrined but is a function of aztec.nr raw log emission.
35
- if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
36
- return undefined;
37
- }
36
+ if (!logEventSelector.equals(eventMetadataDef.eventSelector)) {
37
+ continue;
38
+ }
38
39
 
39
- return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
40
- })
41
- .filter(log => log !== undefined) as T[];
40
+ decodedEvents.push({
41
+ event: decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T,
42
+ metadata: {
43
+ l2BlockNumber: log.id.blockNumber,
44
+ l2BlockHash: log.id.blockHash,
45
+ txHash: log.id.txHash,
46
+ contractAddress: log.log.contractAddress,
47
+ },
48
+ });
49
+ }
42
50
 
43
51
  return decodedEvents;
44
52
  }
package/src/api/fields.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Fr, Fq } from '@aztec/foundation/curves/bn254';
2
2
  export { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
3
+ export { BlockNumber } from '@aztec/foundation/branded-types';
package/src/api/keys.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
2
2
  export {
3
- computeAppNullifierSecretKey,
3
+ computeAppNullifierHidingKey,
4
4
  deriveKeys,
5
5
  deriveMasterIncomingViewingSecretKey,
6
- deriveMasterNullifierSecretKey,
6
+ deriveMasterNullifierHidingKey,
7
7
  } from '@aztec/stdlib/keys';
8
8
  export { generatePublicKey } from '../utils/pub_key.js';
package/src/api/node.ts CHANGED
@@ -3,18 +3,22 @@
3
3
  *
4
4
  * The primary function is {@link createAztecNodeClient}, which creates a JSON-RPC client
5
5
  * that connects to a running Aztec node instance. Use {@link waitForNode} to wait for
6
- * the node to be ready before proceeding.
6
+ * the node to be ready before proceeding, and {@link waitForTx} to wait for a transaction
7
+ * to be mined.
7
8
  *
8
9
  * @example
9
10
  * ```ts
10
- * import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
11
+ * import { createAztecNodeClient, waitForNode, waitForTx } from '@aztec/aztec.js/node';
11
12
  *
12
13
  * const node = createAztecNodeClient('http://localhost:8080');
13
14
  * await waitForNode(node);
14
15
  * const blockNumber = await node.getBlockNumber();
16
+ *
17
+ * // Wait for a transaction
18
+ * const receipt = await waitForTx(node, txHash);
15
19
  * ```
16
20
  *
17
21
  * @packageDocumentation
18
22
  */
19
- export { createAztecNodeClient, waitForNode, type AztecNode } from '../utils/node.js';
23
+ export { createAztecNodeClient, waitForNode, waitForTx, type AztecNode } from '../utils/node.js';
20
24
  export { type NodeInfo } from '@aztec/stdlib/contract';
@@ -1,2 +1,9 @@
1
1
  export { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
2
  export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
3
+
4
+ export { AuthRegistryContract } from '../contract/protocol_contracts/auth-registry.js';
5
+ export { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
6
+ export { ContractInstanceRegistryContract } from '../contract/protocol_contracts/contract-instance-registry.js';
7
+ export { FeeJuiceContract } from '../contract/protocol_contracts/fee-juice.js';
8
+ export { MultiCallEntrypointContract } from '../contract/protocol_contracts/multi-call-entrypoint.js';
9
+ export { PublicChecksContract } from '../contract/protocol_contracts/public-checks.js';
package/src/api/tx.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export {
2
2
  Tx,
3
3
  TxExecutionRequest,
4
+ TxExecutionResult,
4
5
  TxHash,
5
6
  TxReceipt,
6
7
  TxStatus,
8
+ SortedTxStatuses,
7
9
  Capsule,
8
10
  HashedValues,
9
11
  GlobalVariables,
package/src/api/wallet.ts CHANGED
@@ -11,23 +11,67 @@ export {
11
11
  type Wallet,
12
12
  type PrivateEvent,
13
13
  type PrivateEventFilter,
14
- FunctionCallSchema,
14
+ type PublicEvent,
15
+ type PublicEventFilter,
16
+ type ContractMetadata,
17
+ type ContractClassMetadata,
18
+ AppCapabilitiesSchema,
19
+ WalletCapabilitiesSchema,
15
20
  ExecutionPayloadSchema,
16
21
  GasSettingsOptionSchema,
17
22
  WalletSimulationFeeOptionSchema,
23
+ WaitOptsSchema,
18
24
  SendOptionsSchema,
19
25
  SimulateOptionsSchema,
20
26
  ProfileOptionsSchema,
21
27
  MessageHashOrIntentSchema,
22
28
  BatchedMethodSchema,
23
- ContractMetadataSchema,
24
- ContractClassMetadataSchema,
25
29
  EventMetadataDefinitionSchema,
26
30
  PrivateEventSchema,
27
31
  PrivateEventFilterSchema,
32
+ PublicEventSchema,
33
+ PublicEventFilterSchema,
34
+ ContractClassMetadataSchema,
35
+ ContractMetadataSchema,
28
36
  WalletSchema,
37
+ ContractFunctionPatternSchema,
38
+ AccountsCapabilitySchema,
39
+ GrantedAccountsCapabilitySchema,
40
+ ContractsCapabilitySchema,
41
+ GrantedContractsCapabilitySchema,
42
+ ContractClassesCapabilitySchema,
43
+ GrantedContractClassesCapabilitySchema,
44
+ SimulationCapabilitySchema,
45
+ GrantedSimulationCapabilitySchema,
46
+ TransactionCapabilitySchema,
47
+ GrantedTransactionCapabilitySchema,
48
+ DataCapabilitySchema,
49
+ GrantedDataCapabilitySchema,
50
+ CapabilitySchema,
51
+ GrantedCapabilitySchema,
29
52
  } from '../wallet/wallet.js';
30
53
 
54
+ export {
55
+ type AppCapabilities,
56
+ type WalletCapabilities,
57
+ CAPABILITY_VERSION,
58
+ type Capability,
59
+ type GrantedCapability,
60
+ type ContractFunctionPattern,
61
+ type AccountsCapability,
62
+ type GrantedAccountsCapability,
63
+ type ContractsCapability,
64
+ type GrantedContractsCapability,
65
+ type ContractClassesCapability,
66
+ type GrantedContractClassesCapability,
67
+ type SimulationCapability,
68
+ type GrantedSimulationCapability,
69
+ type TransactionCapability,
70
+ type GrantedTransactionCapability,
71
+ type DataCapability,
72
+ type GrantedDataCapability,
73
+ } from '../wallet/capabilities.js';
74
+
31
75
  export { AccountManager } from '../wallet/account_manager.js';
32
76
 
33
77
  export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
@@ -1,10 +1,16 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
3
- import type { Capsule, ExecutionPayload } from '@aztec/stdlib/tx';
3
+ import type { Capsule, ExecutionPayload, TxReceipt } from '@aztec/stdlib/tx';
4
4
 
5
5
  import type { Wallet } from '../wallet/wallet.js';
6
- import { type RequestInteractionOptions, type SendInteractionOptions, toSendOptions } from './interaction_options.js';
7
- import { SentTx } from './sent_tx.js';
6
+ import {
7
+ type InteractionWaitOptions,
8
+ type RequestInteractionOptions,
9
+ type SendInteractionOptions,
10
+ type SendInteractionOptionsWithoutWait,
11
+ type SendReturn,
12
+ toSendOptions,
13
+ } from './interaction_options.js';
8
14
 
9
15
  /**
10
16
  * Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
@@ -30,20 +36,26 @@ export abstract class BaseContractInteraction {
30
36
  // docs:start:send
31
37
  /**
32
38
  * Sends a transaction to the contract function with the specified options.
33
- * This function throws an error if called on a utility function.
34
- * It creates and signs the transaction if necessary, and returns a SentTx instance,
35
- * which can be used to track the transaction status, receipt, and events.
39
+ * By default, waits for the transaction to be mined and returns the receipt (or custom type).
36
40
  * @param options - An object containing 'from' property representing
37
- * the AztecAddress of the sender and optional fee configuration
38
- * @returns A SentTx instance for tracking the transaction status and information.
41
+ * the AztecAddress of the sender, optional fee configuration, and optional wait settings
42
+ * @returns TReturn (if wait is undefined/WaitOpts) or TxHash (if wait is NO_WAIT)
39
43
  */
40
- public send(options: SendInteractionOptions): SentTx {
44
+ // Overload for when wait is not specified at all - returns TReturn
45
+ public send<TReturn = TxReceipt>(options: SendInteractionOptionsWithoutWait): Promise<TReturn>;
46
+ // Generic overload for explicit wait values
47
+ // eslint-disable-next-line jsdoc/require-jsdoc
48
+ public send<TReturn = TxReceipt, W extends InteractionWaitOptions = undefined>(
49
+ options: SendInteractionOptions<W>,
50
+ ): Promise<SendReturn<W, TReturn>>;
51
+ // eslint-disable-next-line jsdoc/require-jsdoc
52
+ public async send<TReturn = TxReceipt>(
53
+ options: SendInteractionOptions<InteractionWaitOptions>,
54
+ ): Promise<SendReturn<typeof options.wait, TReturn>> {
41
55
  // docs:end:send
42
- const sendTx = async () => {
43
- const executionPayload = await this.request(options);
44
- const sendOptions = toSendOptions(options);
45
- return this.wallet.sendTx(executionPayload, sendOptions);
46
- };
47
- return new SentTx(this.wallet, sendTx);
56
+ const executionPayload = await this.request(options);
57
+ const sendOptions = toSendOptions(options);
58
+
59
+ return (await this.wallet.sendTx(executionPayload, sendOptions as any)) as SendReturn<typeof options.wait, TReturn>;
48
60
  }
49
61
  }
@@ -15,6 +15,7 @@ import {
15
15
  } from './interaction_options.js';
16
16
 
17
17
  /** A batch of function calls to be sent as a single transaction through a wallet. */
18
+ // docs:start:batch_call_class
18
19
  export class BatchCall extends BaseContractInteraction {
19
20
  constructor(
20
21
  wallet: Wallet,
@@ -22,6 +23,7 @@ export class BatchCall extends BaseContractInteraction {
22
23
  ) {
23
24
  super(wallet);
24
25
  }
26
+ // docs:end:batch_call_class
25
27
 
26
28
  /**
27
29
  * Returns an execution request that represents this operation.
@@ -74,13 +76,13 @@ export class BatchCall extends BaseContractInteraction {
74
76
  { indexedExecutionPayloads: [], utility: [], publicIndex: 0, privateIndex: 0 },
75
77
  );
76
78
 
77
- const batchRequests: Array<BatchedMethod<'simulateUtility'> | BatchedMethod<'simulateTx'>> = [];
79
+ const batchRequests: BatchedMethod[] = [];
78
80
 
79
81
  // Add utility calls to batch
80
82
  for (const [call] of utility) {
81
83
  batchRequests.push({
82
84
  name: 'simulateUtility' as const,
83
- args: [call, options?.authWitnesses] as const,
85
+ args: [call, options?.authWitnesses],
84
86
  });
85
87
  }
86
88
 
@@ -1,4 +1,11 @@
1
- import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
1
+ import {
2
+ type FunctionAbi,
3
+ FunctionCall,
4
+ FunctionSelector,
5
+ FunctionType,
6
+ decodeFromAbi,
7
+ encodeArguments,
8
+ } from '@aztec/stdlib/abi';
2
9
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
3
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
11
  import { type Capsule, type HashedValues, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
@@ -43,16 +50,16 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
43
50
  */
44
51
  public async getFunctionCall() {
45
52
  const args = encodeArguments(this.functionDao, this.args);
46
- return {
53
+ return FunctionCall.from({
47
54
  name: this.functionDao.name,
48
- args,
55
+ to: this.contractAddress,
49
56
  selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
50
57
  type: this.functionDao.functionType,
51
- to: this.contractAddress,
52
- isStatic: this.functionDao.isStatic,
53
58
  hideMsgSender: false /** Only set to `true` for enqueued public function calls */,
59
+ isStatic: this.functionDao.isStatic,
60
+ args,
54
61
  returnTypes: this.functionDao.returnTypes,
55
- };
62
+ });
56
63
  }
57
64
 
58
65
  /**