@aztec/aztec.js 0.0.1-commit.96bb3f7 → 0.0.1-commit.a072138

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 (167) 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 +16 -10
  22. package/dest/api/contract.d.ts.map +1 -1
  23. package/dest/api/contract.js +14 -8
  24. package/dest/api/keys.d.ts +1 -1
  25. package/dest/api/keys.js +1 -1
  26. package/dest/api/node.d.ts +8 -4
  27. package/dest/api/node.d.ts.map +1 -1
  28. package/dest/api/node.js +7 -3
  29. package/dest/api/protocol.d.ts +7 -1
  30. package/dest/api/protocol.d.ts.map +1 -1
  31. package/dest/api/protocol.js +6 -0
  32. package/dest/api/tx.d.ts +2 -2
  33. package/dest/api/tx.d.ts.map +1 -1
  34. package/dest/api/tx.js +1 -1
  35. package/dest/api/wallet.d.ts +3 -2
  36. package/dest/api/wallet.d.ts.map +1 -1
  37. package/dest/api/wallet.js +2 -1
  38. package/dest/authorization/call_authorization_request.d.ts +22 -1
  39. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  40. package/dest/contract/base_contract_interaction.d.ts +8 -10
  41. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  42. package/dest/contract/base_contract_interaction.js +5 -17
  43. package/dest/contract/contract_base.d.ts +4 -1
  44. package/dest/contract/contract_base.d.ts.map +1 -1
  45. package/dest/contract/contract_function_interaction.d.ts +1 -1
  46. package/dest/contract/deploy_method.d.ts +63 -16
  47. package/dest/contract/deploy_method.d.ts.map +1 -1
  48. package/dest/contract/deploy_method.js +41 -23
  49. package/dest/contract/interaction_options.d.ts +42 -5
  50. package/dest/contract/interaction_options.d.ts.map +1 -1
  51. package/dest/contract/interaction_options.js +8 -1
  52. package/dest/contract/protocol_contracts/auth-registry.d.ts +27 -0
  53. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  54. package/dest/contract/protocol_contracts/auth-registry.js +558 -0
  55. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +26 -0
  56. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  57. package/dest/contract/protocol_contracts/contract-class-registry.js +385 -0
  58. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
  59. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  60. package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
  61. package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
  62. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  63. package/dest/contract/protocol_contracts/fee-juice.js +426 -0
  64. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  65. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  66. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +575 -0
  67. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  68. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  69. package/dest/contract/protocol_contracts/public-checks.js +583 -0
  70. package/dest/contract/wait_for_proven.d.ts +2 -2
  71. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  72. package/dest/contract/wait_for_proven.js +1 -1
  73. package/dest/contract/wait_opts.d.ts +16 -0
  74. package/dest/contract/wait_opts.d.ts.map +1 -0
  75. package/dest/contract/wait_opts.js +5 -0
  76. package/dest/deployment/broadcast_function.js +3 -3
  77. package/dest/deployment/publish_class.js +2 -2
  78. package/dest/deployment/publish_instance.d.ts +2 -2
  79. package/dest/deployment/publish_instance.d.ts.map +1 -1
  80. package/dest/deployment/publish_instance.js +3 -3
  81. package/dest/ethereum/portal_manager.d.ts +3 -1
  82. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  83. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  84. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  85. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  86. package/dest/utils/authwit.d.ts +8 -6
  87. package/dest/utils/authwit.d.ts.map +1 -1
  88. package/dest/utils/authwit.js +5 -9
  89. package/dest/utils/node.d.ts +12 -1
  90. package/dest/utils/node.d.ts.map +1 -1
  91. package/dest/utils/node.js +46 -0
  92. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
  93. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  94. package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
  95. package/dest/wallet/account_manager.d.ts +5 -8
  96. package/dest/wallet/account_manager.d.ts.map +1 -1
  97. package/dest/wallet/account_manager.js +5 -11
  98. package/dest/wallet/capabilities.d.ts +444 -0
  99. package/dest/wallet/capabilities.d.ts.map +1 -0
  100. package/dest/wallet/capabilities.js +3 -0
  101. package/dest/wallet/deploy_account_method.d.ts +34 -6
  102. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  103. package/dest/wallet/deploy_account_method.js +7 -5
  104. package/dest/wallet/index.d.ts +2 -1
  105. package/dest/wallet/index.d.ts.map +1 -1
  106. package/dest/wallet/index.js +1 -0
  107. package/dest/wallet/wallet.d.ts +1460 -2424
  108. package/dest/wallet/wallet.d.ts.map +1 -1
  109. package/dest/wallet/wallet.js +179 -86
  110. package/package.json +14 -12
  111. package/src/account/account.ts +34 -58
  112. package/src/account/account_contract.ts +6 -7
  113. package/src/account/account_with_secret_key.ts +33 -8
  114. package/src/account/index.ts +2 -1
  115. package/src/account/signerless_account.ts +13 -12
  116. package/src/api/account.ts +9 -3
  117. package/src/api/authorization.ts +1 -0
  118. package/src/api/contract.ts +22 -7
  119. package/src/api/keys.ts +2 -2
  120. package/src/api/node.ts +7 -3
  121. package/src/api/protocol.ts +7 -0
  122. package/src/api/tx.ts +2 -0
  123. package/src/api/wallet.ts +43 -2
  124. package/src/contract/base_contract_interaction.ts +27 -15
  125. package/src/contract/batch_call.ts +2 -2
  126. package/src/contract/deploy_method.ts +122 -29
  127. package/src/contract/interaction_options.ts +49 -4
  128. package/src/contract/protocol_contracts/auth-registry.ts +351 -0
  129. package/src/contract/protocol_contracts/contract-class-registry.ts +241 -0
  130. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  131. package/src/contract/protocol_contracts/fee-juice.ts +264 -0
  132. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +332 -0
  133. package/src/contract/protocol_contracts/public-checks.ts +316 -0
  134. package/src/contract/wait_for_proven.ts +1 -1
  135. package/src/contract/wait_opts.ts +21 -0
  136. package/src/deployment/broadcast_function.ts +3 -3
  137. package/src/deployment/publish_class.ts +2 -2
  138. package/src/deployment/publish_instance.ts +3 -6
  139. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  140. package/src/utils/authwit.ts +19 -7
  141. package/src/utils/node.ts +62 -0
  142. package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
  143. package/src/wallet/account_manager.ts +5 -13
  144. package/src/wallet/capabilities.ts +491 -0
  145. package/src/wallet/deploy_account_method.ts +37 -13
  146. package/src/wallet/index.ts +1 -0
  147. package/src/wallet/wallet.ts +257 -93
  148. package/dest/account/interface.d.ts +0 -19
  149. package/dest/account/interface.d.ts.map +0 -1
  150. package/dest/account/interface.js +0 -5
  151. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  152. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  153. package/dest/contract/deploy_sent_tx.js +0 -46
  154. package/dest/contract/protocol_contracts.d.ts +0 -9
  155. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  156. package/dest/contract/protocol_contracts.js +0 -26
  157. package/dest/contract/sent_tx.d.ts +0 -50
  158. package/dest/contract/sent_tx.d.ts.map +0 -1
  159. package/dest/contract/sent_tx.js +0 -90
  160. package/dest/contract/unsafe_contract.d.ts +0 -15
  161. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  162. package/dest/contract/unsafe_contract.js +0 -6
  163. package/src/account/interface.ts +0 -25
  164. package/src/contract/deploy_sent_tx.ts +0 -75
  165. package/src/contract/protocol_contracts.ts +0 -35
  166. package/src/contract/sent_tx.ts +0 -129
  167. package/src/contract/unsafe_contract.ts +0 -19
@@ -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,
@@ -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,9 +33,8 @@
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
40
  * {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract#use-generated-interfaces | autogenerated type-safe interfaces}
@@ -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
 
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,64 @@ export {
11
11
  type Wallet,
12
12
  type PrivateEvent,
13
13
  type PrivateEventFilter,
14
+ type ContractMetadata,
15
+ type ContractClassMetadata,
16
+ AppCapabilitiesSchema,
17
+ WalletCapabilitiesSchema,
14
18
  FunctionCallSchema,
15
19
  ExecutionPayloadSchema,
16
20
  GasSettingsOptionSchema,
17
21
  WalletSimulationFeeOptionSchema,
22
+ WaitOptsSchema,
18
23
  SendOptionsSchema,
19
24
  SimulateOptionsSchema,
20
25
  ProfileOptionsSchema,
21
26
  MessageHashOrIntentSchema,
22
27
  BatchedMethodSchema,
23
- ContractMetadataSchema,
24
- ContractClassMetadataSchema,
25
28
  EventMetadataDefinitionSchema,
26
29
  PrivateEventSchema,
27
30
  PrivateEventFilterSchema,
31
+ ContractClassMetadataSchema,
32
+ ContractMetadataSchema,
28
33
  WalletSchema,
34
+ ContractFunctionPatternSchema,
35
+ AccountsCapabilitySchema,
36
+ GrantedAccountsCapabilitySchema,
37
+ ContractsCapabilitySchema,
38
+ GrantedContractsCapabilitySchema,
39
+ ContractClassesCapabilitySchema,
40
+ GrantedContractClassesCapabilitySchema,
41
+ SimulationCapabilitySchema,
42
+ GrantedSimulationCapabilitySchema,
43
+ TransactionCapabilitySchema,
44
+ GrantedTransactionCapabilitySchema,
45
+ DataCapabilitySchema,
46
+ GrantedDataCapabilitySchema,
47
+ CapabilitySchema,
48
+ GrantedCapabilitySchema,
29
49
  } from '../wallet/wallet.js';
30
50
 
51
+ export {
52
+ type AppCapabilities,
53
+ type WalletCapabilities,
54
+ CAPABILITY_VERSION,
55
+ type Capability,
56
+ type GrantedCapability,
57
+ type ContractFunctionPattern,
58
+ type AccountsCapability,
59
+ type GrantedAccountsCapability,
60
+ type ContractsCapability,
61
+ type GrantedContractsCapability,
62
+ type ContractClassesCapability,
63
+ type GrantedContractClassesCapability,
64
+ type SimulationCapability,
65
+ type GrantedSimulationCapability,
66
+ type TransactionCapability,
67
+ type GrantedTransactionCapability,
68
+ type DataCapability,
69
+ type GrantedDataCapability,
70
+ } from '../wallet/capabilities.js';
71
+
31
72
  export { AccountManager } from '../wallet/account_manager.js';
32
73
 
33
74
  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
  }
@@ -76,13 +76,13 @@ export class BatchCall extends BaseContractInteraction {
76
76
  { indexedExecutionPayloads: [], utility: [], publicIndex: 0, privateIndex: 0 },
77
77
  );
78
78
 
79
- const batchRequests: Array<BatchedMethod<'simulateUtility'> | BatchedMethod<'simulateTx'>> = [];
79
+ const batchRequests: BatchedMethod[] = [];
80
80
 
81
81
  // Add utility calls to batch
82
82
  for (const [call] of utility) {
83
83
  batchRequests.push({
84
84
  name: 'simulateUtility' as const,
85
- args: [call, options?.authWitnesses] as const,
85
+ args: [call, options?.authWitnesses],
86
86
  });
87
87
  }
88
88
 
@@ -9,27 +9,46 @@ import {
9
9
  getContractInstanceFromInstantiationParams,
10
10
  } from '@aztec/stdlib/contract';
11
11
  import type { PublicKeys } from '@aztec/stdlib/keys';
12
- import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
12
+ import { type Capsule, TxHash, type TxProfileResult, type TxReceipt, collectOffchainEffects } from '@aztec/stdlib/tx';
13
13
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
14
14
 
15
15
  import { publishContractClass } from '../deployment/publish_class.js';
16
16
  import { publishInstance } from '../deployment/publish_instance.js';
17
- import type { Wallet } from '../wallet/wallet.js';
17
+ import type { SendOptions, Wallet } from '../wallet/wallet.js';
18
18
  import { BaseContractInteraction } from './base_contract_interaction.js';
19
19
  import type { ContractBase } from './contract_base.js';
20
20
  import { ContractFunctionInteraction } from './contract_function_interaction.js';
21
- import { DeploySentTx } from './deploy_sent_tx.js';
22
21
  import { getGasLimits } from './get_gas_limits.js';
23
22
  import {
23
+ NO_WAIT,
24
+ type NoWait,
24
25
  type ProfileInteractionOptions,
25
26
  type RequestInteractionOptions,
26
- type SendInteractionOptions,
27
+ type SendInteractionOptionsWithoutWait,
27
28
  type SimulationInteractionFeeOptions,
28
29
  type SimulationReturn,
29
30
  toProfileOptions,
30
31
  toSendOptions,
31
32
  toSimulateOptions,
32
33
  } from './interaction_options.js';
34
+ import type { WaitOpts } from './wait_opts.js';
35
+
36
+ /**
37
+ * Wait options specific to deployment transactions.
38
+ * Extends WaitOpts with a flag to return the full receipt instead of just the contract.
39
+ */
40
+ export type DeployWaitOptions = WaitOpts & {
41
+ /** If true, return the full DeployTxReceipt instead of just the contract. Defaults to false. */
42
+ returnReceipt?: boolean;
43
+ };
44
+
45
+ /**
46
+ * Type for wait options in deployment interactions.
47
+ * - NO_WAIT symbol: Don't wait, return TxHash immediately
48
+ * - DeployWaitOptions: Wait with custom options
49
+ * - undefined: Wait with default options
50
+ */
51
+ export type DeployInteractionWaitOptions = NoWait | DeployWaitOptions | undefined;
33
52
 
34
53
  /**
35
54
  * Options for deploying a contract on the Aztec network.
@@ -55,21 +74,34 @@ export type RequestDeployOptions = RequestInteractionOptions & {
55
74
  };
56
75
 
57
76
  /**
58
- * Extends the deployment options with the required parameters to send the transaction
77
+ * Base deployment options without wait parameter.
59
78
  */
60
- export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
79
+ export type DeployOptionsWithoutWait = Omit<RequestDeployOptions, 'deployer'> & {
61
80
  /**
62
81
  * Set to true to *not* include the sender in the address computation. This option
63
82
  * is mutually exclusive with "deployer"
64
83
  */
65
84
  universalDeploy?: boolean;
66
- } & Pick<SendInteractionOptions, 'from' | 'fee'>;
85
+ } & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee'>;
86
+
87
+ /**
88
+ * Extends the deployment options with the required parameters to send the transaction.
89
+ */
90
+ export type DeployOptions<W extends DeployInteractionWaitOptions = undefined> = DeployOptionsWithoutWait & {
91
+ /**
92
+ * Options for waiting for the transaction to be mined.
93
+ * - undefined (default): wait with default options and return the contract instance
94
+ * - DeployWaitOptions: wait with custom options and return contract or receipt based on returnReceipt flag
95
+ * - NO_WAIT: return TxHash immediately without waiting
96
+ */
97
+ wait?: W;
98
+ };
67
99
 
68
100
  /**
69
101
  * Options for simulating the deployment of a contract
70
102
  * Allows skipping certain validations and computing gas estimations
71
103
  */
72
- export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
104
+ export type SimulateDeployOptions = Omit<DeployOptionsWithoutWait, 'fee'> & {
73
105
  /** The fee options for the transaction. */
74
106
  fee?: SimulationInteractionFeeOptions;
75
107
  /** Simulate without checking for the validity of the resulting transaction,
@@ -83,6 +115,29 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
83
115
  includeMetadata?: boolean;
84
116
  };
85
117
 
118
+ /** Receipt for a deployment transaction with the deployed contract instance. */
119
+ export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxReceipt & {
120
+ /** Type-safe wrapper around the deployed contract instance, linked to the deployment wallet */
121
+ contract: TContract;
122
+ /** The deployed contract instance with address and metadata. */
123
+ instance: ContractInstanceWithAddress;
124
+ };
125
+
126
+ /**
127
+ * Represents the result type of deploying a contract.
128
+ * - If wait is NO_WAIT, returns TxHash immediately.
129
+ * - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
130
+ * - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
131
+ */
132
+ export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
133
+ ? TxHash
134
+ : W extends {
135
+ // eslint-disable-next-line jsdoc/require-jsdoc
136
+ returnReceipt: true;
137
+ }
138
+ ? DeployTxReceipt<TContract>
139
+ : TContract;
140
+
86
141
  /**
87
142
  * Contract interaction for deployment.
88
143
  * Handles class publication, instance publication, and initialization of the contract.
@@ -92,8 +147,6 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
92
147
  * then technically the contract has already been "created", and all of the contract's
93
148
  * functions (private and utility) can be interacted-with immediately, without any
94
149
  * "deployment tx".
95
- *
96
- * Extends the BaseContractInteraction class.
97
150
  */
98
151
  export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
99
152
  /** The contract instance to be deployed. */
@@ -142,13 +195,30 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
142
195
  return finalExecutionPayload;
143
196
  }
144
197
 
145
- convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
198
+ convertDeployOptionsToRequestOptions(options: DeployOptionsWithoutWait): RequestDeployOptions {
146
199
  return {
147
200
  ...options,
148
201
  deployer: !options?.universalDeploy ? options.from : undefined,
149
202
  };
150
203
  }
151
204
 
205
+ /**
206
+ * Converts DeployOptions to SendOptions, stripping out the returnReceipt flag if present.
207
+ * @param options - Deploy options with wait parameter
208
+ * @returns Send options with wait parameter
209
+ */
210
+ private convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
211
+ options: DeployOptions<W>,
212
+ // eslint-disable-next-line jsdoc/require-jsdoc
213
+ ): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
214
+ return {
215
+ ...toSendOptions({
216
+ ...options,
217
+ wait: options.wait as any,
218
+ }),
219
+ } as any;
220
+ }
221
+
152
222
  /**
153
223
  * Adds this contract to the wallet and returns the Contract object.
154
224
  * @param options - Deployment options.
@@ -184,16 +254,17 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
184
254
 
185
255
  // Publish the contract class if it hasn't been published already.
186
256
  if (!options?.skipClassPublication) {
187
- if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
188
- this.log.debug(
189
- `Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
190
- );
191
- } else {
257
+ const classMetadata = await this.wallet.getContractClassMetadata(contractClass.id);
258
+ if (!classMetadata.isContractClassPubliclyRegistered) {
192
259
  this.log.info(
193
260
  `Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
194
261
  );
195
262
  const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
196
263
  calls.push(await registerContractClassInteraction.request());
264
+ } else {
265
+ this.log.debug(
266
+ `Skipping contract class publication for ${contractClass.id.toString()} as it is already registered`,
267
+ );
197
268
  }
198
269
  }
199
270
 
@@ -202,7 +273,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
202
273
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
203
274
  // Read the artifact, and if there are no public functions, warn the caller that publication of the
204
275
  // contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
205
- const deploymentInteraction = await publishInstance(this.wallet, instance);
276
+ const deploymentInteraction = publishInstance(this.wallet, instance);
206
277
  calls.push(await deploymentInteraction.request());
207
278
  }
208
279
 
@@ -231,20 +302,42 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
231
302
 
232
303
  /**
233
304
  * Send a contract deployment transaction (initialize and/or publish) using the provided options.
234
- * This function extends the 'send' method from the ContractFunctionInteraction class,
235
- * allowing us to send a transaction specifically for contract deployment.
305
+ * By default, waits for the transaction to be mined and returns the deployed contract instance.
236
306
  *
237
307
  * @param options - An object containing various deployment options such as contractAddressSalt and from.
238
- * @returns A SentTx object that returns the receipt and the deployed contract instance.
308
+ * @returns TxHash (if wait is NO_WAIT), TContract (if wait is undefined or doesn't have returnReceipt), or DeployTxReceipt (if wait.returnReceipt is true)
239
309
  */
240
- public override send(options: DeployOptions): DeploySentTx<TContract> {
241
- const sendTx = async () => {
242
- const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
243
- const sendOptions = toSendOptions(options);
244
- return this.wallet.sendTx(executionPayload, sendOptions);
245
- };
246
- this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
247
- return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, () => this.getInstance(options));
310
+ // Overload for when wait is not specified at all - returns the contract
311
+ public override send(options: DeployOptionsWithoutWait): Promise<TContract>;
312
+ // Generic overload for explicit wait values
313
+ // eslint-disable-next-line jsdoc/require-jsdoc
314
+ public override send<W extends DeployInteractionWaitOptions>(
315
+ options: DeployOptions<W>,
316
+ ): Promise<DeployReturn<TContract, W>>;
317
+ // eslint-disable-next-line jsdoc/require-jsdoc
318
+ public override async send(options: DeployOptions<DeployInteractionWaitOptions>): Promise<any> {
319
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
320
+ const sendOptions = this.convertDeployOptionsToSendOptions(options);
321
+
322
+ if (options.wait === NO_WAIT) {
323
+ const txHash = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
324
+ this.log.debug(`Sent deployment tx ${txHash.hash} of ${this.artifact.name} contract`);
325
+ return txHash;
326
+ }
327
+
328
+ const receipt = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<WaitOpts | undefined>);
329
+ this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
330
+
331
+ // Attach contract instance
332
+ const instance = await this.getInstance(options);
333
+ const contract = this.postDeployCtor(instance, this.wallet) as TContract;
334
+
335
+ // Return full receipt if requested, otherwise just the contract
336
+ if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
337
+ return { ...receipt, contract, instance };
338
+ }
339
+
340
+ return contract;
248
341
  }
249
342
 
250
343
  /**
@@ -295,7 +388,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
295
388
  *
296
389
  * @returns An object containing the function return value and profile result.
297
390
  */
298
- public async profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult> {
391
+ public async profile(options: DeployOptionsWithoutWait & ProfileInteractionOptions): Promise<TxProfileResult> {
299
392
  const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
300
393
  return await this.wallet.profileTx(executionPayload, {
301
394
  ...toProfileOptions(options),