@walletmesh/aztec-rpc-wallet 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/aztecRemoteWallet.d.ts +7 -6
  4. package/dist/aztecRemoteWallet.d.ts.map +1 -1
  5. package/dist/aztecRemoteWallet.js +15 -9
  6. package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
  7. package/dist/handlers/aztecAccountWallet.js +22 -22
  8. package/dist/serializers/account.d.ts +4 -7
  9. package/dist/serializers/account.d.ts.map +1 -1
  10. package/dist/serializers/account.js +28 -29
  11. package/dist/serializers/contract.d.ts +4 -56
  12. package/dist/serializers/contract.d.ts.map +1 -1
  13. package/dist/serializers/contract.js +62 -148
  14. package/dist/serializers/index.d.ts +1 -4
  15. package/dist/serializers/index.d.ts.map +1 -1
  16. package/dist/serializers/index.js +12 -12
  17. package/dist/serializers/log.d.ts +36 -83
  18. package/dist/serializers/log.d.ts.map +1 -1
  19. package/dist/serializers/log.js +96 -107
  20. package/dist/serializers/note.d.ts +14 -17
  21. package/dist/serializers/note.d.ts.map +1 -1
  22. package/dist/serializers/note.js +52 -29
  23. package/dist/serializers/transaction-utils.d.ts +44 -100
  24. package/dist/serializers/transaction-utils.d.ts.map +1 -1
  25. package/dist/serializers/transaction-utils.js +82 -118
  26. package/dist/serializers/transaction.d.ts +3 -6
  27. package/dist/serializers/transaction.d.ts.map +1 -1
  28. package/dist/serializers/transaction.js +39 -50
  29. package/dist/types.d.ts +8 -8
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/types.js +1 -1
  32. package/package.json +5 -5
  33. package/src/aztecRemoteWallet.test.ts +33 -29
  34. package/src/aztecRemoteWallet.ts +25 -14
  35. package/src/handlers/aztecAccountWallet.test.ts +78 -75
  36. package/src/handlers/aztecAccountWallet.ts +32 -35
  37. package/src/serializers/account.test.ts +18 -17
  38. package/src/serializers/account.ts +31 -49
  39. package/src/serializers/contract.test.ts +14 -16
  40. package/src/serializers/contract.ts +75 -164
  41. package/src/serializers/index.test.ts +20 -8
  42. package/src/serializers/index.ts +16 -20
  43. package/src/serializers/log.test.ts +201 -28
  44. package/src/serializers/log.ts +153 -146
  45. package/src/serializers/note.test.ts +26 -28
  46. package/src/serializers/note.ts +60 -36
  47. package/src/serializers/transaction-utils.ts +135 -211
  48. package/src/serializers/transaction.test.ts +190 -30
  49. package/src/serializers/transaction.ts +51 -72
  50. package/src/types.ts +9 -8
  51. package/vitest.config.ts +1 -1
  52. package/dist/serializers/contract-utils.d.ts +0 -40
  53. package/dist/serializers/contract-utils.d.ts.map +0 -1
  54. package/dist/serializers/contract-utils.js +0 -102
  55. package/dist/serializers/core.d.ts +0 -110
  56. package/dist/serializers/core.d.ts.map +0 -1
  57. package/dist/serializers/core.js +0 -130
  58. package/dist/serializers/types.d.ts +0 -49
  59. package/dist/serializers/types.d.ts.map +0 -1
  60. package/dist/serializers/types.js +0 -22
  61. package/src/serializers/contract-utils.ts +0 -104
  62. package/src/serializers/core.test.ts +0 -56
  63. package/src/serializers/core.ts +0 -141
  64. package/src/serializers/types.ts +0 -58
@@ -1,7 +1,18 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { AztecAddress, TxHash, Tx } from '@aztec/aztec.js';
3
-
4
- import { PrivateExecutionResult, TxProvingResult } from '@aztec/circuit-types';
2
+ import { AztecAddress, TxHash, Tx, NoFeePaymentMethod, TxReceipt } from '@aztec/aztec.js';
3
+ import {
4
+ PrivateExecutionResult,
5
+ TxProvingResult,
6
+ FunctionCall,
7
+ TxEffect,
8
+ TxSimulationResult,
9
+ TxStatus,
10
+ PublicSimulationOutput,
11
+ SimulationError,
12
+ } from '@aztec/circuit-types';
13
+ import { Fr, FunctionSelector, PrivateKernelTailCircuitPublicInputs } from '@aztec/circuits.js';
14
+ import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
15
+ import { FunctionType } from '@aztec/foundation/abi';
5
16
  import {
6
17
  aztecCreateTxExecutionRequestSerializer,
7
18
  aztecSendTxSerializer,
@@ -12,16 +23,22 @@ import {
12
23
  } from './transaction.js';
13
24
  import { TxExecutionRequest } from '@aztec/aztec.js';
14
25
 
15
- import { comparePrivateExecutionResults, compareTxProvingResults } from './transaction-utils.js';
26
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
16
27
 
17
28
  describe('Transaction Serializers', () => {
18
29
  describe('aztec_createTxExecutionRequest', () => {
19
30
  const METHOD = 'aztec_createTxExecutionRequest';
20
31
 
21
- it('should serialize and deserialize params', () => {
22
- // Create a request using random() and convert to plain object
23
- const request = TxExecutionRequest.random();
24
- const params = { exec: JSON.parse(JSON.stringify(request)) };
32
+ it('should serialize and deserialize params', async () => {
33
+ const randomTx = await TxExecutionRequest.random();
34
+ const exec = {
35
+ calls: [], // Empty calls array since we're just testing serialization
36
+ fee: {
37
+ gasSettings: randomTx.txContext.gasSettings,
38
+ paymentMethod: new NoFeePaymentMethod(),
39
+ },
40
+ };
41
+ const params = { exec };
25
42
 
26
43
  const serialized = aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
27
44
  expect(serialized.method).toBe(METHOD);
@@ -30,8 +47,38 @@ describe('Transaction Serializers', () => {
30
47
  expect(JSON.stringify(deserialized.exec)).toBe(JSON.stringify(params.exec));
31
48
  });
32
49
 
33
- it('should serialize and deserialize result', () => {
34
- const result = TxExecutionRequest.random();
50
+ it('should handle complex function calls in params', async () => {
51
+ const randomTx = await TxExecutionRequest.random();
52
+ const address = await AztecAddress.random();
53
+ const selector = FunctionSelector.random();
54
+ const functionCall = new FunctionCall(
55
+ 'transfer',
56
+ address,
57
+ selector,
58
+ FunctionType.PRIVATE,
59
+ false,
60
+ [await Fr.random(), await Fr.random()],
61
+ [{ kind: 'field' }, { kind: 'boolean' }],
62
+ );
63
+ const exec: ExecutionRequestInit = {
64
+ calls: [functionCall],
65
+ fee: {
66
+ gasSettings: randomTx.txContext.gasSettings,
67
+ paymentMethod: new NoFeePaymentMethod(),
68
+ },
69
+ };
70
+ const params = { exec };
71
+
72
+ const serialized = aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
73
+ const deserialized = aztecCreateTxExecutionRequestSerializer.params.deserialize(METHOD, serialized);
74
+
75
+ expect(deserialized.exec.calls[0].name).toBe(exec.calls[0].name);
76
+ expect(deserialized.exec.calls[0].to.toString()).toBe(exec.calls[0].to.toString());
77
+ expect(deserialized.exec.calls[0].type).toBe(exec.calls[0].type);
78
+ });
79
+
80
+ it('should serialize and deserialize result', async () => {
81
+ const result = await TxExecutionRequest.random();
35
82
 
36
83
  const serialized = aztecCreateTxExecutionRequestSerializer.result.serialize(METHOD, result);
37
84
  expect(serialized.method).toBe(METHOD);
@@ -39,13 +86,20 @@ describe('Transaction Serializers', () => {
39
86
  const deserialized = aztecCreateTxExecutionRequestSerializer.result.deserialize(METHOD, serialized);
40
87
  expect(deserialized.toString()).toBe(result.toString());
41
88
  });
89
+
90
+ it('should handle invalid params', () => {
91
+ expect(() => {
92
+ // @ts-ignore - Testing invalid input
93
+ aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, { exec: null });
94
+ }).toThrow();
95
+ });
42
96
  });
43
97
 
44
98
  describe('aztec_getTxEffect', () => {
45
99
  const METHOD = 'aztec_getTxEffect';
46
100
 
47
- it('should serialize and deserialize params', () => {
48
- const txHash = TxHash.random();
101
+ it('should serialize and deserialize params', async () => {
102
+ const txHash = await TxHash.random();
49
103
  const params = { txHash };
50
104
 
51
105
  const serialized = aztecGetTxEffectSerializer.params.serialize(METHOD, params);
@@ -54,13 +108,31 @@ describe('Transaction Serializers', () => {
54
108
  const deserialized = aztecGetTxEffectSerializer.params.deserialize(METHOD, serialized);
55
109
  expect(deserialized.txHash.toString()).toBe(txHash.toString());
56
110
  });
111
+
112
+ it('should serialize and deserialize result', async () => {
113
+ const txHash = await TxHash.random();
114
+ const effect = await TxEffect.random();
115
+ const blockHash = await Fr.random();
116
+ const result = {
117
+ txHash,
118
+ l2BlockNumber: 123,
119
+ l2BlockHash: blockHash.toString(),
120
+ data: effect,
121
+ };
122
+
123
+ const serialized = aztecGetTxEffectSerializer.result.serialize(METHOD, result);
124
+ const deserialized = aztecGetTxEffectSerializer.result.deserialize(METHOD, serialized);
125
+
126
+ expect(deserialized.l2BlockNumber).toBe(result.l2BlockNumber);
127
+ expect(deserialized.data).toBeDefined();
128
+ });
57
129
  });
58
130
 
59
131
  describe('aztec_getTxReceipt', () => {
60
132
  const METHOD = 'aztec_getTxReceipt';
61
133
 
62
- it('should serialize and deserialize params', () => {
63
- const txHash = TxHash.random();
134
+ it('should serialize and deserialize params', async () => {
135
+ const txHash = await TxHash.random();
64
136
  const params = { txHash };
65
137
 
66
138
  const serialized = aztecGetTxReceiptSerializer.params.serialize(METHOD, params);
@@ -69,13 +141,30 @@ describe('Transaction Serializers', () => {
69
141
  const deserialized = aztecGetTxReceiptSerializer.params.deserialize(METHOD, serialized);
70
142
  expect(deserialized.txHash.toString()).toBe(txHash.toString());
71
143
  });
144
+
145
+ it('should serialize and deserialize result', async () => {
146
+ const receipt = new TxReceipt(
147
+ TxHash.random(),
148
+ TxStatus.DROPPED,
149
+ 'error',
150
+ undefined,
151
+ undefined,
152
+ undefined,
153
+ );
154
+
155
+ const serialized = aztecGetTxReceiptSerializer.result.serialize(METHOD, receipt);
156
+ const deserialized = aztecGetTxReceiptSerializer.result.deserialize(METHOD, serialized);
157
+
158
+ expect(deserialized.txHash.toString()).toBe(receipt.txHash.toString());
159
+ expect(deserialized.error).toBe(receipt.error);
160
+ });
72
161
  });
73
162
 
74
163
  describe('aztec_sendTx', () => {
75
164
  const METHOD = 'aztec_sendTx';
76
165
 
77
- it('should serialize and deserialize params', () => {
78
- const tx = Tx.random();
166
+ it('should serialize and deserialize params', async () => {
167
+ const tx = await Tx.random();
79
168
  const params = { tx };
80
169
 
81
170
  const serialized = aztecSendTxSerializer.params.serialize(METHOD, params);
@@ -85,8 +174,8 @@ describe('Transaction Serializers', () => {
85
174
  expect(deserialized.tx.toBuffer().toString('hex')).toBe(tx.toBuffer().toString('hex'));
86
175
  });
87
176
 
88
- it('should serialize and deserialize result', () => {
89
- const result = TxHash.random();
177
+ it('should serialize and deserialize result', async () => {
178
+ const result = await TxHash.random();
90
179
 
91
180
  const serialized = aztecSendTxSerializer.result.serialize(METHOD, result);
92
181
  expect(serialized.method).toBe(METHOD);
@@ -99,11 +188,11 @@ describe('Transaction Serializers', () => {
99
188
  describe('aztec_simulateTx', () => {
100
189
  const METHOD = 'aztec_simulateTx';
101
190
 
102
- it('should serialize and deserialize params', () => {
191
+ it('should serialize and deserialize params', async () => {
103
192
  const params = {
104
- txRequest: TxExecutionRequest.random(),
193
+ txRequest: await TxExecutionRequest.random(),
105
194
  simulatePublic: true,
106
- msgSender: AztecAddress.random(),
195
+ msgSender: await AztecAddress.random(),
107
196
  skipTxValidation: false,
108
197
  enforceFeePayment: true,
109
198
  profile: false,
@@ -120,14 +209,68 @@ describe('Transaction Serializers', () => {
120
209
  expect(deserialized.enforceFeePayment).toBe(params.enforceFeePayment);
121
210
  expect(deserialized.profile).toBe(params.profile);
122
211
  });
212
+
213
+ it('should serialize and deserialize result', async () => {
214
+ const result = await TxSimulationResult.random();
215
+
216
+ const serialized = aztecSimulateTxSerializer.result.serialize(METHOD, result);
217
+ const deserialized = aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
218
+
219
+ expect(deserialized.privateExecutionResult).toBeDefined();
220
+ expect(deserialized.publicInputs).toBeDefined();
221
+ expect(deserialized.publicOutput).toBeDefined();
222
+
223
+ expect(jsonStringify(deserialized.privateExecutionResult)).toEqual(
224
+ jsonStringify(result.privateExecutionResult),
225
+ );
226
+ expect(jsonStringify(deserialized.publicInputs)).toEqual(jsonStringify(result.publicInputs));
227
+ if (!result.publicOutput || !deserialized.publicOutput) {
228
+ // Should never happen
229
+ throw new Error('Public output is undefined');
230
+ }
231
+ expect(jsonStringify(deserialized.publicOutput.constants)).toEqual(
232
+ jsonStringify(result.publicOutput.constants),
233
+ );
234
+ expect(jsonStringify(deserialized.publicOutput.constants)).toEqual(
235
+ jsonStringify(result.publicOutput.constants),
236
+ );
237
+ expect(jsonStringify(deserialized.publicOutput.gasUsed.publicGas)).toEqual(
238
+ jsonStringify(result.publicOutput.gasUsed.publicGas),
239
+ );
240
+ expect(jsonStringify(deserialized.publicOutput.gasUsed.teardownGas)).toEqual(
241
+ jsonStringify(result.publicOutput.gasUsed.teardownGas),
242
+ );
243
+ expect(jsonStringify(deserialized.publicOutput.gasUsed.totalGas)).toEqual(
244
+ jsonStringify(result.publicOutput.gasUsed.totalGas),
245
+ );
246
+ });
247
+
248
+ it('should handle simulation errors in result', async () => {
249
+ const privateExecutionResult = await PrivateExecutionResult.random();
250
+ const publicInputs = PrivateKernelTailCircuitPublicInputs.empty();
251
+ const publicOutput = await PublicSimulationOutput.random();
252
+ // Simulate an error by setting revertReason
253
+ publicOutput.revertReason = await SimulationError.random();
254
+ const result = new TxSimulationResult(privateExecutionResult, publicInputs, publicOutput, undefined);
255
+
256
+ const serialized = aztecSimulateTxSerializer.result.serialize(METHOD, result);
257
+ const deserialized = aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
258
+
259
+ const output = deserialized.publicOutput;
260
+ expect(output).toBeDefined();
261
+ if (output && result.publicOutput) {
262
+ expect(output.revertReason).toBeDefined();
263
+ expect(output.gasUsed).toEqual(result.publicOutput.gasUsed);
264
+ }
265
+ });
123
266
  });
124
267
 
125
268
  describe('aztec_proveTx', () => {
126
269
  const METHOD = 'aztec_proveTx';
127
270
 
128
- it('should serialize and deserialize params', () => {
129
- const txRequest = TxExecutionRequest.random();
130
- const privateExecutionResult = PrivateExecutionResult.random();
271
+ it('should serialize and deserialize params', async () => {
272
+ const txRequest = await TxExecutionRequest.random();
273
+ const privateExecutionResult = await PrivateExecutionResult.random();
131
274
  const params = { txRequest, privateExecutionResult };
132
275
 
133
276
  const serialized = aztecProveTxSerializer.params.serialize(METHOD, params);
@@ -135,19 +278,36 @@ describe('Transaction Serializers', () => {
135
278
 
136
279
  const deserialized = aztecProveTxSerializer.params.deserialize(METHOD, serialized);
137
280
  expect(deserialized.txRequest.toString()).toBe(txRequest.toString());
138
- expect(
139
- comparePrivateExecutionResults(privateExecutionResult, deserialized.privateExecutionResult),
140
- ).toBe(true);
281
+ expect(jsonStringify(deserialized.privateExecutionResult)).toEqual(
282
+ jsonStringify(privateExecutionResult),
283
+ );
141
284
  });
142
285
 
143
- it('should serialize and deserialize result', () => {
144
- const result = TxProvingResult.random();
286
+ it('should serialize and deserialize result', async () => {
287
+ const result = await TxProvingResult.random();
145
288
 
146
289
  const serialized = aztecProveTxSerializer.result.serialize(METHOD, result);
147
290
  expect(serialized.method).toBe(METHOD);
148
291
 
149
292
  const deserialized = aztecProveTxSerializer.result.deserialize(METHOD, serialized);
150
- expect(compareTxProvingResults(result, deserialized)).toBe(true);
293
+ expect(jsonStringify(deserialized)).toEqual(jsonStringify(result));
294
+ });
295
+
296
+ it('should handle complex private execution results', async () => {
297
+ const txRequest = await TxExecutionRequest.random();
298
+ const privateExecutionResult = await PrivateExecutionResult.random();
299
+
300
+ // Add nested executions and complex data
301
+ const nestedExecution = await PrivateExecutionResult.random();
302
+ privateExecutionResult.entrypoint.nestedExecutions.push(nestedExecution.entrypoint);
303
+
304
+ const params = { txRequest, privateExecutionResult };
305
+ const serialized = aztecProveTxSerializer.params.serialize(METHOD, params);
306
+ const deserialized = aztecProveTxSerializer.params.deserialize(METHOD, serialized);
307
+
308
+ expect(jsonStringify(deserialized.privateExecutionResult)).toEqual(
309
+ jsonStringify(privateExecutionResult),
310
+ );
151
311
  });
152
312
  });
153
313
  });
@@ -1,11 +1,17 @@
1
1
  import type { AztecWalletMethodMap } from '../types.js';
2
- import type { JSONRPCSerializedData, JSONRPCSerializer } from './types.js';
3
- import { encodeBase64, decodeBase64 } from './types.js';
4
- import { txHashSerializer } from './core.js';
5
- import { TxEffect, TxSimulationResult, inBlockSchemaFor, type TxProvingResult } from '@aztec/circuit-types';
6
- import { TxExecutionRequest, TxReceipt, Tx, AztecAddress } from '@aztec/aztec.js';
2
+ import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
3
+ import { TxProvingResult } from '@aztec/circuit-types';
4
+ import {
5
+ PrivateExecutionResult,
6
+ TxEffect,
7
+ TxSimulationResult,
8
+ inBlockSchemaFor,
9
+ TxHash,
10
+ } from '@aztec/circuit-types';
11
+ import { TxExecutionRequest, TxReceipt, Tx, AztecAddress, Fr } from '@aztec/aztec.js';
12
+ import { serializeExecutionRequestInit, deserializeExecutionRequestInit } from './transaction-utils.js';
7
13
 
8
- import { SerializablePrivateExecutionResult, SerializableTxProvingResult } from './transaction-utils.js';
14
+ import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
9
15
 
10
16
  /**
11
17
  * Serializer for the aztec_createTxExecutionRequest RPC method.
@@ -26,14 +32,14 @@ export class AztecCreateTxExecutionRequestSerializer
26
32
  const { exec } = value;
27
33
  return {
28
34
  method,
29
- serialized: encodeBase64(JSON.stringify(exec)),
35
+ serialized: serializeExecutionRequestInit(exec),
30
36
  };
31
37
  },
32
38
  deserialize: (
33
39
  method: string,
34
40
  data: JSONRPCSerializedData,
35
41
  ): AztecWalletMethodMap['aztec_createTxExecutionRequest']['params'] => {
36
- const exec = JSON.parse(decodeBase64(data.serialized));
42
+ const exec = deserializeExecutionRequestInit(data.serialized);
37
43
  return { exec };
38
44
  },
39
45
  };
@@ -42,11 +48,11 @@ export class AztecCreateTxExecutionRequestSerializer
42
48
  serialize: (method: string, value: TxExecutionRequest): JSONRPCSerializedData => {
43
49
  return {
44
50
  method,
45
- serialized: encodeBase64(value.toString()),
51
+ serialized: jsonStringify(value),
46
52
  };
47
53
  },
48
54
  deserialize: (method: string, data: JSONRPCSerializedData): TxExecutionRequest => {
49
- return TxExecutionRequest.fromString(decodeBase64(data.serialized));
55
+ return jsonParseWithSchema(data.serialized, TxExecutionRequest.schema);
50
56
  },
51
57
  };
52
58
  }
@@ -54,7 +60,6 @@ export class AztecCreateTxExecutionRequestSerializer
54
60
  /**
55
61
  * Serializer for the aztec_proveTx RPC method.
56
62
  * Handles serialization of transaction proving requests and results between JSON-RPC format and native Aztec types.
57
- * Includes handling of private execution results and proving outcomes.
58
63
  */
59
64
  export class AztecProveTxSerializer
60
65
  implements
@@ -69,35 +74,35 @@ export class AztecProveTxSerializer
69
74
  value: AztecWalletMethodMap['aztec_proveTx']['params'],
70
75
  ): JSONRPCSerializedData => {
71
76
  const { txRequest, privateExecutionResult } = value;
72
- const serializablePrivateExecutionResult =
73
- SerializablePrivateExecutionResult.from(privateExecutionResult);
74
77
  return {
75
78
  method,
76
- serialized: encodeBase64(JSON.stringify([txRequest.toString(), serializablePrivateExecutionResult])),
79
+ serialized: JSON.stringify({
80
+ txRequest: jsonStringify(txRequest),
81
+ privateExecutionResult: jsonStringify(privateExecutionResult),
82
+ }),
77
83
  };
78
84
  },
79
85
  deserialize: (
80
86
  method: string,
81
87
  data: JSONRPCSerializedData,
82
88
  ): AztecWalletMethodMap['aztec_proveTx']['params'] => {
83
- const [txRequest, privateExecutionResult] = JSON.parse(decodeBase64(data.serialized));
89
+ const { txRequest, privateExecutionResult } = JSON.parse(data.serialized);
84
90
  return {
85
- txRequest: TxExecutionRequest.fromString(txRequest),
86
- privateExecutionResult: SerializablePrivateExecutionResult.fromJSON(privateExecutionResult),
91
+ txRequest: jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
92
+ privateExecutionResult: jsonParseWithSchema(privateExecutionResult, PrivateExecutionResult.schema),
87
93
  };
88
94
  },
89
95
  };
90
96
 
91
97
  result = {
92
98
  serialize: (method: string, value: TxProvingResult): JSONRPCSerializedData => {
93
- const serializableTxProvingResult = SerializableTxProvingResult.from(value);
94
99
  return {
95
100
  method,
96
- serialized: encodeBase64(JSON.stringify(serializableTxProvingResult)),
101
+ serialized: jsonStringify(value),
97
102
  };
98
103
  },
99
104
  deserialize: (method: string, data: JSONRPCSerializedData): TxProvingResult => {
100
- return SerializableTxProvingResult.fromJSON(JSON.parse(decodeBase64(data.serialized)));
105
+ return jsonParseWithSchema(data.serialized, TxProvingResult.schema);
101
106
  },
102
107
  };
103
108
  }
@@ -121,15 +126,14 @@ export class AztecSendTxSerializer
121
126
  const { tx } = value;
122
127
  return {
123
128
  method,
124
- serialized: encodeBase64(tx.toBuffer().toString('hex')),
129
+ serialized: jsonStringify(tx),
125
130
  };
126
131
  },
127
132
  deserialize: (
128
133
  method: string,
129
134
  data: JSONRPCSerializedData,
130
135
  ): AztecWalletMethodMap['aztec_sendTx']['params'] => {
131
- const tx = Tx.fromBuffer(Buffer.from(decodeBase64(data.serialized), 'hex'));
132
- return { tx };
136
+ return { tx: jsonParseWithSchema(data.serialized, Tx.schema) };
133
137
  },
134
138
  };
135
139
 
@@ -140,14 +144,14 @@ export class AztecSendTxSerializer
140
144
  ): JSONRPCSerializedData => {
141
145
  return {
142
146
  method,
143
- serialized: encodeBase64(txHashSerializer.serialize(value)),
147
+ serialized: jsonStringify(value),
144
148
  };
145
149
  },
146
150
  deserialize: (
147
151
  method: string,
148
152
  data: JSONRPCSerializedData,
149
153
  ): AztecWalletMethodMap['aztec_sendTx']['result'] => {
150
- return txHashSerializer.deserialize(decodeBase64(data.serialized));
154
+ return jsonParseWithSchema(data.serialized, TxHash.schema);
151
155
  },
152
156
  };
153
157
  }
@@ -155,7 +159,6 @@ export class AztecSendTxSerializer
155
159
  /**
156
160
  * Serializer for the aztec_getTxEffect RPC method.
157
161
  * Handles serialization of transaction effect queries and results between JSON-RPC format and native Aztec types.
158
- * Transaction effects represent the outcome and state changes caused by a transaction.
159
162
  */
160
163
  export class AztecGetTxEffectSerializer
161
164
  implements
@@ -172,14 +175,14 @@ export class AztecGetTxEffectSerializer
172
175
  const { txHash } = value;
173
176
  return {
174
177
  method,
175
- serialized: encodeBase64(txHashSerializer.serialize(txHash)),
178
+ serialized: jsonStringify(txHash),
176
179
  };
177
180
  },
178
181
  deserialize: (
179
182
  method: string,
180
183
  data: JSONRPCSerializedData,
181
184
  ): AztecWalletMethodMap['aztec_getTxEffect']['params'] => {
182
- const txHash = txHashSerializer.deserialize(decodeBase64(data.serialized));
185
+ const txHash = jsonParseWithSchema(data.serialized, TxHash.schema);
183
186
  return { txHash };
184
187
  },
185
188
  };
@@ -191,14 +194,14 @@ export class AztecGetTxEffectSerializer
191
194
  ): JSONRPCSerializedData => {
192
195
  return {
193
196
  method,
194
- serialized: encodeBase64(JSON.stringify(TxEffect.schema.parse(value))),
197
+ serialized: jsonStringify(value),
195
198
  };
196
199
  },
197
200
  deserialize: (
198
201
  method: string,
199
202
  data: JSONRPCSerializedData,
200
203
  ): AztecWalletMethodMap['aztec_getTxEffect']['result'] => {
201
- return inBlockSchemaFor(TxEffect.schema).parse(JSON.parse(decodeBase64(data.serialized)));
204
+ return jsonParseWithSchema(data.serialized, inBlockSchemaFor(TxEffect.schema));
202
205
  },
203
206
  };
204
207
  }
@@ -206,7 +209,6 @@ export class AztecGetTxEffectSerializer
206
209
  /**
207
210
  * Serializer for the aztec_getTxReceipt RPC method.
208
211
  * Handles serialization of transaction receipt queries and results between JSON-RPC format and native Aztec types.
209
- * Transaction receipts contain detailed information about executed transactions.
210
212
  */
211
213
  export class AztecGetTxReceiptSerializer
212
214
  implements
@@ -223,14 +225,14 @@ export class AztecGetTxReceiptSerializer
223
225
  const { txHash } = value;
224
226
  return {
225
227
  method,
226
- serialized: encodeBase64(txHashSerializer.serialize(txHash)),
228
+ serialized: jsonStringify(txHash),
227
229
  };
228
230
  },
229
231
  deserialize: (
230
232
  method: string,
231
233
  data: JSONRPCSerializedData,
232
234
  ): AztecWalletMethodMap['aztec_getTxReceipt']['params'] => {
233
- const txHash = txHashSerializer.deserialize(decodeBase64(data.serialized));
235
+ const txHash = jsonParseWithSchema(data.serialized, TxHash.schema);
234
236
  return { txHash };
235
237
  },
236
238
  };
@@ -239,11 +241,11 @@ export class AztecGetTxReceiptSerializer
239
241
  serialize: (method: string, value: TxReceipt): JSONRPCSerializedData => {
240
242
  return {
241
243
  method,
242
- serialized: encodeBase64(JSON.stringify(TxReceipt.schema.parse(value))),
244
+ serialized: jsonStringify(value),
243
245
  };
244
246
  },
245
247
  deserialize: (method: string, data: JSONRPCSerializedData): TxReceipt => {
246
- return TxReceipt.schema.parse(JSON.parse(decodeBase64(data.serialized)));
248
+ return jsonParseWithSchema(data.serialized, TxReceipt.schema);
247
249
  },
248
250
  };
249
251
  }
@@ -251,7 +253,6 @@ export class AztecGetTxReceiptSerializer
251
253
  /**
252
254
  * Serializer for the aztec_simulateTx RPC method.
253
255
  * Handles serialization of transaction simulation requests and results between JSON-RPC format and native Aztec types.
254
- * Supports simulation configuration including public simulation, custom sender, validation options, and profiling.
255
256
  */
256
257
  export class AztecSimulateTxSerializer
257
258
  implements
@@ -268,29 +269,26 @@ export class AztecSimulateTxSerializer
268
269
  const { txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile } = value;
269
270
  return {
270
271
  method,
271
- serialized: encodeBase64(
272
- JSON.stringify([
273
- txRequest.toString(),
274
- simulatePublic,
275
- msgSender,
276
- skipTxValidation,
277
- enforceFeePayment,
278
- profile,
279
- ]),
280
- ),
272
+ serialized: JSON.stringify({
273
+ txRequest: jsonStringify(txRequest),
274
+ simulatePublic,
275
+ msgSender: JSON.stringify(msgSender),
276
+ skipTxValidation,
277
+ enforceFeePayment,
278
+ profile,
279
+ }),
281
280
  };
282
281
  },
283
282
  deserialize: (
284
283
  method: string,
285
284
  data: JSONRPCSerializedData,
286
285
  ): AztecWalletMethodMap['aztec_simulateTx']['params'] => {
287
- const [txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile] = JSON.parse(
288
- decodeBase64(data.serialized),
289
- );
286
+ const { txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile } =
287
+ JSON.parse(data.serialized);
290
288
  return {
291
- txRequest: TxExecutionRequest.fromString(txRequest),
289
+ txRequest: jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
292
290
  simulatePublic,
293
- msgSender: msgSender ? AztecAddress.fromString(msgSender) : undefined,
291
+ msgSender: jsonParseWithSchema(msgSender, AztecAddress.schema),
294
292
  skipTxValidation,
295
293
  enforceFeePayment,
296
294
  profile,
@@ -300,32 +298,13 @@ export class AztecSimulateTxSerializer
300
298
 
301
299
  result = {
302
300
  serialize: (method: string, value: TxSimulationResult): JSONRPCSerializedData => {
303
- const serializablePrivateExecutionResult = SerializablePrivateExecutionResult.from(
304
- value.privateExecutionResult,
305
- );
306
-
307
301
  return {
308
302
  method,
309
- serialized: encodeBase64(
310
- JSON.stringify({
311
- privateExecutionResult: serializablePrivateExecutionResult,
312
- publicInputs: value.publicInputs,
313
- publicOutput: value.publicOutput,
314
- profileResult: value.profileResult,
315
- }),
316
- ),
303
+ serialized: jsonStringify(value),
317
304
  };
318
305
  },
319
306
  deserialize: (method: string, data: JSONRPCSerializedData): TxSimulationResult => {
320
- const { privateExecutionResult, publicInputs, publicOutput, profileResult } = JSON.parse(
321
- decodeBase64(data.serialized),
322
- );
323
- return new TxSimulationResult(
324
- SerializablePrivateExecutionResult.fromJSON(privateExecutionResult),
325
- publicInputs,
326
- publicOutput,
327
- profileResult,
328
- );
307
+ return jsonParseWithSchema(data.serialized, TxSimulationResult.schema);
329
308
  },
330
309
  };
331
310
  }
package/src/types.ts CHANGED
@@ -25,15 +25,16 @@ import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
25
25
  import type { AbiDecoded } from '@aztec/foundation/abi';
26
26
  import type {
27
27
  InBlock,
28
- IncomingNotesFilter,
28
+ NotesFilter,
29
29
  EventMetadataDefinition,
30
30
  PrivateExecutionResult,
31
31
  TxEffect,
32
32
  TxProvingResult,
33
33
  UniqueNote,
34
- GetUnencryptedLogsResponse,
35
34
  PXEInfo,
36
35
  TxSimulationResult,
36
+ GetPublicLogsResponse,
37
+ GetContractClassLogsResponse,
37
38
  } from '@aztec/circuit-types';
38
39
  import type { GasFees, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js';
39
40
  import type { JSONRPCEventMap, JSONRPCMiddleware } from '@walletmesh/jsonrpc';
@@ -265,18 +266,18 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
265
266
  };
266
267
 
267
268
  /* Notes */
268
- aztec_getIncomingNotes: { params: { filter: IncomingNotesFilter }; result: UniqueNote[] };
269
+ aztec_getNotes: { params: { filter: NotesFilter }; result: UniqueNote[] };
269
270
  aztec_addNote: { params: { note: ExtendedNote }; result: boolean };
270
271
  aztec_addNullifiedNote: { params: { note: ExtendedNote }; result: boolean };
271
272
 
272
- /* Logs */
273
- aztec_getUnencryptedLogs: { params: { filter: LogFilter }; result: GetUnencryptedLogsResponse };
274
- aztec_getContractClassLogs: { params: { filter: LogFilter }; result: GetUnencryptedLogsResponse };
275
- aztec_getEncryptedEvents: {
273
+ /* Logs and Events */
274
+ aztec_getPublicLogs: { params: { filter: LogFilter }; result: GetPublicLogsResponse };
275
+ aztec_getContractClassLogs: { params: { filter: LogFilter }; result: GetContractClassLogsResponse };
276
+ aztec_getPrivateEvents: {
276
277
  params: { event: EventMetadataDefinition; from: number; limit: number; vpks?: Point[] };
277
278
  result: unknown[];
278
279
  };
279
- aztec_getUnencryptedEvents: {
280
+ aztec_getPublicEvents: {
280
281
  params: { event: EventMetadataDefinition; from: number; limit: number };
281
282
  result: unknown[];
282
283
  };
package/vitest.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- testTimeout: 200, // .2 second timeout
5
+ testTimeout: 1000, // 1 second timeout
6
6
  coverage: {
7
7
  include: ['src/**/*.ts', '!src/**/types.ts', '!src/**/index.ts', '!src/**/*.test.ts'],
8
8
  },