@aztec/cli-wallet 0.0.1-commit.1142ef1 → 0.0.1-commit.1a99e26c
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.js +8 -5
- package/dest/cmds/create_account.d.ts +1 -1
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +24 -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 +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/send.d.ts +2 -2
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +28 -16
- 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/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +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 +2 -1
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +25 -9
- package/package.json +15 -15
- package/src/cmds/authorize_action.ts +1 -1
- package/src/cmds/check_tx.ts +7 -8
- package/src/cmds/create_account.ts +23 -17
- package/src/cmds/deploy.ts +41 -22
- package/src/cmds/deploy_account.ts +23 -17
- package/src/cmds/send.ts +22 -10
- package/src/cmds/simulate.ts +3 -6
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +27 -6
package/dest/utils/wallet.js
CHANGED
|
@@ -38,12 +38,13 @@ export class CLIWallet extends BaseWallet {
|
|
|
38
38
|
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
39
39
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
40
40
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
41
|
+
const chainInfo = await this.getChainInfo();
|
|
41
42
|
const executionOptions = {
|
|
42
43
|
txNonce,
|
|
43
44
|
cancellable: this.cancellableTransactions,
|
|
44
45
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
45
46
|
};
|
|
46
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
|
|
47
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
47
48
|
}
|
|
48
49
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
49
50
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
@@ -52,8 +53,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
52
53
|
async getAccountFromAddress(address) {
|
|
53
54
|
let account;
|
|
54
55
|
if (address.equals(AztecAddress.ZERO)) {
|
|
55
|
-
|
|
56
|
-
account = new SignerlessAccount(chainInfo);
|
|
56
|
+
account = new SignerlessAccount();
|
|
57
57
|
} else if (this.accountCache.has(address.toString())) {
|
|
58
58
|
return this.accountCache.get(address.toString());
|
|
59
59
|
} else {
|
|
@@ -118,15 +118,25 @@ export class CLIWallet extends BaseWallet {
|
|
|
118
118
|
}
|
|
119
119
|
return account;
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
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) {
|
|
123
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
|
+
}
|
|
124
134
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
125
|
-
const
|
|
135
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
126
136
|
if (!contractInstance) {
|
|
127
137
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
128
138
|
}
|
|
129
|
-
const stubAccount = createStubAccount(originalAddress
|
|
139
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
130
140
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
131
141
|
salt: Fr.random()
|
|
132
142
|
});
|
|
@@ -140,6 +150,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
140
150
|
let simulationResults;
|
|
141
151
|
const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
142
152
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
153
|
+
const chainInfo = await this.getChainInfo();
|
|
143
154
|
const executionOptions = {
|
|
144
155
|
txNonce: Fr.random(),
|
|
145
156
|
cancellable: this.cancellableTransactions,
|
|
@@ -154,11 +165,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
154
165
|
// TODO: allow disabling kernels even when no overrides are necessary
|
|
155
166
|
if (opts.from.equals(AztecAddress.ZERO)) {
|
|
156
167
|
const fromAccount = await this.getAccountFromAddress(opts.from);
|
|
157
|
-
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
168
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
158
169
|
simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
159
170
|
} else {
|
|
160
171
|
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
|
|
161
|
-
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
172
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
162
173
|
const contractOverrides = {
|
|
163
174
|
[opts.from.toString()]: {
|
|
164
175
|
instance,
|
|
@@ -185,4 +196,9 @@ export class CLIWallet extends BaseWallet {
|
|
|
185
196
|
getNotes(filter) {
|
|
186
197
|
return this.pxe.debug.getNotes(filter);
|
|
187
198
|
}
|
|
199
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
200
|
+
// this is just a CLI wallet.
|
|
201
|
+
getContractArtifact(id) {
|
|
202
|
+
return this.pxe.getContractArtifact(id);
|
|
203
|
+
}
|
|
188
204
|
}
|
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.1a99e26c",
|
|
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.1a99e26c",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.1a99e26c",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.1a99e26c",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.1a99e26c",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.1a99e26c",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.1a99e26c",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.1a99e26c",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.1a99e26c",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.1a99e26c",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.1a99e26c",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.1a99e26c",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.1a99e26c",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.1a99e26c",
|
|
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
|
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -164,15 +167,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
|
|
|
164
167
|
const knownContractAddresses = await wallet.getContracts();
|
|
165
168
|
const knownContracts = (
|
|
166
169
|
await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
|
|
167
|
-
).map(contractMetadata => contractMetadata.
|
|
170
|
+
).map(contractMetadata => contractMetadata.instance);
|
|
168
171
|
const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
|
|
169
172
|
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
|
-
);
|
|
173
|
+
await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
|
|
174
|
+
).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
|
|
176
175
|
const map: Record<string, ContractArtifactWithClassId> = {};
|
|
177
176
|
for (const instance of knownContracts) {
|
|
178
177
|
if (instance) {
|
|
@@ -1,9 +1,11 @@
|
|
|
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 { 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';
|
|
9
11
|
import type { AccountType } from '../utils/constants.js';
|
|
@@ -64,8 +66,8 @@ export async function createAccount(
|
|
|
64
66
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
let
|
|
68
|
-
let txReceipt;
|
|
69
|
+
let txHash: TxHash | undefined;
|
|
70
|
+
let txReceipt: TxReceipt | undefined;
|
|
69
71
|
if (!registerOnly) {
|
|
70
72
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
71
73
|
|
|
@@ -100,7 +102,14 @@ export async function createAccount(
|
|
|
100
102
|
};
|
|
101
103
|
}
|
|
102
104
|
} else {
|
|
103
|
-
|
|
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({
|
|
104
113
|
...deployAccountOpts,
|
|
105
114
|
fee: deployAccountOpts.fee
|
|
106
115
|
? {
|
|
@@ -108,32 +117,29 @@ export async function createAccount(
|
|
|
108
117
|
gasSettings: estimatedGas,
|
|
109
118
|
}
|
|
110
119
|
: undefined,
|
|
120
|
+
wait: wait ? { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true } : NO_WAIT,
|
|
111
121
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const txHash = await tx.getTxHash();
|
|
117
|
-
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
118
|
-
out.txHash = txHash;
|
|
119
|
-
if (wait) {
|
|
120
|
-
if (!json) {
|
|
121
|
-
log(`\nWaiting for account contract deployment...`);
|
|
122
|
-
}
|
|
123
|
-
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;
|
|
124
126
|
out.txReceipt = {
|
|
125
127
|
status: txReceipt.status,
|
|
126
128
|
transactionFee: txReceipt.transactionFee,
|
|
127
129
|
};
|
|
130
|
+
} else {
|
|
131
|
+
txHash = result;
|
|
128
132
|
}
|
|
133
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
134
|
+
out.txHash = txHash;
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
if (json) {
|
|
133
139
|
log(prettyPrintJSON(out));
|
|
134
140
|
} else {
|
|
135
|
-
if (
|
|
136
|
-
log(`Deploy tx hash: ${
|
|
141
|
+
if (txHash) {
|
|
142
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
137
143
|
}
|
|
138
144
|
if (txReceipt) {
|
|
139
145
|
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';
|
|
@@ -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}`);
|
package/src/cmds/send.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import { Contract, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { Contract, NO_WAIT, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
5
5
|
import { prepTx } from '@aztec/cli/utils';
|
|
6
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
@@ -46,31 +46,43 @@ export async function send(
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const tx = call.send({ ...sendOptions, fee: { ...sendOptions.fee, gasSettings: estimatedGas } });
|
|
50
49
|
if (verbose) {
|
|
51
50
|
printProfileResult(stats!, log);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
const txHash = await tx.getTxHash();
|
|
55
|
-
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
56
53
|
if (wait) {
|
|
57
54
|
try {
|
|
58
|
-
await
|
|
55
|
+
const receipt = await call.send({
|
|
56
|
+
...sendOptions,
|
|
57
|
+
fee: { ...sendOptions.fee, gasSettings: estimatedGas },
|
|
58
|
+
wait: { timeout: DEFAULT_TX_TIMEOUT_S },
|
|
59
|
+
});
|
|
59
60
|
|
|
61
|
+
const txHash = receipt.txHash;
|
|
62
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
60
63
|
log('Transaction has been mined');
|
|
61
|
-
|
|
62
|
-
const receipt = await tx.getReceipt();
|
|
63
64
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
64
65
|
log(` Status: ${receipt.status}`);
|
|
65
66
|
log(` Block number: ${receipt.blockNumber}`);
|
|
66
67
|
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
txHash,
|
|
71
|
+
};
|
|
67
72
|
} catch (err: any) {
|
|
68
73
|
log(`Transaction failed\n ${err.message}`);
|
|
74
|
+
throw err;
|
|
69
75
|
}
|
|
70
76
|
} else {
|
|
77
|
+
const txHash = await call.send({
|
|
78
|
+
...sendOptions,
|
|
79
|
+
fee: { ...sendOptions.fee, gasSettings: estimatedGas },
|
|
80
|
+
wait: NO_WAIT,
|
|
81
|
+
});
|
|
82
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
71
83
|
log('Transaction pending. Check status with check-tx');
|
|
84
|
+
return {
|
|
85
|
+
txHash,
|
|
86
|
+
};
|
|
72
87
|
}
|
|
73
|
-
return {
|
|
74
|
-
txHash,
|
|
75
|
-
};
|
|
76
88
|
}
|
package/src/cmds/simulate.ts
CHANGED
|
@@ -41,14 +41,11 @@ export async function simulate(
|
|
|
41
41
|
simulationResult.offchainEffects!,
|
|
42
42
|
async (address: AztecAddress) => {
|
|
43
43
|
const metadata = await wallet.getContractMetadata(address);
|
|
44
|
-
if (!metadata.
|
|
44
|
+
if (!metadata.instance) {
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
true,
|
|
50
|
-
);
|
|
51
|
-
return classMetadata.artifact;
|
|
47
|
+
const artifact = await wallet.getContractArtifact(metadata.instance.currentContractClassId);
|
|
48
|
+
return artifact;
|
|
52
49
|
},
|
|
53
50
|
log,
|
|
54
51
|
);
|
package/src/utils/profiling.ts
CHANGED
|
@@ -95,7 +95,7 @@ export function printProfileResult(
|
|
|
95
95
|
|
|
96
96
|
if (stats.nodeRPCCalls) {
|
|
97
97
|
log(format('\nRPC calls:\n'));
|
|
98
|
-
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls)) {
|
|
98
|
+
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)) {
|
|
99
99
|
const calls = times.length;
|
|
100
100
|
const total = times.reduce((acc, time) => acc + time, 0);
|
|
101
101
|
const avg = total / calls;
|
|
@@ -112,6 +112,20 @@ export function printProfileResult(
|
|
|
112
112
|
),
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
const { roundTrips } = stats.nodeRPCCalls;
|
|
117
|
+
log(format('\nRound trips (actual blocking waits):\n'));
|
|
118
|
+
log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
|
|
119
|
+
log(
|
|
120
|
+
format(
|
|
121
|
+
'Total blocking time:'.padEnd(25),
|
|
122
|
+
`${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH),
|
|
123
|
+
),
|
|
124
|
+
);
|
|
125
|
+
if (roundTrips.roundTrips > 0) {
|
|
126
|
+
const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
|
|
127
|
+
log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
128
|
+
}
|
|
115
129
|
}
|
|
116
130
|
|
|
117
131
|
log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));
|
package/src/utils/wallet.ts
CHANGED
|
@@ -67,6 +67,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
67
67
|
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
68
68
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
69
69
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
70
|
+
const chainInfo = await this.getChainInfo();
|
|
70
71
|
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
71
72
|
txNonce,
|
|
72
73
|
cancellable: this.cancellableTransactions,
|
|
@@ -75,6 +76,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
75
76
|
return await fromAccount.createTxExecutionRequest(
|
|
76
77
|
feeExecutionPayload ?? executionPayload,
|
|
77
78
|
feeOptions.gasSettings,
|
|
79
|
+
chainInfo,
|
|
78
80
|
executionOptions,
|
|
79
81
|
);
|
|
80
82
|
}
|
|
@@ -91,8 +93,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
91
93
|
override async getAccountFromAddress(address: AztecAddress) {
|
|
92
94
|
let account: Account | undefined;
|
|
93
95
|
if (address.equals(AztecAddress.ZERO)) {
|
|
94
|
-
|
|
95
|
-
account = new SignerlessAccount(chainInfo);
|
|
96
|
+
account = new SignerlessAccount();
|
|
96
97
|
} else if (this.accountCache.has(address.toString())) {
|
|
97
98
|
return this.accountCache.get(address.toString())!;
|
|
98
99
|
} else {
|
|
@@ -176,15 +177,26 @@ export class CLIWallet extends BaseWallet {
|
|
|
176
177
|
return account;
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
182
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
183
|
+
* @param address - The address of the account to impersonate
|
|
184
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
185
|
+
*/
|
|
179
186
|
private async getFakeAccountDataFor(address: AztecAddress) {
|
|
180
|
-
const chainInfo = await this.getChainInfo();
|
|
181
187
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
// Account contracts can only be overridden if they have an associated address
|
|
189
|
+
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
190
|
+
// since it has no authorization mechanism.
|
|
191
|
+
if (originalAccount instanceof SignerlessAccount) {
|
|
192
|
+
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
193
|
+
}
|
|
194
|
+
const originalAddress = (originalAccount as Account).getCompleteAddress();
|
|
195
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
184
196
|
if (!contractInstance) {
|
|
185
197
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
186
198
|
}
|
|
187
|
-
const stubAccount = createStubAccount(originalAddress
|
|
199
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
188
200
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
189
201
|
salt: Fr.random(),
|
|
190
202
|
});
|
|
@@ -201,6 +213,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
201
213
|
? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
|
|
202
214
|
: await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
203
215
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
216
|
+
const chainInfo = await this.getChainInfo();
|
|
204
217
|
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
205
218
|
txNonce: Fr.random(),
|
|
206
219
|
cancellable: this.cancellableTransactions,
|
|
@@ -218,6 +231,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
218
231
|
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
219
232
|
finalExecutionPayload,
|
|
220
233
|
feeOptions.gasSettings,
|
|
234
|
+
chainInfo,
|
|
221
235
|
executionOptions,
|
|
222
236
|
);
|
|
223
237
|
simulationResults = await this.pxe.simulateTx(
|
|
@@ -231,6 +245,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
231
245
|
const txRequest = await fromAccount.createTxExecutionRequest(
|
|
232
246
|
finalExecutionPayload,
|
|
233
247
|
feeOptions.gasSettings,
|
|
248
|
+
chainInfo,
|
|
234
249
|
executionOptions,
|
|
235
250
|
);
|
|
236
251
|
const contractOverrides = {
|
|
@@ -259,4 +274,10 @@ export class CLIWallet extends BaseWallet {
|
|
|
259
274
|
getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
260
275
|
return this.pxe.debug.getNotes(filter);
|
|
261
276
|
}
|
|
277
|
+
|
|
278
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
279
|
+
// this is just a CLI wallet.
|
|
280
|
+
getContractArtifact(id: Fr) {
|
|
281
|
+
return this.pxe.getContractArtifact(id);
|
|
282
|
+
}
|
|
262
283
|
}
|