@walletmesh/aztec-rpc-wallet 0.4.1 → 0.5.4

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 (94) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/client/aztec-dapp-wallet.d.ts +6 -6
  4. package/dist/client/aztec-dapp-wallet.d.ts.map +1 -1
  5. package/dist/client/aztec-dapp-wallet.js +7 -7
  6. package/dist/client/aztec-router-provider.d.ts +1 -1
  7. package/dist/client/aztec-router-provider.d.ts.map +1 -1
  8. package/dist/client/aztec-router-provider.js +1 -1
  9. package/dist/client/helpers.d.ts.map +1 -1
  10. package/dist/client/helpers.js +2 -2
  11. package/dist/client/register-serializers.js +1 -1
  12. package/dist/index.d.ts +18 -18
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +8 -8
  15. package/dist/types.d.ts +11 -9
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/types.js +1 -1
  18. package/dist/wallet/create-node.d.ts +1 -1
  19. package/dist/wallet/create-node.d.ts.map +1 -1
  20. package/dist/wallet/create-node.js +1 -1
  21. package/dist/wallet/handlers/account.d.ts +1 -1
  22. package/dist/wallet/handlers/account.d.ts.map +1 -1
  23. package/dist/wallet/handlers/account.js +1 -1
  24. package/dist/wallet/handlers/contract-interaction.d.ts +1 -1
  25. package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -1
  26. package/dist/wallet/handlers/contract-interaction.js +6 -5
  27. package/dist/wallet/handlers/contract.d.ts.map +1 -1
  28. package/dist/wallet/handlers/contract.js +1 -1
  29. package/dist/wallet/handlers/event.d.ts +1 -1
  30. package/dist/wallet/handlers/event.d.ts.map +1 -1
  31. package/dist/wallet/handlers/event.js +1 -1
  32. package/dist/wallet/handlers/index.d.ts.map +1 -1
  33. package/dist/wallet/handlers/index.js +2 -2
  34. package/dist/wallet/handlers/node.d.ts +1 -1
  35. package/dist/wallet/handlers/node.d.ts.map +1 -1
  36. package/dist/wallet/handlers/node.js +1 -1
  37. package/dist/wallet/handlers/senders.d.ts +1 -1
  38. package/dist/wallet/handlers/senders.d.ts.map +1 -1
  39. package/dist/wallet/handlers/senders.js +1 -1
  40. package/dist/wallet/handlers/transaction.d.ts +5 -4
  41. package/dist/wallet/handlers/transaction.d.ts.map +1 -1
  42. package/dist/wallet/handlers/transaction.js +9 -6
  43. package/dist/wallet/serializers.d.ts +1 -1
  44. package/dist/wallet/serializers.d.ts.map +1 -1
  45. package/dist/wallet/serializers.js +26 -23
  46. package/docs/README.md +1 -1
  47. package/docs/classes/AztecDappWallet.md +47 -47
  48. package/docs/classes/AztecRouterProvider.md +4 -4
  49. package/docs/classes/AztecWalletError.md +34 -10
  50. package/docs/classes/ContractArtifactCache.md +4 -4
  51. package/docs/functions/connectAztec.md +2 -2
  52. package/docs/functions/createAztecWallet.md +2 -2
  53. package/docs/functions/createAztecWalletNode.md +2 -2
  54. package/docs/functions/registerAztecSerializers.md +2 -2
  55. package/docs/functions/registerWalletAztecSerializers.md +2 -2
  56. package/docs/globals.md +2 -2
  57. package/docs/interfaces/AztecHandlerContext.md +5 -5
  58. package/docs/interfaces/AztecWalletContext.md +5 -5
  59. package/docs/interfaces/AztecWalletMethodMap.md +41 -37
  60. package/docs/type-aliases/AztecChainId.md +2 -2
  61. package/docs/variables/ALL_AZTEC_METHODS.md +2 -2
  62. package/docs/variables/AztecWalletErrorMap.md +2 -2
  63. package/docs/variables/AztecWalletSerializer.md +2 -2
  64. package/package.json +11 -11
  65. package/src/client/aztec-dapp-wallet.test.ts +7 -7
  66. package/src/client/aztec-dapp-wallet.ts +15 -14
  67. package/src/client/aztec-router-provider.test.ts +2 -2
  68. package/src/client/aztec-router-provider.ts +1 -1
  69. package/src/client/helpers.test.ts +3 -3
  70. package/src/client/helpers.ts +1 -2
  71. package/src/client/register-serializers.ts +1 -1
  72. package/src/contractArtifactCache.test.ts +1 -1
  73. package/src/index.test.ts +1 -1
  74. package/src/index.ts +21 -28
  75. package/src/types.ts +20 -20
  76. package/src/wallet/create-node.test.ts +3 -3
  77. package/src/wallet/create-node.ts +3 -4
  78. package/src/wallet/handlers/account.test.ts +6 -6
  79. package/src/wallet/handlers/account.ts +2 -2
  80. package/src/wallet/handlers/contract-interaction.test.ts +6 -7
  81. package/src/wallet/handlers/contract-interaction.ts +9 -8
  82. package/src/wallet/handlers/contract.test.ts +5 -5
  83. package/src/wallet/handlers/contract.ts +1 -1
  84. package/src/wallet/handlers/event.test.ts +4 -4
  85. package/src/wallet/handlers/event.ts +2 -2
  86. package/src/wallet/handlers/index.ts +1 -1
  87. package/src/wallet/handlers/node.test.ts +5 -6
  88. package/src/wallet/handlers/node.ts +2 -2
  89. package/src/wallet/handlers/senders.test.ts +4 -4
  90. package/src/wallet/handlers/senders.ts +2 -2
  91. package/src/wallet/handlers/transaction.test.ts +19 -13
  92. package/src/wallet/handlers/transaction.ts +10 -7
  93. package/src/wallet/serializers.test.ts +15 -62
  94. package/src/wallet/serializers.ts +44 -40
@@ -1,19 +1,27 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { createTransactionHandlers } from './transaction.js';
3
- import type { AccountWallet, PXE, AztecAddress, TxHash, AuthWitness } from '@aztec/aztec.js';
4
- import type { TxExecutionRequest, Tx, TxReceipt } from '@aztec/aztec.js';
5
- // import type { FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces'; // Unused
6
- // import type { ExecutionPayload } from '@aztec/entrypoints/payload'; // Unused
7
- import type { AztecHandlerContext } from './index.js';
8
- import type { ContractArtifactCache } from '../../contractArtifactCache.js';
1
+ import type {
2
+ AccountWallet,
3
+ AuthWitness,
4
+ AztecAddress,
5
+ PXE,
6
+ Tx,
7
+ TxExecutionRequest,
8
+ TxHash,
9
+ TxReceipt,
10
+ } from '@aztec/aztec.js';
9
11
  import { Fr } from '@aztec/aztec.js';
10
12
  import type {
11
13
  PrivateExecutionResult,
14
+ TxProfileResult,
12
15
  TxProvingResult,
13
16
  TxSimulationResult,
14
- TxProfileResult,
15
17
  UtilitySimulationResult,
16
18
  } from '@aztec/stdlib/tx';
19
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
20
+ import type { ContractArtifactCache } from '../../contractArtifactCache.js';
21
+ // import type { FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces'; // Unused
22
+ // import type { ExecutionPayload } from '@aztec/entrypoints/payload'; // Unused
23
+ import type { AztecHandlerContext } from './index.js';
24
+ import { createTransactionHandlers } from './transaction.js';
17
25
 
18
26
  // Mock dependencies
19
27
  const createMockWallet = () =>
@@ -175,7 +183,6 @@ describe('Transaction Handlers', () => {
175
183
  txRequest: { exec: { calls: [] } },
176
184
  } as unknown as TxExecutionRequest;
177
185
  const simulatePublic = true;
178
- const msgSender = '0x1234567890abcdef' as unknown as AztecAddress;
179
186
  const skipTxValidation = true;
180
187
  const skipFeeEnforcement = true;
181
188
 
@@ -190,7 +197,6 @@ describe('Transaction Handlers', () => {
190
197
  const result = await handlers.aztec_simulateTx(context, [
191
198
  txRequest,
192
199
  simulatePublic,
193
- msgSender,
194
200
  skipTxValidation,
195
201
  skipFeeEnforcement,
196
202
  ]);
@@ -198,9 +204,9 @@ describe('Transaction Handlers', () => {
198
204
  expect(mockWallet.simulateTx).toHaveBeenCalledWith(
199
205
  txRequest,
200
206
  simulatePublic,
201
- msgSender,
202
207
  skipTxValidation,
203
208
  skipFeeEnforcement,
209
+ undefined
204
210
  );
205
211
  expect(result).toBe(expectedSimulation);
206
212
  });
@@ -226,7 +232,7 @@ describe('Transaction Handlers', () => {
226
232
  undefined,
227
233
  ]);
228
234
 
229
- expect(mockWallet.simulateTx).toHaveBeenCalledWith(txRequest, false, undefined, undefined, false);
235
+ expect(mockWallet.simulateTx).toHaveBeenCalledWith(txRequest, false, undefined, false, undefined);
230
236
  expect(result).toBe(expectedSimulation);
231
237
  });
232
238
 
@@ -1,6 +1,6 @@
1
- import type { AztecHandlerContext } from './index.js';
2
- import type { AztecWalletMethodMap } from '../../types.js';
3
1
  import { createLogger } from '@aztec/foundation/log';
2
+ import type { AztecWalletMethodMap } from '../../types.js';
3
+ import type { AztecHandlerContext } from './index.js';
4
4
 
5
5
  const logger = createLogger('aztec-rpc-wallet:transaction');
6
6
 
@@ -139,9 +139,10 @@ export function createTransactionHandlers() {
139
139
  * Defined by {@link AztecWalletMethodMap.aztec_simulateTx.params}.
140
140
  * @param paramsTuple.0 - The {@link TxExecutionRequest} to simulate.
141
141
  * @param paramsTuple.1 - Optional: Boolean indicating whether to simulate public parts of the transaction. Defaults to `false`.
142
- * @param paramsTuple.2 - Optional: The {@link AztecAddress} of the message sender for simulation context.
143
- * @param paramsTuple.3 - Optional: Boolean flag to skip transaction validation during simulation.
144
- * @param paramsTuple.4 - Optional: Boolean flag to skip fee enforcement during simulation.
142
+ * @param paramsTuple.2 - Optional: Boolean flag to skip transaction validation during simulation.
143
+ * @param paramsTuple.3 - Optional: Boolean flag to skip fee enforcement during simulation.
144
+ * @param paramsTuple.4 - Optional: {@link SimulationOverrides} for simulation context (includes msgSender).
145
+ * @param paramsTuple.5 - Optional: Array of {@link AztecAddress} scopes for the simulation.
145
146
  * @returns A promise that resolves to the {@link TxSimulationResult}.
146
147
  * Type defined by {@link AztecWalletMethodMap.aztec_simulateTx.result}.
147
148
  * @throws {Error} If the `txRequest` parameter is missing or invalid.
@@ -153,9 +154,9 @@ export function createTransactionHandlers() {
153
154
  const [
154
155
  txRequest,
155
156
  simulatePublicInput, // simulatePublic is optional in PXE interface
156
- msgSender,
157
157
  skipTxValidation,
158
158
  skipFeeEnforcementInput, // skipFeeEnforcement is optional in PXE interface
159
+ overrides, // SimulationOverrides which may contain msgSender
159
160
  ] = paramsTuple;
160
161
  // Handle optional params with defaults if necessary, matching PXE behavior
161
162
  const simulatePublic = simulatePublicInput === undefined ? false : simulatePublicInput;
@@ -166,12 +167,14 @@ export function createTransactionHandlers() {
166
167
  // txRequest is mandatory
167
168
  throw new Error('Invalid txRequest parameter received in tuple');
168
169
  }
170
+
171
+ // Call with the parameters that the underlying wallet expects
169
172
  return await ctx.wallet.simulateTx(
170
173
  txRequest,
171
174
  simulatePublic,
172
- msgSender,
173
175
  skipTxValidation,
174
176
  skipFeeEnforcement,
177
+ overrides,
175
178
  );
176
179
  },
177
180
 
@@ -1,12 +1,11 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { AztecAddress, Fr, AuthWitness } from '@aztec/aztec.js';
3
1
  import type { ContractArtifact } from '@aztec/aztec.js';
4
- import { FunctionSelector } from '@aztec/stdlib/abi';
5
- import { FunctionType } from '@aztec/stdlib/abi';
6
- import { Capsule, HashedValues } from '@aztec/stdlib/tx';
2
+ import { AuthWitness, AztecAddress, Fr } from '@aztec/aztec.js';
7
3
  import { ExecutionPayload } from '@aztec/entrypoints/payload';
4
+ import { emptyFunctionArtifact, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
+ import { randomContractArtifact } from '@aztec/stdlib/testing';
6
+ import { Capsule, HashedValues } from '@aztec/stdlib/tx';
7
+ import { describe, expect, it } from 'vitest';
8
8
  import { AztecWalletSerializer } from './serializers.js';
9
- import { FunctionCall } from '@aztec/stdlib/abi';
10
9
 
11
10
  describe('ExecutionPayload Serialization', () => {
12
11
  it('should serialize and deserialize ExecutionPayload correctly', async () => {
@@ -97,40 +96,15 @@ describe('ExecutionPayload Serialization', () => {
97
96
  describe('DeployContract Serialization', () => {
98
97
  it('should serialize and deserialize aztec_wmDeployContract params correctly', async () => {
99
98
  // Create a minimal valid ContractArtifact
100
- const artifact: ContractArtifact = {
101
- name: 'TestContract',
102
- functions: [
103
- {
104
- name: 'constructor',
105
- functionType: FunctionType.PRIVATE,
106
- isInternal: false,
107
- isStatic: false,
108
- isInitializer: true,
109
- parameters: [
110
- {
111
- name: 'owner',
112
- type: { kind: 'field' },
113
- visibility: 'private',
114
- },
115
- ],
116
- returnTypes: [],
117
- errorTypes: {},
118
- bytecode: Buffer.from('test'),
119
- debugSymbols: '',
120
- },
121
- ],
122
- nonDispatchPublicFunctions: [],
123
- outputs: {
124
- structs: {},
125
- globals: {},
126
- },
127
- storageLayout: {},
128
- notes: {},
129
- fileMap: {},
130
- };
99
+ const artifact: ContractArtifact = await randomContractArtifact();
131
100
 
132
101
  const args = [AztecAddress.random().toString(), '12345'];
133
102
  const constructorName = 'constructor';
103
+ const functionArtifact = emptyFunctionArtifact();
104
+ functionArtifact.name = constructorName;
105
+ functionArtifact.functionType = FunctionType.PUBLIC;
106
+ functionArtifact.isInitializer = true;
107
+ artifact.functions.push(functionArtifact);
134
108
 
135
109
  // Test params serialization
136
110
  const params = { artifact, args, constructorName };
@@ -153,9 +127,10 @@ describe('DeployContract Serialization', () => {
153
127
  constructorName?: string;
154
128
  };
155
129
 
130
+
156
131
  // Verify the artifact structure
157
132
  expect(result.artifact).toBeDefined();
158
- expect(result.artifact.name).toBe('TestContract');
133
+ expect(result.artifact.name).toBe(artifact.name);
159
134
  expect(result.artifact.functions).toHaveLength(1);
160
135
  expect(result.artifact.functions[0]?.name).toBe('constructor');
161
136
  expect(result.artifact.functions[0]?.isInitializer).toBe(true);
@@ -168,18 +143,7 @@ describe('DeployContract Serialization', () => {
168
143
  });
169
144
 
170
145
  it('should handle aztec_wmDeployContract without constructorName', async () => {
171
- const artifact: ContractArtifact = {
172
- name: 'TestContract',
173
- functions: [],
174
- nonDispatchPublicFunctions: [],
175
- outputs: {
176
- structs: {},
177
- globals: {},
178
- },
179
- storageLayout: {},
180
- notes: {},
181
- fileMap: {},
182
- };
146
+ const artifact: ContractArtifact = await randomContractArtifact();
183
147
 
184
148
  const args: unknown[] = [];
185
149
 
@@ -220,18 +184,7 @@ describe('DeployContract Serialization', () => {
220
184
  });
221
185
 
222
186
  it('should validate args array in aztec_wmDeployContract', async () => {
223
- const artifact: ContractArtifact = {
224
- name: 'TestContract',
225
- functions: [],
226
- nonDispatchPublicFunctions: [],
227
- outputs: {
228
- structs: {},
229
- globals: {},
230
- },
231
- storageLayout: {},
232
- notes: {},
233
- fileMap: {},
234
- };
187
+ const artifact: ContractArtifact = await randomContractArtifact();
235
188
 
236
189
  // Test with various types in args array
237
190
  const args = ['string value', 123, true, { nested: 'object' }, ['array', 'of', 'values'], null];
@@ -19,33 +19,23 @@
19
19
  * to reconstruct complex Aztec objects from their JSON representations.
20
20
  */
21
21
 
22
- import type { AztecWalletMethodMap } from '../types.js';
23
-
24
- import type {
25
- JSONRPCNode,
26
- JSONRPCSerializer,
27
- JSONRPCSerializedData,
28
- JSONRPCParams,
29
- } from '@walletmesh/jsonrpc';
30
- import { JSONRPCError } from '@walletmesh/jsonrpc';
31
-
22
+ import type { NodeInfo } from '@aztec/aztec.js';
32
23
  import {
24
+ AuthWitness,
33
25
  AztecAddress,
34
26
  CompleteAddress,
35
- TxExecutionRequest,
36
27
  Fr,
37
28
  Tx,
29
+ TxExecutionRequest,
38
30
  TxHash,
39
- AuthWitness,
40
31
  } from '@aztec/aztec.js';
41
- import type { NodeInfo } from '@aztec/aztec.js';
42
-
43
32
  import type { IntentAction, IntentInnerHash } from '@aztec/aztec.js/utils';
33
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
34
+ import { createLogger } from '@aztec/foundation/log';
35
+ import type { ZodFor } from '@aztec/foundation/schemas';
44
36
 
45
37
  import { AbiTypeSchema, ContractArtifactSchema, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
46
- import { schemas } from '@aztec/stdlib/schemas';
47
-
48
- import type { PXEInfo, ContractMetadata, ContractClassMetadata } from '@aztec/stdlib/interfaces/client';
38
+ import { L2Block } from '@aztec/stdlib/block';
49
39
  import {
50
40
  ContractClassWithIdSchema,
51
41
  ContractInstanceWithAddressSchema,
@@ -53,7 +43,8 @@ import {
53
43
  ProtocolContractAddressesSchema,
54
44
  } from '@aztec/stdlib/contract';
55
45
  import { GasFees } from '@aztec/stdlib/gas';
56
- import { L2Block } from '@aztec/stdlib/block';
46
+ import type { ContractClassMetadata, ContractMetadata, PXEInfo } from '@aztec/stdlib/interfaces/client';
47
+ import { schemas } from '@aztec/stdlib/schemas';
57
48
  import {
58
49
  Capsule,
59
50
  HashedValues,
@@ -64,18 +55,21 @@ import {
64
55
  TxSimulationResult,
65
56
  UtilitySimulationResult,
66
57
  } from '@aztec/stdlib/tx';
67
-
68
- import { jsonStringify, jsonParseWithSchema } from '@aztec/foundation/json-rpc';
69
- import { createLogger } from '@aztec/foundation/log';
70
- import type { ZodFor } from '@aztec/foundation/schemas';
71
-
72
- import { z, type ZodTypeAny } from 'zod';
58
+ import type {
59
+ JSONRPCNode,
60
+ JSONRPCParams,
61
+ JSONRPCSerializedData,
62
+ JSONRPCSerializer,
63
+ } from '@walletmesh/jsonrpc';
64
+ import { JSONRPCError } from '@walletmesh/jsonrpc';
65
+ import { type ZodTypeAny, z } from 'zod';
66
+ import type { AztecWalletMethodMap } from '../types.js';
73
67
 
74
68
  // These aren't exported by @aztec/stdlib/interfaces/client, we've copied them here
75
69
  const ContractMetadataSchema = z.object({
76
70
  contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
77
71
  isContractInitialized: z.boolean(),
78
- isContractPubliclyDeployed: z.boolean(),
72
+ isContractPublished: z.boolean(),
79
73
  }) satisfies ZodFor<ContractMetadata>;
80
74
 
81
75
  const ContractClassMetadataSchema = z.object({
@@ -128,13 +122,17 @@ const DeployContractResultSchema = z.object({
128
122
 
129
123
  const logger = createLogger('aztec-rpc-wallet:serializers');
130
124
 
125
+ async function jsonParseWithSchemaAsync<T>(json: string, schema: ZodTypeAny): Promise<T> {
126
+ return schema.parseAsync(JSON.parse(json));
127
+ }
128
+
131
129
  function createResultSerializer<R>(resultSchema?: ZodTypeAny): Pick<JSONRPCSerializer<unknown, R>, 'result'> {
132
130
  return {
133
131
  result: {
134
132
  serialize: async (method: string, value: R) => ({ method, serialized: jsonStringify(value) }),
135
133
  deserialize: async (method: string, data: JSONRPCSerializedData) => {
136
134
  if (resultSchema) {
137
- return await jsonParseWithSchema(data.serialized, resultSchema);
135
+ return await jsonParseWithSchemaAsync(data.serialized, resultSchema);
138
136
  }
139
137
  // If no schema is provided, parse as JSON
140
138
  logger.debug(`Deserializing result for method without schema: ${method}`);
@@ -383,13 +381,13 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
383
381
  case 'aztec_registerContract': {
384
382
  const instanceRaw = ensureParam<Record<string, unknown>>(dAppParams, 'instance');
385
383
  const artifactRaw = getOptionalParam<Record<string, unknown>>(dAppParams, 'artifact');
386
- const instance = ContractInstanceWithAddressSchema.parse(instanceRaw);
387
- const artifact = artifactRaw ? ContractArtifactSchema.parse(artifactRaw) : undefined;
384
+ const instance = await ContractInstanceWithAddressSchema.parseAsync(instanceRaw);
385
+ const artifact = artifactRaw ? await ContractArtifactSchema.parseAsync(artifactRaw) : undefined;
388
386
  return [instance, artifact];
389
387
  }
390
388
  case 'aztec_registerContractClass': {
391
389
  const artifactRaw = ensureParam<Record<string, unknown>>(dAppParams, 'artifact');
392
- const artifact = ContractArtifactSchema.parse(artifactRaw);
390
+ const artifact = await ContractArtifactSchema.parseAsync(artifactRaw);
393
391
  return [artifact];
394
392
  }
395
393
  case 'aztec_proveTx': {
@@ -400,16 +398,16 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
400
398
  dAppParams,
401
399
  'privateExecutionResult',
402
400
  );
403
- const txRequest = TxExecutionRequest.schema.parse(txRequestRaw);
401
+ const txRequest = await TxExecutionRequest.schema.parseAsync(txRequestRaw);
404
402
  // Conditionally parse if privateExecutionResultRaw is present
405
403
  const privateExecutionResult = privateExecutionResultRaw
406
- ? PrivateExecutionResult.schema.parse(privateExecutionResultRaw)
404
+ ? await PrivateExecutionResult.schema.parseAsync(privateExecutionResultRaw)
407
405
  : undefined;
408
406
  return [txRequest, privateExecutionResult];
409
407
  }
410
408
  case 'aztec_sendTx': {
411
409
  const txRaw = ensureParam<Record<string, unknown>>(dAppParams, 'tx');
412
- const tx = Tx.schema.parse(txRaw);
410
+ const tx = await Tx.schema.parseAsync(txRaw);
413
411
  return [tx];
414
412
  }
415
413
  case 'aztec_getTxReceipt': {
@@ -419,7 +417,7 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
419
417
  }
420
418
  case 'aztec_simulateTx': {
421
419
  const txRequestRaw = ensureParam<Record<string, unknown>>(dAppParams, 'txRequest');
422
- const txRequest = TxExecutionRequest.schema.parse(txRequestRaw);
420
+ const txRequest = await TxExecutionRequest.schema.parseAsync(txRequestRaw);
423
421
  const simulatePublic = getOptionalParam<boolean>(dAppParams, 'simulatePublic', 'boolean');
424
422
  const msgSenderStr = getOptionalParam<string>(dAppParams, 'msgSender', 'string');
425
423
  const msgSender = msgSenderStr ? AztecAddress.fromString(msgSenderStr) : undefined;
@@ -431,7 +429,7 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
431
429
  }
432
430
  case 'aztec_profileTx': {
433
431
  const txRequestRaw = ensureParam<Record<string, unknown>>(dAppParams, 'txRequest');
434
- const txRequest = TxExecutionRequest.schema.parse(txRequestRaw);
432
+ const txRequest = await TxExecutionRequest.schema.parseAsync(txRequestRaw);
435
433
  const profileMode = getOptionalParam<'gates' | 'execution-steps' | 'full'>(
436
434
  dAppParams,
437
435
  'profileMode',
@@ -448,7 +446,7 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
448
446
  const toStr = ensureParam<string>(dAppParams, 'to', 'string');
449
447
  const to = AztecAddress.fromString(toStr);
450
448
  const authWitsRaw = getOptionalParam<Record<string, unknown>[]>(dAppParams, 'authWits');
451
- const authWits = authWitsRaw?.map((aw) => AuthWitness.schema.parse(aw)); // Use AuthWitness from @aztec/aztec.js
449
+ const authWits = await authWitsRaw?.map((aw) => AuthWitness.schema.parseAsync(aw)); // Use AuthWitness from @aztec/aztec.js
452
450
  const fromStr = getOptionalParam<string>(dAppParams, 'from', 'string');
453
451
  const from = fromStr ? AztecAddress.fromString(fromStr) : undefined;
454
452
  return [functionName, args, to, authWits, from];
@@ -457,7 +455,10 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
457
455
  const contractAddressStr = ensureParam<string>(dAppParams, 'contractAddress', 'string');
458
456
  const contractAddress = AztecAddress.fromString(contractAddressStr);
459
457
  const eventMetadataRaw = ensureParam<string>(dAppParams, 'eventMetadata');
460
- const eventMetadata = jsonParseWithSchema(eventMetadataRaw, EventMetadataDefinitionSchema);
458
+ const eventMetadata = await jsonParseWithSchemaAsync(
459
+ eventMetadataRaw,
460
+ EventMetadataDefinitionSchema,
461
+ );
461
462
  const fromBlock = ensureParam<number>(dAppParams, 'from', 'number');
462
463
  const numBlocks = ensureParam<number>(dAppParams, 'numBlocks', 'number');
463
464
  const recipientsRaw = ensureParam<string[]>(dAppParams, 'recipients');
@@ -466,23 +467,26 @@ export const AztecWalletSerializer: JSONRPCSerializer<JSONRPCParams, unknown> =
466
467
  }
467
468
  case 'aztec_getPublicEvents': {
468
469
  const eventMetadataRaw = ensureParam<string>(dAppParams, 'eventMetadata');
469
- const eventMetadata = jsonParseWithSchema(eventMetadataRaw, EventMetadataDefinitionSchema);
470
+ const eventMetadata = await jsonParseWithSchemaAsync(
471
+ eventMetadataRaw,
472
+ EventMetadataDefinitionSchema,
473
+ );
470
474
  const fromBlock = ensureParam<number>(dAppParams, 'from', 'number');
471
475
  const limit = ensureParam<number>(dAppParams, 'limit', 'number');
472
476
  return [eventMetadata, fromBlock, limit];
473
477
  }
474
478
  case 'aztec_wmExecuteTx': {
475
479
  const executionPayloadRaw = ensureParam<Record<string, unknown>>(dAppParams, 'executionPayload');
476
- const executionPayload = ExecutionPayloadSchema.parse(executionPayloadRaw);
480
+ const executionPayload = await ExecutionPayloadSchema.parseAsync(executionPayloadRaw);
477
481
  return [executionPayload];
478
482
  }
479
483
  case 'aztec_wmSimulateTx': {
480
484
  const executionPayloadRaw = ensureParam<Record<string, unknown>>(dAppParams, 'executionPayload');
481
- const executionPayload = ExecutionPayloadSchema.parse(executionPayloadRaw);
485
+ const executionPayload = await ExecutionPayloadSchema.parseAsync(executionPayloadRaw);
482
486
  return [executionPayload];
483
487
  }
484
488
  case 'aztec_wmDeployContract': {
485
- const deployParams = DeployContractParamsSchema.parse(dAppParams);
489
+ const deployParams = await DeployContractParamsSchema.parseAsync(dAppParams);
486
490
  return [deployParams];
487
491
  }
488
492
  case 'wm_getSupportedMethods':