@aztec/wallets 0.0.1-commit.9ee6fcc6 → 0.0.1-commit.a4600f49
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 +52 -8
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +208 -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 +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 +260 -75
- 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,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,135 @@ 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
|
+
/**
|
|
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
|
+
/**
|
|
98
222
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
99
223
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
100
224
|
* private kernel circuit execution.
|
|
101
225
|
*/ 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
|
-
}
|
|
226
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
|
|
227
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
119
228
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
120
|
-
const executionOptions = {
|
|
121
|
-
txNonce: Fr.random(),
|
|
122
|
-
cancellable: this.cancellableTransactions,
|
|
123
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
124
|
-
};
|
|
125
229
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
126
230
|
feeExecutionPayload,
|
|
127
231
|
executionPayload
|
|
128
232
|
]) : executionPayload;
|
|
129
233
|
const chainInfo = await this.getChainInfo();
|
|
130
|
-
const
|
|
131
|
-
|
|
234
|
+
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
235
|
+
const overrides = new SimulationOverrides({
|
|
236
|
+
contracts: accountOverrides
|
|
237
|
+
});
|
|
238
|
+
let txRequest;
|
|
239
|
+
if (from === NO_FROM) {
|
|
240
|
+
const entrypoint = new DefaultEntrypoint();
|
|
241
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
242
|
+
} else {
|
|
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
|
|
252
|
+
};
|
|
253
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
254
|
+
}
|
|
255
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
132
256
|
simulatePublic: true,
|
|
133
257
|
skipFeeEnforcement,
|
|
134
258
|
skipTxValidation,
|
|
135
259
|
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()
|
|
260
|
+
scopes,
|
|
261
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
153
262
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
instance,
|
|
157
|
-
artifact: stubArtifact
|
|
158
|
-
};
|
|
263
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
264
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
159
265
|
}
|
|
160
266
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
161
267
|
let contract;
|
|
268
|
+
let immutablesHash;
|
|
269
|
+
let publicKey;
|
|
162
270
|
switch(type){
|
|
163
271
|
case 'schnorr':
|
|
164
272
|
{
|
|
165
273
|
contract = await this.accountContracts.getSchnorrAccountContract(Fq.fromBuffer(signingKey));
|
|
166
274
|
break;
|
|
167
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
|
+
}
|
|
168
286
|
case 'ecdsasecp256k1':
|
|
169
287
|
{
|
|
170
288
|
contract = await this.accountContracts.getEcdsaKAccountContract(signingKey);
|
|
@@ -180,12 +298,29 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
180
298
|
throw new Error(`Unknown account type ${type}`);
|
|
181
299
|
}
|
|
182
300
|
}
|
|
183
|
-
const accountManager = await AccountManager.create(this, secret, contract,
|
|
301
|
+
const accountManager = await AccountManager.create(this, secret, contract, {
|
|
302
|
+
salt,
|
|
303
|
+
immutablesHash
|
|
304
|
+
});
|
|
184
305
|
const instance = accountManager.getInstance();
|
|
185
306
|
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
186
307
|
if (!existingInstance) {
|
|
187
308
|
const existingArtifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
309
|
+
const artifact = existingArtifact ?? await accountManager.getAccountContract().getContractArtifact();
|
|
188
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
|
+
}
|
|
189
324
|
}
|
|
190
325
|
return accountManager;
|
|
191
326
|
}
|
|
@@ -204,6 +339,10 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
204
339
|
const sk = signingKey ?? deriveSigningKey(secret);
|
|
205
340
|
return this.createAndStoreAccount(alias ?? '', 'schnorr', secret, salt, sk.toBuffer());
|
|
206
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
|
+
}
|
|
207
346
|
createECDSARAccount(secret, salt, signingKey, alias) {
|
|
208
347
|
return this.createAndStoreAccount(alias ?? '', 'ecdsasecp256r1', secret, salt, signingKey);
|
|
209
348
|
}
|
|
@@ -216,7 +355,8 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
216
355
|
setEstimatedGasPadding(value) {
|
|
217
356
|
this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
|
|
218
357
|
}
|
|
219
|
-
stop() {
|
|
220
|
-
|
|
358
|
+
async stop() {
|
|
359
|
+
await this.pxe.stop();
|
|
360
|
+
await this.walletDB.close();
|
|
221
361
|
}
|
|
222
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 };
|