@aztec/wallet-sdk 0.0.1-commit.023c3e5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +321 -0
  2. package/dest/base-wallet/base_wallet.d.ts +117 -0
  3. package/dest/base-wallet/base_wallet.d.ts.map +1 -0
  4. package/dest/base-wallet/base_wallet.js +271 -0
  5. package/dest/base-wallet/index.d.ts +2 -0
  6. package/dest/base-wallet/index.d.ts.map +1 -0
  7. package/dest/base-wallet/index.js +1 -0
  8. package/dest/crypto.d.ts +192 -0
  9. package/dest/crypto.d.ts.map +1 -0
  10. package/dest/crypto.js +394 -0
  11. package/dest/emoji_alphabet.d.ts +35 -0
  12. package/dest/emoji_alphabet.d.ts.map +1 -0
  13. package/dest/emoji_alphabet.js +299 -0
  14. package/dest/extension/handlers/background_connection_handler.d.ts +158 -0
  15. package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -0
  16. package/dest/extension/handlers/background_connection_handler.js +258 -0
  17. package/dest/extension/handlers/content_script_connection_handler.d.ts +56 -0
  18. package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -0
  19. package/dest/extension/handlers/content_script_connection_handler.js +174 -0
  20. package/dest/extension/handlers/index.d.ts +12 -0
  21. package/dest/extension/handlers/index.d.ts.map +1 -0
  22. package/dest/extension/handlers/index.js +10 -0
  23. package/dest/extension/handlers/internal_message_types.d.ts +63 -0
  24. package/dest/extension/handlers/internal_message_types.d.ts.map +1 -0
  25. package/dest/extension/handlers/internal_message_types.js +22 -0
  26. package/dest/extension/provider/extension_provider.d.ts +107 -0
  27. package/dest/extension/provider/extension_provider.d.ts.map +1 -0
  28. package/dest/extension/provider/extension_provider.js +160 -0
  29. package/dest/extension/provider/extension_wallet.d.ts +131 -0
  30. package/dest/extension/provider/extension_wallet.d.ts.map +1 -0
  31. package/dest/extension/provider/extension_wallet.js +271 -0
  32. package/dest/extension/provider/index.d.ts +3 -0
  33. package/dest/extension/provider/index.d.ts.map +1 -0
  34. package/dest/extension/provider/index.js +2 -0
  35. package/dest/manager/index.d.ts +3 -0
  36. package/dest/manager/index.d.ts.map +1 -0
  37. package/dest/manager/index.js +1 -0
  38. package/dest/manager/types.d.ts +167 -0
  39. package/dest/manager/types.d.ts.map +1 -0
  40. package/dest/manager/types.js +19 -0
  41. package/dest/manager/wallet_manager.d.ts +70 -0
  42. package/dest/manager/wallet_manager.d.ts.map +1 -0
  43. package/dest/manager/wallet_manager.js +226 -0
  44. package/dest/types.d.ts +123 -0
  45. package/dest/types.d.ts.map +1 -0
  46. package/dest/types.js +11 -0
  47. package/package.json +99 -0
  48. package/src/base-wallet/base_wallet.ts +394 -0
  49. package/src/base-wallet/index.ts +1 -0
  50. package/src/crypto.ts +499 -0
  51. package/src/emoji_alphabet.ts +317 -0
  52. package/src/extension/handlers/background_connection_handler.ts +423 -0
  53. package/src/extension/handlers/content_script_connection_handler.ts +246 -0
  54. package/src/extension/handlers/index.ts +25 -0
  55. package/src/extension/handlers/internal_message_types.ts +69 -0
  56. package/src/extension/provider/extension_provider.ts +233 -0
  57. package/src/extension/provider/extension_wallet.ts +321 -0
  58. package/src/extension/provider/index.ts +7 -0
  59. package/src/manager/index.ts +12 -0
  60. package/src/manager/types.ts +177 -0
  61. package/src/manager/wallet_manager.ts +259 -0
  62. package/src/types.ts +132 -0
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@aztec/wallet-sdk",
3
+ "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
4
+ "version": "0.0.1-commit.023c3e5",
5
+ "type": "module",
6
+ "exports": {
7
+ "./base-wallet": "./dest/base-wallet/index.js",
8
+ "./extension/handlers": "./dest/extension/handlers/index.js",
9
+ "./extension/provider": "./dest/extension/provider/index.js",
10
+ "./crypto": "./dest/crypto.js",
11
+ "./types": "./dest/types.js",
12
+ "./manager": "./dest/manager/index.js"
13
+ },
14
+ "typedocOptions": {
15
+ "entryPoints": [
16
+ "./src/index.ts"
17
+ ],
18
+ "tsconfig": "./tsconfig.json"
19
+ },
20
+ "scripts": {
21
+ "build": "yarn clean && ../scripts/tsc.sh",
22
+ "build:dev": "../scripts/tsc.sh --watch",
23
+ "build:ts": "tsc -b",
24
+ "clean": "rm -rf ./dest .tsbuildinfo",
25
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
26
+ },
27
+ "inherits": [
28
+ "../package.common.json"
29
+ ],
30
+ "jest": {
31
+ "moduleNameMapper": {
32
+ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
33
+ },
34
+ "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
35
+ "rootDir": "./src",
36
+ "transform": {
37
+ "^.+\\.tsx?$": [
38
+ "@swc/jest",
39
+ {
40
+ "jsc": {
41
+ "parser": {
42
+ "syntax": "typescript",
43
+ "decorators": true
44
+ },
45
+ "transform": {
46
+ "decoratorVersion": "2022-03"
47
+ }
48
+ }
49
+ }
50
+ ]
51
+ },
52
+ "extensionsToTreatAsEsm": [
53
+ ".ts"
54
+ ],
55
+ "reporters": [
56
+ "default"
57
+ ],
58
+ "testTimeout": 120000,
59
+ "setupFiles": [
60
+ "../../foundation/src/jest/setup.mjs"
61
+ ],
62
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
63
+ "setupFilesAfterEnv": [
64
+ "../../foundation/src/jest/setupAfterEnv.mjs"
65
+ ]
66
+ },
67
+ "dependencies": {
68
+ "@aztec/aztec.js": "0.0.1-commit.023c3e5",
69
+ "@aztec/constants": "0.0.1-commit.023c3e5",
70
+ "@aztec/entrypoints": "0.0.1-commit.023c3e5",
71
+ "@aztec/foundation": "0.0.1-commit.023c3e5",
72
+ "@aztec/pxe": "0.0.1-commit.023c3e5",
73
+ "@aztec/stdlib": "0.0.1-commit.023c3e5"
74
+ },
75
+ "devDependencies": {
76
+ "@aztec/noir-contracts.js": "0.0.1-commit.023c3e5",
77
+ "@jest/globals": "^30.0.0",
78
+ "@types/jest": "^30.0.0",
79
+ "@types/node": "^22.15.17",
80
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
81
+ "jest": "^30.0.0",
82
+ "jest-mock-extended": "^4.0.0",
83
+ "resolve-typescript-plugin": "^2.0.1",
84
+ "ts-loader": "^9.5.4",
85
+ "ts-node": "^10.9.1",
86
+ "typescript": "^5.3.3",
87
+ "util": "^0.12.5"
88
+ },
89
+ "files": [
90
+ "dest",
91
+ "src",
92
+ "!*.test.*",
93
+ "artifacts"
94
+ ],
95
+ "types": "./dest/index.d.ts",
96
+ "engines": {
97
+ "node": ">=20.10"
98
+ }
99
+ }
@@ -0,0 +1,394 @@
1
+ import type { Account } from '@aztec/aztec.js/account';
2
+ import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
3
+ import { type InteractionWaitOptions, NO_WAIT, type SendReturn } from '@aztec/aztec.js/contracts';
4
+ import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
5
+ import { waitForTx } from '@aztec/aztec.js/node';
6
+ import type {
7
+ Aliased,
8
+ AppCapabilities,
9
+ BatchResults,
10
+ BatchedMethod,
11
+ PrivateEvent,
12
+ PrivateEventFilter,
13
+ ProfileOptions,
14
+ SendOptions,
15
+ SimulateOptions,
16
+ Wallet,
17
+ WalletCapabilities,
18
+ } from '@aztec/aztec.js/wallet';
19
+ import {
20
+ GAS_ESTIMATION_DA_GAS_LIMIT,
21
+ GAS_ESTIMATION_L2_GAS_LIMIT,
22
+ GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT,
23
+ GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
24
+ } from '@aztec/constants';
25
+ import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
26
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
27
+ import { Fr } from '@aztec/foundation/curves/bn254';
28
+ import { createLogger } from '@aztec/foundation/log';
29
+ import type { FieldsOf } from '@aztec/foundation/types';
30
+ import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
31
+ import {
32
+ type ContractArtifact,
33
+ type EventMetadataDefinition,
34
+ type FunctionCall,
35
+ decodeFromAbi,
36
+ } from '@aztec/stdlib/abi';
37
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
38
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
39
+ import {
40
+ type ContractInstanceWithAddress,
41
+ computePartialAddress,
42
+ getContractClassFromArtifact,
43
+ } from '@aztec/stdlib/contract';
44
+ import { SimulationError } from '@aztec/stdlib/errors';
45
+ import { Gas, GasSettings } from '@aztec/stdlib/gas';
46
+ import { siloNullifier } from '@aztec/stdlib/hash';
47
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
48
+ import type {
49
+ TxExecutionRequest,
50
+ TxProfileResult,
51
+ TxSimulationResult,
52
+ UtilitySimulationResult,
53
+ } from '@aztec/stdlib/tx';
54
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
55
+
56
+ import { inspect } from 'util';
57
+
58
+ /**
59
+ * Options to configure fee payment for a transaction
60
+ */
61
+ export type FeeOptions = {
62
+ /**
63
+ * A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
64
+ * doesn't already include one
65
+ */
66
+ walletFeePaymentMethod?: FeePaymentMethod;
67
+ /** Configuration options for the account to properly handle the selected fee payment method */
68
+ accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
69
+ /** The gas settings to use for the transaction */
70
+ gasSettings: GasSettings;
71
+ };
72
+
73
+ /**
74
+ * A base class for Wallet implementations
75
+ */
76
+ export abstract class BaseWallet implements Wallet {
77
+ protected log = createLogger('wallet-sdk:base_wallet');
78
+
79
+ protected minFeePadding = 0.5;
80
+ protected cancellableTransactions = false;
81
+
82
+ // Protected because we want to force wallets to instantiate their own PXE.
83
+ protected constructor(
84
+ protected readonly pxe: PXE,
85
+ protected readonly aztecNode: AztecNode,
86
+ ) {}
87
+
88
+ protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
89
+
90
+ abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
91
+
92
+ /**
93
+ * Returns the list of aliased contacts associated with the wallet.
94
+ * This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
95
+ * - Senders: Addresses we check during synching in case they sent us notes,
96
+ * - Contacts: more general concept akin to a phone's contact list.
97
+ * @returns The aliased collection of AztecAddresses that form this wallet's address book
98
+ */
99
+ async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
100
+ const senders: AztecAddress[] = await this.pxe.getSenders();
101
+ return senders.map(sender => ({ item: sender, alias: '' }));
102
+ }
103
+
104
+ async getChainInfo(): Promise<ChainInfo> {
105
+ const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
106
+ return { chainId: new Fr(l1ChainId), version: new Fr(rollupVersion) };
107
+ }
108
+
109
+ protected async createTxExecutionRequestFromPayloadAndFee(
110
+ executionPayload: ExecutionPayload,
111
+ from: AztecAddress,
112
+ feeOptions: FeeOptions,
113
+ ): Promise<TxExecutionRequest> {
114
+ const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
115
+ const executionOptions: DefaultAccountEntrypointOptions = {
116
+ txNonce: Fr.random(),
117
+ cancellable: this.cancellableTransactions,
118
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
119
+ };
120
+ const finalExecutionPayload = feeExecutionPayload
121
+ ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
122
+ : executionPayload;
123
+ const fromAccount = await this.getAccountFromAddress(from);
124
+ const chainInfo = await this.getChainInfo();
125
+ return fromAccount.createTxExecutionRequest(
126
+ finalExecutionPayload,
127
+ feeOptions.gasSettings,
128
+ chainInfo,
129
+ executionOptions,
130
+ );
131
+ }
132
+
133
+ public async createAuthWit(
134
+ from: AztecAddress,
135
+ messageHashOrIntent: IntentInnerHash | CallIntent,
136
+ ): Promise<AuthWitness> {
137
+ const account = await this.getAccountFromAddress(from);
138
+ const chainInfo = await this.getChainInfo();
139
+ return account.createAuthWit(messageHashOrIntent, chainInfo);
140
+ }
141
+
142
+ /**
143
+ * Request capabilities from the wallet.
144
+ *
145
+ * This method is wallet-implementation-dependent and must be provided by classes extending BaseWallet.
146
+ * Embedded wallets typically don't support capability-based authorization (no user authorization flow),
147
+ * while external wallets (browser extensions, hardware wallets) implement this to reduce authorization
148
+ * friction by allowing apps to request permissions upfront.
149
+ *
150
+ * TODO: Consider making it abstract so implementing it is a conscious decision. Leaving it as-is
151
+ * while the feature stabilizes.
152
+ *
153
+ * @param _manifest - Application capability manifest declaring what operations the app needs
154
+ */
155
+ public requestCapabilities(_manifest: AppCapabilities): Promise<WalletCapabilities> {
156
+ throw new Error('Not implemented');
157
+ }
158
+
159
+ public async batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>> {
160
+ const results: any[] = [];
161
+ for (const method of methods) {
162
+ const { name, args } = method;
163
+ // Type safety is guaranteed by the BatchedMethod type, which ensures that:
164
+ // 1. `name` is a valid batchable method name
165
+ // 2. `args` matches the parameter types of that specific method
166
+ // 3. The return type is correctly mapped in BatchResults<T>
167
+ // We use dynamic dispatch here for simplicity, but the types are enforced at the call site.
168
+
169
+ const fn = this[name] as (...args: any[]) => Promise<any>;
170
+ const result = await fn.apply(this, args);
171
+ // Wrap result with method name for discriminated union deserialization
172
+ results.push({ name, result });
173
+ }
174
+ return results as BatchResults<T>;
175
+ }
176
+
177
+ /**
178
+ * Completes partial user-provided fee options with wallet defaults.
179
+ * @param from - The address where the transaction is being sent from
180
+ * @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
181
+ * @param gasSettings - User-provided partial gas settings
182
+ * @returns - Complete fee options that can be used to create a transaction execution request
183
+ */
184
+ protected async completeFeeOptions(
185
+ from: AztecAddress,
186
+ feePayer?: AztecAddress,
187
+ gasSettings?: Partial<FieldsOf<GasSettings>>,
188
+ ): Promise<FeeOptions> {
189
+ const maxFeesPerGas =
190
+ gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
191
+ let accountFeePaymentMethodOptions;
192
+ // The transaction does not include a fee payment method, so we set the flag
193
+ // for the account to use its fee juice balance
194
+ if (!feePayer) {
195
+ accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
196
+ } else {
197
+ // The transaction includes fee payment method, so we check if we are the fee payer for it
198
+ // (this can only happen if the embedded payment method is FeeJuiceWithClaim)
199
+ accountFeePaymentMethodOptions = from.equals(feePayer)
200
+ ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
201
+ : AccountFeePaymentMethodOptions.EXTERNAL;
202
+ }
203
+ const fullGasSettings: GasSettings = GasSettings.default({ ...gasSettings, maxFeesPerGas });
204
+ this.log.debug(`Using L2 gas settings`, fullGasSettings);
205
+ return {
206
+ gasSettings: fullGasSettings,
207
+ walletFeePaymentMethod: undefined,
208
+ accountFeePaymentMethodOptions,
209
+ };
210
+ }
211
+
212
+ /**
213
+ * Completes partial user-provided fee options with unreasonably high gas limits
214
+ * for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
215
+ * to avoid running out of gas during estimation.
216
+ * @param from - The address where the transaction is being sent from
217
+ * @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
218
+ * @param gasSettings - User-provided partial gas settings
219
+ */
220
+ protected async completeFeeOptionsForEstimation(
221
+ from: AztecAddress,
222
+ feePayer?: AztecAddress,
223
+ gasSettings?: Partial<FieldsOf<GasSettings>>,
224
+ ) {
225
+ const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
226
+ const {
227
+ gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas },
228
+ } = defaultFeeOptions;
229
+ // Use unrealistically high gas limits for estimation to avoid running out of gas.
230
+ // They will be tuned down after the simulation.
231
+ const gasSettingsForEstimation = new GasSettings(
232
+ new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT),
233
+ new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT),
234
+ maxFeesPerGas,
235
+ maxPriorityFeesPerGas,
236
+ );
237
+ return {
238
+ ...defaultFeeOptions,
239
+ gasSettings: gasSettingsForEstimation,
240
+ };
241
+ }
242
+
243
+ registerSender(address: AztecAddress, _alias: string = ''): Promise<AztecAddress> {
244
+ return this.pxe.registerSender(address);
245
+ }
246
+
247
+ async registerContract(
248
+ instance: ContractInstanceWithAddress,
249
+ artifact?: ContractArtifact,
250
+ secretKey?: Fr,
251
+ ): Promise<ContractInstanceWithAddress> {
252
+ const existingInstance = await this.pxe.getContractInstance(instance.address);
253
+
254
+ if (existingInstance) {
255
+ // Instance already registered in the wallet
256
+ if (artifact) {
257
+ const thisContractClass = await getContractClassFromArtifact(artifact);
258
+ if (!thisContractClass.id.equals(existingInstance.currentContractClassId)) {
259
+ // wallet holds an outdated version of this contract
260
+ await this.pxe.updateContract(instance.address, artifact);
261
+ instance.currentContractClassId = thisContractClass.id;
262
+ }
263
+ }
264
+ // If no artifact provided, we just use the existing registration
265
+ } else {
266
+ // Instance not registered yet
267
+ if (!artifact) {
268
+ // Try to get the artifact from the wallet's contract class storage
269
+ artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
270
+ if (!artifact) {
271
+ throw new Error(
272
+ `Cannot register contract at ${instance.address.toString()}: artifact is required but not provided, and wallet does not have the artifact for contract class ${instance.currentContractClassId.toString()}`,
273
+ );
274
+ }
275
+ }
276
+ await this.pxe.registerContract({ artifact, instance });
277
+ }
278
+
279
+ if (secretKey) {
280
+ await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
281
+ }
282
+ return instance;
283
+ }
284
+
285
+ async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
286
+ const feeOptions = opts.fee?.estimateGas
287
+ ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
288
+ : 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
+ );
296
+ }
297
+
298
+ async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
299
+ const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
300
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
301
+ return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
302
+ }
303
+
304
+ public async sendTx<W extends InteractionWaitOptions = undefined>(
305
+ executionPayload: ExecutionPayload,
306
+ opts: SendOptions<W>,
307
+ ): Promise<SendReturn<W>> {
308
+ const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
309
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
310
+ const provenTx = await this.pxe.proveTx(txRequest);
311
+ const tx = await provenTx.toTx();
312
+ const txHash = tx.getTxHash();
313
+ if (await this.aztecNode.getTxEffect(txHash)) {
314
+ throw new Error(`A settled tx with equal hash ${txHash.toString()} exists.`);
315
+ }
316
+ this.log.debug(`Sending transaction ${txHash}`);
317
+ await this.aztecNode.sendTx(tx).catch(err => {
318
+ throw this.contextualizeError(err, inspect(tx));
319
+ });
320
+ this.log.info(`Sent transaction ${txHash}`);
321
+
322
+ // If wait is NO_WAIT, return txHash immediately
323
+ if (opts.wait === NO_WAIT) {
324
+ return txHash as SendReturn<W>;
325
+ }
326
+
327
+ // Otherwise, wait for the full receipt (default behavior on wait: undefined)
328
+ const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
329
+ return (await waitForTx(this.aztecNode, txHash, waitOpts)) as SendReturn<W>;
330
+ }
331
+
332
+ protected contextualizeError(err: Error, ...context: string[]): Error {
333
+ let contextStr = '';
334
+ if (context.length > 0) {
335
+ contextStr = `\nContext:\n${context.join('\n')}`;
336
+ }
337
+ if (err instanceof SimulationError) {
338
+ err.setAztecContext(contextStr);
339
+ } else {
340
+ this.log.error(err.name, err);
341
+ this.log.debug(contextStr);
342
+ }
343
+ return err;
344
+ }
345
+
346
+ simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult> {
347
+ return this.pxe.simulateUtility(call, authwits);
348
+ }
349
+
350
+ async getPrivateEvents<T>(
351
+ eventDef: EventMetadataDefinition,
352
+ eventFilter: PrivateEventFilter,
353
+ ): Promise<PrivateEvent<T>[]> {
354
+ const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
355
+
356
+ const decodedEvents = pxeEvents.map((pxeEvent: PackedPrivateEvent): PrivateEvent<T> => {
357
+ return {
358
+ event: decodeFromAbi([eventDef.abiType], pxeEvent.packedEvent) as T,
359
+ metadata: {
360
+ l2BlockNumber: pxeEvent.l2BlockNumber,
361
+ l2BlockHash: pxeEvent.l2BlockHash,
362
+ txHash: pxeEvent.txHash,
363
+ },
364
+ };
365
+ });
366
+
367
+ return decodedEvents;
368
+ }
369
+
370
+ async getContractMetadata(address: AztecAddress) {
371
+ 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);
375
+ const isContractUpdated =
376
+ publiclyRegisteredContract &&
377
+ !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
378
+ return {
379
+ instance: instance ?? undefined,
380
+ isContractInitialized: !!initNullifierMembershipWitness,
381
+ isContractPublished: !!publiclyRegisteredContract,
382
+ isContractUpdated: !!isContractUpdated,
383
+ updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined,
384
+ };
385
+ }
386
+
387
+ async getContractClassMetadata(id: Fr) {
388
+ const publiclyRegisteredContractClass = await this.aztecNode.getContractClass(id);
389
+ return {
390
+ isArtifactRegistered: !!(await this.pxe.getContractArtifact(id)),
391
+ isContractClassPubliclyRegistered: !!publiclyRegisteredContractClass,
392
+ };
393
+ }
394
+ }
@@ -0,0 +1 @@
1
+ export { BaseWallet, type FeeOptions } from './base_wallet.js';