@aztec/wallets 0.0.1-commit.2e20a94 → 0.0.1-commit.3100065
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 +3 -6
- package/dest/embedded/account-contract-providers/bundle.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/bundle.js +10 -9
- package/dest/embedded/account-contract-providers/lazy.d.ts +3 -6
- package/dest/embedded/account-contract-providers/lazy.d.ts.map +1 -1
- package/dest/embedded/account-contract-providers/lazy.js +10 -10
- package/dest/embedded/account-contract-providers/types.d.ts +3 -6
- package/dest/embedded/account-contract-providers/types.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.d.ts +29 -4
- package/dest/embedded/embedded_wallet.d.ts.map +1 -1
- package/dest/embedded/embedded_wallet.js +135 -44
- 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 +20 -7
- 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 +19 -6
- package/dest/embedded/store_encryption.d.ts +67 -0
- package/dest/embedded/store_encryption.d.ts.map +1 -0
- package/dest/embedded/store_encryption.js +71 -0
- package/dest/embedded/wallet_db.d.ts +7 -6
- package/dest/embedded/wallet_db.d.ts.map +1 -1
- package/dest/embedded/wallet_db.js +12 -11
- package/dest/testing.d.ts +8 -4
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +8 -14
- package/package.json +12 -10
- package/src/embedded/account-contract-providers/bundle.ts +12 -11
- package/src/embedded/account-contract-providers/lazy.ts +12 -12
- package/src/embedded/account-contract-providers/types.ts +2 -2
- package/src/embedded/embedded_wallet.ts +162 -39
- package/src/embedded/entrypoints/browser.ts +31 -16
- package/src/embedded/entrypoints/node.ts +36 -21
- package/src/embedded/store_encryption.ts +107 -0
- package/src/embedded/wallet_db.ts +15 -12
- package/src/testing.ts +11 -17
|
@@ -4,7 +4,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
|
|
7
|
-
export const AccountTypes = ['schnorr', 'ecdsasecp256r1', 'ecdsasecp256k1'] as const;
|
|
7
|
+
export const AccountTypes = ['schnorr', 'schnorr_initializerless', 'ecdsasecp256r1', 'ecdsasecp256k1'] as const;
|
|
8
8
|
export type AccountType = (typeof AccountTypes)[number];
|
|
9
9
|
|
|
10
10
|
function accountKey(field: string, address: AztecAddress | string): string {
|
|
@@ -12,16 +12,15 @@ function accountKey(field: string, address: AztecAddress | string): string {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class WalletDB {
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
private aliases: AztecAsyncMap<string, Buffer>,
|
|
18
|
-
private userLog: LogFn,
|
|
19
|
-
) {}
|
|
15
|
+
private accounts: AztecAsyncMap<string, Buffer>;
|
|
16
|
+
private aliases: AztecAsyncMap<string, Buffer>;
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
constructor(
|
|
19
|
+
private store: AztecAsyncKVStore,
|
|
20
|
+
private userLog: LogFn,
|
|
21
|
+
) {
|
|
22
|
+
this.accounts = store.openMap<string, Buffer>('accounts');
|
|
23
|
+
this.aliases = store.openMap<string, Buffer>('aliases');
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
async storeAccount(
|
|
@@ -84,7 +83,7 @@ export class WalletDB {
|
|
|
84
83
|
|
|
85
84
|
return accountAddresses.map(addressStr => ({
|
|
86
85
|
alias: aliasesByAddress.get(addressStr) ?? '',
|
|
87
|
-
item: AztecAddress.
|
|
86
|
+
item: AztecAddress.fromStringUnsafe(addressStr),
|
|
88
87
|
}));
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -93,7 +92,7 @@ export class WalletDB {
|
|
|
93
92
|
for await (const [alias, item] of this.aliases.entriesAsync({ start: 'senders:', end: 'senders:\uffff' })) {
|
|
94
93
|
result.push({
|
|
95
94
|
alias: alias.slice('senders:'.length),
|
|
96
|
-
item: AztecAddress.
|
|
95
|
+
item: AztecAddress.fromStringUnsafe(item.toString()),
|
|
97
96
|
});
|
|
98
97
|
}
|
|
99
98
|
return result;
|
|
@@ -131,4 +130,8 @@ export class WalletDB {
|
|
|
131
130
|
await this.aliases.delete(`accounts:${alias}`);
|
|
132
131
|
}
|
|
133
132
|
}
|
|
133
|
+
|
|
134
|
+
async close() {
|
|
135
|
+
await this.store.close();
|
|
136
|
+
}
|
|
134
137
|
}
|
package/src/testing.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
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';
|
|
4
|
-
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
5
3
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
6
4
|
import type { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
7
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
6
|
|
|
9
7
|
interface WalletWithSchnorrAccounts {
|
|
10
|
-
|
|
8
|
+
createSchnorrInitializerlessAccount(secret: Fr, salt: Fr, signingKey: Fq, alias?: string): Promise<AccountManager>;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates the given (genesis-funded) test accounts as initializerless schnorr accounts. Initializerless
|
|
13
|
+
* accounts need no deployment tx — creating one registers the instance and materializes its immutable keys
|
|
14
|
+
* locally — so the accounts are usable as soon as they are created, funded via genesis at their addresses.
|
|
15
|
+
*/
|
|
16
|
+
export async function createFundedInitializerlessAccounts(
|
|
14
17
|
wallet: WalletWithSchnorrAccounts,
|
|
15
18
|
accountsData: InitialAccountData[],
|
|
16
|
-
waitOptions?: WaitOpts,
|
|
17
19
|
) {
|
|
18
20
|
const accountManagers = [];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const { secret, salt, signingKey } = accountsData[i];
|
|
22
|
-
const accountManager = await wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
23
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
24
|
-
await deployMethod.send({
|
|
25
|
-
from: NO_FROM,
|
|
26
|
-
skipClassPublication: i !== 0,
|
|
27
|
-
wait: waitOptions,
|
|
28
|
-
});
|
|
29
|
-
accountManagers.push(accountManager);
|
|
21
|
+
for (const { secret, salt, signingKey } of accountsData) {
|
|
22
|
+
accountManagers.push(await wallet.createSchnorrInitializerlessAccount(secret, salt, signingKey));
|
|
30
23
|
}
|
|
31
24
|
return accountManagers;
|
|
32
25
|
}
|
|
@@ -37,7 +30,8 @@ export async function registerInitialLocalNetworkAccountsInWallet(
|
|
|
37
30
|
const testAccounts = await getInitialTestAccountsData();
|
|
38
31
|
return Promise.all(
|
|
39
32
|
testAccounts.map(async account => {
|
|
40
|
-
return (await wallet.
|
|
33
|
+
return (await wallet.createSchnorrInitializerlessAccount(account.secret, account.salt, account.signingKey))
|
|
34
|
+
.address;
|
|
41
35
|
}),
|
|
42
36
|
);
|
|
43
37
|
}
|