@walletmesh/aztec-rpc-wallet 0.1.0 → 0.1.1

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 (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
@@ -41,13 +41,13 @@ export const AZTEC_WALLET_METHODS: (keyof AztecWalletMethodMap)[] = [
41
41
  'aztec_getTxReceipt',
42
42
  'aztec_simulateTx',
43
43
  'aztec_simulateUnconstrained',
44
- 'aztec_getIncomingNotes',
44
+ 'aztec_getNotes',
45
45
  'aztec_addNote',
46
46
  'aztec_addNullifiedNote',
47
- 'aztec_getUnencryptedLogs',
47
+ 'aztec_getPublicLogs',
48
48
  'aztec_getContractClassLogs',
49
- 'aztec_getEncryptedEvents',
50
- 'aztec_getUnencryptedEvents',
49
+ 'aztec_getPrivateEvents',
50
+ 'aztec_getPublicEvents',
51
51
  ] as const;
52
52
 
53
53
  // Handler functions with proper type safety
@@ -331,11 +331,11 @@ async function handleGetPublicStorageAt(
331
331
  return await wallet.getPublicStorageAt(params.contract, params.storageSlot);
332
332
  }
333
333
 
334
- async function handleGetIncomingNotes(
334
+ async function handleGetNotes(
335
335
  wallet: AccountWallet,
336
- params: AztecWalletMethodMap['aztec_getIncomingNotes']['params'],
337
- ): Promise<AztecWalletMethodMap['aztec_getIncomingNotes']['result']> {
338
- return await wallet.getIncomingNotes(params.filter);
336
+ params: AztecWalletMethodMap['aztec_getNotes']['params'],
337
+ ): Promise<AztecWalletMethodMap['aztec_getNotes']['result']> {
338
+ return await wallet.getNotes(params.filter);
339
339
  }
340
340
 
341
341
  async function handleAddNote(
@@ -354,11 +354,11 @@ async function handleAddNullifiedNote(
354
354
  return true;
355
355
  }
356
356
 
357
- async function handleGetUnencryptedLogs(
357
+ async function handleGetPublicLogs(
358
358
  wallet: AccountWallet,
359
- params: AztecWalletMethodMap['aztec_getUnencryptedLogs']['params'],
360
- ): Promise<AztecWalletMethodMap['aztec_getUnencryptedLogs']['result']> {
361
- return await wallet.getUnencryptedLogs(params.filter);
359
+ params: AztecWalletMethodMap['aztec_getPublicLogs']['params'],
360
+ ): Promise<AztecWalletMethodMap['aztec_getPublicLogs']['result']> {
361
+ return await wallet.getPublicLogs(params.filter);
362
362
  }
363
363
 
364
364
  async function handleGetContractClassLogs(
@@ -368,20 +368,20 @@ async function handleGetContractClassLogs(
368
368
  return await wallet.getContractClassLogs(params.filter);
369
369
  }
370
370
 
371
- async function handleGetEncryptedEvents(
371
+ async function handleGetPrivateEvents(
372
372
  wallet: AccountWallet,
373
- params: AztecWalletMethodMap['aztec_getEncryptedEvents']['params'],
374
- ): Promise<AztecWalletMethodMap['aztec_getEncryptedEvents']['result']> {
373
+ params: AztecWalletMethodMap['aztec_getPrivateEvents']['params'],
374
+ ): Promise<AztecWalletMethodMap['aztec_getPrivateEvents']['result']> {
375
375
  const { event, from, limit, vpks } = params;
376
- return await wallet.getEncryptedEvents(event, from, limit, vpks);
376
+ return await wallet.getPrivateEvents(event, from, limit, vpks);
377
377
  }
378
378
 
379
- async function handleGetUnencryptedEvents(
379
+ async function handleGetPublicEvents(
380
380
  wallet: AccountWallet,
381
- params: AztecWalletMethodMap['aztec_getUnencryptedEvents']['params'],
382
- ): Promise<AztecWalletMethodMap['aztec_getUnencryptedEvents']['result']> {
381
+ params: AztecWalletMethodMap['aztec_getPublicEvents']['params'],
382
+ ): Promise<AztecWalletMethodMap['aztec_getPublicEvents']['result']> {
383
383
  const { event, from, limit } = params;
384
- return await wallet.getUnencryptedEvents(event, from, limit);
384
+ return await wallet.getPublicEvents(event, from, limit);
385
385
  }
386
386
 
387
387
  async function handleL1ToL2MembershipWitness(
@@ -553,11 +553,8 @@ export async function aztecWalletHandler<M extends keyof AztecWalletMethodMap>(
553
553
  );
554
554
 
555
555
  // Notes methods
556
- case 'aztec_getIncomingNotes':
557
- return handleGetIncomingNotes(
558
- context.wallet,
559
- params as AztecWalletMethodMap['aztec_getIncomingNotes']['params'],
560
- );
556
+ case 'aztec_getNotes':
557
+ return handleGetNotes(context.wallet, params as AztecWalletMethodMap['aztec_getNotes']['params']);
561
558
  case 'aztec_addNote':
562
559
  return handleAddNote(context.wallet, params as AztecWalletMethodMap['aztec_addNote']['params']);
563
560
  case 'aztec_addNullifiedNote':
@@ -566,26 +563,26 @@ export async function aztecWalletHandler<M extends keyof AztecWalletMethodMap>(
566
563
  params as AztecWalletMethodMap['aztec_addNullifiedNote']['params'],
567
564
  );
568
565
 
569
- // Logs methods
570
- case 'aztec_getUnencryptedLogs':
571
- return handleGetUnencryptedLogs(
566
+ // Logs and Events methods
567
+ case 'aztec_getPublicLogs':
568
+ return handleGetPublicLogs(
572
569
  context.wallet,
573
- params as AztecWalletMethodMap['aztec_getUnencryptedLogs']['params'],
570
+ params as AztecWalletMethodMap['aztec_getPublicLogs']['params'],
574
571
  );
575
572
  case 'aztec_getContractClassLogs':
576
573
  return handleGetContractClassLogs(
577
574
  context.wallet,
578
575
  params as AztecWalletMethodMap['aztec_getContractClassLogs']['params'],
579
576
  );
580
- case 'aztec_getEncryptedEvents':
581
- return handleGetEncryptedEvents(
577
+ case 'aztec_getPrivateEvents':
578
+ return handleGetPrivateEvents(
582
579
  context.wallet,
583
- params as AztecWalletMethodMap['aztec_getEncryptedEvents']['params'],
580
+ params as AztecWalletMethodMap['aztec_getPrivateEvents']['params'],
584
581
  );
585
- case 'aztec_getUnencryptedEvents':
586
- return handleGetUnencryptedEvents(
582
+ case 'aztec_getPublicEvents':
583
+ return handleGetPublicEvents(
587
584
  context.wallet,
588
- params as AztecWalletMethodMap['aztec_getUnencryptedEvents']['params'],
585
+ params as AztecWalletMethodMap['aztec_getPublicEvents']['params'],
589
586
  );
590
587
  default:
591
588
  throw new AztecWalletError('invalidRequest', `Method not supported: ${String(method)}`);
@@ -7,14 +7,14 @@ import {
7
7
  aztecGetAuthWitnessSerializer,
8
8
  } from './account.js';
9
9
  import { decodeBase64 } from './types.js';
10
- import { frSerializer } from './core.js';
10
+ import { schemas } from '@aztec/foundation/schemas';
11
11
 
12
12
  describe('Account Serializers', () => {
13
13
  describe('aztec_setScopes', () => {
14
14
  const METHOD = 'aztec_setScopes';
15
15
 
16
- it('should serialize and deserialize params', () => {
17
- const scopes = [AztecAddress.random(), AztecAddress.random()];
16
+ it('should serialize and deserialize params', async () => {
17
+ const scopes = [await AztecAddress.random(), await AztecAddress.random()];
18
18
  const params = { scopes };
19
19
 
20
20
  const serialized = aztecSetScopesSerializer.params.serialize(METHOD, params);
@@ -38,9 +38,9 @@ describe('Account Serializers', () => {
38
38
  describe('aztec_registerAccount', () => {
39
39
  const METHOD = 'aztec_registerAccount';
40
40
 
41
- it('should serialize and deserialize params', () => {
42
- const secretKey = Fr.random();
43
- const partialAddress = Fr.random();
41
+ it('should serialize and deserialize params', async () => {
42
+ const secretKey = await Fr.random();
43
+ const partialAddress = await Fr.random();
44
44
  const params = { secretKey, partialAddress };
45
45
 
46
46
  const serialized = aztecRegisterAccountSerializer.params.serialize(METHOD, params);
@@ -51,8 +51,8 @@ describe('Account Serializers', () => {
51
51
  expect(deserialized.partialAddress.toString()).toBe(partialAddress.toString());
52
52
  });
53
53
 
54
- it('should serialize and deserialize result', () => {
55
- const result = CompleteAddress.random();
54
+ it('should serialize and deserialize result', async () => {
55
+ const result = await CompleteAddress.random();
56
56
 
57
57
  const serialized = aztecRegisterAccountSerializer.result.serialize(METHOD, result);
58
58
  expect(serialized.method).toBe(METHOD);
@@ -65,8 +65,8 @@ describe('Account Serializers', () => {
65
65
  describe('aztec_addAuthWitness', () => {
66
66
  const METHOD = 'aztec_addAuthWitness';
67
67
 
68
- it('should serialize and deserialize params', () => {
69
- const authWitness = AuthWitness.random();
68
+ it('should serialize and deserialize params', async () => {
69
+ const authWitness = await AuthWitness.random();
70
70
  const params = { authWitness };
71
71
 
72
72
  const serialized = aztecAddAuthWitnessSerializer.params.serialize(METHOD, params);
@@ -90,8 +90,8 @@ describe('Account Serializers', () => {
90
90
  describe('aztec_getAuthWitness', () => {
91
91
  const METHOD = 'aztec_getAuthWitness';
92
92
 
93
- it('should serialize and deserialize params', () => {
94
- const messageHash = Fr.random();
93
+ it('should serialize and deserialize params', async () => {
94
+ const messageHash = await Fr.random();
95
95
  const params = { messageHash };
96
96
 
97
97
  const serialized = aztecGetAuthWitnessSerializer.params.serialize(METHOD, params);
@@ -101,8 +101,8 @@ describe('Account Serializers', () => {
101
101
  expect(deserialized.messageHash.toString()).toBe(messageHash.toString());
102
102
  });
103
103
 
104
- it('should serialize and deserialize result', () => {
105
- const result = [Fr.random(), Fr.random()];
104
+ it('should serialize and deserialize result', async () => {
105
+ const result = [await Fr.random(), await Fr.random()];
106
106
 
107
107
  const serialized = aztecGetAuthWitnessSerializer.result.serialize(METHOD, result);
108
108
  expect(serialized.method).toBe(METHOD);
@@ -113,12 +113,13 @@ describe('Account Serializers', () => {
113
113
  });
114
114
 
115
115
  describe('Base64 encoding/decoding', () => {
116
- it('should properly encode and decode data', () => {
117
- const messageHash = Fr.random();
116
+ it('should properly encode and decode data', async () => {
117
+ const messageHash = await Fr.random();
118
+
118
119
  const serialized = aztecGetAuthWitnessSerializer.params.serialize('aztec_getAuthWitness', {
119
120
  messageHash,
120
121
  });
121
- const decoded = frSerializer.deserialize(decodeBase64(serialized.serialized));
122
+ const decoded = schemas.Fr.parse(JSON.parse(serialized.serialized));
122
123
  expect(decoded.toString()).toBe(messageHash.toString());
123
124
  });
124
125
  });
@@ -1,18 +1,11 @@
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 {
5
- aztecAddressSerializer,
6
- completeAddressSerializer,
7
- frSerializer,
8
- authWitnessSerializer,
9
- } from './core.js';
10
- import type { PartialAddress, AztecAddress } from '@aztec/aztec.js';
2
+ import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
3
+ import type { PartialAddress } from '@aztec/aztec.js';
4
+ import { CompleteAddress, AuthWitness, AztecAddress, Fr } from '@aztec/aztec.js';
11
5
 
12
6
  /**
13
7
  * Serializer for the aztec_setScopes RPC method.
14
8
  * Handles serialization of account scope settings between JSON-RPC format and native Aztec types.
15
- * Scopes define which contracts can interact with an account.
16
9
  */
17
10
  export class AztecSetScopesSerializer
18
11
  implements
@@ -35,9 +28,9 @@ export class AztecSetScopesSerializer
35
28
  const { scopes } = value;
36
29
  return {
37
30
  method,
38
- serialized: encodeBase64(
39
- JSON.stringify(scopes.map((s: AztecAddress) => aztecAddressSerializer.serialize(s))),
40
- ),
31
+ serialized: JSON.stringify({
32
+ scopes: scopes.map((s) => s.toString()),
33
+ }),
41
34
  };
42
35
  },
43
36
  /**
@@ -50,10 +43,10 @@ export class AztecSetScopesSerializer
50
43
  method: string,
51
44
  data: JSONRPCSerializedData,
52
45
  ): AztecWalletMethodMap['aztec_setScopes']['params'] => {
53
- const scopes = JSON.parse(decodeBase64(data.serialized)).map((s: string) =>
54
- aztecAddressSerializer.deserialize(s),
55
- );
56
- return { scopes };
46
+ const { scopes } = JSON.parse(data.serialized);
47
+ return {
48
+ scopes: scopes.map((s: string) => AztecAddress.fromString(s)),
49
+ };
57
50
  },
58
51
  };
59
52
 
@@ -67,7 +60,7 @@ export class AztecSetScopesSerializer
67
60
  serialize: (method: string, value: boolean): JSONRPCSerializedData => {
68
61
  return {
69
62
  method,
70
- serialized: encodeBase64(JSON.stringify(value)),
63
+ serialized: JSON.stringify(value),
71
64
  };
72
65
  },
73
66
  /**
@@ -77,7 +70,7 @@ export class AztecSetScopesSerializer
77
70
  * @returns Boolean indicating success
78
71
  */
79
72
  deserialize: (method: string, data: JSONRPCSerializedData): boolean => {
80
- return JSON.parse(decodeBase64(data.serialized));
73
+ return JSON.parse(data.serialized);
81
74
  },
82
75
  };
83
76
  }
@@ -85,7 +78,6 @@ export class AztecSetScopesSerializer
85
78
  /**
86
79
  * Serializer for the aztec_registerAccount RPC method.
87
80
  * Handles serialization of account registration data between JSON-RPC format and native Aztec types.
88
- * Account registration involves creating a new account with a secret key and partial address.
89
81
  */
90
82
  export class AztecRegisterAccountSerializer
91
83
  implements
@@ -108,12 +100,10 @@ export class AztecRegisterAccountSerializer
108
100
  const { secretKey, partialAddress } = value;
109
101
  return {
110
102
  method,
111
- serialized: encodeBase64(
112
- JSON.stringify([
113
- frSerializer.serialize(secretKey),
114
- frSerializer.serialize(partialAddress as unknown as PartialAddress),
115
- ]),
116
- ),
103
+ serialized: JSON.stringify({
104
+ secretKey: secretKey.toString(),
105
+ partialAddress: partialAddress.toString(),
106
+ }),
117
107
  };
118
108
  },
119
109
  /**
@@ -126,10 +116,10 @@ export class AztecRegisterAccountSerializer
126
116
  method: string,
127
117
  data: JSONRPCSerializedData,
128
118
  ): AztecWalletMethodMap['aztec_registerAccount']['params'] => {
129
- const [secretKey, partialAddress] = JSON.parse(decodeBase64(data.serialized));
119
+ const { secretKey, partialAddress } = JSON.parse(data.serialized);
130
120
  return {
131
- secretKey: frSerializer.deserialize(secretKey),
132
- partialAddress: frSerializer.deserialize(partialAddress) as PartialAddress,
121
+ secretKey: Fr.fromString(secretKey),
122
+ partialAddress: Fr.fromString(partialAddress) as PartialAddress,
133
123
  };
134
124
  },
135
125
  };
@@ -141,13 +131,10 @@ export class AztecRegisterAccountSerializer
141
131
  * @param value - The complete address of the registered account
142
132
  * @returns Serialized complete address
143
133
  */
144
- serialize: (
145
- method: string,
146
- value: AztecWalletMethodMap['aztec_registerAccount']['result'],
147
- ): JSONRPCSerializedData => {
134
+ serialize: (method: string, value: CompleteAddress): JSONRPCSerializedData => {
148
135
  return {
149
136
  method,
150
- serialized: encodeBase64(completeAddressSerializer.serialize(value)),
137
+ serialized: JSON.stringify(value.toString()),
151
138
  };
152
139
  },
153
140
  /**
@@ -156,11 +143,8 @@ export class AztecRegisterAccountSerializer
156
143
  * @param data - The serialized complete address
157
144
  * @returns Deserialized complete address
158
145
  */
159
- deserialize: (
160
- method: string,
161
- data: JSONRPCSerializedData,
162
- ): AztecWalletMethodMap['aztec_registerAccount']['result'] => {
163
- return completeAddressSerializer.deserialize(decodeBase64(data.serialized));
146
+ deserialize: (method: string, data: JSONRPCSerializedData): CompleteAddress => {
147
+ return CompleteAddress.fromString(JSON.parse(data.serialized));
164
148
  },
165
149
  };
166
150
  }
@@ -168,7 +152,6 @@ export class AztecRegisterAccountSerializer
168
152
  /**
169
153
  * Serializer for the aztec_addAuthWitness RPC method.
170
154
  * Handles serialization of authentication witness data between JSON-RPC format and native Aztec types.
171
- * Auth witnesses are used to prove transaction authorization.
172
155
  */
173
156
  export class AztecAddAuthWitnessSerializer
174
157
  implements
@@ -191,7 +174,7 @@ export class AztecAddAuthWitnessSerializer
191
174
  const { authWitness } = value;
192
175
  return {
193
176
  method,
194
- serialized: encodeBase64(authWitnessSerializer.serialize(authWitness)),
177
+ serialized: JSON.stringify(authWitness.toString()),
195
178
  };
196
179
  },
197
180
  /**
@@ -204,7 +187,7 @@ export class AztecAddAuthWitnessSerializer
204
187
  method: string,
205
188
  data: JSONRPCSerializedData,
206
189
  ): AztecWalletMethodMap['aztec_addAuthWitness']['params'] => {
207
- const authWitness = authWitnessSerializer.deserialize(decodeBase64(data.serialized));
190
+ const authWitness = AuthWitness.fromString(JSON.parse(data.serialized));
208
191
  return { authWitness };
209
192
  },
210
193
  };
@@ -219,7 +202,7 @@ export class AztecAddAuthWitnessSerializer
219
202
  serialize: (method: string, value: boolean): JSONRPCSerializedData => {
220
203
  return {
221
204
  method,
222
- serialized: encodeBase64(JSON.stringify(value)),
205
+ serialized: JSON.stringify(value),
223
206
  };
224
207
  },
225
208
  /**
@@ -229,7 +212,7 @@ export class AztecAddAuthWitnessSerializer
229
212
  * @returns Boolean indicating success
230
213
  */
231
214
  deserialize: (method: string, data: JSONRPCSerializedData): boolean => {
232
- return JSON.parse(decodeBase64(data.serialized));
215
+ return JSON.parse(data.serialized);
233
216
  },
234
217
  };
235
218
  }
@@ -237,7 +220,6 @@ export class AztecAddAuthWitnessSerializer
237
220
  /**
238
221
  * Serializer for the aztec_getAuthWitness RPC method.
239
222
  * Handles serialization of authentication witness retrieval between JSON-RPC format and native Aztec types.
240
- * Retrieves auth witnesses associated with a specific message hash.
241
223
  */
242
224
  export class AztecGetAuthWitnessSerializer
243
225
  implements
@@ -260,7 +242,7 @@ export class AztecGetAuthWitnessSerializer
260
242
  const { messageHash } = value;
261
243
  return {
262
244
  method,
263
- serialized: encodeBase64(frSerializer.serialize(messageHash)),
245
+ serialized: JSON.stringify(messageHash.toString()),
264
246
  };
265
247
  },
266
248
  /**
@@ -273,7 +255,7 @@ export class AztecGetAuthWitnessSerializer
273
255
  method: string,
274
256
  data: JSONRPCSerializedData,
275
257
  ): AztecWalletMethodMap['aztec_getAuthWitness']['params'] => {
276
- const messageHash = frSerializer.deserialize(decodeBase64(data.serialized));
258
+ const messageHash = Fr.fromString(JSON.parse(data.serialized));
277
259
  return { messageHash };
278
260
  },
279
261
  };
@@ -291,7 +273,7 @@ export class AztecGetAuthWitnessSerializer
291
273
  ): JSONRPCSerializedData => {
292
274
  return {
293
275
  method,
294
- serialized: encodeBase64(JSON.stringify(value.map((w) => frSerializer.serialize(w)))),
276
+ serialized: JSON.stringify(value.map((w) => w.toString())),
295
277
  };
296
278
  },
297
279
  /**
@@ -304,7 +286,7 @@ export class AztecGetAuthWitnessSerializer
304
286
  method: string,
305
287
  data: JSONRPCSerializedData,
306
288
  ): AztecWalletMethodMap['aztec_getAuthWitness']['result'] => {
307
- return JSON.parse(decodeBase64(data.serialized)).map((w: string) => frSerializer.deserialize(w));
289
+ return JSON.parse(data.serialized).map((w: string) => Fr.fromString(w));
308
290
  },
309
291
  };
310
292
  }
@@ -20,12 +20,10 @@ import {
20
20
  type ContractNote,
21
21
  } from '@aztec/foundation/abi';
22
22
  import { randomContractArtifact, randomDeployedContract } from '@aztec/circuit-types';
23
- import { aztecAddressSerializer, frSerializer } from './core.js';
24
-
25
23
  describe('Contract Serializers', () => {
26
24
  describe('aztec_getContractInstance', () => {
27
- it('should serialize and deserialize params', () => {
28
- const address = AztecAddress.random();
25
+ it('should serialize and deserialize params', async () => {
26
+ const address = await AztecAddress.random();
29
27
  const params = { address };
30
28
 
31
29
  const serialized = aztecGetContractInstanceSerializer.params.serialize(
@@ -41,9 +39,9 @@ describe('Contract Serializers', () => {
41
39
  expect(deserialized.address.toString()).toBe(address.toString());
42
40
  });
43
41
 
44
- it('should serialize and deserialize result', () => {
42
+ it('should serialize and deserialize result', async () => {
45
43
  // Create a contract instance with all required fields
46
- const result = SerializableContractInstance.random().withAddress(AztecAddress.random());
44
+ const result = (await SerializableContractInstance.random()).withAddress(await AztecAddress.random());
47
45
 
48
46
  const serialized = aztecGetContractInstanceSerializer.result.serialize(
49
47
  'aztec_getContractInstance',
@@ -64,8 +62,8 @@ describe('Contract Serializers', () => {
64
62
  });
65
63
 
66
64
  describe('aztec_getContractClass', () => {
67
- it('should serialize and deserialize params', () => {
68
- const id = Fr.random();
65
+ it('should serialize and deserialize params', async () => {
66
+ const id = await Fr.random();
69
67
  const params = { id };
70
68
 
71
69
  const serialized = aztecGetContractClassSerializer.params.serialize('aztec_getContractClass', params);
@@ -78,8 +76,8 @@ describe('Contract Serializers', () => {
78
76
  expect(deserialized.id.toString()).toBe(id.toString());
79
77
  });
80
78
 
81
- it('should serialize and deserialize result', () => {
82
- const artifact = randomContractArtifact();
79
+ it('should serialize and deserialize result', async () => {
80
+ const artifact = await randomContractArtifact();
83
81
  const result = getContractClassFromArtifact(artifact);
84
82
  const serialized = aztecGetContractClassSerializer.result.serialize('aztec_getContractClass', result);
85
83
  expect(serialized.method).toBe('aztec_getContractClass');
@@ -97,8 +95,8 @@ describe('Contract Serializers', () => {
97
95
  });
98
96
 
99
97
  describe('aztec_getContractArtifact', () => {
100
- it('should serialize and deserialize params', () => {
101
- const id = Fr.random();
98
+ it('should serialize and deserialize params', async () => {
99
+ const id = await Fr.random();
102
100
  const serialized = aztecGetContractArtifactSerializer.params.serialize('aztec_getContractArtifact', {
103
101
  id,
104
102
  });
@@ -111,8 +109,8 @@ describe('Contract Serializers', () => {
111
109
  expect(deserialized.id.toString()).toBe(id.toString());
112
110
  });
113
111
 
114
- it('should serialize and deserialize result', () => {
115
- const result = randomContractArtifact();
112
+ it('should serialize and deserialize result', async () => {
113
+ const result = await randomContractArtifact();
116
114
  const serialized = aztecGetContractArtifactSerializer.result.serialize(
117
115
  'aztec_getContractArtifact',
118
116
  result,
@@ -128,8 +126,8 @@ describe('Contract Serializers', () => {
128
126
  });
129
127
 
130
128
  describe('aztec_registerContract', () => {
131
- it('should serialize and deserialize params', () => {
132
- const { instance, artifact } = randomDeployedContract();
129
+ it('should serialize and deserialize params', async () => {
130
+ const { instance, artifact } = await randomDeployedContract();
133
131
  const serialized = aztecRegisterContractSerializer.params.serialize('aztec_registerContract', {
134
132
  instance,
135
133
  artifact,