@aztec/cli-wallet 0.0.1-commit.df81a97b5 → 0.0.1-commit.e0f15ab9b
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/dest/cmds/create_account.d.ts +4 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +22 -19
- package/dest/cmds/deploy.d.ts +4 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +22 -21
- package/dest/cmds/deploy_account.d.ts +4 -3
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +17 -14
- 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/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +30 -14
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +23 -22
- package/package.json +14 -14
- package/src/cmds/create_account.ts +23 -15
- package/src/cmds/deploy.ts +19 -14
- package/src/cmds/deploy_account.ts +17 -10
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +56 -3
- package/src/cmds/send.ts +20 -15
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import type
|
|
2
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
6
|
import type { AccountType } from '../utils/constants.js';
|
|
6
7
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
7
8
|
import { CLIWallet } from '../utils/wallet.js';
|
|
8
|
-
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, secretKey: Fr | undefined, publicKey: string | undefined, alias: string | undefined, deployer: AztecAddress | undefined, registerOnly: boolean, skipInitialization: boolean, publicDeploy: boolean, registerClass: boolean, wait: boolean, feeOpts: CLIFeeArgs, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
|
|
9
|
+
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, secretKey: Fr | undefined, salt: Fr | undefined, publicKey: string | undefined, alias: string | undefined, deployer: AztecAddress | undefined, registerOnly: boolean, skipInitialization: boolean, publicDeploy: boolean, registerClass: boolean, wait: boolean, feeOpts: CLIFeeArgs, waitForStatus: TxStatus, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
|
|
9
10
|
alias: string | undefined;
|
|
10
11
|
address: AztecAddress;
|
|
11
12
|
secretKey: Fr;
|
|
12
13
|
salt: Fr;
|
|
13
14
|
}>;
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUV6RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSxzQkFBc0IsQ0FBQztBQUdqRSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzNELE9BQU8sRUFBK0IsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFHekUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDekQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXRELE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUUvQyx3QkFBc0IsYUFBYSxDQUNqQyxNQUFNLEVBQUUsU0FBUyxFQUNqQixTQUFTLEVBQUUsU0FBUyxFQUNwQixXQUFXLEVBQUUsV0FBVyxFQUN4QixTQUFTLEVBQUUsRUFBRSxHQUFHLFNBQVMsRUFDekIsSUFBSSxFQUFFLEVBQUUsR0FBRyxTQUFTLEVBQ3BCLFNBQVMsRUFBRSxNQUFNLEdBQUcsU0FBUyxFQUM3QixLQUFLLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDekIsUUFBUSxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQ2xDLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGtCQUFrQixFQUFFLE9BQU8sRUFDM0IsWUFBWSxFQUFFLE9BQU8sRUFDckIsYUFBYSxFQUFFLE9BQU8sRUFDdEIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsVUFBVSxFQUNuQixhQUFhLEVBQUUsUUFBUSxFQUN2QixJQUFJLEVBQUUsT0FBTyxFQUNiLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLFdBQVcsRUFBRSxNQUFNLEVBQ25CLEdBQUcsRUFBRSxLQUFLOzs7OztHQWdJWCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAA+B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,YAAY,EAAE,OAAO,EACrB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,QAAQ,EACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAgIX"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
4
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
4
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
6
7
|
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
-
export async function createAccount(wallet, aztecNode, accountType, secretKey, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, json, verbose, debugLogger, log) {
|
|
8
|
+
export async function createAccount(wallet, aztecNode, accountType, secretKey, salt, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, waitForStatus, json, verbose, debugLogger, log) {
|
|
8
9
|
secretKey ??= Fr.random();
|
|
9
|
-
const account = await wallet.createOrRetrieveAccount(undefined /* address, we don't have it yet */ , secretKey, accountType,
|
|
10
|
-
const
|
|
10
|
+
const account = await wallet.createOrRetrieveAccount(undefined /* address, we don't have it yet */ , secretKey, accountType, salt, publicKey);
|
|
11
|
+
const instanceSalt = account.getInstance().salt;
|
|
11
12
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
12
13
|
const out = {};
|
|
13
14
|
if (json) {
|
|
@@ -17,7 +18,7 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
17
18
|
out.secretKey = secretKey;
|
|
18
19
|
}
|
|
19
20
|
out.partialAddress = partialAddress;
|
|
20
|
-
out.salt =
|
|
21
|
+
out.salt = instanceSalt;
|
|
21
22
|
out.initHash = account.getInstance().initializationHash;
|
|
22
23
|
} else {
|
|
23
24
|
log(`\nNew account:\n`);
|
|
@@ -27,7 +28,7 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
27
28
|
log(`Secret key: ${secretKey.toString()}`);
|
|
28
29
|
}
|
|
29
30
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
30
|
-
log(`Salt: ${
|
|
31
|
+
log(`Salt: ${instanceSalt.toString()}`);
|
|
31
32
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
32
33
|
}
|
|
33
34
|
let txHash;
|
|
@@ -46,6 +47,7 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
46
47
|
gasSettings
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
const localStart = performance.now();
|
|
49
51
|
const deployMethod = await account.getDeployMethod();
|
|
50
52
|
const sim = await deployMethod.simulate({
|
|
51
53
|
...deployAccountOpts,
|
|
@@ -84,25 +86,26 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
84
86
|
gasSettings: estimatedGas
|
|
85
87
|
} : undefined
|
|
86
88
|
};
|
|
89
|
+
({ txHash } = await deployMethod.send({
|
|
90
|
+
...sendOpts,
|
|
91
|
+
wait: NO_WAIT
|
|
92
|
+
}));
|
|
93
|
+
const localTimeMs = performance.now() - localStart;
|
|
87
94
|
if (wait) {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
returnReceipt: true
|
|
93
|
-
}
|
|
95
|
+
const nodeStart = performance.now();
|
|
96
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
97
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
98
|
+
waitForStatus
|
|
94
99
|
});
|
|
95
|
-
|
|
96
|
-
txHash = receipt.txHash;
|
|
100
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
97
101
|
out.txReceipt = {
|
|
98
102
|
status: txReceipt.status,
|
|
99
103
|
transactionFee: txReceipt.transactionFee
|
|
100
104
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}));
|
|
105
|
+
if (!json) {
|
|
106
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
107
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
108
111
|
out.txHash = txHash;
|
|
@@ -122,6 +125,6 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
122
125
|
alias,
|
|
123
126
|
address,
|
|
124
127
|
secretKey,
|
|
125
|
-
salt
|
|
128
|
+
salt: instanceSalt
|
|
126
129
|
};
|
|
127
130
|
}
|
package/dest/cmds/deploy.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import type
|
|
3
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
4
4
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
5
5
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
6
7
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
7
8
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
8
|
-
export declare function deploy(wallet: CLIWallet, node: AztecNode, deployer: AztecAddress, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipInstancePublication: boolean, skipClassPublication: boolean, skipInitialization: boolean | undefined, wait: boolean, feeOpts: CLIFeeArgs, verbose: boolean, timeout: number | undefined, debugLogger: Logger, log: LogFn): Promise<AztecAddress | undefined>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
export declare function deploy(wallet: CLIWallet, node: AztecNode, deployer: AztecAddress, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipInstancePublication: boolean, skipClassPublication: boolean, skipInitialization: boolean | undefined, wait: boolean, feeOpts: CLIFeeArgs, waitForStatus: TxStatus, verbose: boolean, timeout: number | undefined, debugLogger: Logger, log: LogFn): Promise<AztecAddress | undefined>;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9kZXBsb3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBSXpELE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1QyxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSxzQkFBc0IsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFM0QsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2hELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR2pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVwRCx3QkFBc0IsTUFBTSxDQUMxQixNQUFNLEVBQUUsU0FBUyxFQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLFFBQVEsRUFBRSxZQUFZLEVBQ3RCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLElBQUksRUFBRSxPQUFPLEVBQ2IsVUFBVSxFQUFFLFVBQVUsR0FBRyxTQUFTLEVBQ2xDLE9BQU8sRUFBRSxHQUFHLEVBQUUsRUFDZCxJQUFJLEVBQUUsRUFBRSxHQUFHLFNBQVMsRUFDcEIsV0FBVyxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQy9CLHVCQUF1QixFQUFFLE9BQU8sRUFDaEMsb0JBQW9CLEVBQUUsT0FBTyxFQUM3QixrQkFBa0IsRUFBRSxPQUFPLEdBQUcsU0FBUyxFQUN2QyxJQUFJLEVBQUUsT0FBTyxFQUNiLE9BQU8sRUFBRSxVQUFVLEVBQ25CLGFBQWEsRUFBRSxRQUFRLEVBQ3ZCLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLE9BQU8sb0JBQStCLEVBQ3RDLFdBQVcsRUFBRSxNQUFNLEVBQ25CLEdBQUcsRUFBRSxLQUFLLHFDQXdIWCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,MAAM,CAC1B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,kBAAkB,EAAE,OAAO,GAAG,SAAS,EACvC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,OAAO,EAChB,OAAO,oBAA+B,EACtC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,qCAwHX"}
|
package/dest/cmds/deploy.js
CHANGED
|
@@ -2,12 +2,13 @@ import { NO_FROM } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { ContractDeployer } from '@aztec/aztec.js/deployment';
|
|
4
4
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
5
6
|
import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
|
|
6
7
|
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
7
8
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
8
9
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
9
10
|
import { printProfileResult } from '../utils/profiling.js';
|
|
10
|
-
export async function deploy(wallet, node, deployer, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipInstancePublication, skipClassPublication, skipInitialization, wait, feeOpts, verbose, timeout = DEFAULT_TX_TIMEOUT_S, debugLogger, log) {
|
|
11
|
+
export async function deploy(wallet, node, deployer, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipInstancePublication, skipClassPublication, skipInitialization, wait, feeOpts, waitForStatus, verbose, timeout = DEFAULT_TX_TIMEOUT_S, debugLogger, log) {
|
|
11
12
|
const out = {};
|
|
12
13
|
salt ??= Fr.random();
|
|
13
14
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
@@ -24,7 +25,7 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
24
25
|
args = encodeArgs(rawArgs, constructorArtifact.parameters);
|
|
25
26
|
debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
const deployInteraction = contractDeployer.deploy(...args);
|
|
28
29
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
29
30
|
const deployOpts = {
|
|
30
31
|
fee: {
|
|
@@ -38,7 +39,8 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
38
39
|
skipInitialization,
|
|
39
40
|
skipInstancePublication
|
|
40
41
|
};
|
|
41
|
-
const
|
|
42
|
+
const localStart = performance.now();
|
|
43
|
+
const sim = await deployInteraction.simulate({
|
|
42
44
|
...deployOpts,
|
|
43
45
|
fee: {
|
|
44
46
|
...deployOpts.fee,
|
|
@@ -65,19 +67,22 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
65
67
|
if (verbose) {
|
|
66
68
|
printProfileResult(stats, log);
|
|
67
69
|
}
|
|
68
|
-
const { address, partialAddress } =
|
|
69
|
-
const instance = await
|
|
70
|
+
const { address, partialAddress } = deployInteraction;
|
|
71
|
+
const instance = await deployInteraction.getInstance();
|
|
72
|
+
const { txHash } = await deployInteraction.send({
|
|
73
|
+
...deployOpts,
|
|
74
|
+
wait: NO_WAIT
|
|
75
|
+
});
|
|
76
|
+
const localTimeMs = performance.now() - localStart;
|
|
77
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
78
|
+
out.hash = txHash;
|
|
70
79
|
if (wait) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
returnReceipt: true
|
|
76
|
-
}
|
|
80
|
+
const nodeStart = performance.now();
|
|
81
|
+
const receipt = await waitForTx(node, txHash, {
|
|
82
|
+
timeout,
|
|
83
|
+
waitForStatus
|
|
77
84
|
});
|
|
78
|
-
const
|
|
79
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
80
|
-
out.hash = txHash;
|
|
85
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
81
86
|
if (!json) {
|
|
82
87
|
log(`Contract deployed at ${address?.toString()}`);
|
|
83
88
|
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
@@ -86,6 +91,8 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
86
91
|
log(`Deployment salt: ${salt.toString()}`);
|
|
87
92
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
88
93
|
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
94
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
95
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
89
96
|
} else {
|
|
90
97
|
out.contract = {
|
|
91
98
|
address: address?.toString(),
|
|
@@ -96,12 +103,6 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
96
103
|
};
|
|
97
104
|
}
|
|
98
105
|
} else {
|
|
99
|
-
const { txHash } = await deploy1.send({
|
|
100
|
-
...deployOpts,
|
|
101
|
-
wait: NO_WAIT
|
|
102
|
-
});
|
|
103
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
104
|
-
out.hash = txHash;
|
|
105
106
|
if (!json) {
|
|
106
107
|
log(`Contract deployed at ${address?.toString()}`);
|
|
107
108
|
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
@@ -122,5 +123,5 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
122
123
|
if (json) {
|
|
123
124
|
log(prettyPrintJSON(out));
|
|
124
125
|
}
|
|
125
|
-
return
|
|
126
|
+
return deployInteraction.address;
|
|
126
127
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import type
|
|
2
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
3
3
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
4
5
|
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
5
6
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
6
|
-
export declare function deployAccount(wallet: CLIWallet, aztecNode: AztecNode, address: AztecAddress, wait: boolean, deployer: AztecAddress | undefined, registerClass: boolean, publicDeploy: boolean, skipInitialization: boolean, feeOpts: CLIFeeArgs, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<void>;
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
export declare function deployAccount(wallet: CLIWallet, aztecNode: AztecNode, address: AztecAddress, wait: boolean, deployer: AztecAddress | undefined, registerClass: boolean, publicDeploy: boolean, skipInitialization: boolean, feeOpts: CLIFeeArgs, waitForStatus: TxStatus, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2RlcGxveV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUV6RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSxzQkFBc0IsQ0FBQztBQUdqRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQXFCLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR3BFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRTNELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixhQUFhLENBQ2pDLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE9BQU8sRUFBRSxZQUFZLEVBQ3JCLElBQUksRUFBRSxPQUFPLEVBQ2IsUUFBUSxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQ2xDLGFBQWEsRUFBRSxPQUFPLEVBQ3RCLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGtCQUFrQixFQUFFLE9BQU8sRUFDM0IsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsT0FBTyxFQUNoQixXQUFXLEVBQUUsTUFBTSxFQUNuQixHQUFHLEVBQUUsS0FBSyxpQkErR1gifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_account.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy_account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"deploy_account.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy_account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAqB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,QAAQ,EACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,iBA+GX"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
4
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
4
5
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
6
|
import { printProfileResult } from '../utils/profiling.js';
|
|
6
|
-
export async function deployAccount(wallet, aztecNode, address, wait, deployer, registerClass, publicDeploy, skipInitialization, feeOpts, json, verbose, debugLogger, log) {
|
|
7
|
+
export async function deployAccount(wallet, aztecNode, address, wait, deployer, registerClass, publicDeploy, skipInitialization, feeOpts, waitForStatus, json, verbose, debugLogger, log) {
|
|
7
8
|
const out = {};
|
|
8
9
|
const account = await wallet.createOrRetrieveAccount(address);
|
|
9
10
|
const { partialAddress, publicKeys } = await account.getCompleteAddress();
|
|
@@ -37,6 +38,7 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
37
38
|
gasSettings
|
|
38
39
|
}
|
|
39
40
|
};
|
|
41
|
+
const localStart = performance.now();
|
|
40
42
|
const deployMethod = await account.getDeployMethod();
|
|
41
43
|
const sim = await deployMethod.simulate({
|
|
42
44
|
...deployAccountOpts,
|
|
@@ -75,25 +77,26 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
75
77
|
gasSettings: estimatedGas
|
|
76
78
|
} : undefined
|
|
77
79
|
};
|
|
80
|
+
({ txHash } = await deployMethod.send({
|
|
81
|
+
...sendOpts,
|
|
82
|
+
wait: NO_WAIT
|
|
83
|
+
}));
|
|
84
|
+
const localTimeMs = performance.now() - localStart;
|
|
78
85
|
if (wait) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
returnReceipt: true
|
|
84
|
-
}
|
|
86
|
+
const nodeStart = performance.now();
|
|
87
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
88
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
89
|
+
waitForStatus
|
|
85
90
|
});
|
|
86
|
-
|
|
87
|
-
txHash = receipt.txHash;
|
|
91
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
88
92
|
out.txReceipt = {
|
|
89
93
|
status: txReceipt.status,
|
|
90
94
|
transactionFee: txReceipt.transactionFee
|
|
91
95
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}));
|
|
96
|
+
if (!json) {
|
|
97
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
98
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
99
|
+
}
|
|
97
100
|
}
|
|
98
101
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
99
102
|
out.txHash = txHash;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
export declare function getFeeJuiceBalanceCmd(node: AztecNode, address: AztecAddress, json: boolean, exact: boolean, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2ZlZV9qdWljZV9iYWxhbmNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9nZXRfZmVlX2p1aWNlX2JhbGFuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFHdEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFtQm5ELHdCQUFzQixxQkFBcUIsQ0FDekMsSUFBSSxFQUFFLFNBQVMsRUFDZixPQUFPLEVBQUUsWUFBWSxFQUNyQixJQUFJLEVBQUUsT0FBTyxFQUNiLEtBQUssRUFBRSxPQUFPLEVBQ2QsR0FBRyxFQUFFLEtBQUssaUJBUVgifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_fee_juice_balance.d.ts","sourceRoot":"","sources":["../../src/cmds/get_fee_juice_balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAmBnD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,KAAK,iBAQX"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
2
|
+
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
|
+
const FEE_JUICE_DECIMALS = 18;
|
|
4
|
+
const FEE_JUICE_UNIT = 10n ** BigInt(FEE_JUICE_DECIMALS);
|
|
5
|
+
/** Formats a raw FeeJuice balance (18 decimals) for human-readable display. */ function formatFeeJuice(raw, exact) {
|
|
6
|
+
const whole = raw / FEE_JUICE_UNIT;
|
|
7
|
+
const fractional = raw % FEE_JUICE_UNIT;
|
|
8
|
+
const fracStr = fractional.toString().padStart(FEE_JUICE_DECIMALS, '0');
|
|
9
|
+
if (exact) {
|
|
10
|
+
return `${whole}.${fracStr} FJ`;
|
|
11
|
+
}
|
|
12
|
+
if (fractional === 0n) {
|
|
13
|
+
return `${whole} FJ`;
|
|
14
|
+
}
|
|
15
|
+
return `${whole}.${fracStr.replace(/0+$/, '')} FJ`;
|
|
16
|
+
}
|
|
17
|
+
export async function getFeeJuiceBalanceCmd(node, address, json, exact, log) {
|
|
18
|
+
const balance = await getFeeJuiceBalance(address, node);
|
|
19
|
+
if (json) {
|
|
20
|
+
log(prettyPrintJSON({
|
|
21
|
+
address: address.toString(),
|
|
22
|
+
balance: balance.toString()
|
|
23
|
+
}));
|
|
24
|
+
} else {
|
|
25
|
+
log(`Fee Juice balance for ${address.toString()}: ${formatFeeJuice(balance, exact)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dest/cmds/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { type Command } from 'commander';
|
|
|
3
3
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
4
4
|
import type { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
5
|
export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger, walletAndNodeWrapper: CliWalletAndNodeWrapper, db: WalletDB): Command;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUczRCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQW1DdkYsd0JBQWdCLGNBQWMsQ0FDNUIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUssRUFDVixXQUFXLEVBQUUsTUFBTSxFQUNuQixvQkFBb0IsRUFBRSx1QkFBdUIsRUFDN0MsRUFBRSxFQUFFLFFBQVEsV0E2cEJiIn0=
|
package/dest/cmds/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAmCvF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,uBAAuB,EAC7C,EAAE,EAAE,QAAQ,WA6pBb"}
|
package/dest/cmds/index.js
CHANGED
|
@@ -2,9 +2,20 @@ import { getIdentities } from '@aztec/accounts/utils';
|
|
|
2
2
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
3
|
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions, createSecretKeyOption, l1ChainIdOption, parseBigint, parseFieldFromHexString, parsePublicKey } from '@aztec/cli/utils';
|
|
4
4
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
6
|
import { Option } from 'commander';
|
|
6
7
|
import inquirer from 'inquirer';
|
|
7
8
|
import { ARTIFACT_DESCRIPTION, CLIFeeArgs, aliasedAddressParser, aliasedSecretKeyParser, aliasedTxHashParser, artifactPathFromPromiseOrAlias, artifactPathParser, cleanupAuthWitnesses, createAccountOption, createAliasOption, createArgsOption, createArtifactOption, createAuthwitnessOption, createContractAddressOption, createDebugExecutionStepsDirOption, createTypeOption, createVerboseOption, integerArgParser } from '../utils/options/index.js';
|
|
9
|
+
function parseWaitForStatus(status) {
|
|
10
|
+
switch(status){
|
|
11
|
+
case 'proposed':
|
|
12
|
+
return TxStatus.PROPOSED;
|
|
13
|
+
case 'checkpointed':
|
|
14
|
+
return TxStatus.CHECKPOINTED;
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`Invalid wait-for-status: ${status}. Use 'proposed' or 'checkpointed'.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
// TODO: This function is only used in 1 place so we could just inline this
|
|
9
20
|
export function injectCommands(program, log, debugLogger, walletAndNodeWrapper, db) {
|
|
10
21
|
program.command('import-test-accounts').description('Import test accounts from pxe.').option('--json', 'Emit output as json').action(async (options)=>{
|
|
@@ -13,13 +24,13 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
13
24
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
14
25
|
await importTestAccounts(wallet, db, json, log);
|
|
15
26
|
});
|
|
16
|
-
const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr account which uses an immutable key for authentication.').summary('Creates an aztec account that can be used for sending transactions.').addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db)).option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('--register-only', 'Just register the account on the Wallet. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
27
|
+
const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr account which uses an immutable key for authentication.').summary('Creates an aztec account that can be used for sending transactions.').addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db)).option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address. Defaults to 0.', parseFieldFromHexString).option('--register-only', 'Just register the account on the Wallet. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
17
28
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
18
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
|
|
29
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
19
30
|
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command)=>{
|
|
20
31
|
const { createAccount } = await import('./create_account.js');
|
|
21
32
|
const options = command.optsWithGlobals();
|
|
22
|
-
const { type, from: parsedFromAddress, secretKey, wait, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
33
|
+
const { type, from: parsedFromAddress, secretKey, salt, wait, waitForStatus: waitForStatusStr, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
23
34
|
let { publicKey } = options;
|
|
24
35
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
25
36
|
const identities = await getIdentities();
|
|
@@ -34,7 +45,7 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
34
45
|
publicKey = answers.identity.split(' ')[1];
|
|
35
46
|
}
|
|
36
47
|
const { wallet, node } = walletAndNodeWrapper;
|
|
37
|
-
const accountCreationResult = await createAccount(wallet, node, type, secretKey, publicKey, alias, parsedFromAddress, registerOnly, skipInitialization, publicDeploy, registerClass, wait, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
48
|
+
const accountCreationResult = await createAccount(wallet, node, type, secretKey, salt, publicKey, alias, parsedFromAddress, registerOnly, skipInitialization, publicDeploy, registerClass, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
38
49
|
if (db) {
|
|
39
50
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
40
51
|
await db.storeAccount(address, {
|
|
@@ -48,39 +59,39 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
48
59
|
});
|
|
49
60
|
const deployAccountCommand = program.command('deploy-account').description('Deploys an already registered aztec account that can be used for sending transactions.').argument('<address>', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
50
61
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
51
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').addOption(createVerboseOption());
|
|
62
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
52
63
|
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command)=>{
|
|
53
64
|
const { deployAccount } = await import('./deploy_account.js');
|
|
54
65
|
const options = command.optsWithGlobals();
|
|
55
|
-
const { wait, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
66
|
+
const { wait, waitForStatus: waitForStatusStr, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
56
67
|
const { wallet, node } = walletAndNodeWrapper;
|
|
57
|
-
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
68
|
+
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
58
69
|
});
|
|
59
|
-
const deployCommand = program.command('deploy').description('Deploys a compiled Aztec.nr contract to Aztec.').argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('--no-init', 'Leave the contract uninitialized').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address.', parseFieldFromHexString).option('--universal', 'Do not mix the sender address into the deployment.').addOption(createArgsOption(true, db)).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
70
|
+
const deployCommand = program.command('deploy').description('Deploys a compiled Aztec.nr contract to Aztec.').argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('--no-init', 'Leave the contract uninitialized').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address. Defaults to random.', parseFieldFromHexString).option('--universal', 'Do not mix the sender address into the deployment.').addOption(createArgsOption(true, db)).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
60
71
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
61
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(new Option('--timeout <number>', 'The amount of time in seconds to wait for the deployment to post to L2').conflicts('wait')).addOption(createVerboseOption());
|
|
72
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(new Option('--timeout <number>', 'The amount of time in seconds to wait for the deployment to post to L2').conflicts('wait')).option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
62
73
|
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
63
74
|
const { deploy } = await import('./deploy.js');
|
|
64
75
|
const options = command.optsWithGlobals();
|
|
65
|
-
const { json, publicKey, args, salt, wait, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
76
|
+
const { json, publicKey, args, salt, wait, waitForStatus: waitForStatusStr, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
66
77
|
const { wallet, node } = walletAndNodeWrapper;
|
|
67
78
|
const artifactPath = await artifactPathPromise;
|
|
68
79
|
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
69
|
-
const address = await deploy(wallet, node, universal ? undefined : parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db),
|
|
80
|
+
const address = await deploy(wallet, node, universal ? undefined : parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), verbose, timeout, debugLogger, log);
|
|
70
81
|
if (db && address) {
|
|
71
82
|
await db.storeContract(address, artifactPath, log, alias);
|
|
72
83
|
}
|
|
73
84
|
});
|
|
74
|
-
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createAuthwitnessOption('Authorization witness to use for the transaction. If using multiple, pass a comma separated string', !db, db)).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').addOption(createVerboseOption());
|
|
85
|
+
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createAuthwitnessOption('Authorization witness to use for the transaction. If using multiple, pass a comma separated string', !db, db)).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
75
86
|
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
76
87
|
const { send } = await import('./send.js');
|
|
77
88
|
const options = command.optsWithGlobals();
|
|
78
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, alias, authWitness: authWitnessArray, verbose } = options;
|
|
89
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, waitForStatus: waitForStatusStr, alias, authWitness: authWitnessArray, verbose } = options;
|
|
79
90
|
const { wallet, node } = walletAndNodeWrapper;
|
|
80
91
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
81
92
|
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
82
93
|
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
83
|
-
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
94
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, parseWaitForStatus(waitForStatusStr), verbose, log);
|
|
84
95
|
if (db && sentTx) {
|
|
85
96
|
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
86
97
|
await db.storeTx(sentTx, log, txAlias);
|
|
@@ -118,6 +129,11 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
118
129
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
119
130
|
}
|
|
120
131
|
});
|
|
132
|
+
program.command('get-fee-juice-balance').description('Checks the Fee Juice balance for a given address.').argument('<address>', 'Aztec address or alias to check balance for', (address)=>aliasedAddressParser('accounts', address, db)).option('--json', 'Emit output as json').option('--exact', 'Show exact balance with all 18 decimal places').action(async (address, options)=>{
|
|
133
|
+
const { getFeeJuiceBalanceCmd } = await import('./get_fee_juice_balance.js');
|
|
134
|
+
const { json, exact } = options;
|
|
135
|
+
await getFeeJuiceBalanceCmd(walletAndNodeWrapper.node, address, json, exact, log);
|
|
136
|
+
});
|
|
121
137
|
program.command('create-authwit').description('Creates an authorization witness that can be privately sent to a caller so they can perform an action on behalf of the provided account').argument('<functionName>', 'Name of function to authorize').argument('<caller>', 'Account to be authorized to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db)).action(async (functionName, caller, _options, command)=>{
|
|
122
138
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
123
139
|
const options = command.optsWithGlobals();
|
package/dest/cmds/send.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import type
|
|
3
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
4
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
6
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
7
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
|
-
export declare function send(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<{
|
|
8
|
+
export declare function send(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], waitForStatus: TxStatus, verbose: boolean, log: LogFn): Promise<{
|
|
8
9
|
txHash: import("@aztec/stdlib/tx").TxHash;
|
|
9
10
|
} | undefined>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvc2VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFNUQsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUFhLE1BQU0sc0JBQXNCLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRzVDLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVwRCx3QkFBc0IsSUFBSSxDQUN4QixNQUFNLEVBQUUsU0FBUyxFQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixJQUFJLEVBQUUsT0FBTyxFQUNiLFdBQVcsRUFBRSxPQUFPLEVBQ3BCLE9BQU8sRUFBRSxVQUFVLEVBQ25CLGFBQWEsRUFBRSxXQUFXLEVBQUUsRUFDNUIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUs7O2VBb0VYIn0=
|
package/dest/cmds/send.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,IAAI,CACxB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,WAAW,EAAE,EAC5B,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK;;eAoEX"}
|
package/dest/cmds/send.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Contract, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
2
3
|
import { prepTx } from '@aztec/cli/utils';
|
|
4
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
3
5
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
4
6
|
import { printProfileResult } from '../utils/profiling.js';
|
|
5
|
-
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
7
|
+
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, waitForStatus, verbose, log) {
|
|
6
8
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
9
|
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
8
10
|
const call = contract.methods[functionName](...functionArgs);
|
|
@@ -15,6 +17,7 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
15
17
|
from,
|
|
16
18
|
authWitnesses
|
|
17
19
|
};
|
|
20
|
+
const localStart = performance.now();
|
|
18
21
|
const sim = await call.simulate({
|
|
19
22
|
...sendOptions,
|
|
20
23
|
fee: {
|
|
@@ -31,25 +34,32 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
31
34
|
if (verbose) {
|
|
32
35
|
printProfileResult(stats, log);
|
|
33
36
|
}
|
|
37
|
+
const { txHash } = await call.send({
|
|
38
|
+
...sendOptions,
|
|
39
|
+
fee: {
|
|
40
|
+
...sendOptions.fee,
|
|
41
|
+
gasSettings: estimatedGas
|
|
42
|
+
},
|
|
43
|
+
wait: NO_WAIT
|
|
44
|
+
});
|
|
45
|
+
const localTimeMs = performance.now() - localStart;
|
|
46
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
34
47
|
if (wait) {
|
|
35
48
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
gasSettings: estimatedGas
|
|
41
|
-
},
|
|
42
|
-
wait: {
|
|
43
|
-
timeout: DEFAULT_TX_TIMEOUT_S
|
|
44
|
-
}
|
|
49
|
+
const nodeStart = performance.now();
|
|
50
|
+
const receipt = await waitForTx(node, txHash, {
|
|
51
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
52
|
+
waitForStatus
|
|
45
53
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
log(
|
|
54
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
55
|
+
const statusLabel = waitForStatus === TxStatus.PROPOSED ? 'proposed' : 'checkpointed';
|
|
56
|
+
log(`Transaction has been ${statusLabel}`);
|
|
49
57
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
50
58
|
log(` Status: ${receipt.status}`);
|
|
51
59
|
log(` Block number: ${receipt.blockNumber}`);
|
|
52
60
|
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
61
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
62
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
53
63
|
return {
|
|
54
64
|
txHash
|
|
55
65
|
};
|
|
@@ -58,15 +68,6 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
58
68
|
throw err;
|
|
59
69
|
}
|
|
60
70
|
} else {
|
|
61
|
-
const { txHash } = await call.send({
|
|
62
|
-
...sendOptions,
|
|
63
|
-
fee: {
|
|
64
|
-
...sendOptions.fee,
|
|
65
|
-
gasSettings: estimatedGas
|
|
66
|
-
},
|
|
67
|
-
wait: NO_WAIT
|
|
68
|
-
});
|
|
69
|
-
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
70
71
|
log('Transaction pending. Check status with check-tx');
|
|
71
72
|
return {
|
|
72
73
|
txHash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli-wallet",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e0f15ab9b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -67,19 +67,19 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
71
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/cli": "0.0.1-commit.
|
|
74
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
75
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
76
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
77
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
79
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
80
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.e0f15ab9b",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.e0f15ab9b",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.e0f15ab9b",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.e0f15ab9b",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.e0f15ab9b",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.e0f15ab9b",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.e0f15ab9b",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.e0f15ab9b",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e0f15ab9b",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.e0f15ab9b",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.e0f15ab9b",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.e0f15ab9b",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.e0f15ab9b",
|
|
83
83
|
"commander": "^12.1.0",
|
|
84
84
|
"inquirer": "^10.1.8",
|
|
85
85
|
"source-map-support": "^0.5.21",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
-
import type
|
|
4
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
5
5
|
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
7
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
9
|
-
import type
|
|
9
|
+
import { type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
10
10
|
|
|
11
11
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
12
12
|
import type { AccountType } from '../utils/constants.js';
|
|
@@ -19,6 +19,7 @@ export async function createAccount(
|
|
|
19
19
|
aztecNode: AztecNode,
|
|
20
20
|
accountType: AccountType,
|
|
21
21
|
secretKey: Fr | undefined,
|
|
22
|
+
salt: Fr | undefined,
|
|
22
23
|
publicKey: string | undefined,
|
|
23
24
|
alias: string | undefined,
|
|
24
25
|
deployer: AztecAddress | undefined,
|
|
@@ -28,6 +29,7 @@ export async function createAccount(
|
|
|
28
29
|
registerClass: boolean,
|
|
29
30
|
wait: boolean,
|
|
30
31
|
feeOpts: CLIFeeArgs,
|
|
32
|
+
waitForStatus: TxStatus,
|
|
31
33
|
json: boolean,
|
|
32
34
|
verbose: boolean,
|
|
33
35
|
debugLogger: Logger,
|
|
@@ -39,10 +41,10 @@ export async function createAccount(
|
|
|
39
41
|
undefined /* address, we don't have it yet */,
|
|
40
42
|
secretKey,
|
|
41
43
|
accountType,
|
|
42
|
-
|
|
44
|
+
salt,
|
|
43
45
|
publicKey,
|
|
44
46
|
);
|
|
45
|
-
const
|
|
47
|
+
const instanceSalt = account.getInstance().salt;
|
|
46
48
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
47
49
|
|
|
48
50
|
const out: Record<string, any> = {};
|
|
@@ -53,7 +55,7 @@ export async function createAccount(
|
|
|
53
55
|
out.secretKey = secretKey;
|
|
54
56
|
}
|
|
55
57
|
out.partialAddress = partialAddress;
|
|
56
|
-
out.salt =
|
|
58
|
+
out.salt = instanceSalt;
|
|
57
59
|
out.initHash = account.getInstance().initializationHash;
|
|
58
60
|
} else {
|
|
59
61
|
log(`\nNew account:\n`);
|
|
@@ -63,7 +65,7 @@ export async function createAccount(
|
|
|
63
65
|
log(`Secret key: ${secretKey.toString()}`);
|
|
64
66
|
}
|
|
65
67
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
66
|
-
log(`Salt: ${
|
|
68
|
+
log(`Salt: ${instanceSalt.toString()}`);
|
|
67
69
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -83,6 +85,7 @@ export async function createAccount(
|
|
|
83
85
|
fee: { paymentMethod, gasSettings },
|
|
84
86
|
};
|
|
85
87
|
|
|
88
|
+
const localStart = performance.now();
|
|
86
89
|
const deployMethod = await account.getDeployMethod();
|
|
87
90
|
const sim = await deployMethod.simulate({
|
|
88
91
|
...deployAccountOpts,
|
|
@@ -122,19 +125,24 @@ export async function createAccount(
|
|
|
122
125
|
}
|
|
123
126
|
: undefined,
|
|
124
127
|
};
|
|
128
|
+
|
|
129
|
+
({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
|
|
130
|
+
const localTimeMs = performance.now() - localStart;
|
|
131
|
+
|
|
125
132
|
if (wait) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
txReceipt = receipt;
|
|
131
|
-
txHash = receipt.txHash;
|
|
133
|
+
const nodeStart = performance.now();
|
|
134
|
+
txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
|
|
135
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
136
|
+
|
|
132
137
|
out.txReceipt = {
|
|
133
138
|
status: txReceipt.status,
|
|
134
139
|
transactionFee: txReceipt.transactionFee,
|
|
135
140
|
};
|
|
136
|
-
|
|
137
|
-
(
|
|
141
|
+
|
|
142
|
+
if (!json) {
|
|
143
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
144
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
145
|
+
}
|
|
138
146
|
}
|
|
139
147
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
140
148
|
out.txHash = txHash;
|
|
@@ -152,5 +160,5 @@ export async function createAccount(
|
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
|
|
155
|
-
return { alias, address, secretKey, salt };
|
|
163
|
+
return { alias, address, secretKey, salt: instanceSalt };
|
|
156
164
|
}
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -4,11 +4,12 @@ import type { DeployOptions } from '@aztec/aztec.js/contracts';
|
|
|
4
4
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
5
5
|
import { ContractDeployer } from '@aztec/aztec.js/deployment';
|
|
6
6
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
-
import type
|
|
7
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
8
8
|
import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
|
|
9
9
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
10
10
|
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
11
11
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
12
13
|
|
|
13
14
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
14
15
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
@@ -30,6 +31,7 @@ export async function deploy(
|
|
|
30
31
|
skipInitialization: boolean | undefined,
|
|
31
32
|
wait: boolean,
|
|
32
33
|
feeOpts: CLIFeeArgs,
|
|
34
|
+
waitForStatus: TxStatus,
|
|
33
35
|
verbose: boolean,
|
|
34
36
|
timeout: number = DEFAULT_TX_TIMEOUT_S,
|
|
35
37
|
debugLogger: Logger,
|
|
@@ -60,7 +62,7 @@ export async function deploy(
|
|
|
60
62
|
debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
const
|
|
65
|
+
const deployInteraction = contractDeployer.deploy(...args);
|
|
64
66
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
65
67
|
const deployOpts: DeployOptions = {
|
|
66
68
|
fee: { gasSettings, paymentMethod },
|
|
@@ -72,7 +74,8 @@ export async function deploy(
|
|
|
72
74
|
skipInstancePublication,
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
const
|
|
77
|
+
const localStart = performance.now();
|
|
78
|
+
const sim = await deployInteraction.simulate({
|
|
76
79
|
...deployOpts,
|
|
77
80
|
fee: { ...deployOpts.fee, estimateGas: true },
|
|
78
81
|
});
|
|
@@ -98,14 +101,18 @@ export async function deploy(
|
|
|
98
101
|
printProfileResult(stats, log);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
const { address, partialAddress } =
|
|
102
|
-
const instance = await
|
|
104
|
+
const { address, partialAddress } = deployInteraction;
|
|
105
|
+
const instance = await deployInteraction.getInstance();
|
|
106
|
+
|
|
107
|
+
const { txHash } = await deployInteraction.send({ ...deployOpts, wait: NO_WAIT });
|
|
108
|
+
const localTimeMs = performance.now() - localStart;
|
|
109
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
110
|
+
out.hash = txHash;
|
|
103
111
|
|
|
104
112
|
if (wait) {
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
out.hash = txHash;
|
|
113
|
+
const nodeStart = performance.now();
|
|
114
|
+
const receipt = await waitForTx(node, txHash, { timeout, waitForStatus });
|
|
115
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
109
116
|
|
|
110
117
|
if (!json) {
|
|
111
118
|
log(`Contract deployed at ${address?.toString()}`);
|
|
@@ -115,6 +122,8 @@ export async function deploy(
|
|
|
115
122
|
log(`Deployment salt: ${salt.toString()}`);
|
|
116
123
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
117
124
|
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
125
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
126
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
118
127
|
} else {
|
|
119
128
|
out.contract = {
|
|
120
129
|
address: address?.toString(),
|
|
@@ -125,10 +134,6 @@ export async function deploy(
|
|
|
125
134
|
};
|
|
126
135
|
}
|
|
127
136
|
} else {
|
|
128
|
-
const { txHash } = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
129
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
130
|
-
out.hash = txHash;
|
|
131
|
-
|
|
132
137
|
if (!json) {
|
|
133
138
|
log(`Contract deployed at ${address?.toString()}`);
|
|
134
139
|
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
@@ -149,5 +154,5 @@ export async function deploy(
|
|
|
149
154
|
if (json) {
|
|
150
155
|
log(prettyPrintJSON(out));
|
|
151
156
|
}
|
|
152
|
-
return
|
|
157
|
+
return deployInteraction.address;
|
|
153
158
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
-
import type
|
|
4
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
5
5
|
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
7
7
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
|
-
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
10
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
11
11
|
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
@@ -22,6 +22,7 @@ export async function deployAccount(
|
|
|
22
22
|
publicDeploy: boolean,
|
|
23
23
|
skipInitialization: boolean,
|
|
24
24
|
feeOpts: CLIFeeArgs,
|
|
25
|
+
waitForStatus: TxStatus,
|
|
25
26
|
json: boolean,
|
|
26
27
|
verbose: boolean,
|
|
27
28
|
debugLogger: Logger,
|
|
@@ -63,6 +64,7 @@ export async function deployAccount(
|
|
|
63
64
|
fee: { paymentMethod, gasSettings },
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
const localStart = performance.now();
|
|
66
68
|
const deployMethod = await account.getDeployMethod();
|
|
67
69
|
const sim = await deployMethod.simulate({
|
|
68
70
|
...deployAccountOpts,
|
|
@@ -102,19 +104,24 @@ export async function deployAccount(
|
|
|
102
104
|
}
|
|
103
105
|
: undefined,
|
|
104
106
|
};
|
|
107
|
+
|
|
108
|
+
({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
|
|
109
|
+
const localTimeMs = performance.now() - localStart;
|
|
110
|
+
|
|
105
111
|
if (wait) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
txReceipt = receipt;
|
|
111
|
-
txHash = receipt.txHash;
|
|
112
|
+
const nodeStart = performance.now();
|
|
113
|
+
txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
|
|
114
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
115
|
+
|
|
112
116
|
out.txReceipt = {
|
|
113
117
|
status: txReceipt.status,
|
|
114
118
|
transactionFee: txReceipt.transactionFee,
|
|
115
119
|
};
|
|
116
|
-
|
|
117
|
-
(
|
|
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
|
+
}
|
|
118
125
|
}
|
|
119
126
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
120
127
|
out.txHash = txHash;
|
|
@@ -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
|
+
}
|
package/src/cmds/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@aztec/cli/utils';
|
|
13
13
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
14
14
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
15
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
15
16
|
|
|
16
17
|
import { type Command, Option } from 'commander';
|
|
17
18
|
import inquirer from 'inquirer';
|
|
@@ -40,6 +41,17 @@ import {
|
|
|
40
41
|
integerArgParser,
|
|
41
42
|
} from '../utils/options/index.js';
|
|
42
43
|
|
|
44
|
+
function parseWaitForStatus(status: string): TxStatus {
|
|
45
|
+
switch (status) {
|
|
46
|
+
case 'proposed':
|
|
47
|
+
return TxStatus.PROPOSED;
|
|
48
|
+
case 'checkpointed':
|
|
49
|
+
return TxStatus.CHECKPOINTED;
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Invalid wait-for-status: ${status}. Use 'proposed' or 'checkpointed'.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
// TODO: This function is only used in 1 place so we could just inline this
|
|
44
56
|
export function injectCommands(
|
|
45
57
|
program: Command,
|
|
@@ -90,6 +102,11 @@ export function injectCommands(
|
|
|
90
102
|
)
|
|
91
103
|
.addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db))
|
|
92
104
|
.addOption(createTypeOption(true))
|
|
105
|
+
.option(
|
|
106
|
+
'-s, --salt <hex string>',
|
|
107
|
+
'Optional deployment salt as a hex string for generating the deployment address. Defaults to 0.',
|
|
108
|
+
parseFieldFromHexString,
|
|
109
|
+
)
|
|
93
110
|
.option(
|
|
94
111
|
'--register-only',
|
|
95
112
|
'Just register the account on the Wallet. Do not deploy or initialize the account contract.',
|
|
@@ -98,6 +115,7 @@ export function injectCommands(
|
|
|
98
115
|
// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
99
116
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
100
117
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
118
|
+
.option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed')
|
|
101
119
|
.addOption(createVerboseOption());
|
|
102
120
|
|
|
103
121
|
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command) => {
|
|
@@ -107,7 +125,9 @@ export function injectCommands(
|
|
|
107
125
|
type,
|
|
108
126
|
from: parsedFromAddress,
|
|
109
127
|
secretKey,
|
|
128
|
+
salt,
|
|
110
129
|
wait,
|
|
130
|
+
waitForStatus: waitForStatusStr,
|
|
111
131
|
registerOnly,
|
|
112
132
|
skipInitialization,
|
|
113
133
|
publicDeploy,
|
|
@@ -137,6 +157,7 @@ export function injectCommands(
|
|
|
137
157
|
node,
|
|
138
158
|
type,
|
|
139
159
|
secretKey,
|
|
160
|
+
salt,
|
|
140
161
|
publicKey,
|
|
141
162
|
alias,
|
|
142
163
|
parsedFromAddress,
|
|
@@ -146,6 +167,7 @@ export function injectCommands(
|
|
|
146
167
|
registerClass,
|
|
147
168
|
wait,
|
|
148
169
|
CLIFeeArgs.parse(options, log, db),
|
|
170
|
+
parseWaitForStatus(waitForStatusStr),
|
|
149
171
|
json,
|
|
150
172
|
verbose,
|
|
151
173
|
debugLogger,
|
|
@@ -180,12 +202,22 @@ export function injectCommands(
|
|
|
180
202
|
'--skip-initialization',
|
|
181
203
|
'Skip initializing the account contract. Useful for publicly deploying an existing account.',
|
|
182
204
|
)
|
|
205
|
+
.option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed')
|
|
183
206
|
.addOption(createVerboseOption());
|
|
184
207
|
|
|
185
208
|
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command) => {
|
|
186
209
|
const { deployAccount } = await import('./deploy_account.js');
|
|
187
210
|
const options = command.optsWithGlobals();
|
|
188
|
-
const {
|
|
211
|
+
const {
|
|
212
|
+
wait,
|
|
213
|
+
waitForStatus: waitForStatusStr,
|
|
214
|
+
from: parsedFromAddress,
|
|
215
|
+
json,
|
|
216
|
+
registerClass,
|
|
217
|
+
skipInitialization,
|
|
218
|
+
publicDeploy,
|
|
219
|
+
verbose,
|
|
220
|
+
} = options;
|
|
189
221
|
|
|
190
222
|
const { wallet, node } = walletAndNodeWrapper;
|
|
191
223
|
|
|
@@ -199,6 +231,7 @@ export function injectCommands(
|
|
|
199
231
|
publicDeploy,
|
|
200
232
|
skipInitialization,
|
|
201
233
|
CLIFeeArgs.parse(options, log, db),
|
|
234
|
+
parseWaitForStatus(waitForStatusStr),
|
|
202
235
|
json,
|
|
203
236
|
verbose,
|
|
204
237
|
debugLogger,
|
|
@@ -219,7 +252,7 @@ export function injectCommands(
|
|
|
219
252
|
)
|
|
220
253
|
.option(
|
|
221
254
|
'-s, --salt <hex string>',
|
|
222
|
-
'Optional deployment salt as a hex string for generating the deployment address.',
|
|
255
|
+
'Optional deployment salt as a hex string for generating the deployment address. Defaults to random.',
|
|
223
256
|
parseFieldFromHexString,
|
|
224
257
|
)
|
|
225
258
|
.option('--universal', 'Do not mix the sender address into the deployment.')
|
|
@@ -238,6 +271,7 @@ export function injectCommands(
|
|
|
238
271
|
'The amount of time in seconds to wait for the deployment to post to L2',
|
|
239
272
|
).conflicts('wait'),
|
|
240
273
|
)
|
|
274
|
+
.option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed')
|
|
241
275
|
.addOption(createVerboseOption());
|
|
242
276
|
|
|
243
277
|
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command) => {
|
|
@@ -249,6 +283,7 @@ export function injectCommands(
|
|
|
249
283
|
args,
|
|
250
284
|
salt,
|
|
251
285
|
wait,
|
|
286
|
+
waitForStatus: waitForStatusStr,
|
|
252
287
|
classRegistration,
|
|
253
288
|
init,
|
|
254
289
|
publicDeployment,
|
|
@@ -279,8 +314,9 @@ export function injectCommands(
|
|
|
279
314
|
typeof init === 'string' ? false : init,
|
|
280
315
|
wait,
|
|
281
316
|
CLIFeeArgs.parse(options, log, db),
|
|
282
|
-
|
|
317
|
+
parseWaitForStatus(waitForStatusStr),
|
|
283
318
|
verbose,
|
|
319
|
+
timeout,
|
|
284
320
|
debugLogger,
|
|
285
321
|
log,
|
|
286
322
|
);
|
|
@@ -308,6 +344,7 @@ export function injectCommands(
|
|
|
308
344
|
)
|
|
309
345
|
.addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db))
|
|
310
346
|
.option('--no-wait', 'Print transaction hash without waiting for it to be mined')
|
|
347
|
+
.option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed')
|
|
311
348
|
.addOption(createVerboseOption());
|
|
312
349
|
|
|
313
350
|
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command) => {
|
|
@@ -319,6 +356,7 @@ export function injectCommands(
|
|
|
319
356
|
contractAddress,
|
|
320
357
|
from: parsedFromAddress,
|
|
321
358
|
wait,
|
|
359
|
+
waitForStatus: waitForStatusStr,
|
|
322
360
|
alias,
|
|
323
361
|
authWitness: authWitnessArray,
|
|
324
362
|
verbose,
|
|
@@ -342,6 +380,7 @@ export function injectCommands(
|
|
|
342
380
|
alias,
|
|
343
381
|
CLIFeeArgs.parse(options, log, db),
|
|
344
382
|
authWitnesses,
|
|
383
|
+
parseWaitForStatus(waitForStatusStr),
|
|
345
384
|
verbose,
|
|
346
385
|
log,
|
|
347
386
|
);
|
|
@@ -492,6 +531,20 @@ export function injectCommands(
|
|
|
492
531
|
}
|
|
493
532
|
});
|
|
494
533
|
|
|
534
|
+
program
|
|
535
|
+
.command('get-fee-juice-balance')
|
|
536
|
+
.description('Checks the Fee Juice balance for a given address.')
|
|
537
|
+
.argument('<address>', 'Aztec address or alias to check balance for', address =>
|
|
538
|
+
aliasedAddressParser('accounts', address, db),
|
|
539
|
+
)
|
|
540
|
+
.option('--json', 'Emit output as json')
|
|
541
|
+
.option('--exact', 'Show exact balance with all 18 decimal places')
|
|
542
|
+
.action(async (address, options) => {
|
|
543
|
+
const { getFeeJuiceBalanceCmd } = await import('./get_fee_juice_balance.js');
|
|
544
|
+
const { json, exact } = options;
|
|
545
|
+
await getFeeJuiceBalanceCmd(walletAndNodeWrapper.node, address, json, exact, log);
|
|
546
|
+
});
|
|
547
|
+
|
|
495
548
|
program
|
|
496
549
|
.command('create-authwit')
|
|
497
550
|
.description(
|
package/src/cmds/send.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { Contract, NO_WAIT, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
|
|
4
|
-
import type
|
|
4
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
5
5
|
import { prepTx } from '@aztec/cli/utils';
|
|
6
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
7
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
7
8
|
|
|
8
9
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
9
10
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
@@ -22,6 +23,7 @@ export async function send(
|
|
|
22
23
|
cancellable: boolean,
|
|
23
24
|
feeOpts: CLIFeeArgs,
|
|
24
25
|
authWitnesses: AuthWitness[],
|
|
26
|
+
waitForStatus: TxStatus,
|
|
25
27
|
verbose: boolean,
|
|
26
28
|
log: LogFn,
|
|
27
29
|
) {
|
|
@@ -37,6 +39,7 @@ export async function send(
|
|
|
37
39
|
authWitnesses,
|
|
38
40
|
};
|
|
39
41
|
|
|
42
|
+
const localStart = performance.now();
|
|
40
43
|
const sim = await call.simulate({
|
|
41
44
|
...sendOptions,
|
|
42
45
|
fee: { ...sendOptions.fee, estimateGas: true },
|
|
@@ -53,21 +56,29 @@ export async function send(
|
|
|
53
56
|
printProfileResult(stats!, log);
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
const { txHash } = await call.send({
|
|
60
|
+
...sendOptions,
|
|
61
|
+
fee: { ...sendOptions.fee, gasSettings: estimatedGas },
|
|
62
|
+
wait: NO_WAIT,
|
|
63
|
+
});
|
|
64
|
+
const localTimeMs = performance.now() - localStart;
|
|
65
|
+
|
|
66
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
67
|
+
|
|
56
68
|
if (wait) {
|
|
57
69
|
try {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
wait: { timeout: DEFAULT_TX_TIMEOUT_S },
|
|
62
|
-
});
|
|
70
|
+
const nodeStart = performance.now();
|
|
71
|
+
const receipt = await waitForTx(node, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
|
|
72
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
63
73
|
|
|
64
|
-
const
|
|
65
|
-
log(
|
|
66
|
-
log('Transaction has been mined');
|
|
74
|
+
const statusLabel = waitForStatus === TxStatus.PROPOSED ? 'proposed' : 'checkpointed';
|
|
75
|
+
log(`Transaction has been ${statusLabel}`);
|
|
67
76
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
68
77
|
log(` Status: ${receipt.status}`);
|
|
69
78
|
log(` Block number: ${receipt.blockNumber}`);
|
|
70
79
|
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
80
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
81
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
71
82
|
|
|
72
83
|
return {
|
|
73
84
|
txHash,
|
|
@@ -77,12 +88,6 @@ export async function send(
|
|
|
77
88
|
throw err;
|
|
78
89
|
}
|
|
79
90
|
} else {
|
|
80
|
-
const { txHash } = await call.send({
|
|
81
|
-
...sendOptions,
|
|
82
|
-
fee: { ...sendOptions.fee, gasSettings: estimatedGas },
|
|
83
|
-
wait: NO_WAIT,
|
|
84
|
-
});
|
|
85
|
-
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
86
91
|
log('Transaction pending. Check status with check-tx');
|
|
87
92
|
return {
|
|
88
93
|
txHash,
|