@aztec/cli-wallet 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928
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/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +49 -21
- package/dest/cmds/create_account.d.ts +6 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +48 -29
- package/dest/cmds/deploy.d.ts +5 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +43 -40
- 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 +23 -23
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- package/dest/cmds/import_test_accounts.d.ts +1 -1
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +2 -1
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +36 -19
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +26 -28
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +2 -1
- package/dest/storage/wallet_db.d.ts +12 -4
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +29 -1
- package/dest/utils/constants.d.ts +2 -2
- package/dest/utils/constants.d.ts.map +1 -1
- package/dest/utils/constants.js +1 -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 +36 -10
- package/dest/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +5 -5
- package/dest/utils/wallet.d.ts +34 -10
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +174 -97
- package/package.json +16 -15
- package/src/bin/index.ts +1 -1
- package/src/cmds/check_tx.ts +57 -24
- package/src/cmds/create_account.ts +50 -29
- package/src/cmds/deploy.ts +40 -35
- package/src/cmds/deploy_account.ts +23 -15
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +12 -1
- package/src/cmds/index.ts +70 -14
- package/src/cmds/send.ts +23 -18
- package/src/cmds/simulate.ts +2 -1
- package/src/storage/wallet_db.ts +38 -2
- package/src/utils/constants.ts +7 -1
- package/src/utils/options/fees.ts +42 -10
- package/src/utils/options/options.ts +5 -5
- package/src/utils/wallet.ts +221 -134
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');
|
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,6 +60,7 @@ 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){
|
|
@@ -68,7 +68,7 @@ async function inspectTx(wallet, aztecNode, txHash, log) {
|
|
|
68
68
|
const note = deployed ? (await wallet.getNotes({
|
|
69
69
|
siloedNullifier: nullifier,
|
|
70
70
|
contractAddress: deployed,
|
|
71
|
-
scopes:
|
|
71
|
+
scopes: accounts
|
|
72
72
|
}))[0] : undefined;
|
|
73
73
|
const initialized = initNullifiers[nullifier.toString()];
|
|
74
74
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -112,17 +112,22 @@ function toFriendlyAddress(address, artifactMap) {
|
|
|
112
112
|
}
|
|
113
113
|
async function getKnownNullifiers(wallet, artifactMap) {
|
|
114
114
|
const knownContracts = await wallet.getContracts();
|
|
115
|
-
const
|
|
116
|
-
|
|
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
|
+
]);
|
|
117
119
|
const initNullifiers = {};
|
|
118
120
|
const deployNullifiers = {};
|
|
119
121
|
const classNullifiers = {};
|
|
120
|
-
for (const contract of
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
|
123
128
|
}
|
|
124
|
-
for (const
|
|
125
|
-
classNullifiers[
|
|
129
|
+
for (const { nullifier, label } of classResults){
|
|
130
|
+
classNullifiers[nullifier.toString()] = label;
|
|
126
131
|
}
|
|
127
132
|
return {
|
|
128
133
|
initNullifiers,
|
|
@@ -130,22 +135,45 @@ async function getKnownNullifiers(wallet, artifactMap) {
|
|
|
130
135
|
classNullifiers
|
|
131
136
|
};
|
|
132
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
|
+
}
|
|
133
159
|
async function getKnownArtifacts(wallet) {
|
|
134
160
|
const knownContractAddresses = await wallet.getContracts();
|
|
135
|
-
const knownContracts =
|
|
161
|
+
const knownContracts = await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)));
|
|
162
|
+
const classIdFor = (metadata)=>metadata.updatedContractClassId ?? metadata.instance?.originalContractClassId;
|
|
136
163
|
const classIds = [
|
|
137
|
-
...new Set(knownContracts.map(
|
|
164
|
+
...new Set(knownContracts.map(classIdFor))
|
|
138
165
|
];
|
|
139
166
|
const knownArtifacts = (await Promise.all(classIds.map((classId)=>classId ? wallet.getContractArtifact(classId) : undefined))).map((artifact, index)=>artifact ? {
|
|
140
167
|
...artifact,
|
|
141
168
|
classId: classIds[index]
|
|
142
169
|
} : undefined);
|
|
143
170
|
const map = {};
|
|
144
|
-
for (const
|
|
145
|
-
|
|
146
|
-
|
|
171
|
+
for (const metadata of knownContracts){
|
|
172
|
+
const classId = classIdFor(metadata);
|
|
173
|
+
if (metadata.instance && classId) {
|
|
174
|
+
const artifact = knownArtifacts.find((a)=>a?.classId?.equals(classId));
|
|
147
175
|
if (artifact) {
|
|
148
|
-
map[instance.address.toString()] = artifact;
|
|
176
|
+
map[metadata.instance.address.toString()] = artifact;
|
|
149
177
|
}
|
|
150
178
|
}
|
|
151
179
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
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
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
6
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
7
|
import type { AccountType } from '../utils/constants.js';
|
|
6
8
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
7
9
|
import { CLIWallet } from '../utils/wallet.js';
|
|
8
|
-
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType,
|
|
10
|
+
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, signingKey: GrumpkinScalar | 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
11
|
alias: string | undefined;
|
|
10
12
|
address: AztecAddress;
|
|
13
|
+
signingKey: import("@aztec/foundation/curves/bn254").Fq | undefined;
|
|
11
14
|
secretKey: Fr;
|
|
12
15
|
salt: Fr;
|
|
13
16
|
}>;
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUV6RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSxzQkFBc0IsQ0FBQztBQUdqRSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUMzRCxPQUFPLEVBQStCLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR3pFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFL0Msd0JBQXNCLGFBQWEsQ0FDakMsTUFBTSxFQUFFLFNBQVMsRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsVUFBVSxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQ3RDLElBQUksRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUNwQixTQUFTLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDN0IsS0FBSyxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQ3pCLFFBQVEsRUFBRSxZQUFZLEdBQUcsU0FBUyxFQUNsQyxZQUFZLEVBQUUsT0FBTyxFQUNyQixrQkFBa0IsRUFBRSxPQUFPLEVBQzNCLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGFBQWEsRUFBRSxPQUFPLEVBQ3RCLElBQUksRUFBRSxPQUFPLEVBQ2IsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsT0FBTyxFQUNoQixXQUFXLEVBQUUsTUFBTSxFQUNuQixHQUFHLEVBQUUsS0FBSzs7Ozs7O0dBMElYIn0=
|
|
@@ -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":"AAEA,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,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,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,UAAU,EAAE,cAAc,GAAG,SAAS,EACtC,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;;;;;;GA0IX"}
|
|
@@ -1,41 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deriveSecretKeyFromSigningKey } from '@aztec/accounts/utils';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
5
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
4
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
5
8
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
6
9
|
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
-
export async function createAccount(wallet, aztecNode, accountType,
|
|
8
|
-
secretKey
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export async function createAccount(wallet, aztecNode, accountType, signingKey, salt, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, waitForStatus, json, verbose, debugLogger, log) {
|
|
11
|
+
let secretKey;
|
|
12
|
+
if (accountType === 'ecdsasecp256r1ssh') {
|
|
13
|
+
// SSH accounts sign with a key held in the agent, and so we cannot derive their privacy secret key from it. Instead
|
|
14
|
+
// we pick a random value.
|
|
15
|
+
secretKey = Fr.random();
|
|
16
|
+
} else {
|
|
17
|
+
signingKey ??= GrumpkinScalar.random();
|
|
18
|
+
secretKey = await deriveSecretKeyFromSigningKey(signingKey);
|
|
19
|
+
}
|
|
20
|
+
const account = await wallet.createAccount(accountType, signingKey, secretKey, salt, publicKey);
|
|
21
|
+
const instanceSalt = account.getInstance().salt;
|
|
11
22
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
12
23
|
const out = {};
|
|
13
24
|
if (json) {
|
|
14
25
|
out.address = address;
|
|
15
26
|
out.publicKey = publicKeys;
|
|
27
|
+
if (signingKey) {
|
|
28
|
+
out.signingKey = signingKey;
|
|
29
|
+
}
|
|
16
30
|
if (secretKey) {
|
|
17
31
|
out.secretKey = secretKey;
|
|
18
32
|
}
|
|
19
33
|
out.partialAddress = partialAddress;
|
|
20
|
-
out.salt =
|
|
34
|
+
out.salt = instanceSalt;
|
|
21
35
|
out.initHash = account.getInstance().initializationHash;
|
|
22
36
|
} else {
|
|
23
37
|
log(`\nNew account:\n`);
|
|
24
38
|
log(`Address: ${address.toString()}`);
|
|
25
39
|
log(`Public key: ${publicKeys.toString()}`);
|
|
40
|
+
if (signingKey) {
|
|
41
|
+
log(`Signing key: ${signingKey.toString()}`);
|
|
42
|
+
}
|
|
26
43
|
if (secretKey) {
|
|
27
44
|
log(`Secret key: ${secretKey.toString()}`);
|
|
28
45
|
}
|
|
29
46
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
30
|
-
log(`Salt: ${
|
|
47
|
+
log(`Salt: ${instanceSalt.toString()}`);
|
|
31
48
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
32
49
|
}
|
|
33
50
|
let txHash;
|
|
34
51
|
let txReceipt;
|
|
35
|
-
|
|
52
|
+
// Initializerless accounts have no deployment tx — creating one only registers it locally — so there is
|
|
53
|
+
// nothing to deploy on-chain.
|
|
54
|
+
if (!registerOnly && accountType !== 'schnorr_initializerless') {
|
|
36
55
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
37
56
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
38
|
-
const from = delegatedDeployment ? deployer :
|
|
57
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
39
58
|
const deployAccountOpts = {
|
|
40
59
|
skipClassPublication: !registerClass,
|
|
41
60
|
skipInstancePublication: !publicDeploy,
|
|
@@ -46,16 +65,14 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
46
65
|
gasSettings
|
|
47
66
|
}
|
|
48
67
|
};
|
|
68
|
+
const localStart = performance.now();
|
|
49
69
|
const deployMethod = await account.getDeployMethod();
|
|
50
70
|
const sim = await deployMethod.simulate({
|
|
51
71
|
...deployAccountOpts,
|
|
52
|
-
|
|
53
|
-
...deployAccountOpts.fee,
|
|
54
|
-
estimateGas: true
|
|
55
|
-
}
|
|
72
|
+
includeMetadata: true
|
|
56
73
|
});
|
|
57
|
-
//
|
|
58
|
-
const estimatedGas = sim.
|
|
74
|
+
// includeMetadata: true guarantees these fields are present
|
|
75
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
59
76
|
const stats = sim.stats;
|
|
60
77
|
if (feeOpts.estimateOnly) {
|
|
61
78
|
if (json) {
|
|
@@ -84,25 +101,26 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
84
101
|
gasSettings: estimatedGas
|
|
85
102
|
} : undefined
|
|
86
103
|
};
|
|
104
|
+
({ txHash } = await deployMethod.send({
|
|
105
|
+
...sendOpts,
|
|
106
|
+
wait: NO_WAIT
|
|
107
|
+
}));
|
|
108
|
+
const localTimeMs = performance.now() - localStart;
|
|
87
109
|
if (wait) {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
returnReceipt: true
|
|
93
|
-
}
|
|
110
|
+
const nodeStart = performance.now();
|
|
111
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
112
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
113
|
+
waitForStatus
|
|
94
114
|
});
|
|
95
|
-
|
|
96
|
-
txHash = receipt.txHash;
|
|
115
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
97
116
|
out.txReceipt = {
|
|
98
117
|
status: txReceipt.status,
|
|
99
118
|
transactionFee: txReceipt.transactionFee
|
|
100
119
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}));
|
|
120
|
+
if (!json) {
|
|
121
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
122
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
123
|
+
}
|
|
106
124
|
}
|
|
107
125
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
108
126
|
out.txHash = txHash;
|
|
@@ -121,7 +139,8 @@ export async function createAccount(wallet, aztecNode, accountType, secretKey, p
|
|
|
121
139
|
return {
|
|
122
140
|
alias,
|
|
123
141
|
address,
|
|
142
|
+
signingKey,
|
|
124
143
|
secretKey,
|
|
125
|
-
salt
|
|
144
|
+
salt: instanceSalt
|
|
126
145
|
};
|
|
127
146
|
}
|
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,29 +25,31 @@ 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
|
-
|
|
44
|
-
...deployOpts.fee,
|
|
45
|
-
estimateGas: true
|
|
46
|
-
}
|
|
49
|
+
includeMetadata: true
|
|
47
50
|
});
|
|
48
|
-
//
|
|
49
|
-
const estimatedGas = sim.
|
|
51
|
+
// includeMetadata: true guarantees these fields are present
|
|
52
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
50
53
|
const stats = sim.stats;
|
|
51
54
|
if (feeOpts.estimateOnly) {
|
|
52
55
|
if (json) {
|
|
@@ -65,54 +68,54 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
65
68
|
if (verbose) {
|
|
66
69
|
printProfileResult(stats, log);
|
|
67
70
|
}
|
|
68
|
-
const
|
|
69
|
-
const
|
|
71
|
+
const instance = await deployInteraction.getInstance();
|
|
72
|
+
const address = instance.address;
|
|
73
|
+
const partialAddress = await deployInteraction.getPartialAddress();
|
|
74
|
+
const { txHash } = await deployInteraction.send({
|
|
75
|
+
...deployOpts,
|
|
76
|
+
wait: NO_WAIT
|
|
77
|
+
});
|
|
78
|
+
const localTimeMs = performance.now() - localStart;
|
|
79
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
80
|
+
out.hash = txHash;
|
|
70
81
|
if (wait) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
returnReceipt: true
|
|
76
|
-
}
|
|
82
|
+
const nodeStart = performance.now();
|
|
83
|
+
const receipt = await waitForTx(node, txHash, {
|
|
84
|
+
timeout,
|
|
85
|
+
waitForStatus
|
|
77
86
|
});
|
|
78
|
-
const
|
|
79
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
80
|
-
out.hash = txHash;
|
|
87
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
81
88
|
if (!json) {
|
|
82
|
-
log(`Contract deployed at ${address
|
|
83
|
-
log(`Contract partial address ${
|
|
89
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
90
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
84
91
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
85
92
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
86
93
|
log(`Deployment salt: ${salt.toString()}`);
|
|
87
94
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
88
95
|
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
96
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
97
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
89
98
|
} else {
|
|
90
99
|
out.contract = {
|
|
91
|
-
address: address
|
|
92
|
-
partialAddress:
|
|
100
|
+
address: address.toString(),
|
|
101
|
+
partialAddress: partialAddress.toString(),
|
|
93
102
|
initializationHash: instance.initializationHash.toString(),
|
|
94
103
|
salt: salt.toString(),
|
|
95
104
|
transactionFee: receipt.transactionFee?.toString()
|
|
96
105
|
};
|
|
97
106
|
}
|
|
98
107
|
} 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
108
|
if (!json) {
|
|
106
|
-
log(`Contract deployed at ${address
|
|
107
|
-
log(`Contract partial address ${
|
|
109
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
110
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
108
111
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
109
112
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
110
113
|
log(`Deployment salt: ${salt.toString()}`);
|
|
111
114
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
112
115
|
} else {
|
|
113
116
|
out.contract = {
|
|
114
|
-
address: address
|
|
115
|
-
partialAddress:
|
|
117
|
+
address: address.toString(),
|
|
118
|
+
partialAddress: partialAddress.toString(),
|
|
116
119
|
initializationHash: instance.initializationHash.toString(),
|
|
117
120
|
salt: salt.toString()
|
|
118
121
|
};
|
|
@@ -122,5 +125,5 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
122
125
|
if (json) {
|
|
123
126
|
log(prettyPrintJSON(out));
|
|
124
127
|
}
|
|
125
|
-
return
|
|
128
|
+
return await deployInteraction.getAddress();
|
|
126
129
|
}
|
|
@@ -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,11 +1,12 @@
|
|
|
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
|
-
const account = await wallet.
|
|
9
|
+
const account = await wallet.retrieveAccount(address);
|
|
9
10
|
const { partialAddress, publicKeys } = await account.getCompleteAddress();
|
|
10
11
|
const { initializationHash, salt } = account.getInstance();
|
|
11
12
|
if (json) {
|
|
@@ -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,16 +38,14 @@ 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,
|
|
43
|
-
|
|
44
|
-
...deployAccountOpts.fee,
|
|
45
|
-
estimateGas: true
|
|
46
|
-
}
|
|
45
|
+
includeMetadata: true
|
|
47
46
|
});
|
|
48
|
-
//
|
|
49
|
-
const estimatedGas = sim.
|
|
47
|
+
// includeMetadata: true guarantees these fields are present
|
|
48
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
50
49
|
const stats = sim.stats;
|
|
51
50
|
if (feeOpts.estimateOnly) {
|
|
52
51
|
if (json) {
|
|
@@ -75,25 +74,26 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
75
74
|
gasSettings: estimatedGas
|
|
76
75
|
} : undefined
|
|
77
76
|
};
|
|
77
|
+
({ txHash } = await deployMethod.send({
|
|
78
|
+
...sendOpts,
|
|
79
|
+
wait: NO_WAIT
|
|
80
|
+
}));
|
|
81
|
+
const localTimeMs = performance.now() - localStart;
|
|
78
82
|
if (wait) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
returnReceipt: true
|
|
84
|
-
}
|
|
83
|
+
const nodeStart = performance.now();
|
|
84
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
85
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
86
|
+
waitForStatus
|
|
85
87
|
});
|
|
86
|
-
|
|
87
|
-
txHash = receipt.txHash;
|
|
88
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
88
89
|
out.txReceipt = {
|
|
89
90
|
status: txReceipt.status,
|
|
90
91
|
transactionFee: txReceipt.transactionFee
|
|
91
92
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}));
|
|
93
|
+
if (!json) {
|
|
94
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
95
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
96
|
+
}
|
|
97
97
|
}
|
|
98
98
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
99
99
|
out.txHash = txHash;
|