@aztec/cli-wallet 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e
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/bin/index.js +1 -1
- package/dest/cmds/authorize_action.d.ts +2 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +42 -15
- 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 +32 -21
- package/dest/cmds/deploy.d.ts +5 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +43 -34
- 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 +27 -16
- 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 +31 -15
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -23
- package/dest/storage/wallet_db.d.ts +6 -1
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +14 -0
- package/dest/utils/options/fees.d.ts +3 -2
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +32 -9
- package/dest/utils/wallet.d.ts +14 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +115 -56
- package/package.json +16 -15
- package/src/bin/index.ts +1 -1
- package/src/cmds/check_tx.ts +46 -14
- package/src/cmds/create_account.ts +32 -18
- package/src/cmds/deploy.ts +40 -32
- package/src/cmds/deploy_account.ts +26 -13
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +60 -6
- package/src/cmds/send.ts +24 -16
- package/src/cmds/simulate.ts +1 -1
- package/src/storage/wallet_db.ts +14 -0
- package/src/utils/options/fees.ts +39 -9
- package/src/utils/wallet.ts +123 -76
package/dest/bin/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function injectInternalCommands(program, log, db) {
|
|
|
47
47
|
return program;
|
|
48
48
|
}
|
|
49
49
|
/** CLI wallet main entrypoint */ async function main() {
|
|
50
|
-
const walletVersion = getPackageVersion()
|
|
50
|
+
const walletVersion = getPackageVersion();
|
|
51
51
|
const db = WalletDB.getInstance();
|
|
52
52
|
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
|
53
53
|
const program = new Command('wallet');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
-
export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/stdlib/tx").TxReceipt
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js/contracts").TxSendResultMined<import("@aztec/stdlib/tx").TxReceipt>>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplX2FjdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYXV0aG9yaXplX2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUc5RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVyRCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUluRCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyx3R0E2QlgifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,wGA6BX"}
|
package/dest/cmds/check_tx.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { TxHash } from '@aztec/aztec.js/tx';
|
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
5
5
|
export declare function checkTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash, statusOnly: boolean, log: LogFn): Promise<import("@aztec/aztec.js/tx").TxStatus | undefined>;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NoZWNrX3R4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBUW5ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixPQUFPLENBQzNCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsVUFBVSxFQUFFLE9BQU8sRUFDbkIsR0FBRyxFQUFFLEtBQUssOERBUVgifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,EACnB,GAAG,EAAE,KAAK,8DAQX"}
|
package/dest/cmds/check_tx.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
2
|
-
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
2
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
3
3
|
export async function checkTx(wallet, aztecNode, txHash, statusOnly, log) {
|
|
4
4
|
if (statusOnly) {
|
|
5
5
|
const receipt = await aztecNode.getTxReceipt(txHash);
|
|
@@ -11,10 +11,9 @@ export async function checkTx(wallet, aztecNode, txHash, statusOnly, log) {
|
|
|
11
11
|
// The rest of the code here was copied over here from CLI because in CLI I needed to prune the inspect function of the PXE
|
|
12
12
|
// dependency when dropping PXE JSON RPC Server.
|
|
13
13
|
async function inspectTx(wallet, aztecNode, txHash, log) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
14
|
+
const receipt = await aztecNode.getTxReceipt(txHash, {
|
|
15
|
+
includeTxEffect: true
|
|
16
|
+
});
|
|
18
17
|
// Base tx data
|
|
19
18
|
log(`Tx ${txHash.toString()}`);
|
|
20
19
|
log(` Status: ${receipt.status}`);
|
|
@@ -24,10 +23,10 @@ async function inspectTx(wallet, aztecNode, txHash, log) {
|
|
|
24
23
|
if (receipt.error) {
|
|
25
24
|
log(` Error: ${receipt.error}`);
|
|
26
25
|
}
|
|
27
|
-
if (!
|
|
26
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
|
-
const effects =
|
|
29
|
+
const effects = receipt.txEffect;
|
|
31
30
|
const artifactMap = await getKnownArtifacts(wallet);
|
|
32
31
|
log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
|
|
33
32
|
if (receipt.transactionFee) {
|
|
@@ -61,13 +60,15 @@ async function inspectTx(wallet, aztecNode, txHash, log) {
|
|
|
61
60
|
// Nullifiers
|
|
62
61
|
const nullifierCount = effects.nullifiers.length;
|
|
63
62
|
const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
|
|
63
|
+
const accounts = (await wallet.getAccounts()).map((a)=>a.item);
|
|
64
64
|
if (nullifierCount > 0) {
|
|
65
65
|
log(' Nullifiers:');
|
|
66
66
|
for (const nullifier of effects.nullifiers){
|
|
67
67
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
68
68
|
const note = deployed ? (await wallet.getNotes({
|
|
69
69
|
siloedNullifier: nullifier,
|
|
70
|
-
contractAddress: deployed
|
|
70
|
+
contractAddress: deployed,
|
|
71
|
+
scopes: accounts
|
|
71
72
|
}))[0] : undefined;
|
|
72
73
|
const initialized = initNullifiers[nullifier.toString()];
|
|
73
74
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -111,17 +112,22 @@ function toFriendlyAddress(address, artifactMap) {
|
|
|
111
112
|
}
|
|
112
113
|
async function getKnownNullifiers(wallet, artifactMap) {
|
|
113
114
|
const knownContracts = await wallet.getContracts();
|
|
114
|
-
const
|
|
115
|
-
|
|
115
|
+
const [contractResults, classResults] = await Promise.all([
|
|
116
|
+
Promise.all(knownContracts.map((contract)=>getContractNullifiers(wallet, contract))),
|
|
117
|
+
Promise.all(Object.values(artifactMap).map((artifact)=>getClassNullifier(artifact)))
|
|
118
|
+
]);
|
|
116
119
|
const initNullifiers = {};
|
|
117
120
|
const deployNullifiers = {};
|
|
118
121
|
const classNullifiers = {};
|
|
119
|
-
for (const contract of
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults){
|
|
123
|
+
deployNullifiers[deployNullifier.toString()] = contract;
|
|
124
|
+
if (privateInitNullifier) {
|
|
125
|
+
initNullifiers[privateInitNullifier.toString()] = contract;
|
|
126
|
+
}
|
|
127
|
+
initNullifiers[publicInitNullifier.toString()] = contract;
|
|
122
128
|
}
|
|
123
|
-
for (const
|
|
124
|
-
classNullifiers[
|
|
129
|
+
for (const { nullifier, label } of classResults){
|
|
130
|
+
classNullifiers[nullifier.toString()] = label;
|
|
125
131
|
}
|
|
126
132
|
return {
|
|
127
133
|
initNullifiers,
|
|
@@ -129,6 +135,27 @@ async function getKnownNullifiers(wallet, artifactMap) {
|
|
|
129
135
|
classNullifiers
|
|
130
136
|
};
|
|
131
137
|
}
|
|
138
|
+
async function getContractNullifiers(wallet, contract) {
|
|
139
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
140
|
+
const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
|
|
141
|
+
const metadata = await wallet.getContractMetadata(contract);
|
|
142
|
+
const privateInitNullifier = metadata.instance ? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash) : undefined;
|
|
143
|
+
const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
|
|
144
|
+
return {
|
|
145
|
+
contract,
|
|
146
|
+
deployNullifier,
|
|
147
|
+
privateInitNullifier,
|
|
148
|
+
publicInitNullifier
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function getClassNullifier(artifact) {
|
|
152
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
153
|
+
const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
|
|
154
|
+
return {
|
|
155
|
+
nullifier,
|
|
156
|
+
label: `${artifact.name}Class<${artifact.classId}>`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
132
159
|
async function getKnownArtifacts(wallet) {
|
|
133
160
|
const knownContractAddresses = await wallet.getContracts();
|
|
134
161
|
const knownContracts = (await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)))).map((contractMetadata)=>contractMetadata.instance);
|
|
@@ -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":"
|
|
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
|
-
import {
|
|
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;
|
|
@@ -35,7 +36,7 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
35
36
|
if (!registerOnly) {
|
|
36
37
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
37
38
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
38
|
-
const from = delegatedDeployment ? deployer :
|
|
39
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
39
40
|
const deployAccountOpts = {
|
|
40
41
|
skipClassPublication: !registerClass,
|
|
41
42
|
skipInstancePublication: !publicDeploy,
|
|
@@ -46,14 +47,18 @@ 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
|
-
const
|
|
52
|
+
const sim = await deployMethod.simulate({
|
|
51
53
|
...deployAccountOpts,
|
|
52
54
|
fee: {
|
|
53
55
|
...deployAccountOpts.fee,
|
|
54
56
|
estimateGas: true
|
|
55
57
|
}
|
|
56
58
|
});
|
|
59
|
+
// estimateGas: true guarantees these fields are present
|
|
60
|
+
const estimatedGas = sim.estimatedGas;
|
|
61
|
+
const stats = sim.stats;
|
|
57
62
|
if (feeOpts.estimateOnly) {
|
|
58
63
|
if (json) {
|
|
59
64
|
out.fee = {
|
|
@@ -74,27 +79,33 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
74
79
|
if (!json) {
|
|
75
80
|
log(`\nWaiting for account contract deployment...`);
|
|
76
81
|
}
|
|
77
|
-
const
|
|
82
|
+
const sendOpts = {
|
|
78
83
|
...deployAccountOpts,
|
|
79
84
|
fee: deployAccountOpts.fee ? {
|
|
80
85
|
...deployAccountOpts.fee,
|
|
81
86
|
gasSettings: estimatedGas
|
|
82
|
-
} : undefined
|
|
83
|
-
|
|
87
|
+
} : undefined
|
|
88
|
+
};
|
|
89
|
+
({ txHash } = await deployMethod.send({
|
|
90
|
+
...sendOpts,
|
|
91
|
+
wait: NO_WAIT
|
|
92
|
+
}));
|
|
93
|
+
const localTimeMs = performance.now() - localStart;
|
|
94
|
+
if (wait) {
|
|
95
|
+
const nodeStart = performance.now();
|
|
96
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
84
97
|
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const isReceipt = (data)=>'txHash' in data;
|
|
89
|
-
if (isReceipt(result)) {
|
|
90
|
-
txReceipt = result;
|
|
91
|
-
txHash = result.txHash;
|
|
98
|
+
waitForStatus
|
|
99
|
+
});
|
|
100
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
92
101
|
out.txReceipt = {
|
|
93
102
|
status: txReceipt.status,
|
|
94
103
|
transactionFee: txReceipt.transactionFee
|
|
95
104
|
};
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
if (!json) {
|
|
106
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
107
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
108
|
+
}
|
|
98
109
|
}
|
|
99
110
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
100
111
|
out.txHash = txHash;
|
|
@@ -114,6 +125,6 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
114
125
|
alias,
|
|
115
126
|
address,
|
|
116
127
|
secretKey,
|
|
117
|
-
salt
|
|
128
|
+
salt: instanceSalt
|
|
118
129
|
};
|
|
119
130
|
}
|
package/dest/cmds/deploy.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
1
|
+
import type { 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
|
|
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, universal?: boolean): Promise<AztecAddress>;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9kZXBsb3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFJOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVDLE9BQU8sRUFBRSxLQUFLLFNBQVMsRUFBYSxNQUFNLHNCQUFzQixDQUFDO0FBRWpFLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUUzRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDaEQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFHakQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixNQUFNLENBQzFCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxTQUFTLEVBQ2YsUUFBUSxFQUFFLFlBQVksRUFDdEIsWUFBWSxFQUFFLE1BQU0sRUFDcEIsSUFBSSxFQUFFLE9BQU8sRUFDYixVQUFVLEVBQUUsVUFBVSxHQUFHLFNBQVMsRUFDbEMsT0FBTyxFQUFFLEdBQUcsRUFBRSxFQUNkLElBQUksRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUNwQixXQUFXLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDL0IsdUJBQXVCLEVBQUUsT0FBTyxFQUNoQyxvQkFBb0IsRUFBRSxPQUFPLEVBQzdCLGtCQUFrQixFQUFFLE9BQU8sR0FBRyxTQUFTLEVBQ3ZDLElBQUksRUFBRSxPQUFPLEVBQ2IsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsT0FBTyxvQkFBK0IsRUFDdEMsV0FBVyxFQUFFLE1BQU0sRUFDbkIsR0FBRyxFQUFFLEtBQUssRUFDVixTQUFTLENBQUMsRUFBRSxPQUFPLHlCQXNIcEIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,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,EACV,SAAS,CAAC,EAAE,OAAO,yBAsHpB"}
|
package/dest/cmds/deploy.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
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, universal) {
|
|
11
12
|
const out = {};
|
|
12
13
|
salt ??= Fr.random();
|
|
13
14
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
14
15
|
const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
|
|
15
16
|
const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
|
|
16
17
|
// TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
|
|
17
|
-
const contractDeployer = new ContractDeployer(contractArtifact, wallet,
|
|
18
|
+
const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
|
|
18
19
|
let args = [];
|
|
19
20
|
if (rawArgs.length > 0) {
|
|
20
21
|
if (!constructorArtifact) {
|
|
@@ -24,27 +25,35 @@ 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, {
|
|
29
|
+
salt,
|
|
30
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
31
|
+
...universal ? {
|
|
32
|
+
universalDeploy: true
|
|
33
|
+
} : {}
|
|
34
|
+
});
|
|
28
35
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
29
36
|
const deployOpts = {
|
|
30
37
|
fee: {
|
|
31
38
|
gasSettings,
|
|
32
39
|
paymentMethod
|
|
33
40
|
},
|
|
34
|
-
from: deployer ??
|
|
35
|
-
contractAddressSalt: salt,
|
|
36
|
-
universalDeploy: !deployer,
|
|
41
|
+
from: deployer ?? NO_FROM,
|
|
37
42
|
skipClassPublication,
|
|
38
43
|
skipInitialization,
|
|
39
44
|
skipInstancePublication
|
|
40
45
|
};
|
|
41
|
-
const
|
|
46
|
+
const localStart = performance.now();
|
|
47
|
+
const sim = await deployInteraction.simulate({
|
|
42
48
|
...deployOpts,
|
|
43
49
|
fee: {
|
|
44
50
|
...deployOpts.fee,
|
|
45
51
|
estimateGas: true
|
|
46
52
|
}
|
|
47
53
|
});
|
|
54
|
+
// estimateGas: true guarantees these fields are present
|
|
55
|
+
const estimatedGas = sim.estimatedGas;
|
|
56
|
+
const stats = sim.stats;
|
|
48
57
|
if (feeOpts.estimateOnly) {
|
|
49
58
|
if (json) {
|
|
50
59
|
out.fee = {
|
|
@@ -62,54 +71,54 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
62
71
|
if (verbose) {
|
|
63
72
|
printProfileResult(stats, log);
|
|
64
73
|
}
|
|
65
|
-
const
|
|
66
|
-
const
|
|
74
|
+
const instance = await deployInteraction.getInstance();
|
|
75
|
+
const address = instance.address;
|
|
76
|
+
const partialAddress = await deployInteraction.getPartialAddress();
|
|
77
|
+
const { txHash } = await deployInteraction.send({
|
|
78
|
+
...deployOpts,
|
|
79
|
+
wait: NO_WAIT
|
|
80
|
+
});
|
|
81
|
+
const localTimeMs = performance.now() - localStart;
|
|
82
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
83
|
+
out.hash = txHash;
|
|
67
84
|
if (wait) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
returnReceipt: true
|
|
73
|
-
}
|
|
85
|
+
const nodeStart = performance.now();
|
|
86
|
+
const receipt = await waitForTx(node, txHash, {
|
|
87
|
+
timeout,
|
|
88
|
+
waitForStatus
|
|
74
89
|
});
|
|
75
|
-
const
|
|
76
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
77
|
-
out.hash = txHash;
|
|
90
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
78
91
|
if (!json) {
|
|
79
|
-
log(`Contract deployed at ${address
|
|
80
|
-
log(`Contract partial address ${
|
|
92
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
93
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
81
94
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
82
95
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
83
96
|
log(`Deployment salt: ${salt.toString()}`);
|
|
84
97
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
85
98
|
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
99
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
100
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
86
101
|
} else {
|
|
87
102
|
out.contract = {
|
|
88
|
-
address: address
|
|
89
|
-
partialAddress:
|
|
103
|
+
address: address.toString(),
|
|
104
|
+
partialAddress: partialAddress.toString(),
|
|
90
105
|
initializationHash: instance.initializationHash.toString(),
|
|
91
106
|
salt: salt.toString(),
|
|
92
107
|
transactionFee: receipt.transactionFee?.toString()
|
|
93
108
|
};
|
|
94
109
|
}
|
|
95
110
|
} else {
|
|
96
|
-
const txHash = await deploy1.send({
|
|
97
|
-
...deployOpts,
|
|
98
|
-
wait: NO_WAIT
|
|
99
|
-
});
|
|
100
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
101
|
-
out.hash = txHash;
|
|
102
111
|
if (!json) {
|
|
103
|
-
log(`Contract deployed at ${address
|
|
104
|
-
log(`Contract partial address ${
|
|
112
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
113
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
105
114
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
106
115
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
107
116
|
log(`Deployment salt: ${salt.toString()}`);
|
|
108
117
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
109
118
|
} else {
|
|
110
119
|
out.contract = {
|
|
111
|
-
address: address
|
|
112
|
-
partialAddress:
|
|
120
|
+
address: address.toString(),
|
|
121
|
+
partialAddress: partialAddress.toString(),
|
|
113
122
|
initializationHash: instance.initializationHash.toString(),
|
|
114
123
|
salt: salt.toString()
|
|
115
124
|
};
|
|
@@ -119,5 +128,5 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
119
128
|
if (json) {
|
|
120
129
|
log(prettyPrintJSON(out));
|
|
121
130
|
}
|
|
122
|
-
return
|
|
131
|
+
return await deployInteraction.getAddress();
|
|
123
132
|
}
|
|
@@ -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":"
|
|
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
|
-
import {
|
|
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();
|
|
@@ -26,7 +27,7 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
26
27
|
let txReceipt;
|
|
27
28
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
28
29
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
29
|
-
const from = delegatedDeployment ? deployer :
|
|
30
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
30
31
|
const deployAccountOpts = {
|
|
31
32
|
skipClassPublication: !registerClass,
|
|
32
33
|
skipInstancePublication: !publicDeploy,
|
|
@@ -37,14 +38,18 @@ 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
|
-
const
|
|
43
|
+
const sim = await deployMethod.simulate({
|
|
42
44
|
...deployAccountOpts,
|
|
43
45
|
fee: {
|
|
44
46
|
...deployAccountOpts.fee,
|
|
45
47
|
estimateGas: true
|
|
46
48
|
}
|
|
47
49
|
});
|
|
50
|
+
// estimateGas: true guarantees these fields are present
|
|
51
|
+
const estimatedGas = sim.estimatedGas;
|
|
52
|
+
const stats = sim.stats;
|
|
48
53
|
if (feeOpts.estimateOnly) {
|
|
49
54
|
if (json) {
|
|
50
55
|
out.fee = {
|
|
@@ -65,27 +70,33 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
65
70
|
if (!json) {
|
|
66
71
|
log(`\nWaiting for account contract deployment...`);
|
|
67
72
|
}
|
|
68
|
-
const
|
|
73
|
+
const sendOpts = {
|
|
69
74
|
...deployAccountOpts,
|
|
70
75
|
fee: deployAccountOpts.fee ? {
|
|
71
76
|
...deployAccountOpts.fee,
|
|
72
77
|
gasSettings: estimatedGas
|
|
73
|
-
} : undefined
|
|
74
|
-
|
|
78
|
+
} : undefined
|
|
79
|
+
};
|
|
80
|
+
({ txHash } = await deployMethod.send({
|
|
81
|
+
...sendOpts,
|
|
82
|
+
wait: NO_WAIT
|
|
83
|
+
}));
|
|
84
|
+
const localTimeMs = performance.now() - localStart;
|
|
85
|
+
if (wait) {
|
|
86
|
+
const nodeStart = performance.now();
|
|
87
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
75
88
|
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const isReceipt = (data)=>'txHash' in data;
|
|
80
|
-
if (isReceipt(result)) {
|
|
81
|
-
txReceipt = result;
|
|
82
|
-
txHash = result.txHash;
|
|
89
|
+
waitForStatus
|
|
90
|
+
});
|
|
91
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
83
92
|
out.txReceipt = {
|
|
84
93
|
status: txReceipt.status,
|
|
85
94
|
transactionFee: txReceipt.transactionFee
|
|
86
95
|
};
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
if (!json) {
|
|
97
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
98
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
99
|
+
}
|
|
89
100
|
}
|
|
90
101
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
91
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"}
|