@aztec/wallets 5.0.0-private.20260319 → 5.0.0-rc.2
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/account-contract-providers/bundle.d.ts +6 -8
- package/dest/embedded/account-contract-providers/bundle.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/bundle.js +10 -10
- package/dest/embedded/account-contract-providers/lazy.d.ts +6 -8
- package/dest/embedded/account-contract-providers/lazy.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/lazy.js +20 -10
- package/dest/embedded/account-contract-providers/types.d.ts +6 -8
- package/dest/embedded/account-contract-providers/types.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.d.ts +54 -8
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +214 -68
- package/dest/embedded/entrypoints/browser.d.ts +2 -2
- package/dest/embedded/entrypoints/browser.d.ts.map +1 -1
- package/dest/embedded/entrypoints/browser.js +39 -10
- package/dest/embedded/entrypoints/node.d.ts +2 -2
- package/dest/embedded/entrypoints/node.d.ts.map +1 -1
- package/dest/embedded/entrypoints/node.js +33 -10
- package/dest/embedded/store_encryption.d.ts +67 -0
- package/dest/embedded/store_encryption.d.ts.map +1 -0
- package/dest/embedded/store_encryption.js +71 -0
- package/dest/embedded/wallet_db.d.ts +7 -6
- package/dest/embedded/wallet_db.d.ts.map +1 -1
- package/dest/embedded/wallet_db.js +12 -11
- package/dest/testing.d.ts +8 -4
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +8 -14
- package/package.json +12 -10
- package/src/embedded/account-contract-providers/bundle.ts +13 -12
- package/src/embedded/account-contract-providers/lazy.ts +23 -12
- package/src/embedded/account-contract-providers/types.ts +6 -4
- package/src/embedded/embedded_wallet.ts +271 -75
- package/src/embedded/entrypoints/browser.ts +47 -20
- package/src/embedded/entrypoints/node.ts +46 -26
- package/src/embedded/store_encryption.ts +107 -0
- package/src/embedded/wallet_db.ts +15 -12
- package/src/testing.ts +11 -16
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import {
|
|
4
|
-
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { ContractFunctionInteraction, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { AccountManager, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
6
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
7
|
+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
5
8
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import {
|
|
7
|
-
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
9
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
8
10
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
9
11
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
-
import { collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
11
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
12
|
+
import { SimulationOverrides, TxStatus, collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
|
+
import { BaseWallet, getGasLimits } from '@aztec/wallet-sdk/base-wallet';
|
|
14
|
+
/** Splits a unified EmbeddedWalletPXEOptions into PXEConfig overrides and PXECreationOptions. */ export function splitPxeOptions(pxe) {
|
|
15
|
+
if (!pxe) {
|
|
16
|
+
return {
|
|
17
|
+
config: {},
|
|
18
|
+
creation: {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const { loggers, loggerActorLabel, proverOrOptions, store, simulator, hooks, preloadedContractsProvider, ...config } = pxe;
|
|
22
|
+
return {
|
|
23
|
+
config,
|
|
24
|
+
creation: {
|
|
25
|
+
loggers,
|
|
26
|
+
loggerActorLabel,
|
|
27
|
+
proverOrOptions,
|
|
28
|
+
store,
|
|
29
|
+
simulator,
|
|
30
|
+
hooks,
|
|
31
|
+
preloadedContractsProvider
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
12
35
|
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
13
36
|
export class EmbeddedWallet extends BaseWallet {
|
|
14
37
|
walletDB;
|
|
15
38
|
accountContracts;
|
|
16
39
|
estimatedGasPadding;
|
|
40
|
+
// Stub class ids, populated on wallet startup
|
|
41
|
+
// to avoid redundant work per simulation
|
|
42
|
+
stubClassIds;
|
|
17
43
|
constructor(pxe, aztecNode, walletDB, accountContracts, log){
|
|
18
|
-
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
|
|
44
|
+
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING, this.stubClassIds = new Map();
|
|
19
45
|
}
|
|
20
46
|
async getAccountFromAddress(address) {
|
|
21
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
22
|
-
return new SignerlessAccount();
|
|
23
|
-
}
|
|
24
47
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
25
48
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
26
49
|
const account = await accountManager.getAccount();
|
|
@@ -34,14 +57,24 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
34
57
|
}
|
|
35
58
|
async registerSender(address, alias) {
|
|
36
59
|
await this.walletDB.storeSender(address, alias);
|
|
37
|
-
|
|
60
|
+
await this.pxe.registerTaggingSecretSource({
|
|
61
|
+
kind: 'address-derived',
|
|
62
|
+
sender: address
|
|
63
|
+
});
|
|
64
|
+
return address;
|
|
38
65
|
}
|
|
39
66
|
async getAddressBook() {
|
|
40
|
-
const
|
|
67
|
+
const sources = await this.pxe.getTaggingSecretSources({
|
|
68
|
+
kind: 'address-derived'
|
|
69
|
+
});
|
|
70
|
+
const senders = sources.map((source)=>source.sender);
|
|
41
71
|
const storedSenders = await this.walletDB.listSenders();
|
|
42
72
|
for (const storedSender of storedSenders){
|
|
43
73
|
if (senders.findIndex((sender)=>sender.equals(storedSender.item)) === -1) {
|
|
44
|
-
await this.pxe.
|
|
74
|
+
await this.pxe.registerTaggingSecretSource({
|
|
75
|
+
kind: 'address-derived',
|
|
76
|
+
sender: storedSender.item
|
|
77
|
+
});
|
|
45
78
|
}
|
|
46
79
|
}
|
|
47
80
|
return storedSenders;
|
|
@@ -51,20 +84,29 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
51
84
|
* estimates actual gas usage and captures call authorization requests to generate
|
|
52
85
|
* the necessary authwitnesses.
|
|
53
86
|
*/ async sendTx(executionPayload, opts) {
|
|
54
|
-
|
|
87
|
+
// PXE has autoSync disabled by the embedded wallet entrypoints, so we sync once here to cover
|
|
88
|
+
// both the inner simulateTx (via simulateViaEntrypoint) and the proveTx that super.sendTx
|
|
89
|
+
await this.pxe.sync();
|
|
90
|
+
const feeOptions = await this.completeFeeOptions({
|
|
91
|
+
from: opts.from,
|
|
92
|
+
feePayer: executionPayload.feePayer,
|
|
93
|
+
gasSettings: opts.fee?.gasSettings,
|
|
94
|
+
forEstimation: true
|
|
95
|
+
});
|
|
55
96
|
// Simulate the transaction first to estimate gas and capture required
|
|
56
97
|
// private authwitnesses based on offchain effects.
|
|
57
98
|
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
58
99
|
from: opts.from,
|
|
59
100
|
feeOptions,
|
|
60
|
-
|
|
61
|
-
skipTxValidation: true
|
|
101
|
+
additionalScopes: opts.additionalScopes,
|
|
102
|
+
skipTxValidation: true,
|
|
103
|
+
sendMessagesAs: opts.sendMessagesAs
|
|
62
104
|
});
|
|
63
105
|
const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
|
|
64
106
|
const authWitnesses = await Promise.all(offchainEffects.map(async (effect)=>{
|
|
65
107
|
try {
|
|
66
108
|
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
67
|
-
return this.createAuthWit(
|
|
109
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
68
110
|
consumer: effect.contractAddress,
|
|
69
111
|
innerHash: authRequest.innerHash
|
|
70
112
|
});
|
|
@@ -77,7 +119,8 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
77
119
|
executionPayload.authWitnesses.push(authwit);
|
|
78
120
|
}
|
|
79
121
|
}
|
|
80
|
-
const
|
|
122
|
+
const maxTxGasLimits = await this.getMaxTxGasLimits();
|
|
123
|
+
const estimated = getGasLimits(simulationResult.gasUsed, maxTxGasLimits, this.estimatedGasPadding);
|
|
81
124
|
this.log.verbose(`Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`);
|
|
82
125
|
const gasSettings = GasSettings.from({
|
|
83
126
|
...opts.fee?.gasSettings,
|
|
@@ -86,8 +129,24 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
86
129
|
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
87
130
|
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
|
|
88
131
|
});
|
|
132
|
+
let wait = opts.wait;
|
|
133
|
+
if (wait !== NO_WAIT) {
|
|
134
|
+
const callerWaitOpts = typeof wait === 'object' ? wait : {};
|
|
135
|
+
wait = {
|
|
136
|
+
...callerWaitOpts,
|
|
137
|
+
// Default to PROPOSED so the wait returns as soon as the tx lands in a proposed L2 block,
|
|
138
|
+
// rather than waiting until the end of the slot for the checkpoint to be published to L1.
|
|
139
|
+
// This is what makes MBPS (Multiple Blocks Per Slot) actually improve UX: with CHECKPOINTED
|
|
140
|
+
// we'd block until L1 inclusion regardless of how early in the slot the tx was sequenced.
|
|
141
|
+
// The tradeoff is a weaker guarantee — a proposed block only becomes canonical once it (or
|
|
142
|
+
// a later block in the same slot) is checkpointed, so a tx could be re-orged out if the
|
|
143
|
+
// proposer fails to publish to L1 (which should be rare, since they'd get slashed for it).
|
|
144
|
+
waitForStatus: callerWaitOpts.waitForStatus ?? TxStatus.PROPOSED
|
|
145
|
+
};
|
|
146
|
+
}
|
|
89
147
|
return super.sendTx(executionPayload, {
|
|
90
148
|
...opts,
|
|
149
|
+
wait: wait,
|
|
91
150
|
fee: {
|
|
92
151
|
...opts.fee,
|
|
93
152
|
gasSettings
|
|
@@ -95,76 +154,141 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
95
154
|
});
|
|
96
155
|
}
|
|
97
156
|
/**
|
|
157
|
+
* Overrides the base simulateTx to drive PXE syncing explicitly. The PXE created by the embedded
|
|
158
|
+
* wallet has autoSync disabled (so we can share one sync across simulate+send in sendTx); for
|
|
159
|
+
* standalone simulations we still need a fresh anchor block, which we provide here.
|
|
160
|
+
*/ async simulateTx(executionPayload, opts) {
|
|
161
|
+
await this.pxe.sync();
|
|
162
|
+
return super.simulateTx(executionPayload, opts);
|
|
163
|
+
}
|
|
164
|
+
async profileTx(executionPayload, opts) {
|
|
165
|
+
await this.pxe.sync();
|
|
166
|
+
return super.profileTx(executionPayload, opts);
|
|
167
|
+
}
|
|
168
|
+
async executeUtility(call, opts) {
|
|
169
|
+
await this.pxe.sync();
|
|
170
|
+
return super.executeUtility(call, opts);
|
|
171
|
+
}
|
|
172
|
+
async getPrivateEvents(eventDef, eventFilter) {
|
|
173
|
+
await this.pxe.sync();
|
|
174
|
+
return super.getPrivateEvents(eventDef, eventFilter);
|
|
175
|
+
}
|
|
176
|
+
async registerContract(instance, artifact, secretKey) {
|
|
177
|
+
// registerContract may call pxe.updateContract under the hood, which depends on a fresh anchor
|
|
178
|
+
// block to verify the current class id from the node.
|
|
179
|
+
await this.pxe.sync();
|
|
180
|
+
return super.registerContract(instance, artifact, secretKey);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
184
|
+
* stubClassIds. Called on wallet initialization.
|
|
185
|
+
*/ async initStubClasses() {
|
|
186
|
+
const schnorrArtifact = await this.accountContracts.getStubAccountContractArtifact('schnorr');
|
|
187
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(schnorrArtifact);
|
|
188
|
+
await this.pxe.registerContractClass(schnorrArtifact);
|
|
189
|
+
// ecdsa stubs share the same class id
|
|
190
|
+
const ecdsaArtifact = await this.accountContracts.getStubAccountContractArtifact('ecdsasecp256r1');
|
|
191
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(ecdsaArtifact);
|
|
192
|
+
await this.pxe.registerContractClass(ecdsaArtifact);
|
|
193
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
194
|
+
this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
|
|
195
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
196
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
200
|
+
* Uses a type-specific stub artifact so that the stub's constructor selector matches the real account's constructor.
|
|
201
|
+
*/ async buildAccountOverrides(addresses) {
|
|
202
|
+
const accounts = await this.getAccounts();
|
|
203
|
+
const contracts = {};
|
|
204
|
+
const filtered = accounts.filter((acc)=>addresses.some((addr)=>addr.equals(acc.item)));
|
|
205
|
+
for (const account of filtered){
|
|
206
|
+
const address = account.item;
|
|
207
|
+
const { type } = await this.walletDB.retrieveAccount(address);
|
|
208
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
209
|
+
if (!stubClassId) {
|
|
210
|
+
throw new Error(`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`);
|
|
211
|
+
}
|
|
212
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
213
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
214
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
215
|
+
if (!contractInstance) {
|
|
216
|
+
throw new Error(`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`);
|
|
217
|
+
}
|
|
218
|
+
contracts[address.toString()] = {
|
|
219
|
+
instance: {
|
|
220
|
+
...contractInstance,
|
|
221
|
+
currentContractClassId: stubClassId
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return contracts;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
98
228
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
99
229
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
100
230
|
* private kernel circuit execution.
|
|
101
231
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
102
|
-
const { from, feeOptions,
|
|
103
|
-
|
|
104
|
-
let fromAccount;
|
|
105
|
-
if (!from.equals(AztecAddress.ZERO)) {
|
|
106
|
-
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
107
|
-
fromAccount = account;
|
|
108
|
-
overrides = {
|
|
109
|
-
contracts: {
|
|
110
|
-
[from.toString()]: {
|
|
111
|
-
instance,
|
|
112
|
-
artifact
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
} else {
|
|
117
|
-
fromAccount = await this.getAccountFromAddress(from);
|
|
118
|
-
}
|
|
232
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
|
|
233
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
119
234
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
120
|
-
const executionOptions = {
|
|
121
|
-
txNonce: Fr.random(),
|
|
122
|
-
cancellable: this.cancellableTransactions,
|
|
123
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
124
|
-
};
|
|
125
235
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
126
236
|
feeExecutionPayload,
|
|
127
237
|
executionPayload
|
|
128
238
|
]) : executionPayload;
|
|
129
239
|
const chainInfo = await this.getChainInfo();
|
|
130
|
-
const
|
|
131
|
-
|
|
240
|
+
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
241
|
+
const overrides = new SimulationOverrides({
|
|
242
|
+
contracts: accountOverrides
|
|
243
|
+
});
|
|
244
|
+
let txRequest;
|
|
245
|
+
if (from === NO_FROM) {
|
|
246
|
+
const entrypoint = new DefaultEntrypoint();
|
|
247
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
248
|
+
} else {
|
|
249
|
+
const { type } = await this.walletDB.retrieveAccount(from);
|
|
250
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
251
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
252
|
+
const account = await this.accountContracts.createStubAccount(completeAddress, type);
|
|
253
|
+
const executionOptions = {
|
|
254
|
+
txNonce: Fr.random(),
|
|
255
|
+
cancellable: this.cancellableTransactions,
|
|
256
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
257
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
258
|
+
};
|
|
259
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
260
|
+
}
|
|
261
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
132
262
|
simulatePublic: true,
|
|
133
263
|
skipFeeEnforcement,
|
|
134
264
|
skipTxValidation,
|
|
135
265
|
overrides,
|
|
136
|
-
scopes
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
async getFakeAccountDataFor(address) {
|
|
140
|
-
const originalAccount = await this.getAccountFromAddress(address);
|
|
141
|
-
if (originalAccount instanceof SignerlessAccount) {
|
|
142
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
143
|
-
}
|
|
144
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
145
|
-
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
146
|
-
if (!contractInstance) {
|
|
147
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
148
|
-
}
|
|
149
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
150
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
151
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
152
|
-
salt: Fr.random()
|
|
266
|
+
scopes,
|
|
267
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
153
268
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
instance,
|
|
157
|
-
artifact: stubArtifact
|
|
158
|
-
};
|
|
269
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
270
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
159
271
|
}
|
|
160
272
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
161
273
|
let contract;
|
|
274
|
+
let immutablesHash;
|
|
275
|
+
let publicKey;
|
|
162
276
|
switch(type){
|
|
163
277
|
case 'schnorr':
|
|
164
278
|
{
|
|
165
279
|
contract = await this.accountContracts.getSchnorrAccountContract(Fq.fromBuffer(signingKey));
|
|
166
280
|
break;
|
|
167
281
|
}
|
|
282
|
+
case 'schnorr_initializerless':
|
|
283
|
+
{
|
|
284
|
+
contract = await this.accountContracts.getSchnorrInitializerlessAccountContract(Fq.fromBuffer(signingKey));
|
|
285
|
+
publicKey = await new Schnorr().computePublicKey(Fq.fromBuffer(signingKey));
|
|
286
|
+
immutablesHash = await poseidon2Hash([
|
|
287
|
+
publicKey.x,
|
|
288
|
+
publicKey.y
|
|
289
|
+
]);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
168
292
|
case 'ecdsasecp256k1':
|
|
169
293
|
{
|
|
170
294
|
contract = await this.accountContracts.getEcdsaKAccountContract(signingKey);
|
|
@@ -180,12 +304,29 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
180
304
|
throw new Error(`Unknown account type ${type}`);
|
|
181
305
|
}
|
|
182
306
|
}
|
|
183
|
-
const accountManager = await AccountManager.create(this, secret, contract,
|
|
307
|
+
const accountManager = await AccountManager.create(this, secret, contract, {
|
|
308
|
+
salt,
|
|
309
|
+
immutablesHash
|
|
310
|
+
});
|
|
184
311
|
const instance = accountManager.getInstance();
|
|
185
312
|
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
186
313
|
if (!existingInstance) {
|
|
187
314
|
const existingArtifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
315
|
+
const artifact = existingArtifact ?? await accountManager.getAccountContract().getContractArtifact();
|
|
188
316
|
await this.registerContract(instance, !existingArtifact ? await accountManager.getAccountContract().getContractArtifact() : undefined, accountManager.getSecretKey());
|
|
317
|
+
if (type === 'schnorr_initializerless') {
|
|
318
|
+
const constructor = artifact.functions.find((f)=>f.name === 'constructor');
|
|
319
|
+
if (!constructor) {
|
|
320
|
+
throw new Error('Could not create SchnorrInitializerlessAccountContract: constructor ABI not found');
|
|
321
|
+
}
|
|
322
|
+
const storeCall = new ContractFunctionInteraction(this, instance.address, constructor, [
|
|
323
|
+
publicKey.x,
|
|
324
|
+
publicKey.y
|
|
325
|
+
]);
|
|
326
|
+
await storeCall.simulate({
|
|
327
|
+
from: instance.address
|
|
328
|
+
});
|
|
329
|
+
}
|
|
189
330
|
}
|
|
190
331
|
return accountManager;
|
|
191
332
|
}
|
|
@@ -204,6 +345,10 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
204
345
|
const sk = signingKey ?? deriveSigningKey(secret);
|
|
205
346
|
return this.createAndStoreAccount(alias ?? '', 'schnorr', secret, salt, sk.toBuffer());
|
|
206
347
|
}
|
|
348
|
+
createSchnorrInitializerlessAccount(secret, salt, signingKey, alias) {
|
|
349
|
+
const sk = signingKey ?? deriveSigningKey(secret);
|
|
350
|
+
return this.createAndStoreAccount(alias ?? '', 'schnorr_initializerless', secret, salt, sk.toBuffer());
|
|
351
|
+
}
|
|
207
352
|
createECDSARAccount(secret, salt, signingKey, alias) {
|
|
208
353
|
return this.createAndStoreAccount(alias ?? '', 'ecdsasecp256r1', secret, salt, signingKey);
|
|
209
354
|
}
|
|
@@ -216,7 +361,8 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
216
361
|
setEstimatedGasPadding(value) {
|
|
217
362
|
this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
|
|
218
363
|
}
|
|
219
|
-
stop() {
|
|
220
|
-
|
|
364
|
+
async stop() {
|
|
365
|
+
await this.pxe.stop();
|
|
366
|
+
await this.walletDB.close();
|
|
221
367
|
}
|
|
222
368
|
}
|
|
@@ -8,7 +8,7 @@ export declare class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
|
8
8
|
static create<T extends BrowserEmbeddedWallet = BrowserEmbeddedWallet>(this: new (pxe: PXE, aztecNode: AztecNode, walletDB: WalletDB, accountContracts: AccountContractsProvider, log?: Logger) => T, nodeOrUrl: string | AztecNode, options?: EmbeddedWalletOptions): Promise<T>;
|
|
9
9
|
}
|
|
10
10
|
export { BrowserEmbeddedWallet as EmbeddedWallet };
|
|
11
|
-
export type { EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
11
|
+
export type { EmbeddedWalletOptions, EmbeddedWalletPXEOptions } from '../embedded_wallet.js';
|
|
12
12
|
export { WalletDB } from '../wallet_db.js';
|
|
13
13
|
export type { AccountType } from '../wallet_db.js';
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2VtYmVkZGVkL2VudHJ5cG9pbnRzL2Jyb3dzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUF5QixNQUFNLHNCQUFzQixDQUFDO0FBQzdFLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUVsRSxPQUFPLEVBQUUsS0FBSyxHQUFHLEVBQXNDLE1BQU0sd0JBQXdCLENBQUM7QUFPdEYsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx3Q0FBd0MsQ0FBQztBQUN2RixPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUsscUJBQXFCLEVBQW1CLE1BQU0sdUJBQXVCLENBQUM7QUFDcEcsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBRTNDLHFCQUFhLHFCQUFzQixTQUFRLGNBQWM7SUFDdkQsT0FBYSxNQUFNLENBQUMsQ0FBQyxTQUFTLHFCQUFxQixHQUFHLHFCQUFxQixFQUN6RSxJQUFJLEVBQUUsS0FDSixHQUFHLEVBQUUsR0FBRyxFQUNSLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFFBQVEsRUFBRSxRQUFRLEVBQ2xCLGdCQUFnQixFQUFFLHdCQUF3QixFQUMxQyxHQUFHLENBQUMsRUFBRSxNQUFNLEtBQ1QsQ0FBQyxFQUNOLFNBQVMsRUFBRSxNQUFNLEdBQUcsU0FBUyxFQUM3QixPQUFPLEdBQUUscUJBQTBCLEdBQ2xDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0E0RFo7Q0FDRjtBQUVELE9BQU8sRUFBRSxxQkFBcUIsSUFBSSxjQUFjLEVBQUUsQ0FBQztBQUNuRCxZQUFZLEVBQUUscUJBQXFCLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUM3RixPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDM0MsWUFBWSxFQUFFLFdBQVcsRUFBRSxNQUFNLGlCQUFpQixDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/embedded/entrypoints/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/embedded/entrypoints/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,wBAAwB,CAAC;AAOtF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAmB,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,OAAa,MAAM,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,EACzE,IAAI,EAAE,KACJ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,wBAAwB,EAC1C,GAAG,CAAC,EAAE,MAAM,KACT,CAAC,EACN,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,CAAC,CAAC,CA4DZ;CACF;AAED,OAAO,EAAE,qBAAqB,IAAI,cAAc,EAAE,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -3,40 +3,69 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { createStore, openTmpStore } from '@aztec/kv-store/indexeddb';
|
|
4
4
|
import { createPXE } from '@aztec/pxe/client/lazy';
|
|
5
5
|
import { getPXEConfig } from '@aztec/pxe/config';
|
|
6
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry/lazy';
|
|
7
|
+
import { getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry/lazy';
|
|
8
|
+
import { getStandardMultiCallEntrypoint } from '@aztec/standard-contracts/multi-call-entrypoint/lazy';
|
|
6
9
|
import { LazyAccountContractsProvider } from '../account-contract-providers/lazy.js';
|
|
7
|
-
import { EmbeddedWallet } from '../embedded_wallet.js';
|
|
10
|
+
import { EmbeddedWallet, splitPxeOptions } from '../embedded_wallet.js';
|
|
8
11
|
import { WalletDB } from '../wallet_db.js';
|
|
9
12
|
export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
10
13
|
static async create(nodeOrUrl, options = {}) {
|
|
11
14
|
const rootLogger = options.logger ?? createLogger('embedded-wallet');
|
|
12
15
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
13
16
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
17
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
18
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
19
|
+
const mergedConfigOverrides = {
|
|
20
|
+
...options.pxeConfig,
|
|
21
|
+
...pxeConfigFromPxe
|
|
22
|
+
};
|
|
23
|
+
const mergedCreationOverrides = {
|
|
24
|
+
...options.pxeOptions,
|
|
25
|
+
...pxeCreationFromPxe
|
|
26
|
+
};
|
|
14
27
|
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
15
|
-
proverEnabled:
|
|
28
|
+
proverEnabled: mergedConfigOverrides.proverEnabled,
|
|
16
29
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
17
|
-
|
|
30
|
+
autoSync: false,
|
|
31
|
+
...mergedConfigOverrides
|
|
18
32
|
});
|
|
19
33
|
if (options.ephemeral) {
|
|
20
34
|
delete pxeConfig.dataDirectory;
|
|
21
35
|
}
|
|
22
36
|
const pxeOptions = {
|
|
23
|
-
...
|
|
37
|
+
...mergedCreationOverrides,
|
|
38
|
+
preloadedContractsProvider: mergedCreationOverrides.preloadedContractsProvider ?? {
|
|
39
|
+
getPreloadedContracts: async ()=>[
|
|
40
|
+
await getStandardMultiCallEntrypoint(),
|
|
41
|
+
await getStandardAuthRegistry(),
|
|
42
|
+
await getStandardHandshakeRegistry()
|
|
43
|
+
]
|
|
44
|
+
},
|
|
24
45
|
loggers: {
|
|
25
46
|
store: rootLogger.createChild('pxe:data'),
|
|
26
47
|
pxe: rootLogger.createChild('pxe:service'),
|
|
27
48
|
prover: rootLogger.createChild('pxe:prover'),
|
|
28
|
-
...
|
|
49
|
+
...mergedCreationOverrides.loggers
|
|
29
50
|
}
|
|
30
51
|
};
|
|
31
52
|
const pxe = await createPXE(aztecNode, pxeConfig, pxeOptions);
|
|
32
|
-
const walletDBStore = options.ephemeral ? await openTmpStore(true) : await createStore('wallet_data', {
|
|
53
|
+
const walletDBStore = options.walletDb?.store ?? (options.ephemeral ? await openTmpStore(true) : await createStore('wallet_data', {
|
|
33
54
|
dataDirectory: `wallet_data_${l1Contracts.rollupAddress}`,
|
|
34
55
|
dataStoreMapSizeKb: pxeConfig.dataStoreMapSizeKb,
|
|
35
|
-
l1Contracts
|
|
36
|
-
}, 1, rootLogger.createChild('wallet:data'));
|
|
37
|
-
const walletDB = WalletDB
|
|
38
|
-
|
|
56
|
+
rollupAddress: l1Contracts.rollupAddress
|
|
57
|
+
}, 1, rootLogger.createChild('wallet:data')));
|
|
58
|
+
const walletDB = new WalletDB(walletDBStore, rootLogger.createChild('wallet:db').info);
|
|
59
|
+
const wallet = new this(pxe, aztecNode, walletDB, new LazyAccountContractsProvider(), rootLogger);
|
|
60
|
+
await wallet.initStubClasses();
|
|
61
|
+
return wallet;
|
|
39
62
|
}
|
|
40
63
|
}
|
|
41
64
|
export { BrowserEmbeddedWallet as EmbeddedWallet };
|
|
42
65
|
export { WalletDB } from '../wallet_db.js';
|
|
66
|
+
// At-rest encryption helpers are intentionally NOT re-exported here. They live
|
|
67
|
+
// on the `@aztec/wallets/embedded/store-encryption` sub-path so consumers
|
|
68
|
+
// (and bundlers) of this entrypoint don't transitively pull in
|
|
69
|
+
// `@aztec/kv-store/sqlite-opfs` and its `new Worker(new URL('./worker.js'))`
|
|
70
|
+
// chain into `@aztec/sqlite3mc-wasm`. Apps that don't use encryption-at-rest
|
|
71
|
+
// (e.g. the playground) should never see sqlite-opfs in their bundle.
|
|
@@ -8,7 +8,7 @@ export declare class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
|
8
8
|
static create<T extends NodeEmbeddedWallet = NodeEmbeddedWallet>(this: new (pxe: PXE, aztecNode: AztecNode, walletDB: WalletDB, accountContracts: AccountContractsProvider, log?: Logger) => T, nodeOrUrl: string | AztecNode, options?: EmbeddedWalletOptions): Promise<T>;
|
|
9
9
|
}
|
|
10
10
|
export { NodeEmbeddedWallet as EmbeddedWallet };
|
|
11
|
-
export type { EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
11
|
+
export type { EmbeddedWalletOptions, EmbeddedWalletPXEOptions } from '../embedded_wallet.js';
|
|
12
12
|
export { WalletDB } from '../wallet_db.js';
|
|
13
13
|
export type { AccountType } from '../wallet_db.js';
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2VtYmVkZGVkL2VudHJ5cG9pbnRzL25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBR2xFLE9BQU8sRUFBRSxLQUFLLEdBQUcsRUFBc0MsTUFBTSxtQkFBbUIsQ0FBQztBQUlqRixPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHdDQUF3QyxDQUFDO0FBQ3ZGLE9BQU8sRUFBRSxjQUFjLEVBQUUsS0FBSyxxQkFBcUIsRUFBbUIsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFM0MscUJBQWEsa0JBQW1CLFNBQVEsY0FBYztJQUNwRCxPQUFhLE1BQU0sQ0FBQyxDQUFDLFNBQVMsa0JBQWtCLEdBQUcsa0JBQWtCLEVBQ25FLElBQUksRUFBRSxLQUNKLEdBQUcsRUFBRSxHQUFHLEVBQ1IsU0FBUyxFQUFFLFNBQVMsRUFDcEIsUUFBUSxFQUFFLFFBQVEsRUFDbEIsZ0JBQWdCLEVBQUUsd0JBQXdCLEVBQzFDLEdBQUcsQ0FBQyxFQUFFLE1BQU0sS0FDVCxDQUFDLEVBQ04sU0FBUyxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQzdCLE9BQU8sR0FBRSxxQkFBMEIsR0FDbEMsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQWtFWjtDQUNGO0FBRUQsT0FBTyxFQUFFLGtCQUFrQixJQUFJLGNBQWMsRUFBRSxDQUFDO0FBQ2hELFlBQVksRUFBRSxxQkFBcUIsRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzdGLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzQyxZQUFZLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBQWlCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/embedded/entrypoints/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/embedded/entrypoints/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,mBAAmB,CAAC;AAIjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAmB,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,OAAa,MAAM,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EACnE,IAAI,EAAE,KACJ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,wBAAwB,EAC1C,GAAG,CAAC,EAAE,MAAM,KACT,CAAC,EACN,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,CAAC,CAAC,CAkEZ;CACF;AAED,OAAO,EAAE,kBAAkB,IAAI,cAAc,EAAE,CAAC;AAChD,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -3,39 +3,62 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { createStore, openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
4
4
|
import { getPXEConfig } from '@aztec/pxe/config';
|
|
5
5
|
import { createPXE } from '@aztec/pxe/server';
|
|
6
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
7
|
+
import { getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry';
|
|
8
|
+
import { getStandardMultiCallEntrypoint } from '@aztec/standard-contracts/multi-call-entrypoint';
|
|
6
9
|
import { BundleAccountContractsProvider } from '../account-contract-providers/bundle.js';
|
|
7
|
-
import { EmbeddedWallet } from '../embedded_wallet.js';
|
|
10
|
+
import { EmbeddedWallet, splitPxeOptions } from '../embedded_wallet.js';
|
|
8
11
|
import { WalletDB } from '../wallet_db.js';
|
|
9
12
|
export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
10
13
|
static async create(nodeOrUrl, options = {}) {
|
|
11
14
|
const rootLogger = options.logger ?? createLogger('embedded-wallet');
|
|
12
15
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
13
16
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
17
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
18
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
19
|
+
const mergedConfigOverrides = {
|
|
20
|
+
...options.pxeConfig,
|
|
21
|
+
...pxeConfigFromPxe
|
|
22
|
+
};
|
|
23
|
+
const mergedCreationOverrides = {
|
|
24
|
+
...options.pxeOptions,
|
|
25
|
+
...pxeCreationFromPxe
|
|
26
|
+
};
|
|
14
27
|
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
15
|
-
proverEnabled:
|
|
28
|
+
proverEnabled: mergedConfigOverrides.proverEnabled,
|
|
16
29
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
17
|
-
|
|
30
|
+
autoSync: false,
|
|
31
|
+
...mergedConfigOverrides
|
|
18
32
|
});
|
|
19
33
|
if (options.ephemeral) {
|
|
20
34
|
delete pxeConfig.dataDirectory;
|
|
21
35
|
}
|
|
22
36
|
const pxeOptions = {
|
|
23
|
-
...
|
|
37
|
+
...mergedCreationOverrides,
|
|
38
|
+
preloadedContractsProvider: mergedCreationOverrides.preloadedContractsProvider ?? {
|
|
39
|
+
getPreloadedContracts: async ()=>[
|
|
40
|
+
await getStandardMultiCallEntrypoint(),
|
|
41
|
+
await getStandardAuthRegistry(),
|
|
42
|
+
await getStandardHandshakeRegistry()
|
|
43
|
+
]
|
|
44
|
+
},
|
|
24
45
|
loggers: {
|
|
25
46
|
store: rootLogger.createChild('pxe:data'),
|
|
26
47
|
pxe: rootLogger.createChild('pxe:service'),
|
|
27
48
|
prover: rootLogger.createChild('pxe:prover'),
|
|
28
|
-
...
|
|
49
|
+
...mergedCreationOverrides.loggers
|
|
29
50
|
}
|
|
30
51
|
};
|
|
31
52
|
const pxe = await createPXE(aztecNode, pxeConfig, pxeOptions);
|
|
32
|
-
const walletDBStore = options.ephemeral ? await openTmpStore(`wallet_data_${l1Contracts.rollupAddress}`, true, undefined, undefined, rootLogger.createChild('wallet:data').getBindings()) : await createStore('wallet_data', 1, {
|
|
53
|
+
const walletDBStore = options.walletDb?.store ?? (options.ephemeral ? await openTmpStore(`wallet_data_${l1Contracts.rollupAddress}`, true, undefined, undefined, rootLogger.createChild('wallet:data').getBindings()) : await createStore('wallet_data', 1, {
|
|
33
54
|
dataDirectory: `wallet_data_${l1Contracts.rollupAddress}`,
|
|
34
55
|
dataStoreMapSizeKb: pxeConfig.dataStoreMapSizeKb,
|
|
35
|
-
l1Contracts
|
|
36
|
-
}, rootLogger.createChild('wallet:data').getBindings());
|
|
37
|
-
const walletDB = WalletDB
|
|
38
|
-
|
|
56
|
+
rollupAddress: l1Contracts.rollupAddress
|
|
57
|
+
}, rootLogger.createChild('wallet:data').getBindings()));
|
|
58
|
+
const walletDB = new WalletDB(walletDBStore, rootLogger.createChild('wallet:db').info);
|
|
59
|
+
const wallet = new this(pxe, aztecNode, walletDB, new BundleAccountContractsProvider(), rootLogger);
|
|
60
|
+
await wallet.initStubClasses();
|
|
61
|
+
return wallet;
|
|
39
62
|
}
|
|
40
63
|
}
|
|
41
64
|
export { NodeEmbeddedWallet as EmbeddedWallet };
|