@aztec/wallets 4.2.0-nightly.20260319 → 4.2.0-nightly.20260320
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/embedded/embedded_wallet.d.ts +14 -5
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +80 -28
- package/dest/testing.d.ts +1 -1
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +2 -2
- package/package.json +10 -10
- package/src/embedded/embedded_wallet.ts +105 -38
- package/src/testing.ts +2 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type Account } from '@aztec/aztec.js/account';
|
|
2
|
-
import type
|
|
2
|
+
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
|
|
3
4
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
4
5
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import type { Logger } from '@aztec/foundation/log';
|
|
6
|
-
import type {
|
|
7
|
+
import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
7
8
|
import type { PXE } from '@aztec/pxe/server';
|
|
8
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
10
11
|
import { ExecutionPayload, type TxSimulationResult } from '@aztec/stdlib/tx';
|
|
11
|
-
import { BaseWallet, type
|
|
12
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
12
13
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
13
14
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
14
15
|
export type EmbeddedWalletOptions = {
|
|
@@ -24,17 +25,24 @@ export type EmbeddedWalletOptions = {
|
|
|
24
25
|
export declare class EmbeddedWallet extends BaseWallet {
|
|
25
26
|
protected walletDB: WalletDB;
|
|
26
27
|
protected accountContracts: AccountContractsProvider;
|
|
28
|
+
protected estimatedGasPadding: number;
|
|
27
29
|
constructor(pxe: PXE, aztecNode: AztecNode, walletDB: WalletDB, accountContracts: AccountContractsProvider, log?: Logger);
|
|
28
30
|
protected getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
29
31
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
30
32
|
registerSender(address: AztecAddress, alias: string): Promise<AztecAddress>;
|
|
31
33
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
|
|
36
|
+
* estimates actual gas usage and captures call authorization requests to generate
|
|
37
|
+
* the necessary authwitnesses.
|
|
38
|
+
*/
|
|
39
|
+
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
32
40
|
/**
|
|
33
41
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
34
42
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
35
43
|
* private kernel circuit execution.
|
|
36
44
|
*/
|
|
37
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
45
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
38
46
|
private getFakeAccountDataFor;
|
|
39
47
|
protected createAccountInternal(type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
40
48
|
createAndStoreAccount(alias: string, type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
@@ -42,6 +50,7 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
42
50
|
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer, alias?: string): Promise<AccountManager>;
|
|
43
51
|
createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer, alias?: string): Promise<AccountManager>;
|
|
44
52
|
setMinFeePadding(value?: number): void;
|
|
53
|
+
setEstimatedGasPadding(value?: number): void;
|
|
45
54
|
stop(): Promise<void>;
|
|
46
55
|
}
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
56
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1iZWRkZWRfd2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvZW1iZWRkZWRfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBVyxNQUFNLHlCQUF5QixDQUFDO0FBRWhFLE9BQU8sRUFBRSxLQUFLLHNCQUFzQixFQUFFLEtBQUssVUFBVSxFQUFnQixNQUFNLDJCQUEyQixDQUFDO0FBQ3ZHLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUNuRSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHeEQsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1RSxPQUFPLEtBQUssRUFBRSxHQUFHLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUM3QyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFL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Q0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxDQUFDLEVBQUUsRUFBRSxFQUFFLEtBQUssQ0FBQyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBR25HO0lBRUQsbUJBQW1CLENBQUMsTUFBTSxFQUFFLEVBQUUsRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsS0FBSyxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FFckc7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsRUFBRSxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxLQUFLLENBQUMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUVyRztJQUVELGdCQUFnQixDQUFDLEtBQUssQ0FBQyxFQUFFLE1BQU0sUUFFOUI7SUFFRCxzQkFBc0IsQ0FBQyxLQUFLLENBQUMsRUFBRSxNQUFNLFFBRXBDO0lBRUQsSUFBSSxrQkFFSDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded_wallet.d.ts","sourceRoot":"","sources":["../../src/embedded/embedded_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"embedded_wallet.d.ts","sourceRoot":"","sources":["../../src/embedded/embedded_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,UAAU,EAAgB,MAAM,2BAA2B,CAAC;AACvG,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,c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AAG,OAAO,CAAC,cAAc,CAAC,CAErG;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAErG;IAED,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAE9B;IAED,sBAAsB,CAAC,KAAK,CAAC,EAAE,MAAM,QAEpC;IAED,IAAI,kBAEH;CACF"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { getGasLimits } from '@aztec/aztec.js/contracts';
|
|
2
4
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
3
6
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
7
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
8
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
6
9
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
7
|
-
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
10
|
+
import { collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
8
11
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
12
|
+
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
9
13
|
export class EmbeddedWallet extends BaseWallet {
|
|
10
14
|
walletDB;
|
|
11
15
|
accountContracts;
|
|
16
|
+
estimatedGasPadding;
|
|
12
17
|
constructor(pxe, aztecNode, walletDB, accountContracts, log){
|
|
13
|
-
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts;
|
|
18
|
+
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
|
|
14
19
|
}
|
|
15
20
|
async getAccountFromAddress(address) {
|
|
16
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
17
|
-
return new SignerlessAccount();
|
|
18
|
-
}
|
|
19
21
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
20
22
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
21
23
|
const account = await accountManager.getAccount();
|
|
@@ -42,15 +44,72 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
42
44
|
return storedSenders;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
47
|
+
* Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
|
|
48
|
+
* estimates actual gas usage and captures call authorization requests to generate
|
|
49
|
+
* the necessary authwitnesses.
|
|
50
|
+
*/ async sendTx(executionPayload, opts) {
|
|
51
|
+
const feeOptions = await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
52
|
+
// Simulate the transaction first to estimate gas and capture required
|
|
53
|
+
// private authwitnesses based on offchain effects.
|
|
54
|
+
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
55
|
+
from: opts.from,
|
|
56
|
+
feeOptions,
|
|
57
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
58
|
+
skipTxValidation: true
|
|
59
|
+
});
|
|
60
|
+
const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
|
|
61
|
+
const authWitnesses = await Promise.all(offchainEffects.map(async (effect)=>{
|
|
62
|
+
try {
|
|
63
|
+
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
64
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
65
|
+
consumer: effect.contractAddress,
|
|
66
|
+
innerHash: authRequest.innerHash
|
|
67
|
+
});
|
|
68
|
+
} catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
for (const authwit of authWitnesses){
|
|
73
|
+
if (authwit) {
|
|
74
|
+
executionPayload.authWitnesses.push(authwit);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const estimated = getGasLimits(simulationResult, this.estimatedGasPadding);
|
|
78
|
+
this.log.verbose(`Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`);
|
|
79
|
+
const gasSettings = GasSettings.from({
|
|
80
|
+
...opts.fee?.gasSettings,
|
|
81
|
+
maxFeesPerGas: feeOptions.gasSettings.maxFeesPerGas,
|
|
82
|
+
maxPriorityFeesPerGas: feeOptions.gasSettings.maxPriorityFeesPerGas,
|
|
83
|
+
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
84
|
+
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
|
|
85
|
+
});
|
|
86
|
+
return super.sendTx(executionPayload, {
|
|
87
|
+
...opts,
|
|
88
|
+
fee: {
|
|
89
|
+
...opts.fee,
|
|
90
|
+
gasSettings
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
45
95
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
46
96
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
47
97
|
* private kernel circuit execution.
|
|
48
|
-
*/ async simulateViaEntrypoint(executionPayload,
|
|
98
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
99
|
+
const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
|
|
100
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
101
|
+
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
102
|
+
feeExecutionPayload,
|
|
103
|
+
executionPayload
|
|
104
|
+
]) : executionPayload;
|
|
105
|
+
const chainInfo = await this.getChainInfo();
|
|
49
106
|
let overrides;
|
|
50
|
-
let
|
|
51
|
-
if (
|
|
107
|
+
let txRequest;
|
|
108
|
+
if (from === NO_FROM) {
|
|
109
|
+
const entrypoint = new DefaultEntrypoint();
|
|
110
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
111
|
+
} else {
|
|
52
112
|
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
53
|
-
fromAccount = account;
|
|
54
113
|
overrides = {
|
|
55
114
|
contracts: {
|
|
56
115
|
[from.toString()]: {
|
|
@@ -59,21 +118,14 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
59
118
|
}
|
|
60
119
|
}
|
|
61
120
|
};
|
|
62
|
-
|
|
63
|
-
|
|
121
|
+
const executionOptions = {
|
|
122
|
+
txNonce: Fr.random(),
|
|
123
|
+
cancellable: this.cancellableTransactions,
|
|
124
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
125
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
126
|
+
};
|
|
127
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
64
128
|
}
|
|
65
|
-
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
66
|
-
const executionOptions = {
|
|
67
|
-
txNonce: Fr.random(),
|
|
68
|
-
cancellable: this.cancellableTransactions,
|
|
69
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
70
|
-
};
|
|
71
|
-
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
72
|
-
feeExecutionPayload,
|
|
73
|
-
executionPayload
|
|
74
|
-
]) : executionPayload;
|
|
75
|
-
const chainInfo = await this.getChainInfo();
|
|
76
|
-
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
77
129
|
return this.pxe.simulateTx(txRequest, {
|
|
78
130
|
simulatePublic: true,
|
|
79
131
|
skipFeeEnforcement,
|
|
@@ -84,9 +136,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
84
136
|
}
|
|
85
137
|
async getFakeAccountDataFor(address) {
|
|
86
138
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
87
|
-
if (originalAccount instanceof SignerlessAccount) {
|
|
88
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
89
|
-
}
|
|
90
139
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
91
140
|
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
92
141
|
if (!contractInstance) {
|
|
@@ -159,6 +208,9 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
159
208
|
setMinFeePadding(value) {
|
|
160
209
|
this.minFeePadding = value ?? 0.5;
|
|
161
210
|
}
|
|
211
|
+
setEstimatedGasPadding(value) {
|
|
212
|
+
this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
|
|
213
|
+
}
|
|
162
214
|
stop() {
|
|
163
215
|
return this.pxe.stop();
|
|
164
216
|
}
|
package/dest/testing.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ interface WalletWithSchnorrAccounts {
|
|
|
9
9
|
export declare function deployFundedSchnorrAccounts(wallet: WalletWithSchnorrAccounts, accountsData: InitialAccountData[], waitOptions?: WaitOpts): Promise<AccountManager[]>;
|
|
10
10
|
export declare function registerInitialLocalNetworkAccountsInWallet(wallet: WalletWithSchnorrAccounts): Promise<AztecAddress[]>;
|
|
11
11
|
export {};
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzI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
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,UAAU,yBAAyB;IACjC,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtG;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,yBAAyB,EACjC,YAAY,EAAE,kBAAkB,EAAE,EAClC,WAAW,CAAC,EAAE,QAAQ,6BAgBvB;AAED,wBAAsB,2CAA2C,CAC/D,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC,CAOzB"}
|
package/dest/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
3
|
export async function deployFundedSchnorrAccounts(wallet, accountsData, waitOptions) {
|
|
4
4
|
const accountManagers = [];
|
|
5
5
|
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
@@ -8,7 +8,7 @@ export async function deployFundedSchnorrAccounts(wallet, accountsData, waitOpti
|
|
|
8
8
|
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
9
9
|
const deployMethod = await accountManager.getDeployMethod();
|
|
10
10
|
await deployMethod.send({
|
|
11
|
-
from:
|
|
11
|
+
from: NO_FROM,
|
|
12
12
|
skipClassPublication: i !== 0,
|
|
13
13
|
wait: waitOptions
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/wallets",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallets",
|
|
4
|
-
"version": "4.2.0-nightly.
|
|
4
|
+
"version": "4.2.0-nightly.20260320",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./embedded": {
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"../package.common.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@aztec/accounts": "4.2.0-nightly.
|
|
31
|
-
"@aztec/aztec.js": "4.2.0-nightly.
|
|
32
|
-
"@aztec/entrypoints": "4.2.0-nightly.
|
|
33
|
-
"@aztec/foundation": "4.2.0-nightly.
|
|
34
|
-
"@aztec/kv-store": "4.2.0-nightly.
|
|
35
|
-
"@aztec/protocol-contracts": "4.2.0-nightly.
|
|
36
|
-
"@aztec/pxe": "4.2.0-nightly.
|
|
37
|
-
"@aztec/stdlib": "4.2.0-nightly.
|
|
38
|
-
"@aztec/wallet-sdk": "4.2.0-nightly.
|
|
30
|
+
"@aztec/accounts": "4.2.0-nightly.20260320",
|
|
31
|
+
"@aztec/aztec.js": "4.2.0-nightly.20260320",
|
|
32
|
+
"@aztec/entrypoints": "4.2.0-nightly.20260320",
|
|
33
|
+
"@aztec/foundation": "4.2.0-nightly.20260320",
|
|
34
|
+
"@aztec/kv-store": "4.2.0-nightly.20260320",
|
|
35
|
+
"@aztec/protocol-contracts": "4.2.0-nightly.20260320",
|
|
36
|
+
"@aztec/pxe": "4.2.0-nightly.20260320",
|
|
37
|
+
"@aztec/stdlib": "4.2.0-nightly.20260320",
|
|
38
|
+
"@aztec/wallet-sdk": "4.2.0-nightly.20260320"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@jest/globals": "^30.0.0",
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import { type Account,
|
|
2
|
-
import
|
|
1
|
+
import { type Account, NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { type InteractionWaitOptions, type SendReturn, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
|
|
3
5
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
4
6
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
7
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
8
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import type { Logger } from '@aztec/foundation/log';
|
|
7
|
-
import type {
|
|
10
|
+
import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
8
11
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
13
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
14
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
15
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
12
16
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
13
17
|
import {
|
|
14
18
|
ExecutionPayload,
|
|
15
19
|
SimulationOverrides,
|
|
20
|
+
type TxExecutionRequest,
|
|
16
21
|
type TxSimulationResult,
|
|
22
|
+
collectOffchainEffects,
|
|
17
23
|
mergeExecutionPayloads,
|
|
18
24
|
} from '@aztec/stdlib/tx';
|
|
19
|
-
import { BaseWallet, type
|
|
25
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
20
26
|
|
|
21
27
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
22
28
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
@@ -32,7 +38,11 @@ export type EmbeddedWalletOptions = {
|
|
|
32
38
|
pxeOptions?: PXECreationOptions;
|
|
33
39
|
};
|
|
34
40
|
|
|
41
|
+
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
42
|
+
|
|
35
43
|
export class EmbeddedWallet extends BaseWallet {
|
|
44
|
+
protected estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
|
|
45
|
+
|
|
36
46
|
constructor(
|
|
37
47
|
pxe: PXE,
|
|
38
48
|
aztecNode: AztecNode,
|
|
@@ -44,10 +54,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
protected async getAccountFromAddress(address: AztecAddress): Promise<Account> {
|
|
47
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
48
|
-
return new SignerlessAccount();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
57
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
52
58
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
53
59
|
const account = await accountManager.getAccount();
|
|
@@ -79,6 +85,66 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
79
85
|
return storedSenders;
|
|
80
86
|
}
|
|
81
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
|
|
90
|
+
* estimates actual gas usage and captures call authorization requests to generate
|
|
91
|
+
* the necessary authwitnesses.
|
|
92
|
+
*/
|
|
93
|
+
public override async sendTx<W extends InteractionWaitOptions = undefined>(
|
|
94
|
+
executionPayload: ExecutionPayload,
|
|
95
|
+
opts: SendOptions<W>,
|
|
96
|
+
): Promise<SendReturn<W>> {
|
|
97
|
+
const feeOptions = await this.completeFeeOptionsForEstimation(
|
|
98
|
+
opts.from,
|
|
99
|
+
executionPayload.feePayer,
|
|
100
|
+
opts.fee?.gasSettings,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Simulate the transaction first to estimate gas and capture required
|
|
104
|
+
// private authwitnesses based on offchain effects.
|
|
105
|
+
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
106
|
+
from: opts.from,
|
|
107
|
+
feeOptions,
|
|
108
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
109
|
+
skipTxValidation: true,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
|
|
113
|
+
const authWitnesses = await Promise.all(
|
|
114
|
+
offchainEffects.map(async effect => {
|
|
115
|
+
try {
|
|
116
|
+
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
117
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
118
|
+
consumer: effect.contractAddress,
|
|
119
|
+
innerHash: authRequest.innerHash,
|
|
120
|
+
});
|
|
121
|
+
} catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
for (const authwit of authWitnesses) {
|
|
127
|
+
if (authwit) {
|
|
128
|
+
executionPayload.authWitnesses.push(authwit);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const estimated = getGasLimits(simulationResult, this.estimatedGasPadding);
|
|
132
|
+
this.log.verbose(
|
|
133
|
+
`Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`,
|
|
134
|
+
);
|
|
135
|
+
const gasSettings = GasSettings.from({
|
|
136
|
+
...opts.fee?.gasSettings,
|
|
137
|
+
maxFeesPerGas: feeOptions.gasSettings.maxFeesPerGas,
|
|
138
|
+
maxPriorityFeesPerGas: feeOptions.gasSettings.maxPriorityFeesPerGas,
|
|
139
|
+
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
140
|
+
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits,
|
|
141
|
+
});
|
|
142
|
+
return super.sendTx(executionPayload, {
|
|
143
|
+
...opts,
|
|
144
|
+
fee: { ...opts.fee, gasSettings },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
82
148
|
/**
|
|
83
149
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
84
150
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
@@ -86,40 +152,40 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
86
152
|
*/
|
|
87
153
|
protected override async simulateViaEntrypoint(
|
|
88
154
|
executionPayload: ExecutionPayload,
|
|
89
|
-
|
|
90
|
-
feeOptions: FeeOptions,
|
|
91
|
-
scopes: AccessScopes,
|
|
92
|
-
skipTxValidation?: boolean,
|
|
93
|
-
skipFeeEnforcement?: boolean,
|
|
155
|
+
opts: SimulateViaEntrypointOptions,
|
|
94
156
|
): Promise<TxSimulationResult> {
|
|
157
|
+
const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
|
|
158
|
+
|
|
159
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
160
|
+
const finalExecutionPayload = feeExecutionPayload
|
|
161
|
+
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
162
|
+
: executionPayload;
|
|
163
|
+
const chainInfo = await this.getChainInfo();
|
|
164
|
+
|
|
95
165
|
let overrides: SimulationOverrides | undefined;
|
|
96
|
-
let
|
|
97
|
-
if (
|
|
166
|
+
let txRequest: TxExecutionRequest;
|
|
167
|
+
if (from === NO_FROM) {
|
|
168
|
+
const entrypoint = new DefaultEntrypoint();
|
|
169
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
170
|
+
} else {
|
|
98
171
|
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
99
|
-
fromAccount = account;
|
|
100
172
|
overrides = {
|
|
101
173
|
contracts: { [from.toString()]: { instance, artifact } },
|
|
102
174
|
};
|
|
103
|
-
|
|
104
|
-
|
|
175
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
176
|
+
txNonce: Fr.random(),
|
|
177
|
+
cancellable: this.cancellableTransactions,
|
|
178
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
179
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
|
|
180
|
+
};
|
|
181
|
+
txRequest = await account.createTxExecutionRequest(
|
|
182
|
+
finalExecutionPayload,
|
|
183
|
+
feeOptions.gasSettings,
|
|
184
|
+
chainInfo,
|
|
185
|
+
executionOptions,
|
|
186
|
+
);
|
|
105
187
|
}
|
|
106
188
|
|
|
107
|
-
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
108
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
109
|
-
txNonce: Fr.random(),
|
|
110
|
-
cancellable: this.cancellableTransactions,
|
|
111
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
112
|
-
};
|
|
113
|
-
const finalExecutionPayload = feeExecutionPayload
|
|
114
|
-
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
115
|
-
: executionPayload;
|
|
116
|
-
const chainInfo = await this.getChainInfo();
|
|
117
|
-
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
118
|
-
finalExecutionPayload,
|
|
119
|
-
feeOptions.gasSettings,
|
|
120
|
-
chainInfo,
|
|
121
|
-
executionOptions,
|
|
122
|
-
);
|
|
123
189
|
return this.pxe.simulateTx(txRequest, {
|
|
124
190
|
simulatePublic: true,
|
|
125
191
|
skipFeeEnforcement,
|
|
@@ -131,10 +197,7 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
131
197
|
|
|
132
198
|
private async getFakeAccountDataFor(address: AztecAddress) {
|
|
133
199
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
134
|
-
|
|
135
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
136
|
-
}
|
|
137
|
-
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
200
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
138
201
|
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
139
202
|
if (!contractInstance) {
|
|
140
203
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
@@ -220,6 +283,10 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
220
283
|
this.minFeePadding = value ?? 0.5;
|
|
221
284
|
}
|
|
222
285
|
|
|
286
|
+
setEstimatedGasPadding(value?: number) {
|
|
287
|
+
this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
|
|
288
|
+
}
|
|
289
|
+
|
|
223
290
|
stop() {
|
|
224
291
|
return this.pxe.stop();
|
|
225
292
|
}
|
package/src/testing.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
3
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
4
|
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
4
5
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import type { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -21,7 +22,7 @@ export async function deployFundedSchnorrAccounts(
|
|
|
21
22
|
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
22
23
|
const deployMethod = await accountManager.getDeployMethod();
|
|
23
24
|
await deployMethod.send({
|
|
24
|
-
from:
|
|
25
|
+
from: NO_FROM,
|
|
25
26
|
skipClassPublication: i !== 0,
|
|
26
27
|
wait: waitOptions,
|
|
27
28
|
});
|