@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-commit.b655e406
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/README.md +30 -0
- package/dest/bin/index.js +48 -26
- package/dest/cmds/authorize_action.d.ts +3 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +8 -4
- package/dest/cmds/bridge_fee_juice.d.ts +2 -2
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +8 -7
- package/dest/cmds/check_tx.d.ts +4 -2
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +145 -6
- package/dest/cmds/create_account.d.ts +6 -5
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +46 -27
- package/dest/cmds/create_authwit.d.ts +3 -2
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +5 -5
- package/dest/cmds/deploy.d.ts +6 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +71 -54
- package/dest/cmds/deploy_account.d.ts +5 -7
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +46 -29
- package/dest/cmds/import_test_accounts.d.ts +2 -2
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +6 -9
- package/dest/cmds/index.d.ts +2 -2
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +83 -115
- package/dest/cmds/profile.d.ts +8 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +28 -0
- package/dest/cmds/register_contract.d.ts +6 -2
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +20 -7
- package/dest/cmds/register_sender.d.ts +3 -2
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +7 -8
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +31 -20
- package/dest/cmds/simulate.d.ts +6 -2
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +25 -19
- package/dest/storage/wallet_db.d.ts +4 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +2 -23
- package/dest/utils/authorizations.d.ts +6 -0
- package/dest/utils/authorizations.d.ts.map +1 -0
- package/dest/utils/authorizations.js +28 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/ecdsa.d.ts +0 -2
- package/dest/utils/ecdsa.d.ts.map +1 -1
- package/dest/utils/options/fees.d.ts +20 -27
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +85 -144
- package/dest/utils/options/options.d.ts +8 -4
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +26 -14
- package/dest/utils/profiling.d.ts +5 -0
- package/dest/utils/profiling.d.ts.map +1 -0
- package/dest/utils/profiling.js +60 -0
- package/dest/utils/wallet.d.ts +35 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +193 -0
- package/package.json +24 -20
- package/src/bin/index.ts +56 -32
- package/src/cmds/authorize_action.ts +15 -4
- package/src/cmds/bridge_fee_juice.ts +14 -11
- package/src/cmds/check_tx.ts +182 -5
- package/src/cmds/create_account.ts +55 -32
- package/src/cmds/create_authwit.ts +8 -4
- package/src/cmds/deploy.ts +79 -62
- package/src/cmds/deploy_account.ts +57 -28
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +256 -220
- package/src/cmds/profile.ts +48 -0
- package/src/cmds/register_contract.ts +28 -5
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +31 -17
- package/src/cmds/simulate.ts +39 -23
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +51 -0
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +134 -206
- package/src/utils/options/options.ts +41 -19
- package/src/utils/profiling.ts +158 -0
- package/src/utils/wallet.ts +264 -0
- package/dest/cmds/add_authwit.d.ts +0 -4
- package/dest/cmds/add_authwit.d.ts.map +0 -1
- package/dest/cmds/add_authwit.js +0 -4
- package/dest/cmds/cancel_tx.d.ts +0 -11
- package/dest/cmds/cancel_tx.d.ts.map +0 -1
- package/dest/cmds/cancel_tx.js +0 -38
- package/dest/utils/accounts.d.ts +0 -11
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -87
- package/dest/utils/pxe_wrapper.d.ts +0 -10
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -21
- package/src/cmds/add_authwit.ts +0 -13
- package/src/cmds/cancel_tx.ts +0 -62
- package/src/utils/accounts.ts +0 -102
- package/src/utils/pxe_wrapper.ts +0 -26
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
2
4
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
5
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
6
|
|
|
5
|
-
import {
|
|
7
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
8
|
+
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
9
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
10
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
6
11
|
|
|
7
12
|
export async function deployAccount(
|
|
8
|
-
|
|
13
|
+
wallet: CLIWallet,
|
|
14
|
+
aztecNode: AztecNode,
|
|
15
|
+
address: AztecAddress,
|
|
9
16
|
wait: boolean,
|
|
10
|
-
|
|
17
|
+
deployer: AztecAddress | undefined,
|
|
18
|
+
registerClass: boolean,
|
|
19
|
+
publicDeploy: boolean,
|
|
20
|
+
skipInitialization: boolean,
|
|
21
|
+
feeOpts: CLIFeeArgs,
|
|
11
22
|
json: boolean,
|
|
23
|
+
verbose: boolean,
|
|
12
24
|
debugLogger: Logger,
|
|
13
25
|
log: LogFn,
|
|
14
26
|
) {
|
|
15
27
|
const out: Record<string, any> = {};
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
28
|
+
|
|
29
|
+
const account = await wallet.createOrRetrieveAccount(address);
|
|
30
|
+
const { partialAddress, publicKeys } = await account.getCompleteAddress();
|
|
31
|
+
const { initializationHash, salt } = account.getInstance();
|
|
20
32
|
|
|
21
33
|
if (json) {
|
|
22
34
|
out.address = address;
|
|
@@ -28,48 +40,67 @@ export async function deployAccount(
|
|
|
28
40
|
log(`\nNew account:\n`);
|
|
29
41
|
log(`Address: ${address.toString()}`);
|
|
30
42
|
log(`Public key: ${publicKeys.toString()}`);
|
|
31
|
-
if (secretKey) {
|
|
32
|
-
log(`Secret key: ${secretKey.toString()}`);
|
|
33
|
-
}
|
|
34
43
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
35
44
|
log(`Salt: ${salt.toString()}`);
|
|
36
45
|
log(`Init hash: ${initializationHash.toString()}`);
|
|
37
|
-
log(`Deployer: ${deployer.toString()}`);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
let tx;
|
|
41
49
|
let txReceipt;
|
|
50
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
42
51
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
53
|
+
const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
|
|
54
|
+
|
|
55
|
+
const deployAccountOpts: DeployAccountOptions = {
|
|
56
|
+
skipClassPublication: !registerClass,
|
|
57
|
+
skipInstancePublication: !publicDeploy,
|
|
58
|
+
skipInitialization,
|
|
59
|
+
from,
|
|
60
|
+
fee: { paymentMethod, gasSettings },
|
|
46
61
|
};
|
|
62
|
+
|
|
63
|
+
const deployMethod = await account.getDeployMethod();
|
|
64
|
+
const { estimatedGas, stats } = await deployMethod.simulate({
|
|
65
|
+
...deployAccountOpts,
|
|
66
|
+
fee: { ...deployAccountOpts.fee, estimateGas: true },
|
|
67
|
+
});
|
|
68
|
+
|
|
47
69
|
if (feeOpts.estimateOnly) {
|
|
48
|
-
const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
|
|
49
70
|
if (json) {
|
|
50
71
|
out.fee = {
|
|
51
72
|
gasLimits: {
|
|
52
|
-
da:
|
|
53
|
-
l2:
|
|
73
|
+
da: estimatedGas.gasLimits.daGas,
|
|
74
|
+
l2: estimatedGas.gasLimits.l2Gas,
|
|
54
75
|
},
|
|
55
76
|
teardownGasLimits: {
|
|
56
|
-
da:
|
|
57
|
-
l2:
|
|
77
|
+
da: estimatedGas.teardownGasLimits.daGas,
|
|
78
|
+
l2: estimatedGas.teardownGasLimits,
|
|
58
79
|
},
|
|
59
80
|
};
|
|
60
|
-
} else {
|
|
61
|
-
printGasEstimates(feeOpts, gas, log);
|
|
62
81
|
}
|
|
63
82
|
} else {
|
|
64
|
-
tx =
|
|
83
|
+
tx = deployMethod.send({
|
|
84
|
+
...deployAccountOpts,
|
|
85
|
+
fee: deployAccountOpts.fee
|
|
86
|
+
? {
|
|
87
|
+
...deployAccountOpts.fee,
|
|
88
|
+
gasSettings: estimatedGas,
|
|
89
|
+
}
|
|
90
|
+
: undefined,
|
|
91
|
+
});
|
|
92
|
+
if (verbose) {
|
|
93
|
+
printProfileResult(stats, log);
|
|
94
|
+
}
|
|
95
|
+
|
|
65
96
|
const txHash = await tx.getTxHash();
|
|
66
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
|
|
97
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
67
98
|
out.txHash = txHash;
|
|
68
99
|
if (wait) {
|
|
69
100
|
if (!json) {
|
|
70
101
|
log(`\nWaiting for account contract deployment...`);
|
|
71
102
|
}
|
|
72
|
-
txReceipt = await tx.wait();
|
|
103
|
+
txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
|
|
73
104
|
out.txReceipt = {
|
|
74
105
|
status: txReceipt.status,
|
|
75
106
|
transactionFee: txReceipt.transactionFee,
|
|
@@ -81,12 +112,10 @@ export async function deployAccount(
|
|
|
81
112
|
log(prettyPrintJSON(out));
|
|
82
113
|
} else {
|
|
83
114
|
if (tx) {
|
|
84
|
-
log(`Deploy tx hash: ${await tx.getTxHash()}`);
|
|
115
|
+
log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
|
|
85
116
|
}
|
|
86
117
|
if (txReceipt) {
|
|
87
118
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
|
88
119
|
}
|
|
89
120
|
}
|
|
90
|
-
|
|
91
|
-
return { address, secretKey, salt };
|
|
92
121
|
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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(
|
|
10
|
-
const testAccounts = await
|
|
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
|
-
|
|
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.
|
|
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) {
|