@aztec/wallets 0.0.1-commit.b64cb54f6 → 0.0.1-commit.b8a057fa
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 +63 -10
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +260 -69
- 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 +34 -11
- 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 +332 -78
- package/src/embedded/entrypoints/browser.ts +41 -21
- 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,21 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
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';
|
|
3
8
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
9
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
10
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
6
11
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
7
|
-
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
8
|
-
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
|
+
}
|
|
35
|
+
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
9
36
|
export class EmbeddedWallet extends BaseWallet {
|
|
10
37
|
walletDB;
|
|
11
38
|
accountContracts;
|
|
39
|
+
estimatedGasPadding;
|
|
40
|
+
// Stub class ids, populated on wallet startup
|
|
41
|
+
// to avoid redundant work per simulation
|
|
42
|
+
stubClassIds;
|
|
12
43
|
constructor(pxe, aztecNode, walletDB, accountContracts, log){
|
|
13
|
-
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts;
|
|
44
|
+
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING, this.stubClassIds = new Map();
|
|
14
45
|
}
|
|
15
46
|
async getAccountFromAddress(address) {
|
|
16
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
17
|
-
return new SignerlessAccount();
|
|
18
|
-
}
|
|
19
47
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
20
48
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
21
49
|
const account = await accountManager.getAccount();
|
|
@@ -29,94 +57,232 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
29
57
|
}
|
|
30
58
|
async registerSender(address, alias) {
|
|
31
59
|
await this.walletDB.storeSender(address, alias);
|
|
32
|
-
|
|
60
|
+
await this.pxe.registerTaggingSecretSource({
|
|
61
|
+
kind: 'address-derived',
|
|
62
|
+
sender: address
|
|
63
|
+
});
|
|
64
|
+
return address;
|
|
33
65
|
}
|
|
34
66
|
async getAddressBook() {
|
|
35
|
-
const
|
|
67
|
+
const sources = await this.pxe.getTaggingSecretSources({
|
|
68
|
+
kind: 'address-derived'
|
|
69
|
+
});
|
|
70
|
+
const senders = sources.map((source)=>source.sender);
|
|
36
71
|
const storedSenders = await this.walletDB.listSenders();
|
|
37
72
|
for (const storedSender of storedSenders){
|
|
38
73
|
if (senders.findIndex((sender)=>sender.equals(storedSender.item)) === -1) {
|
|
39
|
-
await this.pxe.
|
|
74
|
+
await this.pxe.registerTaggingSecretSource({
|
|
75
|
+
kind: 'address-derived',
|
|
76
|
+
sender: storedSender.item
|
|
77
|
+
});
|
|
40
78
|
}
|
|
41
79
|
}
|
|
42
80
|
return storedSenders;
|
|
43
81
|
}
|
|
44
82
|
/**
|
|
83
|
+
* Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
|
|
84
|
+
* estimates actual gas usage and captures call authorization requests to generate
|
|
85
|
+
* the necessary authwitnesses.
|
|
86
|
+
*/ async sendTx(executionPayload, opts) {
|
|
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
|
+
});
|
|
96
|
+
// Simulate the transaction first to estimate gas and capture required
|
|
97
|
+
// private authwitnesses based on offchain effects.
|
|
98
|
+
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
99
|
+
from: opts.from,
|
|
100
|
+
feeOptions,
|
|
101
|
+
additionalScopes: opts.additionalScopes,
|
|
102
|
+
skipTxValidation: true,
|
|
103
|
+
sendMessagesAs: opts.sendMessagesAs
|
|
104
|
+
});
|
|
105
|
+
const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
|
|
106
|
+
const authWitnesses = await Promise.all(offchainEffects.map(async (effect)=>{
|
|
107
|
+
try {
|
|
108
|
+
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
109
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
110
|
+
consumer: effect.contractAddress,
|
|
111
|
+
innerHash: authRequest.innerHash
|
|
112
|
+
});
|
|
113
|
+
} catch {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
for (const authwit of authWitnesses){
|
|
118
|
+
if (authwit) {
|
|
119
|
+
executionPayload.authWitnesses.push(authwit);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const maxTxGasLimits = await this.getMaxTxGasLimits();
|
|
123
|
+
const estimated = getGasLimits(simulationResult.gasUsed, maxTxGasLimits, this.estimatedGasPadding);
|
|
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}`);
|
|
125
|
+
const gasSettings = GasSettings.from({
|
|
126
|
+
...opts.fee?.gasSettings,
|
|
127
|
+
maxFeesPerGas: feeOptions.gasSettings.maxFeesPerGas,
|
|
128
|
+
maxPriorityFeesPerGas: feeOptions.gasSettings.maxPriorityFeesPerGas,
|
|
129
|
+
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
130
|
+
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
|
|
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
|
+
}
|
|
147
|
+
return super.sendTx(executionPayload, {
|
|
148
|
+
...opts,
|
|
149
|
+
wait: wait,
|
|
150
|
+
fee: {
|
|
151
|
+
...opts.fee,
|
|
152
|
+
gasSettings
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
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
|
+
/**
|
|
177
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
178
|
+
* stubClassIds. Called on wallet initialization.
|
|
179
|
+
*/ async initStubClasses() {
|
|
180
|
+
const schnorrArtifact = await this.accountContracts.getStubAccountContractArtifact('schnorr');
|
|
181
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(schnorrArtifact);
|
|
182
|
+
await this.pxe.registerContractClass(schnorrArtifact);
|
|
183
|
+
// ecdsa stubs share the same class id
|
|
184
|
+
const ecdsaArtifact = await this.accountContracts.getStubAccountContractArtifact('ecdsasecp256r1');
|
|
185
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(ecdsaArtifact);
|
|
186
|
+
await this.pxe.registerContractClass(ecdsaArtifact);
|
|
187
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
188
|
+
this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
|
|
189
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
190
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
194
|
+
* Uses a type-specific stub artifact so that the stub's constructor selector matches the real account's constructor.
|
|
195
|
+
*/ async buildAccountOverrides(addresses) {
|
|
196
|
+
const accounts = await this.getAccounts();
|
|
197
|
+
const contracts = {};
|
|
198
|
+
const filtered = accounts.filter((acc)=>addresses.some((addr)=>addr.equals(acc.item)));
|
|
199
|
+
for (const account of filtered){
|
|
200
|
+
const address = account.item;
|
|
201
|
+
const { type } = await this.walletDB.retrieveAccount(address);
|
|
202
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
203
|
+
if (!stubClassId) {
|
|
204
|
+
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.`);
|
|
205
|
+
}
|
|
206
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
207
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
208
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
209
|
+
if (!contractInstance) {
|
|
210
|
+
throw new Error(`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`);
|
|
211
|
+
}
|
|
212
|
+
contracts[address.toString()] = {
|
|
213
|
+
instance: {
|
|
214
|
+
...contractInstance,
|
|
215
|
+
currentContractClassId: stubClassId
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
return contracts;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
45
222
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
46
223
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
47
224
|
* private kernel circuit execution.
|
|
48
|
-
*/ async simulateViaEntrypoint(executionPayload,
|
|
49
|
-
const {
|
|
225
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
226
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
|
|
227
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
50
228
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
51
|
-
const executionOptions = {
|
|
52
|
-
txNonce: Fr.random(),
|
|
53
|
-
cancellable: this.cancellableTransactions,
|
|
54
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
55
|
-
};
|
|
56
229
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
57
230
|
feeExecutionPayload,
|
|
58
231
|
executionPayload
|
|
59
232
|
]) : executionPayload;
|
|
60
233
|
const chainInfo = await this.getChainInfo();
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
skipFeeEnforcement: true,
|
|
65
|
-
skipTxValidation: true,
|
|
66
|
-
overrides: {
|
|
67
|
-
contracts: {
|
|
68
|
-
[from.toString()]: {
|
|
69
|
-
instance,
|
|
70
|
-
artifact
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
scopes
|
|
234
|
+
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
235
|
+
const overrides = new SimulationOverrides({
|
|
236
|
+
contracts: accountOverrides
|
|
75
237
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// we need to explicitly handle the zero address case here by
|
|
81
|
-
// returning the actual multicall contract instead of trying to create a stub account for it.
|
|
82
|
-
if (!address.equals(AztecAddress.ZERO)) {
|
|
83
|
-
const originalAccount = await this.getAccountFromAddress(address);
|
|
84
|
-
if (originalAccount instanceof SignerlessAccount) {
|
|
85
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
86
|
-
}
|
|
87
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
88
|
-
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
89
|
-
if (!contractInstance) {
|
|
90
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
91
|
-
}
|
|
92
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
93
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
94
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
95
|
-
salt: Fr.random()
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
account: stubAccount,
|
|
99
|
-
instance,
|
|
100
|
-
artifact: stubArtifact
|
|
101
|
-
};
|
|
238
|
+
let txRequest;
|
|
239
|
+
if (from === NO_FROM) {
|
|
240
|
+
const entrypoint = new DefaultEntrypoint();
|
|
241
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
102
242
|
} else {
|
|
103
|
-
const {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
243
|
+
const { type } = await this.walletDB.retrieveAccount(from);
|
|
244
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
245
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
246
|
+
const account = await this.accountContracts.createStubAccount(completeAddress, type);
|
|
247
|
+
const executionOptions = {
|
|
248
|
+
txNonce: Fr.random(),
|
|
249
|
+
cancellable: this.cancellableTransactions,
|
|
250
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
251
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
109
252
|
};
|
|
253
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
110
254
|
}
|
|
255
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
256
|
+
simulatePublic: true,
|
|
257
|
+
skipFeeEnforcement,
|
|
258
|
+
skipTxValidation,
|
|
259
|
+
overrides,
|
|
260
|
+
scopes,
|
|
261
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
262
|
+
});
|
|
263
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
264
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
111
265
|
}
|
|
112
266
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
113
267
|
let contract;
|
|
268
|
+
let immutablesHash;
|
|
269
|
+
let publicKey;
|
|
114
270
|
switch(type){
|
|
115
271
|
case 'schnorr':
|
|
116
272
|
{
|
|
117
273
|
contract = await this.accountContracts.getSchnorrAccountContract(Fq.fromBuffer(signingKey));
|
|
118
274
|
break;
|
|
119
275
|
}
|
|
276
|
+
case 'schnorr_initializerless':
|
|
277
|
+
{
|
|
278
|
+
contract = await this.accountContracts.getSchnorrInitializerlessAccountContract(Fq.fromBuffer(signingKey));
|
|
279
|
+
publicKey = await new Schnorr().computePublicKey(Fq.fromBuffer(signingKey));
|
|
280
|
+
immutablesHash = await poseidon2Hash([
|
|
281
|
+
publicKey.x,
|
|
282
|
+
publicKey.y
|
|
283
|
+
]);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
120
286
|
case 'ecdsasecp256k1':
|
|
121
287
|
{
|
|
122
288
|
contract = await this.accountContracts.getEcdsaKAccountContract(signingKey);
|
|
@@ -132,12 +298,29 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
132
298
|
throw new Error(`Unknown account type ${type}`);
|
|
133
299
|
}
|
|
134
300
|
}
|
|
135
|
-
const accountManager = await AccountManager.create(this, secret, contract,
|
|
301
|
+
const accountManager = await AccountManager.create(this, secret, contract, {
|
|
302
|
+
salt,
|
|
303
|
+
immutablesHash
|
|
304
|
+
});
|
|
136
305
|
const instance = accountManager.getInstance();
|
|
137
306
|
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
138
307
|
if (!existingInstance) {
|
|
139
308
|
const existingArtifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
309
|
+
const artifact = existingArtifact ?? await accountManager.getAccountContract().getContractArtifact();
|
|
140
310
|
await this.registerContract(instance, !existingArtifact ? await accountManager.getAccountContract().getContractArtifact() : undefined, accountManager.getSecretKey());
|
|
311
|
+
if (type === 'schnorr_initializerless') {
|
|
312
|
+
const constructor = artifact.functions.find((f)=>f.name === 'constructor');
|
|
313
|
+
if (!constructor) {
|
|
314
|
+
throw new Error('Could not create SchnorrInitializerlessAccountContract: constructor ABI not found');
|
|
315
|
+
}
|
|
316
|
+
const storeCall = new ContractFunctionInteraction(this, instance.address, constructor, [
|
|
317
|
+
publicKey.x,
|
|
318
|
+
publicKey.y
|
|
319
|
+
]);
|
|
320
|
+
await storeCall.simulate({
|
|
321
|
+
from: instance.address
|
|
322
|
+
});
|
|
323
|
+
}
|
|
141
324
|
}
|
|
142
325
|
return accountManager;
|
|
143
326
|
}
|
|
@@ -156,6 +339,10 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
156
339
|
const sk = signingKey ?? deriveSigningKey(secret);
|
|
157
340
|
return this.createAndStoreAccount(alias ?? '', 'schnorr', secret, salt, sk.toBuffer());
|
|
158
341
|
}
|
|
342
|
+
createSchnorrInitializerlessAccount(secret, salt, signingKey, alias) {
|
|
343
|
+
const sk = signingKey ?? deriveSigningKey(secret);
|
|
344
|
+
return this.createAndStoreAccount(alias ?? '', 'schnorr_initializerless', secret, salt, sk.toBuffer());
|
|
345
|
+
}
|
|
159
346
|
createECDSARAccount(secret, salt, signingKey, alias) {
|
|
160
347
|
return this.createAndStoreAccount(alias ?? '', 'ecdsasecp256r1', secret, salt, signingKey);
|
|
161
348
|
}
|
|
@@ -165,7 +352,11 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
165
352
|
setMinFeePadding(value) {
|
|
166
353
|
this.minFeePadding = value ?? 0.5;
|
|
167
354
|
}
|
|
168
|
-
|
|
169
|
-
|
|
355
|
+
setEstimatedGasPadding(value) {
|
|
356
|
+
this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
|
|
357
|
+
}
|
|
358
|
+
async stop() {
|
|
359
|
+
await this.pxe.stop();
|
|
360
|
+
await this.walletDB.close();
|
|
170
361
|
}
|
|
171
362
|
}
|
|
@@ -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"}
|
|
@@ -1,41 +1,64 @@
|
|
|
1
1
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { createStore, openTmpStore } from '@aztec/kv-store/
|
|
3
|
+
import { createStore, openTmpStore } from '@aztec/kv-store/sqlite-opfs';
|
|
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 };
|
|
@@ -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 };
|