@aztec/cli-wallet 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c

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 (57) hide show
  1. package/dest/cmds/authorize_action.d.ts +2 -2
  2. package/dest/cmds/authorize_action.d.ts.map +1 -1
  3. package/dest/cmds/authorize_action.js +4 -2
  4. package/dest/cmds/bridge_fee_juice.d.ts +2 -2
  5. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
  6. package/dest/cmds/bridge_fee_juice.js +3 -2
  7. package/dest/cmds/check_tx.js +10 -6
  8. package/dest/cmds/create_account.d.ts +4 -3
  9. package/dest/cmds/create_account.d.ts.map +1 -1
  10. package/dest/cmds/create_account.js +25 -19
  11. package/dest/cmds/create_authwit.d.ts +2 -2
  12. package/dest/cmds/create_authwit.d.ts.map +1 -1
  13. package/dest/cmds/deploy.d.ts +1 -1
  14. package/dest/cmds/deploy.d.ts.map +1 -1
  15. package/dest/cmds/deploy.js +46 -23
  16. package/dest/cmds/deploy_account.d.ts +1 -1
  17. package/dest/cmds/deploy_account.d.ts.map +1 -1
  18. package/dest/cmds/deploy_account.js +24 -18
  19. package/dest/cmds/index.js +1 -1
  20. package/dest/cmds/send.d.ts +2 -2
  21. package/dest/cmds/send.d.ts.map +1 -1
  22. package/dest/cmds/send.js +28 -16
  23. package/dest/cmds/simulate.d.ts +1 -1
  24. package/dest/cmds/simulate.d.ts.map +1 -1
  25. package/dest/cmds/simulate.js +3 -3
  26. package/dest/storage/wallet_db.d.ts +3 -3
  27. package/dest/storage/wallet_db.d.ts.map +1 -1
  28. package/dest/storage/wallet_db.js +47 -32
  29. package/dest/utils/constants.d.ts +4 -0
  30. package/dest/utils/constants.d.ts.map +1 -0
  31. package/dest/utils/constants.js +7 -0
  32. package/dest/utils/options/fees.js +3 -3
  33. package/dest/utils/options/options.d.ts +2 -2
  34. package/dest/utils/options/options.d.ts.map +1 -1
  35. package/dest/utils/options/options.js +1 -1
  36. package/dest/utils/profiling.d.ts +1 -1
  37. package/dest/utils/profiling.d.ts.map +1 -1
  38. package/dest/utils/profiling.js +9 -1
  39. package/dest/utils/wallet.d.ts +11 -7
  40. package/dest/utils/wallet.d.ts.map +1 -1
  41. package/dest/utils/wallet.js +56 -43
  42. package/package.json +17 -17
  43. package/src/cmds/authorize_action.ts +1 -1
  44. package/src/cmds/bridge_fee_juice.ts +3 -2
  45. package/src/cmds/check_tx.ts +8 -9
  46. package/src/cmds/create_account.ts +26 -19
  47. package/src/cmds/deploy.ts +41 -22
  48. package/src/cmds/deploy_account.ts +23 -17
  49. package/src/cmds/index.ts +2 -2
  50. package/src/cmds/send.ts +22 -10
  51. package/src/cmds/simulate.ts +3 -6
  52. package/src/storage/wallet_db.ts +51 -38
  53. package/src/utils/constants.ts +4 -0
  54. package/src/utils/options/fees.ts +3 -3
  55. package/src/utils/options/options.ts +1 -1
  56. package/src/utils/profiling.ts +15 -1
  57. package/src/utils/wallet.ts +80 -56
@@ -1,14 +1,17 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
2
3
  import type { AztecNode } from '@aztec/aztec.js/node';
3
4
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
4
5
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
- import { Fr } from '@aztec/foundation/fields';
6
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
7
9
 
8
10
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
11
+ import type { AccountType } from '../utils/constants.js';
9
12
  import { CLIFeeArgs } from '../utils/options/fees.js';
10
13
  import { printProfileResult } from '../utils/profiling.js';
11
- import { type AccountType, CLIWallet } from '../utils/wallet.js';
14
+ import { CLIWallet } from '../utils/wallet.js';
12
15
 
13
16
  export async function createAccount(
14
17
  wallet: CLIWallet,
@@ -63,8 +66,8 @@ export async function createAccount(
63
66
  log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
64
67
  }
65
68
 
66
- let tx;
67
- let txReceipt;
69
+ let txHash: TxHash | undefined;
70
+ let txReceipt: TxReceipt | undefined;
68
71
  if (!registerOnly) {
69
72
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
70
73
 
@@ -99,7 +102,14 @@ export async function createAccount(
99
102
  };
100
103
  }
101
104
  } else {
102
- tx = deployMethod.send({
105
+ if (verbose) {
106
+ printProfileResult(stats, log);
107
+ }
108
+
109
+ if (!json) {
110
+ log(`\nWaiting for account contract deployment...`);
111
+ }
112
+ const result = await deployMethod.send({
103
113
  ...deployAccountOpts,
104
114
  fee: deployAccountOpts.fee
105
115
  ? {
@@ -107,32 +117,29 @@ export async function createAccount(
107
117
  gasSettings: estimatedGas,
108
118
  }
109
119
  : undefined,
120
+ wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
110
121
  });
111
- if (verbose) {
112
- printProfileResult(stats, log);
113
- }
114
-
115
- const txHash = await tx.getTxHash();
116
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
117
- out.txHash = txHash;
118
- if (wait) {
119
- if (!json) {
120
- log(`\nWaiting for account contract deployment...`);
121
- }
122
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
122
+ const isReceipt = (data: TxReceipt | TxHash): data is TxReceipt => 'txHash' in data;
123
+ if (isReceipt(result)) {
124
+ txReceipt = result;
125
+ txHash = result.txHash;
123
126
  out.txReceipt = {
124
127
  status: txReceipt.status,
125
128
  transactionFee: txReceipt.transactionFee,
126
129
  };
130
+ } else {
131
+ txHash = result;
127
132
  }
133
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
134
+ out.txHash = txHash;
128
135
  }
129
136
  }
130
137
 
131
138
  if (json) {
132
139
  log(prettyPrintJSON(out));
133
140
  } else {
134
- if (tx) {
135
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
141
+ if (txHash) {
142
+ log(`Deploy tx hash: ${txHash.toString()}`);
136
143
  }
137
144
  if (txReceipt) {
138
145
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1,5 +1,6 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { DeployOptions } from '@aztec/aztec.js/contracts';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
4
  import { ContractDeployer } from '@aztec/aztec.js/deployment';
4
5
  import { Fr } from '@aztec/aztec.js/fields';
5
6
  import type { AztecNode } from '@aztec/aztec.js/node';
@@ -89,37 +90,55 @@ export async function deploy(
89
90
  };
90
91
  }
91
92
  } else {
92
- const tx = deploy.send(deployOpts);
93
93
  if (verbose) {
94
94
  printProfileResult(stats, log);
95
95
  }
96
96
 
97
- const txHash = await tx.getTxHash();
98
- debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
99
- out.hash = txHash;
100
97
  const { address, partialAddress } = deploy;
101
98
  const instance = await deploy.getInstance();
102
- if (!json) {
103
- log(`Contract deployed at ${address?.toString()}`);
104
- log(`Contract partial address ${(await partialAddress)?.toString()}`);
105
- log(`Contract init hash ${instance.initializationHash.toString()}`);
106
- log(`Deployment tx hash: ${txHash.toString()}`);
107
- log(`Deployment salt: ${salt.toString()}`);
108
- log(`Deployer: ${instance.deployer.toString()}`);
109
- } else {
110
- out.contract = {
111
- address: address?.toString(),
112
- partialAddress: (await partialAddress)?.toString(),
113
- initializationHash: instance.initializationHash.toString(),
114
- salt: salt.toString(),
115
- };
116
- }
99
+
117
100
  if (wait) {
118
- const deployed = await tx.wait({ timeout });
101
+ const receipt = await deploy.send({ ...deployOpts, wait: { timeout, returnReceipt: true } });
102
+ const txHash = receipt.txHash;
103
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
104
+ out.hash = txHash;
105
+
106
+ if (!json) {
107
+ log(`Contract deployed at ${address?.toString()}`);
108
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
109
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
110
+ log(`Deployment tx hash: ${txHash.toString()}`);
111
+ log(`Deployment salt: ${salt.toString()}`);
112
+ log(`Deployer: ${instance.deployer.toString()}`);
113
+ log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
114
+ } else {
115
+ out.contract = {
116
+ address: address?.toString(),
117
+ partialAddress: (await partialAddress)?.toString(),
118
+ initializationHash: instance.initializationHash.toString(),
119
+ salt: salt.toString(),
120
+ transactionFee: receipt.transactionFee?.toString(),
121
+ };
122
+ }
123
+ } else {
124
+ const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
125
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
126
+ out.hash = txHash;
127
+
119
128
  if (!json) {
120
- log(`Transaction fee: ${deployed.transactionFee?.toString()}`);
129
+ log(`Contract deployed at ${address?.toString()}`);
130
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
131
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
132
+ log(`Deployment tx hash: ${txHash.toString()}`);
133
+ log(`Deployment salt: ${salt.toString()}`);
134
+ log(`Deployer: ${instance.deployer.toString()}`);
121
135
  } else {
122
- out.contract.transactionFee = deployed.transactionFee?.toString();
136
+ out.contract = {
137
+ address: address?.toString(),
138
+ partialAddress: (await partialAddress)?.toString(),
139
+ initializationHash: instance.initializationHash.toString(),
140
+ salt: salt.toString(),
141
+ };
123
142
  }
124
143
  }
125
144
  }
@@ -1,8 +1,10 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
2
3
  import type { AztecNode } from '@aztec/aztec.js/node';
3
4
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
4
5
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
6
  import type { LogFn, Logger } from '@aztec/foundation/log';
7
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
6
8
 
7
9
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
8
10
  import type { CLIFeeArgs } from '../utils/options/fees.js';
@@ -45,8 +47,8 @@ export async function deployAccount(
45
47
  log(`Init hash: ${initializationHash.toString()}`);
46
48
  }
47
49
 
48
- let tx;
49
- let txReceipt;
50
+ let txHash: TxHash | undefined;
51
+ let txReceipt: TxReceipt | undefined;
50
52
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
51
53
 
52
54
  const delegatedDeployment = deployer && !account.address.equals(deployer);
@@ -80,7 +82,14 @@ export async function deployAccount(
80
82
  };
81
83
  }
82
84
  } else {
83
- tx = deployMethod.send({
85
+ if (verbose) {
86
+ printProfileResult(stats, log);
87
+ }
88
+
89
+ if (!json) {
90
+ log(`\nWaiting for account contract deployment...`);
91
+ }
92
+ const result = await deployMethod.send({
84
93
  ...deployAccountOpts,
85
94
  fee: deployAccountOpts.fee
86
95
  ? {
@@ -88,31 +97,28 @@ export async function deployAccount(
88
97
  gasSettings: estimatedGas,
89
98
  }
90
99
  : undefined,
100
+ wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
91
101
  });
92
- if (verbose) {
93
- printProfileResult(stats, log);
94
- }
95
-
96
- const txHash = await tx.getTxHash();
97
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
98
- out.txHash = txHash;
99
- if (wait) {
100
- if (!json) {
101
- log(`\nWaiting for account contract deployment...`);
102
- }
103
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
102
+ const isReceipt = (data: TxReceipt | TxHash): data is TxReceipt => 'txHash' in data;
103
+ if (isReceipt(result)) {
104
+ txReceipt = result;
105
+ txHash = result.txHash;
104
106
  out.txReceipt = {
105
107
  status: txReceipt.status,
106
108
  transactionFee: txReceipt.transactionFee,
107
109
  };
110
+ } else {
111
+ txHash = result;
108
112
  }
113
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
114
+ out.txHash = txHash;
109
115
  }
110
116
 
111
117
  if (json) {
112
118
  log(prettyPrintJSON(out));
113
119
  } else {
114
- if (tx) {
115
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
120
+ if (txHash) {
121
+ log(`Deploy tx hash: ${txHash.toString()}`);
116
122
  }
117
123
  if (txReceipt) {
118
124
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
package/src/cmds/index.ts CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  parseFieldFromHexString,
11
11
  parsePublicKey,
12
12
  } from '@aztec/cli/utils';
13
- import { randomBytes } from '@aztec/foundation/crypto';
13
+ import { randomBytes } from '@aztec/foundation/crypto/random';
14
14
  import type { LogFn, Logger } from '@aztec/foundation/log';
15
15
 
16
16
  import { type Command, Option } from 'commander';
@@ -18,6 +18,7 @@ import inquirer from 'inquirer';
18
18
 
19
19
  import type { WalletDB } from '../storage/wallet_db.js';
20
20
  import type { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
21
+ import type { AccountType } from '../utils/constants.js';
21
22
  import {
22
23
  ARTIFACT_DESCRIPTION,
23
24
  CLIFeeArgs,
@@ -38,7 +39,6 @@ import {
38
39
  createVerboseOption,
39
40
  integerArgParser,
40
41
  } from '../utils/options/index.js';
41
- import type { AccountType } from '../utils/wallet.js';
42
42
 
43
43
  // TODO: This function is only used in 1 place so we could just inline this
44
44
  export function injectCommands(
package/src/cmds/send.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import { AuthWitness } from '@aztec/aztec.js/authorization';
3
- import { Contract, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
3
+ import { Contract, NO_WAIT, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
4
4
  import type { AztecNode } from '@aztec/aztec.js/node';
5
5
  import { prepTx } from '@aztec/cli/utils';
6
6
  import type { LogFn } from '@aztec/foundation/log';
@@ -46,31 +46,43 @@ export async function send(
46
46
  return;
47
47
  }
48
48
 
49
- const tx = call.send({ ...sendOptions, fee: { ...sendOptions.fee, gasSettings: estimatedGas } });
50
49
  if (verbose) {
51
50
  printProfileResult(stats!, log);
52
51
  }
53
52
 
54
- const txHash = await tx.getTxHash();
55
- log(`\nTransaction hash: ${txHash.toString()}`);
56
53
  if (wait) {
57
54
  try {
58
- await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
55
+ const receipt = await call.send({
56
+ ...sendOptions,
57
+ fee: { ...sendOptions.fee, gasSettings: estimatedGas },
58
+ wait: { timeout: DEFAULT_TX_TIMEOUT_S },
59
+ });
59
60
 
61
+ const txHash = receipt.txHash;
62
+ log(`\nTransaction hash: ${txHash.toString()}`);
60
63
  log('Transaction has been mined');
61
-
62
- const receipt = await tx.getReceipt();
63
64
  log(` Tx fee: ${receipt.transactionFee}`);
64
65
  log(` Status: ${receipt.status}`);
65
66
  log(` Block number: ${receipt.blockNumber}`);
66
67
  log(` Block hash: ${receipt.blockHash?.toString()}`);
68
+
69
+ return {
70
+ txHash,
71
+ };
67
72
  } catch (err: any) {
68
73
  log(`Transaction failed\n ${err.message}`);
74
+ throw err;
69
75
  }
70
76
  } else {
77
+ const txHash = await call.send({
78
+ ...sendOptions,
79
+ fee: { ...sendOptions.fee, gasSettings: estimatedGas },
80
+ wait: NO_WAIT,
81
+ });
82
+ log(`\nTransaction hash: ${txHash.toString()}`);
71
83
  log('Transaction pending. Check status with check-tx');
84
+ return {
85
+ txHash,
86
+ };
72
87
  }
73
- return {
74
- txHash,
75
- };
76
88
  }
@@ -41,14 +41,11 @@ export async function simulate(
41
41
  simulationResult.offchainEffects!,
42
42
  async (address: AztecAddress) => {
43
43
  const metadata = await wallet.getContractMetadata(address);
44
- if (!metadata.contractInstance) {
44
+ if (!metadata.instance) {
45
45
  return undefined;
46
46
  }
47
- const classMetadata = await wallet.getContractClassMetadata(
48
- metadata.contractInstance.currentContractClassId,
49
- true,
50
- );
51
- return classMetadata.artifact;
47
+ const artifact = await wallet.getContractArtifact(metadata.instance.currentContractClassId);
48
+ return artifact;
52
49
  },
53
50
  log,
54
51
  );
@@ -1,17 +1,18 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
4
4
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import type { TxHash } from '@aztec/stdlib/tx';
7
7
 
8
+ import type { AccountType } from '../utils/constants.js';
8
9
  import { extractECDSAPublicKeyFromBase64String } from '../utils/ecdsa.js';
9
- import type { AccountType } from '../utils/wallet.js';
10
10
 
11
11
  export const Aliases = ['accounts', 'contracts', 'artifacts', 'secrets', 'transactions', 'authwits'] as const;
12
12
  export type AliasType = (typeof Aliases)[number];
13
13
 
14
14
  export class WalletDB {
15
+ #store!: AztecAsyncKVStore;
15
16
  #accounts!: AztecAsyncMap<string, Buffer>;
16
17
  #aliases!: AztecAsyncMap<string, Buffer>;
17
18
  #bridgedFeeJuice!: AztecAsyncMap<string, Buffer>;
@@ -29,6 +30,7 @@ export class WalletDB {
29
30
  }
30
31
 
31
32
  async init(store: AztecAsyncKVStore) {
33
+ this.#store = store;
32
34
  this.#accounts = store.openMap('accounts');
33
35
  this.#aliases = store.openMap('aliases');
34
36
  this.#bridgedFeeJuice = store.openMap('bridgedFeeJuice');
@@ -41,14 +43,17 @@ export class WalletDB {
41
43
  }
42
44
 
43
45
  async pushBridgedFeeJuice(recipient: AztecAddress, secret: Fr, amount: bigint, leafIndex: bigint, log: LogFn) {
44
- let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
45
- stackPointer++;
46
- await this.#bridgedFeeJuice.set(
47
- `${recipient.toString()}:${stackPointer}`,
48
- Buffer.from(`${amount.toString()}:${secret.toString()}:${leafIndex.toString()}`),
49
- );
50
- await this.#bridgedFeeJuice.set(`${recipient.toString()}:stackPointer`, Buffer.from([stackPointer]));
51
- log(`Pushed ${amount} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
46
+ await this.#store.transactionAsync(async () => {
47
+ let stackPointer =
48
+ (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
49
+ stackPointer++;
50
+ await this.#bridgedFeeJuice.set(
51
+ `${recipient.toString()}:${stackPointer}`,
52
+ Buffer.from(`${amount.toString()}:${secret.toString()}:${leafIndex.toString()}`),
53
+ );
54
+ await this.#bridgedFeeJuice.set(`${recipient.toString()}:stackPointer`, Buffer.from([stackPointer]));
55
+ log(`Pushed ${amount} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
56
+ });
52
57
  }
53
58
 
54
59
  async popBridgedFeeJuice(recipient: AztecAddress, log: LogFn) {
@@ -76,19 +81,24 @@ export class WalletDB {
76
81
  }: { type: AccountType; secretKey: Fr; salt: Fr; alias: string | undefined; publicKey: string | undefined },
77
82
  log: LogFn,
78
83
  ) {
79
- if (alias) {
80
- await this.#aliases.set(`accounts:${alias}`, Buffer.from(address.toString()));
81
- }
82
- await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
83
- await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
84
- await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
84
+ let publicSigningKey: Buffer | undefined;
85
85
  if (type === 'ecdsasecp256r1ssh' && publicKey) {
86
- const publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
87
- await this.storeAccountMetadata(address, 'publicSigningKey', publicSigningKey);
86
+ publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
88
87
  }
89
- await this.#aliases.set('accounts:last', Buffer.from(address.toString()));
90
- log(`Account stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
91
88
 
89
+ await this.#store.transactionAsync(async () => {
90
+ if (alias) {
91
+ await this.#aliases.set(`accounts:${alias}`, Buffer.from(address.toString()));
92
+ }
93
+ await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
94
+ await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
95
+ await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
96
+ if (publicSigningKey) {
97
+ await this.#accounts.set(`${address.toString()}:publicSigningKey`, publicSigningKey);
98
+ }
99
+ await this.#aliases.set('accounts:last', Buffer.from(address.toString()));
100
+ });
101
+ log(`Account stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
92
102
  await this.refreshAliasCache();
93
103
  }
94
104
 
@@ -100,35 +110,38 @@ export class WalletDB {
100
110
  }
101
111
 
102
112
  async storeContract(address: AztecAddress, artifactPath: string, log: LogFn, alias?: string) {
103
- if (alias) {
104
- await this.#aliases.set(`contracts:${alias}`, Buffer.from(address.toString()));
105
- await this.#aliases.set(`artifacts:${alias}`, Buffer.from(artifactPath));
106
- }
107
- await this.#aliases.set(`contracts:last`, Buffer.from(address.toString()));
108
- await this.#aliases.set(`artifacts:last`, Buffer.from(artifactPath));
109
- await this.#aliases.set(`artifacts:${address.toString()}`, Buffer.from(artifactPath));
113
+ await this.#store.transactionAsync(async () => {
114
+ if (alias) {
115
+ await this.#aliases.set(`contracts:${alias}`, Buffer.from(address.toString()));
116
+ await this.#aliases.set(`artifacts:${alias}`, Buffer.from(artifactPath));
117
+ }
118
+ await this.#aliases.set(`contracts:last`, Buffer.from(address.toString()));
119
+ await this.#aliases.set(`artifacts:last`, Buffer.from(artifactPath));
120
+ await this.#aliases.set(`artifacts:${address.toString()}`, Buffer.from(artifactPath));
121
+ });
110
122
  log(`Contract stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
111
-
112
123
  await this.refreshAliasCache();
113
124
  }
114
125
 
115
126
  async storeAuthwitness(authWit: AuthWitness, log: LogFn, alias?: string) {
116
- if (alias) {
117
- await this.#aliases.set(`authwits:${alias}`, Buffer.from(authWit.toString()));
118
- }
119
- await this.#aliases.set(`authwits:last`, Buffer.from(authWit.toString()));
127
+ await this.#store.transactionAsync(async () => {
128
+ if (alias) {
129
+ await this.#aliases.set(`authwits:${alias}`, Buffer.from(authWit.toString()));
130
+ }
131
+ await this.#aliases.set(`authwits:last`, Buffer.from(authWit.toString()));
132
+ });
120
133
  log(`Authorization witness stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
121
-
122
134
  await this.refreshAliasCache();
123
135
  }
124
136
 
125
137
  async storeTx({ txHash }: { txHash: TxHash }, log: LogFn, alias?: string) {
126
- if (alias) {
127
- await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
128
- }
129
- await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
138
+ await this.#store.transactionAsync(async () => {
139
+ if (alias) {
140
+ await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
141
+ }
142
+ await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
143
+ });
130
144
  log(`Transaction hash stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
131
-
132
145
  await this.refreshAliasCache();
133
146
  }
134
147
 
@@ -0,0 +1,4 @@
1
+ export const MIN_FEE_PADDING = 0.5;
2
+
3
+ export const AccountTypes = ['schnorr', 'ecdsasecp256r1', 'ecdsasecp256r1ssh', 'ecdsasecp256k1'] as const;
4
+ export type AccountType = (typeof AccountTypes)[number];
@@ -1,7 +1,7 @@
1
1
  import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
2
2
  import type { AztecNode } from '@aztec/aztec.js/node';
3
3
  import type { Wallet } from '@aztec/aztec.js/wallet';
4
- import { Fr } from '@aztec/foundation/fields';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import type { LogFn } from '@aztec/foundation/log';
6
6
  import type { FieldsOf } from '@aztec/foundation/types';
7
7
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -11,7 +11,7 @@ import type { FeeOptions } from '@aztec/wallet-sdk/base-wallet';
11
11
  import { Option } from 'commander';
12
12
 
13
13
  import type { WalletDB } from '../../storage/wallet_db.js';
14
- import { BASE_FEE_PADDING } from '../wallet.js';
14
+ import { MIN_FEE_PADDING } from '../constants.js';
15
15
  import { aliasedAddressParser } from './options.js';
16
16
 
17
17
  export type RawCliFeeArgs = {
@@ -250,7 +250,7 @@ export class CLIFeeArgs {
250
250
  ) {}
251
251
 
252
252
  async toUserFeeOptions(node: AztecNode, wallet: Wallet, from: AztecAddress): Promise<ParsedFeeOptions> {
253
- const maxFeesPerGas = (await node.getCurrentBaseFees()).mul(1 + BASE_FEE_PADDING);
253
+ const maxFeesPerGas = (await node.getCurrentMinFees()).mul(1 + MIN_FEE_PADDING);
254
254
  const gasSettings = GasSettings.default({ ...this.gasSettings, maxFeesPerGas });
255
255
  const paymentMethod = await this.paymentMethod(wallet, from, gasSettings);
256
256
  return {
@@ -7,7 +7,7 @@ import { Option } from 'commander';
7
7
  import { readdir, stat } from 'fs/promises';
8
8
 
9
9
  import type { AliasType, WalletDB } from '../../storage/wallet_db.js';
10
- import { AccountTypes } from '../wallet.js';
10
+ import { AccountTypes } from '../constants.js';
11
11
 
12
12
  const TARGET_DIR = 'target';
13
13
 
@@ -95,7 +95,7 @@ export function printProfileResult(
95
95
 
96
96
  if (stats.nodeRPCCalls) {
97
97
  log(format('\nRPC calls:\n'));
98
- for (const [method, { times }] of Object.entries(stats.nodeRPCCalls)) {
98
+ for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)) {
99
99
  const calls = times.length;
100
100
  const total = times.reduce((acc, time) => acc + time, 0);
101
101
  const avg = total / calls;
@@ -112,6 +112,20 @@ export function printProfileResult(
112
112
  ),
113
113
  );
114
114
  }
115
+
116
+ const { roundTrips } = stats.nodeRPCCalls;
117
+ log(format('\nRound trips (actual blocking waits):\n'));
118
+ log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
119
+ log(
120
+ format(
121
+ 'Total blocking time:'.padEnd(25),
122
+ `${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH),
123
+ ),
124
+ );
125
+ if (roundTrips.roundTrips > 0) {
126
+ const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
127
+ log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
128
+ }
115
129
  }
116
130
 
117
131
  log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));