@aztec/wallet-sdk 4.1.0-rc.4 → 4.2.0-nightly.20260320
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/base-wallet/base_wallet.d.ts +25 -16
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +69 -45
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/base-wallet/base_wallet.ts +102 -65
- package/src/base-wallet/index.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
@@ -27,10 +27,17 @@ export type FeeOptions = {
|
|
|
27
27
|
*/
|
|
28
28
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
29
29
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
30
|
-
accountFeePaymentMethodOptions
|
|
30
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
31
31
|
/** The gas settings to use for the transaction */
|
|
32
32
|
gasSettings: GasSettings;
|
|
33
33
|
};
|
|
34
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
35
|
+
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
36
|
+
/** Fee options for the entrypoint */
|
|
37
|
+
feeOptions: FeeOptions;
|
|
38
|
+
/** Scopes to use for the simulation */
|
|
39
|
+
scopes: AccessScopes;
|
|
40
|
+
};
|
|
34
41
|
/**
|
|
35
42
|
* A base class for Wallet implementations
|
|
36
43
|
*/
|
|
@@ -41,8 +48,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
41
48
|
protected minFeePadding: number;
|
|
42
49
|
protected cancellableTransactions: boolean;
|
|
43
50
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
44
|
-
protected
|
|
45
|
-
protected scopesFrom(from: AztecAddress, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
51
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
46
52
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
47
53
|
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
48
54
|
/**
|
|
@@ -54,7 +60,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
54
60
|
*/
|
|
55
61
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
56
62
|
getChainInfo(): Promise<ChainInfo>;
|
|
57
|
-
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
63
|
+
protected createTxExecutionRequestFromPayloadAndFee(executionPayload: ExecutionPayload, from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<TxExecutionRequest>;
|
|
58
64
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
59
65
|
/**
|
|
60
66
|
* Request capabilities from the wallet.
|
|
@@ -78,7 +84,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
78
84
|
* @param gasSettings - User-provided partial gas settings
|
|
79
85
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
80
86
|
*/
|
|
81
|
-
protected completeFeeOptions(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
87
|
+
protected completeFeeOptions(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
82
88
|
/**
|
|
83
89
|
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
84
90
|
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
@@ -87,14 +93,14 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
87
93
|
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
88
94
|
* @param gasSettings - User-provided partial gas settings
|
|
89
95
|
*/
|
|
90
|
-
protected completeFeeOptionsForEstimation(from: AztecAddress, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
96
|
+
protected completeFeeOptionsForEstimation(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<{
|
|
91
97
|
/**
|
|
92
98
|
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
93
99
|
* doesn't already include one
|
|
94
100
|
*/
|
|
95
101
|
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
96
102
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
97
|
-
accountFeePaymentMethodOptions
|
|
103
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions | undefined;
|
|
98
104
|
gasSettings: GasSettings;
|
|
99
105
|
}>;
|
|
100
106
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
@@ -102,13 +108,9 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
102
108
|
/**
|
|
103
109
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
104
110
|
* @param executionPayload - The execution payload to simulate.
|
|
105
|
-
* @param
|
|
106
|
-
* @param feeOptions - Fee options for the transaction.
|
|
107
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
108
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
109
|
-
* @param scopes - The scopes to use for the simulation.
|
|
111
|
+
* @param opts - Simulation options.
|
|
110
112
|
*/
|
|
111
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
113
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
112
114
|
/**
|
|
113
115
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
114
116
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -128,9 +130,16 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
128
130
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
129
131
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
130
132
|
getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
135
|
+
*
|
|
136
|
+
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
137
|
+
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
138
|
+
* @param address - The contract address to query.
|
|
139
|
+
*/
|
|
131
140
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
132
141
|
instance: ContractInstanceWithAddress | undefined;
|
|
133
|
-
isContractInitialized: boolean;
|
|
142
|
+
isContractInitialized: boolean | undefined;
|
|
134
143
|
isContractPublished: boolean;
|
|
135
144
|
isContractUpdated: boolean;
|
|
136
145
|
updatedContractClassId: Fr | undefined;
|
|
@@ -140,4 +149,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
140
149
|
isContractClassPubliclyRegistered: boolean;
|
|
141
150
|
}>;
|
|
142
151
|
}
|
|
143
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
152
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC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LElBQUksRUFBRSxxQkFBcUIsR0FBRyxPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FFL0Y7SUFFSyxnQkFBZ0IsQ0FBQyxDQUFDLEVBQ3RCLFFBQVEsRUFBRSx1QkFBdUIsRUFDakMsV0FBVyxFQUFFLGtCQUFrQixHQUM5QixPQUFPLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FlNUI7SUFFRDs7Ozs7O09BTUc7SUFDRyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsWUFBWTs7Ozs7O09BMkI5QztJQUVLLHdCQUF3QixDQUFDLEVBQUUsRUFBRSxFQUFFOzs7T0FNcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,MAAM,EACN,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAElH,OAAO,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,CAkCxB;IAED;;;OAGG;IACH,UAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAOlF;IAED,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAYpE;IAED,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAE/F;IAEK,gBAAgB,CAAC,CAAC,EACtB,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAe5B;IAED;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OA2B9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
1
2
|
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
4
|
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
4
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
5
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
9
|
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
@@ -10,7 +12,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
11
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
14
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
-
import {
|
|
15
|
+
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
15
17
|
import { inspect } from 'util';
|
|
16
18
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -30,15 +32,8 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
30
32
|
this.minFeePadding = 0.5;
|
|
31
33
|
this.cancellableTransactions = false;
|
|
32
34
|
}
|
|
33
|
-
// When `from` is the zero address (e.g. when deploying a new account contract), we return an
|
|
34
|
-
// empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
|
|
35
|
-
scopesFor(from) {
|
|
36
|
-
return from.isZero() ? [] : [
|
|
37
|
-
from
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
35
|
scopesFrom(from, additionalScopes = []) {
|
|
41
|
-
const allScopes = from
|
|
36
|
+
const allScopes = from === NO_FROM ? additionalScopes : [
|
|
42
37
|
from,
|
|
43
38
|
...additionalScopes
|
|
44
39
|
];
|
|
@@ -69,18 +64,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
69
64
|
}
|
|
70
65
|
async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
|
|
71
66
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
72
|
-
const executionOptions = {
|
|
73
|
-
txNonce: Fr.random(),
|
|
74
|
-
cancellable: this.cancellableTransactions,
|
|
75
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
76
|
-
};
|
|
77
67
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
78
68
|
feeExecutionPayload,
|
|
79
69
|
executionPayload
|
|
80
70
|
]) : executionPayload;
|
|
81
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
82
71
|
const chainInfo = await this.getChainInfo();
|
|
83
|
-
|
|
72
|
+
if (from === NO_FROM) {
|
|
73
|
+
const entrypoint = new DefaultEntrypoint();
|
|
74
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
75
|
+
} else {
|
|
76
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
77
|
+
const executionOptions = {
|
|
78
|
+
txNonce: Fr.random(),
|
|
79
|
+
cancellable: this.cancellableTransactions,
|
|
80
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
81
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
82
|
+
};
|
|
83
|
+
return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
84
|
+
}
|
|
84
85
|
}
|
|
85
86
|
async createAuthWit(from, messageHashOrIntent) {
|
|
86
87
|
const account = await this.getAccountFromAddress(from);
|
|
@@ -130,14 +131,18 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
130
131
|
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
131
132
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
132
133
|
let accountFeePaymentMethodOptions;
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
135
|
+
// account contract entrypoint to use
|
|
136
|
+
if (from !== NO_FROM) {
|
|
137
|
+
if (!feePayer) {
|
|
138
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
139
|
+
// for the account to use its fee juice balance
|
|
140
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
141
|
+
} else {
|
|
142
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
143
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
144
|
+
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
145
|
+
}
|
|
141
146
|
}
|
|
142
147
|
const fullGasSettings = GasSettings.default({
|
|
143
148
|
...gasSettings,
|
|
@@ -206,18 +211,14 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
206
211
|
/**
|
|
207
212
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
208
213
|
* @param executionPayload - The execution payload to simulate.
|
|
209
|
-
* @param
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
213
|
-
* @param scopes - The scopes to use for the simulation.
|
|
214
|
-
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
|
|
215
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
|
|
214
|
+
* @param opts - Simulation options.
|
|
215
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
216
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
216
217
|
return this.pxe.simulateTx(txRequest, {
|
|
217
218
|
simulatePublic: true,
|
|
218
|
-
skipTxValidation,
|
|
219
|
-
skipFeeEnforcement,
|
|
220
|
-
scopes
|
|
219
|
+
skipTxValidation: opts.skipTxValidation,
|
|
220
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
221
|
+
scopes: opts.scopes
|
|
221
222
|
});
|
|
222
223
|
}
|
|
223
224
|
/**
|
|
@@ -243,9 +244,16 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
243
244
|
} catch {
|
|
244
245
|
blockHeader = await this.aztecNode.getBlockHeader();
|
|
245
246
|
}
|
|
247
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
246
248
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
247
|
-
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls,
|
|
248
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
249
|
+
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
250
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
251
|
+
from: opts.from,
|
|
252
|
+
feeOptions,
|
|
253
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
254
|
+
skipTxValidation: opts.skipTxValidation,
|
|
255
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
256
|
+
}) : Promise.resolve(null)
|
|
249
257
|
]);
|
|
250
258
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
251
259
|
}
|
|
@@ -262,7 +270,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
262
270
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
263
271
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
264
272
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
265
|
-
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects());
|
|
273
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
266
274
|
const tx = await provenTx.toTx();
|
|
267
275
|
const txHash = tx.getTxHash();
|
|
268
276
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -319,9 +327,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
319
327
|
executeUtility(call, opts) {
|
|
320
328
|
return this.pxe.executeUtility(call, {
|
|
321
329
|
authwits: opts.authWitnesses,
|
|
322
|
-
scopes:
|
|
323
|
-
opts.scope
|
|
324
|
-
]
|
|
330
|
+
scopes: opts.scopes
|
|
325
331
|
});
|
|
326
332
|
}
|
|
327
333
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
@@ -340,15 +346,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
340
346
|
});
|
|
341
347
|
return decodedEvents;
|
|
342
348
|
}
|
|
343
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
351
|
+
*
|
|
352
|
+
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
353
|
+
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
354
|
+
* @param address - The contract address to query.
|
|
355
|
+
*/ async getContractMetadata(address) {
|
|
344
356
|
const instance = await this.pxe.getContractInstance(address);
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
357
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
358
|
+
// We check only the private initialization nullifier. It is emitted by both private and public initializers and
|
|
359
|
+
// includes init_hash, preventing observers from determining initialization status from the address alone. Without
|
|
360
|
+
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
361
|
+
//
|
|
362
|
+
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
363
|
+
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
364
|
+
// created in the same tx and will also be present.
|
|
365
|
+
let isContractInitialized = undefined;
|
|
366
|
+
if (instance) {
|
|
367
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
368
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
369
|
+
isContractInitialized = !!witness;
|
|
370
|
+
}
|
|
371
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
348
372
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
349
373
|
return {
|
|
350
374
|
instance: instance ?? undefined,
|
|
351
|
-
isContractInitialized
|
|
375
|
+
isContractInitialized,
|
|
352
376
|
isContractPublished: !!publiclyRegisteredContract,
|
|
353
377
|
isContractUpdated: !!isContractUpdated,
|
|
354
378
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type FeeOptions, type SimulateViaEntrypointOptions } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLEtBQUssNEJBQTRCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNsRyxPQUFPLEVBQUUsZUFBZSxFQUFFLDJCQUEyQixFQUFFLG1DQUFtQyxFQUFFLE1BQU0sWUFBWSxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
|
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": "4.
|
|
4
|
+
"version": "4.2.0-nightly.20260320",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./base-wallet": "./dest/base-wallet/index.js",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/aztec.js": "4.
|
|
75
|
-
"@aztec/constants": "4.
|
|
76
|
-
"@aztec/entrypoints": "4.
|
|
77
|
-
"@aztec/foundation": "4.
|
|
78
|
-
"@aztec/pxe": "4.
|
|
79
|
-
"@aztec/stdlib": "4.
|
|
74
|
+
"@aztec/aztec.js": "4.2.0-nightly.20260320",
|
|
75
|
+
"@aztec/constants": "4.2.0-nightly.20260320",
|
|
76
|
+
"@aztec/entrypoints": "4.2.0-nightly.20260320",
|
|
77
|
+
"@aztec/foundation": "4.2.0-nightly.20260320",
|
|
78
|
+
"@aztec/pxe": "4.2.0-nightly.20260320",
|
|
79
|
+
"@aztec/stdlib": "4.2.0-nightly.20260320"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@aztec/noir-contracts.js": "4.
|
|
82
|
+
"@aztec/noir-contracts.js": "4.2.0-nightly.20260320",
|
|
83
83
|
"@jest/globals": "^30.0.0",
|
|
84
84
|
"@types/jest": "^30.0.0",
|
|
85
85
|
"@types/node": "^22.15.17",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Account } from '@aztec/aztec.js/account';
|
|
1
|
+
import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
4
|
import {
|
|
4
5
|
type InteractionWaitOptions,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
30
31
|
} from '@aztec/constants';
|
|
31
32
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
33
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
32
34
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
33
35
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
34
36
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -50,7 +52,7 @@ import {
|
|
|
50
52
|
} from '@aztec/stdlib/contract';
|
|
51
53
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
52
54
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
53
|
-
import {
|
|
55
|
+
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
54
56
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
55
57
|
import {
|
|
56
58
|
BlockHeader,
|
|
@@ -75,11 +77,21 @@ export type FeeOptions = {
|
|
|
75
77
|
*/
|
|
76
78
|
walletFeePaymentMethod?: FeePaymentMethod;
|
|
77
79
|
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
78
|
-
accountFeePaymentMethodOptions
|
|
80
|
+
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions;
|
|
79
81
|
/** The gas settings to use for the transaction */
|
|
80
82
|
gasSettings: GasSettings;
|
|
81
83
|
};
|
|
82
84
|
|
|
85
|
+
/** Options for `simulateViaEntrypoint`. */
|
|
86
|
+
export type SimulateViaEntrypointOptions = Pick<
|
|
87
|
+
SimulateOptions,
|
|
88
|
+
'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'
|
|
89
|
+
> & {
|
|
90
|
+
/** Fee options for the entrypoint */
|
|
91
|
+
feeOptions: FeeOptions;
|
|
92
|
+
/** Scopes to use for the simulation */
|
|
93
|
+
scopes: AccessScopes;
|
|
94
|
+
};
|
|
83
95
|
/**
|
|
84
96
|
* A base class for Wallet implementations
|
|
85
97
|
*/
|
|
@@ -94,14 +106,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
94
106
|
protected log = createLogger('wallet-sdk:base_wallet'),
|
|
95
107
|
) {}
|
|
96
108
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
protected scopesFor(from: AztecAddress): AztecAddress[] {
|
|
100
|
-
return from.isZero() ? [] : [from];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
protected scopesFrom(from: AztecAddress, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
104
|
-
const allScopes = from.isZero() ? additionalScopes : [from, ...additionalScopes];
|
|
109
|
+
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes: AztecAddress[] = []): AztecAddress[] {
|
|
110
|
+
const allScopes = from === NO_FROM ? additionalScopes : [from, ...additionalScopes];
|
|
105
111
|
const scopeSet = new Set(allScopes.map(address => address.toString()));
|
|
106
112
|
return [...scopeSet].map(AztecAddress.fromString);
|
|
107
113
|
}
|
|
@@ -129,26 +135,33 @@ export abstract class BaseWallet implements Wallet {
|
|
|
129
135
|
|
|
130
136
|
protected async createTxExecutionRequestFromPayloadAndFee(
|
|
131
137
|
executionPayload: ExecutionPayload,
|
|
132
|
-
from: AztecAddress,
|
|
138
|
+
from: AztecAddress | NoFrom,
|
|
133
139
|
feeOptions: FeeOptions,
|
|
134
140
|
): Promise<TxExecutionRequest> {
|
|
135
141
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
136
|
-
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
137
|
-
txNonce: Fr.random(),
|
|
138
|
-
cancellable: this.cancellableTransactions,
|
|
139
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
|
|
140
|
-
};
|
|
141
142
|
const finalExecutionPayload = feeExecutionPayload
|
|
142
143
|
? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
|
|
143
144
|
: executionPayload;
|
|
144
|
-
const fromAccount = await this.getAccountFromAddress(from);
|
|
145
145
|
const chainInfo = await this.getChainInfo();
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
chainInfo
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
|
|
147
|
+
if (from === NO_FROM) {
|
|
148
|
+
const entrypoint = new DefaultEntrypoint();
|
|
149
|
+
return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
150
|
+
} else {
|
|
151
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
152
|
+
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
153
|
+
txNonce: Fr.random(),
|
|
154
|
+
cancellable: this.cancellableTransactions,
|
|
155
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
156
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
|
|
157
|
+
};
|
|
158
|
+
return fromAccount.createTxExecutionRequest(
|
|
159
|
+
finalExecutionPayload,
|
|
160
|
+
feeOptions.gasSettings,
|
|
161
|
+
chainInfo,
|
|
162
|
+
executionOptions,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
152
165
|
}
|
|
153
166
|
|
|
154
167
|
public async createAuthWit(
|
|
@@ -203,23 +216,27 @@ export abstract class BaseWallet implements Wallet {
|
|
|
203
216
|
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
204
217
|
*/
|
|
205
218
|
protected async completeFeeOptions(
|
|
206
|
-
from: AztecAddress,
|
|
219
|
+
from: AztecAddress | NoFrom,
|
|
207
220
|
feePayer?: AztecAddress,
|
|
208
221
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
209
222
|
): Promise<FeeOptions> {
|
|
210
223
|
const maxFeesPerGas =
|
|
211
224
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
212
225
|
let accountFeePaymentMethodOptions;
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
227
|
+
// account contract entrypoint to use
|
|
228
|
+
if (from !== NO_FROM) {
|
|
229
|
+
if (!feePayer) {
|
|
230
|
+
// The transaction does not include a fee payment method, so we set the flag
|
|
231
|
+
// for the account to use its fee juice balance
|
|
232
|
+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
|
|
233
|
+
} else {
|
|
234
|
+
// The transaction includes fee payment method, so we check if we are the fee payer for it
|
|
235
|
+
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
|
|
236
|
+
accountFeePaymentMethodOptions = from.equals(feePayer)
|
|
237
|
+
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
|
|
238
|
+
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
239
|
+
}
|
|
223
240
|
}
|
|
224
241
|
const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
|
|
225
242
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
@@ -239,7 +256,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
239
256
|
* @param gasSettings - User-provided partial gas settings
|
|
240
257
|
*/
|
|
241
258
|
protected async completeFeeOptionsForEstimation(
|
|
242
|
-
from: AztecAddress,
|
|
259
|
+
from: AztecAddress | NoFrom,
|
|
243
260
|
feePayer?: AztecAddress,
|
|
244
261
|
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
245
262
|
) {
|
|
@@ -306,22 +323,20 @@ export abstract class BaseWallet implements Wallet {
|
|
|
306
323
|
/**
|
|
307
324
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
308
325
|
* @param executionPayload - The execution payload to simulate.
|
|
309
|
-
* @param
|
|
310
|
-
* @param feeOptions - Fee options for the transaction.
|
|
311
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
312
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
313
|
-
* @param scopes - The scopes to use for the simulation.
|
|
326
|
+
* @param opts - Simulation options.
|
|
314
327
|
*/
|
|
315
|
-
protected async simulateViaEntrypoint(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
328
|
+
protected async simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions) {
|
|
329
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(
|
|
330
|
+
executionPayload,
|
|
331
|
+
opts.from,
|
|
332
|
+
opts.feeOptions,
|
|
333
|
+
);
|
|
334
|
+
return this.pxe.simulateTx(txRequest, {
|
|
335
|
+
simulatePublic: true,
|
|
336
|
+
skipTxValidation: opts.skipTxValidation,
|
|
337
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
338
|
+
scopes: opts.scopes,
|
|
339
|
+
});
|
|
325
340
|
}
|
|
326
341
|
|
|
327
342
|
/**
|
|
@@ -349,12 +364,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
349
364
|
blockHeader = (await this.aztecNode.getBlockHeader())!;
|
|
350
365
|
}
|
|
351
366
|
|
|
367
|
+
const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
|
|
352
368
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
353
369
|
optimizableCalls.length > 0
|
|
354
370
|
? simulateViaNode(
|
|
355
371
|
this.aztecNode,
|
|
356
372
|
optimizableCalls,
|
|
357
|
-
|
|
373
|
+
simulationOrigin,
|
|
358
374
|
chainInfo,
|
|
359
375
|
feeOptions.gasSettings,
|
|
360
376
|
blockHeader,
|
|
@@ -363,14 +379,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
363
379
|
)
|
|
364
380
|
: Promise.resolve([]),
|
|
365
381
|
remainingCalls.length > 0
|
|
366
|
-
? this.simulateViaEntrypoint(
|
|
367
|
-
|
|
368
|
-
opts.from,
|
|
382
|
+
? this.simulateViaEntrypoint(remainingPayload, {
|
|
383
|
+
from: opts.from,
|
|
369
384
|
feeOptions,
|
|
370
|
-
this.scopesFrom(opts.from, opts.additionalScopes),
|
|
371
|
-
opts.skipTxValidation,
|
|
372
|
-
opts.skipFeeEnforcement ?? true,
|
|
373
|
-
)
|
|
385
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
386
|
+
skipTxValidation: opts.skipTxValidation,
|
|
387
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
388
|
+
})
|
|
374
389
|
: Promise.resolve(null),
|
|
375
390
|
]);
|
|
376
391
|
|
|
@@ -394,7 +409,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
394
409
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
395
410
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
396
411
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
397
|
-
const offchainOutput = extractOffchainOutput(
|
|
412
|
+
const offchainOutput = extractOffchainOutput(
|
|
413
|
+
provenTx.getOffchainEffects(),
|
|
414
|
+
provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp,
|
|
415
|
+
);
|
|
398
416
|
const tx = await provenTx.toTx();
|
|
399
417
|
const txHash = tx.getTxHash();
|
|
400
418
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -451,7 +469,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
451
469
|
}
|
|
452
470
|
|
|
453
471
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
454
|
-
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes:
|
|
472
|
+
return this.pxe.executeUtility(call, { authwits: opts.authWitnesses, scopes: opts.scopes });
|
|
455
473
|
}
|
|
456
474
|
|
|
457
475
|
async getPrivateEvents<T>(
|
|
@@ -474,17 +492,36 @@ export abstract class BaseWallet implements Wallet {
|
|
|
474
492
|
return decodedEvents;
|
|
475
493
|
}
|
|
476
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
497
|
+
*
|
|
498
|
+
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
499
|
+
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
500
|
+
* @param address - The contract address to query.
|
|
501
|
+
*/
|
|
477
502
|
async getContractMetadata(address: AztecAddress) {
|
|
478
503
|
const instance = await this.pxe.getContractInstance(address);
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
504
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
505
|
+
// We check only the private initialization nullifier. It is emitted by both private and public initializers and
|
|
506
|
+
// includes init_hash, preventing observers from determining initialization status from the address alone. Without
|
|
507
|
+
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
508
|
+
//
|
|
509
|
+
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
510
|
+
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
511
|
+
// created in the same tx and will also be present.
|
|
512
|
+
let isContractInitialized: boolean | undefined = undefined;
|
|
513
|
+
if (instance) {
|
|
514
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
515
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
516
|
+
isContractInitialized = !!witness;
|
|
517
|
+
}
|
|
518
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
482
519
|
const isContractUpdated =
|
|
483
520
|
publiclyRegisteredContract &&
|
|
484
521
|
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
485
522
|
return {
|
|
486
523
|
instance: instance ?? undefined,
|
|
487
|
-
isContractInitialized
|
|
524
|
+
isContractInitialized,
|
|
488
525
|
isContractPublished: !!publiclyRegisteredContract,
|
|
489
526
|
isContractUpdated: !!isContractUpdated,
|
|
490
527
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
|
package/src/base-wallet/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type FeeOptions, type SimulateViaEntrypointOptions } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|