@aztec/cli-wallet 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa
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/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +41 -10
- 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 +42 -25
- package/dest/cmds/deploy.d.ts +4 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +56 -29
- package/dest/cmds/deploy_account.d.ts +4 -3
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +37 -20
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +30 -14
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +32 -16
- package/dest/storage/wallet_db.d.ts +6 -1
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +60 -31
- package/dest/utils/options/fees.d.ts +3 -2
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +32 -9
- package/dest/utils/wallet.d.ts +11 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +73 -49
- package/package.json +14 -14
- package/src/cmds/authorize_action.ts +1 -1
- package/src/cmds/check_tx.ts +47 -12
- package/src/cmds/create_account.ts +44 -24
- package/src/cmds/deploy.ts +55 -27
- package/src/cmds/deploy_account.ts +38 -19
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +57 -4
- package/src/cmds/send.ts +32 -12
- package/src/cmds/simulate.ts +1 -1
- package/src/storage/wallet_db.ts +63 -36
- package/src/utils/options/fees.ts +39 -9
- package/src/utils/wallet.ts +84 -69
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -2,16 +2,17 @@ import { type Account } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import { type InteractionFeeOptions } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
4
|
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
+
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
7
9
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
8
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
11
|
-
import type {
|
|
12
|
-
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
|
+
import type { TxProvingResult } from '@aztec/stdlib/tx';
|
|
13
14
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
15
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
15
16
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
16
17
|
import type { AccountType } from './constants.js';
|
|
17
18
|
export declare class CLIWallet extends BaseWallet {
|
|
@@ -27,9 +28,14 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
27
28
|
private createAccount;
|
|
28
29
|
createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
29
30
|
private getFakeAccountDataFor;
|
|
30
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
31
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
32
|
+
/**
|
|
33
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
34
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
35
|
+
*/
|
|
36
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
31
37
|
getContracts(): Promise<AztecAddress[]>;
|
|
32
38
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
33
39
|
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
34
40
|
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RixPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFHM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdC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NqQyxPQUFPLENBQUMsK0JBQStCLENBQUMsQ0EwQzFDO0lBSUQsWUFBWSxJQUFJLE9BQU8sQ0FBQyxZQUFZLEVBQUUsQ0FBQyxDQUV0QztJQUlELFFBQVEsQ0FBQyxNQUFNLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQUVoRDtJQUlELG1CQUFtQixDQUFDLEVBQUUsRUFBRSxFQUFFLHFFQUV6QjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"
|
|
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,EACL,KAAK,qBAAqB,EAG3B,MAAM,2BAA2B,CAAC;AACnC,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;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAA2C,eAAe,EAAE,MAAM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+BAA+B,CAAC,CAa1C;IAED;;;OAGG;IACH,UAAyB,qBAAqB,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,+BAA+B,CAAC,CA0C1C;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
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
-
import {
|
|
3
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
4
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
|
-
import {
|
|
6
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
6
7
|
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
8
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
8
11
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
12
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
10
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -28,33 +31,39 @@ export class CLIWallet extends BaseWallet {
|
|
|
28
31
|
}
|
|
29
32
|
async getAccounts() {
|
|
30
33
|
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
31
|
-
return Promise.resolve(accounts.map(({ key, value })=>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
return Promise.resolve(accounts.map(({ key, value })=>{
|
|
35
|
+
const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
|
|
36
|
+
return {
|
|
37
|
+
alias,
|
|
38
|
+
item: AztecAddress.fromString(value)
|
|
39
|
+
};
|
|
40
|
+
}));
|
|
35
41
|
}
|
|
36
42
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
37
43
|
const executionPayload = ExecutionPayload.empty();
|
|
38
|
-
const feeOptions = await this.completeFeeOptions(
|
|
44
|
+
const feeOptions = await this.completeFeeOptions({
|
|
45
|
+
from,
|
|
46
|
+
feePayer: executionPayload.feePayer,
|
|
47
|
+
gasSettings: increasedFee.gasSettings
|
|
48
|
+
});
|
|
39
49
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
40
50
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
41
51
|
const chainInfo = await this.getChainInfo();
|
|
42
52
|
const executionOptions = {
|
|
43
53
|
txNonce,
|
|
44
54
|
cancellable: this.cancellableTransactions,
|
|
55
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
45
56
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
46
57
|
};
|
|
47
58
|
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
48
59
|
}
|
|
49
60
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
50
61
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
51
|
-
return await this.pxe.proveTx(cancellationTxRequest);
|
|
62
|
+
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
52
63
|
}
|
|
53
64
|
async getAccountFromAddress(address) {
|
|
54
65
|
let account;
|
|
55
|
-
if (address.
|
|
56
|
-
account = new SignerlessAccount();
|
|
57
|
-
} else if (this.accountCache.has(address.toString())) {
|
|
66
|
+
if (this.accountCache.has(address.toString())) {
|
|
58
67
|
return this.accountCache.get(address.toString());
|
|
59
68
|
} else {
|
|
60
69
|
const accountManager = await this.createOrRetrieveAccount(address);
|
|
@@ -125,66 +134,81 @@ export class CLIWallet extends BaseWallet {
|
|
|
125
134
|
* @returns The stub account, contract instance, and artifact for simulation
|
|
126
135
|
*/ async getFakeAccountDataFor(address) {
|
|
127
136
|
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
|
-
}
|
|
134
137
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
135
138
|
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
136
139
|
if (!contractInstance) {
|
|
137
140
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
138
141
|
}
|
|
139
|
-
const
|
|
140
|
-
const
|
|
142
|
+
const { type } = await this.db.retrieveAccount(address);
|
|
143
|
+
const isSchnorr = type === 'schnorr';
|
|
144
|
+
const artifact = isSchnorr ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact;
|
|
145
|
+
const stubAccount = isSchnorr ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
146
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
141
147
|
salt: Fr.random()
|
|
142
148
|
});
|
|
143
149
|
return {
|
|
144
150
|
account: stubAccount,
|
|
145
151
|
instance,
|
|
146
|
-
artifact
|
|
152
|
+
artifact
|
|
147
153
|
};
|
|
148
154
|
}
|
|
149
155
|
async simulateTx(executionPayload, opts) {
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
const simulationResults = await super.simulateTx(executionPayload, opts);
|
|
157
|
+
if (opts.fee?.estimateGas) {
|
|
158
|
+
const feeOptions = await this.completeFeeOptions({
|
|
159
|
+
from: opts.from,
|
|
160
|
+
feePayer: executionPayload.feePayer,
|
|
161
|
+
gasSettings: opts.fee?.gasSettings
|
|
162
|
+
});
|
|
163
|
+
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
164
|
+
printGasEstimates(feeOptions, limits, this.userLog);
|
|
165
|
+
}
|
|
166
|
+
return simulationResults;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
170
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
171
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
172
|
+
const { from, feeOptions, additionalScopes } = opts;
|
|
173
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
152
174
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
153
|
-
const chainInfo = await this.getChainInfo();
|
|
154
|
-
const executionOptions = {
|
|
155
|
-
txNonce: Fr.random(),
|
|
156
|
-
cancellable: this.cancellableTransactions,
|
|
157
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
158
|
-
};
|
|
159
175
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
160
176
|
feeExecutionPayload,
|
|
161
177
|
executionPayload
|
|
162
178
|
]) : executionPayload;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
179
|
+
const chainInfo = await this.getChainInfo();
|
|
180
|
+
let overrides;
|
|
181
|
+
let txRequest;
|
|
182
|
+
if (from === NO_FROM) {
|
|
183
|
+
const entrypoint = new DefaultEntrypoint();
|
|
184
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
170
185
|
} else {
|
|
171
|
-
const { account
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
186
|
+
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
187
|
+
overrides = {
|
|
188
|
+
contracts: {
|
|
189
|
+
[from.toString()]: {
|
|
190
|
+
instance,
|
|
191
|
+
artifact
|
|
192
|
+
}
|
|
177
193
|
}
|
|
178
194
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
const executionOptions = {
|
|
196
|
+
txNonce: Fr.random(),
|
|
197
|
+
cancellable: this.cancellableTransactions,
|
|
198
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
199
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
200
|
+
};
|
|
201
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
186
202
|
}
|
|
187
|
-
|
|
203
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
204
|
+
simulatePublic: true,
|
|
205
|
+
skipFeeEnforcement: true,
|
|
206
|
+
skipTxValidation: true,
|
|
207
|
+
overrides,
|
|
208
|
+
scopes
|
|
209
|
+
});
|
|
210
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
211
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
188
212
|
}
|
|
189
213
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
190
214
|
// this is just a CLI wallet.
|
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.d939eb5aa",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -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.d939eb5aa",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.d939eb5aa",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.d939eb5aa",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.d939eb5aa",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.d939eb5aa",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.d939eb5aa",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.d939eb5aa",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.d939eb5aa",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d939eb5aa",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.d939eb5aa",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.d939eb5aa",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.d939eb5aa",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.d939eb5aa",
|
|
83
83
|
"commander": "^12.1.0",
|
|
84
84
|
"inquirer": "^10.1.8",
|
|
85
85
|
"source-map-support": "^0.5.21",
|
|
@@ -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
|
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import
|
|
2
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
4
|
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
|
}
|
|
@@ -80,12 +87,13 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
80
87
|
// Nullifiers
|
|
81
88
|
const nullifierCount = effects.nullifiers.length;
|
|
82
89
|
const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
|
|
90
|
+
const accounts = (await wallet.getAccounts()).map(a => a.item);
|
|
83
91
|
if (nullifierCount > 0) {
|
|
84
92
|
log(' Nullifiers:');
|
|
85
93
|
for (const nullifier of effects.nullifiers) {
|
|
86
94
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
87
95
|
const note = deployed
|
|
88
|
-
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
|
|
96
|
+
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: accounts }))[0]
|
|
89
97
|
: undefined;
|
|
90
98
|
const initialized = initNullifiers[nullifier.toString()];
|
|
91
99
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -141,22 +149,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
|
141
149
|
|
|
142
150
|
async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
|
|
143
151
|
const knownContracts = await wallet.getContracts();
|
|
144
|
-
|
|
145
|
-
const
|
|
152
|
+
|
|
153
|
+
const [contractResults, classResults] = await Promise.all([
|
|
154
|
+
Promise.all(knownContracts.map(contract => getContractNullifiers(wallet, contract))),
|
|
155
|
+
Promise.all(Object.values(artifactMap).map(artifact => getClassNullifier(artifact))),
|
|
156
|
+
]);
|
|
157
|
+
|
|
146
158
|
const initNullifiers: Record<string, AztecAddress> = {};
|
|
147
159
|
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
148
160
|
const classNullifiers: Record<string, string> = {};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
deployNullifiers[
|
|
161
|
+
|
|
162
|
+
for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults) {
|
|
163
|
+
deployNullifiers[deployNullifier.toString()] = contract;
|
|
164
|
+
if (privateInitNullifier) {
|
|
165
|
+
initNullifiers[privateInitNullifier.toString()] = contract;
|
|
166
|
+
}
|
|
167
|
+
initNullifiers[publicInitNullifier.toString()] = contract;
|
|
152
168
|
}
|
|
153
|
-
for (const
|
|
154
|
-
classNullifiers[
|
|
155
|
-
`${artifact.name}Class<${artifact.classId}>`;
|
|
169
|
+
for (const { nullifier, label } of classResults) {
|
|
170
|
+
classNullifiers[nullifier.toString()] = label;
|
|
156
171
|
}
|
|
172
|
+
|
|
157
173
|
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
158
174
|
}
|
|
159
175
|
|
|
176
|
+
async function getContractNullifiers(wallet: CLIWallet, contract: AztecAddress) {
|
|
177
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
178
|
+
const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
|
|
179
|
+
|
|
180
|
+
const metadata = await wallet.getContractMetadata(contract);
|
|
181
|
+
const privateInitNullifier = metadata.instance
|
|
182
|
+
? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash)
|
|
183
|
+
: undefined;
|
|
184
|
+
const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
|
|
185
|
+
|
|
186
|
+
return { contract, deployNullifier, privateInitNullifier, publicInitNullifier };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function getClassNullifier(artifact: ContractArtifactWithClassId) {
|
|
190
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
191
|
+
const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
|
|
192
|
+
return { nullifier, label: `${artifact.name}Class<${artifact.classId}>` };
|
|
193
|
+
}
|
|
194
|
+
|
|
160
195
|
type ArtifactMap = Record<string, ContractArtifactWithClassId>;
|
|
161
196
|
type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
|
|
162
197
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
1
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import
|
|
3
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
3
5
|
import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
|
|
4
6
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
9
|
+
import { type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
7
10
|
|
|
8
11
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
9
12
|
import type { AccountType } from '../utils/constants.js';
|
|
@@ -16,6 +19,7 @@ export async function createAccount(
|
|
|
16
19
|
aztecNode: AztecNode,
|
|
17
20
|
accountType: AccountType,
|
|
18
21
|
secretKey: Fr | undefined,
|
|
22
|
+
salt: Fr | undefined,
|
|
19
23
|
publicKey: string | undefined,
|
|
20
24
|
alias: string | undefined,
|
|
21
25
|
deployer: AztecAddress | undefined,
|
|
@@ -25,6 +29,7 @@ export async function createAccount(
|
|
|
25
29
|
registerClass: boolean,
|
|
26
30
|
wait: boolean,
|
|
27
31
|
feeOpts: CLIFeeArgs,
|
|
32
|
+
waitForStatus: TxStatus,
|
|
28
33
|
json: boolean,
|
|
29
34
|
verbose: boolean,
|
|
30
35
|
debugLogger: Logger,
|
|
@@ -36,10 +41,10 @@ export async function createAccount(
|
|
|
36
41
|
undefined /* address, we don't have it yet */,
|
|
37
42
|
secretKey,
|
|
38
43
|
accountType,
|
|
39
|
-
|
|
44
|
+
salt,
|
|
40
45
|
publicKey,
|
|
41
46
|
);
|
|
42
|
-
const
|
|
47
|
+
const instanceSalt = account.getInstance().salt;
|
|
43
48
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
44
49
|
|
|
45
50
|
const out: Record<string, any> = {};
|
|
@@ -50,7 +55,7 @@ export async function createAccount(
|
|
|
50
55
|
out.secretKey = secretKey;
|
|
51
56
|
}
|
|
52
57
|
out.partialAddress = partialAddress;
|
|
53
|
-
out.salt =
|
|
58
|
+
out.salt = instanceSalt;
|
|
54
59
|
out.initHash = account.getInstance().initializationHash;
|
|
55
60
|
} else {
|
|
56
61
|
log(`\nNew account:\n`);
|
|
@@ -60,17 +65,17 @@ export async function createAccount(
|
|
|
60
65
|
log(`Secret key: ${secretKey.toString()}`);
|
|
61
66
|
}
|
|
62
67
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
63
|
-
log(`Salt: ${
|
|
68
|
+
log(`Salt: ${instanceSalt.toString()}`);
|
|
64
69
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
let
|
|
68
|
-
let txReceipt;
|
|
72
|
+
let txHash: TxHash | undefined;
|
|
73
|
+
let txReceipt: TxReceipt | undefined;
|
|
69
74
|
if (!registerOnly) {
|
|
70
75
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
71
76
|
|
|
72
77
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
73
|
-
const from = delegatedDeployment ? deployer :
|
|
78
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
74
79
|
|
|
75
80
|
const deployAccountOpts: DeployAccountOptions = {
|
|
76
81
|
skipClassPublication: !registerClass,
|
|
@@ -80,11 +85,15 @@ export async function createAccount(
|
|
|
80
85
|
fee: { paymentMethod, gasSettings },
|
|
81
86
|
};
|
|
82
87
|
|
|
88
|
+
const localStart = performance.now();
|
|
83
89
|
const deployMethod = await account.getDeployMethod();
|
|
84
|
-
const
|
|
90
|
+
const sim = await deployMethod.simulate({
|
|
85
91
|
...deployAccountOpts,
|
|
86
92
|
fee: { ...deployAccountOpts.fee, estimateGas: true },
|
|
87
93
|
});
|
|
94
|
+
// estimateGas: true guarantees these fields are present
|
|
95
|
+
const estimatedGas = sim.estimatedGas!;
|
|
96
|
+
const stats = sim.stats!;
|
|
88
97
|
|
|
89
98
|
if (feeOpts.estimateOnly) {
|
|
90
99
|
if (json) {
|
|
@@ -100,7 +109,14 @@ export async function createAccount(
|
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
111
|
} else {
|
|
103
|
-
|
|
112
|
+
if (verbose) {
|
|
113
|
+
printProfileResult(stats, log);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!json) {
|
|
117
|
+
log(`\nWaiting for account contract deployment...`);
|
|
118
|
+
}
|
|
119
|
+
const sendOpts = {
|
|
104
120
|
...deployAccountOpts,
|
|
105
121
|
fee: deployAccountOpts.fee
|
|
106
122
|
? {
|
|
@@ -108,37 +124,41 @@ export async function createAccount(
|
|
|
108
124
|
gasSettings: estimatedGas,
|
|
109
125
|
}
|
|
110
126
|
: undefined,
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
|
|
130
|
+
const localTimeMs = performance.now() - localStart;
|
|
115
131
|
|
|
116
|
-
const txHash = await tx.getTxHash();
|
|
117
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
118
|
-
out.txHash = txHash;
|
|
119
132
|
if (wait) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
const nodeStart = performance.now();
|
|
134
|
+
txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
|
|
135
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
136
|
+
|
|
124
137
|
out.txReceipt = {
|
|
125
138
|
status: txReceipt.status,
|
|
126
139
|
transactionFee: txReceipt.transactionFee,
|
|
127
140
|
};
|
|
141
|
+
|
|
142
|
+
if (!json) {
|
|
143
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
144
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
145
|
+
}
|
|
128
146
|
}
|
|
147
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
148
|
+
out.txHash = txHash;
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
if (json) {
|
|
133
153
|
log(prettyPrintJSON(out));
|
|
134
154
|
} else {
|
|
135
|
-
if (
|
|
136
|
-
log(`Deploy tx hash: ${
|
|
155
|
+
if (txHash) {
|
|
156
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
137
157
|
}
|
|
138
158
|
if (txReceipt) {
|
|
139
159
|
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
|
140
160
|
}
|
|
141
161
|
}
|
|
142
162
|
|
|
143
|
-
return { alias, address, secretKey, salt };
|
|
163
|
+
return { alias, address, secretKey, salt: instanceSalt };
|
|
144
164
|
}
|