@aztec/wallets 0.0.1-commit.9ee6fcc6 → 0.0.1-commit.a89ec08
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 +4 -3
- package/dest/embedded/account-contract-providers/bundle.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/bundle.js +6 -5
- package/dest/embedded/account-contract-providers/lazy.d.ts +4 -3
- package/dest/embedded/account-contract-providers/lazy.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/lazy.js +16 -6
- package/dest/embedded/account-contract-providers/types.d.ts +4 -3
- package/dest/embedded/account-contract-providers/types.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.d.ts +26 -7
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +101 -55
- 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 +15 -5
- 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 +15 -5
- package/dest/testing.d.ts +1 -1
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +2 -2
- package/package.json +15 -15
- package/src/embedded/account-contract-providers/bundle.ts +7 -5
- package/src/embedded/account-contract-providers/lazy.ts +17 -6
- package/src/embedded/account-contract-providers/types.ts +4 -2
- package/src/embedded/embedded_wallet.ts +124 -65
- package/src/embedded/entrypoints/browser.ts +11 -6
- package/src/embedded/entrypoints/node.ts +11 -6
- package/src/testing.ts +2 -1
|
@@ -2,6 +2,7 @@ import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { AccountType } from '../wallet_db.js';
|
|
5
6
|
import type { AccountContractsProvider } from './types.js';
|
|
6
7
|
/**
|
|
7
8
|
* Loads account contract artifacts eagerly via static imports.
|
|
@@ -11,11 +12,11 @@ export declare class BundleAccountContractsProvider implements AccountContractsP
|
|
|
11
12
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
12
13
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
13
14
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
14
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact>;
|
|
15
|
-
createStubAccount(address: CompleteAddress): Promise<Account>;
|
|
15
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
16
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account>;
|
|
16
17
|
getMulticallContract(): Promise<{
|
|
17
18
|
instance: ContractInstanceWithAddress;
|
|
18
19
|
artifact: ContractArtifact;
|
|
19
20
|
}>;
|
|
20
21
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZW1iZWRkZWQvYWNjb3VudC1jb250cmFjdC1wcm92aWRlcnMvYnVuZGxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUV6RCxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTNGLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRTNEOzs7R0FHRztBQUNILHFCQUFhLDhCQUErQixZQUFXLHdCQUF3QjtJQUM3RSx5QkFBeUIsQ0FBQyxVQUFVLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FFbEU7SUFFRCx3QkFBd0IsQ0FBQyxVQUFVLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FFckU7SUFFRCx3QkFBd0IsQ0FBQyxVQUFVLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FFckU7SUFFRCw4QkFBOEIsQ0FBQyxJQUFJLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUUzRTtJQUVELGlCQUFpQixDQUFDLE9BQU8sRUFBRSxlQUFlLEVBQUUsSUFBSSxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBRS9FO0lBRUQsb0JBQW9CLElBQUksT0FBTyxDQUFDO1FBQUUsUUFBUSxFQUFFLDJCQUEyQixDQUFDO1FBQUMsUUFBUSxFQUFFLGdCQUFnQixDQUFBO0tBQUUsQ0FBQyxDQUVyRztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/embedded/account-contract-providers/bundle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/embedded/account-contract-providers/bundle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,wBAAwB;IAC7E,yBAAyB,CAAC,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAElE;IAED,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAErE;IAED,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAErE;IAED,8BAA8B,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE3E;IAED,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/E;IAED,oBAAoB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,2BAA2B,CAAC;QAAC,QAAQ,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAErG;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
-
import {
|
|
3
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
4
5
|
import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi-call-entrypoint';
|
|
5
6
|
/**
|
|
6
7
|
* Loads account contract artifacts eagerly via static imports.
|
|
@@ -15,11 +16,11 @@ import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi
|
|
|
15
16
|
getEcdsaKAccountContract(signingKey) {
|
|
16
17
|
return Promise.resolve(new EcdsaKAccountContract(signingKey));
|
|
17
18
|
}
|
|
18
|
-
getStubAccountContractArtifact() {
|
|
19
|
-
return Promise.resolve(
|
|
19
|
+
getStubAccountContractArtifact(type) {
|
|
20
|
+
return Promise.resolve(type === 'schnorr' ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact);
|
|
20
21
|
}
|
|
21
|
-
createStubAccount(address) {
|
|
22
|
-
return Promise.resolve(
|
|
22
|
+
createStubAccount(address, type) {
|
|
23
|
+
return Promise.resolve(type === 'schnorr' ? createStubSchnorrAccount(address) : createStubEcdsaAccount(address));
|
|
23
24
|
}
|
|
24
25
|
getMulticallContract() {
|
|
25
26
|
return getCanonicalMultiCallEntrypoint();
|
|
@@ -2,6 +2,7 @@ import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { AccountType } from '../wallet_db.js';
|
|
5
6
|
import type { AccountContractsProvider } from './types.js';
|
|
6
7
|
/**
|
|
7
8
|
* Loads account contract artifacts lazily via dynamic imports.
|
|
@@ -11,11 +12,11 @@ export declare class LazyAccountContractsProvider implements AccountContractsPro
|
|
|
11
12
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
12
13
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
13
14
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
14
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact>;
|
|
15
|
-
createStubAccount(address: CompleteAddress): Promise<Account>;
|
|
15
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
16
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account>;
|
|
16
17
|
getMulticallContract(): Promise<{
|
|
17
18
|
instance: ContractInstanceWithAddress;
|
|
18
19
|
artifact: ContractArtifact;
|
|
19
20
|
}>;
|
|
20
21
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2VtYmVkZGVkL2FjY291bnQtY29udHJhY3QtcHJvdmlkZXJzL2xhenkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXpELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLDJCQUEyQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFM0YsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDbkQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFFM0Q7OztHQUdHO0FBQ0gscUJBQWEsNEJBQTZCLFlBQVcsd0JBQXdCO0lBQ3JFLHlCQUF5QixDQUFDLFVBQVUsRUFBRSxFQUFFLEdBQUcs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import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi
|
|
|
15
15
|
const { EcdsaKAccountContract } = await import('@aztec/accounts/ecdsa/lazy');
|
|
16
16
|
return new EcdsaKAccountContract(signingKey);
|
|
17
17
|
}
|
|
18
|
-
async getStubAccountContractArtifact() {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
async getStubAccountContractArtifact(type) {
|
|
19
|
+
if (type === 'schnorr') {
|
|
20
|
+
const { getStubSchnorrAccountContractArtifact } = await import('@aztec/accounts/stub/schnorr/lazy');
|
|
21
|
+
return getStubSchnorrAccountContractArtifact();
|
|
22
|
+
} else {
|
|
23
|
+
const { getStubEcdsaAccountContractArtifact } = await import('@aztec/accounts/stub/ecdsa/lazy');
|
|
24
|
+
return getStubEcdsaAccountContractArtifact();
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
|
-
async createStubAccount(address) {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
async createStubAccount(address, type) {
|
|
28
|
+
if (type === 'schnorr') {
|
|
29
|
+
const { createStubSchnorrAccount } = await import('@aztec/accounts/stub/schnorr/lazy');
|
|
30
|
+
return createStubSchnorrAccount(address);
|
|
31
|
+
} else {
|
|
32
|
+
const { createStubEcdsaAccount } = await import('@aztec/accounts/stub/ecdsa/lazy');
|
|
33
|
+
return createStubEcdsaAccount(address);
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
getMulticallContract() {
|
|
27
37
|
return getCanonicalMultiCallEntrypoint();
|
|
@@ -2,6 +2,7 @@ import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { AccountType } from '../wallet_db.js';
|
|
5
6
|
/**
|
|
6
7
|
* Provides account contract implementations and stub accounts for the EmbeddedWallet.
|
|
7
8
|
* Two implementations exist:
|
|
@@ -12,11 +13,11 @@ export interface AccountContractsProvider {
|
|
|
12
13
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
13
14
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
14
15
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
15
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact>;
|
|
16
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
16
17
|
getMulticallContract(): Promise<{
|
|
17
18
|
instance: ContractInstanceWithAddress;
|
|
18
19
|
artifact: ContractArtifact;
|
|
19
20
|
}>;
|
|
20
|
-
createStubAccount(address: CompleteAddress): Promise<Account>;
|
|
21
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account>;
|
|
21
22
|
}
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9lbWJlZGRlZC9hY2NvdW50LWNvbnRyYWN0LXByb3ZpZGVycy90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUUzRixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTS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
|
import { type Account } from '@aztec/aztec.js/account';
|
|
2
2
|
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
|
|
4
|
-
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AccountManager, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import type { Logger } from '@aztec/foundation/log';
|
|
7
7
|
import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
8
8
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
-
import {
|
|
11
|
+
import { type ContractOverrides, ExecutionPayload } from '@aztec/stdlib/tx';
|
|
12
12
|
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
13
13
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
14
14
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
15
|
+
/** Options for the PXE instance created by the EmbeddedWallet. */
|
|
16
|
+
export type EmbeddedWalletPXEOptions = Partial<PXEConfig> & PXECreationOptions;
|
|
17
|
+
/** Splits a unified EmbeddedWalletPXEOptions into PXEConfig overrides and PXECreationOptions. */
|
|
18
|
+
export declare function splitPxeOptions(pxe?: EmbeddedWalletPXEOptions): {
|
|
19
|
+
config: Partial<PXEConfig>;
|
|
20
|
+
creation: PXECreationOptions;
|
|
21
|
+
};
|
|
15
22
|
export type EmbeddedWalletOptions = {
|
|
16
23
|
/** Parent logger. Child loggers are derived via createChild() for each subsystem. */
|
|
17
24
|
logger?: Logger;
|
|
18
25
|
/** Use ephemeral (in-memory) stores. Data will not persist across sessions. */
|
|
19
26
|
ephemeral?: boolean;
|
|
20
|
-
/**
|
|
27
|
+
/** PXE configuration and dependency overrides (custom store, prover, simulator). */
|
|
28
|
+
pxe?: EmbeddedWalletPXEOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Override PXE configuration.
|
|
31
|
+
* @deprecated Use `pxe` instead.
|
|
32
|
+
*/
|
|
21
33
|
pxeConfig?: Partial<PXEConfig>;
|
|
22
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Advanced PXE creation options (custom store, prover, simulator).
|
|
36
|
+
* @deprecated Use `pxe` instead.
|
|
37
|
+
*/
|
|
23
38
|
pxeOptions?: PXECreationOptions;
|
|
24
39
|
};
|
|
25
40
|
export declare class EmbeddedWallet extends BaseWallet {
|
|
@@ -37,13 +52,17 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
37
52
|
* the necessary authwitnesses.
|
|
38
53
|
*/
|
|
39
54
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
55
|
+
/**
|
|
56
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
57
|
+
* Uses a type-specific stub artifact so that the stub's constructor selector matches the real account's constructor.
|
|
58
|
+
*/
|
|
59
|
+
protected buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides>;
|
|
40
60
|
/**
|
|
41
61
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
42
62
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
43
63
|
* private kernel circuit execution.
|
|
44
64
|
*/
|
|
45
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<
|
|
46
|
-
private getFakeAccountDataFor;
|
|
65
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
47
66
|
protected createAccountInternal(type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
48
67
|
createAndStoreAccount(alias: string, type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
49
68
|
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq, alias?: string): Promise<AccountManager>;
|
|
@@ -53,4 +72,4 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
53
72
|
setEstimatedGasPadding(value?: number): void;
|
|
54
73
|
stop(): Promise<void>;
|
|
55
74
|
}
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
75
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1iZWRkZWRfd2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvZW1iZWRkZWRfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBVyxNQUFNLHlCQUF5QixDQUFDO0FBRWhFLE9BQU8sRUFBRSxLQUFLLHNCQUFzQixFQUFFLEtBQUssVUFBVSxFQUErQixNQUFNLDJCQUEyQixDQUFDO0FBQ3RILE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUNuRSxPQUFPLEVBQUUsY0FBYyxFQUFFLCtCQUErQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHekYsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1RSxPQUFPLEtBQUssRUFBRSxHQUFHLEVBQUUsTUFBTS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sT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUVyRztJQUVELGdCQUFnQixDQUFDLEtBQUssQ0FBQyxFQUFFLE1BQU0sUUFFOUI7SUFFRCxzQkFBc0IsQ0FBQyxLQUFLLENBQUMsRUFBRSxNQUFNLFFBRXBDO0lBRUQsSUFBSSxrQkFFSDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded_wallet.d.ts","sourceRoot":"","sources":["../../src/embedded/embedded_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"embedded_wallet.d.ts","sourceRoot":"","sources":["../../src/embedded/embedded_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,UAAU,EAA+B,MAAM,2BAA2B,CAAC;AACtH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzF,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EACL,KAAK,iBAAiB,EACtB,gBAAgB,EAMjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,KAAK,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AA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AAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAErG;IAED,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAE9B;IAED,sBAAsB,CAAC,KAAK,CAAC,EAAE,MAAM,QAEpC;IAED,IAAI,kBAEH;CACF"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { getGasLimits } from '@aztec/aztec.js/contracts';
|
|
4
|
-
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AccountManager, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
6
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
8
8
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
9
9
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
-
import { collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
10
|
+
import { SimulationOverrides, TxStatus, collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
11
11
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
12
|
+
/** Splits a unified EmbeddedWalletPXEOptions into PXEConfig overrides and PXECreationOptions. */ export function splitPxeOptions(pxe) {
|
|
13
|
+
if (!pxe) {
|
|
14
|
+
return {
|
|
15
|
+
config: {},
|
|
16
|
+
creation: {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const { loggers, loggerActorLabel, proverOrOptions, store, simulator, ...config } = pxe;
|
|
20
|
+
return {
|
|
21
|
+
config,
|
|
22
|
+
creation: {
|
|
23
|
+
loggers,
|
|
24
|
+
loggerActorLabel,
|
|
25
|
+
proverOrOptions,
|
|
26
|
+
store,
|
|
27
|
+
simulator
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
12
31
|
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
13
32
|
export class EmbeddedWallet extends BaseWallet {
|
|
14
33
|
walletDB;
|
|
@@ -18,9 +37,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
18
37
|
super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
|
|
19
38
|
}
|
|
20
39
|
async getAccountFromAddress(address) {
|
|
21
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
22
|
-
return new SignerlessAccount();
|
|
23
|
-
}
|
|
24
40
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
25
41
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
26
42
|
const account = await accountManager.getAccount();
|
|
@@ -51,20 +67,25 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
51
67
|
* estimates actual gas usage and captures call authorization requests to generate
|
|
52
68
|
* the necessary authwitnesses.
|
|
53
69
|
*/ async sendTx(executionPayload, opts) {
|
|
54
|
-
const feeOptions = await this.
|
|
70
|
+
const feeOptions = await this.completeFeeOptions({
|
|
71
|
+
from: opts.from,
|
|
72
|
+
feePayer: executionPayload.feePayer,
|
|
73
|
+
gasSettings: opts.fee?.gasSettings,
|
|
74
|
+
forEstimation: true
|
|
75
|
+
});
|
|
55
76
|
// Simulate the transaction first to estimate gas and capture required
|
|
56
77
|
// private authwitnesses based on offchain effects.
|
|
57
78
|
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
58
79
|
from: opts.from,
|
|
59
80
|
feeOptions,
|
|
60
|
-
|
|
81
|
+
additionalScopes: opts.additionalScopes,
|
|
61
82
|
skipTxValidation: true
|
|
62
83
|
});
|
|
63
84
|
const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
|
|
64
85
|
const authWitnesses = await Promise.all(offchainEffects.map(async (effect)=>{
|
|
65
86
|
try {
|
|
66
87
|
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
67
|
-
return this.createAuthWit(
|
|
88
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
68
89
|
consumer: effect.contractAddress,
|
|
69
90
|
innerHash: authRequest.innerHash
|
|
70
91
|
});
|
|
@@ -86,6 +107,17 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
86
107
|
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
87
108
|
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
|
|
88
109
|
});
|
|
110
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : {};
|
|
111
|
+
if (!waitOpts?.waitForStatus) {
|
|
112
|
+
// Default to PROPOSED so the wait returns as soon as the tx lands in a proposed L2 block,
|
|
113
|
+
// rather than waiting until the end of the slot for the checkpoint to be published to L1.
|
|
114
|
+
// This is what makes MBPS (Multiple Blocks Per Slot) actually improve UX: with CHECKPOINTED
|
|
115
|
+
// we'd block until L1 inclusion regardless of how early in the slot the tx was sequenced.
|
|
116
|
+
// The tradeoff is a weaker guarantee — a proposed block only becomes canonical once it (or
|
|
117
|
+
// a later block in the same slot) is checkpointed, so a tx could be re-orged out if the
|
|
118
|
+
// proposer fails to publish to L1 (which should be rare, since they'd get slashed for it).
|
|
119
|
+
waitOpts.waitForStatus = TxStatus.PROPOSED;
|
|
120
|
+
}
|
|
89
121
|
return super.sendTx(executionPayload, {
|
|
90
122
|
...opts,
|
|
91
123
|
fee: {
|
|
@@ -95,67 +127,81 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
95
127
|
});
|
|
96
128
|
}
|
|
97
129
|
/**
|
|
130
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
131
|
+
* Uses a type-specific stub artifact so that the stub's constructor selector matches the real account's constructor.
|
|
132
|
+
*/ async buildAccountOverrides(addresses) {
|
|
133
|
+
const accounts = await this.getAccounts();
|
|
134
|
+
const contracts = {};
|
|
135
|
+
const filtered = accounts.filter((acc)=>addresses.some((addr)=>addr.equals(acc.item)));
|
|
136
|
+
for (const account of filtered){
|
|
137
|
+
const address = account.item;
|
|
138
|
+
const { type } = await this.walletDB.retrieveAccount(address);
|
|
139
|
+
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact(type);
|
|
140
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
141
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
142
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
143
|
+
if (!contractInstance) {
|
|
144
|
+
throw new Error(`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`);
|
|
145
|
+
}
|
|
146
|
+
const stubConstructorArgs = type === 'schnorr' ? [
|
|
147
|
+
Fr.ZERO,
|
|
148
|
+
Fr.ZERO
|
|
149
|
+
] : [
|
|
150
|
+
Buffer.alloc(32),
|
|
151
|
+
Buffer.alloc(32)
|
|
152
|
+
];
|
|
153
|
+
const stubInstance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
154
|
+
salt: Fr.random(),
|
|
155
|
+
constructorArgs: stubConstructorArgs
|
|
156
|
+
});
|
|
157
|
+
contracts[address.toString()] = {
|
|
158
|
+
instance: stubInstance,
|
|
159
|
+
artifact: stubArtifact
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return contracts;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
98
165
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
99
166
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
100
167
|
* private kernel circuit execution.
|
|
101
168
|
*/ 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
|
-
}
|
|
169
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement } = opts;
|
|
170
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
119
171
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
120
|
-
const executionOptions = {
|
|
121
|
-
txNonce: Fr.random(),
|
|
122
|
-
cancellable: this.cancellableTransactions,
|
|
123
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
124
|
-
};
|
|
125
172
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
126
173
|
feeExecutionPayload,
|
|
127
174
|
executionPayload
|
|
128
175
|
]) : executionPayload;
|
|
129
176
|
const chainInfo = await this.getChainInfo();
|
|
130
|
-
const
|
|
131
|
-
|
|
177
|
+
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
178
|
+
const overrides = new SimulationOverrides(accountOverrides);
|
|
179
|
+
let txRequest;
|
|
180
|
+
if (from === NO_FROM) {
|
|
181
|
+
const entrypoint = new DefaultEntrypoint();
|
|
182
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
183
|
+
} else {
|
|
184
|
+
const { type } = await this.walletDB.retrieveAccount(from);
|
|
185
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
186
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
187
|
+
const account = await this.accountContracts.createStubAccount(completeAddress, type);
|
|
188
|
+
const executionOptions = {
|
|
189
|
+
txNonce: Fr.random(),
|
|
190
|
+
cancellable: this.cancellableTransactions,
|
|
191
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
192
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
193
|
+
};
|
|
194
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
195
|
+
}
|
|
196
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
132
197
|
simulatePublic: true,
|
|
133
198
|
skipFeeEnforcement,
|
|
134
199
|
skipTxValidation,
|
|
135
200
|
overrides,
|
|
136
201
|
scopes
|
|
137
202
|
});
|
|
138
|
-
|
|
139
|
-
|
|
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()
|
|
153
|
-
});
|
|
154
|
-
return {
|
|
155
|
-
account: stubAccount,
|
|
156
|
-
instance,
|
|
157
|
-
artifact: stubArtifact
|
|
158
|
-
};
|
|
203
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
204
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
159
205
|
}
|
|
160
206
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
161
207
|
let contract;
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2VtYmVkZGVkL2VudHJ5cG9pbnRzL2Jyb3dzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUF5QixNQUFNLHNCQUFzQixDQUFDO0FBQzdFLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUVsRSxPQUFPLEVBQUUsS0FBSyxHQUFHLEVBQXNDLE1BQU0sd0JBQXdCLENBQUM7QUFJdEYsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx3Q0FBd0MsQ0FBQztBQUN2RixPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUsscUJBQXFCLEVBQW1CLE1BQU0sdUJBQXVCLENBQUM7QUFDcE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,
|
|
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;AAItF,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,CAgDZ;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"}
|
|
@@ -4,28 +4,38 @@ 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
6
|
import { LazyAccountContractsProvider } from '../account-contract-providers/lazy.js';
|
|
7
|
-
import { EmbeddedWallet } from '../embedded_wallet.js';
|
|
7
|
+
import { EmbeddedWallet, splitPxeOptions } from '../embedded_wallet.js';
|
|
8
8
|
import { WalletDB } from '../wallet_db.js';
|
|
9
9
|
export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
10
10
|
static async create(nodeOrUrl, options = {}) {
|
|
11
11
|
const rootLogger = options.logger ?? createLogger('embedded-wallet');
|
|
12
12
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
13
13
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
14
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
15
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
16
|
+
const mergedConfigOverrides = {
|
|
17
|
+
...options.pxeConfig,
|
|
18
|
+
...pxeConfigFromPxe
|
|
19
|
+
};
|
|
20
|
+
const mergedCreationOverrides = {
|
|
21
|
+
...options.pxeOptions,
|
|
22
|
+
...pxeCreationFromPxe
|
|
23
|
+
};
|
|
14
24
|
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
15
|
-
proverEnabled:
|
|
25
|
+
proverEnabled: mergedConfigOverrides.proverEnabled ?? false,
|
|
16
26
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
17
|
-
...
|
|
27
|
+
...mergedConfigOverrides
|
|
18
28
|
});
|
|
19
29
|
if (options.ephemeral) {
|
|
20
30
|
delete pxeConfig.dataDirectory;
|
|
21
31
|
}
|
|
22
32
|
const pxeOptions = {
|
|
23
|
-
...
|
|
33
|
+
...mergedCreationOverrides,
|
|
24
34
|
loggers: {
|
|
25
35
|
store: rootLogger.createChild('pxe:data'),
|
|
26
36
|
pxe: rootLogger.createChild('pxe:service'),
|
|
27
37
|
prover: rootLogger.createChild('pxe:prover'),
|
|
28
|
-
...
|
|
38
|
+
...mergedCreationOverrides.loggers
|
|
29
39
|
}
|
|
30
40
|
};
|
|
31
41
|
const pxe = await createPXE(aztecNode, pxeConfig, pxeOptions);
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2VtYmVkZGVkL2VudHJ5cG9pbnRzL25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBR2xFLE9BQU8sRUFBRSxLQUFLLEdBQUcsRUFBc0MsTUFBTSxtQkFBbUIsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHdDQUF3QyxDQUFDO0FBQ3ZGLE9BQU8sRUFBRSxjQUFjLEVBQUUsS0FBSyxxQkFBcUIsRUFBbUIsTUFBTSx1Q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Ac,EAAE,KAAK,qBAAqB,
|
|
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;AACjF,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,CAsDZ;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"}
|
|
@@ -4,28 +4,38 @@ 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
6
|
import { BundleAccountContractsProvider } from '../account-contract-providers/bundle.js';
|
|
7
|
-
import { EmbeddedWallet } from '../embedded_wallet.js';
|
|
7
|
+
import { EmbeddedWallet, splitPxeOptions } from '../embedded_wallet.js';
|
|
8
8
|
import { WalletDB } from '../wallet_db.js';
|
|
9
9
|
export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
10
10
|
static async create(nodeOrUrl, options = {}) {
|
|
11
11
|
const rootLogger = options.logger ?? createLogger('embedded-wallet');
|
|
12
12
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
13
13
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
14
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
15
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
16
|
+
const mergedConfigOverrides = {
|
|
17
|
+
...options.pxeConfig,
|
|
18
|
+
...pxeConfigFromPxe
|
|
19
|
+
};
|
|
20
|
+
const mergedCreationOverrides = {
|
|
21
|
+
...options.pxeOptions,
|
|
22
|
+
...pxeCreationFromPxe
|
|
23
|
+
};
|
|
14
24
|
const pxeConfig = Object.assign(getPXEConfig(), {
|
|
15
|
-
proverEnabled:
|
|
25
|
+
proverEnabled: mergedConfigOverrides.proverEnabled ?? false,
|
|
16
26
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
17
|
-
...
|
|
27
|
+
...mergedConfigOverrides
|
|
18
28
|
});
|
|
19
29
|
if (options.ephemeral) {
|
|
20
30
|
delete pxeConfig.dataDirectory;
|
|
21
31
|
}
|
|
22
32
|
const pxeOptions = {
|
|
23
|
-
...
|
|
33
|
+
...mergedCreationOverrides,
|
|
24
34
|
loggers: {
|
|
25
35
|
store: rootLogger.createChild('pxe:data'),
|
|
26
36
|
pxe: rootLogger.createChild('pxe:service'),
|
|
27
37
|
prover: rootLogger.createChild('pxe:prover'),
|
|
28
|
-
...
|
|
38
|
+
...mergedCreationOverrides.loggers
|
|
29
39
|
}
|
|
30
40
|
};
|
|
31
41
|
const pxe = await createPXE(aztecNode, pxeConfig, pxeOptions);
|
package/dest/testing.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ interface WalletWithSchnorrAccounts {
|
|
|
9
9
|
export declare function deployFundedSchnorrAccounts(wallet: WalletWithSchnorrAccounts, accountsData: InitialAccountData[], waitOptions?: WaitOpts): Promise<AccountManager[]>;
|
|
10
10
|
export declare function registerInitialLocalNetworkAccountsInWallet(wallet: WalletWithSchnorrAccounts): Promise<AztecAddress[]>;
|
|
11
11
|
export {};
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUdsRSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDN0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNELFVBQVUseUJBQXlCO0lBQ2pDLG9CQUFvQixDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLENBQUMsRUFBRSxFQUFFLEVBQUUsS0FBSyxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQztDQUN0RztBQUVELHdCQUFzQiwyQkFBMkIsQ0FDL0MsTUFBTSxFQUFFLHlCQUF5QixFQUNqQyxZQUFZLEVBQUUsa0JBQWtCLEVBQUUsRUFDbEMsV0FBVyxDQUFDLEVBQUUsUUFBUSw2QkFnQnZCO0FBRUQsd0JBQXNCLDJDQUEyQyxDQUMvRCxNQUFNLEVBQUUseUJBQXlCLEdBQ2hDLE9BQU8sQ0FBQyxZQUFZLEVBQUUsQ0FBQyxDQU96QiJ9
|
package/dest/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,UAAU,yBAAyB;IACjC,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtG;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,yBAAyB,EACjC,YAAY,EAAE,kBAAkB,EAAE,EAClC,WAAW,CAAC,EAAE,QAAQ,6BAgBvB;AAED,wBAAsB,2CAA2C,CAC/D,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC,CAOzB"}
|
package/dest/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
3
|
export async function deployFundedSchnorrAccounts(wallet, accountsData, waitOptions) {
|
|
4
4
|
const accountManagers = [];
|
|
5
5
|
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
@@ -8,7 +8,7 @@ export async function deployFundedSchnorrAccounts(wallet, accountsData, waitOpti
|
|
|
8
8
|
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
9
9
|
const deployMethod = await accountManager.getDeployMethod();
|
|
10
10
|
await deployMethod.send({
|
|
11
|
-
from:
|
|
11
|
+
from: NO_FROM,
|
|
12
12
|
skipClassPublication: i !== 0,
|
|
13
13
|
wait: waitOptions
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/wallets",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallets",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.a89ec08",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./embedded": {
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"../package.common.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
31
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
32
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
33
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
34
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
35
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
36
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
37
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
38
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
30
|
+
"@aztec/accounts": "0.0.1-commit.a89ec08",
|
|
31
|
+
"@aztec/aztec.js": "0.0.1-commit.a89ec08",
|
|
32
|
+
"@aztec/entrypoints": "0.0.1-commit.a89ec08",
|
|
33
|
+
"@aztec/foundation": "0.0.1-commit.a89ec08",
|
|
34
|
+
"@aztec/kv-store": "0.0.1-commit.a89ec08",
|
|
35
|
+
"@aztec/protocol-contracts": "0.0.1-commit.a89ec08",
|
|
36
|
+
"@aztec/pxe": "0.0.1-commit.a89ec08",
|
|
37
|
+
"@aztec/stdlib": "0.0.1-commit.a89ec08",
|
|
38
|
+
"@aztec/wallet-sdk": "0.0.1-commit.a89ec08"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@jest/globals": "^30.0.0",
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"ts-node": "^10.9.1",
|
|
45
45
|
"typescript": "^5.3.3"
|
|
46
46
|
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dest",
|
|
49
|
+
"src",
|
|
50
|
+
"!*.test.*"
|
|
51
|
+
],
|
|
47
52
|
"typedocOptions": {
|
|
48
53
|
"entryPoints": [
|
|
49
54
|
"./src/embedded/entrypoints/browser.ts",
|
|
@@ -53,11 +58,6 @@
|
|
|
53
58
|
"name": "Wallets",
|
|
54
59
|
"tsconfig": "./tsconfig.json"
|
|
55
60
|
},
|
|
56
|
-
"files": [
|
|
57
|
-
"dest",
|
|
58
|
-
"src",
|
|
59
|
-
"!*.test.*"
|
|
60
|
-
],
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=20.10"
|
|
63
63
|
},
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
-
import {
|
|
3
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
4
5
|
import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
5
6
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
6
7
|
import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi-call-entrypoint';
|
|
7
8
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
8
9
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
9
10
|
|
|
11
|
+
import type { AccountType } from '../wallet_db.js';
|
|
10
12
|
import type { AccountContractsProvider } from './types.js';
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -26,12 +28,12 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
26
28
|
return Promise.resolve(new EcdsaKAccountContract(signingKey));
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact> {
|
|
30
|
-
return Promise.resolve(
|
|
31
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
32
|
+
return Promise.resolve(type === 'schnorr' ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
createStubAccount(address: CompleteAddress): Promise<Account> {
|
|
34
|
-
return Promise.resolve(
|
|
35
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
36
|
+
return Promise.resolve(type === 'schnorr' ? createStubSchnorrAccount(address) : createStubEcdsaAccount(address));
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
getMulticallContract(): Promise<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }> {
|
|
@@ -4,6 +4,7 @@ import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi
|
|
|
4
4
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
|
|
7
|
+
import type { AccountType } from '../wallet_db.js';
|
|
7
8
|
import type { AccountContractsProvider } from './types.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -26,14 +27,24 @@ export class LazyAccountContractsProvider implements AccountContractsProvider {
|
|
|
26
27
|
return new EcdsaKAccountContract(signingKey);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
async getStubAccountContractArtifact(): Promise<ContractArtifact> {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
async getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
31
|
+
if (type === 'schnorr') {
|
|
32
|
+
const { getStubSchnorrAccountContractArtifact } = await import('@aztec/accounts/stub/schnorr/lazy');
|
|
33
|
+
return getStubSchnorrAccountContractArtifact();
|
|
34
|
+
} else {
|
|
35
|
+
const { getStubEcdsaAccountContractArtifact } = await import('@aztec/accounts/stub/ecdsa/lazy');
|
|
36
|
+
return getStubEcdsaAccountContractArtifact();
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
async createStubAccount(address: CompleteAddress): Promise<Account> {
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
async createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
41
|
+
if (type === 'schnorr') {
|
|
42
|
+
const { createStubSchnorrAccount } = await import('@aztec/accounts/stub/schnorr/lazy');
|
|
43
|
+
return createStubSchnorrAccount(address);
|
|
44
|
+
} else {
|
|
45
|
+
const { createStubEcdsaAccount } = await import('@aztec/accounts/stub/ecdsa/lazy');
|
|
46
|
+
return createStubEcdsaAccount(address);
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
getMulticallContract(): Promise<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }> {
|
|
@@ -3,6 +3,8 @@ import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
|
|
6
|
+
import type { AccountType } from '../wallet_db.js';
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Provides account contract implementations and stub accounts for the EmbeddedWallet.
|
|
8
10
|
* Two implementations exist:
|
|
@@ -13,7 +15,7 @@ export interface AccountContractsProvider {
|
|
|
13
15
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
14
16
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
15
17
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
16
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact>;
|
|
18
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
17
19
|
getMulticallContract(): Promise<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }>;
|
|
18
|
-
createStubAccount(address: CompleteAddress): Promise<Account>;
|
|
20
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account>;
|
|
19
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type Account,
|
|
1
|
+
import { type Account, NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import { type InteractionWaitOptions, type SendReturn, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { type InteractionWaitOptions, type SendReturn, type WaitOpts, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
-
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { AccountManager, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
7
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
7
8
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
8
9
|
import type { Logger } from '@aztec/foundation/log';
|
|
9
10
|
import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
@@ -14,9 +15,11 @@ import { GasSettings } from '@aztec/stdlib/gas';
|
|
|
14
15
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
15
16
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
16
17
|
import {
|
|
18
|
+
type ContractOverrides,
|
|
17
19
|
ExecutionPayload,
|
|
18
20
|
SimulationOverrides,
|
|
19
|
-
type
|
|
21
|
+
type TxExecutionRequest,
|
|
22
|
+
TxStatus,
|
|
20
23
|
collectOffchainEffects,
|
|
21
24
|
mergeExecutionPayloads,
|
|
22
25
|
} from '@aztec/stdlib/tx';
|
|
@@ -25,14 +28,37 @@ import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk
|
|
|
25
28
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
26
29
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
27
30
|
|
|
31
|
+
/** Options for the PXE instance created by the EmbeddedWallet. */
|
|
32
|
+
export type EmbeddedWalletPXEOptions = Partial<PXEConfig> & PXECreationOptions;
|
|
33
|
+
|
|
34
|
+
/** Splits a unified EmbeddedWalletPXEOptions into PXEConfig overrides and PXECreationOptions. */
|
|
35
|
+
export function splitPxeOptions(pxe?: EmbeddedWalletPXEOptions): {
|
|
36
|
+
config: Partial<PXEConfig>;
|
|
37
|
+
creation: PXECreationOptions;
|
|
38
|
+
} {
|
|
39
|
+
if (!pxe) {
|
|
40
|
+
return { config: {}, creation: {} };
|
|
41
|
+
}
|
|
42
|
+
const { loggers, loggerActorLabel, proverOrOptions, store, simulator, ...config } = pxe;
|
|
43
|
+
return { config, creation: { loggers, loggerActorLabel, proverOrOptions, store, simulator } };
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
export type EmbeddedWalletOptions = {
|
|
29
47
|
/** Parent logger. Child loggers are derived via createChild() for each subsystem. */
|
|
30
48
|
logger?: Logger;
|
|
31
49
|
/** Use ephemeral (in-memory) stores. Data will not persist across sessions. */
|
|
32
50
|
ephemeral?: boolean;
|
|
33
|
-
/**
|
|
51
|
+
/** PXE configuration and dependency overrides (custom store, prover, simulator). */
|
|
52
|
+
pxe?: EmbeddedWalletPXEOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Override PXE configuration.
|
|
55
|
+
* @deprecated Use `pxe` instead.
|
|
56
|
+
*/
|
|
34
57
|
pxeConfig?: Partial<PXEConfig>;
|
|
35
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Advanced PXE creation options (custom store, prover, simulator).
|
|
60
|
+
* @deprecated Use `pxe` instead.
|
|
61
|
+
*/
|
|
36
62
|
pxeOptions?: PXECreationOptions;
|
|
37
63
|
};
|
|
38
64
|
|
|
@@ -52,10 +78,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
52
78
|
}
|
|
53
79
|
|
|
54
80
|
protected async getAccountFromAddress(address: AztecAddress): Promise<Account> {
|
|
55
|
-
if (address.equals(AztecAddress.ZERO)) {
|
|
56
|
-
return new SignerlessAccount();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
81
|
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
|
|
60
82
|
const accountManager = await this.createAccountInternal(type, secretKey, salt, signingKey);
|
|
61
83
|
const account = await accountManager.getAccount();
|
|
@@ -96,18 +118,19 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
96
118
|
executionPayload: ExecutionPayload,
|
|
97
119
|
opts: SendOptions<W>,
|
|
98
120
|
): Promise<SendReturn<W>> {
|
|
99
|
-
const feeOptions = await this.
|
|
100
|
-
opts.from,
|
|
101
|
-
executionPayload.feePayer,
|
|
102
|
-
opts.fee?.gasSettings,
|
|
103
|
-
|
|
121
|
+
const feeOptions = await this.completeFeeOptions({
|
|
122
|
+
from: opts.from,
|
|
123
|
+
feePayer: executionPayload.feePayer,
|
|
124
|
+
gasSettings: opts.fee?.gasSettings,
|
|
125
|
+
forEstimation: true,
|
|
126
|
+
});
|
|
104
127
|
|
|
105
128
|
// Simulate the transaction first to estimate gas and capture required
|
|
106
129
|
// private authwitnesses based on offchain effects.
|
|
107
130
|
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
108
131
|
from: opts.from,
|
|
109
132
|
feeOptions,
|
|
110
|
-
|
|
133
|
+
additionalScopes: opts.additionalScopes,
|
|
111
134
|
skipTxValidation: true,
|
|
112
135
|
});
|
|
113
136
|
|
|
@@ -116,7 +139,7 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
116
139
|
offchainEffects.map(async effect => {
|
|
117
140
|
try {
|
|
118
141
|
const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
|
|
119
|
-
return this.createAuthWit(
|
|
142
|
+
return this.createAuthWit(authRequest.onBehalfOf, {
|
|
120
143
|
consumer: effect.contractAddress,
|
|
121
144
|
innerHash: authRequest.innerHash,
|
|
122
145
|
});
|
|
@@ -141,12 +164,63 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
141
164
|
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
142
165
|
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits,
|
|
143
166
|
});
|
|
167
|
+
const waitOpts: WaitOpts = typeof opts.wait === 'object' ? opts.wait : {};
|
|
168
|
+
|
|
169
|
+
if (!waitOpts?.waitForStatus) {
|
|
170
|
+
// Default to PROPOSED so the wait returns as soon as the tx lands in a proposed L2 block,
|
|
171
|
+
// rather than waiting until the end of the slot for the checkpoint to be published to L1.
|
|
172
|
+
// This is what makes MBPS (Multiple Blocks Per Slot) actually improve UX: with CHECKPOINTED
|
|
173
|
+
// we'd block until L1 inclusion regardless of how early in the slot the tx was sequenced.
|
|
174
|
+
// The tradeoff is a weaker guarantee — a proposed block only becomes canonical once it (or
|
|
175
|
+
// a later block in the same slot) is checkpointed, so a tx could be re-orged out if the
|
|
176
|
+
// proposer fails to publish to L1 (which should be rare, since they'd get slashed for it).
|
|
177
|
+
waitOpts!.waitForStatus = TxStatus.PROPOSED;
|
|
178
|
+
}
|
|
144
179
|
return super.sendTx(executionPayload, {
|
|
145
180
|
...opts,
|
|
146
181
|
fee: { ...opts.fee, gasSettings },
|
|
147
182
|
});
|
|
148
183
|
}
|
|
149
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
187
|
+
* Uses a type-specific stub artifact so that the stub's constructor selector matches the real account's constructor.
|
|
188
|
+
*/
|
|
189
|
+
protected async buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides> {
|
|
190
|
+
const accounts = await this.getAccounts();
|
|
191
|
+
const contracts: ContractOverrides = {};
|
|
192
|
+
|
|
193
|
+
const filtered = accounts.filter(acc => addresses.some(addr => addr.equals(acc.item)));
|
|
194
|
+
|
|
195
|
+
for (const account of filtered) {
|
|
196
|
+
const address = account.item;
|
|
197
|
+
const { type } = await this.walletDB.retrieveAccount(address);
|
|
198
|
+
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact(type);
|
|
199
|
+
|
|
200
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
201
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
202
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
203
|
+
if (!contractInstance) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const stubConstructorArgs = type === 'schnorr' ? [Fr.ZERO, Fr.ZERO] : [Buffer.alloc(32), Buffer.alloc(32)];
|
|
210
|
+
const stubInstance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
211
|
+
salt: Fr.random(),
|
|
212
|
+
constructorArgs: stubConstructorArgs,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
contracts[address.toString()] = {
|
|
216
|
+
instance: stubInstance,
|
|
217
|
+
artifact: stubArtifact,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return contracts;
|
|
222
|
+
}
|
|
223
|
+
|
|
150
224
|
/**
|
|
151
225
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
152
226
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
@@ -155,66 +229,51 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
155
229
|
protected override async simulateViaEntrypoint(
|
|
156
230
|
executionPayload: ExecutionPayload,
|
|
157
231
|
opts: SimulateViaEntrypointOptions,
|
|
158
|
-
): Promise<
|
|
159
|
-
const { from, feeOptions,
|
|
160
|
-
|
|
161
|
-
let overrides: SimulationOverrides | undefined;
|
|
162
|
-
let fromAccount: Account;
|
|
163
|
-
if (!from.equals(AztecAddress.ZERO)) {
|
|
164
|
-
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
165
|
-
fromAccount = account;
|
|
166
|
-
overrides = {
|
|
167
|
-
contracts: { [from.toString()]: { instance, artifact } },
|
|
168
|
-
};
|
|
169
|
-
} else {
|
|
170
|
-
fromAccount = await this.getAccountFromAddress(from);
|
|
171
|
-
}
|
|
232
|
+
): Promise<TxSimulationResultWithAppOffset> {
|
|
233
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement } = opts;
|
|
234
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
172
235
|
|
|
173
236
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
174
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
175
|
-
txNonce: Fr.random(),
|
|
176
|
-
cancellable: this.cancellableTransactions,
|
|
177
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
178
|
-
};
|
|
179
237
|
const finalExecutionPayload = feeExecutionPayload
|
|
180
238
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
181
239
|
: executionPayload;
|
|
182
240
|
const chainInfo = await this.getChainInfo();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
)
|
|
189
|
-
|
|
241
|
+
|
|
242
|
+
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
243
|
+
const overrides = new SimulationOverrides(accountOverrides);
|
|
244
|
+
|
|
245
|
+
let txRequest: TxExecutionRequest;
|
|
246
|
+
if (from === NO_FROM) {
|
|
247
|
+
const entrypoint = new DefaultEntrypoint();
|
|
248
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
249
|
+
} else {
|
|
250
|
+
const { type } = await this.walletDB.retrieveAccount(from);
|
|
251
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
252
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
253
|
+
const account = await this.accountContracts.createStubAccount(completeAddress, type);
|
|
254
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
255
|
+
txNonce: Fr.random(),
|
|
256
|
+
cancellable: this.cancellableTransactions,
|
|
257
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
258
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
|
|
259
|
+
};
|
|
260
|
+
txRequest = await account.createTxExecutionRequest(
|
|
261
|
+
finalExecutionPayload,
|
|
262
|
+
feeOptions.gasSettings,
|
|
263
|
+
chainInfo,
|
|
264
|
+
executionOptions,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
190
269
|
simulatePublic: true,
|
|
191
270
|
skipFeeEnforcement,
|
|
192
271
|
skipTxValidation,
|
|
193
272
|
overrides,
|
|
194
273
|
scopes,
|
|
195
274
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
private async getFakeAccountDataFor(address: AztecAddress) {
|
|
199
|
-
const originalAccount = await this.getAccountFromAddress(address);
|
|
200
|
-
if (originalAccount instanceof SignerlessAccount) {
|
|
201
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
202
|
-
}
|
|
203
|
-
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
204
|
-
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
205
|
-
if (!contractInstance) {
|
|
206
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
207
|
-
}
|
|
208
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
209
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
210
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
211
|
-
salt: Fr.random(),
|
|
212
|
-
});
|
|
213
|
-
return {
|
|
214
|
-
account: stubAccount,
|
|
215
|
-
instance,
|
|
216
|
-
artifact: stubArtifact,
|
|
217
|
-
};
|
|
275
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
276
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
218
277
|
}
|
|
219
278
|
|
|
220
279
|
protected async createAccountInternal(
|
|
@@ -6,7 +6,7 @@ import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
|
|
|
6
6
|
|
|
7
7
|
import { LazyAccountContractsProvider } from '../account-contract-providers/lazy.js';
|
|
8
8
|
import type { AccountContractsProvider } from '../account-contract-providers/types.js';
|
|
9
|
-
import { EmbeddedWallet, type EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
9
|
+
import { EmbeddedWallet, type EmbeddedWalletOptions, splitPxeOptions } from '../embedded_wallet.js';
|
|
10
10
|
import { WalletDB } from '../wallet_db.js';
|
|
11
11
|
|
|
12
12
|
export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
@@ -26,10 +26,15 @@ export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
|
26
26
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
27
27
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
28
28
|
|
|
29
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
30
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
31
|
+
const mergedConfigOverrides = { ...options.pxeConfig, ...pxeConfigFromPxe };
|
|
32
|
+
const mergedCreationOverrides: PXECreationOptions = { ...options.pxeOptions, ...pxeCreationFromPxe };
|
|
33
|
+
|
|
29
34
|
const pxeConfig: PXEConfig = Object.assign(getPXEConfig(), {
|
|
30
|
-
proverEnabled:
|
|
35
|
+
proverEnabled: mergedConfigOverrides.proverEnabled ?? false,
|
|
31
36
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
32
|
-
...
|
|
37
|
+
...mergedConfigOverrides,
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
if (options.ephemeral) {
|
|
@@ -37,12 +42,12 @@ export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
const pxeOptions: PXECreationOptions = {
|
|
40
|
-
...
|
|
45
|
+
...mergedCreationOverrides,
|
|
41
46
|
loggers: {
|
|
42
47
|
store: rootLogger.createChild('pxe:data'),
|
|
43
48
|
pxe: rootLogger.createChild('pxe:service'),
|
|
44
49
|
prover: rootLogger.createChild('pxe:prover'),
|
|
45
|
-
...
|
|
50
|
+
...mergedCreationOverrides.loggers,
|
|
46
51
|
},
|
|
47
52
|
};
|
|
48
53
|
|
|
@@ -67,6 +72,6 @@ export class BrowserEmbeddedWallet extends EmbeddedWallet {
|
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
export { BrowserEmbeddedWallet as EmbeddedWallet };
|
|
70
|
-
export type { EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
75
|
+
export type { EmbeddedWalletOptions, EmbeddedWalletPXEOptions } from '../embedded_wallet.js';
|
|
71
76
|
export { WalletDB } from '../wallet_db.js';
|
|
72
77
|
export type { AccountType } from '../wallet_db.js';
|
|
@@ -7,7 +7,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
7
7
|
|
|
8
8
|
import { BundleAccountContractsProvider } from '../account-contract-providers/bundle.js';
|
|
9
9
|
import type { AccountContractsProvider } from '../account-contract-providers/types.js';
|
|
10
|
-
import { EmbeddedWallet, type EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
10
|
+
import { EmbeddedWallet, type EmbeddedWalletOptions, splitPxeOptions } from '../embedded_wallet.js';
|
|
11
11
|
import { WalletDB } from '../wallet_db.js';
|
|
12
12
|
|
|
13
13
|
export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
@@ -27,10 +27,15 @@ export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
|
27
27
|
const aztecNode = typeof nodeOrUrl === 'string' ? createAztecNodeClient(nodeOrUrl) : nodeOrUrl;
|
|
28
28
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
29
29
|
|
|
30
|
+
// Support both the new unified `pxe` option and the deprecated `pxeConfig`/`pxeOptions`.
|
|
31
|
+
const { config: pxeConfigFromPxe, creation: pxeCreationFromPxe } = splitPxeOptions(options.pxe);
|
|
32
|
+
const mergedConfigOverrides = { ...options.pxeConfig, ...pxeConfigFromPxe };
|
|
33
|
+
const mergedCreationOverrides: PXECreationOptions = { ...options.pxeOptions, ...pxeCreationFromPxe };
|
|
34
|
+
|
|
30
35
|
const pxeConfig: PXEConfig = Object.assign(getPXEConfig(), {
|
|
31
|
-
proverEnabled:
|
|
36
|
+
proverEnabled: mergedConfigOverrides.proverEnabled ?? false,
|
|
32
37
|
dataDirectory: `pxe_data_${l1Contracts.rollupAddress}`,
|
|
33
|
-
...
|
|
38
|
+
...mergedConfigOverrides,
|
|
34
39
|
});
|
|
35
40
|
|
|
36
41
|
if (options.ephemeral) {
|
|
@@ -38,12 +43,12 @@ export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
const pxeOptions: PXECreationOptions = {
|
|
41
|
-
...
|
|
46
|
+
...mergedCreationOverrides,
|
|
42
47
|
loggers: {
|
|
43
48
|
store: rootLogger.createChild('pxe:data'),
|
|
44
49
|
pxe: rootLogger.createChild('pxe:service'),
|
|
45
50
|
prover: rootLogger.createChild('pxe:prover'),
|
|
46
|
-
...
|
|
51
|
+
...mergedCreationOverrides.loggers,
|
|
47
52
|
},
|
|
48
53
|
};
|
|
49
54
|
|
|
@@ -74,6 +79,6 @@ export class NodeEmbeddedWallet extends EmbeddedWallet {
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
export { NodeEmbeddedWallet as EmbeddedWallet };
|
|
77
|
-
export type { EmbeddedWalletOptions } from '../embedded_wallet.js';
|
|
82
|
+
export type { EmbeddedWalletOptions, EmbeddedWalletPXEOptions } from '../embedded_wallet.js';
|
|
78
83
|
export { WalletDB } from '../wallet_db.js';
|
|
79
84
|
export type { AccountType } from '../wallet_db.js';
|
package/src/testing.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
3
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
4
|
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
4
5
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import type { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -21,7 +22,7 @@ export async function deployFundedSchnorrAccounts(
|
|
|
21
22
|
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
22
23
|
const deployMethod = await accountManager.getDeployMethod();
|
|
23
24
|
await deployMethod.send({
|
|
24
|
-
from:
|
|
25
|
+
from: NO_FROM,
|
|
25
26
|
skipClassPublication: i !== 0,
|
|
26
27
|
wait: waitOptions,
|
|
27
28
|
});
|