@aztec/aztec.js 0.0.1-commit.d431d1c → 0.0.1-commit.d6f2b3f94

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 (125) hide show
  1. package/dest/api/block.d.ts +2 -2
  2. package/dest/api/block.d.ts.map +1 -1
  3. package/dest/api/block.js +1 -1
  4. package/dest/api/contract.d.ts +18 -12
  5. package/dest/api/contract.d.ts.map +1 -1
  6. package/dest/api/contract.js +16 -10
  7. package/dest/api/deployment.d.ts +1 -2
  8. package/dest/api/deployment.d.ts.map +1 -1
  9. package/dest/api/deployment.js +0 -1
  10. package/dest/api/events.d.ts +10 -6
  11. package/dest/api/events.d.ts.map +1 -1
  12. package/dest/api/events.js +30 -20
  13. package/dest/api/fields.d.ts +2 -1
  14. package/dest/api/fields.d.ts.map +1 -1
  15. package/dest/api/fields.js +1 -0
  16. package/dest/api/keys.d.ts +1 -1
  17. package/dest/api/keys.js +1 -1
  18. package/dest/api/node.d.ts +8 -4
  19. package/dest/api/node.d.ts.map +1 -1
  20. package/dest/api/node.js +7 -3
  21. package/dest/api/tx.d.ts +2 -2
  22. package/dest/api/tx.d.ts.map +1 -1
  23. package/dest/api/tx.js +1 -1
  24. package/dest/api/wallet.d.ts +3 -2
  25. package/dest/api/wallet.d.ts.map +1 -1
  26. package/dest/api/wallet.js +2 -1
  27. package/dest/contract/base_contract_interaction.d.ts +8 -10
  28. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  29. package/dest/contract/base_contract_interaction.js +5 -17
  30. package/dest/contract/contract_function_interaction.d.ts +3 -12
  31. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  32. package/dest/contract/contract_function_interaction.js +6 -6
  33. package/dest/contract/deploy_method.d.ts +63 -16
  34. package/dest/contract/deploy_method.d.ts.map +1 -1
  35. package/dest/contract/deploy_method.js +36 -19
  36. package/dest/contract/interaction_options.d.ts +42 -5
  37. package/dest/contract/interaction_options.d.ts.map +1 -1
  38. package/dest/contract/interaction_options.js +8 -1
  39. package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -10
  40. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  41. package/dest/contract/protocol_contracts/auth-registry.js +61 -479
  42. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -22
  43. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
  44. package/dest/contract/protocol_contracts/contract-class-registry.js +2 -672
  45. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
  46. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
  47. package/dest/contract/protocol_contracts/contract-instance-registry.js +80 -486
  48. package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
  49. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
  50. package/dest/contract/protocol_contracts/fee-juice.js +0 -414
  51. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +3 -3
  52. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  53. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +23 -14
  54. package/dest/contract/protocol_contracts/public-checks.d.ts +3 -3
  55. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  56. package/dest/contract/protocol_contracts/public-checks.js +23 -22
  57. package/dest/contract/wait_for_proven.js +1 -1
  58. package/dest/contract/wait_opts.d.ts +16 -0
  59. package/dest/contract/wait_opts.d.ts.map +1 -0
  60. package/dest/contract/wait_opts.js +5 -0
  61. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
  62. package/dest/fee/private_fee_payment_method.js +10 -10
  63. package/dest/fee/public_fee_payment_method.js +10 -10
  64. package/dest/fee/sponsored_fee_payment.js +3 -3
  65. package/dest/utils/authwit.d.ts +6 -6
  66. package/dest/utils/authwit.d.ts.map +1 -1
  67. package/dest/utils/authwit.js +2 -6
  68. package/dest/utils/node.d.ts +12 -1
  69. package/dest/utils/node.d.ts.map +1 -1
  70. package/dest/utils/node.js +46 -0
  71. package/dest/wallet/capabilities.d.ts +444 -0
  72. package/dest/wallet/capabilities.d.ts.map +1 -0
  73. package/dest/wallet/capabilities.js +3 -0
  74. package/dest/wallet/deploy_account_method.d.ts +19 -5
  75. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  76. package/dest/wallet/index.d.ts +2 -1
  77. package/dest/wallet/index.d.ts.map +1 -1
  78. package/dest/wallet/index.js +1 -0
  79. package/dest/wallet/wallet.d.ts +1491 -92
  80. package/dest/wallet/wallet.d.ts.map +1 -1
  81. package/dest/wallet/wallet.js +158 -25
  82. package/package.json +19 -10
  83. package/src/api/block.ts +1 -1
  84. package/src/api/contract.ts +24 -9
  85. package/src/api/deployment.ts +0 -1
  86. package/src/api/events.ts +35 -27
  87. package/src/api/fields.ts +1 -0
  88. package/src/api/keys.ts +2 -2
  89. package/src/api/node.ts +7 -3
  90. package/src/api/tx.ts +2 -0
  91. package/src/api/wallet.ts +47 -1
  92. package/src/contract/base_contract_interaction.ts +27 -15
  93. package/src/contract/contract_function_interaction.ts +13 -6
  94. package/src/contract/deploy_method.ts +115 -23
  95. package/src/contract/interaction_options.ts +49 -4
  96. package/src/contract/protocol_contracts/auth-registry.ts +37 -240
  97. package/src/contract/protocol_contracts/contract-class-registry.ts +1 -347
  98. package/src/contract/protocol_contracts/contract-instance-registry.ts +34 -234
  99. package/src/contract/protocol_contracts/fee-juice.ts +0 -202
  100. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +6 -12
  101. package/src/contract/protocol_contracts/public-checks.ts +6 -14
  102. package/src/contract/wait_for_proven.ts +1 -1
  103. package/src/contract/wait_opts.ts +21 -0
  104. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
  105. package/src/fee/private_fee_payment_method.ts +7 -7
  106. package/src/fee/public_fee_payment_method.ts +8 -8
  107. package/src/fee/sponsored_fee_payment.ts +3 -3
  108. package/src/utils/authwit.ts +16 -4
  109. package/src/utils/node.ts +62 -0
  110. package/src/wallet/capabilities.ts +491 -0
  111. package/src/wallet/deploy_account_method.ts +19 -4
  112. package/src/wallet/index.ts +1 -0
  113. package/src/wallet/wallet.ts +213 -46
  114. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  115. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  116. package/dest/contract/deploy_sent_tx.js +0 -46
  117. package/dest/contract/sent_tx.d.ts +0 -50
  118. package/dest/contract/sent_tx.d.ts.map +0 -1
  119. package/dest/contract/sent_tx.js +0 -90
  120. package/dest/deployment/broadcast_function.d.ts +0 -24
  121. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  122. package/dest/deployment/broadcast_function.js +0 -74
  123. package/src/contract/deploy_sent_tx.ts +0 -75
  124. package/src/contract/sent_tx.ts +0 -129
  125. package/src/deployment/broadcast_function.ts +0 -148
@@ -7,14 +7,14 @@ import {
7
7
  type ContractArtifact,
8
8
  ContractArtifactSchema,
9
9
  type EventMetadataDefinition,
10
- type FunctionCall,
11
- FunctionType,
10
+ FunctionCall,
12
11
  } from '@aztec/stdlib/abi';
13
12
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
14
13
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
15
14
  import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
16
15
  import { Gas } from '@aztec/stdlib/gas';
17
16
  import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
17
+ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
18
18
  import {
19
19
  Capsule,
20
20
  HashedValues,
@@ -25,18 +25,21 @@ import {
25
25
  UtilitySimulationResult,
26
26
  inTxSchema,
27
27
  } from '@aztec/stdlib/tx';
28
- import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
29
28
 
30
29
  import { z } from 'zod';
31
30
 
32
- import type {
33
- FeeEstimationOptions,
34
- GasSettingsOption,
35
- ProfileInteractionOptions,
36
- SendInteractionOptions,
37
- 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,
38
40
  } from '../contract/interaction_options.js';
39
41
  import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
42
+ import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
40
43
 
41
44
  /**
42
45
  * A wrapper type that allows any item to be associated with an alias.
@@ -77,9 +80,14 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
77
80
  * a simplified version that only hints at the wallet whether the interaction contains a
78
81
  * fee payment method or not
79
82
  */
80
- export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
83
+ export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
84
+ SendInteractionOptionsWithoutWait,
85
+ 'fee'
86
+ > & {
81
87
  /** The fee options */
82
88
  fee?: GasSettingsOption;
89
+ /** Whether to wait for the transaction to be mined */
90
+ wait?: W;
83
91
  };
84
92
 
85
93
  /**
@@ -131,37 +139,66 @@ export type BatchResults<T extends readonly BatchedMethod[]> = {
131
139
  };
132
140
 
133
141
  /**
134
- * Filter options when querying private events.
142
+ * Base filter options for event queries.
135
143
  */
136
- export type PrivateEventFilter = {
137
- /** The address of the contract that emitted the events. */
138
- contractAddress: AztecAddress;
139
- /** Addresses of accounts that are in scope for this filter. */
140
- scopes: AztecAddress[];
144
+ export type EventFilterBase = {
141
145
  /** Transaction in which the events were emitted. */
142
146
  txHash?: TxHash;
143
147
  /** The block number from which to start fetching events (inclusive).
144
148
  * Optional. If provided, it must be greater or equal than 1.
145
149
  * Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
146
- * */
150
+ */
147
151
  fromBlock?: BlockNumber;
148
152
  /** The block number until which to fetch logs (not inclusive).
149
153
  * Optional. If provided, it must be greater than fromBlock.
150
- * Defaults to the latest known block to PXE + 1.
151
154
  */
152
155
  toBlock?: BlockNumber;
153
156
  };
154
157
 
155
158
  /**
156
- * An ABI decoded private event with associated metadata.
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.
157
170
  */
158
- export type PrivateEvent<T> = {
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> = {
159
182
  /** The ABI decoded event */
160
183
  event: T;
161
184
  /** Metadata describing event context information such as tx and block */
162
- metadata: InTx;
185
+ metadata: InTx & M;
163
186
  };
164
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
+
165
202
  /**
166
203
  * Contract metadata including deployment and registration status.
167
204
  */
@@ -197,7 +234,6 @@ export type Wallet = {
197
234
  eventFilter: PrivateEventFilter,
198
235
  ): Promise<PrivateEvent<T>[]>;
199
236
  getChainInfo(): Promise<ChainInfo>;
200
- getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
201
237
  getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
202
238
  getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
203
239
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
@@ -211,24 +247,17 @@ export type Wallet = {
211
247
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
212
248
  simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
213
249
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
214
- sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
250
+ sendTx<W extends InteractionWaitOptions = undefined>(
251
+ exec: ExecutionPayload,
252
+ opts: SendOptions<W>,
253
+ ): Promise<SendReturn<W>>;
215
254
  createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
255
+ requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
216
256
  batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
217
257
  };
218
258
 
219
- export const FunctionCallSchema = z.object({
220
- name: z.string(),
221
- to: schemas.AztecAddress,
222
- selector: schemas.FunctionSelector,
223
- type: z.nativeEnum(FunctionType),
224
- isStatic: z.boolean(),
225
- hideMsgSender: z.boolean(),
226
- args: z.array(schemas.Fr),
227
- returnTypes: z.array(AbiTypeSchema),
228
- });
229
-
230
259
  export const ExecutionPayloadSchema = z.object({
231
- calls: z.array(FunctionCallSchema),
260
+ calls: z.array(FunctionCall.schema),
232
261
  authWitnesses: z.array(AuthWitness.schema),
233
262
  capsules: z.array(Capsule.schema),
234
263
  extraHashedArgs: z.array(HashedValues.schema),
@@ -251,11 +280,19 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
251
280
  estimateGas: optional(z.boolean()),
252
281
  });
253
282
 
283
+ export const WaitOptsSchema = z.object({
284
+ ignoreDroppedReceiptsFor: optional(z.number()),
285
+ timeout: optional(z.number()),
286
+ interval: optional(z.number()),
287
+ dontThrowOnRevert: optional(z.boolean()),
288
+ });
289
+
254
290
  export const SendOptionsSchema = z.object({
255
291
  from: schemas.AztecAddress,
256
292
  authWitnesses: optional(z.array(AuthWitness.schema)),
257
293
  capsules: optional(z.array(Capsule.schema)),
258
294
  fee: optional(GasSettingsOptionSchema),
295
+ wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
259
296
  });
260
297
 
261
298
  export const SimulateOptionsSchema = z.object({
@@ -277,7 +314,7 @@ export const MessageHashOrIntentSchema = z.union([
277
314
  z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
278
315
  z.object({
279
316
  caller: schemas.AztecAddress,
280
- call: FunctionCallSchema,
317
+ call: FunctionCall.schema,
281
318
  }),
282
319
  ]);
283
320
 
@@ -287,6 +324,21 @@ export const EventMetadataDefinitionSchema = z.object({
287
324
  fieldNames: z.array(z.string()),
288
325
  });
289
326
 
327
+ const EventFilterBaseSchema = z.object({
328
+ txHash: optional(TxHash.schema),
329
+ fromBlock: optional(BlockNumberPositiveSchema),
330
+ toBlock: optional(BlockNumberPositiveSchema),
331
+ });
332
+
333
+ export const PrivateEventFilterSchema = EventFilterBaseSchema.extend({
334
+ contractAddress: schemas.AztecAddress,
335
+ scopes: z.array(schemas.AztecAddress),
336
+ });
337
+
338
+ export const PublicEventFilterSchema = EventFilterBaseSchema.extend({
339
+ contractAddress: optional(schemas.AztecAddress),
340
+ });
341
+
290
342
  export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
291
343
  z.object({
292
344
  event: AbiDecodedSchema,
@@ -294,13 +346,12 @@ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded
294
346
  }),
295
347
  );
296
348
 
297
- export const PrivateEventFilterSchema = z.object({
298
- contractAddress: schemas.AztecAddress,
299
- scopes: z.array(schemas.AztecAddress),
300
- txHash: optional(TxHash.schema),
301
- fromBlock: optional(BlockNumberPositiveSchema),
302
- toBlock: optional(BlockNumberPositiveSchema),
303
- });
349
+ export const PublicEventSchema = zodFor<PublicEvent<AbiDecoded>>()(
350
+ z.object({
351
+ event: AbiDecodedSchema,
352
+ metadata: z.intersection(inTxSchema(), z.object({ contractAddress: schemas.AztecAddress })),
353
+ }),
354
+ );
304
355
 
305
356
  export const ContractMetadataSchema = z.object({
306
357
  instance: optional(ContractInstanceWithAddressSchema),
@@ -315,6 +366,119 @@ export const ContractClassMetadataSchema = z.object({
315
366
  isContractClassPubliclyRegistered: z.boolean(),
316
367
  });
317
368
 
369
+ export const ContractFunctionPatternSchema = z.object({
370
+ contract: z.union([schemas.AztecAddress, z.literal('*')]),
371
+ function: z.union([z.string(), z.literal('*')]),
372
+ });
373
+
374
+ export const AccountsCapabilitySchema = z.object({
375
+ type: z.literal('accounts'),
376
+ canGet: optional(z.boolean()),
377
+ canCreateAuthWit: optional(z.boolean()),
378
+ });
379
+
380
+ export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
381
+ accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
382
+ });
383
+
384
+ export const ContractsCapabilitySchema = z.object({
385
+ type: z.literal('contracts'),
386
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
387
+ canRegister: optional(z.boolean()),
388
+ canGetMetadata: optional(z.boolean()),
389
+ });
390
+
391
+ export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
392
+
393
+ export const ContractClassesCapabilitySchema = z.object({
394
+ type: z.literal('contractClasses'),
395
+ classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
396
+ canGetMetadata: z.boolean(),
397
+ });
398
+
399
+ export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
400
+
401
+ export const SimulationCapabilitySchema = z.object({
402
+ type: z.literal('simulation'),
403
+ transactions: optional(
404
+ z.object({
405
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
406
+ }),
407
+ ),
408
+ utilities: optional(
409
+ z.object({
410
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
411
+ }),
412
+ ),
413
+ });
414
+
415
+ export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
416
+
417
+ export const TransactionCapabilitySchema = z.object({
418
+ type: z.literal('transaction'),
419
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
420
+ });
421
+
422
+ export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
423
+
424
+ export const DataCapabilitySchema = z.object({
425
+ type: z.literal('data'),
426
+ addressBook: optional(z.boolean()),
427
+ privateEvents: optional(
428
+ z.object({
429
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
430
+ }),
431
+ ),
432
+ });
433
+
434
+ export const GrantedDataCapabilitySchema = DataCapabilitySchema;
435
+
436
+ export const CapabilitySchema = z.discriminatedUnion('type', [
437
+ AccountsCapabilitySchema,
438
+ ContractsCapabilitySchema,
439
+ ContractClassesCapabilitySchema,
440
+ SimulationCapabilitySchema,
441
+ TransactionCapabilitySchema,
442
+ DataCapabilitySchema,
443
+ ]);
444
+
445
+ export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
446
+ GrantedAccountsCapabilitySchema,
447
+ GrantedContractsCapabilitySchema,
448
+ GrantedContractClassesCapabilitySchema,
449
+ GrantedSimulationCapabilitySchema,
450
+ GrantedTransactionCapabilitySchema,
451
+ GrantedDataCapabilitySchema,
452
+ ]);
453
+
454
+ export const AppCapabilitiesSchema = z.object({
455
+ version: z.literal('1.0'),
456
+ metadata: z.object({
457
+ name: z.string(),
458
+ version: z.string(),
459
+ description: optional(z.string()),
460
+ url: optional(z.string()),
461
+ icon: optional(z.string()),
462
+ }),
463
+ capabilities: z.array(CapabilitySchema),
464
+ behavior: optional(
465
+ z.object({
466
+ mode: optional(z.enum(['strict', 'permissive'])),
467
+ expiration: optional(z.number()),
468
+ }),
469
+ ),
470
+ });
471
+
472
+ export const WalletCapabilitiesSchema = z.object({
473
+ version: z.literal('1.0'),
474
+ granted: z.array(GrantedCapabilitySchema),
475
+ wallet: z.object({
476
+ name: z.string(),
477
+ version: z.string(),
478
+ }),
479
+ expiresAt: optional(z.number()),
480
+ });
481
+
318
482
  /**
319
483
  * Record of all wallet method schemas (excluding batch).
320
484
  * This is the single source of truth for method schemas - batch schemas are derived from this.
@@ -324,7 +488,6 @@ const WalletMethodSchemas = {
324
488
  .function()
325
489
  .args()
326
490
  .returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
327
- getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
328
491
  getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
329
492
  getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
330
493
  getPrivateEvents: z
@@ -347,11 +510,15 @@ const WalletMethodSchemas = {
347
510
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
348
511
  simulateUtility: z
349
512
  .function()
350
- .args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
513
+ .args(FunctionCall.schema, optional(z.array(AuthWitness.schema)))
351
514
  .returns(UtilitySimulationResult.schema),
352
515
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
353
- sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
516
+ sendTx: z
517
+ .function()
518
+ .args(ExecutionPayloadSchema, SendOptionsSchema)
519
+ .returns(z.union([TxHash.schema, TxReceipt.schema])),
354
520
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
521
+ requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
355
522
  };
356
523
 
357
524
  /**
@@ -1,48 +0,0 @@
1
- import type { FieldsOf } from '@aztec/foundation/types';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
4
- import type { Wallet } from '../wallet/wallet.js';
5
- import type { ContractBase } from './contract_base.js';
6
- import { SentTx, type WaitOpts } from './sent_tx.js';
7
- /** Options related to waiting for a deployment tx. */
8
- export type DeployedWaitOpts = WaitOpts & {
9
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
10
- wallet?: Wallet;
11
- };
12
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
13
- export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
14
- /** Instance of the newly deployed contract. */
15
- contract: TContract;
16
- /** The deployed contract instance with address and metadata. */
17
- instance: ContractInstanceWithAddress;
18
- };
19
- /**
20
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
21
- */
22
- export declare class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
23
- private postDeployCtor;
24
- /** A getter for the deployed contract instance */
25
- private instanceGetter;
26
- private log;
27
- constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
28
- /** A getter for the deployed contract instance */
29
- instanceGetter: () => Promise<ContractInstanceWithAddress>);
30
- /**
31
- * Returns the contract instance for this deployment.
32
- * @returns The deployed contract instance with address and metadata.
33
- */
34
- getInstance(): Promise<ContractInstanceWithAddress>;
35
- /**
36
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
37
- * @param opts - Options for configuring the waiting for the tx to be mined.
38
- * @returns The deployed contract instance.
39
- */
40
- deployed(opts?: DeployedWaitOpts): Promise<TContract>;
41
- /**
42
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
43
- * @param opts - Options for configuring the waiting for the tx to be mined.
44
- * @returns The transaction receipt with the deployed contract instance.
45
- */
46
- wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
47
- }
48
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X3NlbnRfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC9kZXBsb3lfc2VudF90eC50cyJdLCJuYW1lc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MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,0GAA0G;AAC1G,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG;IACjG,+CAA+C;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,gEAAgE;IAChE,QAAQ,EAAE,2BAA2B,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,CAAE,SAAQ,MAAM;IAMnF,OAAO,CAAC,cAAc;IACtB,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAPxB,OAAO,CAAC,GAAG,CAA0C;IAErD,YACE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrB,cAAc,EAAE,CAAC,QAAQ,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS;IAC5F,kDAAkD;IAC1C,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC,EAGnE;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAE/D;IAED;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAIjE;IAED;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAUvF;CACF"}
@@ -1,46 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { SentTx } from './sent_tx.js';
3
- /**
4
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
5
- */ export class DeploySentTx extends SentTx {
6
- postDeployCtor;
7
- instanceGetter;
8
- log;
9
- constructor(wallet, sendTx, postDeployCtor, /** A getter for the deployed contract instance */ instanceGetter){
10
- super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
11
- }
12
- /**
13
- * Returns the contract instance for this deployment.
14
- * @returns The deployed contract instance with address and metadata.
15
- */ async getInstance() {
16
- return await this.instanceGetter();
17
- }
18
- /**
19
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
20
- * @param opts - Options for configuring the waiting for the tx to be mined.
21
- * @returns The deployed contract instance.
22
- */ async deployed(opts) {
23
- const receipt = await this.wait(opts);
24
- this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
25
- return receipt.contract;
26
- }
27
- /**
28
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
29
- * @param opts - Options for configuring the waiting for the tx to be mined.
30
- * @returns The transaction receipt with the deployed contract instance.
31
- */ async wait(opts) {
32
- const receipt = await super.wait(opts);
33
- // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
34
- const contractWallet = opts?.wallet ?? this.walletOrNode;
35
- if (!contractWallet) {
36
- throw new Error(`A wallet is required for creating a contract instance`);
37
- }
38
- const instance = await this.instanceGetter();
39
- const contract = this.postDeployCtor(instance, contractWallet);
40
- return {
41
- ...receipt,
42
- contract,
43
- instance
44
- };
45
- }
46
- }
@@ -1,50 +0,0 @@
1
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
2
- import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
3
- import type { Wallet } from '../wallet/wallet.js';
4
- /** Options related to waiting for a tx. */
5
- export type WaitOpts = {
6
- /** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
7
- ignoreDroppedReceiptsFor?: number;
8
- /** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
9
- timeout?: number;
10
- /** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
11
- interval?: number;
12
- /** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
13
- dontThrowOnRevert?: boolean;
14
- };
15
- export declare const DefaultWaitOpts: WaitOpts;
16
- /**
17
- * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
18
- * its hash, receipt, and mining status.
19
- */
20
- export declare class SentTx {
21
- protected walletOrNode: Wallet | AztecNode;
22
- protected sendTxPromise: Promise<void>;
23
- protected sendTxError?: Error;
24
- protected txHash?: TxHash;
25
- constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
26
- /**
27
- * Retrieves the transaction hash of the SentTx instance.
28
- * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
29
- *
30
- * @returns A promise that resolves to the transaction hash of the SentTx instance.
31
- * TODO(#7717): Don't throw here.
32
- */
33
- getTxHash(): Promise<TxHash>;
34
- /**
35
- * Retrieve the transaction receipt associated with the current SentTx instance.
36
- * The function fetches the transaction hash using 'getTxHash' and then queries
37
- * the PXE to get the corresponding transaction receipt.
38
- *
39
- * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
40
- */
41
- getReceipt(): Promise<TxReceipt>;
42
- /**
43
- * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
44
- * @param opts - Options for configuring the waiting for the tx to be mined.
45
- * @returns The transaction receipt.
46
- */
47
- wait(opts?: WaitOpts): Promise<TxReceipt>;
48
- protected waitForReceipt(opts?: WaitOpts): Promise<TxReceipt>;
49
- }
50
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VudF90eC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L3NlbnRfdHgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLE1BQU0sRUFBRSxLQUFLLFNBQVMsRUFB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IAED;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAQrD;IAED,UAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CA4BlE;CACF"}
@@ -1,90 +0,0 @@
1
- import { promiseWithResolvers } from '@aztec/foundation/promise';
2
- import { retryUntil } from '@aztec/foundation/retry';
3
- import { TxStatus } from '@aztec/stdlib/tx';
4
- export const DefaultWaitOpts = {
5
- ignoreDroppedReceiptsFor: 5,
6
- timeout: 300,
7
- interval: 1
8
- };
9
- /**
10
- * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
11
- * its hash, receipt, and mining status.
12
- */ export class SentTx {
13
- walletOrNode;
14
- sendTxPromise;
15
- sendTxError;
16
- txHash;
17
- constructor(walletOrNode, sendTx){
18
- this.walletOrNode = walletOrNode;
19
- const { promise, resolve } = promiseWithResolvers();
20
- this.sendTxPromise = promise;
21
- sendTx().then((txHash)=>{
22
- this.txHash = txHash;
23
- resolve();
24
- }).catch((err)=>{
25
- this.sendTxError = err;
26
- // Calling resolve instead of reject here because we want to throw the error when getTxHash is called.
27
- resolve();
28
- });
29
- }
30
- /**
31
- * Retrieves the transaction hash of the SentTx instance.
32
- * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
33
- *
34
- * @returns A promise that resolves to the transaction hash of the SentTx instance.
35
- * TODO(#7717): Don't throw here.
36
- */ async getTxHash() {
37
- // Make sure sendTx has been resolved, which can be triggered when it returns a txHash or when it throws an error.
38
- await this.sendTxPromise;
39
- // If sendTx threw an error, throw it.
40
- if (this.sendTxError) {
41
- throw this.sendTxError;
42
- }
43
- // sendTx returned a txHash if it's been resolved and no error was set.
44
- return Promise.resolve(this.txHash);
45
- }
46
- /**
47
- * Retrieve the transaction receipt associated with the current SentTx instance.
48
- * The function fetches the transaction hash using 'getTxHash' and then queries
49
- * the PXE to get the corresponding transaction receipt.
50
- *
51
- * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
52
- */ async getReceipt() {
53
- const txHash = await this.getTxHash();
54
- return await this.walletOrNode.getTxReceipt(txHash);
55
- }
56
- /**
57
- * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
58
- * @param opts - Options for configuring the waiting for the tx to be mined.
59
- * @returns The transaction receipt.
60
- */ async wait(opts) {
61
- const receipt = await this.waitForReceipt(opts);
62
- if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) {
63
- throw new Error(`Transaction ${(await this.getTxHash()).toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
64
- }
65
- return receipt;
66
- }
67
- async waitForReceipt(opts) {
68
- const txHash = await this.getTxHash();
69
- const startTime = Date.now();
70
- const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
71
- return await retryUntil(async ()=>{
72
- const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
73
- // If receipt is not yet available, try again
74
- if (txReceipt.status === TxStatus.PENDING) {
75
- return undefined;
76
- }
77
- // If the tx was "dropped", either return it or ignore based on timing.
78
- // We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
79
- // If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
80
- if (txReceipt.status === TxStatus.DROPPED) {
81
- const elapsedSeconds = (Date.now() - startTime) / 1000;
82
- if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
83
- return txReceipt;
84
- }
85
- return undefined;
86
- }
87
- return txReceipt;
88
- }, 'isMined', opts?.timeout ?? DefaultWaitOpts.timeout, opts?.interval ?? DefaultWaitOpts.interval);
89
- }
90
- }
@@ -1,24 +0,0 @@
1
- import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
2
- import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
3
- import type { Wallet } from '../wallet/index.js';
4
- /**
5
- * Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
6
- * Note that this is not required for users to call the function, but is rather a convenience to make
7
- * this code publicly available so dapps or wallets do not need to redistribute it.
8
- * @param wallet - Wallet to send the transaction.
9
- * @param artifact - Contract artifact that contains the function to be broadcast.
10
- * @param selector - Selector of the function to be broadcast.
11
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
12
- */
13
- export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
14
- /**
15
- * Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
16
- * Note that this is not required for users to call the function, but is rather a convenience to make
17
- * this code publicly available so dapps or wallets do not need to redistribute it.
18
- * @param wallet - Wallet to send the transaction.
19
- * @param artifact - Contract artifact that contains the function to be broadcast.
20
- * @param selector - Selector of the function to be broadcast.
21
- * @returns A ContractFunctionInteraction object that can be used to send the transaction.
22
- */
23
- export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvYWRjYXN0X2Z1bmN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVwbG95bWVudC9icm9hZGNhc3RfZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQWdDLE1BQU0sbUJBQW1CLENBQUM7QUFTMUcsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSw4Q0FBOEMsQ0FBQztBQUVoRyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVqRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFzQ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