@aztec/aztec.js 3.0.0-nightly.20251111 → 3.0.0-nightly.20251113
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.
- package/dest/account/account.d.ts +1 -2
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/signerless_account.d.ts +1 -2
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/api/contract.d.ts +1 -1
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/tx.d.ts +1 -1
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -1
- package/dest/contract/base_contract_interaction.d.ts +1 -2
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +1 -1
- package/dest/contract/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +9 -8
- package/dest/contract/contract_function_interaction.d.ts +1 -1
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +9 -6
- package/dest/contract/deploy_method.d.ts +1 -1
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +4 -4
- package/dest/contract/interaction_options.d.ts +3 -3
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +4 -10
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +2 -2
- package/dest/fee/fee_payment_method.d.ts +1 -1
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +1 -1
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +3 -3
- package/dest/fee/public_fee_payment_method.d.ts +1 -1
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +3 -3
- package/dest/fee/sponsored_fee_payment.d.ts +1 -1
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +2 -2
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +20 -4
- package/dest/utils/fee_juice.d.ts +1 -1
- package/dest/utils/fee_juice.js +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +2 -2
- package/dest/wallet/base_wallet.d.ts +16 -14
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +27 -26
- package/dest/wallet/deploy_account_method.d.ts +1 -1
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +1 -1
- package/dest/wallet/wallet.d.ts +214 -915
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +8 -10
- package/package.json +8 -8
- package/src/account/account.ts +1 -2
- package/src/account/signerless_account.ts +1 -2
- package/src/api/contract.ts +1 -0
- package/src/api/tx.ts +1 -0
- package/src/api/wallet.ts +1 -2
- package/src/contract/base_contract_interaction.ts +2 -3
- package/src/contract/batch_call.ts +7 -5
- package/src/contract/contract_function_interaction.ts +10 -11
- package/src/contract/deploy_method.ts +4 -4
- package/src/contract/interaction_options.ts +4 -10
- package/src/fee/fee_juice_payment_method_with_claim.ts +3 -1
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +4 -2
- package/src/fee/public_fee_payment_method.ts +4 -2
- package/src/fee/sponsored_fee_payment.ts +3 -1
- package/src/utils/authwit.ts +15 -4
- package/src/utils/fee_juice.ts +1 -1
- package/src/wallet/account_entrypoint_meta_payment_method.ts +2 -1
- package/src/wallet/base_wallet.ts +43 -32
- package/src/wallet/deploy_account_method.ts +1 -1
- package/src/wallet/wallet.ts +12 -24
|
@@ -6,10 +6,15 @@ import {
|
|
|
6
6
|
} from '@aztec/constants';
|
|
7
7
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
8
8
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
9
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
10
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
|
-
import
|
|
11
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
12
|
+
import {
|
|
13
|
+
type ContractArtifact,
|
|
14
|
+
type EventMetadataDefinition,
|
|
15
|
+
type FunctionCall,
|
|
16
|
+
decodeFromAbi,
|
|
17
|
+
} from '@aztec/stdlib/abi';
|
|
13
18
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
20
|
import {
|
|
@@ -32,6 +37,7 @@ import type {
|
|
|
32
37
|
TxSimulationResult,
|
|
33
38
|
UtilitySimulationResult,
|
|
34
39
|
} from '@aztec/stdlib/tx';
|
|
40
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
35
41
|
|
|
36
42
|
import { inspect } from 'util';
|
|
37
43
|
|
|
@@ -47,7 +53,6 @@ import type {
|
|
|
47
53
|
ProfileOptions,
|
|
48
54
|
SendOptions,
|
|
49
55
|
SimulateOptions,
|
|
50
|
-
UserFeeOptions,
|
|
51
56
|
Wallet,
|
|
52
57
|
} from './wallet.js';
|
|
53
58
|
|
|
@@ -151,46 +156,54 @@ export abstract class BaseWallet implements Wallet {
|
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
/**
|
|
154
|
-
*
|
|
155
|
-
* if they were omitted by the user.
|
|
159
|
+
* Completes partial user-provided fee options with wallet defaults.
|
|
156
160
|
* @param from - The address where the transaction is being sent from
|
|
157
|
-
* @param
|
|
158
|
-
* @
|
|
161
|
+
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
162
|
+
* @param gasSettings - User-provided partial gas settings
|
|
163
|
+
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
159
164
|
*/
|
|
160
|
-
protected async
|
|
165
|
+
protected async completeFeeOptions(
|
|
166
|
+
from: AztecAddress,
|
|
167
|
+
feePayer?: AztecAddress,
|
|
168
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
169
|
+
): Promise<FeeOptions> {
|
|
161
170
|
const maxFeesPerGas =
|
|
162
|
-
|
|
163
|
-
(await this.aztecNode.getCurrentBaseFees()).mul(1 + this.baseFeePadding);
|
|
171
|
+
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentBaseFees()).mul(1 + this.baseFeePadding);
|
|
164
172
|
let accountFeePaymentMethodOptions;
|
|
165
173
|
// The transaction does not include a fee payment method, so we set the flag
|
|
166
174
|
// for the account to use its fee juice balance
|
|
167
|
-
if (!
|
|
175
|
+
if (!feePayer) {
|
|
168
176
|
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
169
177
|
} else {
|
|
170
178
|
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
171
179
|
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
172
|
-
accountFeePaymentMethodOptions = from.equals(
|
|
180
|
+
accountFeePaymentMethodOptions = from.equals(feePayer)
|
|
173
181
|
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
|
|
174
182
|
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
175
183
|
}
|
|
176
|
-
const
|
|
177
|
-
this.log.debug(`Using L2 gas settings`,
|
|
184
|
+
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
185
|
+
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
178
186
|
return {
|
|
179
|
-
gasSettings,
|
|
187
|
+
gasSettings: fullGasSettings,
|
|
180
188
|
walletFeePaymentMethod: undefined,
|
|
181
189
|
accountFeePaymentMethodOptions,
|
|
182
190
|
};
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
194
|
+
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
195
|
+
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
196
|
+
* to avoid running out of gas during estimation.
|
|
189
197
|
* @param from - The address where the transaction is being sent from
|
|
190
|
-
* @param
|
|
198
|
+
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
199
|
+
* @param gasSettings - User-provided partial gas settings
|
|
191
200
|
*/
|
|
192
|
-
protected async
|
|
193
|
-
|
|
201
|
+
protected async completeFeeOptionsForEstimation(
|
|
202
|
+
from: AztecAddress,
|
|
203
|
+
feePayer?: AztecAddress,
|
|
204
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
205
|
+
) {
|
|
206
|
+
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
194
207
|
const {
|
|
195
208
|
gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas },
|
|
196
209
|
} = defaultFeeOptions;
|
|
@@ -269,8 +282,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
269
282
|
|
|
270
283
|
async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
|
|
271
284
|
const feeOptions = opts.fee?.estimateGas
|
|
272
|
-
? await this.
|
|
273
|
-
: await this.
|
|
285
|
+
? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
|
|
286
|
+
: await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
274
287
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
275
288
|
return this.pxe.simulateTx(
|
|
276
289
|
txRequest,
|
|
@@ -281,14 +294,14 @@ export abstract class BaseWallet implements Wallet {
|
|
|
281
294
|
}
|
|
282
295
|
|
|
283
296
|
async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|
|
284
|
-
const
|
|
285
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from,
|
|
297
|
+
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
298
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
286
299
|
return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
|
|
287
300
|
}
|
|
288
301
|
|
|
289
302
|
async sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash> {
|
|
290
|
-
const
|
|
291
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from,
|
|
303
|
+
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
304
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
292
305
|
const provenTx = await this.pxe.proveTx(txRequest);
|
|
293
306
|
const tx = await provenTx.toTx();
|
|
294
307
|
const txHash = tx.getTxHash();
|
|
@@ -318,13 +331,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
simulateUtility(
|
|
321
|
-
|
|
322
|
-
args: any[],
|
|
323
|
-
to: AztecAddress,
|
|
334
|
+
call: FunctionCall,
|
|
324
335
|
authwits?: AuthWitness[],
|
|
325
|
-
|
|
336
|
+
scopes?: AztecAddress[],
|
|
326
337
|
): Promise<UtilitySimulationResult> {
|
|
327
|
-
return this.pxe.simulateUtility(
|
|
338
|
+
return this.pxe.simulateUtility(call, authwits, scopes);
|
|
328
339
|
}
|
|
329
340
|
|
|
330
341
|
getContractClassMetadata(id: Fr, includeArtifact: boolean = false): Promise<ContractClassMetadata> {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
4
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
5
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { Contract } from '../contract/contract.js';
|
|
8
8
|
import type { ContractBase } from '../contract/contract_base.js';
|
package/src/wallet/wallet.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import {
|
|
5
4
|
AbiTypeSchema,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
ContractArtifactSchema,
|
|
8
7
|
type EventMetadataDefinition,
|
|
9
8
|
FunctionAbiSchema,
|
|
9
|
+
type FunctionCall,
|
|
10
10
|
FunctionType,
|
|
11
11
|
} from '@aztec/stdlib/abi';
|
|
12
12
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
TxSimulationResult,
|
|
32
32
|
UtilitySimulationResult,
|
|
33
33
|
} from '@aztec/stdlib/tx';
|
|
34
|
+
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
34
35
|
|
|
35
36
|
import { z } from 'zod';
|
|
36
37
|
|
|
@@ -63,17 +64,6 @@ export type Aliased<T> = {
|
|
|
63
64
|
*/
|
|
64
65
|
export type ContractInstanceAndArtifact = Pick<Contract, 'artifact' | 'instance'>;
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* Options that can be provided to the wallet for configuration of the fee payment.
|
|
68
|
-
*/
|
|
69
|
-
export type UserFeeOptions = {
|
|
70
|
-
/**
|
|
71
|
-
* Informs the wallet that the crafted tx already contains the necessary calls to pay for its fee
|
|
72
|
-
* and who is paying
|
|
73
|
-
*/
|
|
74
|
-
embeddedPaymentMethodFeePayer?: AztecAddress;
|
|
75
|
-
} & GasSettingsOption;
|
|
76
|
-
|
|
77
67
|
/**
|
|
78
68
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
79
69
|
* a simplified version that only hints at the wallet wether the interaction contains a
|
|
@@ -81,7 +71,7 @@ export type UserFeeOptions = {
|
|
|
81
71
|
*/
|
|
82
72
|
export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
83
73
|
/** The fee options */
|
|
84
|
-
fee?:
|
|
74
|
+
fee?: GasSettingsOption & FeeEstimationOptions;
|
|
85
75
|
};
|
|
86
76
|
|
|
87
77
|
/**
|
|
@@ -91,7 +81,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
|
91
81
|
*/
|
|
92
82
|
export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
93
83
|
/** The fee options */
|
|
94
|
-
fee?:
|
|
84
|
+
fee?: GasSettingsOption;
|
|
95
85
|
};
|
|
96
86
|
|
|
97
87
|
/**
|
|
@@ -101,7 +91,7 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
|
101
91
|
*/
|
|
102
92
|
export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
103
93
|
/** The fee options */
|
|
104
|
-
fee?:
|
|
94
|
+
fee?: GasSettingsOption;
|
|
105
95
|
};
|
|
106
96
|
|
|
107
97
|
/**
|
|
@@ -178,10 +168,9 @@ export type Wallet = {
|
|
|
178
168
|
): Promise<ContractInstanceWithAddress>;
|
|
179
169
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
180
170
|
simulateUtility(
|
|
181
|
-
|
|
182
|
-
args: any[],
|
|
183
|
-
to: AztecAddress,
|
|
171
|
+
call: FunctionCall,
|
|
184
172
|
authwits?: AuthWitness[],
|
|
173
|
+
scopes?: AztecAddress[],
|
|
185
174
|
): Promise<UtilitySimulationResult>;
|
|
186
175
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
187
176
|
sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
|
|
@@ -216,7 +205,7 @@ export const ExecutionPayloadSchema = z.object({
|
|
|
216
205
|
extraHashedArgs: z.array(HashedValues.schema),
|
|
217
206
|
});
|
|
218
207
|
|
|
219
|
-
export const
|
|
208
|
+
export const GasSettingsOptionSchema = z.object({
|
|
220
209
|
gasSettings: optional(
|
|
221
210
|
z.object({
|
|
222
211
|
gasLimits: optional(Gas.schema),
|
|
@@ -225,10 +214,9 @@ export const UserFeeOptionsSchema = z.object({
|
|
|
225
214
|
maxPriorityFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
|
|
226
215
|
}),
|
|
227
216
|
),
|
|
228
|
-
embeddedPaymentMethodFeePayer: optional(schemas.AztecAddress),
|
|
229
217
|
});
|
|
230
218
|
|
|
231
|
-
export const WalletSimulationFeeOptionSchema =
|
|
219
|
+
export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
|
|
232
220
|
estimatedGasPadding: optional(z.number()),
|
|
233
221
|
estimateGas: optional(z.boolean()),
|
|
234
222
|
});
|
|
@@ -237,7 +225,7 @@ export const SendOptionsSchema = z.object({
|
|
|
237
225
|
from: schemas.AztecAddress,
|
|
238
226
|
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
239
227
|
capsules: optional(z.array(Capsule.schema)),
|
|
240
|
-
fee: optional(
|
|
228
|
+
fee: optional(GasSettingsOptionSchema),
|
|
241
229
|
});
|
|
242
230
|
|
|
243
231
|
export const SimulateOptionsSchema = z.object({
|
|
@@ -286,7 +274,7 @@ export const BatchedMethodSchema = z.union([
|
|
|
286
274
|
}),
|
|
287
275
|
z.object({
|
|
288
276
|
name: z.literal('simulateUtility'),
|
|
289
|
-
args: z.tuple([
|
|
277
|
+
args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema)), optional(z.array(schemas.AztecAddress))]),
|
|
290
278
|
}),
|
|
291
279
|
]);
|
|
292
280
|
|
|
@@ -336,7 +324,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
336
324
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
337
325
|
simulateUtility: z
|
|
338
326
|
.function()
|
|
339
|
-
.args(
|
|
327
|
+
.args(FunctionCallSchema, optional(z.array(AuthWitness.schema)), optional(z.array(schemas.AztecAddress)))
|
|
340
328
|
.returns(UtilitySimulationResult.schema),
|
|
341
329
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
342
330
|
sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
|