@aztec/wallets 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316
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 +2 -1
- package/dest/embedded/account-contract-providers/bundle.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/bundle.js +10 -5
- package/dest/embedded/account-contract-providers/lazy.d.ts +2 -1
- package/dest/embedded/account-contract-providers/lazy.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/lazy.js +10 -6
- package/dest/embedded/account-contract-providers/types.d.ts +2 -1
- package/dest/embedded/account-contract-providers/types.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.d.ts +5 -6
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +53 -17
- 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 +21 -18
- 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 +24 -12
- package/dest/embedded/store_encryption.d.ts +9 -2
- package/dest/embedded/store_encryption.d.ts.map +1 -1
- package/dest/embedded/store_encryption.js +27 -5
- package/dest/embedded/wallet_db.d.ts +5 -3
- package/dest/embedded/wallet_db.d.ts.map +1 -1
- package/dest/embedded/wallet_db.js +4 -2
- package/dest/testing.d.ts +8 -4
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +8 -14
- package/package.json +11 -11
- package/src/embedded/account-contract-providers/bundle.ts +11 -5
- package/src/embedded/account-contract-providers/lazy.ts +11 -6
- package/src/embedded/account-contract-providers/types.ts +1 -0
- package/src/embedded/embedded_wallet.ts +42 -25
- package/src/embedded/entrypoints/browser.ts +26 -28
- package/src/embedded/entrypoints/node.ts +33 -27
- package/src/embedded/store_encryption.ts +42 -3
- package/src/embedded/wallet_db.ts +6 -3
- package/src/testing.ts +11 -17
|
@@ -39,6 +39,13 @@ export interface OpenEncryptedEmbeddedStoresOptions {
|
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
export type OpenSqliteEncryptedStoreFn = (log: Logger, name: string, poolDirectory: string | undefined, encryptionKey: Uint8Array) => Promise<AztecSQLiteOPFSStore>;
|
|
42
|
+
/**
|
|
43
|
+
* Internal seam for tests to inject a fake store wiper. Defaults to removing the store's OPFS pool directory
|
|
44
|
+
* outright. Not part of the public API.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export type WipeSqliteStoreFn = (poolDirectory: string | undefined) => Promise<void>;
|
|
42
49
|
/**
|
|
43
50
|
* Opens the PXE and wallet stores in sequence, both encrypted with keys obtained from `getEncryptionKey`.
|
|
44
51
|
*
|
|
@@ -60,8 +67,8 @@ export type OpenSqliteEncryptedStoreFn = (log: Logger, name: string, poolDirecto
|
|
|
60
67
|
* @param log - Logger for both stores.
|
|
61
68
|
* @param openStore - Internal test seam. Do not pass in production code.
|
|
62
69
|
*/
|
|
63
|
-
export declare function openEncryptedEmbeddedStores(config: OpenEncryptedEmbeddedStoresOptions, getEncryptionKey: () => Promise<Uint8Array>, log: Logger, openStore?: OpenSqliteEncryptedStoreFn): Promise<{
|
|
70
|
+
export declare function openEncryptedEmbeddedStores(config: OpenEncryptedEmbeddedStoresOptions, getEncryptionKey: () => Promise<Uint8Array>, log: Logger, openStore?: OpenSqliteEncryptedStoreFn, wipeStore?: WipeSqliteStoreFn): Promise<{
|
|
64
71
|
pxeStore: AztecSQLiteOPFSStore;
|
|
65
72
|
walletStore: AztecSQLiteOPFSStore;
|
|
66
73
|
}>;
|
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVfZW5jcnlwdGlvbi5kLnRzIiwic291cmNlUm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ENBQUMsb0JBQW9CLENBQUMsQ0FBQztBQUtuQzs7Ozs7R0FLRztBQUNILE1BQU0sTUFBTSxpQkFBaUIsR0FBRyxDQUFDLGFBQWEsRUFBRSxNQUFNLEdBQUcsU0FBUyxLQUFLLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztBQWdCckY7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBb0JHO0FBQ0gsd0JBQXNCLDJCQUEyQixDQUMvQyxNQUFNLEVBQUUsa0NBQWtDLEVBQzFDLGdCQUFnQixFQUFFLE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQyxFQUMzQyxHQUFHLEVBQUUsTUFBTSxFQUNYLFNBQVMsR0FBRSwwQkFBNkMsRUFDeEQsU0FBUyxHQUFFLGlCQUFvQyxHQUM5QyxPQUFPLENBQUM7SUFBRSxRQUFRLEVBQUUsb0JBQW9CLENBQUM7SUFBQyxXQUFXLEVBQUUsb0JBQW9CLENBQUE7Q0FBRSxDQUFDLENBV2hGIn0=
|
|
@@ -1 +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,
|
|
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,EACL,oBAAoB,EAEpB,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAErC,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;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAgBrF;;;;;;;;;;;;;;;;;;;;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,EACxD,SAAS,GAAE,iBAAoC,GAC9C,OAAO,CAAC;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,WAAW,EAAE,oBAAoB,CAAA;CAAE,CAAC,CAWhF"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - `storeName: 'pxe' | 'wallet'`, telling callers WHICH store failed.
|
|
7
7
|
* - Cleanup: when the wallet store fails to open, ensures the already-opened PXE store is closed before the error
|
|
8
8
|
* surfaces, so callers don't leak the SAH Pool's OPFS lock.
|
|
9
|
-
*/ import { AztecSQLiteOPFSStore, SqliteEncryptionError } from '@aztec/kv-store/sqlite-opfs';
|
|
9
|
+
*/ import { AztecSQLiteOPFSStore, SqliteCorruptionError, SqliteEncryptionError, deletePoolDirectory } from '@aztec/kv-store/sqlite-opfs';
|
|
10
10
|
/**
|
|
11
11
|
* Thrown by {@link openEncryptedEmbeddedStores} when one of the two stores cannot be decrypted with the supplied
|
|
12
12
|
* key. The original {@link SqliteEncryptionError} is preserved as `cause`.
|
|
@@ -21,6 +21,18 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
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
|
+
};
|
|
24
36
|
/**
|
|
25
37
|
* Opens the PXE and wallet stores in sequence, both encrypted with keys obtained from `getEncryptionKey`.
|
|
26
38
|
*
|
|
@@ -41,10 +53,10 @@ const defaultOpenStore = (log, name, poolDirectory, encryptionKey)=>AztecSQLiteO
|
|
|
41
53
|
* detaches on transfer, so each call must allocate).
|
|
42
54
|
* @param log - Logger for both stores.
|
|
43
55
|
* @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);
|
|
56
|
+
*/ export async function openEncryptedEmbeddedStores(config, getEncryptionKey, log, openStore = defaultOpenStore, wipeStore = defaultWipeStore) {
|
|
57
|
+
const pxeStore = await openOneStore('pxe', config.pxe, getEncryptionKey, log, openStore, wipeStore);
|
|
46
58
|
try {
|
|
47
|
-
const walletStore = await openOneStore('wallet', config.wallet, getEncryptionKey, log, openStore);
|
|
59
|
+
const walletStore = await openOneStore('wallet', config.wallet, getEncryptionKey, log, openStore, wipeStore);
|
|
48
60
|
return {
|
|
49
61
|
pxeStore,
|
|
50
62
|
walletStore
|
|
@@ -56,7 +68,7 @@ const defaultOpenStore = (log, name, poolDirectory, encryptionKey)=>AztecSQLiteO
|
|
|
56
68
|
throw err;
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
|
-
async function openOneStore(storeName, { name, poolDirectory }, getEncryptionKey, log, openStore) {
|
|
71
|
+
async function openOneStore(storeName, { name, poolDirectory }, getEncryptionKey, log, openStore, wipeStore) {
|
|
60
72
|
const key = await getEncryptionKey();
|
|
61
73
|
try {
|
|
62
74
|
return await openStore(log, name, poolDirectory, key);
|
|
@@ -66,6 +78,16 @@ async function openOneStore(storeName, { name, poolDirectory }, getEncryptionKey
|
|
|
66
78
|
cause: err
|
|
67
79
|
});
|
|
68
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
|
+
}
|
|
69
91
|
throw err;
|
|
70
92
|
}
|
|
71
93
|
}
|
|
@@ -3,8 +3,10 @@ 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;
|
|
10
12
|
private store;
|
|
@@ -24,7 +26,7 @@ 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>[]>;
|
|
@@ -32,4 +34,4 @@ export declare class WalletDB {
|
|
|
32
34
|
deleteAccount(address: AztecAddress): Promise<void>;
|
|
33
35
|
close(): Promise<void>;
|
|
34
36
|
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X2RiLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvd2FsbGV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BRyxNQUFNLENBQUM7UUFDeEIsS0FBSyxFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUM7S0FDM0IsRUFDRCxHQUFHLEdBQUUsS0FBb0IsaUJBYTFCO0lBRUssV0FBVyxDQUFDLE9BQU8sRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxHQUFHLEdBQUUsS0FBb0IsaUJBR2hGO0lBRUssZUFBZSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsTUFBTTs7Ozs7O09BY25EO0lBRUssWUFBWSxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsWUFBWSxDQUFDLEVBQUUsQ0FBQyxDQVdyRDtJQUVLLFdBQVcsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxFQUFFLENBQUMsQ0FTcEQ7SUFvQkssYUFBYSxDQUFDLE9BQU8sRUFBRSxZQUFZLGlCQWF4QztJQUVLLEtBQUssa0JBRVY7Q0FDRiJ9
|
|
@@ -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,wBAAwB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,EAAE,EAA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K,KAAK,kBAEV;CACF"}
|
|
@@ -2,12 +2,14 @@ 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 {
|
|
12
14
|
store;
|
|
13
15
|
userLog;
|
|
@@ -62,7 +64,7 @@ export class WalletDB {
|
|
|
62
64
|
]);
|
|
63
65
|
return accountAddresses.map((addressStr)=>({
|
|
64
66
|
alias: aliasesByAddress.get(addressStr) ?? '',
|
|
65
|
-
item: AztecAddress.
|
|
67
|
+
item: AztecAddress.fromStringUnsafe(addressStr)
|
|
66
68
|
}));
|
|
67
69
|
}
|
|
68
70
|
async listSenders() {
|
|
@@ -73,7 +75,7 @@ export class WalletDB {
|
|
|
73
75
|
})){
|
|
74
76
|
result.push({
|
|
75
77
|
alias: alias.slice('senders:'.length),
|
|
76
|
-
item: AztecAddress.
|
|
78
|
+
item: AztecAddress.fromStringUnsafe(item.toString())
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
return result;
|
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.be03c316",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./embedded": {
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
32
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
33
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
34
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
35
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
36
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
37
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
38
|
-
"@aztec/standard-contracts": "0.0.1-commit.
|
|
39
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
40
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
31
|
+
"@aztec/accounts": "0.0.1-commit.be03c316",
|
|
32
|
+
"@aztec/aztec.js": "0.0.1-commit.be03c316",
|
|
33
|
+
"@aztec/entrypoints": "0.0.1-commit.be03c316",
|
|
34
|
+
"@aztec/foundation": "0.0.1-commit.be03c316",
|
|
35
|
+
"@aztec/kv-store": "0.0.1-commit.be03c316",
|
|
36
|
+
"@aztec/protocol-contracts": "0.0.1-commit.be03c316",
|
|
37
|
+
"@aztec/pxe": "0.0.1-commit.be03c316",
|
|
38
|
+
"@aztec/standard-contracts": "0.0.1-commit.be03c316",
|
|
39
|
+
"@aztec/stdlib": "0.0.1-commit.be03c316",
|
|
40
|
+
"@aztec/wallet-sdk": "0.0.1-commit.be03c316"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "^30.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub
|
|
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';
|
|
5
5
|
import type { Account, AccountContract } from '@aztec/aztec.js/account';
|
|
6
6
|
import type { Fq } from '@aztec/foundation/curves/bn254';
|
|
7
7
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
@@ -19,6 +19,10 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
19
19
|
return Promise.resolve(new SchnorrAccountContract(signingKey));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
getSchnorrInitializerlessAccountContract(signingKey: Fq): Promise<AccountContract> {
|
|
23
|
+
return Promise.resolve(new SchnorrInitializerlessAccountContract(signingKey));
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract> {
|
|
23
27
|
return Promise.resolve(new EcdsaRAccountContract(signingKey));
|
|
24
28
|
}
|
|
@@ -28,10 +32,12 @@ export class BundleAccountContractsProvider implements AccountContractsProvider
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
31
|
-
|
|
35
|
+
const isSchnorr = type === 'schnorr' || type === 'schnorr_initializerless';
|
|
36
|
+
return Promise.resolve(isSchnorr ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
35
|
-
|
|
40
|
+
const isSchnorr = type === 'schnorr' || type === 'schnorr_initializerless';
|
|
41
|
+
return Promise.resolve(isSchnorr ? createStubSchnorrAccount(address) : createStubEcdsaAccount(address));
|
|
36
42
|
}
|
|
37
43
|
}
|
|
@@ -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);
|
|
@@ -27,21 +32,21 @@ export class LazyAccountContractsProvider implements AccountContractsProvider {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
async getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact> {
|
|
30
|
-
if (type === 'schnorr') {
|
|
31
|
-
const { getStubSchnorrAccountContractArtifact } = await import('@aztec/accounts/stub/
|
|
35
|
+
if (type === 'schnorr' || type === 'schnorr_initializerless') {
|
|
36
|
+
const { getStubSchnorrAccountContractArtifact } = await import('@aztec/accounts/schnorr/stub/lazy');
|
|
32
37
|
return getStubSchnorrAccountContractArtifact();
|
|
33
38
|
} else {
|
|
34
|
-
const { getStubEcdsaAccountContractArtifact } = await import('@aztec/accounts/stub/
|
|
39
|
+
const { getStubEcdsaAccountContractArtifact } = await import('@aztec/accounts/ecdsa/stub/lazy');
|
|
35
40
|
return getStubEcdsaAccountContractArtifact();
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
async createStubAccount(address: CompleteAddress, type: AccountType): Promise<Account> {
|
|
40
|
-
if (type === 'schnorr') {
|
|
41
|
-
const { createStubSchnorrAccount } = await import('@aztec/accounts/stub/
|
|
45
|
+
if (type === 'schnorr' || type === 'schnorr_initializerless') {
|
|
46
|
+
const { createStubSchnorrAccount } = await import('@aztec/accounts/schnorr/stub/lazy');
|
|
42
47
|
return createStubSchnorrAccount(address);
|
|
43
48
|
} else {
|
|
44
|
-
const { createStubEcdsaAccount } = await import('@aztec/accounts/stub/
|
|
49
|
+
const { createStubEcdsaAccount } = await import('@aztec/accounts/ecdsa/stub/lazy');
|
|
45
50
|
return createStubEcdsaAccount(address);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -13,6 +13,7 @@ import type { AccountType } from '../wallet_db.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export interface AccountContractsProvider {
|
|
15
15
|
getSchnorrAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
16
|
+
getSchnorrInitializerlessAccountContract(signingKey: Fq): Promise<AccountContract>;
|
|
16
17
|
getEcdsaRAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
17
18
|
getEcdsaKAccountContract(signingKey: Buffer): Promise<AccountContract>;
|
|
18
19
|
getStubAccountContractArtifact(type: AccountType): Promise<ContractArtifact>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Account, NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import {
|
|
4
|
+
ContractFunctionInteraction,
|
|
4
5
|
type InteractionWaitOptions,
|
|
5
6
|
NO_WAIT,
|
|
6
7
|
type SendReturn,
|
|
7
8
|
type WaitOpts,
|
|
8
|
-
getGasLimits,
|
|
9
9
|
} from '@aztec/aztec.js/contracts';
|
|
10
10
|
import type {
|
|
11
11
|
Aliased,
|
|
@@ -19,17 +19,18 @@ import type {
|
|
|
19
19
|
import { AccountManager, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
20
20
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
21
21
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
22
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
23
|
+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
22
24
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
23
25
|
import type { Logger } from '@aztec/foundation/log';
|
|
24
26
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
25
27
|
import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
26
28
|
import type { PXE } from '@aztec/pxe/server';
|
|
27
|
-
import type {
|
|
29
|
+
import type { EventMetadataDefinition, FunctionCall } from '@aztec/stdlib/abi';
|
|
28
30
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
29
|
-
import {
|
|
31
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
30
32
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
31
33
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
32
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
33
34
|
import {
|
|
34
35
|
type ContractOverrides,
|
|
35
36
|
ExecutionPayload,
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
collectOffchainEffects,
|
|
42
43
|
mergeExecutionPayloads,
|
|
43
44
|
} from '@aztec/stdlib/tx';
|
|
44
|
-
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
45
|
+
import { BaseWallet, type SimulateViaEntrypointOptions, getGasLimits } from '@aztec/wallet-sdk/base-wallet';
|
|
45
46
|
|
|
46
47
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
47
48
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
@@ -129,15 +130,17 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
129
130
|
|
|
130
131
|
override async registerSender(address: AztecAddress, alias: string) {
|
|
131
132
|
await this.walletDB.storeSender(address, alias);
|
|
132
|
-
|
|
133
|
+
await this.pxe.registerTaggingSecretSource({ kind: 'address-derived', sender: address });
|
|
134
|
+
return address;
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
override async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
|
|
136
|
-
const
|
|
138
|
+
const sources = await this.pxe.getTaggingSecretSources({ kind: 'address-derived' });
|
|
139
|
+
const senders = sources.map(source => source.sender);
|
|
137
140
|
const storedSenders = await this.walletDB.listSenders();
|
|
138
141
|
for (const storedSender of storedSenders) {
|
|
139
142
|
if (senders.findIndex(sender => sender.equals(storedSender.item)) === -1) {
|
|
140
|
-
await this.pxe.
|
|
143
|
+
await this.pxe.registerTaggingSecretSource({ kind: 'address-derived', sender: storedSender.item });
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
return storedSenders;
|
|
@@ -191,7 +194,8 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
191
194
|
executionPayload.authWitnesses.push(authwit);
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
|
-
const
|
|
197
|
+
const maxTxGasLimits = await this.getMaxTxGasLimits();
|
|
198
|
+
const estimated = getGasLimits(simulationResult.gasUsed, maxTxGasLimits, this.estimatedGasPadding);
|
|
195
199
|
this.log.verbose(
|
|
196
200
|
`Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`,
|
|
197
201
|
);
|
|
@@ -258,17 +262,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
258
262
|
return super.getPrivateEvents<T>(eventDef, eventFilter);
|
|
259
263
|
}
|
|
260
264
|
|
|
261
|
-
public override async registerContract(
|
|
262
|
-
instance: ContractInstanceWithAddress,
|
|
263
|
-
artifact?: ContractArtifact,
|
|
264
|
-
secretKey?: Fr,
|
|
265
|
-
): Promise<ContractInstanceWithAddress> {
|
|
266
|
-
// registerContract may call pxe.updateContract under the hood, which depends on a fresh anchor
|
|
267
|
-
// block to verify the current class id from the node.
|
|
268
|
-
await this.pxe.sync();
|
|
269
|
-
return super.registerContract(instance, artifact, secretKey);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
265
|
/**
|
|
273
266
|
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
274
267
|
* stubClassIds. Called on wallet initialization.
|
|
@@ -284,6 +277,7 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
284
277
|
await this.pxe.registerContractClass(ecdsaArtifact);
|
|
285
278
|
|
|
286
279
|
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
280
|
+
this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
|
|
287
281
|
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
288
282
|
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
289
283
|
}
|
|
@@ -335,7 +329,7 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
335
329
|
opts: SimulateViaEntrypointOptions,
|
|
336
330
|
): Promise<TxSimulationResultWithAppOffset> {
|
|
337
331
|
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
|
|
338
|
-
const scopes = this.scopesFrom(from, additionalScopes);
|
|
332
|
+
const scopes = this.scopesFrom(from, additionalScopes ?? [], sendMessagesAs);
|
|
339
333
|
|
|
340
334
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
341
335
|
const finalExecutionPayload = feeExecutionPayload
|
|
@@ -388,11 +382,19 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
388
382
|
signingKey: Buffer,
|
|
389
383
|
): Promise<AccountManager> {
|
|
390
384
|
let contract;
|
|
385
|
+
let immutablesHash;
|
|
386
|
+
let publicKey;
|
|
391
387
|
switch (type) {
|
|
392
388
|
case 'schnorr': {
|
|
393
389
|
contract = await this.accountContracts.getSchnorrAccountContract(Fq.fromBuffer(signingKey));
|
|
394
390
|
break;
|
|
395
391
|
}
|
|
392
|
+
case 'schnorr_initializerless': {
|
|
393
|
+
contract = await this.accountContracts.getSchnorrInitializerlessAccountContract(Fq.fromBuffer(signingKey));
|
|
394
|
+
publicKey = await new Schnorr().computePublicKey(Fq.fromBuffer(signingKey));
|
|
395
|
+
immutablesHash = await poseidon2Hash([publicKey.x, publicKey.y]);
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
396
398
|
case 'ecdsasecp256k1': {
|
|
397
399
|
contract = await this.accountContracts.getEcdsaKAccountContract(signingKey);
|
|
398
400
|
break;
|
|
@@ -406,17 +408,29 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
406
408
|
}
|
|
407
409
|
}
|
|
408
410
|
|
|
409
|
-
const accountManager = await AccountManager.create(this, secret, contract, { salt });
|
|
411
|
+
const accountManager = await AccountManager.create(this, secret, contract, { salt, immutablesHash });
|
|
410
412
|
|
|
411
413
|
const instance = accountManager.getInstance();
|
|
412
414
|
const existingInstance = await this.pxe.getContractInstance(instance.address);
|
|
413
415
|
if (!existingInstance) {
|
|
414
416
|
const existingArtifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
|
|
417
|
+
const artifact = existingArtifact ?? (await accountManager.getAccountContract().getContractArtifact());
|
|
415
418
|
await this.registerContract(
|
|
416
419
|
instance,
|
|
417
420
|
!existingArtifact ? await accountManager.getAccountContract().getContractArtifact() : undefined,
|
|
418
421
|
accountManager.getSecretKey(),
|
|
419
422
|
);
|
|
423
|
+
if (type === 'schnorr_initializerless') {
|
|
424
|
+
const constructor = artifact.functions.find(f => f.name === 'constructor');
|
|
425
|
+
if (!constructor) {
|
|
426
|
+
throw new Error('Could not create SchnorrInitializerlessAccountContract: constructor ABI not found');
|
|
427
|
+
}
|
|
428
|
+
const storeCall = new ContractFunctionInteraction(this, instance.address, constructor, [
|
|
429
|
+
publicKey!.x,
|
|
430
|
+
publicKey!.y,
|
|
431
|
+
]);
|
|
432
|
+
await storeCall.simulate({ from: instance.address });
|
|
433
|
+
}
|
|
420
434
|
}
|
|
421
435
|
return accountManager;
|
|
422
436
|
}
|
|
@@ -433,9 +447,12 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
433
447
|
return accountManager;
|
|
434
448
|
}
|
|
435
449
|
|
|
436
|
-
createSchnorrAccount(secret: Fr, salt: Fr, signingKey
|
|
437
|
-
|
|
438
|
-
|
|
450
|
+
createSchnorrAccount(secret: Fr, salt: Fr, signingKey: Fq, alias?: string): Promise<AccountManager> {
|
|
451
|
+
return this.createAndStoreAccount(alias ?? '', 'schnorr', secret, salt, signingKey.toBuffer());
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
createSchnorrInitializerlessAccount(secret: Fr, salt: Fr, signingKey: Fq, alias?: string): Promise<AccountManager> {
|
|
455
|
+
return this.createAndStoreAccount(alias ?? '', 'schnorr_initializerless', secret, salt, signingKey.toBuffer());
|
|
439
456
|
}
|
|
440
457
|
|
|
441
458
|
createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer, alias?: string): Promise<AccountManager> {
|