@aztec/aztec.js 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a

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 (214) 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/abi.d.ts +2 -2
  16. package/dest/api/abi.d.ts.map +1 -1
  17. package/dest/api/account.d.ts +2 -4
  18. package/dest/api/account.d.ts.map +1 -1
  19. package/dest/api/account.js +1 -3
  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/contract.d.ts +18 -12
  24. package/dest/api/contract.d.ts.map +1 -1
  25. package/dest/api/contract.js +16 -10
  26. package/dest/api/deployment.d.ts +1 -2
  27. package/dest/api/deployment.d.ts.map +1 -1
  28. package/dest/api/deployment.js +0 -1
  29. package/dest/api/events.d.ts +18 -6
  30. package/dest/api/events.d.ts.map +1 -1
  31. package/dest/api/events.js +37 -22
  32. package/dest/api/fields.d.ts +2 -1
  33. package/dest/api/fields.d.ts.map +1 -1
  34. package/dest/api/fields.js +1 -0
  35. package/dest/api/keys.d.ts +1 -1
  36. package/dest/api/keys.js +1 -1
  37. package/dest/api/node.d.ts +8 -4
  38. package/dest/api/node.d.ts.map +1 -1
  39. package/dest/api/node.js +7 -3
  40. package/dest/api/protocol.d.ts +7 -1
  41. package/dest/api/protocol.d.ts.map +1 -1
  42. package/dest/api/protocol.js +6 -0
  43. package/dest/api/tx.d.ts +2 -2
  44. package/dest/api/tx.d.ts.map +1 -1
  45. package/dest/api/tx.js +1 -1
  46. package/dest/api/wallet.d.ts +3 -2
  47. package/dest/api/wallet.d.ts.map +1 -1
  48. package/dest/api/wallet.js +2 -1
  49. package/dest/authorization/call_authorization_request.d.ts +22 -1
  50. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  51. package/dest/contract/base_contract_interaction.d.ts +8 -10
  52. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  53. package/dest/contract/base_contract_interaction.js +5 -17
  54. package/dest/contract/batch_call.d.ts +3 -3
  55. package/dest/contract/batch_call.d.ts.map +1 -1
  56. package/dest/contract/batch_call.js +20 -9
  57. package/dest/contract/contract_base.d.ts +4 -1
  58. package/dest/contract/contract_base.d.ts.map +1 -1
  59. package/dest/contract/contract_function_interaction.d.ts +7 -16
  60. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  61. package/dest/contract/contract_function_interaction.js +107 -18
  62. package/dest/contract/deploy_method.d.ts +91 -19
  63. package/dest/contract/deploy_method.d.ts.map +1 -1
  64. package/dest/contract/deploy_method.js +73 -34
  65. package/dest/contract/get_gas_limits.js +3 -3
  66. package/dest/contract/interaction_options.d.ts +99 -21
  67. package/dest/contract/interaction_options.d.ts.map +1 -1
  68. package/dest/contract/interaction_options.js +41 -1
  69. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  70. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  71. package/dest/contract/protocol_contracts/auth-registry.js +1005 -0
  72. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
  73. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  74. package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
  75. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
  76. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  77. package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
  78. package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
  79. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  80. package/dest/contract/protocol_contracts/fee-juice.js +434 -0
  81. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  82. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  83. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +601 -0
  84. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  85. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  86. package/dest/contract/protocol_contracts/public-checks.js +609 -0
  87. package/dest/contract/wait_for_proven.d.ts +2 -2
  88. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  89. package/dest/contract/wait_for_proven.js +1 -1
  90. package/dest/contract/wait_opts.d.ts +16 -0
  91. package/dest/contract/wait_opts.d.ts.map +1 -0
  92. package/dest/contract/wait_opts.js +5 -0
  93. package/dest/deployment/publish_class.js +2 -2
  94. package/dest/deployment/publish_instance.d.ts +2 -2
  95. package/dest/deployment/publish_instance.d.ts.map +1 -1
  96. package/dest/deployment/publish_instance.js +3 -3
  97. package/dest/ethereum/portal_manager.d.ts +7 -4
  98. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  99. package/dest/ethereum/portal_manager.js +15 -16
  100. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
  101. package/dest/fee/private_fee_payment_method.d.ts +2 -1
  102. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  103. package/dest/fee/private_fee_payment_method.js +11 -10
  104. package/dest/fee/public_fee_payment_method.d.ts +2 -1
  105. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  106. package/dest/fee/public_fee_payment_method.js +11 -10
  107. package/dest/fee/sponsored_fee_payment.js +3 -3
  108. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  109. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  110. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  111. package/dest/utils/abi_types.d.ts +6 -1
  112. package/dest/utils/abi_types.d.ts.map +1 -1
  113. package/dest/utils/abi_types.js +1 -1
  114. package/dest/utils/authwit.d.ts +8 -6
  115. package/dest/utils/authwit.d.ts.map +1 -1
  116. package/dest/utils/authwit.js +15 -15
  117. package/dest/utils/cross_chain.d.ts +3 -8
  118. package/dest/utils/cross_chain.d.ts.map +1 -1
  119. package/dest/utils/cross_chain.js +8 -15
  120. package/dest/utils/node.d.ts +12 -1
  121. package/dest/utils/node.d.ts.map +1 -1
  122. package/dest/utils/node.js +46 -0
  123. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
  124. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  125. package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
  126. package/dest/wallet/account_manager.d.ts +5 -8
  127. package/dest/wallet/account_manager.d.ts.map +1 -1
  128. package/dest/wallet/account_manager.js +5 -11
  129. package/dest/wallet/capabilities.d.ts +452 -0
  130. package/dest/wallet/capabilities.d.ts.map +1 -0
  131. package/dest/wallet/capabilities.js +3 -0
  132. package/dest/wallet/deploy_account_method.d.ts +46 -7
  133. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  134. package/dest/wallet/deploy_account_method.js +33 -5
  135. package/dest/wallet/index.d.ts +2 -1
  136. package/dest/wallet/index.d.ts.map +1 -1
  137. package/dest/wallet/index.js +1 -0
  138. package/dest/wallet/wallet.d.ts +1810 -2493
  139. package/dest/wallet/wallet.d.ts.map +1 -1
  140. package/dest/wallet/wallet.js +230 -108
  141. package/package.json +25 -14
  142. package/src/account/account.ts +34 -58
  143. package/src/account/account_contract.ts +6 -7
  144. package/src/account/account_with_secret_key.ts +33 -8
  145. package/src/account/index.ts +2 -1
  146. package/src/account/signerless_account.ts +13 -12
  147. package/src/api/abi.ts +1 -0
  148. package/src/api/account.ts +9 -3
  149. package/src/api/authorization.ts +1 -0
  150. package/src/api/contract.ts +31 -9
  151. package/src/api/deployment.ts +0 -1
  152. package/src/api/events.ts +50 -32
  153. package/src/api/fields.ts +1 -0
  154. package/src/api/keys.ts +2 -2
  155. package/src/api/node.ts +7 -3
  156. package/src/api/protocol.ts +7 -0
  157. package/src/api/tx.ts +2 -0
  158. package/src/api/wallet.ts +48 -3
  159. package/src/contract/base_contract_interaction.ts +28 -15
  160. package/src/contract/batch_call.ts +20 -15
  161. package/src/contract/contract_function_interaction.ts +114 -26
  162. package/src/contract/deploy_method.ts +179 -41
  163. package/src/contract/get_gas_limits.ts +3 -3
  164. package/src/contract/interaction_options.ts +141 -23
  165. package/src/contract/protocol_contracts/auth-registry.ts +553 -0
  166. package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
  167. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  168. package/src/contract/protocol_contracts/fee-juice.ts +266 -0
  169. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +336 -0
  170. package/src/contract/protocol_contracts/public-checks.ts +320 -0
  171. package/src/contract/wait_for_proven.ts +1 -1
  172. package/src/contract/wait_opts.ts +21 -0
  173. package/src/deployment/publish_class.ts +2 -2
  174. package/src/deployment/publish_instance.ts +3 -6
  175. package/src/ethereum/portal_manager.ts +17 -21
  176. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
  177. package/src/fee/private_fee_payment_method.ts +8 -7
  178. package/src/fee/public_fee_payment_method.ts +9 -8
  179. package/src/fee/sponsored_fee_payment.ts +3 -3
  180. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  181. package/src/utils/abi_types.ts +7 -0
  182. package/src/utils/authwit.ts +34 -24
  183. package/src/utils/cross_chain.ts +9 -18
  184. package/src/utils/node.ts +62 -0
  185. package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
  186. package/src/wallet/account_manager.ts +5 -13
  187. package/src/wallet/capabilities.ts +500 -0
  188. package/src/wallet/deploy_account_method.ts +74 -13
  189. package/src/wallet/index.ts +1 -0
  190. package/src/wallet/wallet.ts +367 -128
  191. package/dest/account/interface.d.ts +0 -19
  192. package/dest/account/interface.d.ts.map +0 -1
  193. package/dest/account/interface.js +0 -5
  194. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  195. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  196. package/dest/contract/deploy_sent_tx.js +0 -46
  197. package/dest/contract/protocol_contracts.d.ts +0 -9
  198. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  199. package/dest/contract/protocol_contracts.js +0 -26
  200. package/dest/contract/sent_tx.d.ts +0 -50
  201. package/dest/contract/sent_tx.d.ts.map +0 -1
  202. package/dest/contract/sent_tx.js +0 -90
  203. package/dest/contract/unsafe_contract.d.ts +0 -15
  204. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  205. package/dest/contract/unsafe_contract.js +0 -6
  206. package/dest/deployment/broadcast_function.d.ts +0 -24
  207. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  208. package/dest/deployment/broadcast_function.js +0 -74
  209. package/src/account/interface.ts +0 -25
  210. package/src/contract/deploy_sent_tx.ts +0 -75
  211. package/src/contract/protocol_contracts.ts +0 -35
  212. package/src/contract/sent_tx.ts +0 -129
  213. package/src/contract/unsafe_contract.ts +0 -19
  214. package/src/deployment/broadcast_function.ts +0 -148
@@ -1,11 +1,11 @@
1
- import type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
1
+ import type { AuthWitnessProvider } from '@aztec/entrypoints/interfaces';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ContractArtifact } from '@aztec/stdlib/abi';
4
4
  import type { CompleteAddress } from '@aztec/stdlib/contract';
5
5
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
6
6
  import { deriveKeys } from '@aztec/stdlib/keys';
7
7
 
8
- import type { AccountInterface } from './interface.js';
8
+ import type { Account } from './account.js';
9
9
 
10
10
  /**
11
11
  * An account contract instance. Knows its artifact, deployment arguments, how to create
@@ -31,14 +31,13 @@ export interface AccountContract {
31
31
  >;
32
32
 
33
33
  /**
34
- * Returns the account interface for this account contract given an instance at the provided address.
35
- * The account interface is responsible for assembling tx requests given requested function calls, and
34
+ * Returns the account implementation for this account contract given an instance at the provided address.
35
+ * The account is responsible for assembling tx requests given requested function calls, and
36
36
  * for creating signed auth witnesses given action identifiers (message hashes).
37
37
  * @param address - Address of this account contract.
38
- * @param chainInfo - Chain id and version of the rollup where the account contract is initialized / published.
39
- * @returns An account interface instance for creating tx requests and authorizing actions.
38
+ * @returns An account instance for creating tx requests and authorizing actions.
40
39
  */
41
- getInterface(address: CompleteAddress, chainInfo: ChainInfo): AccountInterface;
40
+ getAccount(address: CompleteAddress): Account;
42
41
 
43
42
  /**
44
43
  * Returns the auth witness provider for the given address.
@@ -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
  }
package/src/api/abi.ts CHANGED
@@ -31,6 +31,7 @@ export {
31
31
  type EventSelectorLike,
32
32
  type FieldLike,
33
33
  type FunctionSelectorLike,
34
+ type OptionLike,
34
35
  type U128Like,
35
36
  type WrappedFieldLike,
36
37
  } from '../utils/abi_types.js';
@@ -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,42 @@ 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,
51
+ type OffchainMessage,
52
+ type OffchainOutput,
42
53
  type RequestInteractionOptions,
43
54
  type SendInteractionOptions,
44
55
  type ProfileInteractionOptions,
45
56
  type SimulateInteractionOptions,
46
57
  type InteractionFeeOptions,
58
+ type InteractionWaitOptions,
47
59
  type GasSettingsOption,
60
+ type SendReturn,
61
+ type SimulationResult,
62
+ type TxSendResultImmediate,
63
+ type TxSendResultMined,
64
+ emptyOffchainOutput,
65
+ extractOffchainOutput,
48
66
  toProfileOptions,
49
67
  toSendOptions,
50
68
  toSimulateOptions,
51
69
  } from '../contract/interaction_options.js';
52
70
 
53
- export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
71
+ export { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
54
72
  export { ContractBase, type ContractMethod, type ContractStorageLayout } from '../contract/contract_base.js';
55
73
  export { BatchCall } from '../contract/batch_call.js';
56
74
  export {
57
75
  type DeployOptions,
76
+ type DeployResultMined,
77
+ type DeployReturn,
78
+ type DeployTxReceipt,
79
+ type DeployWaitOptions,
80
+ type DeployInteractionWaitOptions,
58
81
  DeployMethod,
59
82
  type RequestDeployOptions,
60
83
  type SimulateDeployOptions,
61
84
  } from '../contract/deploy_method.js';
62
- export { DeploySentTx } from '../contract/deploy_sent_tx.js';
63
85
  export { waitForProven, type WaitForProvenOpts, DefaultWaitForProvenOpts } from '../contract/wait_for_proven.js';
64
86
  export { getGasLimits } from '../contract/get_gas_limits.js';
65
87
 
@@ -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,62 @@
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
+
6
+ /** Result of a paginated public event query. */
7
+ export type GetPublicEventsResult<T> = {
8
+ /** The decoded events with metadata. */
9
+ events: PublicEvent<T>[];
10
+ /** Whether the log limit was reached, indicating more results may be available. */
11
+ maxLogsHit: boolean;
12
+ };
13
+
4
14
  /**
5
15
  * Returns decoded public events given search parameters.
6
16
  * @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.
17
+ * @param eventMetadataDef - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
18
+ * @param filter - Filter options for the event query:
19
+ * - `contractAddress`: The address of the contract that emitted the events.
20
+ * - `txHash`: Transaction in which the events were emitted.
21
+ * - `fromBlock`: The block number from which to start fetching events (inclusive). Defaults to 1.
22
+ * - `toBlock`: The block number until which to fetch events (not inclusive). Defaults to latest + 1.
23
+ * - `afterLog`: Log id after which to start fetching logs. Used for pagination.
24
+ * @returns The decoded events with metadata and a flag indicating if more results are available.
11
25
  */
12
- export async function getDecodedPublicEvents<T>(
26
+ export async function getPublicEvents<T>(
13
27
  node: AztecNode,
14
28
  eventMetadataDef: EventMetadataDefinition,
15
- from: number,
16
- limit: number,
17
- ): Promise<T[]> {
18
- const { logs } = await node.getPublicLogs({
19
- fromBlock: from,
20
- toBlock: from + limit,
29
+ filter: PublicEventFilter,
30
+ ): Promise<GetPublicEventsResult<T>> {
31
+ const { logs, maxLogsHit } = await node.getPublicLogs({
32
+ fromBlock: filter.fromBlock ? Number(filter.fromBlock) : undefined,
33
+ toBlock: filter.toBlock ? Number(filter.toBlock) : undefined,
34
+ txHash: filter.txHash,
35
+ contractAddress: filter.contractAddress,
36
+ afterLog: filter.afterLog,
21
37
  });
22
38
 
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
- }
32
-
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
- }
38
-
39
- return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
40
- })
41
- .filter(log => log !== undefined) as T[];
42
-
43
- return decodedEvents;
39
+ const events: PublicEvent<T>[] = [];
40
+
41
+ for (const log of logs) {
42
+ const logFields = log.log.getEmittedFields();
43
+ // Event selector is at the last position of the emitted fields
44
+ const logEventSelector = EventSelector.fromField(logFields[logFields.length - 1]);
45
+
46
+ if (!logEventSelector.equals(eventMetadataDef.eventSelector)) {
47
+ continue;
48
+ }
49
+
50
+ events.push({
51
+ event: decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T,
52
+ metadata: {
53
+ l2BlockNumber: log.id.blockNumber,
54
+ l2BlockHash: log.id.blockHash,
55
+ txHash: log.id.txHash,
56
+ contractAddress: log.log.contractAddress,
57
+ },
58
+ });
59
+ }
60
+
61
+ return { events, maxLogsHit };
44
62
  }
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
@@ -1,6 +1,7 @@
1
1
  export {
2
2
  type Aliased,
3
3
  type SimulateOptions,
4
+ type ExecuteUtilityOptions,
4
5
  type ProfileOptions,
5
6
  type SendOptions,
6
7
  type BatchableMethods,
@@ -11,23 +12,67 @@ export {
11
12
  type Wallet,
12
13
  type PrivateEvent,
13
14
  type PrivateEventFilter,
14
- FunctionCallSchema,
15
+ type PublicEvent,
16
+ type PublicEventFilter,
17
+ type ContractMetadata,
18
+ type ContractClassMetadata,
19
+ AppCapabilitiesSchema,
20
+ WalletCapabilitiesSchema,
15
21
  ExecutionPayloadSchema,
16
22
  GasSettingsOptionSchema,
17
23
  WalletSimulationFeeOptionSchema,
24
+ WaitOptsSchema,
18
25
  SendOptionsSchema,
19
26
  SimulateOptionsSchema,
20
27
  ProfileOptionsSchema,
21
28
  MessageHashOrIntentSchema,
22
29
  BatchedMethodSchema,
23
- ContractMetadataSchema,
24
- ContractClassMetadataSchema,
25
30
  EventMetadataDefinitionSchema,
26
31
  PrivateEventSchema,
27
32
  PrivateEventFilterSchema,
33
+ PublicEventSchema,
34
+ PublicEventFilterSchema,
35
+ ContractClassMetadataSchema,
36
+ ContractMetadataSchema,
28
37
  WalletSchema,
38
+ ContractFunctionPatternSchema,
39
+ AccountsCapabilitySchema,
40
+ GrantedAccountsCapabilitySchema,
41
+ ContractsCapabilitySchema,
42
+ GrantedContractsCapabilitySchema,
43
+ ContractClassesCapabilitySchema,
44
+ GrantedContractClassesCapabilitySchema,
45
+ SimulationCapabilitySchema,
46
+ GrantedSimulationCapabilitySchema,
47
+ TransactionCapabilitySchema,
48
+ GrantedTransactionCapabilitySchema,
49
+ DataCapabilitySchema,
50
+ GrantedDataCapabilitySchema,
51
+ CapabilitySchema,
52
+ GrantedCapabilitySchema,
29
53
  } from '../wallet/wallet.js';
30
54
 
55
+ export {
56
+ type AppCapabilities,
57
+ type WalletCapabilities,
58
+ CAPABILITY_VERSION,
59
+ type Capability,
60
+ type GrantedCapability,
61
+ type ContractFunctionPattern,
62
+ type AccountsCapability,
63
+ type GrantedAccountsCapability,
64
+ type ContractsCapability,
65
+ type GrantedContractsCapability,
66
+ type ContractClassesCapability,
67
+ type GrantedContractClassesCapability,
68
+ type SimulationCapability,
69
+ type GrantedSimulationCapability,
70
+ type TransactionCapability,
71
+ type GrantedTransactionCapability,
72
+ type DataCapability,
73
+ type GrantedDataCapability,
74
+ } from '../wallet/capabilities.js';
75
+
31
76
  export { AccountManager } from '../wallet/account_manager.js';
32
77
 
33
78
  export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
@@ -1,10 +1,17 @@
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
+ type TxSendResultMined,
13
+ toSendOptions,
14
+ } from './interaction_options.js';
8
15
 
9
16
  /**
10
17
  * Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
@@ -30,20 +37,26 @@ export abstract class BaseContractInteraction {
30
37
  // docs:start:send
31
38
  /**
32
39
  * 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.
40
+ * By default, waits for the transaction to be mined and returns the receipt (or custom type).
36
41
  * @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.
42
+ * the AztecAddress of the sender, optional fee configuration, and optional wait settings
43
+ * @returns TReturn (if wait is undefined/WaitOpts) or TxHash (if wait is NO_WAIT)
39
44
  */
40
- public send(options: SendInteractionOptions): SentTx {
45
+ // Overload for when wait is not specified at all - returns { receipt: TReturn, offchainEffects }
46
+ public send<TReturn = TxReceipt>(options: SendInteractionOptionsWithoutWait): Promise<TxSendResultMined<TReturn>>;
47
+ // Generic overload for explicit wait values
48
+ // eslint-disable-next-line jsdoc/require-jsdoc
49
+ public send<TReturn = TxReceipt, W extends InteractionWaitOptions = undefined>(
50
+ options: SendInteractionOptions<W>,
51
+ ): Promise<SendReturn<W, TReturn>>;
52
+ // eslint-disable-next-line jsdoc/require-jsdoc
53
+ public async send<TReturn = TxReceipt>(
54
+ options: SendInteractionOptions<InteractionWaitOptions>,
55
+ ): Promise<SendReturn<typeof options.wait, TReturn>> {
41
56
  // 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);
57
+ const executionPayload = await this.request(options);
58
+ const sendOptions = toSendOptions(options);
59
+
60
+ return (await this.wallet.sendTx(executionPayload, sendOptions as any)) as SendReturn<typeof options.wait, TReturn>;
48
61
  }
49
62
  }