@aztec/cli-wallet 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cmds/authorize_action.d.ts +2 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +4 -2
- 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.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +44 -14
- package/dest/cmds/create_account.d.ts +4 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +32 -18
- package/dest/cmds/create_authwit.d.ts +2 -2
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/deploy.d.ts +1 -1
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +50 -24
- 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 +31 -17
- package/dest/cmds/index.js +2 -2
- package/dest/cmds/send.d.ts +2 -2
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +32 -17
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +3 -3
- package/dest/storage/wallet_db.d.ts +3 -3
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +47 -32
- 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/options/fees.d.ts +1 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +5 -3
- 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 +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 +11 -7
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +63 -44
- package/package.json +17 -17
- package/src/cmds/authorize_action.ts +1 -1
- package/src/cmds/bridge_fee_juice.ts +3 -2
- package/src/cmds/check_tx.ts +48 -18
- package/src/cmds/create_account.ts +32 -20
- package/src/cmds/deploy.ts +45 -23
- package/src/cmds/deploy_account.ts +29 -18
- package/src/cmds/index.ts +3 -3
- package/src/cmds/send.ts +26 -11
- package/src/cmds/simulate.ts +4 -7
- package/src/storage/wallet_db.ts +51 -38
- package/src/utils/constants.ts +4 -0
- package/src/utils/options/fees.ts +9 -3
- package/src/utils/options/options.ts +1 -1
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +76 -57
package/dest/utils/wallet.js
CHANGED
|
@@ -5,7 +5,7 @@ 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
7
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
-
import { Fr } from '@aztec/foundation/
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
10
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
11
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
@@ -13,13 +13,6 @@ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
|
13
13
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
14
14
|
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
15
15
|
import { printGasEstimates } from './options/fees.js';
|
|
16
|
-
export const AccountTypes = [
|
|
17
|
-
'schnorr',
|
|
18
|
-
'ecdsasecp256r1',
|
|
19
|
-
'ecdsasecp256r1ssh',
|
|
20
|
-
'ecdsasecp256k1'
|
|
21
|
-
];
|
|
22
|
-
export const BASE_FEE_PADDING = 0.5;
|
|
23
16
|
export class CLIWallet extends BaseWallet {
|
|
24
17
|
userLog;
|
|
25
18
|
db;
|
|
@@ -45,22 +38,22 @@ export class CLIWallet extends BaseWallet {
|
|
|
45
38
|
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
46
39
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
47
40
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
41
|
+
const chainInfo = await this.getChainInfo();
|
|
48
42
|
const executionOptions = {
|
|
49
43
|
txNonce,
|
|
50
44
|
cancellable: this.cancellableTransactions,
|
|
51
45
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
52
46
|
};
|
|
53
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
|
|
47
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
54
48
|
}
|
|
55
49
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
56
50
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
57
|
-
return await this.pxe.proveTx(cancellationTxRequest);
|
|
51
|
+
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
58
52
|
}
|
|
59
53
|
async getAccountFromAddress(address) {
|
|
60
54
|
let account;
|
|
61
55
|
if (address.equals(AztecAddress.ZERO)) {
|
|
62
|
-
|
|
63
|
-
account = new SignerlessAccount(chainInfo);
|
|
56
|
+
account = new SignerlessAccount();
|
|
64
57
|
} else if (this.accountCache.has(address.toString())) {
|
|
65
58
|
return this.accountCache.get(address.toString());
|
|
66
59
|
} else {
|
|
@@ -125,15 +118,25 @@ export class CLIWallet extends BaseWallet {
|
|
|
125
118
|
}
|
|
126
119
|
return account;
|
|
127
120
|
}
|
|
128
|
-
|
|
129
|
-
|
|
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) {
|
|
130
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
|
+
}
|
|
131
134
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
132
|
-
const
|
|
135
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
133
136
|
if (!contractInstance) {
|
|
134
137
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
135
138
|
}
|
|
136
|
-
const stubAccount = createStubAccount(originalAddress
|
|
139
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
137
140
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
138
141
|
salt: Fr.random()
|
|
139
142
|
});
|
|
@@ -144,8 +147,35 @@ export class CLIWallet extends BaseWallet {
|
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
async simulateTx(executionPayload, opts) {
|
|
147
|
-
|
|
148
|
-
|
|
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, opts) {
|
|
162
|
+
const { from, feeOptions, scopes } = opts;
|
|
163
|
+
let overrides;
|
|
164
|
+
let fromAccount;
|
|
165
|
+
if (!from.equals(AztecAddress.ZERO)) {
|
|
166
|
+
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
167
|
+
fromAccount = account;
|
|
168
|
+
overrides = {
|
|
169
|
+
contracts: {
|
|
170
|
+
[from.toString()]: {
|
|
171
|
+
instance,
|
|
172
|
+
artifact
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
fromAccount = await this.getAccountFromAddress(from);
|
|
178
|
+
}
|
|
149
179
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
150
180
|
const executionOptions = {
|
|
151
181
|
txNonce: Fr.random(),
|
|
@@ -156,31 +186,15 @@ export class CLIWallet extends BaseWallet {
|
|
|
156
186
|
feeExecutionPayload,
|
|
157
187
|
executionPayload
|
|
158
188
|
]) : executionPayload;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
169
|
-
const contractOverrides = {
|
|
170
|
-
[opts.from.toString()]: {
|
|
171
|
-
instance,
|
|
172
|
-
artifact
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
simulationResults = await this.pxe.simulateTx(txRequest, true, true, true, {
|
|
176
|
-
contracts: contractOverrides
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
if (opts.fee?.estimateGas) {
|
|
180
|
-
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
181
|
-
printGasEstimates(feeOptions, limits, this.userLog);
|
|
182
|
-
}
|
|
183
|
-
return simulationResults;
|
|
189
|
+
const chainInfo = await this.getChainInfo();
|
|
190
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
191
|
+
return this.pxe.simulateTx(txRequest, {
|
|
192
|
+
simulatePublic: true,
|
|
193
|
+
skipFeeEnforcement: true,
|
|
194
|
+
skipTxValidation: true,
|
|
195
|
+
overrides,
|
|
196
|
+
scopes
|
|
197
|
+
});
|
|
184
198
|
}
|
|
185
199
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
186
200
|
// this is just a CLI wallet.
|
|
@@ -190,6 +204,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
190
204
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
191
205
|
// this is just a CLI wallet.
|
|
192
206
|
getNotes(filter) {
|
|
193
|
-
return this.pxe.getNotes(filter);
|
|
207
|
+
return this.pxe.debug.getNotes(filter);
|
|
208
|
+
}
|
|
209
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
210
|
+
// this is just a CLI wallet.
|
|
211
|
+
getContractArtifact(id) {
|
|
212
|
+
return this.pxe.getContractArtifact(id);
|
|
194
213
|
}
|
|
195
214
|
}
|
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.9ee6fcc6",
|
|
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 &&
|
|
24
|
-
"build:dev": "
|
|
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,19 +67,19 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
71
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/cli": "0.0.1-commit.
|
|
74
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
75
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
76
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
77
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
79
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
80
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.9ee6fcc6",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.9ee6fcc6",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.9ee6fcc6",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.9ee6fcc6",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.9ee6fcc6",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.9ee6fcc6",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.9ee6fcc6",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.9ee6fcc6",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9ee6fcc6",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.9ee6fcc6",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.9ee6fcc6",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.9ee6fcc6",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.9ee6fcc6",
|
|
83
83
|
"commander": "^12.1.0",
|
|
84
84
|
"inquirer": "^10.1.8",
|
|
85
85
|
"source-map-support": "^0.5.21",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@types/jest": "^30.0.0",
|
|
91
91
|
"@types/node": "^22.15.17",
|
|
92
92
|
"@types/source-map-support": "^0.5.10",
|
|
93
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
93
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
94
94
|
"jest": "^30.0.0",
|
|
95
95
|
"jest-mock-extended": "^4.0.0",
|
|
96
96
|
"ts-jest": "^29.4.0",
|
|
@@ -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
|
@@ -5,7 +5,11 @@ import type { AztecNode } from '@aztec/aztec.js/node';
|
|
|
5
5
|
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
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
computeSiloedPrivateInitializationNullifier,
|
|
10
|
+
computeSiloedPublicInitializationNullifier,
|
|
11
|
+
siloNullifier,
|
|
12
|
+
} from '@aztec/stdlib/hash';
|
|
9
13
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
10
14
|
|
|
11
15
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
@@ -32,7 +36,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
32
36
|
const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
|
|
33
37
|
// Base tx data
|
|
34
38
|
log(`Tx ${txHash.toString()}`);
|
|
35
|
-
log(` Status: ${receipt.status}
|
|
39
|
+
log(` Status: ${receipt.status}`);
|
|
40
|
+
if (receipt.executionResult) {
|
|
41
|
+
log(` Execution result: ${receipt.executionResult}`);
|
|
42
|
+
}
|
|
36
43
|
if (receipt.error) {
|
|
37
44
|
log(` Error: ${receipt.error}`);
|
|
38
45
|
}
|
|
@@ -85,7 +92,7 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
85
92
|
for (const nullifier of effects.nullifiers) {
|
|
86
93
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
87
94
|
const note = deployed
|
|
88
|
-
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
|
|
95
|
+
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: 'ALL_SCOPES' }))[0]
|
|
89
96
|
: undefined;
|
|
90
97
|
const initialized = initNullifiers[nullifier.toString()];
|
|
91
98
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -141,22 +148,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
|
141
148
|
|
|
142
149
|
async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
|
|
143
150
|
const knownContracts = await wallet.getContracts();
|
|
144
|
-
|
|
145
|
-
const
|
|
151
|
+
|
|
152
|
+
const [contractResults, classResults] = await Promise.all([
|
|
153
|
+
Promise.all(knownContracts.map(contract => getContractNullifiers(wallet, contract))),
|
|
154
|
+
Promise.all(Object.values(artifactMap).map(artifact => getClassNullifier(artifact))),
|
|
155
|
+
]);
|
|
156
|
+
|
|
146
157
|
const initNullifiers: Record<string, AztecAddress> = {};
|
|
147
158
|
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
148
159
|
const classNullifiers: Record<string, string> = {};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
deployNullifiers[
|
|
160
|
+
|
|
161
|
+
for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults) {
|
|
162
|
+
deployNullifiers[deployNullifier.toString()] = contract;
|
|
163
|
+
if (privateInitNullifier) {
|
|
164
|
+
initNullifiers[privateInitNullifier.toString()] = contract;
|
|
165
|
+
}
|
|
166
|
+
initNullifiers[publicInitNullifier.toString()] = contract;
|
|
152
167
|
}
|
|
153
|
-
for (const
|
|
154
|
-
classNullifiers[
|
|
155
|
-
`${artifact.name}Class<${artifact.classId}>`;
|
|
168
|
+
for (const { nullifier, label } of classResults) {
|
|
169
|
+
classNullifiers[nullifier.toString()] = label;
|
|
156
170
|
}
|
|
171
|
+
|
|
157
172
|
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
158
173
|
}
|
|
159
174
|
|
|
175
|
+
async function getContractNullifiers(wallet: CLIWallet, contract: AztecAddress) {
|
|
176
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
177
|
+
const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
|
|
178
|
+
|
|
179
|
+
const metadata = await wallet.getContractMetadata(contract);
|
|
180
|
+
const privateInitNullifier = metadata.instance
|
|
181
|
+
? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash)
|
|
182
|
+
: undefined;
|
|
183
|
+
const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
|
|
184
|
+
|
|
185
|
+
return { contract, deployNullifier, privateInitNullifier, publicInitNullifier };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function getClassNullifier(artifact: ContractArtifactWithClassId) {
|
|
189
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
190
|
+
const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
|
|
191
|
+
return { nullifier, label: `${artifact.name}Class<${artifact.classId}>` };
|
|
192
|
+
}
|
|
193
|
+
|
|
160
194
|
type ArtifactMap = Record<string, ContractArtifactWithClassId>;
|
|
161
195
|
type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
|
|
162
196
|
|
|
@@ -164,15 +198,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
|
|
|
164
198
|
const knownContractAddresses = await wallet.getContracts();
|
|
165
199
|
const knownContracts = (
|
|
166
200
|
await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
|
|
167
|
-
).map(contractMetadata => contractMetadata.
|
|
201
|
+
).map(contractMetadata => contractMetadata.instance);
|
|
168
202
|
const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
|
|
169
203
|
const knownArtifacts = (
|
|
170
|
-
await Promise.all(classIds.map(classId => (classId ? wallet.
|
|
171
|
-
).map(
|
|
172
|
-
contractClassMetadata
|
|
173
|
-
? { ...contractClassMetadata.artifact, classId: contractClassMetadata.contractClass?.id }
|
|
174
|
-
: undefined,
|
|
175
|
-
);
|
|
204
|
+
await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
|
|
205
|
+
).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
|
|
176
206
|
const map: Record<string, ContractArtifactWithClassId> = {};
|
|
177
207
|
for (const instance of knownContracts) {
|
|
178
208
|
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
|
|
|
@@ -80,10 +83,13 @@ export async function createAccount(
|
|
|
80
83
|
};
|
|
81
84
|
|
|
82
85
|
const deployMethod = await account.getDeployMethod();
|
|
83
|
-
const
|
|
86
|
+
const sim = await deployMethod.simulate({
|
|
84
87
|
...deployAccountOpts,
|
|
85
88
|
fee: { ...deployAccountOpts.fee, estimateGas: true },
|
|
86
89
|
});
|
|
90
|
+
// estimateGas: true guarantees these fields are present
|
|
91
|
+
const estimatedGas = sim.estimatedGas!;
|
|
92
|
+
const stats = sim.stats!;
|
|
87
93
|
|
|
88
94
|
if (feeOpts.estimateOnly) {
|
|
89
95
|
if (json) {
|
|
@@ -99,7 +105,14 @@ export async function createAccount(
|
|
|
99
105
|
};
|
|
100
106
|
}
|
|
101
107
|
} else {
|
|
102
|
-
|
|
108
|
+
if (verbose) {
|
|
109
|
+
printProfileResult(stats, log);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!json) {
|
|
113
|
+
log(`\nWaiting for account contract deployment...`);
|
|
114
|
+
}
|
|
115
|
+
const sendOpts = {
|
|
103
116
|
...deployAccountOpts,
|
|
104
117
|
fee: deployAccountOpts.fee
|
|
105
118
|
? {
|
|
@@ -107,32 +120,31 @@ export async function createAccount(
|
|
|
107
120
|
gasSettings: estimatedGas,
|
|
108
121
|
}
|
|
109
122
|
: undefined,
|
|
110
|
-
}
|
|
111
|
-
if (verbose) {
|
|
112
|
-
printProfileResult(stats, log);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const txHash = await tx.getTxHash();
|
|
116
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
117
|
-
out.txHash = txHash;
|
|
123
|
+
};
|
|
118
124
|
if (wait) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
const { receipt } = await deployMethod.send({
|
|
126
|
+
...sendOpts,
|
|
127
|
+
wait: { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true },
|
|
128
|
+
});
|
|
129
|
+
txReceipt = receipt;
|
|
130
|
+
txHash = receipt.txHash;
|
|
123
131
|
out.txReceipt = {
|
|
124
132
|
status: txReceipt.status,
|
|
125
133
|
transactionFee: txReceipt.transactionFee,
|
|
126
134
|
};
|
|
135
|
+
} else {
|
|
136
|
+
({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
|
|
127
137
|
}
|
|
138
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
139
|
+
out.txHash = txHash;
|
|
128
140
|
}
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
if (json) {
|
|
132
144
|
log(prettyPrintJSON(out));
|
|
133
145
|
} else {
|
|
134
|
-
if (
|
|
135
|
-
log(`Deploy tx hash: ${
|
|
146
|
+
if (txHash) {
|
|
147
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
136
148
|
}
|
|
137
149
|
if (txReceipt) {
|
|
138
150
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
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';
|
|
@@ -70,10 +71,13 @@ export async function deploy(
|
|
|
70
71
|
skipInstancePublication,
|
|
71
72
|
};
|
|
72
73
|
|
|
73
|
-
const
|
|
74
|
+
const sim = await deploy.simulate({
|
|
74
75
|
...deployOpts,
|
|
75
76
|
fee: { ...deployOpts.fee, estimateGas: true },
|
|
76
77
|
});
|
|
78
|
+
// estimateGas: true guarantees these fields are present
|
|
79
|
+
const estimatedGas = sim.estimatedGas!;
|
|
80
|
+
const stats = sim.stats!;
|
|
77
81
|
|
|
78
82
|
if (feeOpts.estimateOnly) {
|
|
79
83
|
if (json) {
|
|
@@ -89,37 +93,55 @@ export async function deploy(
|
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
} else {
|
|
92
|
-
const tx = deploy.send(deployOpts);
|
|
93
96
|
if (verbose) {
|
|
94
97
|
printProfileResult(stats, log);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
const txHash = await tx.getTxHash();
|
|
98
|
-
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
99
|
-
out.hash = txHash;
|
|
100
100
|
const { address, partialAddress } = deploy;
|
|
101
101
|
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
|
-
}
|
|
102
|
+
|
|
117
103
|
if (wait) {
|
|
118
|
-
const
|
|
104
|
+
const { receipt } = await deploy.send({ ...deployOpts, wait: { timeout, returnReceipt: true } });
|
|
105
|
+
const txHash = receipt.txHash;
|
|
106
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
107
|
+
out.hash = txHash;
|
|
108
|
+
|
|
109
|
+
if (!json) {
|
|
110
|
+
log(`Contract deployed at ${address?.toString()}`);
|
|
111
|
+
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
112
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
113
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
114
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
115
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
116
|
+
log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
|
|
117
|
+
} else {
|
|
118
|
+
out.contract = {
|
|
119
|
+
address: address?.toString(),
|
|
120
|
+
partialAddress: (await partialAddress)?.toString(),
|
|
121
|
+
initializationHash: instance.initializationHash.toString(),
|
|
122
|
+
salt: salt.toString(),
|
|
123
|
+
transactionFee: receipt.transactionFee?.toString(),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
const { txHash } = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
128
|
+
debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
|
|
129
|
+
out.hash = txHash;
|
|
130
|
+
|
|
119
131
|
if (!json) {
|
|
120
|
-
log(`
|
|
132
|
+
log(`Contract deployed at ${address?.toString()}`);
|
|
133
|
+
log(`Contract partial address ${(await partialAddress)?.toString()}`);
|
|
134
|
+
log(`Contract init hash ${instance.initializationHash.toString()}`);
|
|
135
|
+
log(`Deployment tx hash: ${txHash.toString()}`);
|
|
136
|
+
log(`Deployment salt: ${salt.toString()}`);
|
|
137
|
+
log(`Deployer: ${instance.deployer.toString()}`);
|
|
121
138
|
} else {
|
|
122
|
-
out.contract
|
|
139
|
+
out.contract = {
|
|
140
|
+
address: address?.toString(),
|
|
141
|
+
partialAddress: (await partialAddress)?.toString(),
|
|
142
|
+
initializationHash: instance.initializationHash.toString(),
|
|
143
|
+
salt: salt.toString(),
|
|
144
|
+
};
|
|
123
145
|
}
|
|
124
146
|
}
|
|
125
147
|
}
|