@aztec/cli-wallet 0.0.1-commit.b655e406 → 0.0.1-commit.c0b82b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dest/bin/index.d.ts +2 -1
- package/dest/bin/index.js +20 -10
- package/dest/cmds/authorize_action.d.ts +2 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +5 -3
- package/dest/cmds/bridge_fee_juice.d.ts +2 -2
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +3 -2
- package/dest/cmds/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.js +10 -7
- 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 +25 -19
- package/dest/cmds/create_authwit.d.ts +1 -1
- package/dest/cmds/create_authwit.js +1 -1
- package/dest/cmds/deploy.d.ts +1 -1
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +46 -23
- package/dest/cmds/deploy_account.d.ts +1 -1
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +24 -18
- package/dest/cmds/import_test_accounts.d.ts +1 -1
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.js +3 -3
- package/dest/cmds/profile.d.ts +1 -1
- package/dest/cmds/profile.js +1 -1
- package/dest/cmds/register_contract.d.ts +1 -1
- package/dest/cmds/register_sender.d.ts +1 -1
- package/dest/cmds/send.d.ts +2 -2
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +29 -17
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +4 -4
- package/dest/storage/wallet_db.d.ts +5 -5
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +47 -32
- package/dest/utils/authorizations.d.ts +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -1
- package/dest/utils/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +7 -0
- package/dest/utils/ecdsa.d.ts +1 -1
- package/dest/utils/options/fees.d.ts +3 -2
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +3 -3
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/profiling.d.ts.map +1 -1
- package/dest/utils/profiling.js +9 -1
- package/dest/utils/wallet.d.ts +15 -10
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +61 -46
- package/package.json +17 -14
- package/src/bin/index.ts +18 -12
- package/src/cmds/authorize_action.ts +2 -2
- package/src/cmds/bridge_fee_juice.ts +3 -2
- package/src/cmds/check_tx.ts +10 -12
- package/src/cmds/create_account.ts +26 -19
- package/src/cmds/create_authwit.ts +1 -1
- package/src/cmds/deploy.ts +41 -22
- package/src/cmds/deploy_account.ts +23 -17
- package/src/cmds/index.ts +4 -4
- package/src/cmds/profile.ts +1 -1
- package/src/cmds/send.ts +23 -11
- package/src/cmds/simulate.ts +4 -7
- package/src/storage/wallet_db.ts +51 -38
- package/src/utils/cli_wallet_and_node_wrapper.ts +1 -1
- package/src/utils/constants.ts +4 -0
- package/src/utils/options/fees.ts +5 -4
- package/src/utils/options/options.ts +1 -1
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +87 -61
package/dest/utils/wallet.js
CHANGED
|
@@ -4,21 +4,15 @@ import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/
|
|
|
4
4
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
5
|
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
6
6
|
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
|
-
import { AccountManager
|
|
8
|
-
import {
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
7
|
+
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
9
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
11
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
11
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
12
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
|
+
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
13
14
|
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
14
15
|
import { printGasEstimates } from './options/fees.js';
|
|
15
|
-
export const AccountTypes = [
|
|
16
|
-
'schnorr',
|
|
17
|
-
'ecdsasecp256r1',
|
|
18
|
-
'ecdsasecp256r1ssh',
|
|
19
|
-
'ecdsasecp256k1'
|
|
20
|
-
];
|
|
21
|
-
export const BASE_FEE_PADDING = 0.5;
|
|
22
16
|
export class CLIWallet extends BaseWallet {
|
|
23
17
|
userLog;
|
|
24
18
|
db;
|
|
@@ -40,25 +34,26 @@ export class CLIWallet extends BaseWallet {
|
|
|
40
34
|
})));
|
|
41
35
|
}
|
|
42
36
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
43
|
-
const
|
|
37
|
+
const executionPayload = ExecutionPayload.empty();
|
|
38
|
+
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
44
39
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
45
40
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
41
|
+
const chainInfo = await this.getChainInfo();
|
|
46
42
|
const executionOptions = {
|
|
47
43
|
txNonce,
|
|
48
44
|
cancellable: this.cancellableTransactions,
|
|
49
45
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
50
46
|
};
|
|
51
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ??
|
|
47
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
52
48
|
}
|
|
53
49
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
54
50
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
55
|
-
return await this.pxe.proveTx(cancellationTxRequest);
|
|
51
|
+
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
56
52
|
}
|
|
57
53
|
async getAccountFromAddress(address) {
|
|
58
54
|
let account;
|
|
59
55
|
if (address.equals(AztecAddress.ZERO)) {
|
|
60
|
-
|
|
61
|
-
account = new SignerlessAccount(chainInfo);
|
|
56
|
+
account = new SignerlessAccount();
|
|
62
57
|
} else if (this.accountCache.has(address.toString())) {
|
|
63
58
|
return this.accountCache.get(address.toString());
|
|
64
59
|
} else {
|
|
@@ -123,15 +118,25 @@ export class CLIWallet extends BaseWallet {
|
|
|
123
118
|
}
|
|
124
119
|
return account;
|
|
125
120
|
}
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
123
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
124
|
+
* @param address - The address of the account to impersonate
|
|
125
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
126
|
+
*/ async getFakeAccountDataFor(address) {
|
|
128
127
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
128
|
+
// Account contracts can only be overridden if they have an associated address
|
|
129
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
130
|
+
// since it has no authorization mechanism.
|
|
131
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
132
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
133
|
+
}
|
|
129
134
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
130
|
-
const
|
|
135
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
131
136
|
if (!contractInstance) {
|
|
132
137
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
133
138
|
}
|
|
134
|
-
const stubAccount = createStubAccount(originalAddress
|
|
139
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
135
140
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
136
141
|
salt: Fr.random()
|
|
137
142
|
});
|
|
@@ -142,8 +147,21 @@ export class CLIWallet extends BaseWallet {
|
|
|
142
147
|
};
|
|
143
148
|
}
|
|
144
149
|
async simulateTx(executionPayload, opts) {
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
const simulationResults = await super.simulateTx(executionPayload, opts);
|
|
151
|
+
if (opts.fee?.estimateGas) {
|
|
152
|
+
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
153
|
+
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
154
|
+
printGasEstimates(feeOptions, limits, this.userLog);
|
|
155
|
+
}
|
|
156
|
+
return simulationResults;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
160
|
+
* Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
|
|
161
|
+
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
|
|
162
|
+
if (from.equals(AztecAddress.ZERO)) {
|
|
163
|
+
return super.simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement);
|
|
164
|
+
}
|
|
147
165
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
148
166
|
const executionOptions = {
|
|
149
167
|
txNonce: Fr.random(),
|
|
@@ -154,31 +172,23 @@ export class CLIWallet extends BaseWallet {
|
|
|
154
172
|
feeExecutionPayload,
|
|
155
173
|
executionPayload
|
|
156
174
|
]) : executionPayload;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
artifact
|
|
175
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
176
|
+
const chainInfo = await this.getChainInfo();
|
|
177
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
178
|
+
return this.pxe.simulateTx(txRequest, {
|
|
179
|
+
simulatePublic: true,
|
|
180
|
+
skipFeeEnforcement: true,
|
|
181
|
+
skipTxValidation: true,
|
|
182
|
+
overrides: {
|
|
183
|
+
contracts: {
|
|
184
|
+
[from.toString()]: {
|
|
185
|
+
instance,
|
|
186
|
+
artifact
|
|
187
|
+
}
|
|
171
188
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (opts.fee?.estimateGas) {
|
|
178
|
-
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
179
|
-
printGasEstimates(feeOptions, limits, this.userLog);
|
|
180
|
-
}
|
|
181
|
-
return simulationResults;
|
|
189
|
+
},
|
|
190
|
+
scopes
|
|
191
|
+
});
|
|
182
192
|
}
|
|
183
193
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
184
194
|
// this is just a CLI wallet.
|
|
@@ -188,6 +198,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
188
198
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
189
199
|
// this is just a CLI wallet.
|
|
190
200
|
getNotes(filter) {
|
|
191
|
-
return this.pxe.getNotes(filter);
|
|
201
|
+
return this.pxe.debug.getNotes(filter);
|
|
202
|
+
}
|
|
203
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
204
|
+
// this is just a CLI wallet.
|
|
205
|
+
getContractArtifact(id) {
|
|
206
|
+
return this.pxe.getContractArtifact(id);
|
|
192
207
|
}
|
|
193
208
|
}
|
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.c0b82b2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"start": "node --no-warnings ./dest/bin",
|
|
21
21
|
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
22
22
|
"dev": "LOG_LEVEL=debug && node ./dest/bin",
|
|
23
|
-
"build": "yarn clean && tsc
|
|
24
|
-
"build:dev": "tsc
|
|
23
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
25
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
26
26
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
27
27
|
},
|
|
@@ -67,17 +67,19 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
71
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/noir-
|
|
79
|
-
"@aztec/
|
|
80
|
-
"@aztec/
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.c0b82b2",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.c0b82b2",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.c0b82b2",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.c0b82b2",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.c0b82b2",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.c0b82b2",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.c0b82b2",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.c0b82b2",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.c0b82b2",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.c0b82b2",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.c0b82b2",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.c0b82b2",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.c0b82b2",
|
|
81
83
|
"commander": "^12.1.0",
|
|
82
84
|
"inquirer": "^10.1.8",
|
|
83
85
|
"source-map-support": "^0.5.21",
|
|
@@ -88,6 +90,7 @@
|
|
|
88
90
|
"@types/jest": "^30.0.0",
|
|
89
91
|
"@types/node": "^22.15.17",
|
|
90
92
|
"@types/source-map-support": "^0.5.10",
|
|
93
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
91
94
|
"jest": "^30.0.0",
|
|
92
95
|
"jest-mock-extended": "^4.0.0",
|
|
93
96
|
"ts-jest": "^29.4.0",
|
package/src/bin/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
4
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
4
5
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
6
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
5
7
|
import { LOCALHOST } from '@aztec/cli/cli-utils';
|
|
6
8
|
import { type LogFn, createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
7
9
|
import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
|
|
@@ -9,10 +11,8 @@ import type { PXEConfig } from '@aztec/pxe/config';
|
|
|
9
11
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
12
|
|
|
11
13
|
import { Argument, Command, Option } from 'commander';
|
|
12
|
-
import { mkdirSync } from 'fs';
|
|
13
14
|
import { homedir } from 'os';
|
|
14
|
-
import {
|
|
15
|
-
import { fileURLToPath } from 'url';
|
|
15
|
+
import { join } from 'path';
|
|
16
16
|
|
|
17
17
|
import { injectCommands } from '../cmds/index.js';
|
|
18
18
|
import { Aliases, WalletDB } from '../storage/wallet_db.js';
|
|
@@ -95,22 +95,26 @@ async function main() {
|
|
|
95
95
|
.default(`http://${LOCALHOST}:8080`),
|
|
96
96
|
)
|
|
97
97
|
.hook('preSubcommand', async command => {
|
|
98
|
+
// Skip initialization if user is just requesting help
|
|
99
|
+
if (command.args.includes('--help') || command.args.includes('-h')) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
98
103
|
const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
|
|
99
104
|
|
|
100
105
|
const proverEnabled = prover !== 'none';
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
switch (prover) {
|
|
108
|
+
case 'native':
|
|
109
|
+
await Barretenberg.initSingleton({ backend: BackendType.NativeUnixSocket });
|
|
110
|
+
break;
|
|
111
|
+
case 'wasm':
|
|
112
|
+
await Barretenberg.initSingleton({ backend: BackendType.Wasm });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
109
115
|
|
|
110
116
|
const overridePXEConfig: Partial<PXEConfig> = {
|
|
111
117
|
proverEnabled,
|
|
112
|
-
bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
|
|
113
|
-
bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined,
|
|
114
118
|
dataDirectory: join(dataDir, 'pxe'),
|
|
115
119
|
};
|
|
116
120
|
|
|
@@ -142,6 +146,8 @@ async function main() {
|
|
|
142
146
|
injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
|
|
143
147
|
injectInternalCommands(program, userLog, db);
|
|
144
148
|
await program.parseAsync(process.argv);
|
|
149
|
+
|
|
150
|
+
await Barretenberg.destroySingleton();
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
main().catch(err => {
|
|
@@ -30,7 +30,7 @@ export async function authorizeAction(
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const contract =
|
|
33
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
34
34
|
const action = contract.methods[functionName](...functionArgs);
|
|
35
35
|
|
|
36
36
|
const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
@@ -39,7 +39,7 @@ export async function authorizeAction(
|
|
|
39
39
|
{ caller, action },
|
|
40
40
|
true,
|
|
41
41
|
);
|
|
42
|
-
const witness = await setAuthwitnessInteraction.send(
|
|
42
|
+
const witness = await setAuthwitnessInteraction.send({ wait: { timeout: DEFAULT_TX_TIMEOUT_S } });
|
|
43
43
|
|
|
44
44
|
log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
45
45
|
|
|
@@ -2,8 +2,9 @@ import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
|
2
2
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
3
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
4
4
|
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
5
|
-
import { createEthereumChain
|
|
6
|
-
import {
|
|
5
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
6
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
10
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
|
6
6
|
import type { TxHash } from '@aztec/aztec.js/tx';
|
|
7
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
8
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
9
|
-
import {
|
|
9
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
10
10
|
|
|
11
11
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
12
12
|
|
|
@@ -32,7 +32,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
32
32
|
const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
|
|
33
33
|
// Base tx data
|
|
34
34
|
log(`Tx ${txHash.toString()}`);
|
|
35
|
-
log(` Status: ${receipt.status}
|
|
35
|
+
log(` Status: ${receipt.status}`);
|
|
36
|
+
if (receipt.executionResult) {
|
|
37
|
+
log(` Execution result: ${receipt.executionResult}`);
|
|
38
|
+
}
|
|
36
39
|
if (receipt.error) {
|
|
37
40
|
log(` Error: ${receipt.error}`);
|
|
38
41
|
}
|
|
@@ -85,7 +88,7 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
85
88
|
for (const nullifier of effects.nullifiers) {
|
|
86
89
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
87
90
|
const note = deployed
|
|
88
|
-
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
|
|
91
|
+
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: 'ALL_SCOPES' }))[0]
|
|
89
92
|
: undefined;
|
|
90
93
|
const initialized = initNullifiers[nullifier.toString()];
|
|
91
94
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -121,11 +124,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
function inspectNote(note:
|
|
127
|
+
function inspectNote(note: NoteDao, artifactMap: ArtifactMap, log: LogFn, text = 'Note') {
|
|
125
128
|
const artifact = artifactMap[note.contractAddress.toString()];
|
|
126
129
|
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
127
130
|
log(` ${text} at ${contract}`);
|
|
128
|
-
log(` Recipient: ${toFriendlyAddress(note.recipient, artifactMap)}`);
|
|
129
131
|
for (const field of note.note.items) {
|
|
130
132
|
log(` ${field.toString()}`);
|
|
131
133
|
}
|
|
@@ -165,15 +167,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
|
|
|
165
167
|
const knownContractAddresses = await wallet.getContracts();
|
|
166
168
|
const knownContracts = (
|
|
167
169
|
await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
|
|
168
|
-
).map(contractMetadata => contractMetadata.
|
|
170
|
+
).map(contractMetadata => contractMetadata.instance);
|
|
169
171
|
const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
|
|
170
172
|
const knownArtifacts = (
|
|
171
|
-
await Promise.all(classIds.map(classId => (classId ? wallet.
|
|
172
|
-
).map(
|
|
173
|
-
contractClassMetadata
|
|
174
|
-
? { ...contractClassMetadata.artifact, classId: contractClassMetadata.contractClass?.id }
|
|
175
|
-
: undefined,
|
|
176
|
-
);
|
|
173
|
+
await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
|
|
174
|
+
).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
|
|
177
175
|
const map: Record<string, ContractArtifactWithClassId> = {};
|
|
178
176
|
for (const instance of knownContracts) {
|
|
179
177
|
if (instance) {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
4
|
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
4
5
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
|
-
import { Fr } from '@aztec/foundation/
|
|
6
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
7
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
7
9
|
|
|
8
10
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
11
|
+
import type { AccountType } from '../utils/constants.js';
|
|
9
12
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
10
13
|
import { printProfileResult } from '../utils/profiling.js';
|
|
11
|
-
import {
|
|
14
|
+
import { CLIWallet } from '../utils/wallet.js';
|
|
12
15
|
|
|
13
16
|
export async function createAccount(
|
|
14
17
|
wallet: CLIWallet,
|
|
@@ -63,8 +66,8 @@ export async function createAccount(
|
|
|
63
66
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
let
|
|
67
|
-
let txReceipt;
|
|
69
|
+
let txHash: TxHash | undefined;
|
|
70
|
+
let txReceipt: TxReceipt | undefined;
|
|
68
71
|
if (!registerOnly) {
|
|
69
72
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
70
73
|
|
|
@@ -99,7 +102,14 @@ export async function createAccount(
|
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
} else {
|
|
102
|
-
|
|
105
|
+
if (verbose) {
|
|
106
|
+
printProfileResult(stats, log);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!json) {
|
|
110
|
+
log(`\nWaiting for account contract deployment...`);
|
|
111
|
+
}
|
|
112
|
+
const result = await deployMethod.send({
|
|
103
113
|
...deployAccountOpts,
|
|
104
114
|
fee: deployAccountOpts.fee
|
|
105
115
|
? {
|
|
@@ -107,32 +117,29 @@ export async function createAccount(
|
|
|
107
117
|
gasSettings: estimatedGas,
|
|
108
118
|
}
|
|
109
119
|
: undefined,
|
|
120
|
+
wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
|
|
110
121
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const txHash = await tx.getTxHash();
|
|
116
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
117
|
-
out.txHash = txHash;
|
|
118
|
-
if (wait) {
|
|
119
|
-
if (!json) {
|
|
120
|
-
log(`\nWaiting for account contract deployment...`);
|
|
121
|
-
}
|
|
122
|
-
txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
|
|
122
|
+
const isReceipt = (data: TxReceipt | TxHash): data is TxReceipt => 'txHash' in data;
|
|
123
|
+
if (isReceipt(result)) {
|
|
124
|
+
txReceipt = result;
|
|
125
|
+
txHash = result.txHash;
|
|
123
126
|
out.txReceipt = {
|
|
124
127
|
status: txReceipt.status,
|
|
125
128
|
transactionFee: txReceipt.transactionFee,
|
|
126
129
|
};
|
|
130
|
+
} else {
|
|
131
|
+
txHash = result;
|
|
127
132
|
}
|
|
133
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
134
|
+
out.txHash = txHash;
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
if (json) {
|
|
132
139
|
log(prettyPrintJSON(out));
|
|
133
140
|
} else {
|
|
134
|
-
if (
|
|
135
|
-
log(`Deploy tx hash: ${
|
|
141
|
+
if (txHash) {
|
|
142
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
136
143
|
}
|
|
137
144
|
if (txReceipt) {
|
|
138
145
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
|
@@ -28,7 +28,7 @@ export async function createAuthwit(
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const contract =
|
|
31
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
32
32
|
const call = await contract.methods[functionName](...functionArgs).getFunctionCall();
|
|
33
33
|
|
|
34
34
|
const witness = await wallet.createAuthWit(from, { caller, call });
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { DeployOptions } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
4
|
import { ContractDeployer } from '@aztec/aztec.js/deployment';
|
|
4
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
6
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
@@ -89,37 +90,55 @@ export async function deploy(
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
} else {
|
|
92
|
-
const tx = deploy.send(deployOpts);
|
|
93
93
|
if (verbose) {
|
|
94
94
|
printProfileResult(stats, log);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const txHash = await tx.getTxHash();
|
|
98
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
99
|
-
out.hash = txHash;
|
|
100
97
|
const { address, partialAddress } = deploy;
|
|
101
98
|
const instance = await deploy.getInstance();
|
|
102
|
-
|
|
103
|
-
log(`Contract deployed at ${address?.toString()}`);
|
|
104
|
-
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
105
|
-
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
106
|
-
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
107
|
-
log(`Deployment salt: ${salt.toString()}`);
|
|
108
|
-
log(`Deployer: ${instance.deployer.toString()}`);
|
|
109
|
-
} else {
|
|
110
|
-
out.contract = {
|
|
111
|
-
address: address?.toString(),
|
|
112
|
-
partialAddress: (await partialAddress)?.toString(),
|
|
113
|
-
initializationHash: instance.initializationHash.toString(),
|
|
114
|
-
salt: salt.toString(),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
99
|
+
|
|
117
100
|
if (wait) {
|
|
118
|
-
const
|
|
101
|
+
const receipt = await deploy.send({ ...deployOpts, wait: { timeout, returnReceipt: true } });
|
|
102
|
+
const txHash = receipt.txHash;
|
|
103
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
104
|
+
out.hash = txHash;
|
|
105
|
+
|
|
106
|
+
if (!json) {
|
|
107
|
+
log(`Contract deployed at ${address?.toString()}`);
|
|
108
|
+
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
109
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
110
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
111
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
112
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
113
|
+
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
114
|
+
} else {
|
|
115
|
+
out.contract = {
|
|
116
|
+
address: address?.toString(),
|
|
117
|
+
partialAddress: (await partialAddress)?.toString(),
|
|
118
|
+
initializationHash: instance.initializationHash.toString(),
|
|
119
|
+
salt: salt.toString(),
|
|
120
|
+
transactionFee: receipt.transactionFee?.toString(),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
125
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
126
|
+
out.hash = txHash;
|
|
127
|
+
|
|
119
128
|
if (!json) {
|
|
120
|
-
log(`
|
|
129
|
+
log(`Contract deployed at ${address?.toString()}`);
|
|
130
|
+
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
131
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
132
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
133
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
134
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
121
135
|
} else {
|
|
122
|
-
out.contract
|
|
136
|
+
out.contract = {
|
|
137
|
+
address: address?.toString(),
|
|
138
|
+
partialAddress: (await partialAddress)?.toString(),
|
|
139
|
+
initializationHash: instance.initializationHash.toString(),
|
|
140
|
+
salt: salt.toString(),
|
|
141
|
+
};
|
|
123
142
|
}
|
|
124
143
|
}
|
|
125
144
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
4
|
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
4
5
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
6
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
7
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
8
|
|
|
7
9
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
8
10
|
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
@@ -45,8 +47,8 @@ export async function deployAccount(
|
|
|
45
47
|
log(`Init hash: ${initializationHash.toString()}`);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
let
|
|
49
|
-
let txReceipt;
|
|
50
|
+
let txHash: TxHash | undefined;
|
|
51
|
+
let txReceipt: TxReceipt | undefined;
|
|
50
52
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
51
53
|
|
|
52
54
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
@@ -80,7 +82,14 @@ export async function deployAccount(
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
} else {
|
|
83
|
-
|
|
85
|
+
if (verbose) {
|
|
86
|
+
printProfileResult(stats, log);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!json) {
|
|
90
|
+
log(`\nWaiting for account contract deployment...`);
|
|
91
|
+
}
|
|
92
|
+
const result = await deployMethod.send({
|
|
84
93
|
...deployAccountOpts,
|
|
85
94
|
fee: deployAccountOpts.fee
|
|
86
95
|
? {
|
|
@@ -88,31 +97,28 @@ export async function deployAccount(
|
|
|
88
97
|
gasSettings: estimatedGas,
|
|
89
98
|
}
|
|
90
99
|
: undefined,
|
|
100
|
+
wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
|
|
91
101
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const txHash = await tx.getTxHash();
|
|
97
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
98
|
-
out.txHash = txHash;
|
|
99
|
-
if (wait) {
|
|
100
|
-
if (!json) {
|
|
101
|
-
log(`\nWaiting for account contract deployment...`);
|
|
102
|
-
}
|
|
103
|
-
txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
|
|
102
|
+
const isReceipt = (data: TxReceipt | TxHash): data is TxReceipt => 'txHash' in data;
|
|
103
|
+
if (isReceipt(result)) {
|
|
104
|
+
txReceipt = result;
|
|
105
|
+
txHash = result.txHash;
|
|
104
106
|
out.txReceipt = {
|
|
105
107
|
status: txReceipt.status,
|
|
106
108
|
transactionFee: txReceipt.transactionFee,
|
|
107
109
|
};
|
|
110
|
+
} else {
|
|
111
|
+
txHash = result;
|
|
108
112
|
}
|
|
113
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
114
|
+
out.txHash = txHash;
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
if (json) {
|
|
112
118
|
log(prettyPrintJSON(out));
|
|
113
119
|
} else {
|
|
114
|
-
if (
|
|
115
|
-
log(`Deploy tx hash: ${
|
|
120
|
+
if (txHash) {
|
|
121
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
116
122
|
}
|
|
117
123
|
if (txReceipt) {
|
|
118
124
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|