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