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

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 (97) 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 +16 -10
  5. package/dest/api/contract.d.ts.map +1 -1
  6. package/dest/api/contract.js +14 -8
  7. package/dest/api/keys.d.ts +1 -1
  8. package/dest/api/keys.js +1 -1
  9. package/dest/api/node.d.ts +8 -4
  10. package/dest/api/node.d.ts.map +1 -1
  11. package/dest/api/node.js +7 -3
  12. package/dest/api/tx.d.ts +2 -2
  13. package/dest/api/tx.d.ts.map +1 -1
  14. package/dest/api/tx.js +1 -1
  15. package/dest/api/wallet.d.ts +3 -2
  16. package/dest/api/wallet.d.ts.map +1 -1
  17. package/dest/api/wallet.js +2 -1
  18. package/dest/contract/base_contract_interaction.d.ts +8 -10
  19. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  20. package/dest/contract/base_contract_interaction.js +5 -17
  21. package/dest/contract/deploy_method.d.ts +63 -16
  22. package/dest/contract/deploy_method.d.ts.map +1 -1
  23. package/dest/contract/deploy_method.js +36 -19
  24. package/dest/contract/interaction_options.d.ts +42 -5
  25. package/dest/contract/interaction_options.d.ts.map +1 -1
  26. package/dest/contract/interaction_options.js +8 -1
  27. package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -10
  28. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  29. package/dest/contract/protocol_contracts/auth-registry.js +61 -479
  30. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -11
  31. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
  32. package/dest/contract/protocol_contracts/contract-class-registry.js +10 -422
  33. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
  34. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
  35. package/dest/contract/protocol_contracts/contract-instance-registry.js +80 -486
  36. package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
  37. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
  38. package/dest/contract/protocol_contracts/fee-juice.js +0 -414
  39. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +3 -3
  40. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  41. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +13 -14
  42. package/dest/contract/protocol_contracts/public-checks.d.ts +3 -3
  43. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  44. package/dest/contract/protocol_contracts/public-checks.js +13 -22
  45. package/dest/contract/wait_for_proven.js +1 -1
  46. package/dest/contract/wait_opts.d.ts +16 -0
  47. package/dest/contract/wait_opts.d.ts.map +1 -0
  48. package/dest/contract/wait_opts.js +5 -0
  49. package/dest/utils/authwit.d.ts +6 -6
  50. package/dest/utils/authwit.d.ts.map +1 -1
  51. package/dest/utils/authwit.js +2 -6
  52. package/dest/utils/node.d.ts +12 -1
  53. package/dest/utils/node.d.ts.map +1 -1
  54. package/dest/utils/node.js +46 -0
  55. package/dest/wallet/capabilities.d.ts +444 -0
  56. package/dest/wallet/capabilities.d.ts.map +1 -0
  57. package/dest/wallet/capabilities.js +3 -0
  58. package/dest/wallet/deploy_account_method.d.ts +19 -5
  59. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  60. package/dest/wallet/index.d.ts +2 -1
  61. package/dest/wallet/index.d.ts.map +1 -1
  62. package/dest/wallet/index.js +1 -0
  63. package/dest/wallet/wallet.d.ts +1356 -18
  64. package/dest/wallet/wallet.d.ts.map +1 -1
  65. package/dest/wallet/wallet.js +136 -4
  66. package/package.json +9 -9
  67. package/src/api/block.ts +1 -1
  68. package/src/api/contract.ts +22 -7
  69. package/src/api/keys.ts +2 -2
  70. package/src/api/node.ts +7 -3
  71. package/src/api/tx.ts +2 -0
  72. package/src/api/wallet.ts +43 -0
  73. package/src/contract/base_contract_interaction.ts +27 -15
  74. package/src/contract/deploy_method.ts +115 -23
  75. package/src/contract/interaction_options.ts +49 -4
  76. package/src/contract/protocol_contracts/auth-registry.ts +37 -240
  77. package/src/contract/protocol_contracts/contract-class-registry.ts +3 -204
  78. package/src/contract/protocol_contracts/contract-instance-registry.ts +34 -234
  79. package/src/contract/protocol_contracts/fee-juice.ts +0 -202
  80. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +6 -12
  81. package/src/contract/protocol_contracts/public-checks.ts +6 -14
  82. package/src/contract/wait_for_proven.ts +1 -1
  83. package/src/contract/wait_opts.ts +21 -0
  84. package/src/utils/authwit.ts +16 -4
  85. package/src/utils/node.ts +62 -0
  86. package/src/wallet/capabilities.ts +491 -0
  87. package/src/wallet/deploy_account_method.ts +19 -4
  88. package/src/wallet/index.ts +1 -0
  89. package/src/wallet/wallet.ts +148 -12
  90. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  91. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  92. package/dest/contract/deploy_sent_tx.js +0 -46
  93. package/dest/contract/sent_tx.d.ts +0 -50
  94. package/dest/contract/sent_tx.d.ts.map +0 -1
  95. package/dest/contract/sent_tx.js +0 -90
  96. package/src/contract/deploy_sent_tx.ts +0 -75
  97. package/src/contract/sent_tx.ts +0 -129
@@ -15,6 +15,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
16
16
  import { Gas } from '@aztec/stdlib/gas';
17
17
  import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
18
+ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
18
19
  import {
19
20
  Capsule,
20
21
  HashedValues,
@@ -25,18 +26,21 @@ import {
25
26
  UtilitySimulationResult,
26
27
  inTxSchema,
27
28
  } from '@aztec/stdlib/tx';
28
- import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
29
29
 
30
30
  import { z } from 'zod';
31
31
 
32
- import type {
33
- FeeEstimationOptions,
34
- GasSettingsOption,
35
- ProfileInteractionOptions,
36
- SendInteractionOptions,
37
- SimulateInteractionOptions,
32
+ import {
33
+ type FeeEstimationOptions,
34
+ type GasSettingsOption,
35
+ type InteractionWaitOptions,
36
+ NO_WAIT,
37
+ type ProfileInteractionOptions,
38
+ type SendInteractionOptionsWithoutWait,
39
+ type SendReturn,
40
+ type SimulateInteractionOptions,
38
41
  } from '../contract/interaction_options.js';
39
42
  import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
43
+ import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
40
44
 
41
45
  /**
42
46
  * A wrapper type that allows any item to be associated with an alias.
@@ -77,9 +81,14 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
77
81
  * a simplified version that only hints at the wallet whether the interaction contains a
78
82
  * fee payment method or not
79
83
  */
80
- export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
84
+ export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
85
+ SendInteractionOptionsWithoutWait,
86
+ 'fee'
87
+ > & {
81
88
  /** The fee options */
82
89
  fee?: GasSettingsOption;
90
+ /** Whether to wait for the transaction to be mined */
91
+ wait?: W;
83
92
  };
84
93
 
85
94
  /**
@@ -197,7 +206,6 @@ export type Wallet = {
197
206
  eventFilter: PrivateEventFilter,
198
207
  ): Promise<PrivateEvent<T>[]>;
199
208
  getChainInfo(): Promise<ChainInfo>;
200
- getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
201
209
  getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
202
210
  getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
203
211
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
@@ -211,8 +219,12 @@ export type Wallet = {
211
219
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
212
220
  simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
213
221
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
214
- sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
222
+ sendTx<W extends InteractionWaitOptions = undefined>(
223
+ exec: ExecutionPayload,
224
+ opts: SendOptions<W>,
225
+ ): Promise<SendReturn<W>>;
215
226
  createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
227
+ requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
216
228
  batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
217
229
  };
218
230
 
@@ -251,11 +263,19 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
251
263
  estimateGas: optional(z.boolean()),
252
264
  });
253
265
 
266
+ export const WaitOptsSchema = z.object({
267
+ ignoreDroppedReceiptsFor: optional(z.number()),
268
+ timeout: optional(z.number()),
269
+ interval: optional(z.number()),
270
+ dontThrowOnRevert: optional(z.boolean()),
271
+ });
272
+
254
273
  export const SendOptionsSchema = z.object({
255
274
  from: schemas.AztecAddress,
256
275
  authWitnesses: optional(z.array(AuthWitness.schema)),
257
276
  capsules: optional(z.array(Capsule.schema)),
258
277
  fee: optional(GasSettingsOptionSchema),
278
+ wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
259
279
  });
260
280
 
261
281
  export const SimulateOptionsSchema = z.object({
@@ -315,6 +335,119 @@ export const ContractClassMetadataSchema = z.object({
315
335
  isContractClassPubliclyRegistered: z.boolean(),
316
336
  });
317
337
 
338
+ export const ContractFunctionPatternSchema = z.object({
339
+ contract: z.union([schemas.AztecAddress, z.literal('*')]),
340
+ function: z.union([z.string(), z.literal('*')]),
341
+ });
342
+
343
+ export const AccountsCapabilitySchema = z.object({
344
+ type: z.literal('accounts'),
345
+ canGet: optional(z.boolean()),
346
+ canCreateAuthWit: optional(z.boolean()),
347
+ });
348
+
349
+ export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
350
+ accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
351
+ });
352
+
353
+ export const ContractsCapabilitySchema = z.object({
354
+ type: z.literal('contracts'),
355
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
356
+ canRegister: optional(z.boolean()),
357
+ canGetMetadata: optional(z.boolean()),
358
+ });
359
+
360
+ export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
361
+
362
+ export const ContractClassesCapabilitySchema = z.object({
363
+ type: z.literal('contractClasses'),
364
+ classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
365
+ canGetMetadata: z.boolean(),
366
+ });
367
+
368
+ export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
369
+
370
+ export const SimulationCapabilitySchema = z.object({
371
+ type: z.literal('simulation'),
372
+ transactions: optional(
373
+ z.object({
374
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
375
+ }),
376
+ ),
377
+ utilities: optional(
378
+ z.object({
379
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
380
+ }),
381
+ ),
382
+ });
383
+
384
+ export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
385
+
386
+ export const TransactionCapabilitySchema = z.object({
387
+ type: z.literal('transaction'),
388
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
389
+ });
390
+
391
+ export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
392
+
393
+ export const DataCapabilitySchema = z.object({
394
+ type: z.literal('data'),
395
+ addressBook: optional(z.boolean()),
396
+ privateEvents: optional(
397
+ z.object({
398
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
399
+ }),
400
+ ),
401
+ });
402
+
403
+ export const GrantedDataCapabilitySchema = DataCapabilitySchema;
404
+
405
+ export const CapabilitySchema = z.discriminatedUnion('type', [
406
+ AccountsCapabilitySchema,
407
+ ContractsCapabilitySchema,
408
+ ContractClassesCapabilitySchema,
409
+ SimulationCapabilitySchema,
410
+ TransactionCapabilitySchema,
411
+ DataCapabilitySchema,
412
+ ]);
413
+
414
+ export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
415
+ GrantedAccountsCapabilitySchema,
416
+ GrantedContractsCapabilitySchema,
417
+ GrantedContractClassesCapabilitySchema,
418
+ GrantedSimulationCapabilitySchema,
419
+ GrantedTransactionCapabilitySchema,
420
+ GrantedDataCapabilitySchema,
421
+ ]);
422
+
423
+ export const AppCapabilitiesSchema = z.object({
424
+ version: z.literal('1.0'),
425
+ metadata: z.object({
426
+ name: z.string(),
427
+ version: z.string(),
428
+ description: optional(z.string()),
429
+ url: optional(z.string()),
430
+ icon: optional(z.string()),
431
+ }),
432
+ capabilities: z.array(CapabilitySchema),
433
+ behavior: optional(
434
+ z.object({
435
+ mode: optional(z.enum(['strict', 'permissive'])),
436
+ expiration: optional(z.number()),
437
+ }),
438
+ ),
439
+ });
440
+
441
+ export const WalletCapabilitiesSchema = z.object({
442
+ version: z.literal('1.0'),
443
+ granted: z.array(GrantedCapabilitySchema),
444
+ wallet: z.object({
445
+ name: z.string(),
446
+ version: z.string(),
447
+ }),
448
+ expiresAt: optional(z.number()),
449
+ });
450
+
318
451
  /**
319
452
  * Record of all wallet method schemas (excluding batch).
320
453
  * This is the single source of truth for method schemas - batch schemas are derived from this.
@@ -324,7 +457,6 @@ const WalletMethodSchemas = {
324
457
  .function()
325
458
  .args()
326
459
  .returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
327
- getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
328
460
  getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
329
461
  getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
330
462
  getPrivateEvents: z
@@ -350,8 +482,12 @@ const WalletMethodSchemas = {
350
482
  .args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
351
483
  .returns(UtilitySimulationResult.schema),
352
484
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
353
- sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
485
+ sendTx: z
486
+ .function()
487
+ .args(ExecutionPayloadSchema, SendOptionsSchema)
488
+ .returns(z.union([TxHash.schema, TxReceipt.schema])),
354
489
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
490
+ requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
355
491
  };
356
492
 
357
493
  /**
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X3NlbnRfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC9kZXBsb3lfc2VudF90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUxRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUN2RCxPQUFPLEVBQUUsTUFBTSxFQUFFLEtBQUssUUFBUSxFQUFFLE1BQU0sY0FBYyxDQU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,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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VudF90eC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L3NlbnRfdHgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLE1BQU0sRUFBRSxLQUFLLFNBQVMsRUFBWSxNQUFNLGtCQUFrQixDQUFDO0FBRXBFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRWxELDJDQUEyQztBQUMzQyxNQUFNLE1BQU0sUUFBUSxHQUFHO0lBQ3JCLGdLQUFnSztJQUNoSyx3QkFBd0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQyw2RkFBNkY7SUFDN0YsT0FBTyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLHNHQUFzRztJQUN0RyxRQUFRLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDbEIsMEhBQTBIO0lBQzFILGlCQUFpQixDQUFDLEVBQUUsT0FBTyxDQUFDO0NBQzdCLENBQUM7QUFFRixlQUFPLE1BQU0sZUFBZSxFQUFFLFF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gK;IAChK,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAMf,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAL5C,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAE1B,YACY,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAc9B;IAED;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAWxC;IAED;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAG5C;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,75 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
-
6
- import type { Wallet } from '../wallet/wallet.js';
7
- import type { ContractBase } from './contract_base.js';
8
- import { SentTx, type WaitOpts } from './sent_tx.js';
9
-
10
- /** Options related to waiting for a deployment tx. */
11
- export type DeployedWaitOpts = WaitOpts & {
12
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
13
- wallet?: Wallet;
14
- };
15
-
16
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
17
- export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
18
- /** Instance of the newly deployed contract. */
19
- contract: TContract;
20
- /** The deployed contract instance with address and metadata. */
21
- instance: ContractInstanceWithAddress;
22
- };
23
-
24
- /**
25
- * A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
26
- */
27
- export class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
28
- private log = createLogger('aztecjs:deploy_sent_tx');
29
-
30
- constructor(
31
- wallet: Wallet,
32
- sendTx: () => Promise<TxHash>,
33
- private postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
34
- /** A getter for the deployed contract instance */
35
- private instanceGetter: () => Promise<ContractInstanceWithAddress>,
36
- ) {
37
- super(wallet, sendTx);
38
- }
39
-
40
- /**
41
- * Returns the contract instance for this deployment.
42
- * @returns The deployed contract instance with address and metadata.
43
- */
44
- public async getInstance(): Promise<ContractInstanceWithAddress> {
45
- return await this.instanceGetter();
46
- }
47
-
48
- /**
49
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
50
- * @param opts - Options for configuring the waiting for the tx to be mined.
51
- * @returns The deployed contract instance.
52
- */
53
- public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
54
- const receipt = await this.wait(opts);
55
- this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
56
- return receipt.contract;
57
- }
58
-
59
- /**
60
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
61
- * @param opts - Options for configuring the waiting for the tx to be mined.
62
- * @returns The transaction receipt with the deployed contract instance.
63
- */
64
- public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
65
- const receipt = await super.wait(opts);
66
- // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
67
- const contractWallet = opts?.wallet ?? (this.walletOrNode as Wallet);
68
- if (!contractWallet) {
69
- throw new Error(`A wallet is required for creating a contract instance`);
70
- }
71
- const instance = await this.instanceGetter();
72
- const contract = this.postDeployCtor(instance, contractWallet) as TContract;
73
- return { ...receipt, contract, instance };
74
- }
75
- }