@aztec/wallets 0.0.1-commit.d1da697d6 → 0.0.1-commit.d58ff9d0
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 +12 -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 +32 -6
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +146 -41
- package/dest/embedded/entrypoints/browser.d.ts +1 -1
- package/dest/embedded/entrypoints/browser.d.ts.map +1 -1
- package/dest/embedded/entrypoints/browser.js +33 -13
- package/dest/embedded/entrypoints/node.d.ts +1 -1
- package/dest/embedded/entrypoints/node.d.ts.map +1 -1
- package/dest/embedded/entrypoints/node.js +36 -13
- package/dest/embedded/store_encryption.d.ts +74 -0
- package/dest/embedded/store_encryption.d.ts.map +1 -0
- package/dest/embedded/store_encryption.js +93 -0
- package/dest/embedded/wallet_db.d.ts +9 -6
- package/dest/embedded/wallet_db.d.ts.map +1 -1
- package/dest/embedded/wallet_db.js +13 -11
- package/dest/testing.d.ts +8 -4
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +8 -14
- package/package.json +12 -10
- package/src/embedded/account-contract-providers/bundle.ts +15 -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 +175 -45
- package/src/embedded/entrypoints/browser.ts +32 -17
- package/src/embedded/entrypoints/node.ts +37 -21
- package/src/embedded/store_encryption.ts +146 -0
- package/src/embedded/wallet_db.ts +18 -12
- package/src/testing.ts +11 -17
|
@@ -0,0 +1,93 @@
|
|
|
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, SqliteCorruptionError, SqliteEncryptionError, deletePoolDirectory } 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
|
+
* Deletes a store's OPFS pool directory. Safe to call only after a *failed* open() — a live store's SAH pool holds
|
|
26
|
+
* a lock on the directory and the removal would reject. A store with no `poolDirectory` lives in the shared default
|
|
27
|
+
* pool, which we won't blow away (it would take unrelated stores with it), so wiping is a no-op there.
|
|
28
|
+
*/ const defaultWipeStore = async (poolDirectory)=>{
|
|
29
|
+
if (!poolDirectory) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
await deletePoolDirectory(poolDirectory).catch(()=>{
|
|
33
|
+
// Already gone / never created — nothing to wipe.
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Opens the PXE and wallet stores in sequence, both encrypted with keys obtained from `getEncryptionKey`.
|
|
38
|
+
*
|
|
39
|
+
* The callback is invoked once per store (twice total per call) because `AztecSQLiteOPFSStore.open` *transfers*
|
|
40
|
+
* the key buffer to its worker. A single buffer would detach between the two opens.
|
|
41
|
+
*
|
|
42
|
+
* Failure modes:
|
|
43
|
+
*
|
|
44
|
+
* - PXE store fails to decrypt → throws `EmbeddedWalletEncryptionError({ storeName: 'pxe', cause })`. No cleanup
|
|
45
|
+
* needed (nothing was opened).
|
|
46
|
+
* - Wallet store fails to decrypt → closes the already-opened PXE store then throws
|
|
47
|
+
* `EmbeddedWalletEncryptionError({ storeName: 'wallet', cause })`.
|
|
48
|
+
* - Any non-decrypt error during the wallet open → still closes PXE, then re-throws the original error unwrapped
|
|
49
|
+
* (preserves callers' existing untyped error handling for non-encryption faults).
|
|
50
|
+
*
|
|
51
|
+
* @param config - Per-store name/poolDirectory.
|
|
52
|
+
* @param getEncryptionKey - Returns a fresh 32-byte key per call (the buffer
|
|
53
|
+
* detaches on transfer, so each call must allocate).
|
|
54
|
+
* @param log - Logger for both stores.
|
|
55
|
+
* @param openStore - Internal test seam. Do not pass in production code.
|
|
56
|
+
*/ export async function openEncryptedEmbeddedStores(config, getEncryptionKey, log, openStore = defaultOpenStore, wipeStore = defaultWipeStore) {
|
|
57
|
+
const pxeStore = await openOneStore('pxe', config.pxe, getEncryptionKey, log, openStore, wipeStore);
|
|
58
|
+
try {
|
|
59
|
+
const walletStore = await openOneStore('wallet', config.wallet, getEncryptionKey, log, openStore, wipeStore);
|
|
60
|
+
return {
|
|
61
|
+
pxeStore,
|
|
62
|
+
walletStore
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
// Cleanup is best-effort — if close() itself throws (e.g. worker already dead), swallow it so the original error
|
|
66
|
+
// surfaces unobstructed.
|
|
67
|
+
await pxeStore.close().catch(()=>{});
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function openOneStore(storeName, { name, poolDirectory }, getEncryptionKey, log, openStore, wipeStore) {
|
|
72
|
+
const key = await getEncryptionKey();
|
|
73
|
+
try {
|
|
74
|
+
return await openStore(log, name, poolDirectory, key);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
if (err instanceof SqliteEncryptionError && err.code === 'decrypt_failed') {
|
|
77
|
+
throw new EmbeddedWalletEncryptionError(storeName, {
|
|
78
|
+
cause: err
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (err instanceof SqliteCorruptionError) {
|
|
82
|
+
// A corrupt image is unrecoverable — no key or retry against the same bytes brings it back. Self-heal
|
|
83
|
+
// instead of dead-ending forever: wipe the store's OPFS directory (safe — the failed open left no SAH-pool
|
|
84
|
+
// lock behind) and reopen a fresh, empty one, so callers see a normal first-run rather than a permanent
|
|
85
|
+
// "database disk image is malformed" on every open.
|
|
86
|
+
log.warn(`Embedded wallet '${storeName}' store is corrupt (${err.message}); wiping and reopening fresh`);
|
|
87
|
+
await wipeStore(poolDirectory);
|
|
88
|
+
// open() transferred (detached) the previous key buffer, so fetch a fresh one for the reopen.
|
|
89
|
+
return await openStore(log, name, poolDirectory, await getEncryptionKey());
|
|
90
|
+
}
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -3,15 +3,17 @@ 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
|
+
/** Bump when the WalletDB layout changes; a new version selects a fresh store, leaving the old one intact. */
|
|
9
|
+
export declare const WALLET_DATA_SCHEMA_VERSION = 1;
|
|
8
10
|
export declare class WalletDB {
|
|
9
11
|
#private;
|
|
12
|
+
private store;
|
|
13
|
+
private userLog;
|
|
10
14
|
private accounts;
|
|
11
15
|
private aliases;
|
|
12
|
-
|
|
13
|
-
private constructor();
|
|
14
|
-
static init(store: AztecAsyncKVStore, userLog: LogFn): WalletDB;
|
|
16
|
+
constructor(store: AztecAsyncKVStore, userLog: LogFn);
|
|
15
17
|
storeAccount(address: AztecAddress, { type, secretKey, salt, alias, signingKey }: {
|
|
16
18
|
type: AccountType;
|
|
17
19
|
secretKey: Fr;
|
|
@@ -24,11 +26,12 @@ export declare class WalletDB {
|
|
|
24
26
|
address: string | AztecAddress;
|
|
25
27
|
secretKey: Fr;
|
|
26
28
|
salt: Fr;
|
|
27
|
-
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "schnorr";
|
|
29
|
+
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "schnorr" | "schnorr_initializerless";
|
|
28
30
|
signingKey: Buffer<ArrayBufferLike>;
|
|
29
31
|
}>;
|
|
30
32
|
listAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
31
33
|
listSenders(): Promise<Aliased<AztecAddress>[]>;
|
|
32
34
|
deleteAccount(address: AztecAddress): Promise<void>;
|
|
35
|
+
close(): Promise<void>;
|
|
33
36
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X2RiLmQudHMiLCJzb3VyY2VSb290IjoiIi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UsRUFBRSxDQUFDO1FBQ1QsVUFBVSxFQUFFLEVBQUUsR0FBRyxNQUFNLENBQUM7UUFDeEIsS0FBSyxFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUM7S0FDM0IsRUFDRCxHQUFHLEdBQUUsS0FBb0IsaUJBYTFCO0lBRUssV0FBVyxDQUFDLE9BQU8sRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxHQUFHLEdBQUUsS0FBb0IsaUJBR2hGO0lBRUssZUFBZSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsTUFBTTs7Ozs7O09BY25EO0lBRUssWUFBWSxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxDQVdyRDtJQUVLLFdBQVcsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsQ0FTcEQ7SUFvQkssYUFBYSxDQUFDLE9BQU8sRUFBRSxZQUFZLGlCQWF4QztJQUVLLEtBQUssa0JBRVY7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_db.d.ts","sourceRoot":"","sources":["../../src/embedded/wallet_db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"wallet_db.d.ts","sourceRoot":"","sources":["../../src/embedded/wallet_db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM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CASpD;IAoBK,aAAa,CAAC,OAAO,EAAE,YAAY,iBAaxC;IAEK,KAAK,kBAEV;CACF"}
|
|
@@ -2,25 +2,24 @@ 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
|
];
|
|
8
9
|
function accountKey(field, address) {
|
|
9
10
|
return `${field}:${address.toString()}`;
|
|
10
11
|
}
|
|
12
|
+
/** Bump when the WalletDB layout changes; a new version selects a fresh store, leaving the old one intact. */ export const WALLET_DATA_SCHEMA_VERSION = 1;
|
|
11
13
|
export class WalletDB {
|
|
14
|
+
store;
|
|
15
|
+
userLog;
|
|
12
16
|
accounts;
|
|
13
17
|
aliases;
|
|
14
|
-
userLog
|
|
15
|
-
|
|
16
|
-
this.accounts = accounts;
|
|
17
|
-
this.aliases = aliases;
|
|
18
|
+
constructor(store, userLog){
|
|
19
|
+
this.store = store;
|
|
18
20
|
this.userLog = userLog;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const accounts = store.openMap('accounts');
|
|
22
|
-
const aliases = store.openMap('aliases');
|
|
23
|
-
return new WalletDB(accounts, aliases, userLog);
|
|
21
|
+
this.accounts = store.openMap('accounts');
|
|
22
|
+
this.aliases = store.openMap('aliases');
|
|
24
23
|
}
|
|
25
24
|
async storeAccount(address, { type, secretKey, salt, alias, signingKey }, log = this.userLog) {
|
|
26
25
|
if (alias) {
|
|
@@ -65,7 +64,7 @@ export class WalletDB {
|
|
|
65
64
|
]);
|
|
66
65
|
return accountAddresses.map((addressStr)=>({
|
|
67
66
|
alias: aliasesByAddress.get(addressStr) ?? '',
|
|
68
|
-
item: AztecAddress.
|
|
67
|
+
item: AztecAddress.fromStringUnsafe(addressStr)
|
|
69
68
|
}));
|
|
70
69
|
}
|
|
71
70
|
async listSenders() {
|
|
@@ -76,7 +75,7 @@ export class WalletDB {
|
|
|
76
75
|
})){
|
|
77
76
|
result.push({
|
|
78
77
|
alias: alias.slice('senders:'.length),
|
|
79
|
-
item: AztecAddress.
|
|
78
|
+
item: AztecAddress.fromStringUnsafe(item.toString())
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
81
|
return result;
|
|
@@ -117,4 +116,7 @@ export class WalletDB {
|
|
|
117
116
|
await this.aliases.delete(`accounts:${alias}`);
|
|
118
117
|
}
|
|
119
118
|
}
|
|
119
|
+
async close() {
|
|
120
|
+
await this.store.close();
|
|
121
|
+
}
|
|
120
122
|
}
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVsRSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDN0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTNELFVBQVUseUJBQXlCO0lBQ2pDLG1DQUFtQyxDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLEtBQUssQ0FBQyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBQUM7Q0FDcEg7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQXNCLG1DQUFtQyxDQUN2RCxNQUFNLEVBQUUseUJBQXlCLEVBQ2pDLFlBQVksRUFBRSxrQkFBa0IsRUFBRSw2QkFPbkM7QUFFRCx3QkFBc0IsMkNBQTJDLENBQy9ELE1BQU0sRUFBRSx5QkFBeUIsR0FDaEMsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBUXpCIn0=
|
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;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,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACpH;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: NO_FROM,
|
|
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": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.d58ff9d0",
|
|
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": "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/
|
|
38
|
-
"@aztec/
|
|
31
|
+
"@aztec/accounts": "0.0.1-commit.d58ff9d0",
|
|
32
|
+
"@aztec/aztec.js": "0.0.1-commit.d58ff9d0",
|
|
33
|
+
"@aztec/entrypoints": "0.0.1-commit.d58ff9d0",
|
|
34
|
+
"@aztec/foundation": "0.0.1-commit.d58ff9d0",
|
|
35
|
+
"@aztec/kv-store": "0.0.1-commit.d58ff9d0",
|
|
36
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d58ff9d0",
|
|
37
|
+
"@aztec/pxe": "0.0.1-commit.d58ff9d0",
|
|
38
|
+
"@aztec/standard-contracts": "0.0.1-commit.d58ff9d0",
|
|
39
|
+
"@aztec/stdlib": "0.0.1-commit.d58ff9d0",
|
|
40
|
+
"@aztec/wallet-sdk": "0.0.1-commit.d58ff9d0"
|
|
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,13 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
26
31
|
return Promise.resolve(new EcdsaKAccountContract(signingKey));
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
getStubAccountContractArtifact(): Promise<ContractArtifact> {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
createStubAccount(address: CompleteAddress): Promise<Account> {
|
|
34
|
-
return Promise.resolve(createStubAccount(address));
|
|
34
|
+
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
35
|
+
const isSchnorr = type === 'schnorr' || type === 'schnorr_initializerless';
|
|
36
|
+
return Promise.resolve(isSchnorr ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
40
|
+
const isSchnorr = type === 'schnorr' || type === 'schnorr_initializerless';
|
|
41
|
+
return Promise.resolve(isSchnorr ? createStubSchnorrAccount(address) : createStubEcdsaAccount(address));
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -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' || type === 'schnorr_initializerless') {
|
|
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' || type === 'schnorr_initializerless') {
|
|
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
|
}
|