@aztec/cli-wallet 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981

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 (106) hide show
  1. package/README.md +30 -0
  2. package/dest/bin/index.d.ts +2 -1
  3. package/dest/bin/index.js +39 -23
  4. package/dest/cmds/authorize_action.d.ts +4 -3
  5. package/dest/cmds/authorize_action.d.ts.map +1 -1
  6. package/dest/cmds/authorize_action.js +8 -7
  7. package/dest/cmds/bridge_fee_juice.d.ts +4 -4
  8. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
  9. package/dest/cmds/bridge_fee_juice.js +9 -7
  10. package/dest/cmds/check_tx.d.ts +5 -3
  11. package/dest/cmds/check_tx.d.ts.map +1 -1
  12. package/dest/cmds/check_tx.js +148 -6
  13. package/dest/cmds/create_account.d.ts +8 -6
  14. package/dest/cmds/create_account.d.ts.map +1 -1
  15. package/dest/cmds/create_account.js +56 -62
  16. package/dest/cmds/create_authwit.d.ts +4 -3
  17. package/dest/cmds/create_authwit.d.ts.map +1 -1
  18. package/dest/cmds/create_authwit.js +6 -6
  19. package/dest/cmds/deploy.d.ts +7 -4
  20. package/dest/cmds/deploy.d.ts.map +1 -1
  21. package/dest/cmds/deploy.js +84 -50
  22. package/dest/cmds/deploy_account.d.ts +6 -8
  23. package/dest/cmds/deploy_account.d.ts.map +1 -1
  24. package/dest/cmds/deploy_account.js +56 -65
  25. package/dest/cmds/import_test_accounts.d.ts +3 -3
  26. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  27. package/dest/cmds/import_test_accounts.js +6 -9
  28. package/dest/cmds/index.d.ts +3 -3
  29. package/dest/cmds/index.d.ts.map +1 -1
  30. package/dest/cmds/index.js +73 -112
  31. package/dest/cmds/profile.d.ts +7 -4
  32. package/dest/cmds/profile.d.ts.map +1 -1
  33. package/dest/cmds/profile.js +9 -4
  34. package/dest/cmds/register_contract.d.ts +7 -3
  35. package/dest/cmds/register_contract.d.ts.map +1 -1
  36. package/dest/cmds/register_contract.js +5 -6
  37. package/dest/cmds/register_sender.d.ts +4 -3
  38. package/dest/cmds/register_sender.d.ts.map +1 -1
  39. package/dest/cmds/send.d.ts +8 -9
  40. package/dest/cmds/send.d.ts.map +1 -1
  41. package/dest/cmds/send.js +46 -31
  42. package/dest/cmds/simulate.d.ts +7 -4
  43. package/dest/cmds/simulate.d.ts.map +1 -1
  44. package/dest/cmds/simulate.js +12 -7
  45. package/dest/storage/wallet_db.d.ts +6 -16
  46. package/dest/storage/wallet_db.d.ts.map +1 -1
  47. package/dest/storage/wallet_db.js +48 -54
  48. package/dest/utils/authorizations.d.ts +3 -2
  49. package/dest/utils/authorizations.d.ts.map +1 -1
  50. package/dest/utils/authorizations.js +1 -1
  51. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  52. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  53. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  54. package/dest/utils/constants.d.ts +4 -0
  55. package/dest/utils/constants.d.ts.map +1 -0
  56. package/dest/utils/constants.js +7 -0
  57. package/dest/utils/ecdsa.d.ts +1 -1
  58. package/dest/utils/options/fees.d.ts +22 -28
  59. package/dest/utils/options/fees.d.ts.map +1 -1
  60. package/dest/utils/options/fees.js +66 -133
  61. package/dest/utils/options/index.d.ts +1 -1
  62. package/dest/utils/options/options.d.ts +3 -2
  63. package/dest/utils/options/options.d.ts.map +1 -1
  64. package/dest/utils/options/options.js +1 -1
  65. package/dest/utils/profiling.d.ts +1 -1
  66. package/dest/utils/profiling.d.ts.map +1 -1
  67. package/dest/utils/profiling.js +9 -1
  68. package/dest/utils/wallet.d.ts +40 -0
  69. package/dest/utils/wallet.d.ts.map +1 -0
  70. package/dest/utils/wallet.js +208 -0
  71. package/package.json +17 -14
  72. package/src/bin/index.ts +39 -31
  73. package/src/cmds/authorize_action.ts +14 -6
  74. package/src/cmds/bridge_fee_juice.ts +15 -11
  75. package/src/cmds/check_tx.ts +180 -5
  76. package/src/cmds/create_account.ts +63 -66
  77. package/src/cmds/create_authwit.ts +9 -5
  78. package/src/cmds/deploy.ts +82 -61
  79. package/src/cmds/deploy_account.ts +62 -64
  80. package/src/cmds/import_test_accounts.ts +7 -11
  81. package/src/cmds/index.ts +120 -206
  82. package/src/cmds/profile.ts +14 -6
  83. package/src/cmds/register_contract.ts +9 -11
  84. package/src/cmds/register_sender.ts +3 -2
  85. package/src/cmds/send.ts +42 -40
  86. package/src/cmds/simulate.ts +17 -12
  87. package/src/storage/wallet_db.ts +52 -67
  88. package/src/utils/authorizations.ts +3 -1
  89. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  90. package/src/utils/constants.ts +4 -0
  91. package/src/utils/options/fees.ts +88 -178
  92. package/src/utils/options/options.ts +3 -2
  93. package/src/utils/profiling.ts +15 -1
  94. package/src/utils/wallet.ts +290 -0
  95. package/dest/cmds/cancel_tx.d.ts +0 -11
  96. package/dest/cmds/cancel_tx.d.ts.map +0 -1
  97. package/dest/cmds/cancel_tx.js +0 -43
  98. package/dest/utils/accounts.d.ts +0 -9
  99. package/dest/utils/accounts.d.ts.map +0 -1
  100. package/dest/utils/accounts.js +0 -61
  101. package/dest/utils/pxe_wrapper.d.ts +0 -12
  102. package/dest/utils/pxe_wrapper.d.ts.map +0 -1
  103. package/dest/utils/pxe_wrapper.js +0 -26
  104. package/src/cmds/cancel_tx.ts +0 -66
  105. package/src/utils/accounts.ts +0 -77
  106. package/src/utils/pxe_wrapper.ts +0 -32
@@ -1,9 +1,13 @@
1
- import { type AccountWalletWithSecretKey, type AztecAddress, Contract } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { Contract } from '@aztec/aztec.js/contracts';
2
3
  import { prepTx } from '@aztec/cli/utils';
3
4
  import type { LogFn } from '@aztec/foundation/log';
4
5
 
6
+ import type { CLIWallet } from '../utils/wallet.js';
7
+
5
8
  export async function createAuthwit(
6
- wallet: AccountWalletWithSecretKey,
9
+ wallet: CLIWallet,
10
+ from: AztecAddress,
7
11
  functionName: string,
8
12
  caller: AztecAddress,
9
13
  functionArgsIn: any[],
@@ -24,10 +28,10 @@ export async function createAuthwit(
24
28
  );
25
29
  }
26
30
 
27
- const contract = await Contract.at(contractAddress, contractArtifact, wallet);
28
- const action = contract.methods[functionName](...functionArgs);
31
+ const contract = Contract.at(contractAddress, contractArtifact, wallet);
32
+ const call = await contract.methods[functionName](...functionArgs).getFunctionCall();
29
33
 
30
- const witness = await wallet.createAuthWit({ caller, action });
34
+ const witness = await wallet.createAuthWit(from, { caller, call });
31
35
 
32
36
  log(`Created authorization witness for action ${functionName} on contract ${contractAddress} for caller ${caller}`);
33
37
 
@@ -1,22 +1,23 @@
1
- import {
2
- type AccountWalletWithSecretKey,
3
- AztecAddress,
4
- ContractDeployer,
5
- type DeployOptions,
6
- Fr,
7
- } from '@aztec/aztec.js';
8
- import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { DeployOptions } from '@aztec/aztec.js/contracts';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
+ import { ContractDeployer } from '@aztec/aztec.js/deployment';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import type { AztecNode } from '@aztec/aztec.js/node';
7
+ import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
9
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
10
9
  import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
11
10
  import { PublicKeys } from '@aztec/stdlib/keys';
12
11
 
13
- import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
12
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
13
+ import { CLIFeeArgs } from '../utils/options/fees.js';
14
14
  import { printProfileResult } from '../utils/profiling.js';
15
- import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
15
+ import type { CLIWallet } from '../utils/wallet.js';
16
16
 
17
17
  export async function deploy(
18
- wallet: AccountWalletWithSecretKey,
19
- deployer: AztecAddress | undefined,
18
+ wallet: CLIWallet,
19
+ node: AztecNode,
20
+ deployer: AztecAddress,
20
21
  artifactPath: string,
21
22
  json: boolean,
22
23
  publicKeys: PublicKeys | undefined,
@@ -27,13 +28,13 @@ export async function deploy(
27
28
  skipClassPublication: boolean,
28
29
  skipInitialization: boolean | undefined,
29
30
  wait: boolean,
30
- feeOpts: IFeeOpts,
31
+ feeOpts: CLIFeeArgs,
31
32
  verbose: boolean,
32
33
  timeout: number = DEFAULT_TX_TIMEOUT_S,
33
34
  debugLogger: Logger,
34
35
  log: LogFn,
35
- logJson: (output: any) => void,
36
36
  ) {
37
+ const out: Record<string, any> = {};
37
38
  salt ??= Fr.random();
38
39
  const contractArtifact = await getContractArtifact(artifactPath, log);
39
40
  const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
@@ -59,8 +60,9 @@ export async function deploy(
59
60
  }
60
61
 
61
62
  const deploy = contractDeployer.deploy(...args);
63
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
62
64
  const deployOpts: DeployOptions = {
63
- ...(await feeOpts.toDeployAccountOpts(wallet)),
65
+ fee: { gasSettings, paymentMethod },
64
66
  from: deployer ?? AztecAddress.ZERO,
65
67
  contractAddressSalt: salt,
66
68
  universalDeploy: !deployer,
@@ -69,60 +71,79 @@ export async function deploy(
69
71
  skipInstancePublication,
70
72
  };
71
73
 
72
- if (feeOpts.estimateOnly) {
73
- const gas = await deploy.estimateGas(deployOpts);
74
- printGasEstimates(feeOpts, gas, log);
75
- return;
76
- }
77
-
78
- const provenTx = await deploy.prove(deployOpts);
79
- if (verbose) {
80
- printProfileResult(provenTx.stats!, log);
81
- }
74
+ const { estimatedGas, stats } = await deploy.simulate({
75
+ ...deployOpts,
76
+ fee: { ...deployOpts.fee, estimateGas: true },
77
+ });
82
78
 
83
- const tx = provenTx.send();
84
-
85
- const txHash = await tx.getTxHash();
86
- debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
87
- if (wait) {
88
- const deployed = await tx.wait({ timeout });
89
- const { address, partialAddress, instance } = deployed.contract;
79
+ if (feeOpts.estimateOnly) {
90
80
  if (json) {
91
- logJson({
92
- address: address.toString(),
93
- partialAddress: (await partialAddress).toString(),
94
- initializationHash: instance.initializationHash.toString(),
95
- salt: salt.toString(),
96
- transactionFee: deployed.transactionFee?.toString(),
97
- });
98
- } else {
99
- log(`Contract deployed at ${address.toString()}`);
100
- log(`Contract partial address ${(await partialAddress).toString()}`);
101
- log(`Contract init hash ${instance.initializationHash.toString()}`);
102
- log(`Deployment tx hash: ${txHash.toString()}`);
103
- log(`Deployment salt: ${salt.toString()}`);
104
- log(`Deployment fee: ${deployed.transactionFee}`);
81
+ out.fee = {
82
+ gasLimits: {
83
+ da: estimatedGas.gasLimits.daGas,
84
+ l2: estimatedGas.gasLimits.l2Gas,
85
+ },
86
+ teardownGasLimits: {
87
+ da: estimatedGas.teardownGasLimits.daGas,
88
+ l2: estimatedGas.teardownGasLimits,
89
+ },
90
+ };
105
91
  }
106
92
  } else {
93
+ if (verbose) {
94
+ printProfileResult(stats, log);
95
+ }
96
+
107
97
  const { address, partialAddress } = deploy;
108
98
  const instance = await deploy.getInstance();
109
- if (json) {
110
- logJson({
111
- address: address?.toString() ?? 'N/A',
112
- partialAddress: (await partialAddress)?.toString() ?? 'N/A',
113
- txHash: txHash.toString(),
114
- initializationHash: instance.initializationHash.toString(),
115
- salt: salt.toString(),
116
- deployer: instance.deployer.toString(),
117
- });
99
+
100
+ if (wait) {
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
+ }
118
123
  } else {
119
- log(`Contract deployed at ${address?.toString()}`);
120
- log(`Contract partial address ${(await partialAddress)?.toString()}`);
121
- log(`Contract init hash ${instance.initializationHash.toString()}`);
122
- log(`Deployment tx hash: ${txHash.toString()}`);
123
- log(`Deployment salt: ${salt.toString()}`);
124
- log(`Deployer: ${instance.deployer.toString()}`);
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
+
128
+ if (!json) {
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()}`);
135
+ } else {
136
+ out.contract = {
137
+ address: address?.toString(),
138
+ partialAddress: (await partialAddress)?.toString(),
139
+ initializationHash: instance.initializationHash.toString(),
140
+ salt: salt.toString(),
141
+ };
142
+ }
125
143
  }
126
144
  }
145
+ if (json) {
146
+ log(prettyPrintJSON(out));
147
+ }
127
148
  return deploy.address;
128
149
  }
@@ -1,27 +1,36 @@
1
- import { type AccountManager, AztecAddress, type DeployAccountOptions } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
4
+ import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
2
5
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
6
  import type { LogFn, Logger } from '@aztec/foundation/log';
7
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
4
8
 
5
- import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
9
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
10
+ import type { CLIFeeArgs } from '../utils/options/fees.js';
6
11
  import { printProfileResult } from '../utils/profiling.js';
7
- import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
12
+ import type { CLIWallet } from '../utils/wallet.js';
8
13
 
9
14
  export async function deployAccount(
10
- account: AccountManager,
15
+ wallet: CLIWallet,
16
+ aztecNode: AztecNode,
17
+ address: AztecAddress,
11
18
  wait: boolean,
19
+ deployer: AztecAddress | undefined,
12
20
  registerClass: boolean,
13
21
  publicDeploy: boolean,
14
- feeOpts: IFeeOpts,
22
+ skipInitialization: boolean,
23
+ feeOpts: CLIFeeArgs,
15
24
  json: boolean,
16
25
  verbose: boolean,
17
26
  debugLogger: Logger,
18
27
  log: LogFn,
19
28
  ) {
20
29
  const out: Record<string, any> = {};
21
- const { address, partialAddress, publicKeys } = await account.getCompleteAddress();
22
- const { initializationHash, deployer, salt } = account.getInstance();
23
- const wallet = await account.getWallet();
24
- const secretKey = wallet.getSecretKey();
30
+
31
+ const account = await wallet.createOrRetrieveAccount(address);
32
+ const { partialAddress, publicKeys } = await account.getCompleteAddress();
33
+ const { initializationHash, salt } = account.getInstance();
25
34
 
26
35
  if (json) {
27
36
  out.address = address;
@@ -33,97 +42,86 @@ export async function deployAccount(
33
42
  log(`\nNew account:\n`);
34
43
  log(`Address: ${address.toString()}`);
35
44
  log(`Public key: ${publicKeys.toString()}`);
36
- if (secretKey) {
37
- log(`Secret key: ${secretKey.toString()}`);
38
- }
39
45
  log(`Partial address: ${partialAddress.toString()}`);
40
46
  log(`Salt: ${salt.toString()}`);
41
47
  log(`Init hash: ${initializationHash.toString()}`);
42
- log(`Deployer: ${deployer.toString()}`);
43
48
  }
44
49
 
45
- let tx;
46
- let txReceipt;
50
+ let txHash: TxHash | undefined;
51
+ let txReceipt: TxReceipt | undefined;
52
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
47
53
 
48
- const deployOpts: DeployAccountOptions = {
49
- skipInstancePublication: !publicDeploy,
54
+ const delegatedDeployment = deployer && !account.address.equals(deployer);
55
+ const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
56
+
57
+ const deployAccountOpts: DeployAccountOptions = {
50
58
  skipClassPublication: !registerClass,
51
- ...(await feeOpts.toDeployAccountOpts(wallet)),
59
+ skipInstancePublication: !publicDeploy,
60
+ skipInitialization,
61
+ from,
62
+ fee: { paymentMethod, gasSettings },
52
63
  };
53
64
 
54
- /*
55
- * This is usually handled by accountManager.deploy(), but we're accessing the lower
56
- * level method to get gas and timings. That means we have to replicate some of the logic here.
57
- * In case we're deploying our own account, we need to hijack the payment method for the fee,
58
- * wrapping it in the one that will make use of the freshly deployed account's
59
- * entrypoint. For reference, see aztec.js/src/account_manager.ts:deploy()
60
- * Also, salt and universalDeploy have to be explicitly provided
61
- */
62
- deployOpts.fee =
63
- !deployOpts?.deployWallet && deployOpts?.fee
64
- ? { ...deployOpts.fee, paymentMethod: await account.getSelfPaymentMethod(deployOpts.fee.paymentMethod) }
65
- : deployOpts?.fee;
66
-
67
- const deployMethod = await account.getDeployMethod(deployOpts.deployWallet);
65
+ const deployMethod = await account.getDeployMethod();
66
+ const { estimatedGas, stats } = await deployMethod.simulate({
67
+ ...deployAccountOpts,
68
+ fee: { ...deployAccountOpts.fee, estimateGas: true },
69
+ });
68
70
 
69
71
  if (feeOpts.estimateOnly) {
70
- const gas = await deployMethod.estimateGas({
71
- ...deployOpts,
72
- from: AztecAddress.ZERO,
73
- universalDeploy: true,
74
- contractAddressSalt: salt,
75
- });
76
72
  if (json) {
77
73
  out.fee = {
78
74
  gasLimits: {
79
- da: gas.gasLimits.daGas,
80
- l2: gas.gasLimits.l2Gas,
75
+ da: estimatedGas.gasLimits.daGas,
76
+ l2: estimatedGas.gasLimits.l2Gas,
81
77
  },
82
78
  teardownGasLimits: {
83
- da: gas.teardownGasLimits.daGas,
84
- l2: gas.teardownGasLimits,
79
+ da: estimatedGas.teardownGasLimits.daGas,
80
+ l2: estimatedGas.teardownGasLimits,
85
81
  },
86
82
  };
87
- } else {
88
- printGasEstimates(feeOpts, gas, log);
89
83
  }
90
84
  } else {
91
- const provenTx = await deployMethod.prove({
92
- ...deployOpts,
93
- from: AztecAddress.ZERO,
94
- universalDeploy: true,
95
- contractAddressSalt: salt,
96
- });
97
85
  if (verbose) {
98
- printProfileResult(provenTx.stats!, log);
86
+ printProfileResult(stats, log);
99
87
  }
100
- tx = provenTx.send();
101
88
 
102
- const txHash = await tx.getTxHash();
103
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
104
- out.txHash = txHash;
105
- if (wait) {
106
- if (!json) {
107
- log(`\nWaiting for account contract deployment...`);
108
- }
109
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
89
+ if (!json) {
90
+ log(`\nWaiting for account contract deployment...`);
91
+ }
92
+ const result = await deployMethod.send({
93
+ ...deployAccountOpts,
94
+ fee: deployAccountOpts.fee
95
+ ? {
96
+ ...deployAccountOpts.fee,
97
+ gasSettings: estimatedGas,
98
+ }
99
+ : undefined,
100
+ wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
101
+ });
102
+ const isReceipt = (data: TxReceipt | TxHash): data is TxReceipt => 'txHash' in data;
103
+ if (isReceipt(result)) {
104
+ txReceipt = result;
105
+ txHash = result.txHash;
110
106
  out.txReceipt = {
111
107
  status: txReceipt.status,
112
108
  transactionFee: txReceipt.transactionFee,
113
109
  };
110
+ } else {
111
+ txHash = result;
114
112
  }
113
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
114
+ out.txHash = txHash;
115
115
  }
116
116
 
117
117
  if (json) {
118
118
  log(prettyPrintJSON(out));
119
119
  } else {
120
- if (tx) {
121
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
120
+ if (txHash) {
121
+ log(`Deploy tx hash: ${txHash.toString()}`);
122
122
  }
123
123
  if (txReceipt) {
124
124
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
125
125
  }
126
126
  }
127
-
128
- return { address, secretKey, salt };
129
127
  }
@@ -1,25 +1,21 @@
1
- import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { getInitialTestAccounts } from '@aztec/accounts/testing';
3
- import { Fr, type PXE } from '@aztec/aztec.js';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { Fr } from '@aztec/aztec.js/fields';
4
3
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
4
  import type { LogFn } from '@aztec/foundation/log';
6
5
 
7
6
  import type { WalletDB } from '../storage/wallet_db.js';
7
+ import type { CLIWallet } from '../utils/wallet.js';
8
8
 
9
- export async function importTestAccounts(client: PXE, db: WalletDB, json: boolean, log: LogFn) {
10
- const testAccounts = await getInitialTestAccounts();
11
- const accounts = await Promise.all(
12
- testAccounts.map(({ secret, signingKey, salt }) => getSchnorrAccount(client, secret, signingKey, salt)),
13
- );
9
+ export async function importTestAccounts(wallet: CLIWallet, db: WalletDB, json: boolean, log: LogFn) {
10
+ const testAccounts = await getInitialTestAccountsData();
14
11
 
15
12
  const out: Record<string, any> = {};
16
13
  await Promise.all(
17
- accounts.map(async (account, i) => {
14
+ testAccounts.map(async (account, i) => {
18
15
  const alias = `test${i}`;
19
16
  const secret = testAccounts[i].secret;
20
17
  const salt = new Fr(account.salt);
21
- const address = account.getAddress();
22
- await account.register();
18
+ const address = account.address;
23
19
  await db.storeAccount(address, { type: 'schnorr', secretKey: secret, salt, alias, publicKey: undefined }, log);
24
20
 
25
21
  if (json) {