@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-commit.017a351
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 +174 -6
- package/dest/cmds/create_account.d.ts +10 -7
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +74 -38
- 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 +8 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +108 -59
- package/dest/cmds/deploy_account.d.ts +7 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +70 -36
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- 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 +99 -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 +9 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +54 -27
- 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 +12 -19
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +63 -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 +23 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +112 -148
- 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 +44 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +263 -0
- package/package.json +31 -23
- 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 +212 -5
- package/src/cmds/create_account.ts +89 -45
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +115 -71
- package/src/cmds/deploy_account.ts +84 -36
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +312 -222
- 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 +59 -25
- package/src/cmds/simulate.ts +37 -24
- package/src/storage/wallet_db.ts +67 -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 +169 -210
- package/src/utils/options/options.ts +41 -19
- package/src/utils/profiling.ts +172 -0
- package/src/utils/wallet.ts +330 -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
package/src/cmds/deploy.ts
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import type { DeployOptions } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
5
|
+
import { ContractDeployer } from '@aztec/aztec.js/deployment';
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
8
|
+
import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
|
|
3
9
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
-
import { getInitializer } from '@aztec/stdlib/abi';
|
|
10
|
+
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
5
11
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
6
13
|
|
|
7
|
-
import {
|
|
14
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
15
|
+
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
16
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
17
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
8
18
|
|
|
9
19
|
export async function deploy(
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
wallet: CLIWallet,
|
|
21
|
+
node: AztecNode,
|
|
22
|
+
deployer: AztecAddress,
|
|
12
23
|
artifactPath: string,
|
|
13
24
|
json: boolean,
|
|
14
25
|
publicKeys: PublicKeys | undefined,
|
|
15
26
|
rawArgs: any[],
|
|
16
27
|
salt: Fr | undefined,
|
|
17
28
|
initializer: string | undefined,
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
skipInstancePublication: boolean,
|
|
30
|
+
skipClassPublication: boolean,
|
|
20
31
|
skipInitialization: boolean | undefined,
|
|
21
|
-
universalDeploy: boolean | undefined,
|
|
22
32
|
wait: boolean,
|
|
23
|
-
feeOpts:
|
|
33
|
+
feeOpts: CLIFeeArgs,
|
|
34
|
+
waitForStatus: TxStatus,
|
|
35
|
+
verbose: boolean,
|
|
36
|
+
timeout: number = DEFAULT_TX_TIMEOUT_S,
|
|
24
37
|
debugLogger: Logger,
|
|
25
38
|
log: LogFn,
|
|
26
|
-
|
|
39
|
+
universal?: boolean,
|
|
27
40
|
) {
|
|
41
|
+
const out: Record<string, any> = {};
|
|
28
42
|
salt ??= Fr.random();
|
|
29
43
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
30
|
-
const
|
|
44
|
+
const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
|
|
45
|
+
const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.nodeVersion}`;
|
|
34
|
-
if (contractArtifact.aztecNrVersion && contractArtifact.aztecNrVersion !== expectedAztecNrVersion) {
|
|
35
|
-
log(
|
|
36
|
-
`\nWarning: Contract was compiled with a different version of Aztec.nr: ${contractArtifact.aztecNrVersion}. Consider updating Aztec.nr to ${expectedAztecNrVersion}\n`,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
47
|
+
// TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
|
|
39
48
|
|
|
40
|
-
const
|
|
49
|
+
const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
|
|
41
50
|
|
|
42
51
|
let args = [];
|
|
43
52
|
if (rawArgs.length > 0) {
|
|
@@ -49,65 +58,100 @@ export async function deploy(
|
|
|
49
58
|
debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
const deployInteraction = contractDeployer.deploy(args, {
|
|
62
|
+
salt,
|
|
63
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
64
|
+
...(universal ? { universalDeploy: true as const } : {}),
|
|
65
|
+
});
|
|
66
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
67
|
+
const deployOpts: DeployOptions = {
|
|
68
|
+
fee: { gasSettings, paymentMethod },
|
|
69
|
+
from: deployer ?? NO_FROM,
|
|
70
|
+
skipClassPublication,
|
|
58
71
|
skipInitialization,
|
|
59
|
-
|
|
72
|
+
skipInstancePublication,
|
|
60
73
|
};
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const
|
|
75
|
+
const localStart = performance.now();
|
|
76
|
+
const sim = await deployInteraction.simulate({
|
|
77
|
+
...deployOpts,
|
|
78
|
+
fee: { ...deployOpts.fee, estimateGas: true },
|
|
79
|
+
});
|
|
80
|
+
// estimateGas: true guarantees these fields are present
|
|
81
|
+
const estimatedGas = sim.estimatedGas!;
|
|
82
|
+
const stats = sim.stats!;
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash}`);
|
|
72
|
-
if (wait) {
|
|
73
|
-
const deployed = await tx.wait();
|
|
74
|
-
const { address, partialAddress, instance } = deployed.contract;
|
|
84
|
+
if (feeOpts.estimateOnly) {
|
|
75
85
|
if (json) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
87
|
-
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
88
|
-
log(`Deployment salt: ${salt.toString()}`);
|
|
89
|
-
log(`Deployment fee: ${deployed.transactionFee}`);
|
|
86
|
+
out.fee = {
|
|
87
|
+
gasLimits: {
|
|
88
|
+
da: estimatedGas.gasLimits.daGas,
|
|
89
|
+
l2: estimatedGas.gasLimits.l2Gas,
|
|
90
|
+
},
|
|
91
|
+
teardownGasLimits: {
|
|
92
|
+
da: estimatedGas.teardownGasLimits.daGas,
|
|
93
|
+
l2: estimatedGas.teardownGasLimits,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
90
96
|
}
|
|
91
97
|
} else {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
if (verbose) {
|
|
99
|
+
printProfileResult(stats, log);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const instance = await deployInteraction.getInstance();
|
|
103
|
+
const address = instance.address;
|
|
104
|
+
const partialAddress = await deployInteraction.getPartialAddress();
|
|
105
|
+
|
|
106
|
+
const { txHash } = await deployInteraction.send({ ...deployOpts, wait: NO_WAIT });
|
|
107
|
+
const localTimeMs = performance.now() - localStart;
|
|
108
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
109
|
+
out.hash = txHash;
|
|
110
|
+
|
|
111
|
+
if (wait) {
|
|
112
|
+
const nodeStart = performance.now();
|
|
113
|
+
const receipt = await waitForTx(node, txHash, { timeout, waitForStatus });
|
|
114
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
115
|
+
|
|
116
|
+
if (!json) {
|
|
117
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
118
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
119
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
120
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
121
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
122
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
123
|
+
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
124
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
125
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
126
|
+
} else {
|
|
127
|
+
out.contract = {
|
|
128
|
+
address: address.toString(),
|
|
129
|
+
partialAddress: partialAddress.toString(),
|
|
130
|
+
initializationHash: instance.initializationHash.toString(),
|
|
131
|
+
salt: salt.toString(),
|
|
132
|
+
transactionFee: receipt.transactionFee?.toString(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
103
135
|
} else {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
136
|
+
if (!json) {
|
|
137
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
138
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
139
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
140
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
141
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
142
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
143
|
+
} else {
|
|
144
|
+
out.contract = {
|
|
145
|
+
address: address.toString(),
|
|
146
|
+
partialAddress: partialAddress.toString(),
|
|
147
|
+
initializationHash: instance.initializationHash.toString(),
|
|
148
|
+
salt: salt.toString(),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
110
151
|
}
|
|
111
152
|
}
|
|
112
|
-
|
|
153
|
+
if (json) {
|
|
154
|
+
log(prettyPrintJSON(out));
|
|
155
|
+
}
|
|
156
|
+
return await deployInteraction.getAddress();
|
|
113
157
|
}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
5
|
+
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
2
6
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
7
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
|
+
import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
4
9
|
|
|
5
|
-
import {
|
|
10
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
11
|
+
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
12
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
13
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
6
14
|
|
|
7
15
|
export async function deployAccount(
|
|
8
|
-
|
|
16
|
+
wallet: CLIWallet,
|
|
17
|
+
aztecNode: AztecNode,
|
|
18
|
+
address: AztecAddress,
|
|
9
19
|
wait: boolean,
|
|
10
|
-
|
|
20
|
+
deployer: AztecAddress | undefined,
|
|
21
|
+
registerClass: boolean,
|
|
22
|
+
publicDeploy: boolean,
|
|
23
|
+
skipInitialization: boolean,
|
|
24
|
+
feeOpts: CLIFeeArgs,
|
|
25
|
+
waitForStatus: TxStatus,
|
|
11
26
|
json: boolean,
|
|
27
|
+
verbose: boolean,
|
|
12
28
|
debugLogger: Logger,
|
|
13
29
|
log: LogFn,
|
|
14
30
|
) {
|
|
15
31
|
const out: Record<string, any> = {};
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
32
|
+
|
|
33
|
+
const account = await wallet.createOrRetrieveAccount(address);
|
|
34
|
+
const { partialAddress, publicKeys } = await account.getCompleteAddress();
|
|
35
|
+
const { initializationHash, salt } = account.getInstance();
|
|
20
36
|
|
|
21
37
|
if (json) {
|
|
22
38
|
out.address = address;
|
|
@@ -28,65 +44,97 @@ export async function deployAccount(
|
|
|
28
44
|
log(`\nNew account:\n`);
|
|
29
45
|
log(`Address: ${address.toString()}`);
|
|
30
46
|
log(`Public key: ${publicKeys.toString()}`);
|
|
31
|
-
if (secretKey) {
|
|
32
|
-
log(`Secret key: ${secretKey.toString()}`);
|
|
33
|
-
}
|
|
34
47
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
35
48
|
log(`Salt: ${salt.toString()}`);
|
|
36
49
|
log(`Init hash: ${initializationHash.toString()}`);
|
|
37
|
-
log(`Deployer: ${deployer.toString()}`);
|
|
38
50
|
}
|
|
39
51
|
|
|
40
|
-
let
|
|
41
|
-
let txReceipt;
|
|
52
|
+
let txHash: TxHash | undefined;
|
|
53
|
+
let txReceipt: TxReceipt | undefined;
|
|
54
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
55
|
+
|
|
56
|
+
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
57
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
42
58
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
const deployAccountOpts: DeployAccountOptions = {
|
|
60
|
+
skipClassPublication: !registerClass,
|
|
61
|
+
skipInstancePublication: !publicDeploy,
|
|
62
|
+
skipInitialization,
|
|
63
|
+
from,
|
|
64
|
+
fee: { paymentMethod, gasSettings },
|
|
46
65
|
};
|
|
66
|
+
|
|
67
|
+
const localStart = performance.now();
|
|
68
|
+
const deployMethod = await account.getDeployMethod();
|
|
69
|
+
const sim = await deployMethod.simulate({
|
|
70
|
+
...deployAccountOpts,
|
|
71
|
+
fee: { ...deployAccountOpts.fee, estimateGas: true },
|
|
72
|
+
});
|
|
73
|
+
// estimateGas: true guarantees these fields are present
|
|
74
|
+
const estimatedGas = sim.estimatedGas!;
|
|
75
|
+
const stats = sim.stats!;
|
|
76
|
+
|
|
47
77
|
if (feeOpts.estimateOnly) {
|
|
48
|
-
const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
|
|
49
78
|
if (json) {
|
|
50
79
|
out.fee = {
|
|
51
80
|
gasLimits: {
|
|
52
|
-
da:
|
|
53
|
-
l2:
|
|
81
|
+
da: estimatedGas.gasLimits.daGas,
|
|
82
|
+
l2: estimatedGas.gasLimits.l2Gas,
|
|
54
83
|
},
|
|
55
84
|
teardownGasLimits: {
|
|
56
|
-
da:
|
|
57
|
-
l2:
|
|
85
|
+
da: estimatedGas.teardownGasLimits.daGas,
|
|
86
|
+
l2: estimatedGas.teardownGasLimits,
|
|
58
87
|
},
|
|
59
88
|
};
|
|
60
|
-
} else {
|
|
61
|
-
printGasEstimates(feeOpts, gas, log);
|
|
62
89
|
}
|
|
63
90
|
} else {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
if (verbose) {
|
|
92
|
+
printProfileResult(stats, log);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!json) {
|
|
96
|
+
log(`\nWaiting for account contract deployment...`);
|
|
97
|
+
}
|
|
98
|
+
const sendOpts = {
|
|
99
|
+
...deployAccountOpts,
|
|
100
|
+
fee: deployAccountOpts.fee
|
|
101
|
+
? {
|
|
102
|
+
...deployAccountOpts.fee,
|
|
103
|
+
gasSettings: estimatedGas,
|
|
104
|
+
}
|
|
105
|
+
: undefined,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
|
|
109
|
+
const localTimeMs = performance.now() - localStart;
|
|
110
|
+
|
|
68
111
|
if (wait) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
112
|
+
const nodeStart = performance.now();
|
|
113
|
+
txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
|
|
114
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
115
|
+
|
|
73
116
|
out.txReceipt = {
|
|
74
117
|
status: txReceipt.status,
|
|
75
118
|
transactionFee: txReceipt.transactionFee,
|
|
76
119
|
};
|
|
120
|
+
|
|
121
|
+
if (!json) {
|
|
122
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
123
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
124
|
+
}
|
|
77
125
|
}
|
|
126
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
127
|
+
out.txHash = txHash;
|
|
78
128
|
}
|
|
79
129
|
|
|
80
130
|
if (json) {
|
|
81
131
|
log(prettyPrintJSON(out));
|
|
82
132
|
} else {
|
|
83
|
-
if (
|
|
84
|
-
log(`Deploy tx hash: ${
|
|
133
|
+
if (txHash) {
|
|
134
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
85
135
|
}
|
|
86
136
|
if (txReceipt) {
|
|
87
137
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
|
88
138
|
}
|
|
89
139
|
}
|
|
90
|
-
|
|
91
|
-
return { address, secretKey, salt };
|
|
92
140
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
4
|
+
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
6
|
+
|
|
7
|
+
const FEE_JUICE_DECIMALS = 18;
|
|
8
|
+
const FEE_JUICE_UNIT = 10n ** BigInt(FEE_JUICE_DECIMALS);
|
|
9
|
+
|
|
10
|
+
/** Formats a raw FeeJuice balance (18 decimals) for human-readable display. */
|
|
11
|
+
function formatFeeJuice(raw: bigint, exact: boolean): string {
|
|
12
|
+
const whole = raw / FEE_JUICE_UNIT;
|
|
13
|
+
const fractional = raw % FEE_JUICE_UNIT;
|
|
14
|
+
const fracStr = fractional.toString().padStart(FEE_JUICE_DECIMALS, '0');
|
|
15
|
+
if (exact) {
|
|
16
|
+
return `${whole}.${fracStr} FJ`;
|
|
17
|
+
}
|
|
18
|
+
if (fractional === 0n) {
|
|
19
|
+
return `${whole} FJ`;
|
|
20
|
+
}
|
|
21
|
+
return `${whole}.${fracStr.replace(/0+$/, '')} FJ`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function getFeeJuiceBalanceCmd(
|
|
25
|
+
node: AztecNode,
|
|
26
|
+
address: AztecAddress,
|
|
27
|
+
json: boolean,
|
|
28
|
+
exact: boolean,
|
|
29
|
+
log: LogFn,
|
|
30
|
+
) {
|
|
31
|
+
const balance = await getFeeJuiceBalance(address, node);
|
|
32
|
+
if (json) {
|
|
33
|
+
log(prettyPrintJSON({ address: address.toString(), balance: balance.toString() }));
|
|
34
|
+
} else {
|
|
35
|
+
log(`Fee Juice balance for ${address.toString()}: ${formatFeeJuice(balance, exact)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -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) {
|