@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.
Files changed (39) hide show
  1. package/dest/cmds/check_tx.js +2 -1
  2. package/dest/cmds/create_account.d.ts +4 -3
  3. package/dest/cmds/create_account.d.ts.map +1 -1
  4. package/dest/cmds/create_account.js +22 -19
  5. package/dest/cmds/deploy.d.ts +4 -3
  6. package/dest/cmds/deploy.d.ts.map +1 -1
  7. package/dest/cmds/deploy.js +22 -21
  8. package/dest/cmds/deploy_account.d.ts +4 -3
  9. package/dest/cmds/deploy_account.d.ts.map +1 -1
  10. package/dest/cmds/deploy_account.js +17 -14
  11. package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
  12. package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
  13. package/dest/cmds/get_fee_juice_balance.js +27 -0
  14. package/dest/cmds/index.d.ts +1 -1
  15. package/dest/cmds/index.d.ts.map +1 -1
  16. package/dest/cmds/index.js +30 -14
  17. package/dest/cmds/send.d.ts +4 -3
  18. package/dest/cmds/send.d.ts.map +1 -1
  19. package/dest/cmds/send.js +23 -22
  20. package/dest/storage/wallet_db.d.ts +6 -1
  21. package/dest/storage/wallet_db.d.ts.map +1 -1
  22. package/dest/storage/wallet_db.js +14 -0
  23. package/dest/utils/options/fees.d.ts +3 -2
  24. package/dest/utils/options/fees.d.ts.map +1 -1
  25. package/dest/utils/options/fees.js +30 -9
  26. package/dest/utils/wallet.d.ts +5 -4
  27. package/dest/utils/wallet.d.ts.map +1 -1
  28. package/dest/utils/wallet.js +31 -12
  29. package/package.json +14 -14
  30. package/src/cmds/check_tx.ts +3 -2
  31. package/src/cmds/create_account.ts +23 -15
  32. package/src/cmds/deploy.ts +19 -14
  33. package/src/cmds/deploy_account.ts +17 -10
  34. package/src/cmds/get_fee_juice_balance.ts +37 -0
  35. package/src/cmds/index.ts +56 -3
  36. package/src/cmds/send.ts +20 -15
  37. package/src/storage/wallet_db.ts +14 -0
  38. package/src/utils/options/fees.ts +33 -9
  39. package/src/utils/wallet.ts +36 -18
@@ -1,6 +1,7 @@
1
1
  import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
2
2
  import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
3
- import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
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, TxSimulationResult } from '@aztec/stdlib/tx';
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(accounts.map(({ key, value }) => ({ alias: value, item: AztecAddress.fromString(key) })));
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(from, executionPayload.feePayer, increasedFee.gasSettings);
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 stubAccount = createStubAccount(originalAddress);
194
- const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
195
- salt: Fr.random(),
196
- });
197
- return {
198
- account: stubAccount,
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(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
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(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
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<TxSimulationResult> {
223
- const { from, feeOptions, scopes } = opts;
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
- return this.pxe.simulateTx(txRequest, {
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