@aztec/aztec.js 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c

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 (212) 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 +9 -10
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +21 -9
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/account_with_secret_key.js +21 -4
  9. package/dest/account/index.d.ts +4 -3
  10. package/dest/account/index.d.ts.map +1 -1
  11. package/dest/account/index.js +2 -0
  12. package/dest/account/signerless_account.d.ts +6 -7
  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 +4 -2
  31. package/dest/api/fields.d.ts.map +1 -1
  32. package/dest/api/fields.js +3 -1
  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 +23 -2
  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 +3 -3
  53. package/dest/contract/batch_call.d.ts.map +1 -1
  54. package/dest/contract/batch_call.js +11 -6
  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 +10 -7
  60. package/dest/contract/deploy_method.d.ts +77 -18
  61. package/dest/contract/deploy_method.d.ts.map +1 -1
  62. package/dest/contract/deploy_method.js +56 -30
  63. package/dest/contract/interaction_options.d.ts +49 -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 +36 -0
  67. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  68. package/dest/contract/protocol_contracts/auth-registry.js +997 -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 +139 -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 +593 -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 +601 -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 +3 -3
  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 +9 -6
  95. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  96. package/dest/ethereum/portal_manager.js +17 -18
  97. package/dest/fee/fee_juice_payment_method_with_claim.js +7 -7
  98. package/dest/fee/private_fee_payment_method.js +11 -11
  99. package/dest/fee/public_fee_payment_method.js +11 -11
  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/abi_types.d.ts +2 -2
  105. package/dest/utils/abi_types.d.ts.map +1 -1
  106. package/dest/utils/authwit.d.ts +9 -7
  107. package/dest/utils/authwit.d.ts.map +1 -1
  108. package/dest/utils/authwit.js +6 -10
  109. package/dest/utils/cross_chain.d.ts +2 -2
  110. package/dest/utils/cross_chain.d.ts.map +1 -1
  111. package/dest/utils/fee_juice.js +1 -1
  112. package/dest/utils/field_compressed_string.js +1 -1
  113. package/dest/utils/node.d.ts +12 -1
  114. package/dest/utils/node.d.ts.map +1 -1
  115. package/dest/utils/node.js +46 -0
  116. package/dest/utils/pub_key.d.ts +2 -2
  117. package/dest/utils/pub_key.d.ts.map +1 -1
  118. package/dest/utils/pub_key.js +1 -1
  119. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
  120. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  121. package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
  122. package/dest/wallet/account_manager.d.ts +6 -9
  123. package/dest/wallet/account_manager.d.ts.map +1 -1
  124. package/dest/wallet/account_manager.js +6 -12
  125. package/dest/wallet/capabilities.d.ts +452 -0
  126. package/dest/wallet/capabilities.d.ts.map +1 -0
  127. package/dest/wallet/capabilities.js +3 -0
  128. package/dest/wallet/deploy_account_method.d.ts +47 -8
  129. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  130. package/dest/wallet/deploy_account_method.js +34 -6
  131. package/dest/wallet/index.d.ts +2 -1
  132. package/dest/wallet/index.d.ts.map +1 -1
  133. package/dest/wallet/index.js +1 -0
  134. package/dest/wallet/wallet.d.ts +1817 -984
  135. package/dest/wallet/wallet.d.ts.map +1 -1
  136. package/dest/wallet/wallet.js +216 -101
  137. package/package.json +25 -14
  138. package/src/account/account.ts +34 -58
  139. package/src/account/account_contract.ts +7 -8
  140. package/src/account/account_with_secret_key.ts +34 -9
  141. package/src/account/index.ts +3 -2
  142. package/src/account/signerless_account.ts +14 -13
  143. package/src/api/account.ts +9 -3
  144. package/src/api/authorization.ts +1 -0
  145. package/src/api/contract.ts +24 -9
  146. package/src/api/deployment.ts +0 -1
  147. package/src/api/events.ts +35 -27
  148. package/src/api/fields.ts +3 -1
  149. package/src/api/keys.ts +2 -2
  150. package/src/api/node.ts +7 -3
  151. package/src/api/protocol.ts +7 -0
  152. package/src/api/tx.ts +2 -0
  153. package/src/api/wallet.ts +52 -3
  154. package/src/authorization/call_authorization_request.ts +1 -1
  155. package/src/contract/base_contract_interaction.ts +27 -15
  156. package/src/contract/batch_call.ts +10 -13
  157. package/src/contract/contract_function_interaction.ts +17 -7
  158. package/src/contract/deploy_method.ts +146 -36
  159. package/src/contract/interaction_options.ts +56 -4
  160. package/src/contract/protocol_contracts/auth-registry.ts +551 -0
  161. package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
  162. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  163. package/src/contract/protocol_contracts/fee-juice.ts +264 -0
  164. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +334 -0
  165. package/src/contract/protocol_contracts/public-checks.ts +318 -0
  166. package/src/contract/wait_for_proven.ts +1 -1
  167. package/src/contract/wait_opts.ts +21 -0
  168. package/src/deployment/publish_class.ts +3 -3
  169. package/src/deployment/publish_instance.ts +3 -6
  170. package/src/ethereum/portal_manager.ts +20 -24
  171. package/src/fee/fee_juice_payment_method_with_claim.ts +6 -6
  172. package/src/fee/private_fee_payment_method.ts +8 -8
  173. package/src/fee/public_fee_payment_method.ts +9 -9
  174. package/src/fee/sponsored_fee_payment.ts +3 -3
  175. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  176. package/src/utils/abi_types.ts +1 -1
  177. package/src/utils/authwit.ts +20 -8
  178. package/src/utils/cross_chain.ts +1 -1
  179. package/src/utils/fee_juice.ts +1 -1
  180. package/src/utils/field_compressed_string.ts +1 -1
  181. package/src/utils/node.ts +62 -0
  182. package/src/utils/pub_key.ts +2 -2
  183. package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
  184. package/src/wallet/account_manager.ts +6 -14
  185. package/src/wallet/capabilities.ts +500 -0
  186. package/src/wallet/deploy_account_method.ts +75 -14
  187. package/src/wallet/index.ts +1 -0
  188. package/src/wallet/wallet.ts +375 -110
  189. package/dest/account/interface.d.ts +0 -19
  190. package/dest/account/interface.d.ts.map +0 -1
  191. package/dest/account/interface.js +0 -5
  192. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  193. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  194. package/dest/contract/deploy_sent_tx.js +0 -46
  195. package/dest/contract/protocol_contracts.d.ts +0 -9
  196. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  197. package/dest/contract/protocol_contracts.js +0 -26
  198. package/dest/contract/sent_tx.d.ts +0 -51
  199. package/dest/contract/sent_tx.d.ts.map +0 -1
  200. package/dest/contract/sent_tx.js +0 -90
  201. package/dest/contract/unsafe_contract.d.ts +0 -15
  202. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  203. package/dest/contract/unsafe_contract.js +0 -6
  204. package/dest/deployment/broadcast_function.d.ts +0 -24
  205. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  206. package/dest/deployment/broadcast_function.js +0 -74
  207. package/src/account/interface.ts +0 -25
  208. package/src/contract/deploy_sent_tx.ts +0 -75
  209. package/src/contract/protocol_contracts.ts +0 -35
  210. package/src/contract/sent_tx.ts +0 -130
  211. package/src/contract/unsafe_contract.ts +0 -19
  212. package/src/deployment/broadcast_function.ts +0 -148
@@ -1,24 +1,20 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/fields';
2
+ import { BlockNumber, BlockNumberPositiveSchema } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import {
5
+ type AbiDecoded,
4
6
  AbiTypeSchema,
5
7
  type ContractArtifact,
6
8
  ContractArtifactSchema,
7
9
  type EventMetadataDefinition,
8
- type FunctionCall,
9
- FunctionType,
10
+ FunctionCall,
10
11
  } from '@aztec/stdlib/abi';
11
12
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
12
13
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import {
14
- type ContractClassMetadata,
15
- ContractClassWithIdSchema,
16
- type ContractInstanceWithAddress,
17
- ContractInstanceWithAddressSchema,
18
- type ContractMetadata,
19
- } from '@aztec/stdlib/contract';
14
+ import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
20
15
  import { Gas } from '@aztec/stdlib/gas';
21
- import { AbiDecodedSchema, type ApiSchemaFor, type ZodFor, optional, schemas } from '@aztec/stdlib/schemas';
16
+ import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
17
+ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
22
18
  import {
23
19
  Capsule,
24
20
  HashedValues,
@@ -26,20 +22,24 @@ import {
26
22
  TxProfileResult,
27
23
  TxReceipt,
28
24
  TxSimulationResult,
29
- UtilitySimulationResult,
25
+ UtilityExecutionResult,
26
+ inTxSchema,
30
27
  } from '@aztec/stdlib/tx';
31
- import type { ExecutionPayload } from '@aztec/stdlib/tx';
32
28
 
33
29
  import { z } from 'zod';
34
30
 
35
- import type {
36
- FeeEstimationOptions,
37
- GasSettingsOption,
38
- ProfileInteractionOptions,
39
- SendInteractionOptions,
40
- SimulateInteractionOptions,
31
+ import {
32
+ type FeeEstimationOptions,
33
+ type GasSettingsOption,
34
+ type InteractionWaitOptions,
35
+ NO_WAIT,
36
+ type ProfileInteractionOptions,
37
+ type SendInteractionOptionsWithoutWait,
38
+ type SendReturn,
39
+ type SimulateInteractionOptions,
41
40
  } from '../contract/interaction_options.js';
42
41
  import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
42
+ import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
43
43
 
44
44
  /**
45
45
  * A wrapper type that allows any item to be associated with an alias.
@@ -57,7 +57,7 @@ export type Aliased<T> = {
57
57
 
58
58
  /**
59
59
  * Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
60
- * a simplified version that only hints at the wallet wether the interaction contains a
60
+ * a simplified version that only hints at the wallet whether the interaction contains a
61
61
  * fee payment method or not
62
62
  */
63
63
  export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
@@ -67,7 +67,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
67
67
 
68
68
  /**
69
69
  * Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
70
- * a simplified version that only hints at the wallet wether the interaction contains a
70
+ * a simplified version that only hints at the wallet whether the interaction contains a
71
71
  * fee payment method or not
72
72
  */
73
73
  export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
@@ -77,45 +77,54 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
77
77
 
78
78
  /**
79
79
  * Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
80
- * a simplified version that only hints at the wallet wether the interaction contains a
80
+ * a simplified version that only hints at the wallet whether the interaction contains a
81
81
  * fee payment method or not
82
82
  */
83
- export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
83
+ export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
84
+ SendInteractionOptionsWithoutWait,
85
+ 'fee'
86
+ > & {
84
87
  /** The fee options */
85
88
  fee?: GasSettingsOption;
89
+ /** Whether to wait for the transaction to be mined */
90
+ wait?: W;
86
91
  };
87
92
 
88
93
  /**
89
- * Helper type that represents all methods that can be batched.
94
+ * Helper type that represents all methods that can be batched (all methods except batch itself).
90
95
  */
91
- export type BatchableMethods = Pick<
92
- Wallet,
93
- 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility' | 'simulateTx'
94
- >;
96
+ export type BatchableMethods = Omit<Wallet, 'batch'>;
95
97
 
96
98
  /**
97
- * From the batchable methods, we create a type that represents a method call with its name and arguments.
98
- * This is what the wallet will accept as arguments to the `batch` method.
99
+ * A method call with its name and arguments.
99
100
  */
100
- export type BatchedMethod<T extends keyof BatchableMethods> = {
101
+ type BatchedMethodInternal<T extends keyof BatchableMethods> = {
101
102
  /** The method name */
102
103
  name: T;
103
104
  /** The method arguments */
104
105
  args: Parameters<BatchableMethods[T]>;
105
106
  };
106
107
 
108
+ /**
109
+ * Union of all possible batched method calls.
110
+ * This ensures type safety: the `args` must match the specific `name`.
111
+ */
112
+ export type BatchedMethod = {
113
+ [K in keyof BatchableMethods]: BatchedMethodInternal<K>;
114
+ }[keyof BatchableMethods];
115
+
107
116
  /**
108
117
  * Helper type to extract the return type of a batched method
109
118
  */
110
119
  export type BatchedMethodResult<T> =
111
- T extends BatchedMethod<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
120
+ T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
112
121
 
113
122
  /**
114
123
  * Wrapper type for batch results that includes the method name for discriminated union deserialization.
115
124
  * Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
116
125
  * when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
117
126
  */
118
- export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMethods>> = {
127
+ export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
119
128
  /** The method name */
120
129
  name: T['name'];
121
130
  /** The method result */
@@ -125,25 +134,118 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
125
134
  /**
126
135
  * Maps a tuple of BatchedMethod to a tuple of their wrapped return types
127
136
  */
128
- export type BatchResults<T extends readonly BatchedMethod<keyof BatchableMethods>[]> = {
137
+ export type BatchResults<T extends readonly BatchedMethod[]> = {
129
138
  [K in keyof T]: BatchedMethodResultWrapper<T[K]>;
130
139
  };
131
140
 
141
+ /**
142
+ * Base filter options for event queries.
143
+ */
144
+ export type EventFilterBase = {
145
+ /** Transaction in which the events were emitted. */
146
+ txHash?: TxHash;
147
+ /** The block number from which to start fetching events (inclusive).
148
+ * Optional. If provided, it must be greater or equal than 1.
149
+ * Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
150
+ */
151
+ fromBlock?: BlockNumber;
152
+ /** The block number until which to fetch logs (not inclusive).
153
+ * Optional. If provided, it must be greater than fromBlock.
154
+ */
155
+ toBlock?: BlockNumber;
156
+ };
157
+
158
+ /**
159
+ * Filter options when querying private events.
160
+ */
161
+ export type PrivateEventFilter = EventFilterBase & {
162
+ /** The address of the contract that emitted the events. */
163
+ contractAddress: AztecAddress;
164
+ /** Addresses of accounts that are in scope for this filter. */
165
+ scopes: AztecAddress[];
166
+ };
167
+
168
+ /**
169
+ * Filter options when querying public events.
170
+ */
171
+ export type PublicEventFilter = EventFilterBase & {
172
+ /** The address of the contract that emitted the events. */
173
+ contractAddress?: AztecAddress;
174
+ };
175
+
176
+ /**
177
+ * An ABI decoded event with associated metadata.
178
+ * @typeParam T - The decoded event type
179
+ * @typeParam M - Additional metadata fields (empty by default)
180
+ */
181
+ export type Event<T, M extends object = object> = {
182
+ /** The ABI decoded event */
183
+ event: T;
184
+ /** Metadata describing event context information such as tx and block */
185
+ metadata: InTx & M;
186
+ };
187
+
188
+ /** An ABI decoded private event with associated metadata. */
189
+ export type PrivateEvent<T> = Event<T>;
190
+
191
+ /** An ABI decoded public event with associated metadata (includes contract address). */
192
+ export type PublicEvent<T> = Event<
193
+ T,
194
+ {
195
+ /**
196
+ * Address of the contract that emitted this event
197
+ */
198
+ contractAddress: AztecAddress;
199
+ }
200
+ >;
201
+
202
+ /**
203
+ * Contract metadata including deployment and registration status.
204
+ */
205
+ export type ContractMetadata = {
206
+ /** The contract instance */
207
+ instance?: ContractInstanceWithAddress;
208
+ /** Whether the contract has been initialized (init nullifier exists) */
209
+ isContractInitialized: boolean;
210
+ /** Whether the contract instance is publicly deployed on-chain */
211
+ isContractPublished: boolean;
212
+ /** Whether the contract has been updated to a different class */
213
+ isContractUpdated: boolean;
214
+ /** The updated contract class ID if the contract has been updated */
215
+ updatedContractClassId?: Fr | undefined;
216
+ };
217
+
218
+ /**
219
+ * Contract class metadata.
220
+ */
221
+ export type ContractClassMetadata = {
222
+ /** Whether the artifact is registered in the wallet */
223
+ isArtifactRegistered: boolean;
224
+ /** Whether the contract class is publicly registered on-chain */
225
+ isContractClassPubliclyRegistered: boolean;
226
+ };
227
+
228
+ /**
229
+ * Options for executing a utility function call.
230
+ */
231
+ export type ExecuteUtilityOptions = {
232
+ /** The scope for the utility execution (determines which notes and keys are visible). */
233
+ scope: AztecAddress;
234
+ /** Optional auth witnesses to use during execution. */
235
+ authWitnesses?: AuthWitness[];
236
+ };
237
+
132
238
  /**
133
239
  * The wallet interface.
134
240
  */
135
241
  export type Wallet = {
136
- getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
137
- getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
138
242
  getPrivateEvents<T>(
139
- contractAddress: AztecAddress,
140
243
  eventMetadata: EventMetadataDefinition,
141
- from: number,
142
- numBlocks: number,
143
- recipients: AztecAddress[],
144
- ): Promise<T[]>;
244
+ eventFilter: PrivateEventFilter,
245
+ ): Promise<PrivateEvent<T>[]>;
145
246
  getChainInfo(): Promise<ChainInfo>;
146
- getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
247
+ getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
248
+ getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
147
249
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
148
250
  getAddressBook(): Promise<Aliased<AztecAddress>[]>;
149
251
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
@@ -153,26 +255,19 @@ export type Wallet = {
153
255
  secretKey?: Fr,
154
256
  ): Promise<ContractInstanceWithAddress>;
155
257
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
156
- simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
258
+ executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
157
259
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
158
- sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
159
- createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent): Promise<AuthWitness>;
160
- batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
260
+ sendTx<W extends InteractionWaitOptions = undefined>(
261
+ exec: ExecutionPayload,
262
+ opts: SendOptions<W>,
263
+ ): Promise<SendReturn<W>>;
264
+ createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
265
+ requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
266
+ batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
161
267
  };
162
268
 
163
- export const FunctionCallSchema = z.object({
164
- name: z.string(),
165
- to: schemas.AztecAddress,
166
- selector: schemas.FunctionSelector,
167
- type: z.nativeEnum(FunctionType),
168
- isStatic: z.boolean(),
169
- hideMsgSender: z.boolean(),
170
- args: z.array(schemas.Fr),
171
- returnTypes: z.array(AbiTypeSchema),
172
- });
173
-
174
269
  export const ExecutionPayloadSchema = z.object({
175
- calls: z.array(FunctionCallSchema),
270
+ calls: z.array(FunctionCall.schema),
176
271
  authWitnesses: z.array(AuthWitness.schema),
177
272
  capsules: z.array(Capsule.schema),
178
273
  extraHashedArgs: z.array(HashedValues.schema),
@@ -195,11 +290,20 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
195
290
  estimateGas: optional(z.boolean()),
196
291
  });
197
292
 
293
+ export const WaitOptsSchema = z.object({
294
+ ignoreDroppedReceiptsFor: optional(z.number()),
295
+ timeout: optional(z.number()),
296
+ interval: optional(z.number()),
297
+ dontThrowOnRevert: optional(z.boolean()),
298
+ });
299
+
198
300
  export const SendOptionsSchema = z.object({
199
301
  from: schemas.AztecAddress,
200
302
  authWitnesses: optional(z.array(AuthWitness.schema)),
201
303
  capsules: optional(z.array(Capsule.schema)),
202
304
  fee: optional(GasSettingsOptionSchema),
305
+ wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
306
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
203
307
  });
204
308
 
205
309
  export const SimulateOptionsSchema = z.object({
@@ -210,6 +314,7 @@ export const SimulateOptionsSchema = z.object({
210
314
  skipTxValidation: optional(z.boolean()),
211
315
  skipFeeEnforcement: optional(z.boolean()),
212
316
  includeMetadata: optional(z.boolean()),
317
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
213
318
  });
214
319
 
215
320
  export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
@@ -218,67 +323,190 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
218
323
  });
219
324
 
220
325
  export const MessageHashOrIntentSchema = z.union([
221
- schemas.Fr,
222
326
  z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
223
327
  z.object({
224
328
  caller: schemas.AztecAddress,
225
- call: FunctionCallSchema,
329
+ call: FunctionCall.schema,
226
330
  }),
227
331
  ]);
228
332
 
229
- export const BatchedMethodSchema = z.union([
230
- z.object({
231
- name: z.literal('registerSender'),
232
- args: z.tuple([schemas.AztecAddress, optional(z.string())]),
233
- }),
234
- z.object({
235
- name: z.literal('registerContract'),
236
- args: z.tuple([ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
237
- }),
238
- z.object({
239
- name: z.literal('sendTx'),
240
- args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
241
- }),
333
+ export const EventMetadataDefinitionSchema = z.object({
334
+ eventSelector: schemas.EventSelector,
335
+ abiType: AbiTypeSchema,
336
+ fieldNames: z.array(z.string()),
337
+ });
338
+
339
+ const EventFilterBaseSchema = z.object({
340
+ txHash: optional(TxHash.schema),
341
+ fromBlock: optional(BlockNumberPositiveSchema),
342
+ toBlock: optional(BlockNumberPositiveSchema),
343
+ });
344
+
345
+ export const PrivateEventFilterSchema = EventFilterBaseSchema.extend({
346
+ contractAddress: schemas.AztecAddress,
347
+ scopes: z.array(schemas.AztecAddress),
348
+ });
349
+
350
+ export const PublicEventFilterSchema = EventFilterBaseSchema.extend({
351
+ contractAddress: optional(schemas.AztecAddress),
352
+ });
353
+
354
+ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
242
355
  z.object({
243
- name: z.literal('simulateUtility'),
244
- args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema))]),
356
+ event: AbiDecodedSchema,
357
+ metadata: inTxSchema(),
245
358
  }),
359
+ );
360
+
361
+ export const PublicEventSchema = zodFor<PublicEvent<AbiDecoded>>()(
246
362
  z.object({
247
- name: z.literal('simulateTx'),
248
- args: z.tuple([ExecutionPayloadSchema, SimulateOptionsSchema]),
363
+ event: AbiDecodedSchema,
364
+ metadata: z.intersection(inTxSchema(), z.object({ contractAddress: schemas.AztecAddress })),
249
365
  }),
250
- ]);
366
+ );
251
367
 
252
368
  export const ContractMetadataSchema = z.object({
253
- contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
369
+ instance: optional(ContractInstanceWithAddressSchema),
254
370
  isContractInitialized: z.boolean(),
255
371
  isContractPublished: z.boolean(),
256
- }) satisfies ZodFor<ContractMetadata>;
372
+ isContractUpdated: z.boolean(),
373
+ updatedContractClassId: optional(schemas.Fr),
374
+ });
257
375
 
258
376
  export const ContractClassMetadataSchema = z.object({
259
- contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
377
+ isArtifactRegistered: z.boolean(),
260
378
  isContractClassPubliclyRegistered: z.boolean(),
261
- artifact: z.union([ContractArtifactSchema, z.undefined()]),
262
- }) satisfies ZodFor<ContractClassMetadata>;
379
+ });
263
380
 
264
- export const EventMetadataDefinitionSchema = z.object({
265
- eventSelector: schemas.EventSelector,
266
- abiType: AbiTypeSchema,
267
- fieldNames: z.array(z.string()),
381
+ export const ContractFunctionPatternSchema = z.object({
382
+ contract: z.union([schemas.AztecAddress, z.literal('*')]),
383
+ function: z.union([z.string(), z.literal('*')]),
384
+ additionalScopes: optional(z.union([z.array(schemas.AztecAddress), z.literal('*')])),
268
385
  });
269
386
 
270
- export const WalletSchema: ApiSchemaFor<Wallet> = {
387
+ export const AccountsCapabilitySchema = z.object({
388
+ type: z.literal('accounts'),
389
+ canGet: optional(z.boolean()),
390
+ canCreateAuthWit: optional(z.boolean()),
391
+ });
392
+
393
+ export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
394
+ accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
395
+ });
396
+
397
+ export const ContractsCapabilitySchema = z.object({
398
+ type: z.literal('contracts'),
399
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
400
+ canRegister: optional(z.boolean()),
401
+ canGetMetadata: optional(z.boolean()),
402
+ });
403
+
404
+ export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
405
+
406
+ export const ContractClassesCapabilitySchema = z.object({
407
+ type: z.literal('contractClasses'),
408
+ classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
409
+ canGetMetadata: z.boolean(),
410
+ });
411
+
412
+ export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
413
+
414
+ export const SimulationCapabilitySchema = z.object({
415
+ type: z.literal('simulation'),
416
+ transactions: optional(
417
+ z.object({
418
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
419
+ }),
420
+ ),
421
+ utilities: optional(
422
+ z.object({
423
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
424
+ }),
425
+ ),
426
+ });
427
+
428
+ export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
429
+
430
+ export const TransactionCapabilitySchema = z.object({
431
+ type: z.literal('transaction'),
432
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
433
+ });
434
+
435
+ export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
436
+
437
+ export const DataCapabilitySchema = z.object({
438
+ type: z.literal('data'),
439
+ addressBook: optional(z.boolean()),
440
+ privateEvents: optional(
441
+ z.object({
442
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
443
+ }),
444
+ ),
445
+ });
446
+
447
+ export const GrantedDataCapabilitySchema = DataCapabilitySchema;
448
+
449
+ export const CapabilitySchema = z.discriminatedUnion('type', [
450
+ AccountsCapabilitySchema,
451
+ ContractsCapabilitySchema,
452
+ ContractClassesCapabilitySchema,
453
+ SimulationCapabilitySchema,
454
+ TransactionCapabilitySchema,
455
+ DataCapabilitySchema,
456
+ ]);
457
+
458
+ export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
459
+ GrantedAccountsCapabilitySchema,
460
+ GrantedContractsCapabilitySchema,
461
+ GrantedContractClassesCapabilitySchema,
462
+ GrantedSimulationCapabilitySchema,
463
+ GrantedTransactionCapabilitySchema,
464
+ GrantedDataCapabilitySchema,
465
+ ]);
466
+
467
+ export const AppCapabilitiesSchema = z.object({
468
+ version: z.literal('1.0'),
469
+ metadata: z.object({
470
+ name: z.string(),
471
+ version: z.string(),
472
+ description: optional(z.string()),
473
+ url: optional(z.string()),
474
+ icon: optional(z.string()),
475
+ }),
476
+ capabilities: z.array(CapabilitySchema),
477
+ behavior: optional(
478
+ z.object({
479
+ mode: optional(z.enum(['strict', 'permissive'])),
480
+ expiration: optional(z.number()),
481
+ }),
482
+ ),
483
+ });
484
+
485
+ export const WalletCapabilitiesSchema = z.object({
486
+ version: z.literal('1.0'),
487
+ granted: z.array(GrantedCapabilitySchema),
488
+ wallet: z.object({
489
+ name: z.string(),
490
+ version: z.string(),
491
+ }),
492
+ expiresAt: optional(z.number()),
493
+ });
494
+
495
+ /**
496
+ * Record of all wallet method schemas (excluding batch).
497
+ * This is the single source of truth for method schemas - batch schemas are derived from this.
498
+ */
499
+ const WalletMethodSchemas = {
271
500
  getChainInfo: z
272
501
  .function()
273
502
  .args()
274
503
  .returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
275
- getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
276
504
  getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
277
- getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
505
+ getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
278
506
  getPrivateEvents: z
279
507
  .function()
280
- .args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
281
- .returns(z.array(AbiDecodedSchema)),
508
+ .args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
509
+ .returns(z.array(PrivateEventSchema)),
282
510
  registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
283
511
  getAddressBook: z
284
512
  .function()
@@ -293,26 +521,63 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
293
521
  .args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
294
522
  .returns(ContractInstanceWithAddressSchema),
295
523
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
296
- simulateUtility: z
524
+ executeUtility: z
297
525
  .function()
298
- .args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
299
- .returns(UtilitySimulationResult.schema),
526
+ .args(
527
+ FunctionCall.schema,
528
+ z.object({
529
+ scope: schemas.AztecAddress,
530
+ authWitnesses: optional(z.array(AuthWitness.schema)),
531
+ }),
532
+ )
533
+ .returns(UtilityExecutionResult.schema),
300
534
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
301
- sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
535
+ sendTx: z
536
+ .function()
537
+ .args(ExecutionPayloadSchema, SendOptionsSchema)
538
+ .returns(z.union([TxHash.schema, TxReceipt.schema])),
302
539
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
540
+ requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
541
+ };
542
+
543
+ /**
544
+ * Creates batch schemas from the individual wallet methods.
545
+ * This allows us to define them once and derive batch schemas automatically,
546
+ * reducing duplication and ensuring consistency.
547
+ */
548
+ function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
549
+ methodSchemas: T,
550
+ ) {
551
+ const names = Object.keys(methodSchemas) as (keyof T)[];
552
+
553
+ const namesAndArgs = names.map(name =>
554
+ z.object({
555
+ name: z.literal(name),
556
+ args: methodSchemas[name].parameters(),
557
+ }),
558
+ );
559
+
560
+ const namesAndReturns = names.map(name =>
561
+ z.object({
562
+ name: z.literal(name),
563
+ result: methodSchemas[name].returnType(),
564
+ }),
565
+ );
566
+
567
+ // Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
568
+ // but we're building the array dynamically. The runtime behavior is correct.
569
+ return {
570
+ input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
571
+ output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
572
+ };
573
+ }
574
+
575
+ const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
576
+
577
+ export { BatchedMethodSchema, BatchedResultSchema };
578
+
579
+ export const WalletSchema: ApiSchemaFor<Wallet> = {
580
+ ...WalletMethodSchemas,
303
581
  // @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
304
- batch: z
305
- .function()
306
- .args(z.array(BatchedMethodSchema))
307
- .returns(
308
- z.array(
309
- z.discriminatedUnion('name', [
310
- z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
311
- z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
312
- z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
313
- z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
314
- z.object({ name: z.literal('simulateTx'), result: TxSimulationResult.schema }),
315
- ]),
316
- ),
317
- ),
582
+ batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
318
583
  };
@@ -1,19 +0,0 @@
1
- import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import type { CompleteAddress } from '@aztec/stdlib/contract';
5
- /**
6
- * Handler for interfacing with an account. Knows how to create transaction execution
7
- * requests and authorize actions for its corresponding account.
8
- */
9
- export interface AccountInterface extends EntrypointInterface, AuthWitnessProvider {
10
- /** Returns the complete address for this account. */
11
- getCompleteAddress(): CompleteAddress;
12
- /** Returns the address for this account. */
13
- getAddress(): AztecAddress;
14
- /** Returns the chain id for this account */
15
- getChainId(): Fr;
16
- /** Returns the rollup version for this account */
17
- getVersion(): Fr;
18
- }
19
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWNjb3VudC9pbnRlcmZhY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUM5RixPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUk5RDs7O0dBR0c7QUFDSCxNQUFNLFdBQVcsZ0JBQWlCLFNBQVEsbUJBQW1CLEVBQUUsbUJBQW1CO0lBQ2hGLHFEQUFxRDtJQUNyRCxrQkFBa0IsSUFBSSxlQUFlLENBQUM7SUFFdEMsNENBQTRDO0lBQzVDLFVBQVUsSUFBSSxZQUFZLENBQUM7SUFFM0IsNENBQTRDO0lBQzVDLFVBQVUsSUFBSSxFQUFFLENBQUM7SUFFakIsa0RBQWtEO0lBQ2xELFVBQVUsSUFBSSxFQUFFLENBQUM7Q0FDbEIifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/account/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB,EAAE,mBAAmB;IAChF,qDAAqD;IACrD,kBAAkB,IAAI,eAAe,CAAC;IAEtC,4CAA4C;IAC5C,UAAU,IAAI,YAAY,CAAC;IAE3B,4CAA4C;IAC5C,UAAU,IAAI,EAAE,CAAC;IAEjB,kDAAkD;IAClD,UAAU,IAAI,EAAE,CAAC;CAClB"}
@@ -1,5 +0,0 @@
1
- // docs:start:account-interface
2
- /**
3
- * Handler for interfacing with an account. Knows how to create transaction execution
4
- * requests and authorize actions for its corresponding account.
5
- */ export { }; // docs:end:account-interface