@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.
- package/README.md +30 -0
- package/dest/bin/index.d.ts +2 -1
- package/dest/bin/index.js +39 -23
- 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 +8 -7
- 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 +9 -7
- 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 +148 -6
- package/dest/cmds/create_account.d.ts +8 -6
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +56 -62
- 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 +84 -50
- 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 +56 -65
- 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 +73 -112
- package/dest/cmds/profile.d.ts +7 -4
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +9 -4
- 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 +5 -6
- 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 +46 -31
- package/dest/cmds/simulate.d.ts +7 -4
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +12 -7
- package/dest/storage/wallet_db.d.ts +6 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +48 -54
- package/dest/utils/authorizations.d.ts +3 -2
- package/dest/utils/authorizations.d.ts.map +1 -1
- package/dest/utils/authorizations.js +1 -1
- 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 -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 +66 -133
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +3 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/profiling.d.ts.map +1 -1
- package/dest/utils/profiling.js +9 -1
- package/dest/utils/wallet.d.ts +40 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +208 -0
- package/package.json +17 -14
- package/src/bin/index.ts +39 -31
- package/src/cmds/authorize_action.ts +14 -6
- package/src/cmds/bridge_fee_juice.ts +15 -11
- package/src/cmds/check_tx.ts +180 -5
- package/src/cmds/create_account.ts +63 -66
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +82 -61
- package/src/cmds/deploy_account.ts +62 -64
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +120 -206
- package/src/cmds/profile.ts +14 -6
- package/src/cmds/register_contract.ts +9 -11
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +42 -40
- package/src/cmds/simulate.ts +17 -12
- package/src/storage/wallet_db.ts +52 -67
- package/src/utils/authorizations.ts +3 -1
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/constants.ts +4 -0
- package/src/utils/options/fees.ts +88 -178
- package/src/utils/options/options.ts +3 -2
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +290 -0
- 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 -43
- package/dest/utils/accounts.d.ts +0 -9
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -61
- package/dest/utils/pxe_wrapper.d.ts +0 -12
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -26
- package/src/cmds/cancel_tx.ts +0 -66
- package/src/utils/accounts.ts +0 -77
- package/src/utils/pxe_wrapper.ts +0 -32
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
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:
|
|
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 =
|
|
28
|
-
const
|
|
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,
|
|
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
|
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
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 {
|
|
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 {
|
|
15
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
16
16
|
|
|
17
17
|
export async function deploy(
|
|
18
|
-
wallet:
|
|
19
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 {
|
|
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';
|
|
6
11
|
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
-
import {
|
|
12
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
8
13
|
|
|
9
14
|
export async function deployAccount(
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
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
|
|
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
|
|
49
|
-
|
|
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
|
-
|
|
59
|
+
skipInstancePublication: !publicDeploy,
|
|
60
|
+
skipInitialization,
|
|
61
|
+
from,
|
|
62
|
+
fee: { paymentMethod, gasSettings },
|
|
52
63
|
};
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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:
|
|
80
|
-
l2:
|
|
75
|
+
da: estimatedGas.gasLimits.daGas,
|
|
76
|
+
l2: estimatedGas.gasLimits.l2Gas,
|
|
81
77
|
},
|
|
82
78
|
teardownGasLimits: {
|
|
83
|
-
da:
|
|
84
|
-
l2:
|
|
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(
|
|
86
|
+
printProfileResult(stats, log);
|
|
99
87
|
}
|
|
100
|
-
tx = provenTx.send();
|
|
101
88
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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 (
|
|
121
|
-
log(`Deploy tx hash: ${
|
|
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 {
|
|
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) {
|