@aztec/wallet-sdk 0.0.1-commit.c949de6bc → 0.0.1-commit.cbf2c2d5d
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 +18 -8
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +47 -20
- 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 +65 -30
- package/src/base-wallet/index.ts +1 -1
|
@@ -31,6 +31,13 @@ export type FeeOptions = {
|
|
|
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
|
*/
|
|
@@ -101,13 +108,9 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
101
108
|
/**
|
|
102
109
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
103
110
|
* @param executionPayload - The execution payload to simulate.
|
|
104
|
-
* @param
|
|
105
|
-
* @param feeOptions - Fee options for the transaction.
|
|
106
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
107
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
108
|
-
* @param scopes - The scopes to use for the simulation.
|
|
111
|
+
* @param opts - Simulation options.
|
|
109
112
|
*/
|
|
110
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
113
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
111
114
|
/**
|
|
112
115
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
113
116
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -127,9 +130,16 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
127
130
|
protected contextualizeError(err: Error, ...context: string[]): Error;
|
|
128
131
|
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
129
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
|
+
*/
|
|
130
140
|
getContractMetadata(address: AztecAddress): Promise<{
|
|
131
141
|
instance: ContractInstanceWithAddress | undefined;
|
|
132
|
-
isContractInitialized: boolean;
|
|
142
|
+
isContractInitialized: boolean | undefined;
|
|
133
143
|
isContractPublished: boolean;
|
|
134
144
|
isContractUpdated: boolean;
|
|
135
145
|
updatedContractClassId: Fr | undefined;
|
|
@@ -139,4 +149,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
139
149
|
isContractClassPubliclyRegistered: boolean;
|
|
140
150
|
}>;
|
|
141
151
|
}
|
|
142
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
152
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJd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Q0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQWU1QjtJQUVEOzs7Ozs7T0FNRztJQUNHLG1CQUFtQixDQUFDLE9BQU8sRUFBRSxZQUFZOzs7Ozs7T0EyQjlDO0lBRUssd0JBQXdCLENBQUMsRUFBRSxFQUFFLEVBQUU7OztPQU1wQztDQUNGIn0=
|
|
@@ -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;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,
|
|
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;AACvD,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;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM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AE,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,4 +1,4 @@
|
|
|
1
|
-
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
1
|
+
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
3
|
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
4
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
@@ -10,7 +10,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
10
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
11
11
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
12
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
13
|
-
import {
|
|
13
|
+
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
14
14
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
15
15
|
import { inspect } from 'util';
|
|
16
16
|
import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
|
|
@@ -199,18 +199,14 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
199
199
|
/**
|
|
200
200
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
201
201
|
* @param executionPayload - The execution payload to simulate.
|
|
202
|
-
* @param
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
206
|
-
* @param scopes - The scopes to use for the simulation.
|
|
207
|
-
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
|
|
208
|
-
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
|
|
202
|
+
* @param opts - Simulation options.
|
|
203
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
204
|
+
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
209
205
|
return this.pxe.simulateTx(txRequest, {
|
|
210
206
|
simulatePublic: true,
|
|
211
|
-
skipTxValidation,
|
|
212
|
-
skipFeeEnforcement,
|
|
213
|
-
scopes
|
|
207
|
+
skipTxValidation: opts.skipTxValidation,
|
|
208
|
+
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
209
|
+
scopes: opts.scopes
|
|
214
210
|
});
|
|
215
211
|
}
|
|
216
212
|
/**
|
|
@@ -238,7 +234,13 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
238
234
|
}
|
|
239
235
|
const [optimizedResults, normalResult] = await Promise.all([
|
|
240
236
|
optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, opts.from, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
|
|
241
|
-
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload,
|
|
237
|
+
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
238
|
+
from: opts.from,
|
|
239
|
+
feeOptions,
|
|
240
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
241
|
+
skipTxValidation: opts.skipTxValidation,
|
|
242
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
243
|
+
}) : Promise.resolve(null)
|
|
242
244
|
]);
|
|
243
245
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
244
246
|
}
|
|
@@ -255,6 +257,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
255
257
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
256
258
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
257
259
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
260
|
+
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
258
261
|
const tx = await provenTx.toTx();
|
|
259
262
|
const txHash = tx.getTxHash();
|
|
260
263
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -267,7 +270,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
267
270
|
this.log.info(`Sent transaction ${txHash}`);
|
|
268
271
|
// If wait is NO_WAIT, return txHash immediately
|
|
269
272
|
if (opts.wait === NO_WAIT) {
|
|
270
|
-
return
|
|
273
|
+
return {
|
|
274
|
+
txHash,
|
|
275
|
+
...offchainOutput
|
|
276
|
+
};
|
|
271
277
|
}
|
|
272
278
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
273
279
|
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
@@ -276,7 +282,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
276
282
|
if (receipt.debugLogs?.length) {
|
|
277
283
|
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
278
284
|
}
|
|
279
|
-
return
|
|
285
|
+
return {
|
|
286
|
+
receipt,
|
|
287
|
+
...offchainOutput
|
|
288
|
+
};
|
|
280
289
|
}
|
|
281
290
|
/**
|
|
282
291
|
* Resolves a contract address to a human-readable name via PXE, if available.
|
|
@@ -326,15 +335,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
326
335
|
});
|
|
327
336
|
return decodedEvents;
|
|
328
337
|
}
|
|
329
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Returns metadata about a contract, including whether it has been initialized, published, and updated.
|
|
340
|
+
*
|
|
341
|
+
* `isContractInitialized` requires the contract instance to be registered in the PXE (for `init_hash`). When the
|
|
342
|
+
* instance is not available, `isContractInitialized` is `undefined` since it cannot be determined.
|
|
343
|
+
* @param address - The contract address to query.
|
|
344
|
+
*/ async getContractMetadata(address) {
|
|
330
345
|
const instance = await this.pxe.getContractInstance(address);
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
346
|
+
const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
|
|
347
|
+
// We check only the private initialization nullifier. It is emitted by both private and public initializers and
|
|
348
|
+
// includes init_hash, preventing observers from determining initialization status from the address alone. Without
|
|
349
|
+
// the instance (and thus init_hash), we can't compute it, so we return undefined.
|
|
350
|
+
//
|
|
351
|
+
// We skip the public initialization nullifier because it's not always emitted (contracts without public external
|
|
352
|
+
// functions that require initialization checks won't emit it). If the private one exists, the public one was
|
|
353
|
+
// created in the same tx and will also be present.
|
|
354
|
+
let isContractInitialized = undefined;
|
|
355
|
+
if (instance) {
|
|
356
|
+
const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
|
|
357
|
+
const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
358
|
+
isContractInitialized = !!witness;
|
|
359
|
+
}
|
|
360
|
+
const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
|
|
334
361
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
335
362
|
return {
|
|
336
363
|
instance: instance ?? undefined,
|
|
337
|
-
isContractInitialized
|
|
364
|
+
isContractInitialized,
|
|
338
365
|
isContractPublished: !!publiclyRegisteredContract,
|
|
339
366
|
isContractUpdated: !!isContractUpdated,
|
|
340
367
|
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": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.cbf2c2d5d",
|
|
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": "0.0.1-commit.
|
|
75
|
-
"@aztec/constants": "0.0.1-commit.
|
|
76
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
77
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
78
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
74
|
+
"@aztec/aztec.js": "0.0.1-commit.cbf2c2d5d",
|
|
75
|
+
"@aztec/constants": "0.0.1-commit.cbf2c2d5d",
|
|
76
|
+
"@aztec/entrypoints": "0.0.1-commit.cbf2c2d5d",
|
|
77
|
+
"@aztec/foundation": "0.0.1-commit.cbf2c2d5d",
|
|
78
|
+
"@aztec/pxe": "0.0.1-commit.cbf2c2d5d",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.cbf2c2d5d"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
82
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.cbf2c2d5d",
|
|
83
83
|
"@jest/globals": "^30.0.0",
|
|
84
84
|
"@types/jest": "^30.0.0",
|
|
85
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 {
|
|
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 {
|
|
@@ -45,7 +50,7 @@ import {
|
|
|
45
50
|
} from '@aztec/stdlib/contract';
|
|
46
51
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
47
52
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
48
|
-
import {
|
|
53
|
+
import { computeSiloedPrivateInitializationNullifier } from '@aztec/stdlib/hash';
|
|
49
54
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
50
55
|
import {
|
|
51
56
|
BlockHeader,
|
|
@@ -75,6 +80,16 @@ export type FeeOptions = {
|
|
|
75
80
|
gasSettings: GasSettings;
|
|
76
81
|
};
|
|
77
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
|
+
};
|
|
78
93
|
/**
|
|
79
94
|
* A base class for Wallet implementations
|
|
80
95
|
*/
|
|
@@ -295,22 +310,20 @@ export abstract class BaseWallet implements Wallet {
|
|
|
295
310
|
/**
|
|
296
311
|
* Simulates calls through the standard PXE path (account entrypoint).
|
|
297
312
|
* @param executionPayload - The execution payload to simulate.
|
|
298
|
-
* @param
|
|
299
|
-
* @param feeOptions - Fee options for the transaction.
|
|
300
|
-
* @param skipTxValidation - Whether to skip tx validation.
|
|
301
|
-
* @param skipFeeEnforcement - Whether to skip fee enforcement.
|
|
302
|
-
* @param scopes - The scopes to use for the simulation.
|
|
313
|
+
* @param opts - Simulation options.
|
|
303
314
|
*/
|
|
304
|
-
protected async simulateViaEntrypoint(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
+
});
|
|
314
327
|
}
|
|
315
328
|
|
|
316
329
|
/**
|
|
@@ -352,14 +365,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
352
365
|
)
|
|
353
366
|
: Promise.resolve([]),
|
|
354
367
|
remainingCalls.length > 0
|
|
355
|
-
? this.simulateViaEntrypoint(
|
|
356
|
-
|
|
357
|
-
opts.from,
|
|
368
|
+
? this.simulateViaEntrypoint(remainingPayload, {
|
|
369
|
+
from: opts.from,
|
|
358
370
|
feeOptions,
|
|
359
|
-
this.scopesFrom(opts.from, opts.additionalScopes),
|
|
360
|
-
opts.skipTxValidation,
|
|
361
|
-
opts.skipFeeEnforcement ?? true,
|
|
362
|
-
)
|
|
371
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
372
|
+
skipTxValidation: opts.skipTxValidation,
|
|
373
|
+
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
374
|
+
})
|
|
363
375
|
: Promise.resolve(null),
|
|
364
376
|
]);
|
|
365
377
|
|
|
@@ -383,6 +395,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
383
395
|
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
384
396
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
385
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
|
+
);
|
|
386
402
|
const tx = await provenTx.toTx();
|
|
387
403
|
const txHash = tx.getTxHash();
|
|
388
404
|
if (await this.aztecNode.getTxEffect(txHash)) {
|
|
@@ -396,7 +412,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
396
412
|
|
|
397
413
|
// If wait is NO_WAIT, return txHash immediately
|
|
398
414
|
if (opts.wait === NO_WAIT) {
|
|
399
|
-
return txHash as SendReturn<W>;
|
|
415
|
+
return { txHash, ...offchainOutput } as SendReturn<W>;
|
|
400
416
|
}
|
|
401
417
|
|
|
402
418
|
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
@@ -408,7 +424,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
408
424
|
await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
|
|
409
425
|
}
|
|
410
426
|
|
|
411
|
-
return receipt as SendReturn<W>;
|
|
427
|
+
return { receipt, ...offchainOutput } as SendReturn<W>;
|
|
412
428
|
}
|
|
413
429
|
|
|
414
430
|
/**
|
|
@@ -462,17 +478,36 @@ export abstract class BaseWallet implements Wallet {
|
|
|
462
478
|
return decodedEvents;
|
|
463
479
|
}
|
|
464
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
|
+
*/
|
|
465
488
|
async getContractMetadata(address: AztecAddress) {
|
|
466
489
|
const instance = await this.pxe.getContractInstance(address);
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
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;
|
|
470
505
|
const isContractUpdated =
|
|
471
506
|
publiclyRegisteredContract &&
|
|
472
507
|
!publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
473
508
|
return {
|
|
474
509
|
instance: instance ?? undefined,
|
|
475
|
-
isContractInitialized
|
|
510
|
+
isContractInitialized,
|
|
476
511
|
isContractPublished: !!publiclyRegisteredContract,
|
|
477
512
|
isContractUpdated: !!isContractUpdated,
|
|
478
513
|
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';
|