@aztec/aztec.js 0.0.1-commit.fcb71a6 → 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 (197) hide show
  1. package/dest/account/account.d.ts +25 -40
  2. package/dest/account/account.d.ts.map +1 -1
  3. package/dest/account/account.js +19 -47
  4. package/dest/account/account_contract.d.ts +8 -9
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +19 -7
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/account_with_secret_key.js +21 -4
  9. package/dest/account/index.d.ts +3 -2
  10. package/dest/account/index.d.ts.map +1 -1
  11. package/dest/account/index.js +2 -0
  12. package/dest/account/signerless_account.d.ts +5 -6
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/account.d.ts +2 -4
  16. package/dest/api/account.d.ts.map +1 -1
  17. package/dest/api/account.js +1 -3
  18. package/dest/api/authorization.d.ts +2 -2
  19. package/dest/api/authorization.d.ts.map +1 -1
  20. package/dest/api/authorization.js +1 -1
  21. package/dest/api/contract.d.ts +18 -12
  22. package/dest/api/contract.d.ts.map +1 -1
  23. package/dest/api/contract.js +16 -10
  24. package/dest/api/deployment.d.ts +1 -2
  25. package/dest/api/deployment.d.ts.map +1 -1
  26. package/dest/api/deployment.js +0 -1
  27. package/dest/api/events.d.ts +10 -6
  28. package/dest/api/events.d.ts.map +1 -1
  29. package/dest/api/events.js +30 -20
  30. package/dest/api/fields.d.ts +2 -1
  31. package/dest/api/fields.d.ts.map +1 -1
  32. package/dest/api/fields.js +1 -0
  33. package/dest/api/keys.d.ts +1 -1
  34. package/dest/api/keys.js +1 -1
  35. package/dest/api/node.d.ts +8 -4
  36. package/dest/api/node.d.ts.map +1 -1
  37. package/dest/api/node.js +7 -3
  38. package/dest/api/protocol.d.ts +7 -1
  39. package/dest/api/protocol.d.ts.map +1 -1
  40. package/dest/api/protocol.js +6 -0
  41. package/dest/api/tx.d.ts +2 -2
  42. package/dest/api/tx.d.ts.map +1 -1
  43. package/dest/api/tx.js +1 -1
  44. package/dest/api/wallet.d.ts +3 -2
  45. package/dest/api/wallet.d.ts.map +1 -1
  46. package/dest/api/wallet.js +2 -1
  47. package/dest/authorization/call_authorization_request.d.ts +22 -1
  48. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  49. package/dest/contract/base_contract_interaction.d.ts +8 -10
  50. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  51. package/dest/contract/base_contract_interaction.js +5 -17
  52. package/dest/contract/batch_call.d.ts +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 +76 -17
  61. package/dest/contract/deploy_method.d.ts.map +1 -1
  62. package/dest/contract/deploy_method.js +55 -29
  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 +2 -2
  91. package/dest/deployment/publish_instance.d.ts +2 -2
  92. package/dest/deployment/publish_instance.d.ts.map +1 -1
  93. package/dest/deployment/publish_instance.js +3 -3
  94. package/dest/ethereum/portal_manager.d.ts +6 -3
  95. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  96. package/dest/ethereum/portal_manager.js +10 -10
  97. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
  98. package/dest/fee/private_fee_payment_method.js +10 -10
  99. package/dest/fee/public_fee_payment_method.js +10 -10
  100. package/dest/fee/sponsored_fee_payment.js +3 -3
  101. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  102. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  103. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  104. package/dest/utils/authwit.d.ts +8 -6
  105. package/dest/utils/authwit.d.ts.map +1 -1
  106. package/dest/utils/authwit.js +5 -9
  107. package/dest/utils/node.d.ts +12 -1
  108. package/dest/utils/node.d.ts.map +1 -1
  109. package/dest/utils/node.js +46 -0
  110. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
  111. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  112. package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
  113. package/dest/wallet/account_manager.d.ts +5 -8
  114. package/dest/wallet/account_manager.d.ts.map +1 -1
  115. package/dest/wallet/account_manager.js +5 -11
  116. package/dest/wallet/capabilities.d.ts +452 -0
  117. package/dest/wallet/capabilities.d.ts.map +1 -0
  118. package/dest/wallet/capabilities.js +3 -0
  119. package/dest/wallet/deploy_account_method.d.ts +46 -7
  120. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  121. package/dest/wallet/deploy_account_method.js +33 -5
  122. package/dest/wallet/index.d.ts +2 -1
  123. package/dest/wallet/index.d.ts.map +1 -1
  124. package/dest/wallet/index.js +1 -0
  125. package/dest/wallet/wallet.d.ts +1740 -2496
  126. package/dest/wallet/wallet.d.ts.map +1 -1
  127. package/dest/wallet/wallet.js +211 -108
  128. package/package.json +24 -13
  129. package/src/account/account.ts +34 -58
  130. package/src/account/account_contract.ts +6 -7
  131. package/src/account/account_with_secret_key.ts +33 -8
  132. package/src/account/index.ts +2 -1
  133. package/src/account/signerless_account.ts +13 -12
  134. package/src/api/account.ts +9 -3
  135. package/src/api/authorization.ts +1 -0
  136. package/src/api/contract.ts +24 -9
  137. package/src/api/deployment.ts +0 -1
  138. package/src/api/events.ts +35 -27
  139. package/src/api/fields.ts +1 -0
  140. package/src/api/keys.ts +2 -2
  141. package/src/api/node.ts +7 -3
  142. package/src/api/protocol.ts +7 -0
  143. package/src/api/tx.ts +2 -0
  144. package/src/api/wallet.ts +48 -3
  145. package/src/contract/base_contract_interaction.ts +27 -15
  146. package/src/contract/batch_call.ts +10 -13
  147. package/src/contract/contract_function_interaction.ts +17 -7
  148. package/src/contract/deploy_method.ts +145 -35
  149. package/src/contract/interaction_options.ts +56 -4
  150. package/src/contract/protocol_contracts/auth-registry.ts +551 -0
  151. package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
  152. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  153. package/src/contract/protocol_contracts/fee-juice.ts +264 -0
  154. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +334 -0
  155. package/src/contract/protocol_contracts/public-checks.ts +318 -0
  156. package/src/contract/wait_for_proven.ts +1 -1
  157. package/src/contract/wait_opts.ts +21 -0
  158. package/src/deployment/publish_class.ts +2 -2
  159. package/src/deployment/publish_instance.ts +3 -6
  160. package/src/ethereum/portal_manager.ts +9 -8
  161. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
  162. package/src/fee/private_fee_payment_method.ts +7 -7
  163. package/src/fee/public_fee_payment_method.ts +8 -8
  164. package/src/fee/sponsored_fee_payment.ts +3 -3
  165. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  166. package/src/utils/authwit.ts +19 -7
  167. package/src/utils/node.ts +62 -0
  168. package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
  169. package/src/wallet/account_manager.ts +5 -13
  170. package/src/wallet/capabilities.ts +500 -0
  171. package/src/wallet/deploy_account_method.ts +74 -13
  172. package/src/wallet/index.ts +1 -0
  173. package/src/wallet/wallet.ts +344 -130
  174. package/dest/account/interface.d.ts +0 -19
  175. package/dest/account/interface.d.ts.map +0 -1
  176. package/dest/account/interface.js +0 -5
  177. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  178. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  179. package/dest/contract/deploy_sent_tx.js +0 -46
  180. package/dest/contract/protocol_contracts.d.ts +0 -9
  181. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  182. package/dest/contract/protocol_contracts.js +0 -26
  183. package/dest/contract/sent_tx.d.ts +0 -50
  184. package/dest/contract/sent_tx.d.ts.map +0 -1
  185. package/dest/contract/sent_tx.js +0 -90
  186. package/dest/contract/unsafe_contract.d.ts +0 -15
  187. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  188. package/dest/contract/unsafe_contract.js +0 -6
  189. package/dest/deployment/broadcast_function.d.ts +0 -24
  190. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  191. package/dest/deployment/broadcast_function.js +0 -74
  192. package/src/account/interface.ts +0 -25
  193. package/src/contract/deploy_sent_tx.ts +0 -75
  194. package/src/contract/protocol_contracts.ts +0 -35
  195. package/src/contract/sent_tx.ts +0 -129
  196. package/src/contract/unsafe_contract.ts +0 -19
  197. package/src/deployment/broadcast_function.ts +0 -148
@@ -9,7 +9,6 @@ import { deriveKeys } from '@aztec/stdlib/keys';
9
9
  import type { AccountContract } from '../account/account_contract.js';
10
10
  import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
11
11
  import type { Salt } from '../account/index.js';
12
- import type { AccountInterface } from '../account/interface.js';
13
12
  import { Contract } from '../contract/contract.js';
14
13
  import { DeployAccountMethod } from './deploy_account_method.js';
15
14
  import type { Wallet } from './wallet.js';
@@ -58,16 +57,6 @@ export class AccountManager {
58
57
  return this.getPublicKeys().hash();
59
58
  }
60
59
 
61
- /**
62
- * Returns the entrypoint for this account as defined by its account contract.
63
- * @returns An entrypoint.
64
- */
65
- public async getAccountInterface(): Promise<AccountInterface> {
66
- const chainInfo = await this.wallet.getChainInfo();
67
- const completeAddress = await this.getCompleteAddress();
68
- return this.accountContract.getInterface(completeAddress, chainInfo);
69
- }
70
-
71
60
  /**
72
61
  * Gets the calculated complete address associated with this account.
73
62
  * Does not require the account to have been published for public execution.
@@ -103,8 +92,9 @@ export class AccountManager {
103
92
  * @returns A Wallet instance.
104
93
  */
105
94
  public async getAccount(): Promise<AccountWithSecretKey> {
106
- const accountInterface = await this.getAccountInterface();
107
- return new AccountWithSecretKey(accountInterface, this.secretKey, this.salt);
95
+ const completeAddress = await this.getCompleteAddress();
96
+ const account = this.accountContract.getAccount(completeAddress);
97
+ return new AccountWithSecretKey(account, this.secretKey, this.salt);
108
98
  }
109
99
 
110
100
  /**
@@ -134,12 +124,14 @@ export class AccountManager {
134
124
  constructorArgs: undefined,
135
125
  };
136
126
 
127
+ const account = await this.getAccount();
137
128
  return new DeployAccountMethod(
138
129
  this.getPublicKeys(),
139
130
  this.wallet,
140
131
  artifact,
141
132
  instance => Contract.at(instance.address, artifact, this.wallet),
142
133
  new Fr(this.salt),
134
+ account,
143
135
  constructorArgs,
144
136
  constructorName,
145
137
  );
@@ -0,0 +1,500 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+
4
+ import type { Aliased } from './wallet.js';
5
+
6
+ /**
7
+ * Current capability manifest version.
8
+ */
9
+ export const CAPABILITY_VERSION = '1.0' as const;
10
+
11
+ /**
12
+ * Pattern for matching contract functions with wildcards.
13
+ *
14
+ * Used in simulation and transaction capabilities to specify which
15
+ * contract functions are allowed.
16
+ *
17
+ * @example
18
+ * // Allow any function on a specific contract
19
+ * \{ contract: ammAddress, function: '*' \}
20
+ *
21
+ * @example
22
+ * // Allow only 'swap' function on a specific contract
23
+ * \{ contract: ammAddress, function: 'swap' \}
24
+ *
25
+ * @example
26
+ * // Allow 'transfer' on any contract
27
+ * \{ contract: '*', function: 'transfer' \}
28
+ */
29
+ export interface ContractFunctionPattern {
30
+ /** Contract address or '*' for any contract */
31
+ contract: AztecAddress | '*';
32
+
33
+ /** Function name or '*' for any function */
34
+ function: string;
35
+
36
+ /**
37
+ * Additional addresses whose private state and keys are accessible
38
+ * when calling this function, beyond the sender's.
39
+ * - undefined: No additional scopes allowed
40
+ * - AztecAddress[]: Only these specific addresses allowed as additional scopes
41
+ * - '*': All known address allowed as an additional scope
42
+ */
43
+ additionalScopes?: AztecAddress[] | '*';
44
+ }
45
+
46
+ /**
47
+ * Account access capability - grants access to user accounts.
48
+ *
49
+ * Maps to wallet methods:
50
+ * - getAccounts (when canGet: true)
51
+ * - createAuthWit (when canCreateAuthWit: true)
52
+ *
53
+ * The wallet decides which accounts to reveal to the app.
54
+ * Apps don't specify which accounts they want - they just request
55
+ * the capability and the wallet shows them the available accounts.
56
+ */
57
+ export interface AccountsCapability {
58
+ /** Discriminator for capability type */
59
+ type: 'accounts';
60
+
61
+ /** Can get accounts from wallet. Maps to: getAccounts */
62
+ canGet?: boolean;
63
+
64
+ /** Can create auth witnesses for accounts. Maps to: createAuthWit */
65
+ canCreateAuthWit?: boolean;
66
+ }
67
+
68
+ /**
69
+ * Granted account access capability.
70
+ *
71
+ * Extends the request with specific accounts that were granted by the wallet.
72
+ */
73
+ export interface GrantedAccountsCapability extends AccountsCapability {
74
+ /** Specific accounts granted by the wallet with their aliases. The wallet adds this when granting the capability. */
75
+ accounts: Aliased<AztecAddress>[];
76
+ }
77
+
78
+ /**
79
+ * Contract interaction capability - for registering and querying contracts.
80
+ *
81
+ * Maps to wallet methods:
82
+ * - registerContract (when canRegister: true)
83
+ * - getContractMetadata (when canGetMetadata: true)
84
+ *
85
+ * Matching is done by contract address, not class ID. This allows updating
86
+ * existing contracts with new artifacts (e.g., when contract is upgraded
87
+ * to a new contractClassId on-chain).
88
+ *
89
+ * Note: For querying contract class metadata, use ContractClassesCapability instead.
90
+ *
91
+ * @example
92
+ * // Register and query specific contracts
93
+ * \{
94
+ * type: 'contracts',
95
+ * contracts: [ammAddress, tokenAddress],
96
+ * canRegister: true,
97
+ * canGetMetadata: true
98
+ * \}
99
+ *
100
+ * @example
101
+ * // Query any contract (read-only)
102
+ * \{
103
+ * type: 'contracts',
104
+ * contracts: '*',
105
+ * canGetMetadata: true
106
+ * \}
107
+ */
108
+ export interface ContractsCapability {
109
+ /** Discriminator for capability type */
110
+ type: 'contracts';
111
+
112
+ /**
113
+ * Which contracts this applies to:
114
+ * - '*': Any contract address
115
+ * - AztecAddress[]: Specific contract addresses
116
+ */
117
+ contracts: '*' | AztecAddress[];
118
+
119
+ /**
120
+ * Can register contracts and update existing registrations.
121
+ * Maps to: registerContract
122
+ *
123
+ * When true, allows:
124
+ * - Registering new contract instances at specified addresses
125
+ * - Re-registering existing contracts with updated artifacts (e.g., after upgrade)
126
+ */
127
+ canRegister?: boolean;
128
+
129
+ /** Can query contract metadata. Maps to: getContractMetadata */
130
+ canGetMetadata?: boolean;
131
+ }
132
+
133
+ /**
134
+ * Granted contract interaction capability.
135
+ *
136
+ * The wallet may reduce the scope (e.g., from '*' to specific addresses).
137
+ */
138
+ export interface GrantedContractsCapability extends ContractsCapability {}
139
+
140
+ /**
141
+ * Contract class capability - for querying contract class metadata.
142
+ *
143
+ * Maps to wallet methods:
144
+ * - getContractClassMetadata
145
+ *
146
+ * Contract classes are identified by their class ID (Fr), not by contract address.
147
+ * Multiple contract instances can share the same class. This capability grants
148
+ * permission to query metadata for specific contract classes.
149
+ *
150
+ * Apps typically acquire this permission automatically when registering a contract
151
+ * with an artifact (the wallet auto-grants permission for that contract's class ID).
152
+ *
153
+ * @example
154
+ * // Query specific contract classes
155
+ * \{
156
+ * type: 'contractClasses',
157
+ * classes: [classId1, classId2],
158
+ * canGetMetadata: true
159
+ * \}
160
+ *
161
+ * @example
162
+ * // Query any contract class (wildcard)
163
+ * \{
164
+ * type: 'contractClasses',
165
+ * classes: '*',
166
+ * canGetMetadata: true
167
+ * \}
168
+ */
169
+ export interface ContractClassesCapability {
170
+ /** Discriminator for capability type */
171
+ type: 'contractClasses';
172
+
173
+ /**
174
+ * Which contract classes this applies to:
175
+ * - '*': Any contract class ID
176
+ * - Fr[]: Specific contract class IDs
177
+ */
178
+ classes: '*' | Fr[];
179
+
180
+ /** Can query contract class metadata. Maps to: getContractClassMetadata */
181
+ canGetMetadata: boolean;
182
+ }
183
+
184
+ /**
185
+ * Granted contract class capability.
186
+ *
187
+ * The wallet may reduce the scope (e.g., from '*' to specific class IDs).
188
+ */
189
+ export interface GrantedContractClassesCapability extends ContractClassesCapability {}
190
+
191
+ /**
192
+ * Transaction simulation capability - for simulating transactions and executing utilities.
193
+ *
194
+ * Maps to wallet methods:
195
+ * - simulateTx (when transactions scope specified)
196
+ * - executeUtility (when utilities scope specified)
197
+ * - profileTx (when transactions scope specified)
198
+ *
199
+ * @example
200
+ * // Simulate any transaction on specific contracts
201
+ * \{
202
+ * type: 'simulation',
203
+ * transactions: \{
204
+ * scope: [
205
+ * \{ contract: ammAddress, function: '*' \},
206
+ * \{ contract: tokenAddress, function: 'transfer' \}
207
+ * ]
208
+ * \}
209
+ * \}
210
+ *
211
+ * @example
212
+ * // Simulate any transaction and execute any utility call
213
+ * \{
214
+ * type: 'simulation',
215
+ * transactions: \{ scope: '*' \},
216
+ * utilities: \{ scope: '*' \}
217
+ * \}
218
+ */
219
+ export interface SimulationCapability {
220
+ /** Discriminator for capability type */
221
+ type: 'simulation';
222
+
223
+ /** Transaction simulation scope. Maps to: simulateTx, profileTx */
224
+ transactions?: {
225
+ /**
226
+ * Which contracts/functions to allow:
227
+ * - '*': Any transaction
228
+ * - ContractFunctionPattern[]: Specific contract functions
229
+ */
230
+ scope: '*' | ContractFunctionPattern[];
231
+ };
232
+
233
+ /** Utility execution scope (unconstrained calls). Maps to: executeUtility */
234
+ utilities?: {
235
+ /**
236
+ * Which contracts/functions to allow:
237
+ * - '*': Any utility call
238
+ * - ContractFunctionPattern[]: Specific contract functions
239
+ */
240
+ scope: '*' | ContractFunctionPattern[];
241
+ };
242
+ }
243
+
244
+ /**
245
+ * Granted transaction simulation capability.
246
+ *
247
+ * The wallet may reduce the scope (e.g., from '*' to specific patterns).
248
+ */
249
+ export interface GrantedSimulationCapability extends SimulationCapability {}
250
+
251
+ /**
252
+ * Transaction execution capability - for sending transactions.
253
+ *
254
+ * Maps to wallet methods:
255
+ * - sendTx
256
+ *
257
+ * Policy enforcement (rate limits, spending limits) should be handled
258
+ * at the contract level in Aztec, not at the wallet level.
259
+ *
260
+ * @example
261
+ * // Send specific transactions with approval
262
+ * \{
263
+ * type: 'transaction',
264
+ * scope: [
265
+ * \{ contract: ammAddress, function: 'swap' \},
266
+ * \{ contract: ammAddress, function: 'addLiquidity' \}
267
+ * ]
268
+ * \}
269
+ *
270
+ * @example
271
+ * // Send any transaction
272
+ * \{
273
+ * type: 'transaction',
274
+ * scope: '*'
275
+ * \}
276
+ */
277
+ export interface TransactionCapability {
278
+ /** Discriminator for capability type */
279
+ type: 'transaction';
280
+
281
+ /**
282
+ * Which contracts/functions to allow:
283
+ * - '*': Any transaction
284
+ * - ContractFunctionPattern[]: Specific patterns
285
+ */
286
+ scope: '*' | ContractFunctionPattern[];
287
+ }
288
+
289
+ /**
290
+ * Granted transaction execution capability.
291
+ *
292
+ * The wallet may reduce the scope (e.g., from '*' to specific patterns).
293
+ */
294
+ export interface GrantedTransactionCapability extends TransactionCapability {}
295
+
296
+ /**
297
+ * Data access capability - for querying private data.
298
+ *
299
+ * Maps to wallet methods:
300
+ * - getAddressBook (when addressBook: true)
301
+ * - getPrivateEvents (when privateEvents specified)
302
+ *
303
+ * @example
304
+ * // Access address book and events from specific contract
305
+ * \{
306
+ * type: 'data',
307
+ * addressBook: true,
308
+ * privateEvents: \{
309
+ * contracts: [ammAddress],
310
+ * events: ['Swap', 'LiquidityAdded']
311
+ * \}
312
+ * \}
313
+ *
314
+ * @example
315
+ * // Access all events from any contract
316
+ * \{
317
+ * type: 'data',
318
+ * privateEvents: \{
319
+ * contracts: '*',
320
+ * events: '*'
321
+ * \}
322
+ * \}
323
+ */
324
+ export interface DataCapability {
325
+ /** Discriminator for capability type */
326
+ type: 'data';
327
+
328
+ /** Access to address book. Maps to: getAddressBook */
329
+ addressBook?: boolean;
330
+
331
+ /** Access to private events. Maps to: getPrivateEvents */
332
+ privateEvents?: {
333
+ /**
334
+ * Which contracts to allow event queries from:
335
+ * - '*': Any contract
336
+ * - AztecAddress[]: Specific contracts
337
+ */
338
+ contracts: '*' | AztecAddress[];
339
+ };
340
+ }
341
+
342
+ /**
343
+ * Granted data access capability.
344
+ *
345
+ * The wallet may reduce the scope (e.g., from '*' to specific contracts).
346
+ */
347
+ export interface GrantedDataCapability extends DataCapability {}
348
+
349
+ /**
350
+ * Union type of all capability scopes (app request).
351
+ *
352
+ * Capabilities group wallet operations by their security sensitivity
353
+ * and functional cohesion, making permission requests understandable
354
+ * to users.
355
+ */
356
+ export type Capability =
357
+ | AccountsCapability
358
+ | ContractsCapability
359
+ | ContractClassesCapability
360
+ | SimulationCapability
361
+ | TransactionCapability
362
+ | DataCapability;
363
+
364
+ /**
365
+ * Union type of all granted capabilities (wallet response).
366
+ *
367
+ * The wallet may augment capabilities with additional information:
368
+ * - AccountsCapability: adds specific accounts granted
369
+ * - Other capabilities: may reduce scope (e.g., '*' to specific addresses)
370
+ */
371
+ export type GrantedCapability =
372
+ | GrantedAccountsCapability
373
+ | GrantedContractsCapability
374
+ | GrantedContractClassesCapability
375
+ | GrantedSimulationCapability
376
+ | GrantedTransactionCapability
377
+ | GrantedDataCapability;
378
+
379
+ /**
380
+ * Application capability manifest.
381
+ *
382
+ * Sent by dApp to declare all operations it needs. This reduces authorization
383
+ * friction from multiple dialogs to a single comprehensive permission request.
384
+ *
385
+ * @example
386
+ * // DEX application manifest
387
+ * const manifest: AppCapabilities = \{
388
+ * version: CAPABILITY_VERSION,
389
+ * metadata: \{
390
+ * name: 'MyDEX',
391
+ * version: '1.0.0',
392
+ * description: 'Decentralized exchange for private token swaps',
393
+ * url: 'https://example.com',
394
+ * icon: 'https://example.com/icon.png'
395
+ * \},
396
+ * capabilities: [
397
+ * \{
398
+ * type: 'accounts',
399
+ * canGet: true,
400
+ * canCreateAuthWit: true
401
+ * \},
402
+ * \{
403
+ * type: 'contracts',
404
+ * contracts: [ammAddress, tokenAAddress, tokenBAddress],
405
+ * canRegister: true,
406
+ * canGetMetadata: true
407
+ * \},
408
+ * \{
409
+ * type: 'simulation',
410
+ * transactions: \{
411
+ * scope: [\{ contract: ammAddress, function: '*' \}]
412
+ * \}
413
+ * \},
414
+ * \{
415
+ * type: 'transaction',
416
+ * scope: [\{ contract: ammAddress, function: 'swap' \}]
417
+ * \}
418
+ * ]
419
+ * \};
420
+ */
421
+ export interface AppCapabilities {
422
+ /**
423
+ * Manifest version for forward compatibility.
424
+ * Currently only '1.0' is supported.
425
+ */
426
+ version: typeof CAPABILITY_VERSION;
427
+
428
+ /** Application metadata for display in authorization dialogs. */
429
+ metadata: {
430
+ /** Human-readable app name */
431
+ name: string;
432
+
433
+ /** App version */
434
+ version: string;
435
+
436
+ /** Optional description of what the app does */
437
+ description?: string;
438
+
439
+ /** Optional website URL */
440
+ url?: string;
441
+
442
+ /** Optional icon URL or data URI */
443
+ icon?: string;
444
+ };
445
+
446
+ /**
447
+ * Requested capabilities grouped by scope.
448
+ */
449
+ capabilities: Capability[];
450
+ }
451
+
452
+ /**
453
+ * Wallet capability response.
454
+ *
455
+ * Returned by wallet after user reviews and approves/denies the capability request.
456
+ *
457
+ * The wallet can modify requested capabilities:
458
+ * - Reduce scope (e.g., restrict to specific contracts instead of '*')
459
+ * - Add information (e.g., specify which accounts are granted)
460
+ * - Deny capabilities (by omitting them from the `granted` array)
461
+ *
462
+ * @example
463
+ * // App requests
464
+ * const manifest: AppCapabilities = \{
465
+ * version: '1.0',
466
+ * metadata: \{ name: 'MyDApp', version: '1.0.0' \},
467
+ * capabilities: [
468
+ * \{ type: 'accounts', canGet: true \},
469
+ * \{ type: 'contracts', contracts: '*', canRegister: true \}
470
+ * ]
471
+ * \};
472
+ *
473
+ * // Wallet responds with specific accounts and restricted contracts
474
+ * const response = await wallet.requestCapabilities(manifest);
475
+ * console.log(response.granted);
476
+ * // [
477
+ * // \{ type: 'accounts', canGet: true, accounts: [addr1, addr2] \},
478
+ * // \{ type: 'contracts', contracts: [specificContract], canRegister: true \}
479
+ * // ]
480
+ */
481
+ export interface WalletCapabilities {
482
+ /** Response version for forward compatibility. */
483
+ version: typeof CAPABILITY_VERSION;
484
+
485
+ /**
486
+ * Capabilities granted by the wallet.
487
+ * Capabilities not in this array were implicitly denied.
488
+ * Empty array means the user denied all capabilities.
489
+ */
490
+ granted: GrantedCapability[];
491
+
492
+ /** Wallet implementation details. */
493
+ wallet: {
494
+ /** Wallet name/implementation */
495
+ name: string;
496
+
497
+ /** Wallet version */
498
+ version: string;
499
+ };
500
+ }
@@ -5,30 +5,65 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
5
  import type { PublicKeys } from '@aztec/stdlib/keys';
6
6
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
7
7
 
8
+ import type { Account } from '../account/account.js';
8
9
  import type { Contract } from '../contract/contract.js';
9
10
  import type { ContractBase } from '../contract/contract_base.js';
10
11
  import {
12
+ type DeployInteractionWaitOptions,
11
13
  DeployMethod,
12
14
  type DeployOptions,
15
+ type DeployOptionsWithoutWait,
13
16
  type RequestDeployOptions,
14
17
  type SimulateDeployOptions,
15
18
  } from '../contract/deploy_method.js';
19
+ import type {
20
+ FeePaymentMethodOption,
21
+ InteractionWaitOptions,
22
+ ProfileInteractionOptions,
23
+ } from '../contract/interaction_options.js';
24
+ import type { WaitOpts } from '../contract/wait_opts.js';
16
25
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
17
26
  import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
18
- import type { Wallet } from './index.js';
27
+ import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from './index.js';
28
+
29
+ /**
30
+ * Extended fee payment method option for account deployments that includes entrypoint wrapping options
31
+ */
32
+ export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
33
+ /** Optional entrypoint-specific options for wrapping execution payloads */
34
+ feeEntrypointOptions?: unknown;
35
+ };
19
36
 
20
37
  /**
21
38
  * The configuration options for the request method. Omits the contractAddressSalt, since
22
39
  * for account contracts that is fixed in the constructor
23
40
  */
24
- export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'>;
41
+ export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
42
+ /** Fee options specific to account deployment */
43
+ fee?: DeployAccountFeePaymentMethodOption;
44
+ };
45
+
46
+ /**
47
+ * Base configuration options for the send/prove methods without wait parameter. Omits:
48
+ * - The contractAddressSalt, since for account contracts that is fixed in the constructor.
49
+ * - UniversalDeployment flag, since account contracts are always deployed with it set to true
50
+ */
51
+ export type DeployAccountOptionsWithoutWait = Omit<DeployOptionsWithoutWait, 'contractAddressSalt' | 'universalDeploy'>;
25
52
 
26
53
  /**
27
54
  * The configuration options for the send/prove methods. Omits:
28
55
  * - The contractAddressSalt, since for account contracts that is fixed in the constructor.
29
56
  * - UniversalDeployment flag, since account contracts are always deployed with it set to true
30
57
  */
31
- export type DeployAccountOptions = Omit<DeployOptions, 'contractAddressSalt' | 'universalDeploy'>;
58
+ export type DeployAccountOptions<W extends InteractionWaitOptions = undefined> = DeployAccountOptionsWithoutWait & {
59
+ /**
60
+ * Whether to wait for the transaction to be mined.
61
+ * - undefined (default): wait with default options and return TxReceipt
62
+ * - WaitOpts object: wait with custom options and return TxReceipt
63
+ * - false: return txHash immediately without waiting
64
+ */
65
+ wait?: W;
66
+ };
32
67
 
33
68
  /**
34
69
  * The configuration options for the simulate method. Omits the contractAddressSalt, since
@@ -47,6 +82,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
47
82
  artifact: ContractArtifact,
48
83
  postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
49
84
  private salt: Fr,
85
+ private account: Account,
50
86
  args: any[] = [],
51
87
  constructorNameOrArtifact?: string | FunctionArtifact,
52
88
  ) {
@@ -61,19 +97,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
61
97
  * For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
62
98
  *
63
99
  * @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
100
+ * @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
64
101
  * @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
65
102
  */
66
- private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
103
+ private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
67
104
  if (!this.address) {
68
105
  throw new Error('Instance is not yet constructed. This is a bug!');
69
106
  }
70
- return new AccountEntrypointMetaPaymentMethod(
71
- this.wallet,
72
- this.artifact,
73
- 'entrypoint',
74
- this.address,
75
- originalPaymentMethod,
76
- );
107
+ return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
77
108
  }
78
109
 
79
110
  /**
@@ -97,7 +128,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
97
128
  const executionPayloads = [deploymentExecutionPayload];
98
129
  // If this is a self-deployment, manage the fee accordingly
99
130
  if (opts?.deployer?.equals(AztecAddress.ZERO)) {
100
- const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
131
+ const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
101
132
  const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
102
133
  // Notice they are reversed (fee payment usually goes first):
103
134
  // this is because we need to construct the contract BEFORE it can pay for its own fee
@@ -113,7 +144,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
113
144
  return mergeExecutionPayloads(executionPayloads);
114
145
  }
115
146
 
116
- override convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
147
+ override convertDeployOptionsToRequestOptions(options: DeployAccountOptionsWithoutWait): RequestDeployOptions {
117
148
  return {
118
149
  ...options,
119
150
  // Deployer is handled in the request method and forcibly set to undefined,
@@ -123,4 +154,34 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
123
154
  deployer: options.from,
124
155
  };
125
156
  }
157
+
158
+ protected override convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
159
+ options: DeployOptions<W>,
160
+ // eslint-disable-next-line jsdoc/require-jsdoc
161
+ ): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
162
+ return super.convertDeployOptionsToSendOptions(this.injectContractAddressIntoScopes(options));
163
+ }
164
+
165
+ protected override convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
166
+ return super.convertDeployOptionsToSimulateOptions(this.injectContractAddressIntoScopes(options));
167
+ }
168
+
169
+ protected override convertDeployOptionsToProfileOptions(
170
+ options: DeployOptionsWithoutWait & ProfileInteractionOptions,
171
+ ): ProfileOptions {
172
+ return super.convertDeployOptionsToProfileOptions(this.injectContractAddressIntoScopes(options));
173
+ }
174
+
175
+ /**
176
+ * Injects the contract's own address into scopes so the constructor can access its own keys.
177
+ * @param options - The deploy options to augment with the contract address.
178
+ */
179
+ // eslint-disable-next-line jsdoc/require-jsdoc
180
+ private injectContractAddressIntoScopes<T extends { additionalScopes?: AztecAddress[] }>(options: T): T {
181
+ if (!this.address) {
182
+ throw new Error('Instance not yet constructed. This is a bug!');
183
+ }
184
+ const existing = options.additionalScopes ?? [];
185
+ return { ...options, additionalScopes: [...existing, this.address] };
186
+ }
126
187
  }
@@ -1,2 +1,3 @@
1
1
  export * from './wallet.js';
2
2
  export * from './account_manager.js';
3
+ export * from './capabilities.js';