@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.
Files changed (36) hide show
  1. package/dest/embedded/account-contract-providers/bundle.d.ts +3 -6
  2. package/dest/embedded/account-contract-providers/bundle.d.ts.map +1 -1
  3. package/dest/embedded/account-contract-providers/bundle.js +10 -9
  4. package/dest/embedded/account-contract-providers/lazy.d.ts +3 -6
  5. package/dest/embedded/account-contract-providers/lazy.d.ts.map +1 -1
  6. package/dest/embedded/account-contract-providers/lazy.js +10 -10
  7. package/dest/embedded/account-contract-providers/types.d.ts +3 -6
  8. package/dest/embedded/account-contract-providers/types.d.ts.map +1 -1
  9. package/dest/embedded/embedded_wallet.d.ts +29 -4
  10. package/dest/embedded/embedded_wallet.d.ts.map +1 -1
  11. package/dest/embedded/embedded_wallet.js +135 -44
  12. package/dest/embedded/entrypoints/browser.d.ts +1 -1
  13. package/dest/embedded/entrypoints/browser.d.ts.map +1 -1
  14. package/dest/embedded/entrypoints/browser.js +20 -7
  15. package/dest/embedded/entrypoints/node.d.ts +1 -1
  16. package/dest/embedded/entrypoints/node.d.ts.map +1 -1
  17. package/dest/embedded/entrypoints/node.js +19 -6
  18. package/dest/embedded/store_encryption.d.ts +67 -0
  19. package/dest/embedded/store_encryption.d.ts.map +1 -0
  20. package/dest/embedded/store_encryption.js +71 -0
  21. package/dest/embedded/wallet_db.d.ts +7 -6
  22. package/dest/embedded/wallet_db.d.ts.map +1 -1
  23. package/dest/embedded/wallet_db.js +12 -11
  24. package/dest/testing.d.ts +8 -4
  25. package/dest/testing.d.ts.map +1 -1
  26. package/dest/testing.js +8 -14
  27. package/package.json +12 -10
  28. package/src/embedded/account-contract-providers/bundle.ts +12 -11
  29. package/src/embedded/account-contract-providers/lazy.ts +12 -12
  30. package/src/embedded/account-contract-providers/types.ts +2 -2
  31. package/src/embedded/embedded_wallet.ts +162 -39
  32. package/src/embedded/entrypoints/browser.ts +31 -16
  33. package/src/embedded/entrypoints/node.ts +36 -21
  34. package/src/embedded/store_encryption.ts +107 -0
  35. package/src/embedded/wallet_db.ts +15 -12
  36. 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 constructor(
16
- private accounts: AztecAsyncMap<string, Buffer>,
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
- static init(store: AztecAsyncKVStore, userLog: LogFn) {
22
- const accounts = store.openMap<string, Buffer>('accounts');
23
- const aliases = store.openMap<string, Buffer>('aliases');
24
- return new WalletDB(accounts, aliases, userLog);
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.fromString(addressStr),
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.fromString(item.toString()),
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
- createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq, alias?: string): Promise<AccountManager>;
8
+ createSchnorrInitializerlessAccount(secret: Fr, salt: Fr, signingKey: Fq, alias?: string): Promise<AccountManager>;
11
9
  }
12
10
 
13
- export async function deployFundedSchnorrAccounts(
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
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
20
- for (let i = 0; i < accountsData.length; i++) {
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.createSchnorrAccount(account.secret, account.salt, account.signingKey)).address;
33
+ return (await wallet.createSchnorrInitializerlessAccount(account.secret, account.salt, account.signingKey))
34
+ .address;
41
35
  }),
42
36
  );
43
37
  }