@aztec/wallet-sdk 0.0.1-commit.9d2bcf6d → 0.0.1-commit.9ee6fcc6

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.
@@ -107,18 +107,18 @@ export interface WalletProvider {
107
107
  * After calling this, the wallet returned from confirm() should no longer be used.
108
108
  * @returns A promise that resolves when disconnection is complete
109
109
  */
110
- disconnect?(): Promise<void>;
110
+ disconnect(): Promise<void>;
111
111
  /**
112
112
  * Registers a callback to be invoked when the wallet disconnects unexpectedly.
113
113
  * @param callback - Function to call when wallet disconnects
114
114
  * @returns A function to unregister the callback
115
115
  */
116
- onDisconnect?(callback: ProviderDisconnectionCallback): () => void;
116
+ onDisconnect(callback: ProviderDisconnectionCallback): () => void;
117
117
  /**
118
118
  * Returns whether the provider's wallet connection has been disconnected.
119
119
  * @returns true if the wallet is no longer connected
120
120
  */
121
- isDisconnected?(): boolean;
121
+ isDisconnected(): boolean;
122
122
  }
123
123
  /**
124
124
  * Options for discovering wallets
@@ -164,4 +164,4 @@ export interface DiscoverySession {
164
164
  /** Cancel discovery immediately and clean up resources */
165
165
  cancel: () => void;
166
166
  }
167
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYW5hZ2VyL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXJEOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sV0FBVyxpQkFBaUI7SUFDaEM7Ozs7T0FJRztJQUNILGdCQUFnQixFQUFFLE1BQU0sQ0FBQztJQUV6Qjs7O09BR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AkB,CAAC;IACzB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,6BAA6B,GAAG,MAAM,IAAI,CAAC;IAClE;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,SAAS,EAAE,SAAS,CAAC;IACrB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,qEAAqE;IACrE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB"}
@@ -67,4 +67,4 @@ export declare class WalletManager {
67
67
  */
68
68
  private isExtensionAllowed;
69
69
  }
70
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X21hbmFnZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYW5hZ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RixPQUFPLGVBQWlCO0lBRXhCOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLG1CQUFtQixHQUFHLGFBQWEsQ0FPM0Q7SUFFRDs7Ozs7Ozs7Ozs7O09BWUc7SUFDSCxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsc0JBQXNCLEdBQUcsZ0JBQWdCLENBNkVyRTtJQUVEOzs7Ozs7T0FNRztJQUNILE9BQU8sQ0FBQyxrQ0FBa0M7SUEwRTFDOzs7O09BSUc7SUFDSCxPQUFPLENBQUMsa0JBQWtCO0NBVzNCIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../src/manager/wallet_manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAIhB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAGZ;IAEF,OAAO,eAAiB;IAExB;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAO3D;IAED;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CA6ErE;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kCAAkC;IA4E1C;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAW3B"}
1
+ {"version":3,"file":"wallet_manager.d.ts","sourceRoot":"","sources":["../../src/manager/wallet_manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAIhB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAGZ;IAEF,OAAO,eAAiB;IAExB;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAO3D;IAED;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CA6ErE;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kCAAkC;IA0E1C;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAW3B"}
@@ -176,7 +176,8 @@ import { WalletMessageType } from '../types.js';
176
176
  return {
177
177
  verificationHash: connection.info.verificationHash,
178
178
  confirm: ()=>{
179
- return Promise.resolve(ExtensionWallet.create(connection.info.id, connection.port, connection.sharedKey, chainInfo, connectAppId));
179
+ extensionWallet = ExtensionWallet.create(connection.info.id, connection.port, connection.sharedKey, chainInfo, connectAppId);
180
+ return Promise.resolve(extensionWallet.asWallet());
180
181
  },
181
182
  cancel: ()=>{
182
183
  // Send disconnect to terminate the session on the extension side
@@ -185,7 +186,6 @@ import { WalletMessageType } from '../types.js';
185
186
  type: WalletMessageType.DISCONNECT,
186
187
  requestId: discoveredWallet.requestId
187
188
  });
188
- // Don't close the port - allow retry with fresh key exchange
189
189
  }
190
190
  };
191
191
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aztec/wallet-sdk",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
4
- "version": "0.0.1-commit.9d2bcf6d",
4
+ "version": "0.0.1-commit.9ee6fcc6",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./base-wallet": "./dest/base-wallet/index.js",
@@ -13,8 +13,14 @@
13
13
  },
14
14
  "typedocOptions": {
15
15
  "entryPoints": [
16
- "./src/index.ts"
16
+ "./src/base-wallet/index.ts",
17
+ "./src/extension/handlers/index.ts",
18
+ "./src/extension/provider/index.ts",
19
+ "./src/crypto.ts",
20
+ "./src/types.ts",
21
+ "./src/manager/index.ts"
17
22
  ],
23
+ "name": "Wallet SDK",
18
24
  "tsconfig": "./tsconfig.json"
19
25
  },
20
26
  "scripts": {
@@ -65,15 +71,15 @@
65
71
  ]
66
72
  },
67
73
  "dependencies": {
68
- "@aztec/aztec.js": "0.0.1-commit.9d2bcf6d",
69
- "@aztec/constants": "0.0.1-commit.9d2bcf6d",
70
- "@aztec/entrypoints": "0.0.1-commit.9d2bcf6d",
71
- "@aztec/foundation": "0.0.1-commit.9d2bcf6d",
72
- "@aztec/pxe": "0.0.1-commit.9d2bcf6d",
73
- "@aztec/stdlib": "0.0.1-commit.9d2bcf6d"
74
+ "@aztec/aztec.js": "0.0.1-commit.9ee6fcc6",
75
+ "@aztec/constants": "0.0.1-commit.9ee6fcc6",
76
+ "@aztec/entrypoints": "0.0.1-commit.9ee6fcc6",
77
+ "@aztec/foundation": "0.0.1-commit.9ee6fcc6",
78
+ "@aztec/pxe": "0.0.1-commit.9ee6fcc6",
79
+ "@aztec/stdlib": "0.0.1-commit.9ee6fcc6"
74
80
  },
75
81
  "devDependencies": {
76
- "@aztec/noir-contracts.js": "0.0.1-commit.9d2bcf6d",
82
+ "@aztec/noir-contracts.js": "0.0.1-commit.9ee6fcc6",
77
83
  "@jest/globals": "^30.0.0",
78
84
  "@types/jest": "^30.0.0",
79
85
  "@types/node": "^22.15.17",
@@ -1,6 +1,11 @@
1
1
  import type { Account } from '@aztec/aztec.js/account';
2
2
  import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
3
- import { type InteractionWaitOptions, NO_WAIT, type SendReturn } from '@aztec/aztec.js/contracts';
3
+ import {
4
+ type InteractionWaitOptions,
5
+ NO_WAIT,
6
+ type SendReturn,
7
+ extractOffchainOutput,
8
+ } from '@aztec/aztec.js/contracts';
4
9
  import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
5
10
  import { waitForTx } from '@aztec/aztec.js/node';
6
11
  import type {
@@ -8,6 +13,7 @@ import type {
8
13
  AppCapabilities,
9
14
  BatchResults,
10
15
  BatchedMethod,
16
+ ExecuteUtilityOptions,
11
17
  PrivateEvent,
12
18
  PrivateEventFilter,
13
19
  ProfileOptions,
@@ -27,6 +33,7 @@ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
27
33
  import { Fr } from '@aztec/foundation/curves/bn254';
28
34
  import { createLogger } from '@aztec/foundation/log';
29
35
  import type { FieldsOf } from '@aztec/foundation/types';
36
+ import { type AccessScopes, displayDebugLogs } from '@aztec/pxe/client/lazy';
30
37
  import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
31
38
  import {
32
39
  type ContractArtifact,
@@ -35,7 +42,7 @@ import {
35
42
  decodeFromAbi,
36
43
  } from '@aztec/stdlib/abi';
37
44
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
38
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
45
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
39
46
  import {
40
47
  type ContractInstanceWithAddress,
41
48
  computePartialAddress,
@@ -43,18 +50,21 @@ import {
43
50
  } from '@aztec/stdlib/contract';
44
51
  import { SimulationError } from '@aztec/stdlib/errors';
45
52
  import { Gas, GasSettings } from '@aztec/stdlib/gas';
46
- import { siloNullifier } from '@aztec/stdlib/hash';
53
+ import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
47
54
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
48
- import type {
49
- TxExecutionRequest,
50
- TxProfileResult,
55
+ import {
56
+ BlockHeader,
57
+ type TxExecutionRequest,
58
+ type TxProfileResult,
51
59
  TxSimulationResult,
52
- UtilitySimulationResult,
60
+ type UtilityExecutionResult,
53
61
  } from '@aztec/stdlib/tx';
54
62
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
55
63
 
56
64
  import { inspect } from 'util';
57
65
 
66
+ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
67
+
58
68
  /**
59
69
  * Options to configure fee payment for a transaction
60
70
  */
@@ -70,12 +80,20 @@ export type FeeOptions = {
70
80
  gasSettings: GasSettings;
71
81
  };
72
82
 
83
+ /** Options for `simulateViaEntrypoint`. */
84
+ export type SimulateViaEntrypointOptions = Pick<
85
+ SimulateOptions,
86
+ 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'
87
+ > & {
88
+ /** Fee options for the entrypoint */
89
+ feeOptions: FeeOptions;
90
+ /** Scopes to use for the simulation */
91
+ scopes: AccessScopes;
92
+ };
73
93
  /**
74
94
  * A base class for Wallet implementations
75
95
  */
76
96
  export abstract class BaseWallet implements Wallet {
77
- protected log = createLogger('wallet-sdk:base_wallet');
78
-
79
97
  protected minFeePadding = 0.5;
80
98
  protected cancellableTransactions = false;
81
99
 
@@ -83,8 +101,15 @@ export abstract class BaseWallet implements Wallet {
83
101
  protected constructor(
84
102
  protected readonly pxe: PXE,
85
103
  protected readonly aztecNode: AztecNode,
104
+ protected log = createLogger('wallet-sdk:base_wallet'),
86
105
  ) {}
87
106
 
107
+ protected scopesFrom(from: AztecAddress, additionalScopes: AztecAddress[] = []): AztecAddress[] {
108
+ const allScopes = from.isZero() ? additionalScopes : [from, ...additionalScopes];
109
+ const scopeSet = new Set(allScopes.map(address => address.toString()));
110
+ return [...scopeSet].map(AztecAddress.fromString);
111
+ }
112
+
88
113
  protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
89
114
 
90
115
  abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
@@ -282,23 +307,85 @@ export abstract class BaseWallet implements Wallet {
282
307
  return instance;
283
308
  }
284
309
 
310
+ /**
311
+ * Simulates calls through the standard PXE path (account entrypoint).
312
+ * @param executionPayload - The execution payload to simulate.
313
+ * @param opts - Simulation options.
314
+ */
315
+ protected async simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions) {
316
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(
317
+ executionPayload,
318
+ opts.from,
319
+ opts.feeOptions,
320
+ );
321
+ return this.pxe.simulateTx(txRequest, {
322
+ simulatePublic: true,
323
+ skipTxValidation: opts.skipTxValidation,
324
+ skipFeeEnforcement: opts.skipFeeEnforcement,
325
+ scopes: opts.scopes,
326
+ });
327
+ }
328
+
329
+ /**
330
+ * Simulates a transaction, optimizing leading public static calls by running them directly
331
+ * on the node while sending the remaining calls through the standard PXE path.
332
+ * Return values from both paths are merged back in original call order.
333
+ * @param executionPayload - The execution payload to simulate.
334
+ * @param opts - Simulation options (from address, fee settings, etc.).
335
+ * @returns The merged simulation result.
336
+ */
285
337
  async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
286
338
  const feeOptions = opts.fee?.estimateGas
287
339
  ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
288
340
  : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
289
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
290
- return this.pxe.simulateTx(
291
- txRequest,
292
- true /* simulatePublic */,
293
- opts?.skipTxValidation,
294
- opts?.skipFeeEnforcement ?? true,
295
- );
341
+ const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
342
+ const remainingPayload = { ...executionPayload, calls: remainingCalls };
343
+
344
+ const chainInfo = await this.getChainInfo();
345
+ let blockHeader: BlockHeader;
346
+ // PXE might not be synced yet, so we pull the latest header from the node
347
+ // To keep things consistent, we'll always try with PXE first
348
+ try {
349
+ blockHeader = await this.pxe.getSyncedBlockHeader();
350
+ } catch {
351
+ blockHeader = (await this.aztecNode.getBlockHeader())!;
352
+ }
353
+
354
+ const [optimizedResults, normalResult] = await Promise.all([
355
+ optimizableCalls.length > 0
356
+ ? simulateViaNode(
357
+ this.aztecNode,
358
+ optimizableCalls,
359
+ opts.from,
360
+ chainInfo,
361
+ feeOptions.gasSettings,
362
+ blockHeader,
363
+ opts.skipFeeEnforcement ?? true,
364
+ this.getContractName.bind(this),
365
+ )
366
+ : Promise.resolve([]),
367
+ remainingCalls.length > 0
368
+ ? this.simulateViaEntrypoint(remainingPayload, {
369
+ from: opts.from,
370
+ feeOptions,
371
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
372
+ skipTxValidation: opts.skipTxValidation,
373
+ skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
374
+ })
375
+ : Promise.resolve(null),
376
+ ]);
377
+
378
+ return buildMergedSimulationResult(optimizedResults, normalResult);
296
379
  }
297
380
 
298
381
  async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
299
382
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
300
383
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
301
- return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
384
+ return this.pxe.profileTx(txRequest, {
385
+ profileMode: opts.profileMode,
386
+ skipProofGeneration: opts.skipProofGeneration ?? true,
387
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
388
+ });
302
389
  }
303
390
 
304
391
  public async sendTx<W extends InteractionWaitOptions = undefined>(
@@ -307,7 +394,11 @@ export abstract class BaseWallet implements Wallet {
307
394
  ): Promise<SendReturn<W>> {
308
395
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
309
396
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
310
- const provenTx = await this.pxe.proveTx(txRequest);
397
+ const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
398
+ const offchainOutput = extractOffchainOutput(
399
+ provenTx.getOffchainEffects(),
400
+ provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp,
401
+ );
311
402
  const tx = await provenTx.toTx();
312
403
  const txHash = tx.getTxHash();
313
404
  if (await this.aztecNode.getTxEffect(txHash)) {
@@ -321,12 +412,32 @@ export abstract class BaseWallet implements Wallet {
321
412
 
322
413
  // If wait is NO_WAIT, return txHash immediately
323
414
  if (opts.wait === NO_WAIT) {
324
- return txHash as SendReturn<W>;
415
+ return { txHash, ...offchainOutput } as SendReturn<W>;
325
416
  }
326
417
 
327
418
  // Otherwise, wait for the full receipt (default behavior on wait: undefined)
328
419
  const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
329
- return (await waitForTx(this.aztecNode, txHash, waitOpts)) as SendReturn<W>;
420
+ const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
421
+
422
+ // Display debug logs from public execution if present (served in test mode only)
423
+ if (receipt.debugLogs?.length) {
424
+ await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
425
+ }
426
+
427
+ return { receipt, ...offchainOutput } as SendReturn<W>;
428
+ }
429
+
430
+ /**
431
+ * Resolves a contract address to a human-readable name via PXE, if available.
432
+ * @param address - The contract address to resolve.
433
+ */
434
+ protected async getContractName(address: AztecAddress): Promise<string | undefined> {
435
+ const instance = await this.pxe.getContractInstance(address);
436
+ if (!instance) {
437
+ return undefined;
438
+ }
439
+ const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
440
+ return artifact?.name;
330
441
  }
331
442
 
332
443
  protected contextualizeError(err: Error, ...context: string[]): Error {
@@ -343,8 +454,8 @@ export abstract class BaseWallet implements Wallet {
343
454
  return err;
344
455
  }
345
456
 
346
- simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult> {
347
- return this.pxe.simulateUtility(call, authwits);
457
+ executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
458
+ return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes: [opts.scope] });
348
459
  }
349
460
 
350
461
  async getPrivateEvents<T>(
@@ -367,17 +478,36 @@ export abstract class BaseWallet implements Wallet {
367
478
  return decodedEvents;
368
479
  }
369
480
 
481
+ /**
482
+ * Returns metadata about a contract, including whether it has been initialized, published, and updated.
483
+ *
484
+ * `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
485
+ * instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
486
+ * @param address - The contract address to query.
487
+ */
370
488
  async getContractMetadata(address: AztecAddress) {
371
489
  const instance = await this.pxe.getContractInstance(address);
372
- const initNullifier = await siloNullifier(address, address.toField());
373
- const publiclyRegisteredContract = await this.aztecNode.getContract(address);
374
- const initNullifierMembershipWitness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
490
+ const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
491
+ // We check only the private initialization nullifier. It is emitted by both private and public initializers and
492
+ // includes init_hash, preventing observers from determining initialization status from the address alone. Without
493
+ // the instance (and thus init_hash), we can't compute it, so we return undefined.
494
+ //
495
+ // We skip the public initialization nullifier because it's not always emitted (contracts without public external
496
+ // functions that require initialization checks won't emit it). If the private one exists, the public one was
497
+ // created in the same tx and will also be present.
498
+ let isContractInitialized: boolean | undefined = undefined;
499
+ if (instance) {
500
+ const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
501
+ const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
502
+ isContractInitialized = !!witness;
503
+ }
504
+ const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
375
505
  const isContractUpdated =
376
506
  publiclyRegisteredContract &&
377
507
  !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
378
508
  return {
379
509
  instance: instance ?? undefined,
380
- isContractInitialized: !!initNullifierMembershipWitness,
510
+ isContractInitialized,
381
511
  isContractPublished: !!publiclyRegisteredContract,
382
512
  isContractUpdated: !!isContractUpdated,
383
513
  updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
@@ -1 +1,2 @@
1
- export { BaseWallet, type FeeOptions } from './base_wallet.js';
1
+ export { BaseWallet, type FeeOptions, type SimulateViaEntrypointOptions } from './base_wallet.js';
2
+ export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
@@ -0,0 +1,238 @@
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
3
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
4
+ import { makeTuple } from '@aztec/foundation/array';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import type { Tuple } from '@aztec/foundation/serialize';
7
+ import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
8
+ import { displayDebugLogs } from '@aztec/pxe/client/lazy';
9
+ import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
10
+ import { type FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
11
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
12
+ import type { GasSettings } from '@aztec/stdlib/gas';
13
+ import {
14
+ ClaimedLengthArray,
15
+ CountedPublicCallRequest,
16
+ PrivateCircuitPublicInputs,
17
+ PublicCallRequest,
18
+ } from '@aztec/stdlib/kernel';
19
+ import { ChonkProof } from '@aztec/stdlib/proofs';
20
+ import {
21
+ type BlockHeader,
22
+ type ExecutionPayload,
23
+ HashedValues,
24
+ PrivateCallExecutionResult,
25
+ PrivateExecutionResult,
26
+ PublicSimulationOutput,
27
+ Tx,
28
+ TxContext,
29
+ TxSimulationResult,
30
+ } from '@aztec/stdlib/tx';
31
+
32
+ /**
33
+ * Splits an execution payload into a leading prefix of public static calls
34
+ * (eligible for direct node simulation) and the remaining calls.
35
+ *
36
+ * Only a leading run of public static calls is eligible for optimization.
37
+ * Any non-public-static call may enqueue public state mutations
38
+ * (e.g. private calls can enqueue public calls), so all calls that follow
39
+ * must go through the normal simulation path to see the correct state.
40
+ *
41
+ */
42
+ export function extractOptimizablePublicStaticCalls(payload: ExecutionPayload): {
43
+ /** Leading public static calls eligible for direct node simulation. */
44
+ optimizableCalls: FunctionCall[];
45
+ /** All remaining calls. */
46
+ remainingCalls: FunctionCall[];
47
+ } {
48
+ const splitIndex = payload.calls.findIndex(call => !call.isPublicStatic());
49
+ const boundary = splitIndex === -1 ? payload.calls.length : splitIndex;
50
+ return {
51
+ optimizableCalls: payload.calls.slice(0, boundary),
52
+ remainingCalls: payload.calls.slice(boundary),
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Simulates a batch of public static calls by bypassing account entrypoint and private execution,
58
+ * directly constructing a minimal Tx and calling node.simulatePublicCalls.
59
+ *
60
+ * @param node - The Aztec node to simulate on.
61
+ * @param publicStaticCalls - Array of public static function calls (max MAX_ENQUEUED_CALLS_PER_CALL).
62
+ * @param from - The account address making the calls.
63
+ * @param chainInfo - Chain information (chainId and version).
64
+ * @param gasSettings - Gas settings for the transaction.
65
+ * @param blockHeader - Block header to use as anchor.
66
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
67
+ * @returns TxSimulationResult with public return values.
68
+ */
69
+ async function simulateBatchViaNode(
70
+ node: AztecNode,
71
+ publicStaticCalls: FunctionCall[],
72
+ from: AztecAddress,
73
+ chainInfo: ChainInfo,
74
+ gasSettings: GasSettings,
75
+ blockHeader: BlockHeader,
76
+ skipFeeEnforcement: boolean,
77
+ getContractName: ContractNameResolver,
78
+ ): Promise<TxSimulationResult> {
79
+ const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
80
+
81
+ const publicFunctionCalldata: HashedValues[] = [];
82
+ for (const call of publicStaticCalls) {
83
+ const calldata = await HashedValues.fromCalldata([call.selector.toField(), ...call.args]);
84
+ publicFunctionCalldata.push(calldata);
85
+ }
86
+
87
+ const publicCallRequests = makeTuple(MAX_ENQUEUED_CALLS_PER_CALL, i => {
88
+ const call = publicStaticCalls[i];
89
+ if (!call) {
90
+ return CountedPublicCallRequest.empty();
91
+ }
92
+ const publicCallRequest = new PublicCallRequest(from, call.to, call.isStatic, publicFunctionCalldata[i]!.hash);
93
+ // Counter starts at 1 (minRevertibleSideEffectCounter) so all calls are revertible
94
+ return new CountedPublicCallRequest(publicCallRequest, i + 1);
95
+ });
96
+
97
+ const publicCallRequestsArray: ClaimedLengthArray<CountedPublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_CALL> =
98
+ new ClaimedLengthArray(
99
+ publicCallRequests as Tuple<CountedPublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_CALL>,
100
+ publicStaticCalls.length,
101
+ );
102
+
103
+ const publicInputs = PrivateCircuitPublicInputs.from({
104
+ ...PrivateCircuitPublicInputs.empty(),
105
+ anchorBlockHeader: blockHeader,
106
+ txContext: txContext,
107
+ publicCallRequests: publicCallRequestsArray,
108
+ startSideEffectCounter: new Fr(0),
109
+ endSideEffectCounter: new Fr(publicStaticCalls.length + 1),
110
+ });
111
+
112
+ // Minimal entrypoint structure — no real private execution, just public call requests
113
+ const emptyEntrypoint = new PrivateCallExecutionResult(
114
+ Buffer.alloc(0),
115
+ Buffer.alloc(0),
116
+ new Map(),
117
+ publicInputs,
118
+ [],
119
+ new Map(),
120
+ [],
121
+ [],
122
+ [],
123
+ [],
124
+ [],
125
+ );
126
+
127
+ const privateResult = new PrivateExecutionResult(emptyEntrypoint, Fr.random(), publicFunctionCalldata);
128
+
129
+ const provingResult = await generateSimulatedProvingResult(
130
+ privateResult,
131
+ (_contractAddress: AztecAddress, _functionSelector: FunctionSelector) => Promise.resolve(''),
132
+ node,
133
+ 1, // minRevertibleSideEffectCounter
134
+ );
135
+
136
+ provingResult.publicInputs.feePayer = from;
137
+
138
+ const tx = await Tx.create({
139
+ data: provingResult.publicInputs,
140
+ chonkProof: ChonkProof.empty(),
141
+ contractClassLogFields: [],
142
+ publicFunctionCalldata: publicFunctionCalldata,
143
+ });
144
+
145
+ const publicOutput = await node.simulatePublicCalls(tx, skipFeeEnforcement);
146
+
147
+ if (publicOutput.revertReason) {
148
+ throw publicOutput.revertReason;
149
+ }
150
+
151
+ // Display debug logs from the public simulation.
152
+ await displayDebugLogs(publicOutput.debugLogs, getContractName);
153
+
154
+ return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
155
+ }
156
+
157
+ /**
158
+ * Simulates public static calls by splitting them into batches of MAX_ENQUEUED_CALLS_PER_CALL
159
+ * and sending each batch directly to the node.
160
+ *
161
+ * @param node - The Aztec node to simulate on.
162
+ * @param publicStaticCalls - Array of public static function calls to optimize.
163
+ * @param from - The account address making the calls.
164
+ * @param chainInfo - Chain information (chainId and version).
165
+ * @param gasSettings - Gas settings for the transaction.
166
+ * @param blockHeader - Block header to use as anchor.
167
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
168
+ * @returns Array of TxSimulationResult, one per batch.
169
+ */
170
+ export async function simulateViaNode(
171
+ node: AztecNode,
172
+ publicStaticCalls: FunctionCall[],
173
+ from: AztecAddress,
174
+ chainInfo: ChainInfo,
175
+ gasSettings: GasSettings,
176
+ blockHeader: BlockHeader,
177
+ skipFeeEnforcement: boolean = true,
178
+ getContractName: ContractNameResolver,
179
+ ): Promise<TxSimulationResult[]> {
180
+ const batches: FunctionCall[][] = [];
181
+
182
+ for (let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL) {
183
+ batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
184
+ }
185
+
186
+ const results: TxSimulationResult[] = [];
187
+
188
+ for (const batch of batches) {
189
+ const result = await simulateBatchViaNode(
190
+ node,
191
+ batch,
192
+ from,
193
+ chainInfo,
194
+ gasSettings,
195
+ blockHeader,
196
+ skipFeeEnforcement,
197
+ getContractName,
198
+ );
199
+ results.push(result);
200
+ }
201
+
202
+ return results;
203
+ }
204
+
205
+ /**
206
+ * Merges simulation results from the optimized (public static) and normal paths.
207
+ * Since optimized calls are always a leading prefix, return values are simply
208
+ * concatenated: optimized first, then normal.
209
+ * Stats are taken from the normal result only (the optimized path doesn't produce them).
210
+ *
211
+ * @param optimizedResults - Results from optimized public static call batches.
212
+ * @param normalResult - Result from normal simulation (null if all calls were optimized).
213
+ * @returns A single TxSimulationResult with return values in original call order.
214
+ */
215
+ export function buildMergedSimulationResult(
216
+ optimizedResults: TxSimulationResult[],
217
+ normalResult: TxSimulationResult | null,
218
+ ): TxSimulationResult {
219
+ const optimizedReturnValues = optimizedResults.flatMap(r => r.publicOutput?.publicReturnValues ?? []);
220
+ const normalReturnValues = normalResult?.publicOutput?.publicReturnValues ?? [];
221
+ const allReturnValues = [...optimizedReturnValues, ...normalReturnValues];
222
+
223
+ const baseResult = normalResult ?? optimizedResults[0];
224
+
225
+ const mergedPublicOutput: PublicSimulationOutput | undefined = baseResult.publicOutput
226
+ ? {
227
+ ...baseResult.publicOutput,
228
+ publicReturnValues: allReturnValues,
229
+ }
230
+ : undefined;
231
+
232
+ return new TxSimulationResult(
233
+ baseResult.privateExecutionResult,
234
+ baseResult.publicInputs,
235
+ mergedPublicOutput,
236
+ normalResult?.stats,
237
+ );
238
+ }