@aztec/aztec.js 3.0.0-nightly.20251022 → 3.0.0-nightly.20251023

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 (37) hide show
  1. package/dest/api/contract.d.ts +2 -3
  2. package/dest/api/contract.d.ts.map +1 -1
  3. package/dest/api/contract.js +1 -1
  4. package/dest/api/wallet.d.ts +3 -1
  5. package/dest/api/wallet.d.ts.map +1 -1
  6. package/dest/api/wallet.js +3 -1
  7. package/dest/contract/base_contract_interaction.d.ts +3 -18
  8. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  9. package/dest/contract/base_contract_interaction.js +5 -26
  10. package/dest/contract/deploy_method.d.ts +2 -10
  11. package/dest/contract/deploy_method.d.ts.map +1 -1
  12. package/dest/contract/deploy_method.js +4 -16
  13. package/dest/utils/authwit.d.ts +0 -7
  14. package/dest/utils/authwit.d.ts.map +1 -1
  15. package/dest/utils/authwit.js +0 -11
  16. package/dest/wallet/base_wallet.d.ts +11 -5
  17. package/dest/wallet/base_wallet.d.ts.map +1 -1
  18. package/dest/wallet/base_wallet.js +18 -9
  19. package/dest/wallet/wallet.d.ts +20 -10
  20. package/dest/wallet/wallet.d.ts.map +1 -1
  21. package/dest/wallet/wallet.js +17 -9
  22. package/package.json +8 -8
  23. package/src/api/contract.ts +9 -2
  24. package/src/api/wallet.ts +28 -7
  25. package/src/contract/base_contract_interaction.ts +6 -36
  26. package/src/contract/deploy_method.ts +6 -27
  27. package/src/utils/authwit.ts +0 -10
  28. package/src/wallet/base_wallet.ts +16 -12
  29. package/src/wallet/wallet.ts +29 -13
  30. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  31. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  32. package/dest/contract/deploy_proven_tx.js +0 -21
  33. package/dest/contract/proven_tx.d.ts +0 -21
  34. package/dest/contract/proven_tx.d.ts.map +0 -1
  35. package/dest/contract/proven_tx.js +0 -23
  36. package/src/contract/deploy_proven_tx.ts +0 -45
  37. package/src/contract/proven_tx.ts +0 -36
@@ -4,7 +4,7 @@ import { ContractClassWithIdSchema, ContractInstanceWithAddressSchema } from '@a
4
4
  import { Gas } from '@aztec/stdlib/gas';
5
5
  import { PublicKeys } from '@aztec/stdlib/keys';
6
6
  import { AbiDecodedSchema, optional, schemas } from '@aztec/stdlib/schemas';
7
- import { Capsule, HashedValues, Tx, TxHash, TxProfileResult, TxProvingResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
7
+ import { Capsule, HashedValues, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
8
8
  import { z } from 'zod';
9
9
  export const ContractInstantiationDataSchema = z.object({
10
10
  constructorArtifact: optional(z.union([
@@ -116,7 +116,7 @@ export const BatchedMethodSchema = z.union([
116
116
  ])
117
117
  }),
118
118
  z.object({
119
- name: z.literal('proveTx'),
119
+ name: z.literal('sendTx'),
120
120
  args: z.tuple([
121
121
  ExecutionPayloadSchema,
122
122
  SendOptionsSchema
@@ -157,7 +157,7 @@ export const WalletSchema = {
157
157
  getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
158
158
  getPrivateEvents: z.function().args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress)).returns(z.array(AbiDecodedSchema)),
159
159
  registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
160
- getSenders: z.function().args().returns(z.array(z.object({
160
+ getAddressBook: z.function().args().returns(z.array(z.object({
161
161
  alias: z.string(),
162
162
  item: schemas.AztecAddress
163
163
  }))),
@@ -169,13 +169,21 @@ export const WalletSchema = {
169
169
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
170
170
  simulateUtility: z.function().args(z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema))).returns(UtilitySimulationResult.schema),
171
171
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
172
- proveTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxProvingResult.schema),
173
- sendTx: z.function().args(Tx.schema).returns(TxHash.schema),
172
+ sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
174
173
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
175
174
  // @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
176
- batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(z.union([
177
- schemas.AztecAddress,
178
- ContractInstanceWithAddressSchema,
179
- TxProvingResult.schema
175
+ batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(z.discriminatedUnion('name', [
176
+ z.object({
177
+ name: z.literal('registerSender'),
178
+ result: schemas.AztecAddress
179
+ }),
180
+ z.object({
181
+ name: z.literal('registerContract'),
182
+ result: ContractInstanceWithAddressSchema
183
+ }),
184
+ z.object({
185
+ name: z.literal('sendTx'),
186
+ result: TxHash.schema
187
+ })
180
188
  ])))
181
189
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aztec/aztec.js",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
4
- "version": "3.0.0-nightly.20251022",
4
+ "version": "3.0.0-nightly.20251023",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./dest/index.js",
@@ -80,13 +80,13 @@
80
80
  ]
81
81
  },
82
82
  "dependencies": {
83
- "@aztec/constants": "3.0.0-nightly.20251022",
84
- "@aztec/entrypoints": "3.0.0-nightly.20251022",
85
- "@aztec/ethereum": "3.0.0-nightly.20251022",
86
- "@aztec/foundation": "3.0.0-nightly.20251022",
87
- "@aztec/l1-artifacts": "3.0.0-nightly.20251022",
88
- "@aztec/protocol-contracts": "3.0.0-nightly.20251022",
89
- "@aztec/stdlib": "3.0.0-nightly.20251022",
83
+ "@aztec/constants": "3.0.0-nightly.20251023",
84
+ "@aztec/entrypoints": "3.0.0-nightly.20251023",
85
+ "@aztec/ethereum": "3.0.0-nightly.20251023",
86
+ "@aztec/foundation": "3.0.0-nightly.20251023",
87
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251023",
88
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251023",
89
+ "@aztec/stdlib": "3.0.0-nightly.20251023",
90
90
  "axios": "^1.12.0",
91
91
  "tslib": "^2.4.0",
92
92
  "viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
@@ -44,14 +44,21 @@ export {
44
44
  type ProfileInteractionOptions,
45
45
  type SimulateInteractionOptions,
46
46
  type InteractionFeeOptions,
47
+ toProfileOptions,
48
+ toSendOptions,
49
+ toSimulateOptions,
47
50
  } from '../contract/interaction_options.js';
48
51
 
49
52
  export { TxProfileResult } from '@aztec/stdlib/tx';
50
53
  export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
51
- export { ProvenTx } from '../contract/proven_tx.js';
52
54
  export { ContractBase, type ContractMethod, type ContractStorageLayout } from '../contract/contract_base.js';
53
55
  export { BatchCall } from '../contract/batch_call.js';
54
- export { type DeployOptions, DeployMethod } from '../contract/deploy_method.js';
56
+ export {
57
+ type DeployOptions,
58
+ DeployMethod,
59
+ type RequestDeployOptions,
60
+ type SimulateDeployOptions,
61
+ } from '../contract/deploy_method.js';
55
62
  export { DeploySentTx } from '../contract/deploy_sent_tx.js';
56
63
  export { waitForProven, type WaitForProvenOpts, DefaultWaitForProvenOpts } from '../contract/wait_for_proven.js';
57
64
  export { getGasLimits } from '../contract/get_gas_limits.js';
package/src/api/wallet.ts CHANGED
@@ -1,14 +1,35 @@
1
1
  export {
2
2
  type Aliased,
3
- BaseWallet,
4
- type Wallet,
5
- AccountManager,
6
- WalletSchema,
7
- type FeeOptions,
3
+ type ContractInstanceAndArtifact,
8
4
  type UserFeeOptions,
9
5
  type SimulateOptions,
10
- type SendOptions,
11
6
  type ProfileOptions,
12
- } from '../wallet/index.js';
7
+ type SendOptions,
8
+ type BatchableMethods,
9
+ type BatchedMethod,
10
+ type BatchedMethodResult,
11
+ type BatchedMethodResultWrapper,
12
+ type BatchResults,
13
+ type Wallet,
14
+ ContractInstantiationDataSchema,
15
+ FunctionCallSchema,
16
+ ExecutionPayloadSchema,
17
+ UserFeeOptionsSchema,
18
+ WalletSimulationFeeOptionSchema,
19
+ SendOptionsSchema,
20
+ SimulateOptionsSchema,
21
+ ProfileOptionsSchema,
22
+ InstanceDataSchema,
23
+ MessageHashOrIntentSchema,
24
+ BatchedMethodSchema,
25
+ ContractMetadataSchema,
26
+ ContractClassMetadataSchema,
27
+ EventMetadataDefinitionSchema,
28
+ WalletSchema,
29
+ } from '../wallet/wallet.js';
30
+
31
+ export { type FeeOptions, BaseWallet } from '../wallet/base_wallet.js';
32
+
33
+ export { AccountManager } from '../wallet/account_manager.js';
13
34
 
14
35
  export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
@@ -1,11 +1,10 @@
1
1
  import type { ExecutionPayload } from '@aztec/entrypoints/payload';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
- import type { Capsule, TxProvingResult } from '@aztec/stdlib/tx';
4
+ import type { Capsule } from '@aztec/stdlib/tx';
5
5
 
6
6
  import type { Wallet } from '../wallet/wallet.js';
7
7
  import { type RequestInteractionOptions, type SendInteractionOptions, toSendOptions } from './interaction_options.js';
8
- import { ProvenTx } from './proven_tx.js';
9
8
  import { SentTx } from './sent_tx.js';
10
9
 
11
10
  /**
@@ -29,51 +28,22 @@ export abstract class BaseContractInteraction {
29
28
  */
30
29
  public abstract request(options?: RequestInteractionOptions): Promise<ExecutionPayload>;
31
30
 
32
- /**
33
- * Creates a transaction execution request, simulates and proves it. Differs from .prove in
34
- * that its result does not include the wallet nor the composed tx object, but only the proving result.
35
- * This object can then be used to either create a ProvenTx ready to be sent, or directly send the transaction.
36
- * @param options - optional arguments to be used in the creation of the transaction
37
- * @returns The proving result.
38
- */
39
- protected async proveInternal(options: SendInteractionOptions): Promise<TxProvingResult> {
40
- const executionPayload = await this.request(options);
41
- const proveOptions = await toSendOptions(options);
42
- return await this.wallet.proveTx(executionPayload, proveOptions);
43
- }
44
-
45
- // docs:start:prove
46
- /**
47
- * Proves a transaction execution request and returns a tx object ready to be sent.
48
- * @param options - optional arguments to be used in the creation of the transaction
49
- * @returns The resulting transaction
50
- */
51
- public async prove(options: SendInteractionOptions): Promise<ProvenTx> {
52
- // docs:end:prove
53
- const txProvingResult = await this.proveInternal(options);
54
- return new ProvenTx(
55
- this.wallet,
56
- await txProvingResult.toTx(),
57
- txProvingResult.getOffchainEffects(),
58
- txProvingResult.stats,
59
- );
60
- }
61
-
62
31
  // docs:start:send
63
32
  /**
64
33
  * Sends a transaction to the contract function with the specified options.
65
34
  * This function throws an error if called on a utility function.
66
35
  * It creates and signs the transaction if necessary, and returns a SentTx instance,
67
36
  * which can be used to track the transaction status, receipt, and events.
68
- * @param options - An optional object containing 'from' property representing
69
- * the AztecAddress of the sender. If not provided, the default address is used.
37
+ * @param options - An object containing 'from' property representing
38
+ * the AztecAddress of the sender and optional fee configuration
70
39
  * @returns A SentTx instance for tracking the transaction status and information.
71
40
  */
72
41
  public send(options: SendInteractionOptions): SentTx {
73
42
  // docs:end:send
74
43
  const sendTx = async () => {
75
- const txProvingResult = await this.proveInternal(options);
76
- return this.wallet.sendTx(await txProvingResult.toTx());
44
+ const executionPayload = await this.request(options);
45
+ const sendOptions = await toSendOptions(options);
46
+ return this.wallet.sendTx(executionPayload, sendOptions);
77
47
  };
78
48
  return new SentTx(this.wallet, sendTx);
79
49
  }
@@ -10,7 +10,7 @@ import {
10
10
  getContractInstanceFromInstantiationParams,
11
11
  } from '@aztec/stdlib/contract';
12
12
  import type { PublicKeys } from '@aztec/stdlib/keys';
13
- import { type Capsule, type TxProfileResult, TxProvingResult, collectOffchainEffects } from '@aztec/stdlib/tx';
13
+ import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
14
14
 
15
15
  import { publishContractClass } from '../deployment/publish_class.js';
16
16
  import { publishInstance } from '../deployment/publish_instance.js';
@@ -19,7 +19,6 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
19
19
  import type { Contract } from './contract.js';
20
20
  import type { ContractBase } from './contract_base.js';
21
21
  import { ContractFunctionInteraction } from './contract_function_interaction.js';
22
- import { DeployProvenTx } from './deploy_proven_tx.js';
23
22
  import { DeploySentTx } from './deploy_sent_tx.js';
24
23
  import { getGasLimits } from './get_gas_limits.js';
25
24
  import {
@@ -142,7 +141,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
142
141
  return finalExecutionPayload;
143
142
  }
144
143
 
145
- protected convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
144
+ convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
146
145
  return {
147
146
  ...options,
148
147
  deployer: !options?.universalDeploy ? options.from : undefined,
@@ -229,12 +228,6 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
229
228
  return mergeExecutionPayloads(executionsPayloads);
230
229
  }
231
230
 
232
- override async proveInternal(options: DeployOptions): Promise<TxProvingResult> {
233
- const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
234
- const proveOptions = await toSendOptions(options);
235
- return await this.wallet.proveTx(executionPayload, proveOptions);
236
- }
237
-
238
231
  /**
239
232
  * Send a contract deployment transaction (initialize and/or publish) using the provided options.
240
233
  * This function extends the 'send' method from the ContractFunctionInteraction class,
@@ -244,8 +237,10 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
244
237
  * @returns A SentTx object that returns the receipt and the deployed contract instance.
245
238
  */
246
239
  public override send(options: DeployOptions): DeploySentTx<TContract> {
247
- const sendTx = () => {
248
- return super.send(options).getTxHash();
240
+ const sendTx = async () => {
241
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
242
+ const sendOptions = await toSendOptions(options);
243
+ return this.wallet.sendTx(executionPayload, sendOptions);
249
244
  };
250
245
  this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
251
246
  return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, () => this.getInstance(options));
@@ -270,22 +265,6 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
270
265
  return this.instance;
271
266
  }
272
267
 
273
- /**
274
- * Prove the request.
275
- * @param options - initialization and publication options.
276
- * @returns The proven tx.
277
- */
278
- public override async prove(options: DeployOptions): Promise<DeployProvenTx<TContract>> {
279
- const txProvingResult = await this.proveInternal(options);
280
- return await DeployProvenTx.fromProvingResult(
281
- this.wallet,
282
- txProvingResult,
283
- this.postDeployCtor,
284
- () => this.getInstance(options),
285
- txProvingResult.stats,
286
- );
287
- }
288
-
289
268
  /**
290
269
  * Simulate the deployment
291
270
  *
@@ -248,16 +248,6 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
248
248
  return new SetPublicAuthwitContractInteraction(wallet, from, messageHash, authorized);
249
249
  }
250
250
 
251
- /**
252
- * Overrides the proveInternal method, adding the sender of the authwit (authorizer) as from
253
- * and preventing misuse
254
- * @param options - An optional object containing additional configuration for the transaction.
255
- * @returns The result of the transaction as returned by the contract function.
256
- */
257
- public override proveInternal(options: Omit<SendInteractionOptions, 'from'>) {
258
- return super.proveInternal({ ...options, from: this.from });
259
- }
260
-
261
251
  /**
262
252
  * Overrides the simulate method, adding the sender of the authwit (authorizer) as from
263
253
  * and preventing misuse
@@ -25,11 +25,9 @@ import { SimulationError } from '@aztec/stdlib/errors';
25
25
  import { Gas, GasSettings } from '@aztec/stdlib/gas';
26
26
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
27
27
  import type {
28
- Tx,
29
28
  TxExecutionRequest,
30
29
  TxHash,
31
30
  TxProfileResult,
32
- TxProvingResult,
33
31
  TxReceipt,
34
32
  TxSimulationResult,
35
33
  UtilitySimulationResult,
@@ -89,7 +87,14 @@ export abstract class BaseWallet implements Wallet {
89
87
 
90
88
  abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
91
89
 
92
- async getSenders(): Promise<Aliased<AztecAddress>[]> {
90
+ /**
91
+ * Returns the list of aliased contacts associated with the wallet.
92
+ * This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
93
+ * - Senders: Addresses we check during synching in case they sent us notes,
94
+ * - Contacts: more general concept akin to a phone's contact list.
95
+ * @returns The aliased collection of AztecAddresses that form this wallet's address book
96
+ */
97
+ async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
93
98
  const senders: AztecAddress[] = await this.pxe.getSenders();
94
99
  return senders.map(sender => ({ item: sender, alias: '' }));
95
100
  }
@@ -139,7 +144,8 @@ export abstract class BaseWallet implements Wallet {
139
144
 
140
145
  const fn = this[name] as (...args: any[]) => Promise<any>;
141
146
  const result = await fn.apply(this, args);
142
- results.push(result);
147
+ // Wrap result with method name for discriminated union deserialization
148
+ results.push({ name, result });
143
149
  }
144
150
  return results as BatchResults<T>;
145
151
  }
@@ -280,26 +286,24 @@ export abstract class BaseWallet implements Wallet {
280
286
  return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
281
287
  }
282
288
 
283
- async proveTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxProvingResult> {
289
+ async sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash> {
284
290
  const fee = await this.getDefaultFeeOptions(opts.from, opts.fee);
285
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
286
- return this.pxe.proveTx(txRequest);
287
- }
288
-
289
- async sendTx(tx: Tx): Promise<TxHash> {
291
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, fee);
292
+ const provenTx = await this.pxe.proveTx(txRequest);
293
+ const tx = await provenTx.toTx();
290
294
  const txHash = tx.getTxHash();
291
295
  if (await this.aztecNode.getTxEffect(txHash)) {
292
296
  throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
293
297
  }
294
298
  this.log.debug(`Sending transaction ${txHash}`);
295
299
  await this.aztecNode.sendTx(tx).catch(err => {
296
- throw this.#contextualizeError(err, inspect(tx));
300
+ throw this.contextualizeError(err, inspect(tx));
297
301
  });
298
302
  this.log.info(`Sent transaction ${txHash}`);
299
303
  return txHash;
300
304
  }
301
305
 
302
- #contextualizeError(err: Error, ...context: string[]): Error {
306
+ protected contextualizeError(err: Error, ...context: string[]): Error {
303
307
  let contextStr = '';
304
308
  if (context.length > 0) {
305
309
  contextStr = `\nContext:\n${context.join('\n')}`;
@@ -25,10 +25,8 @@ import { AbiDecodedSchema, type ApiSchemaFor, type ZodFor, optional, schemas } f
25
25
  import {
26
26
  Capsule,
27
27
  HashedValues,
28
- Tx,
29
28
  TxHash,
30
29
  TxProfileResult,
31
- TxProvingResult,
32
30
  TxReceipt,
33
31
  TxSimulationResult,
34
32
  UtilitySimulationResult,
@@ -109,7 +107,7 @@ export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
109
107
  /**
110
108
  * Helper type that represents all methods that can be batched.
111
109
  */
112
- export type BatchableMethods = Pick<Wallet, 'registerContract' | 'proveTx' | 'registerSender'>;
110
+ export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender'>;
113
111
 
114
112
  /**
115
113
  * From the batchable methods, we create a type that represents a method call with its name and arguments.
@@ -129,10 +127,22 @@ export type BatchedMethodResult<T> =
129
127
  T extends BatchedMethod<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
130
128
 
131
129
  /**
132
- * Maps a tuple of BatchedMethod to a tuple of their return types
130
+ * Wrapper type for batch results that includes the method name for discriminated union deserialization.
131
+ * Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
132
+ * when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
133
+ */
134
+ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMethods>> = {
135
+ /** The method name */
136
+ name: T['name'];
137
+ /** The method result */
138
+ result: BatchedMethodResult<T>;
139
+ };
140
+
141
+ /**
142
+ * Maps a tuple of BatchedMethod to a tuple of their wrapped return types
133
143
  */
134
144
  export type BatchResults<T extends readonly BatchedMethod<keyof BatchableMethods>[]> = {
135
- [K in keyof T]: BatchedMethodResult<T[K]>;
145
+ [K in keyof T]: BatchedMethodResultWrapper<T[K]>;
136
146
  };
137
147
 
138
148
  /**
@@ -151,7 +161,7 @@ export type Wallet = {
151
161
  getChainInfo(): Promise<ChainInfo>;
152
162
  getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
153
163
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
154
- getSenders(): Promise<Aliased<AztecAddress>[]>;
164
+ getAddressBook(): Promise<Aliased<AztecAddress>[]>;
155
165
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
156
166
  registerContract(
157
167
  instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
@@ -174,8 +184,7 @@ export type Wallet = {
174
184
  authwits?: AuthWitness[],
175
185
  ): Promise<UtilitySimulationResult>;
176
186
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
177
- proveTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxProvingResult>;
178
- sendTx(tx: Tx): Promise<TxHash>;
187
+ sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
179
188
  createAuthWit(
180
189
  from: AztecAddress,
181
190
  messageHashOrIntent: Fr | Buffer<ArrayBuffer> | IntentInnerHash | CallIntent,
@@ -276,7 +285,7 @@ export const BatchedMethodSchema = z.union([
276
285
  args: z.tuple([InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
277
286
  }),
278
287
  z.object({
279
- name: z.literal('proveTx'),
288
+ name: z.literal('sendTx'),
280
289
  args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
281
290
  }),
282
291
  ]);
@@ -312,7 +321,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
312
321
  .args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
313
322
  .returns(z.array(AbiDecodedSchema)),
314
323
  registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
315
- getSenders: z
324
+ getAddressBook: z
316
325
  .function()
317
326
  .args()
318
327
  .returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),
@@ -330,12 +339,19 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
330
339
  .args(z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema)))
331
340
  .returns(UtilitySimulationResult.schema),
332
341
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
333
- proveTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxProvingResult.schema),
334
- sendTx: z.function().args(Tx.schema).returns(TxHash.schema),
342
+ sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
335
343
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
336
344
  // @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
337
345
  batch: z
338
346
  .function()
339
347
  .args(z.array(BatchedMethodSchema))
340
- .returns(z.array(z.union([schemas.AztecAddress, ContractInstanceWithAddressSchema, TxProvingResult.schema]))),
348
+ .returns(
349
+ z.array(
350
+ z.discriminatedUnion('name', [
351
+ z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
352
+ z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
353
+ z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
354
+ ]),
355
+ ),
356
+ ),
341
357
  };
@@ -1,21 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { ProvingStats, TxProvingResult } from '@aztec/stdlib/tx';
4
- import type { Wallet } from '../wallet/wallet.js';
5
- import type { Contract } from './contract.js';
6
- import { DeploySentTx } from './deploy_sent_tx.js';
7
- import { ProvenTx } from './proven_tx.js';
8
- /**
9
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
10
- */
11
- export declare class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
12
- private postDeployCtor;
13
- private instanceGetter;
14
- private constructor();
15
- static fromProvingResult<TContract extends Contract = Contract>(wallet: Wallet, txProvingResult: TxProvingResult, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>, instanceGetter: () => Promise<ContractInstanceWithAddress>, stats?: ProvingStats): Promise<DeployProvenTx<TContract>>;
16
- /**
17
- * Sends the transaction to the network via the provided wallet.
18
- */
19
- send(): DeploySentTx<TContract>;
20
- }
21
- //# sourceMappingURL=deploy_proven_tx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy_proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAkB,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,QAAQ;IAK/E,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;IALxB,OAAO;WAWM,iBAAiB,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,EAClE,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EAC7E,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC,EAC1D,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAKrC;;OAEG;IACa,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC;CAKhD"}
@@ -1,21 +0,0 @@
1
- import { DeploySentTx } from './deploy_sent_tx.js';
2
- import { ProvenTx } from './proven_tx.js';
3
- /**
4
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
5
- */ export class DeployProvenTx extends ProvenTx {
6
- postDeployCtor;
7
- instanceGetter;
8
- constructor(wallet, tx, offchainEffects, postDeployCtor, instanceGetter, stats){
9
- super(wallet, tx, offchainEffects, stats), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter;
10
- }
11
- static async fromProvingResult(wallet, txProvingResult, postDeployCtor, instanceGetter, stats) {
12
- const tx = await txProvingResult.toTx();
13
- return new DeployProvenTx(wallet, tx, txProvingResult.getOffchainEffects(), postDeployCtor, instanceGetter, stats);
14
- }
15
- /**
16
- * Sends the transaction to the network via the provided wallet.
17
- */ send() {
18
- const sendTx = ()=>this.wallet.sendTx(this);
19
- return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, this.instanceGetter);
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- import { type OffchainEffect, type ProvingStats, Tx } from '@aztec/stdlib/tx';
2
- import type { Wallet } from '../wallet/wallet.js';
3
- import { SentTx } from './sent_tx.js';
4
- /**
5
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
6
- */
7
- export declare class ProvenTx extends Tx {
8
- #private;
9
- /** The offchain effects emitted during the execution of the transaction. */
10
- offchainEffects: OffchainEffect[];
11
- stats?: ProvingStats | undefined;
12
- constructor(wallet: Wallet, tx: Tx,
13
- /** The offchain effects emitted during the execution of the transaction. */
14
- offchainEffects: OffchainEffect[], stats?: ProvingStats | undefined);
15
- protected get wallet(): Wallet;
16
- /**
17
- * Sends the transaction to the network via the provided wallet.
18
- */
19
- send(): SentTx;
20
- }
21
- //# sourceMappingURL=proven_tx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,qBAAa,QAAS,SAAQ,EAAE;;IAM5B,4EAA4E;IACrE,eAAe,EAAE,cAAc,EAAE;IAEjC,KAAK,CAAC,EAAE,YAAY;gBAL3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,EAAE;IACN,4EAA4E;IACrE,eAAe,EAAE,cAAc,EAAE,EAEjC,KAAK,CAAC,EAAE,YAAY,YAAA;IAM7B,SAAS,KAAK,MAAM,IAAI,MAAM,CAE7B;IAED;;OAEG;IACI,IAAI,IAAI,MAAM;CAKtB"}
@@ -1,23 +0,0 @@
1
- import { Tx } from '@aztec/stdlib/tx';
2
- import { SentTx } from './sent_tx.js';
3
- /**
4
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
5
- */ export class ProvenTx extends Tx {
6
- offchainEffects;
7
- stats;
8
- #wallet;
9
- constructor(wallet, tx, /** The offchain effects emitted during the execution of the transaction. */ offchainEffects, // eslint-disable-next-line jsdoc/require-jsdoc
10
- stats){
11
- super(tx.txHash, tx.data, tx.clientIvcProof, tx.contractClassLogFields, tx.publicFunctionCalldata), this.offchainEffects = offchainEffects, this.stats = stats;
12
- this.#wallet = wallet;
13
- }
14
- get wallet() {
15
- return this.#wallet;
16
- }
17
- /**
18
- * Sends the transaction to the network via the provided wallet.
19
- */ send() {
20
- const sendTx = ()=>this.#wallet.sendTx(this);
21
- return new SentTx(this.#wallet, sendTx);
22
- }
23
- }
@@ -1,45 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { OffchainEffect, ProvingStats, TxProvingResult } from '@aztec/stdlib/tx';
4
- import { Tx } from '@aztec/stdlib/tx';
5
-
6
- import type { Wallet } from '../wallet/wallet.js';
7
- import type { Contract } from './contract.js';
8
- import { DeploySentTx } from './deploy_sent_tx.js';
9
- import { ProvenTx } from './proven_tx.js';
10
-
11
- /**
12
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
13
- */
14
- export class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
15
- private constructor(
16
- wallet: Wallet,
17
- tx: Tx,
18
- offchainEffects: OffchainEffect[],
19
- private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
20
- private instanceGetter: () => Promise<ContractInstanceWithAddress>,
21
- stats?: ProvingStats,
22
- ) {
23
- super(wallet, tx, offchainEffects, stats);
24
- }
25
-
26
- static async fromProvingResult<TContract extends Contract = Contract>(
27
- wallet: Wallet,
28
- txProvingResult: TxProvingResult,
29
- postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
30
- instanceGetter: () => Promise<ContractInstanceWithAddress>,
31
- stats?: ProvingStats,
32
- ): Promise<DeployProvenTx<TContract>> {
33
- const tx = await txProvingResult.toTx();
34
- return new DeployProvenTx(wallet, tx, txProvingResult.getOffchainEffects(), postDeployCtor, instanceGetter, stats);
35
- }
36
-
37
- /**
38
- * Sends the transaction to the network via the provided wallet.
39
- */
40
- public override send(): DeploySentTx<TContract> {
41
- const sendTx = () => this.wallet.sendTx(this);
42
-
43
- return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, this.instanceGetter);
44
- }
45
- }