@aztec/cli-wallet 0.0.1-commit.3f296a7d2 → 0.0.1-commit.3f5453c7b
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/check_tx.js +2 -1
- 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 +22 -19
- package/dest/cmds/deploy.d.ts +4 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +22 -21
- 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 +17 -14
- 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 +23 -22
- 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 +14 -0
- 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 +30 -9
- package/dest/utils/wallet.d.ts +5 -4
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +31 -12
- package/package.json +14 -14
- package/src/cmds/check_tx.ts +3 -2
- package/src/cmds/create_account.ts +23 -15
- package/src/cmds/deploy.ts +19 -14
- package/src/cmds/deploy_account.ts +17 -10
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +56 -3
- package/src/cmds/send.ts +20 -15
- package/src/storage/wallet_db.ts +14 -0
- package/src/utils/options/fees.ts +33 -9
- package/src/utils/wallet.ts +36 -18
package/src/utils/wallet.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
6
|
import { type Account, type AccountContract, NO_FROM } from '@aztec/aztec.js/account';
|
|
6
7
|
import {
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
} from '@aztec/aztec.js/contracts';
|
|
11
12
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
12
13
|
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
14
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
13
15
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
14
16
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
15
17
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -21,7 +23,7 @@ import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
|
21
23
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
24
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
23
25
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
24
|
-
import type { SimulationOverrides, TxExecutionRequest, TxProvingResult
|
|
26
|
+
import type { SimulationOverrides, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib/tx';
|
|
25
27
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
26
28
|
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
27
29
|
|
|
@@ -56,7 +58,12 @@ export class CLIWallet extends BaseWallet {
|
|
|
56
58
|
|
|
57
59
|
override async getAccounts(): Promise<Aliased<AztecAddress>[]> {
|
|
58
60
|
const accounts = (await this.db?.listAliases('accounts')) ?? [];
|
|
59
|
-
return Promise.resolve(
|
|
61
|
+
return Promise.resolve(
|
|
62
|
+
accounts.map(({ key, value }) => {
|
|
63
|
+
const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
|
|
64
|
+
return { alias, item: AztecAddress.fromString(value) };
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
private async createCancellationTxExecutionRequest(
|
|
@@ -65,7 +72,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
65
72
|
increasedFee: InteractionFeeOptions,
|
|
66
73
|
) {
|
|
67
74
|
const executionPayload = ExecutionPayload.empty();
|
|
68
|
-
const feeOptions = await this.completeFeeOptions(
|
|
75
|
+
const feeOptions = await this.completeFeeOptions({
|
|
76
|
+
from,
|
|
77
|
+
feePayer: executionPayload.feePayer,
|
|
78
|
+
gasSettings: increasedFee.gasSettings,
|
|
79
|
+
});
|
|
69
80
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
70
81
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
71
82
|
const chainInfo = await this.getChainInfo();
|
|
@@ -190,22 +201,26 @@ export class CLIWallet extends BaseWallet {
|
|
|
190
201
|
if (!contractInstance) {
|
|
191
202
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
192
203
|
}
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
instance,
|
|
200
|
-
artifact: StubAccountContractArtifact,
|
|
201
|
-
};
|
|
204
|
+
const { type } = await this.db!.retrieveAccount(address);
|
|
205
|
+
const isSchnorr = type === 'schnorr';
|
|
206
|
+
const artifact = isSchnorr ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact;
|
|
207
|
+
const stubAccount = isSchnorr ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
208
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, { salt: Fr.random() });
|
|
209
|
+
return { account: stubAccount, instance, artifact };
|
|
202
210
|
}
|
|
203
211
|
|
|
204
|
-
override async simulateTx(
|
|
212
|
+
override async simulateTx(
|
|
213
|
+
executionPayload: ExecutionPayload,
|
|
214
|
+
opts: SimulateOptions,
|
|
215
|
+
): Promise<TxSimulationResultWithAppOffset> {
|
|
205
216
|
const simulationResults = await super.simulateTx(executionPayload, opts);
|
|
206
217
|
|
|
207
218
|
if (opts.fee?.estimateGas) {
|
|
208
|
-
const feeOptions = await this.completeFeeOptions(
|
|
219
|
+
const feeOptions = await this.completeFeeOptions({
|
|
220
|
+
from: opts.from,
|
|
221
|
+
feePayer: executionPayload.feePayer,
|
|
222
|
+
gasSettings: opts.fee?.gasSettings,
|
|
223
|
+
});
|
|
209
224
|
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
210
225
|
printGasEstimates(feeOptions, limits, this.userLog);
|
|
211
226
|
}
|
|
@@ -219,8 +234,9 @@ export class CLIWallet extends BaseWallet {
|
|
|
219
234
|
protected override async simulateViaEntrypoint(
|
|
220
235
|
executionPayload: ExecutionPayload,
|
|
221
236
|
opts: SimulateViaEntrypointOptions,
|
|
222
|
-
): Promise<
|
|
223
|
-
const { from, feeOptions,
|
|
237
|
+
): Promise<TxSimulationResultWithAppOffset> {
|
|
238
|
+
const { from, feeOptions, additionalScopes } = opts;
|
|
239
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
224
240
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
225
241
|
const finalExecutionPayload = feeExecutionPayload
|
|
226
242
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
@@ -251,13 +267,15 @@ export class CLIWallet extends BaseWallet {
|
|
|
251
267
|
);
|
|
252
268
|
}
|
|
253
269
|
|
|
254
|
-
|
|
270
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
255
271
|
simulatePublic: true,
|
|
256
272
|
skipFeeEnforcement: true,
|
|
257
273
|
skipTxValidation: true,
|
|
258
274
|
overrides,
|
|
259
275
|
scopes,
|
|
260
276
|
});
|
|
277
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
278
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
261
279
|
}
|
|
262
280
|
|
|
263
281
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|