@aztec/wallets 5.0.0-private.20260318 → 5.0.0-rc.1
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 +65 -10
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +252 -59
- package/dest/embedded/entrypoints/browser.d.ts +2 -2
- package/dest/embedded/entrypoints/browser.d.ts.map +1 -1
- package/dest/embedded/entrypoints/browser.js +39 -10
- package/dest/embedded/entrypoints/node.d.ts +2 -2
- package/dest/embedded/entrypoints/node.d.ts.map +1 -1
- package/dest/embedded/entrypoints/node.js +33 -10
- package/dest/embedded/store_encryption.d.ts +67 -0
- package/dest/embedded/store_encryption.d.ts.map +1 -0
- package/dest/embedded/store_encryption.js +71 -0
- package/dest/embedded/wallet_db.d.ts +7 -6
- package/dest/embedded/wallet_db.d.ts.map +1 -1
- package/dest/embedded/wallet_db.js +10 -9
- 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 +331 -67
- package/src/embedded/entrypoints/browser.ts +47 -20
- package/src/embedded/entrypoints/node.ts +46 -26
- package/src/embedded/store_encryption.ts +107 -0
- package/src/embedded/wallet_db.ts +13 -10
- package/src/testing.ts +11 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store_encryption.d.ts","sourceRoot":"","sources":["../../src/embedded/store_encryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAE1F,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEjD;;;GAGG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IACtD,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC,YAAY,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,qBAAqB,CAAA;KAAE,EAI/E;CACF;AAED,6DAA6D;AAC7D,MAAM,WAAW,kCAAkC;IACjD,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,aAAa,EAAE,UAAU,KACtB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAKnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,kCAAkC,EAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,EAC3C,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,0BAA6C,GACvD,OAAO,CAAC;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,WAAW,EAAE,oBAAoB,CAAA;CAAE,CAAC,CAWhF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet-layer helpers for opening the embedded wallet's two encrypted stores (PXE + walletDB) as a cohesive unit.
|
|
3
|
+
*
|
|
4
|
+
* Sits on top of `@aztec/kv-store/sqlite-opfs`'s typed `SqliteEncryptionError` and adds:
|
|
5
|
+
*
|
|
6
|
+
* - `storeName: 'pxe' | 'wallet'`, telling callers WHICH store failed.
|
|
7
|
+
* - Cleanup: when the wallet store fails to open, ensures the already-opened PXE store is closed before the error
|
|
8
|
+
* surfaces, so callers don't leak the SAH Pool's OPFS lock.
|
|
9
|
+
*/ import { AztecSQLiteOPFSStore, SqliteEncryptionError } from '@aztec/kv-store/sqlite-opfs';
|
|
10
|
+
/**
|
|
11
|
+
* Thrown by {@link openEncryptedEmbeddedStores} when one of the two stores cannot be decrypted with the supplied
|
|
12
|
+
* key. The original {@link SqliteEncryptionError} is preserved as `cause`.
|
|
13
|
+
*/ export class EmbeddedWalletEncryptionError extends Error {
|
|
14
|
+
storeName;
|
|
15
|
+
constructor(storeName, opts){
|
|
16
|
+
super(`Embedded wallet '${storeName}' store could not be decrypted with the provided key`, {
|
|
17
|
+
cause: opts.cause
|
|
18
|
+
});
|
|
19
|
+
this.name = 'EmbeddedWalletEncryptionError';
|
|
20
|
+
this.storeName = storeName;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const defaultOpenStore = (log, name, poolDirectory, encryptionKey)=>AztecSQLiteOPFSStore.open(log, name, false, poolDirectory, encryptionKey);
|
|
24
|
+
/**
|
|
25
|
+
* Opens the PXE and wallet stores in sequence, both encrypted with keys obtained from `getEncryptionKey`.
|
|
26
|
+
*
|
|
27
|
+
* The callback is invoked once per store (twice total per call) because `AztecSQLiteOPFSStore.open` *transfers*
|
|
28
|
+
* the key buffer to its worker. A single buffer would detach between the two opens.
|
|
29
|
+
*
|
|
30
|
+
* Failure modes:
|
|
31
|
+
*
|
|
32
|
+
* - PXE store fails to decrypt → throws `EmbeddedWalletEncryptionError({ storeName: 'pxe', cause })`. No cleanup
|
|
33
|
+
* needed (nothing was opened).
|
|
34
|
+
* - Wallet store fails to decrypt → closes the already-opened PXE store then throws
|
|
35
|
+
* `EmbeddedWalletEncryptionError({ storeName: 'wallet', cause })`.
|
|
36
|
+
* - Any non-decrypt error during the wallet open → still closes PXE, then re-throws the original error unwrapped
|
|
37
|
+
* (preserves callers' existing untyped error handling for non-encryption faults).
|
|
38
|
+
*
|
|
39
|
+
* @param config - Per-store name/poolDirectory.
|
|
40
|
+
* @param getEncryptionKey - Returns a fresh 32-byte key per call (the buffer
|
|
41
|
+
* detaches on transfer, so each call must allocate).
|
|
42
|
+
* @param log - Logger for both stores.
|
|
43
|
+
* @param openStore - Internal test seam. Do not pass in production code.
|
|
44
|
+
*/ export async function openEncryptedEmbeddedStores(config, getEncryptionKey, log, openStore = defaultOpenStore) {
|
|
45
|
+
const pxeStore = await openOneStore('pxe', config.pxe, getEncryptionKey, log, openStore);
|
|
46
|
+
try {
|
|
47
|
+
const walletStore = await openOneStore('wallet', config.wallet, getEncryptionKey, log, openStore);
|
|
48
|
+
return {
|
|
49
|
+
pxeStore,
|
|
50
|
+
walletStore
|
|
51
|
+
};
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// Cleanup is best-effort — if close() itself throws (e.g. worker already dead), swallow it so the original error
|
|
54
|
+
// surfaces unobstructed.
|
|
55
|
+
await pxeStore.close().catch(()=>{});
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function openOneStore(storeName, { name, poolDirectory }, getEncryptionKey, log, openStore) {
|
|
60
|
+
const key = await getEncryptionKey();
|
|
61
|
+
try {
|
|
62
|
+
return await openStore(log, name, poolDirectory, key);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
if (err instanceof SqliteEncryptionError && err.code === 'decrypt_failed') {
|
|
65
|
+
throw new EmbeddedWalletEncryptionError(storeName, {
|
|
66
|
+
cause: err
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -3,15 +3,15 @@ import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256k1"];
|
|
6
|
+
export declare const AccountTypes: readonly ["schnorr", "schnorr_initializerless", "ecdsasecp256r1", "ecdsasecp256k1"];
|
|
7
7
|
export type AccountType = (typeof AccountTypes)[number];
|
|
8
8
|
export declare class WalletDB {
|
|
9
9
|
#private;
|
|
10
|
+
private store;
|
|
11
|
+
private userLog;
|
|
10
12
|
private accounts;
|
|
11
13
|
private aliases;
|
|
12
|
-
|
|
13
|
-
private constructor();
|
|
14
|
-
static init(store: AztecAsyncKVStore, userLog: LogFn): WalletDB;
|
|
14
|
+
constructor(store: AztecAsyncKVStore, userLog: LogFn);
|
|
15
15
|
storeAccount(address: AztecAddress, { type, secretKey, salt, alias, signingKey }: {
|
|
16
16
|
type: AccountType;
|
|
17
17
|
secretKey: Fr;
|
|
@@ -24,11 +24,12 @@ export declare class WalletDB {
|
|
|
24
24
|
address: string | AztecAddress;
|
|
25
25
|
secretKey: Fr;
|
|
26
26
|
salt: Fr;
|
|
27
|
-
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "schnorr";
|
|
27
|
+
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "schnorr" | "schnorr_initializerless";
|
|
28
28
|
signingKey: Buffer<ArrayBufferLike>;
|
|
29
29
|
}>;
|
|
30
30
|
listAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
31
31
|
listSenders(): Promise<Aliased<AztecAddress>[]>;
|
|
32
32
|
deleteAccount(address: AztecAddress): Promise<void>;
|
|
33
|
+
close(): Promise<void>;
|
|
33
34
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X2RiLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvd2FsbGV0X2RiLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNELGVBQU8sTUFBTSxZQUFZLHFGQUFzRixDQUFDO0FBQ2hILE1BQU0sTUFBTSxXQUFXLEdBQUcsQ0FBQyxPQUFPLFlBQVksQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBTXhELHFCQUFhLFFBQVE7O0lBS2pCLE9BQU8sQ0FBQyxLQUFLO0lBQ2IsT0FBTyxDQUFDLE9BQU87SUFMakIsT0FBTyxDQUFDLFFBQVEsQ0FBZ0M7SUFDaEQsT0FBTyxDQUFDLE9BQU8sQ0FBZ0M7SUFFL0MsWUFDVSxLQUFLLEVBQUUsaUJBQWlCLEVBQ3hCLE9BQU8sRUFBRSxLQUFLLEVBSXZCO0lBRUssWUFBWSxDQUNoQixPQUFPLEVBQUUsWUFBWSxFQUNyQixFQUNFLElBQUksRUFDSixTQUFTLEVBQ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CAAC,EAAE,CAAC,CAWrD;IAEK,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CASpD;IAoBK,aAAa,CAAC,OAAO,EAAE,YAAY,iBAaxC;IAEK,KAAK,kBAEV;CACF"}
|
|
@@ -2,6 +2,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
export const AccountTypes = [
|
|
4
4
|
'schnorr',
|
|
5
|
+
'schnorr_initializerless',
|
|
5
6
|
'ecdsasecp256r1',
|
|
6
7
|
'ecdsasecp256k1'
|
|
7
8
|
];
|
|
@@ -9,18 +10,15 @@ function accountKey(field, address) {
|
|
|
9
10
|
return `${field}:${address.toString()}`;
|
|
10
11
|
}
|
|
11
12
|
export class WalletDB {
|
|
13
|
+
store;
|
|
14
|
+
userLog;
|
|
12
15
|
accounts;
|
|
13
16
|
aliases;
|
|
14
|
-
userLog
|
|
15
|
-
|
|
16
|
-
this.accounts = accounts;
|
|
17
|
-
this.aliases = aliases;
|
|
17
|
+
constructor(store, userLog){
|
|
18
|
+
this.store = store;
|
|
18
19
|
this.userLog = userLog;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const accounts = store.openMap('accounts');
|
|
22
|
-
const aliases = store.openMap('aliases');
|
|
23
|
-
return new WalletDB(accounts, aliases, userLog);
|
|
20
|
+
this.accounts = store.openMap('accounts');
|
|
21
|
+
this.aliases = store.openMap('aliases');
|
|
24
22
|
}
|
|
25
23
|
async storeAccount(address, { type, secretKey, salt, alias, signingKey }, log = this.userLog) {
|
|
26
24
|
if (alias) {
|
|
@@ -117,4 +115,7 @@ export class WalletDB {
|
|
|
117
115
|
await this.aliases.delete(`accounts:${alias}`);
|
|
118
116
|
}
|
|
119
117
|
}
|
|
118
|
+
async close() {
|
|
119
|
+
await this.store.close();
|
|
120
|
+
}
|
|
120
121
|
}
|
package/dest/testing.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
3
2
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
4
3
|
import type { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
5
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
5
|
interface WalletWithSchnorrAccounts {
|
|
7
|
-
|
|
6
|
+
createSchnorrInitializerlessAccount(secret: Fr, salt: Fr, signingKey?: Fq, alias?: string): Promise<AccountManager>;
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Creates the given (genesis-funded) test accounts as initializerless schnorr accounts. Initializerless
|
|
10
|
+
* accounts need no deployment tx — creating one registers the instance and materializes its immutable keys
|
|
11
|
+
* locally — so the accounts are usable as soon as they are created, funded via genesis at their addresses.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFundedInitializerlessAccounts(wallet: WalletWithSchnorrAccounts, accountsData: InitialAccountData[]): Promise<AccountManager[]>;
|
|
10
14
|
export declare function registerInitialLocalNetworkAccountsInWallet(wallet: WalletWithSchnorrAccounts): Promise<AztecAddress[]>;
|
|
11
15
|
export {};
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVsRSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDN0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNELFVBQVUseUJBQXlCO0lBQ2pDLG1DQUFtQyxDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLENBQUMsRUFBRSxFQUFFLEVBQUUsS0FBSyxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQztDQUNySDtBQUVEOzs7O0dBSUc7QUFDSCx3QkFBc0IsbUNBQW1DLENBQ3ZELE1BQU0sRUFBRSx5QkFBeUIsRUFDakMsWUFBWSxFQUFFLGtCQUFrQixFQUFFLDZCQU9uQztBQUVELHdCQUFzQiwyQ0FBMkMsQ0FDL0QsTUFBTSxFQUFFLHlCQUF5QixHQUNoQyxPQUFPLENBQUMsWUFBWSxFQUFFLENBQUMsQ0FRekIifQ==
|
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;AAElE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,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,mCAAmC,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACrH;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yBAAyB,EACjC,YAAY,EAAE,kBAAkB,EAAE,6BAOnC;AAED,wBAAsB,2CAA2C,CAC/D,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC,CAQzB"}
|
package/dest/testing.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates the given (genesis-funded) test accounts as initializerless schnorr accounts. Initializerless
|
|
4
|
+
* accounts need no deployment tx — creating one registers the instance and materializes its immutable keys
|
|
5
|
+
* locally — so the accounts are usable as soon as they are created, funded via genesis at their addresses.
|
|
6
|
+
*/ export async function createFundedInitializerlessAccounts(wallet, accountsData) {
|
|
4
7
|
const accountManagers = [];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { secret, salt, signingKey } = accountsData[i];
|
|
8
|
-
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
9
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
10
|
-
await deployMethod.send({
|
|
11
|
-
from: AztecAddress.ZERO,
|
|
12
|
-
skipClassPublication: i !== 0,
|
|
13
|
-
wait: waitOptions
|
|
14
|
-
});
|
|
15
|
-
accountManagers.push(accountManager);
|
|
8
|
+
for (const { secret, salt, signingKey } of accountsData){
|
|
9
|
+
accountManagers.push(await wallet.createSchnorrInitializerlessAccount(secret, salt, signingKey));
|
|
16
10
|
}
|
|
17
11
|
return accountManagers;
|
|
18
12
|
}
|
|
19
13
|
export async function registerInitialLocalNetworkAccountsInWallet(wallet) {
|
|
20
14
|
const testAccounts = await getInitialTestAccountsData();
|
|
21
15
|
return Promise.all(testAccounts.map(async (account)=>{
|
|
22
|
-
return (await wallet.
|
|
16
|
+
return (await wallet.createSchnorrInitializerlessAccount(account.secret, account.salt, account.signingKey)).address;
|
|
23
17
|
}));
|
|
24
18
|
}
|
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": "5.0.0-
|
|
4
|
+
"version": "5.0.0-rc.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./embedded": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"default": "./dest/embedded/entrypoints/node.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
+
"./embedded/store-encryption": "./dest/embedded/store_encryption.js",
|
|
17
18
|
"./testing": "./dest/testing.js"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
@@ -27,15 +28,16 @@
|
|
|
27
28
|
"../package.common.json"
|
|
28
29
|
],
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@aztec/accounts": "5.0.0-
|
|
31
|
-
"@aztec/aztec.js": "5.0.0-
|
|
32
|
-
"@aztec/entrypoints": "5.0.0-
|
|
33
|
-
"@aztec/foundation": "5.0.0-
|
|
34
|
-
"@aztec/kv-store": "5.0.0-
|
|
35
|
-
"@aztec/protocol-contracts": "5.0.0-
|
|
36
|
-
"@aztec/pxe": "5.0.0-
|
|
37
|
-
"@aztec/
|
|
38
|
-
"@aztec/
|
|
31
|
+
"@aztec/accounts": "5.0.0-rc.1",
|
|
32
|
+
"@aztec/aztec.js": "5.0.0-rc.1",
|
|
33
|
+
"@aztec/entrypoints": "5.0.0-rc.1",
|
|
34
|
+
"@aztec/foundation": "5.0.0-rc.1",
|
|
35
|
+
"@aztec/kv-store": "5.0.0-rc.1",
|
|
36
|
+
"@aztec/protocol-contracts": "5.0.0-rc.1",
|
|
37
|
+
"@aztec/pxe": "5.0.0-rc.1",
|
|
38
|
+
"@aztec/standard-contracts": "5.0.0-rc.1",
|
|
39
|
+
"@aztec/stdlib": "5.0.0-rc.1",
|
|
40
|
+
"@aztec/wallet-sdk": "5.0.0-rc.1"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@jest/globals": "^30.0.0",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/ecdsa/stub';
|
|
3
|
+
import { SchnorrAccountContract, SchnorrInitializerlessAccountContract } from '@aztec/accounts/schnorr';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/schnorr/stub';
|
|
4
5
|
import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
5
6
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi-call-entrypoint';
|
|
7
7
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
8
|
-
import type { CompleteAddress
|
|
8
|
+
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
9
9
|
|
|
10
|
+
import type { AccountType } from '../wallet_db.js';
|
|
10
11
|
import type { AccountContractsProvider } from './types.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -18,6 +19,10 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
18
19
|
return Promise.resolve(new SchnorrAccountContract(signingKey));
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
getSchnorrInitializerlessAccountContract(signingKey: Fq): Promise<AccountContract> {
|
|
23
|
+
return Promise.resolve(new SchnorrInitializerlessAccountContract(signingKey));
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract> {
|
|
22
27
|
return Promise.resolve(new EcdsaRAccountContract(signingKey));
|
|
23
28
|
}
|
|
@@ -26,15 +31,11 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
26
31
|
return Promise.resolve(new EcdsaKAccountContract(signingKey));
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact> {
|
|
30
|
-
return Promise.resolve(
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
createStubAccount(address: CompleteAddress): Promise<Account> {
|
|
34
|
-
return Promise.resolve(createStubAccount(address));
|
|
34
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
35
|
+
return Promise.resolve(type === 'schnorr' ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
return
|
|
38
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
39
|
+
return Promise.resolve(type === 'schnorr' ? createStubSchnorrAccount(address) : createStubEcdsaAccount(address));
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { getCanonicalMultiCallEntrypoint } from '@aztec/protocol-contracts/multi-call-entrypoint/lazy';
|
|
4
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
-
import type { CompleteAddress
|
|
4
|
+
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
5
|
|
|
6
|
+
import type { AccountType } from '../wallet_db.js';
|
|
7
7
|
import type { AccountContractsProvider } from './types.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -16,6 +16,11 @@ export class LazyAccountContractsProvider implements AccountContractsProvider {
|
|
|
16
16
|
return new SchnorrAccountContract(signingKey);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
async getSchnorrInitializerlessAccountContract(signingKey: Fq): Promise<AccountContract> {
|
|
20
|
+
const { SchnorrInitializerlessAccountContract } = await import('@aztec/accounts/schnorr/lazy');
|
|
21
|
+
return new SchnorrInitializerlessAccountContract(signingKey);
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
async getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract> {
|
|
20
25
|
const { EcdsaRAccountContract } = await import('@aztec/accounts/ecdsa/lazy');
|
|
21
26
|
return new EcdsaRAccountContract(signingKey);
|
|
@@ -26,17 +31,23 @@ export class LazyAccountContractsProvider implements AccountContractsProvider {
|
|
|
26
31
|
return new EcdsaKAccountContract(signingKey);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
async getStubAccountContractArtifact(): Promise<ContractArtifact> {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
async getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
35
|
+
if (type === 'schnorr') {
|
|
36
|
+
const { getStubSchnorrAccountContractArtifact } = await import('@aztec/accounts/schnorr/stub/lazy');
|
|
37
|
+
return getStubSchnorrAccountContractArtifact();
|
|
38
|
+
} else {
|
|
39
|
+
const { getStubEcdsaAccountContractArtifact } = await import('@aztec/accounts/ecdsa/stub/lazy');
|
|
40
|
+
return getStubEcdsaAccountContractArtifact();
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
async createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
45
|
+
if (type === 'schnorr') {
|
|
46
|
+
const { createStubSchnorrAccount } = await import('@aztec/accounts/schnorr/stub/lazy');
|
|
47
|
+
return createStubSchnorrAccount(address);
|
|
48
|
+
} else {
|
|
49
|
+
const { createStubEcdsaAccount } = await import('@aztec/accounts/ecdsa/stub/lazy');
|
|
50
|
+
return createStubEcdsaAccount(address);
|
|
51
|
+
}
|
|
41
52
|
}
|
|
42
53
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
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
|
-
import type { CompleteAddress
|
|
4
|
+
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
|
|
6
|
+
import type { AccountType } from '../wallet_db.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Provides account contract implementations and stub accounts for the EmbeddedWallet.
|
|
@@ -11,9 +13,9 @@ import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib
|
|
|
11
13
|
*/
|
|
12
14
|
export interface AccountContractsProvider {
|
|
13
15
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
16
|
+
getSchnorrInitializerlessAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
14
17
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
15
18
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
16
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact>;
|
|
17
|
-
|
|
18
|
-
createStubAccount(address: CompleteAddress): Promise<Account>;
|
|
19
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
20
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account>;
|
|
19
21
|
}
|