@aztec/aztec.js 0.0.1-commit.1bb068fb5 → 0.0.1-commit.217f559981

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 (40) hide show
  1. package/dest/api/wallet.d.ts +2 -2
  2. package/dest/api/wallet.d.ts.map +1 -1
  3. package/dest/contract/batch_call.d.ts +3 -3
  4. package/dest/contract/batch_call.d.ts.map +1 -1
  5. package/dest/contract/batch_call.js +4 -4
  6. package/dest/contract/contract_function_interaction.js +1 -1
  7. package/dest/contract/deploy_method.d.ts +16 -4
  8. package/dest/contract/deploy_method.d.ts.map +1 -1
  9. package/dest/contract/deploy_method.js +14 -6
  10. package/dest/contract/interaction_options.d.ts +8 -1
  11. package/dest/contract/interaction_options.d.ts.map +1 -1
  12. package/dest/contract/protocol_contracts/auth-registry.d.ts +10 -1
  13. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  14. package/dest/contract/protocol_contracts/auth-registry.js +498 -59
  15. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +1 -1
  16. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  17. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +9 -1
  18. package/dest/contract/protocol_contracts/public-checks.d.ts +1 -1
  19. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  20. package/dest/contract/protocol_contracts/public-checks.js +9 -1
  21. package/dest/wallet/capabilities.d.ts +13 -5
  22. package/dest/wallet/capabilities.d.ts.map +1 -1
  23. package/dest/wallet/deploy_account_method.d.ts +15 -4
  24. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  25. package/dest/wallet/deploy_account_method.js +26 -0
  26. package/dest/wallet/wallet.d.ts +156 -18
  27. package/dest/wallet/wallet.d.ts.map +1 -1
  28. package/dest/wallet/wallet.js +12 -6
  29. package/package.json +9 -9
  30. package/src/api/wallet.ts +1 -1
  31. package/src/contract/batch_call.ts +6 -11
  32. package/src/contract/contract_function_interaction.ts +1 -1
  33. package/src/contract/deploy_method.ts +26 -9
  34. package/src/contract/interaction_options.ts +7 -0
  35. package/src/contract/protocol_contracts/auth-registry.ts +237 -37
  36. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +3 -1
  37. package/src/contract/protocol_contracts/public-checks.ts +3 -1
  38. package/src/wallet/capabilities.ts +13 -4
  39. package/src/wallet/deploy_account_method.ts +39 -2
  40. package/src/wallet/wallet.ts +10 -7
@@ -99,7 +99,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
99
99
  type: {
100
100
  kind: 'struct',
101
101
  fields: [
102
- { name: 'storage', type: { kind: 'array', length: 17, type: { kind: 'field' } } },
102
+ { name: 'storage', type: { kind: 'array', length: 15, type: { kind: 'field' } } },
103
103
  { name: 'len', type: { kind: 'integer', sign: 'unsigned', width: 32 } },
104
104
  ],
105
105
  path: 'std::collections::bounded_vec::BoundedVec',
@@ -161,6 +161,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
161
161
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
162
162
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
163
163
  '5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
164
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
164
165
  '9791669845391776238': {
165
166
  error_kind: 'string',
166
167
  string: '0 has a square root; you cannot claim it is not square',
@@ -224,6 +225,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
224
225
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
225
226
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
226
227
  '5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
228
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
227
229
  '9791669845391776238': {
228
230
  error_kind: 'string',
229
231
  string: '0 has a square root; you cannot claim it is not square',
@@ -32,7 +32,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
32
32
  type: {
33
33
  kind: 'struct',
34
34
  fields: [
35
- { name: 'storage', type: { kind: 'array', length: 17, type: { kind: 'field' } } },
35
+ { name: 'storage', type: { kind: 'array', length: 15, type: { kind: 'field' } } },
36
36
  { name: 'len', type: { kind: 'integer', sign: 'unsigned', width: 32 } },
37
37
  ],
38
38
  path: 'std::collections::bounded_vec::BoundedVec',
@@ -94,6 +94,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
94
94
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
95
95
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
96
96
  '5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
97
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
97
98
  '9791669845391776238': {
98
99
  error_kind: 'string',
99
100
  string: '0 has a square root; you cannot claim it is not square',
@@ -185,6 +186,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
185
186
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
186
187
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
187
188
  '5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
189
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
188
190
  '9791669845391776238': {
189
191
  error_kind: 'string',
190
192
  string: '0 has a square root; you cannot claim it is not square',
@@ -32,6 +32,15 @@ export interface ContractFunctionPattern {
32
32
 
33
33
  /** Function name or '*' for any function */
34
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[] | '*';
35
44
  }
36
45
 
37
46
  /**
@@ -180,11 +189,11 @@ export interface ContractClassesCapability {
180
189
  export interface GrantedContractClassesCapability extends ContractClassesCapability {}
181
190
 
182
191
  /**
183
- * Transaction simulation capability - for simulating transactions and utilities.
192
+ * Transaction simulation capability - for simulating transactions and executing utilities.
184
193
  *
185
194
  * Maps to wallet methods:
186
195
  * - simulateTx (when transactions scope specified)
187
- * - simulateUtility (when utilities scope specified)
196
+ * - executeUtility (when utilities scope specified)
188
197
  * - profileTx (when transactions scope specified)
189
198
  *
190
199
  * @example
@@ -200,7 +209,7 @@ export interface GrantedContractClassesCapability extends ContractClassesCapabil
200
209
  * \}
201
210
  *
202
211
  * @example
203
- * // Simulate any transaction and utility call
212
+ * // Simulate any transaction and execute any utility call
204
213
  * \{
205
214
  * type: 'simulation',
206
215
  * transactions: \{ scope: '*' \},
@@ -221,7 +230,7 @@ export interface SimulationCapability {
221
230
  scope: '*' | ContractFunctionPattern[];
222
231
  };
223
232
 
224
- /** Utility simulation scope (unconstrained calls). Maps to: simulateUtility */
233
+ /** Utility execution scope (unconstrained calls). Maps to: executeUtility */
225
234
  utilities?: {
226
235
  /**
227
236
  * Which contracts/functions to allow:
@@ -9,15 +9,22 @@ import type { Account } from '../account/account.js';
9
9
  import type { Contract } from '../contract/contract.js';
10
10
  import type { ContractBase } from '../contract/contract_base.js';
11
11
  import {
12
+ type DeployInteractionWaitOptions,
12
13
  DeployMethod,
14
+ type DeployOptions,
13
15
  type DeployOptionsWithoutWait,
14
16
  type RequestDeployOptions,
15
17
  type SimulateDeployOptions,
16
18
  } from '../contract/deploy_method.js';
17
- import type { FeePaymentMethodOption, InteractionWaitOptions } from '../contract/interaction_options.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';
18
25
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
19
26
  import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
20
- import type { Wallet } from './index.js';
27
+ import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from './index.js';
21
28
 
22
29
  /**
23
30
  * Extended fee payment method option for account deployments that includes entrypoint wrapping options
@@ -147,4 +154,34 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
147
154
  deployer: options.from,
148
155
  };
149
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
+ }
150
187
  }
@@ -22,7 +22,7 @@ import {
22
22
  TxProfileResult,
23
23
  TxReceipt,
24
24
  TxSimulationResult,
25
- UtilitySimulationResult,
25
+ UtilityExecutionResult,
26
26
  inTxSchema,
27
27
  } from '@aztec/stdlib/tx';
28
28
 
@@ -226,10 +226,10 @@ export type ContractClassMetadata = {
226
226
  };
227
227
 
228
228
  /**
229
- * Options for simulating a utility function call.
229
+ * Options for executing a utility function call.
230
230
  */
231
- export type SimulateUtilityOptions = {
232
- /** The scope for the utility simulation (determines which notes and keys are visible). */
231
+ export type ExecuteUtilityOptions = {
232
+ /** The scope for the utility execution (determines which notes and keys are visible). */
233
233
  scope: AztecAddress;
234
234
  /** Optional auth witnesses to use during execution. */
235
235
  authWitnesses?: AuthWitness[];
@@ -255,7 +255,7 @@ export type Wallet = {
255
255
  secretKey?: Fr,
256
256
  ): Promise<ContractInstanceWithAddress>;
257
257
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
258
- simulateUtility(call: FunctionCall, opts: SimulateUtilityOptions): Promise<UtilitySimulationResult>;
258
+ executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
259
259
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
260
260
  sendTx<W extends InteractionWaitOptions = undefined>(
261
261
  exec: ExecutionPayload,
@@ -303,6 +303,7 @@ export const SendOptionsSchema = z.object({
303
303
  capsules: optional(z.array(Capsule.schema)),
304
304
  fee: optional(GasSettingsOptionSchema),
305
305
  wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
306
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
306
307
  });
307
308
 
308
309
  export const SimulateOptionsSchema = z.object({
@@ -313,6 +314,7 @@ export const SimulateOptionsSchema = z.object({
313
314
  skipTxValidation: optional(z.boolean()),
314
315
  skipFeeEnforcement: optional(z.boolean()),
315
316
  includeMetadata: optional(z.boolean()),
317
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
316
318
  });
317
319
 
318
320
  export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
@@ -379,6 +381,7 @@ export const ContractClassMetadataSchema = z.object({
379
381
  export const ContractFunctionPatternSchema = z.object({
380
382
  contract: z.union([schemas.AztecAddress, z.literal('*')]),
381
383
  function: z.union([z.string(), z.literal('*')]),
384
+ additionalScopes: optional(z.union([z.array(schemas.AztecAddress), z.literal('*')])),
382
385
  });
383
386
 
384
387
  export const AccountsCapabilitySchema = z.object({
@@ -518,7 +521,7 @@ const WalletMethodSchemas = {
518
521
  .args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
519
522
  .returns(ContractInstanceWithAddressSchema),
520
523
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
521
- simulateUtility: z
524
+ executeUtility: z
522
525
  .function()
523
526
  .args(
524
527
  FunctionCall.schema,
@@ -527,7 +530,7 @@ const WalletMethodSchemas = {
527
530
  authWitnesses: optional(z.array(AuthWitness.schema)),
528
531
  }),
529
532
  )
530
- .returns(UtilitySimulationResult.schema),
533
+ .returns(UtilityExecutionResult.schema),
531
534
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
532
535
  sendTx: z
533
536
  .function()