@aztec/cli-wallet 0.0.1-commit.3469e52 → 0.0.1-commit.358457c

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.
@@ -13,16 +13,16 @@ import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec
13
13
  import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
14
14
  import { Fr } from '@aztec/foundation/curves/bn254';
15
15
  import type { LogFn } from '@aztec/foundation/log';
16
+ import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
16
17
  import type { PXEConfig } from '@aztec/pxe/config';
17
18
  import type { PXE } from '@aztec/pxe/server';
18
19
  import { createPXE, getPXEConfig } from '@aztec/pxe/server';
19
20
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
20
21
  import { deriveSigningKey } from '@aztec/stdlib/keys';
21
22
  import { NoteDao } from '@aztec/stdlib/note';
22
- import type { NotesFilter } from '@aztec/stdlib/note';
23
23
  import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
24
24
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
25
- import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
25
+ import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
26
26
 
27
27
  import type { WalletDB } from '../storage/wallet_db.js';
28
28
  import type { AccountType } from './constants.js';
@@ -87,7 +87,7 @@ export class CLIWallet extends BaseWallet {
87
87
  increasedFee: InteractionFeeOptions,
88
88
  ): Promise<TxProvingResult> {
89
89
  const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
90
- return await this.pxe.proveTx(cancellationTxRequest);
90
+ return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
91
91
  }
92
92
 
93
93
  override async getAccountFromAddress(address: AztecAddress) {
@@ -208,12 +208,40 @@ export class CLIWallet extends BaseWallet {
208
208
  }
209
209
 
210
210
  override async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
211
- let simulationResults;
212
- const feeOptions = opts.fee?.estimateGas
213
- ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
214
- : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
211
+ const simulationResults = await super.simulateTx(executionPayload, opts);
212
+
213
+ if (opts.fee?.estimateGas) {
214
+ const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
215
+ const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
216
+ printGasEstimates(feeOptions, limits, this.userLog);
217
+ }
218
+ return simulationResults;
219
+ }
220
+
221
+ /**
222
+ * Uses a stub account for kernelless simulation, bypassing real account authorization.
223
+ * Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
224
+ */
225
+ protected override async simulateViaEntrypoint(
226
+ executionPayload: ExecutionPayload,
227
+ from: AztecAddress,
228
+ feeOptions: FeeOptions,
229
+ scopes: AccessScopes,
230
+ skipTxValidation?: boolean,
231
+ skipFeeEnforcement?: boolean,
232
+ ): Promise<TxSimulationResult> {
233
+ if (from.equals(AztecAddress.ZERO)) {
234
+ return super.simulateViaEntrypoint(
235
+ executionPayload,
236
+ from,
237
+ feeOptions,
238
+ scopes,
239
+ skipTxValidation,
240
+ skipFeeEnforcement,
241
+ );
242
+ }
243
+
215
244
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
216
- const chainInfo = await this.getChainInfo();
217
245
  const executionOptions: DefaultAccountEntrypointOptions = {
218
246
  txNonce: Fr.random(),
219
247
  cancellable: this.cancellableTransactions,
@@ -223,44 +251,23 @@ export class CLIWallet extends BaseWallet {
223
251
  ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
224
252
  : executionPayload;
225
253
 
226
- // Kernelless simulations using the multicall entrypoints are not currently supported,
227
- // since we only override proper account contracts.
228
- // TODO: allow disabling kernels even when no overrides are necessary
229
- if (opts.from.equals(AztecAddress.ZERO)) {
230
- const fromAccount = await this.getAccountFromAddress(opts.from);
231
- const txRequest = await fromAccount.createTxExecutionRequest(
232
- finalExecutionPayload,
233
- feeOptions.gasSettings,
234
- chainInfo,
235
- executionOptions,
236
- );
237
- simulationResults = await this.pxe.simulateTx(
238
- txRequest,
239
- true /* simulatePublic */,
240
- opts?.skipTxValidation,
241
- opts?.skipFeeEnforcement ?? true,
242
- );
243
- } else {
244
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
245
- const txRequest = await fromAccount.createTxExecutionRequest(
246
- finalExecutionPayload,
247
- feeOptions.gasSettings,
248
- chainInfo,
249
- executionOptions,
250
- );
251
- const contractOverrides = {
252
- [opts.from.toString()]: { instance, artifact },
253
- };
254
- simulationResults = await this.pxe.simulateTx(txRequest, true /* simulatePublic */, true, true, {
255
- contracts: contractOverrides,
256
- });
257
- }
258
-
259
- if (opts.fee?.estimateGas) {
260
- const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
261
- printGasEstimates(feeOptions, limits, this.userLog);
262
- }
263
- return simulationResults;
254
+ const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
255
+ const chainInfo = await this.getChainInfo();
256
+ const txRequest = await fromAccount.createTxExecutionRequest(
257
+ finalExecutionPayload,
258
+ feeOptions.gasSettings,
259
+ chainInfo,
260
+ executionOptions,
261
+ );
262
+ return this.pxe.simulateTx(txRequest, {
263
+ simulatePublic: true,
264
+ skipFeeEnforcement: true,
265
+ skipTxValidation: true,
266
+ overrides: {
267
+ contracts: { [from.toString()]: { instance, artifact } },
268
+ },
269
+ scopes,
270
+ });
264
271
  }
265
272
 
266
273
  // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because