@aztec/cli-wallet 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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.js +5 -6
- package/dest/cmds/deploy.d.ts +3 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +20 -15
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +2 -2
- package/dest/utils/wallet.d.ts +4 -1
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +53 -18
- package/package.json +16 -15
- package/src/bin/index.ts +1 -1
- package/src/cmds/check_tx.ts +3 -3
- package/src/cmds/deploy.ts +19 -20
- package/src/cmds/index.ts +3 -2
- package/src/utils/wallet.ts +48 -16
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.js
CHANGED
|
@@ -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) {
|
package/dest/cmds/deploy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
4
4
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
@@ -6,5 +6,5 @@ import { PublicKeys } from '@aztec/stdlib/keys';
|
|
|
6
6
|
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
7
7
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
8
8
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
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
|
|
10
|
-
//# 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":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
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
|
@@ -8,14 +8,14 @@ import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
|
8
8
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
9
9
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
10
10
|
import { printProfileResult } from '../utils/profiling.js';
|
|
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
|
+
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) {
|
|
12
12
|
const out = {};
|
|
13
13
|
salt ??= Fr.random();
|
|
14
14
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
15
15
|
const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
|
|
16
16
|
const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
|
|
17
17
|
// TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
|
|
18
|
-
const contractDeployer = new ContractDeployer(contractArtifact, wallet,
|
|
18
|
+
const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
|
|
19
19
|
let args = [];
|
|
20
20
|
if (rawArgs.length > 0) {
|
|
21
21
|
if (!constructorArtifact) {
|
|
@@ -25,7 +25,13 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
25
25
|
args = encodeArgs(rawArgs, constructorArtifact.parameters);
|
|
26
26
|
debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
|
|
27
27
|
}
|
|
28
|
-
const deployInteraction = contractDeployer.deploy(
|
|
28
|
+
const deployInteraction = contractDeployer.deploy(args, {
|
|
29
|
+
salt,
|
|
30
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
31
|
+
...universal ? {
|
|
32
|
+
universalDeploy: true
|
|
33
|
+
} : {}
|
|
34
|
+
});
|
|
29
35
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
30
36
|
const deployOpts = {
|
|
31
37
|
fee: {
|
|
@@ -33,8 +39,6 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
33
39
|
paymentMethod
|
|
34
40
|
},
|
|
35
41
|
from: deployer ?? NO_FROM,
|
|
36
|
-
contractAddressSalt: salt,
|
|
37
|
-
universalDeploy: !deployer,
|
|
38
42
|
skipClassPublication,
|
|
39
43
|
skipInitialization,
|
|
40
44
|
skipInstancePublication
|
|
@@ -67,8 +71,9 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
67
71
|
if (verbose) {
|
|
68
72
|
printProfileResult(stats, log);
|
|
69
73
|
}
|
|
70
|
-
const { address, partialAddress } = deployInteraction;
|
|
71
74
|
const instance = await deployInteraction.getInstance();
|
|
75
|
+
const address = instance.address;
|
|
76
|
+
const partialAddress = await deployInteraction.getPartialAddress();
|
|
72
77
|
const { txHash } = await deployInteraction.send({
|
|
73
78
|
...deployOpts,
|
|
74
79
|
wait: NO_WAIT
|
|
@@ -84,8 +89,8 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
84
89
|
});
|
|
85
90
|
const nodeTimeMs = performance.now() - nodeStart;
|
|
86
91
|
if (!json) {
|
|
87
|
-
log(`Contract deployed at ${address
|
|
88
|
-
log(`Contract partial address ${
|
|
92
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
93
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
89
94
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
90
95
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
91
96
|
log(`Deployment salt: ${salt.toString()}`);
|
|
@@ -95,8 +100,8 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
95
100
|
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
96
101
|
} else {
|
|
97
102
|
out.contract = {
|
|
98
|
-
address: address
|
|
99
|
-
partialAddress:
|
|
103
|
+
address: address.toString(),
|
|
104
|
+
partialAddress: partialAddress.toString(),
|
|
100
105
|
initializationHash: instance.initializationHash.toString(),
|
|
101
106
|
salt: salt.toString(),
|
|
102
107
|
transactionFee: receipt.transactionFee?.toString()
|
|
@@ -104,16 +109,16 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
104
109
|
}
|
|
105
110
|
} else {
|
|
106
111
|
if (!json) {
|
|
107
|
-
log(`Contract deployed at ${address
|
|
108
|
-
log(`Contract partial address ${
|
|
112
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
113
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
109
114
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
110
115
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
111
116
|
log(`Deployment salt: ${salt.toString()}`);
|
|
112
117
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
113
118
|
} else {
|
|
114
119
|
out.contract = {
|
|
115
|
-
address: address
|
|
116
|
-
partialAddress:
|
|
120
|
+
address: address.toString(),
|
|
121
|
+
partialAddress: partialAddress.toString(),
|
|
117
122
|
initializationHash: instance.initializationHash.toString(),
|
|
118
123
|
salt: salt.toString()
|
|
119
124
|
};
|
|
@@ -123,5 +128,5 @@ export async function deploy(wallet, node, deployer, artifactPath, json, publicK
|
|
|
123
128
|
if (json) {
|
|
124
129
|
log(prettyPrintJSON(out));
|
|
125
130
|
}
|
|
126
|
-
return deployInteraction.
|
|
131
|
+
return await deployInteraction.getAddress();
|
|
127
132
|
}
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUczRCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQW1DdkYsd0JBQWdCLGNBQWMsQ0FDNUIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUssRUFDVixXQUFXLEVBQUUsTUFBTSxFQUNuQixvQkFBb0IsRUFBRSx1QkFBdUIsRUFDN0MsRUFBRSxFQUFFLFFBQVEsV0E4cEJiIn0=
|
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;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,
|
|
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,WA8pBb"}
|
package/dest/cmds/index.js
CHANGED
|
@@ -76,8 +76,8 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
76
76
|
const { json, publicKey, args, salt, wait, waitForStatus: waitForStatusStr, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
77
77
|
const { wallet, node } = walletAndNodeWrapper;
|
|
78
78
|
const artifactPath = await artifactPathPromise;
|
|
79
|
-
debugLogger.info(`Using wallet with address ${parsedFromAddress
|
|
80
|
-
const address = await deploy(wallet, node,
|
|
79
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress?.toString() ?? '<none>'}`);
|
|
80
|
+
const address = await deploy(wallet, node, 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, universal);
|
|
81
81
|
if (db && address) {
|
|
82
82
|
await db.storeContract(address, artifactPath, log, alias);
|
|
83
83
|
}
|
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -19,8 +19,11 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
19
19
|
private userLog;
|
|
20
20
|
private db?;
|
|
21
21
|
private accountCache;
|
|
22
|
+
private stubClassIds;
|
|
22
23
|
constructor(pxe: PXE, node: AztecNode, userLog: LogFn, db?: WalletDB | undefined);
|
|
23
24
|
static create(node: AztecNode, log: LogFn, db?: WalletDB, overridePXEConfig?: Partial<PXEConfig>): Promise<CLIWallet>;
|
|
25
|
+
private registerAuthRegistry;
|
|
26
|
+
private initStubClasses;
|
|
24
27
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
25
28
|
private createCancellationTxExecutionRequest;
|
|
26
29
|
proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
|
|
@@ -38,4 +41,4 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
38
41
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
39
42
|
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
40
43
|
}
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RixPQUFPLEVBQUUsS0FBSyxxQkFBcUIsRUFBOEMsTUFBTSwyQkFBMkIsQ0FBQztBQUNuSCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUYsT0FBTyxFQUFFLCtCQUErQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHekUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHdC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QyxPQUFPLEVBQUUsQ0FBQyxDQUVoRDtJQUlELG1CQUFtQixDQUFDLEVBQUUsRUFBRSxFQUFFLHFFQUV6QjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,KAAK,qBAAqB,EAA8C,MAAM,2BAA2B,CAAC;AACnH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAA2C,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,4BAA4B,EAAE,MA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BAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,+BAA+B,CAAC,CA2C1C;IAID,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtC;IAID,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
|
package/dest/utils/wallet.js
CHANGED
|
@@ -4,12 +4,13 @@ import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec
|
|
|
4
4
|
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
5
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
6
6
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
7
|
-
import {
|
|
7
|
+
import { getContractClassFromArtifact, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
8
8
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
9
9
|
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
10
10
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
11
11
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
12
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
13
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
15
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
15
16
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
@@ -20,14 +21,41 @@ export class CLIWallet extends BaseWallet {
|
|
|
20
21
|
userLog;
|
|
21
22
|
db;
|
|
22
23
|
accountCache;
|
|
24
|
+
// Stub class ids, populated on wallet startup
|
|
25
|
+
// to avoid redundant work per simulation
|
|
26
|
+
stubClassIds;
|
|
23
27
|
constructor(pxe, node, userLog, db){
|
|
24
|
-
super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map();
|
|
28
|
+
super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map(), this.stubClassIds = new Map();
|
|
25
29
|
this.cancellableTransactions = true;
|
|
26
30
|
}
|
|
27
31
|
static async create(node, log, db, overridePXEConfig) {
|
|
28
32
|
const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
|
|
29
33
|
const pxe = await createPXE(node, pxeConfig);
|
|
30
|
-
|
|
34
|
+
const wallet = new CLIWallet(pxe, node, log, db);
|
|
35
|
+
await wallet.initStubClasses();
|
|
36
|
+
await wallet.registerAuthRegistry();
|
|
37
|
+
return wallet;
|
|
38
|
+
}
|
|
39
|
+
async registerAuthRegistry() {
|
|
40
|
+
const { instance, artifact } = await getStandardAuthRegistry();
|
|
41
|
+
await this.pxe.registerContract({
|
|
42
|
+
instance,
|
|
43
|
+
artifact
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
48
|
+
* stubClassIds. Called on wallet initialization.
|
|
49
|
+
*/ async initStubClasses() {
|
|
50
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(StubSchnorrAccountContractArtifact);
|
|
51
|
+
await this.pxe.registerContractClass(StubSchnorrAccountContractArtifact);
|
|
52
|
+
// ecdsa stubs share the same class id
|
|
53
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
|
|
54
|
+
await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
|
|
55
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
56
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
57
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
58
|
+
this.stubClassIds.set('ecdsasecp256r1ssh', ecdsaClassId);
|
|
31
59
|
}
|
|
32
60
|
async getAccounts() {
|
|
33
61
|
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
@@ -59,7 +87,10 @@ export class CLIWallet extends BaseWallet {
|
|
|
59
87
|
}
|
|
60
88
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
61
89
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
62
|
-
return await this.pxe.proveTx(cancellationTxRequest,
|
|
90
|
+
return await this.pxe.proveTx(cancellationTxRequest, {
|
|
91
|
+
scopes: this.scopesFrom(from),
|
|
92
|
+
senderForTags: from
|
|
93
|
+
});
|
|
63
94
|
}
|
|
64
95
|
async getAccountFromAddress(address) {
|
|
65
96
|
let account;
|
|
@@ -75,7 +106,9 @@ export class CLIWallet extends BaseWallet {
|
|
|
75
106
|
return account;
|
|
76
107
|
}
|
|
77
108
|
async createAccount(secret, salt, contract) {
|
|
78
|
-
const accountManager = await AccountManager.create(this, secret, contract,
|
|
109
|
+
const accountManager = await AccountManager.create(this, secret, contract, {
|
|
110
|
+
salt
|
|
111
|
+
});
|
|
79
112
|
const instance = accountManager.getInstance();
|
|
80
113
|
const artifact = await contract.getContractArtifact();
|
|
81
114
|
await this.registerContract(instance, artifact, secret);
|
|
@@ -140,16 +173,18 @@ export class CLIWallet extends BaseWallet {
|
|
|
140
173
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
141
174
|
}
|
|
142
175
|
const { type } = await this.db.retrieveAccount(address);
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
176
|
+
const stubAccount = type === 'schnorr' ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
177
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
178
|
+
if (!stubClassId) {
|
|
179
|
+
throw new Error(`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`);
|
|
180
|
+
}
|
|
181
|
+
const instance = {
|
|
182
|
+
...contractInstance,
|
|
183
|
+
currentContractClassId: stubClassId
|
|
184
|
+
};
|
|
149
185
|
return {
|
|
150
186
|
account: stubAccount,
|
|
151
|
-
instance
|
|
152
|
-
artifact
|
|
187
|
+
instance
|
|
153
188
|
};
|
|
154
189
|
}
|
|
155
190
|
async simulateTx(executionPayload, opts) {
|
|
@@ -169,7 +204,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
169
204
|
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
170
205
|
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
171
206
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
172
|
-
const { from, feeOptions, additionalScopes } = opts;
|
|
207
|
+
const { from, feeOptions, additionalScopes, sendMessagesAs } = opts;
|
|
173
208
|
const scopes = this.scopesFrom(from, additionalScopes);
|
|
174
209
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
175
210
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
@@ -183,12 +218,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
183
218
|
const entrypoint = new DefaultEntrypoint();
|
|
184
219
|
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
185
220
|
} else {
|
|
186
|
-
const { account, instance
|
|
221
|
+
const { account, instance } = await this.getFakeAccountDataFor(from);
|
|
187
222
|
overrides = {
|
|
188
223
|
contracts: {
|
|
189
224
|
[from.toString()]: {
|
|
190
|
-
instance
|
|
191
|
-
artifact
|
|
225
|
+
instance
|
|
192
226
|
}
|
|
193
227
|
}
|
|
194
228
|
};
|
|
@@ -205,7 +239,8 @@ export class CLIWallet extends BaseWallet {
|
|
|
205
239
|
skipFeeEnforcement: true,
|
|
206
240
|
skipTxValidation: true,
|
|
207
241
|
overrides,
|
|
208
|
-
scopes
|
|
242
|
+
scopes,
|
|
243
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
209
244
|
});
|
|
210
245
|
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
211
246
|
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
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.b3d3157a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "node --no-warnings ./dest/bin",
|
|
21
21
|
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
22
|
-
"dev": "LOG_LEVEL
|
|
22
|
+
"dev": "LOG_LEVEL=\"debug; info: json-rpc, simulator\" node ./dest/bin",
|
|
23
23
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
24
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
25
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
@@ -67,19 +67,20 @@
|
|
|
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/
|
|
82
|
-
"@aztec/
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.b3d3157a",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.b3d3157a",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.b3d3157a",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.b3d3157a",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.b3d3157a",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.b3d3157a",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.b3d3157a",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.b3d3157a",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.b3d3157a",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.b3d3157a",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.b3d3157a",
|
|
81
|
+
"@aztec/standard-contracts": "0.0.1-commit.b3d3157a",
|
|
82
|
+
"@aztec/stdlib": "0.0.1-commit.b3d3157a",
|
|
83
|
+
"@aztec/wallet-sdk": "0.0.1-commit.b3d3157a",
|
|
83
84
|
"commander": "^12.1.0",
|
|
84
85
|
"inquirer": "^10.1.8",
|
|
85
86
|
"source-map-support": "^0.5.21",
|
package/src/bin/index.ts
CHANGED
|
@@ -73,7 +73,7 @@ function injectInternalCommands(program: Command, log: LogFn, db: WalletDB) {
|
|
|
73
73
|
|
|
74
74
|
/** CLI wallet main entrypoint */
|
|
75
75
|
async function main() {
|
|
76
|
-
const walletVersion = getPackageVersion()
|
|
76
|
+
const walletVersion = getPackageVersion();
|
|
77
77
|
|
|
78
78
|
const db = WalletDB.getInstance();
|
|
79
79
|
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -33,7 +33,7 @@ export async function checkTx(
|
|
|
33
33
|
// dependency when dropping PXE JSON RPC Server.
|
|
34
34
|
|
|
35
35
|
async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash, log: LogFn) {
|
|
36
|
-
const
|
|
36
|
+
const receipt = await aztecNode.getTxReceipt(txHash, { includeTxEffect: true });
|
|
37
37
|
// Base tx data
|
|
38
38
|
log(`Tx ${txHash.toString()}`);
|
|
39
39
|
log(` Status: ${receipt.status}`);
|
|
@@ -44,11 +44,11 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
44
44
|
log(` Error: ${receipt.error}`);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (!
|
|
47
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const effects =
|
|
51
|
+
const effects = receipt.txEffect;
|
|
52
52
|
const artifactMap = await getKnownArtifacts(wallet);
|
|
53
53
|
|
|
54
54
|
log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
|
-
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
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';
|
|
@@ -36,6 +36,7 @@ export async function deploy(
|
|
|
36
36
|
timeout: number = DEFAULT_TX_TIMEOUT_S,
|
|
37
37
|
debugLogger: Logger,
|
|
38
38
|
log: LogFn,
|
|
39
|
+
universal?: boolean,
|
|
39
40
|
) {
|
|
40
41
|
const out: Record<string, any> = {};
|
|
41
42
|
salt ??= Fr.random();
|
|
@@ -45,12 +46,7 @@ export async function deploy(
|
|
|
45
46
|
|
|
46
47
|
// TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
|
|
47
48
|
|
|
48
|
-
const contractDeployer = new ContractDeployer(
|
|
49
|
-
contractArtifact,
|
|
50
|
-
wallet,
|
|
51
|
-
publicKeys ?? PublicKeys.default(),
|
|
52
|
-
initializer,
|
|
53
|
-
);
|
|
49
|
+
const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
|
|
54
50
|
|
|
55
51
|
let args = [];
|
|
56
52
|
if (rawArgs.length > 0) {
|
|
@@ -62,13 +58,15 @@ export async function deploy(
|
|
|
62
58
|
debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
const deployInteraction = contractDeployer.deploy(
|
|
61
|
+
const deployInteraction = contractDeployer.deploy(args, {
|
|
62
|
+
salt,
|
|
63
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
64
|
+
...(universal ? { universalDeploy: true as const } : {}),
|
|
65
|
+
});
|
|
66
66
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
|
|
67
67
|
const deployOpts: DeployOptions = {
|
|
68
68
|
fee: { gasSettings, paymentMethod },
|
|
69
69
|
from: deployer ?? NO_FROM,
|
|
70
|
-
contractAddressSalt: salt,
|
|
71
|
-
universalDeploy: !deployer,
|
|
72
70
|
skipClassPublication,
|
|
73
71
|
skipInitialization,
|
|
74
72
|
skipInstancePublication,
|
|
@@ -101,8 +99,9 @@ export async function deploy(
|
|
|
101
99
|
printProfileResult(stats, log);
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
const { address, partialAddress } = deployInteraction;
|
|
105
102
|
const instance = await deployInteraction.getInstance();
|
|
103
|
+
const address = instance.address;
|
|
104
|
+
const partialAddress = await deployInteraction.getPartialAddress();
|
|
106
105
|
|
|
107
106
|
const { txHash } = await deployInteraction.send({ ...deployOpts, wait: NO_WAIT });
|
|
108
107
|
const localTimeMs = performance.now() - localStart;
|
|
@@ -115,8 +114,8 @@ export async function deploy(
|
|
|
115
114
|
const nodeTimeMs = performance.now() - nodeStart;
|
|
116
115
|
|
|
117
116
|
if (!json) {
|
|
118
|
-
log(`Contract deployed at ${address
|
|
119
|
-
log(`Contract partial address ${
|
|
117
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
118
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
120
119
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
121
120
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
122
121
|
log(`Deployment salt: ${salt.toString()}`);
|
|
@@ -126,8 +125,8 @@ export async function deploy(
|
|
|
126
125
|
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
127
126
|
} else {
|
|
128
127
|
out.contract = {
|
|
129
|
-
address: address
|
|
130
|
-
partialAddress:
|
|
128
|
+
address: address.toString(),
|
|
129
|
+
partialAddress: partialAddress.toString(),
|
|
131
130
|
initializationHash: instance.initializationHash.toString(),
|
|
132
131
|
salt: salt.toString(),
|
|
133
132
|
transactionFee: receipt.transactionFee?.toString(),
|
|
@@ -135,16 +134,16 @@ export async function deploy(
|
|
|
135
134
|
}
|
|
136
135
|
} else {
|
|
137
136
|
if (!json) {
|
|
138
|
-
log(`Contract deployed at ${address
|
|
139
|
-
log(`Contract partial address ${
|
|
137
|
+
log(`Contract deployed at ${address.toString()}`);
|
|
138
|
+
log(`Contract partial address ${partialAddress.toString()}`);
|
|
140
139
|
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
141
140
|
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
142
141
|
log(`Deployment salt: ${salt.toString()}`);
|
|
143
142
|
log(`Deployer: ${instance.deployer.toString()}`);
|
|
144
143
|
} else {
|
|
145
144
|
out.contract = {
|
|
146
|
-
address: address
|
|
147
|
-
partialAddress:
|
|
145
|
+
address: address.toString(),
|
|
146
|
+
partialAddress: partialAddress.toString(),
|
|
148
147
|
initializationHash: instance.initializationHash.toString(),
|
|
149
148
|
salt: salt.toString(),
|
|
150
149
|
};
|
|
@@ -154,5 +153,5 @@ export async function deploy(
|
|
|
154
153
|
if (json) {
|
|
155
154
|
log(prettyPrintJSON(out));
|
|
156
155
|
}
|
|
157
|
-
return deployInteraction.
|
|
156
|
+
return await deployInteraction.getAddress();
|
|
158
157
|
}
|
package/src/cmds/index.ts
CHANGED
|
@@ -297,12 +297,12 @@ export function injectCommands(
|
|
|
297
297
|
const { wallet, node } = walletAndNodeWrapper;
|
|
298
298
|
const artifactPath = await artifactPathPromise;
|
|
299
299
|
|
|
300
|
-
debugLogger.info(`Using wallet with address ${parsedFromAddress
|
|
300
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress?.toString() ?? '<none>'}`);
|
|
301
301
|
|
|
302
302
|
const address = await deploy(
|
|
303
303
|
wallet,
|
|
304
304
|
node,
|
|
305
|
-
|
|
305
|
+
parsedFromAddress,
|
|
306
306
|
artifactPath,
|
|
307
307
|
json,
|
|
308
308
|
publicKey,
|
|
@@ -319,6 +319,7 @@ export function injectCommands(
|
|
|
319
319
|
timeout,
|
|
320
320
|
debugLogger,
|
|
321
321
|
log,
|
|
322
|
+
universal,
|
|
322
323
|
);
|
|
323
324
|
if (db && address) {
|
|
324
325
|
await db.storeContract(address, artifactPath, log, alias);
|
package/src/utils/wallet.ts
CHANGED
|
@@ -4,11 +4,7 @@ import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec
|
|
|
4
4
|
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
5
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
6
6
|
import { type Account, type AccountContract, NO_FROM } from '@aztec/aztec.js/account';
|
|
7
|
-
import {
|
|
8
|
-
type InteractionFeeOptions,
|
|
9
|
-
getContractInstanceFromInstantiationParams,
|
|
10
|
-
getGasLimits,
|
|
11
|
-
} from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { type InteractionFeeOptions, getContractClassFromArtifact, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
12
8
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
13
9
|
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
14
10
|
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
@@ -20,6 +16,7 @@ import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
|
20
16
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
21
17
|
import type { PXE } from '@aztec/pxe/server';
|
|
22
18
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
19
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
23
20
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
21
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
25
22
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
@@ -34,6 +31,9 @@ import { printGasEstimates } from './options/fees.js';
|
|
|
34
31
|
|
|
35
32
|
export class CLIWallet extends BaseWallet {
|
|
36
33
|
private accountCache = new Map<string, Account>();
|
|
34
|
+
// Stub class ids, populated on wallet startup
|
|
35
|
+
// to avoid redundant work per simulation
|
|
36
|
+
private stubClassIds = new Map<AccountType, Fr>();
|
|
37
37
|
|
|
38
38
|
constructor(
|
|
39
39
|
pxe: PXE,
|
|
@@ -53,7 +53,33 @@ export class CLIWallet extends BaseWallet {
|
|
|
53
53
|
): Promise<CLIWallet> {
|
|
54
54
|
const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
|
|
55
55
|
const pxe = await createPXE(node, pxeConfig);
|
|
56
|
-
|
|
56
|
+
const wallet = new CLIWallet(pxe, node, log, db);
|
|
57
|
+
await wallet.initStubClasses();
|
|
58
|
+
await wallet.registerAuthRegistry();
|
|
59
|
+
return wallet;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private async registerAuthRegistry(): Promise<void> {
|
|
63
|
+
const { instance, artifact } = await getStandardAuthRegistry();
|
|
64
|
+
await this.pxe.registerContract({ instance, artifact });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
69
|
+
* stubClassIds. Called on wallet initialization.
|
|
70
|
+
*/
|
|
71
|
+
private async initStubClasses(): Promise<void> {
|
|
72
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(StubSchnorrAccountContractArtifact);
|
|
73
|
+
await this.pxe.registerContractClass(StubSchnorrAccountContractArtifact);
|
|
74
|
+
|
|
75
|
+
// ecdsa stubs share the same class id
|
|
76
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
|
|
77
|
+
await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
|
|
78
|
+
|
|
79
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
80
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
81
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
82
|
+
this.stubClassIds.set('ecdsasecp256r1ssh', ecdsaClassId);
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
override async getAccounts(): Promise<Aliased<AztecAddress>[]> {
|
|
@@ -100,7 +126,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
100
126
|
increasedFee: InteractionFeeOptions,
|
|
101
127
|
): Promise<TxProvingResult> {
|
|
102
128
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
103
|
-
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
129
|
+
return await this.pxe.proveTx(cancellationTxRequest, { scopes: this.scopesFrom(from), senderForTags: from });
|
|
104
130
|
}
|
|
105
131
|
|
|
106
132
|
override async getAccountFromAddress(address: AztecAddress) {
|
|
@@ -119,7 +145,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
119
145
|
}
|
|
120
146
|
|
|
121
147
|
private async createAccount(secret: Fr, salt: Fr, contract: AccountContract): Promise<AccountManager> {
|
|
122
|
-
const accountManager = await AccountManager.create(this, secret, contract, salt);
|
|
148
|
+
const accountManager = await AccountManager.create(this, secret, contract, { salt });
|
|
123
149
|
|
|
124
150
|
const instance = accountManager.getInstance();
|
|
125
151
|
const artifact = await contract.getContractArtifact();
|
|
@@ -202,11 +228,16 @@ export class CLIWallet extends BaseWallet {
|
|
|
202
228
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
203
229
|
}
|
|
204
230
|
const { type } = await this.db!.retrieveAccount(address);
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
231
|
+
const stubAccount =
|
|
232
|
+
type === 'schnorr' ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
233
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
234
|
+
if (!stubClassId) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`,
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
const instance = { ...contractInstance, currentContractClassId: stubClassId };
|
|
240
|
+
return { account: stubAccount, instance };
|
|
210
241
|
}
|
|
211
242
|
|
|
212
243
|
override async simulateTx(
|
|
@@ -235,7 +266,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
235
266
|
executionPayload: ExecutionPayload,
|
|
236
267
|
opts: SimulateViaEntrypointOptions,
|
|
237
268
|
): Promise<TxSimulationResultWithAppOffset> {
|
|
238
|
-
const { from, feeOptions, additionalScopes } = opts;
|
|
269
|
+
const { from, feeOptions, additionalScopes, sendMessagesAs } = opts;
|
|
239
270
|
const scopes = this.scopesFrom(from, additionalScopes);
|
|
240
271
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
241
272
|
const finalExecutionPayload = feeExecutionPayload
|
|
@@ -249,9 +280,9 @@ export class CLIWallet extends BaseWallet {
|
|
|
249
280
|
const entrypoint = new DefaultEntrypoint();
|
|
250
281
|
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
251
282
|
} else {
|
|
252
|
-
const { account, instance
|
|
283
|
+
const { account, instance } = await this.getFakeAccountDataFor(from);
|
|
253
284
|
overrides = {
|
|
254
|
-
contracts: { [from.toString()]: { instance
|
|
285
|
+
contracts: { [from.toString()]: { instance } },
|
|
255
286
|
};
|
|
256
287
|
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
257
288
|
txNonce: Fr.random(),
|
|
@@ -273,6 +304,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
273
304
|
skipTxValidation: true,
|
|
274
305
|
overrides,
|
|
275
306
|
scopes,
|
|
307
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
|
|
276
308
|
});
|
|
277
309
|
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
278
310
|
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|