@walletmesh/aztec-rpc-wallet 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +4 -4
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/aztecRemoteWallet.d.ts +4 -8
  5. package/dist/aztecRemoteWallet.d.ts.map +1 -1
  6. package/dist/aztecRemoteWallet.js +5 -30
  7. package/dist/chainProvider.d.ts.map +1 -1
  8. package/dist/chainProvider.js +1 -1
  9. package/dist/contractArtifactCache.d.ts.map +1 -1
  10. package/dist/contractArtifactCache.js +20 -9
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +1 -1
  13. package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
  14. package/dist/handlers/aztecAccountWallet.js +12 -45
  15. package/dist/handlers/transactions.d.ts.map +1 -1
  16. package/dist/handlers/transactions.js +11 -3
  17. package/dist/serializers/account.d.ts +24 -24
  18. package/dist/serializers/account.d.ts.map +1 -1
  19. package/dist/serializers/account.js +51 -51
  20. package/dist/serializers/contract.d.ts +22 -76
  21. package/dist/serializers/contract.d.ts.map +1 -1
  22. package/dist/serializers/contract.js +68 -120
  23. package/dist/serializers/index.d.ts +0 -4
  24. package/dist/serializers/index.d.ts.map +1 -1
  25. package/dist/serializers/index.js +15 -20
  26. package/dist/serializers/log.d.ts +16 -16
  27. package/dist/serializers/log.d.ts.map +1 -1
  28. package/dist/serializers/log.js +66 -64
  29. package/dist/serializers/note.d.ts +18 -18
  30. package/dist/serializers/note.d.ts.map +1 -1
  31. package/dist/serializers/note.js +54 -51
  32. package/dist/serializers/transaction.d.ts +25 -26
  33. package/dist/serializers/transaction.d.ts.map +1 -1
  34. package/dist/serializers/transaction.js +92 -44
  35. package/dist/types.d.ts +8 -31
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/types.js +1 -1
  38. package/docs/README.md +264 -0
  39. package/docs/classes/AztecChainProvider.md +553 -0
  40. package/docs/classes/AztecChainWallet.md +409 -0
  41. package/docs/classes/AztecProvider.md +1112 -0
  42. package/docs/classes/AztecWalletError.md +213 -0
  43. package/docs/classes/ContractArtifactCache.md +81 -0
  44. package/docs/globals.md +34 -0
  45. package/docs/interfaces/AztecWalletBaseMethodMap.md +135 -0
  46. package/docs/interfaces/AztecWalletEventMap.md +17 -0
  47. package/docs/interfaces/AztecWalletMethodMap.md +1012 -0
  48. package/docs/type-aliases/AztecChainId.md +11 -0
  49. package/docs/type-aliases/AztecChainWalletMiddleware.md +13 -0
  50. package/docs/type-aliases/AztecWalletContext.md +29 -0
  51. package/docs/type-aliases/AztecWalletMethodHandler.md +37 -0
  52. package/docs/type-aliases/AztecWalletMiddleware.md +13 -0
  53. package/docs/type-aliases/AztecWalletRouterClient.md +13 -0
  54. package/docs/type-aliases/TransactionFunctionCall.md +33 -0
  55. package/docs/type-aliases/TransactionParams.md +27 -0
  56. package/docs/variables/AztecWalletErrorMap.md +13 -0
  57. package/package.json +11 -11
  58. package/src/aztecRemoteWallet.test.ts +23 -65
  59. package/src/aztecRemoteWallet.ts +8 -36
  60. package/src/chainProvider.test.ts +117 -38
  61. package/src/chainProvider.ts +1 -7
  62. package/src/contractArtifactCache.test.ts +28 -45
  63. package/src/contractArtifactCache.ts +20 -10
  64. package/src/errors.ts +0 -1
  65. package/src/handlers/aztecAccountWallet.test.ts +12 -86
  66. package/src/handlers/aztecAccountWallet.ts +20 -78
  67. package/src/handlers/transactions.ts +16 -2
  68. package/src/provider.test.ts +0 -2
  69. package/src/serializers/account.test.ts +19 -20
  70. package/src/serializers/account.ts +65 -65
  71. package/src/serializers/contract.test.ts +4 -140
  72. package/src/serializers/contract.ts +98 -176
  73. package/src/serializers/index.test.ts +30 -28
  74. package/src/serializers/index.ts +15 -33
  75. package/src/serializers/log.test.ts +42 -48
  76. package/src/serializers/log.ts +85 -83
  77. package/src/serializers/note.test.ts +43 -16
  78. package/src/serializers/note.ts +62 -63
  79. package/src/serializers/transaction.test.ts +48 -41
  80. package/src/serializers/transaction.ts +154 -66
  81. package/src/types.ts +8 -8
  82. package/src/wallet.test.ts +3 -3
  83. package/tsconfig.json +1 -1
  84. package/dist/serializers/transaction-utils.d.ts +0 -51
  85. package/dist/serializers/transaction-utils.d.ts.map +0 -1
  86. package/dist/serializers/transaction-utils.js +0 -94
  87. package/src/serializers/transaction-utils.ts +0 -161
@@ -40,11 +40,16 @@ describe('Transaction Serializers', () => {
40
40
  };
41
41
  const params = { exec };
42
42
 
43
- const serialized = aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
43
+ const serialized = await aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
44
44
  expect(serialized.method).toBe(METHOD);
45
45
 
46
- const deserialized = aztecCreateTxExecutionRequestSerializer.params.deserialize(METHOD, serialized);
47
- expect(JSON.stringify(deserialized.exec)).toBe(JSON.stringify(params.exec));
46
+ const deserialized = await aztecCreateTxExecutionRequestSerializer.params.deserialize(
47
+ METHOD,
48
+ serialized,
49
+ );
50
+ expect(deserialized.exec.calls).toEqual([]);
51
+ expect(deserialized.exec.fee.gasSettings.equals(randomTx.txContext.gasSettings)).toBe(true);
52
+ expect(deserialized.exec.fee.paymentMethod).toBeDefined();
48
53
  });
49
54
 
50
55
  it('should handle complex function calls in params', async () => {
@@ -69,30 +74,32 @@ describe('Transaction Serializers', () => {
69
74
  };
70
75
  const params = { exec };
71
76
 
72
- const serialized = aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
73
- const deserialized = aztecCreateTxExecutionRequestSerializer.params.deserialize(METHOD, serialized);
77
+ const serialized = await aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
78
+ const deserialized = await aztecCreateTxExecutionRequestSerializer.params.deserialize(
79
+ METHOD,
80
+ serialized,
81
+ );
74
82
 
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);
83
+ // biome-ignore lint/style/noNonNullAssertion: test
84
+ expect(deserialized.exec.calls[0]!.name).toBe(exec.calls[0]!.name);
85
+ // biome-ignore lint/style/noNonNullAssertion: test
86
+ expect(deserialized.exec.calls[0]!.to.toString()).toBe(exec.calls[0]!.to.toString());
87
+ // biome-ignore lint/style/noNonNullAssertion: test
88
+ expect(deserialized.exec.calls[0]!.type).toBe(exec.calls[0]!.type);
78
89
  });
79
90
 
80
91
  it('should serialize and deserialize result', async () => {
81
92
  const result = await TxExecutionRequest.random();
82
93
 
83
- const serialized = aztecCreateTxExecutionRequestSerializer.result.serialize(METHOD, result);
94
+ const serialized = await aztecCreateTxExecutionRequestSerializer.result.serialize(METHOD, result);
84
95
  expect(serialized.method).toBe(METHOD);
85
96
 
86
- const deserialized = aztecCreateTxExecutionRequestSerializer.result.deserialize(METHOD, serialized);
97
+ const deserialized = await aztecCreateTxExecutionRequestSerializer.result.deserialize(
98
+ METHOD,
99
+ serialized,
100
+ );
87
101
  expect(deserialized.toString()).toBe(result.toString());
88
102
  });
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
- });
96
103
  });
97
104
 
98
105
  describe('aztec_getTxEffect', () => {
@@ -102,10 +109,10 @@ describe('Transaction Serializers', () => {
102
109
  const txHash = await TxHash.random();
103
110
  const params = { txHash };
104
111
 
105
- const serialized = aztecGetTxEffectSerializer.params.serialize(METHOD, params);
112
+ const serialized = await aztecGetTxEffectSerializer.params.serialize(METHOD, params);
106
113
  expect(serialized.method).toBe(METHOD);
107
114
 
108
- const deserialized = aztecGetTxEffectSerializer.params.deserialize(METHOD, serialized);
115
+ const deserialized = await aztecGetTxEffectSerializer.params.deserialize(METHOD, serialized);
109
116
  expect(deserialized.txHash.toString()).toBe(txHash.toString());
110
117
  });
111
118
 
@@ -120,8 +127,8 @@ describe('Transaction Serializers', () => {
120
127
  data: effect,
121
128
  };
122
129
 
123
- const serialized = aztecGetTxEffectSerializer.result.serialize(METHOD, result);
124
- const deserialized = aztecGetTxEffectSerializer.result.deserialize(METHOD, serialized);
130
+ const serialized = await aztecGetTxEffectSerializer.result.serialize(METHOD, result);
131
+ const deserialized = await aztecGetTxEffectSerializer.result.deserialize(METHOD, serialized);
125
132
 
126
133
  expect(deserialized.l2BlockNumber).toBe(result.l2BlockNumber);
127
134
  expect(deserialized.data).toBeDefined();
@@ -135,10 +142,10 @@ describe('Transaction Serializers', () => {
135
142
  const txHash = await TxHash.random();
136
143
  const params = { txHash };
137
144
 
138
- const serialized = aztecGetTxReceiptSerializer.params.serialize(METHOD, params);
145
+ const serialized = await aztecGetTxReceiptSerializer.params.serialize(METHOD, params);
139
146
  expect(serialized.method).toBe(METHOD);
140
147
 
141
- const deserialized = aztecGetTxReceiptSerializer.params.deserialize(METHOD, serialized);
148
+ const deserialized = await aztecGetTxReceiptSerializer.params.deserialize(METHOD, serialized);
142
149
  expect(deserialized.txHash.toString()).toBe(txHash.toString());
143
150
  });
144
151
 
@@ -152,8 +159,8 @@ describe('Transaction Serializers', () => {
152
159
  undefined,
153
160
  );
154
161
 
155
- const serialized = aztecGetTxReceiptSerializer.result.serialize(METHOD, receipt);
156
- const deserialized = aztecGetTxReceiptSerializer.result.deserialize(METHOD, serialized);
162
+ const serialized = await aztecGetTxReceiptSerializer.result.serialize(METHOD, receipt);
163
+ const deserialized = await aztecGetTxReceiptSerializer.result.deserialize(METHOD, serialized);
157
164
 
158
165
  expect(deserialized.txHash.toString()).toBe(receipt.txHash.toString());
159
166
  expect(deserialized.error).toBe(receipt.error);
@@ -167,20 +174,20 @@ describe('Transaction Serializers', () => {
167
174
  const tx = await Tx.random();
168
175
  const params = { tx };
169
176
 
170
- const serialized = aztecSendTxSerializer.params.serialize(METHOD, params);
177
+ const serialized = await aztecSendTxSerializer.params.serialize(METHOD, params);
171
178
  expect(serialized.method).toBe(METHOD);
172
179
 
173
- const deserialized = aztecSendTxSerializer.params.deserialize(METHOD, serialized);
180
+ const deserialized = await aztecSendTxSerializer.params.deserialize(METHOD, serialized);
174
181
  expect(deserialized.tx.toBuffer().toString('hex')).toBe(tx.toBuffer().toString('hex'));
175
182
  });
176
183
 
177
184
  it('should serialize and deserialize result', async () => {
178
185
  const result = await TxHash.random();
179
186
 
180
- const serialized = aztecSendTxSerializer.result.serialize(METHOD, result);
187
+ const serialized = await aztecSendTxSerializer.result.serialize(METHOD, result);
181
188
  expect(serialized.method).toBe(METHOD);
182
189
 
183
- const deserialized = aztecSendTxSerializer.result.deserialize(METHOD, serialized);
190
+ const deserialized = await aztecSendTxSerializer.result.deserialize(METHOD, serialized);
184
191
  expect(deserialized.toString()).toBe(result.toString());
185
192
  });
186
193
  });
@@ -198,10 +205,10 @@ describe('Transaction Serializers', () => {
198
205
  profile: false,
199
206
  };
200
207
 
201
- const serialized = aztecSimulateTxSerializer.params.serialize(METHOD, params);
208
+ const serialized = await aztecSimulateTxSerializer.params.serialize(METHOD, params);
202
209
  expect(serialized.method).toBe(METHOD);
203
210
 
204
- const deserialized = aztecSimulateTxSerializer.params.deserialize(METHOD, serialized);
211
+ const deserialized = await aztecSimulateTxSerializer.params.deserialize(METHOD, serialized);
205
212
  expect(deserialized.txRequest.toString()).toBe((params.txRequest as TxExecutionRequest).toString());
206
213
  expect(deserialized.simulatePublic).toBe(params.simulatePublic);
207
214
  expect(deserialized.msgSender?.toString()).toBe(params.msgSender.toString());
@@ -213,8 +220,8 @@ describe('Transaction Serializers', () => {
213
220
  it('should serialize and deserialize result', async () => {
214
221
  const result = await TxSimulationResult.random();
215
222
 
216
- const serialized = aztecSimulateTxSerializer.result.serialize(METHOD, result);
217
- const deserialized = aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
223
+ const serialized = await aztecSimulateTxSerializer.result.serialize(METHOD, result);
224
+ const deserialized = await aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
218
225
 
219
226
  expect(deserialized.privateExecutionResult).toBeDefined();
220
227
  expect(deserialized.publicInputs).toBeDefined();
@@ -253,8 +260,8 @@ describe('Transaction Serializers', () => {
253
260
  publicOutput.revertReason = await SimulationError.random();
254
261
  const result = new TxSimulationResult(privateExecutionResult, publicInputs, publicOutput, undefined);
255
262
 
256
- const serialized = aztecSimulateTxSerializer.result.serialize(METHOD, result);
257
- const deserialized = aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
263
+ const serialized = await aztecSimulateTxSerializer.result.serialize(METHOD, result);
264
+ const deserialized = await aztecSimulateTxSerializer.result.deserialize(METHOD, serialized);
258
265
 
259
266
  const output = deserialized.publicOutput;
260
267
  expect(output).toBeDefined();
@@ -273,10 +280,10 @@ describe('Transaction Serializers', () => {
273
280
  const privateExecutionResult = await PrivateExecutionResult.random();
274
281
  const params = { txRequest, privateExecutionResult };
275
282
 
276
- const serialized = aztecProveTxSerializer.params.serialize(METHOD, params);
283
+ const serialized = await aztecProveTxSerializer.params.serialize(METHOD, params);
277
284
  expect(serialized.method).toBe(METHOD);
278
285
 
279
- const deserialized = aztecProveTxSerializer.params.deserialize(METHOD, serialized);
286
+ const deserialized = await aztecProveTxSerializer.params.deserialize(METHOD, serialized);
280
287
  expect(deserialized.txRequest.toString()).toBe(txRequest.toString());
281
288
  expect(jsonStringify(deserialized.privateExecutionResult)).toEqual(
282
289
  jsonStringify(privateExecutionResult),
@@ -286,10 +293,10 @@ describe('Transaction Serializers', () => {
286
293
  it('should serialize and deserialize result', async () => {
287
294
  const result = await TxProvingResult.random();
288
295
 
289
- const serialized = aztecProveTxSerializer.result.serialize(METHOD, result);
296
+ const serialized = await aztecProveTxSerializer.result.serialize(METHOD, result);
290
297
  expect(serialized.method).toBe(METHOD);
291
298
 
292
- const deserialized = aztecProveTxSerializer.result.deserialize(METHOD, serialized);
299
+ const deserialized = await aztecProveTxSerializer.result.deserialize(METHOD, serialized);
293
300
  expect(jsonStringify(deserialized)).toEqual(jsonStringify(result));
294
301
  });
295
302
 
@@ -302,8 +309,8 @@ describe('Transaction Serializers', () => {
302
309
  privateExecutionResult.entrypoint.nestedExecutions.push(nestedExecution.entrypoint);
303
310
 
304
311
  const params = { txRequest, privateExecutionResult };
305
- const serialized = aztecProveTxSerializer.params.serialize(METHOD, params);
306
- const deserialized = aztecProveTxSerializer.params.deserialize(METHOD, serialized);
312
+ const serialized = await aztecProveTxSerializer.params.serialize(METHOD, params);
313
+ const deserialized = await aztecProveTxSerializer.params.deserialize(METHOD, serialized);
307
314
 
308
315
  expect(jsonStringify(deserialized.privateExecutionResult)).toEqual(
309
316
  jsonStringify(privateExecutionResult),
@@ -1,17 +1,40 @@
1
1
  import type { AztecWalletMethodMap } from '../types.js';
2
2
  import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
3
- import { TxProvingResult } from '@aztec/circuit-types';
4
3
  import {
4
+ FunctionCall,
5
5
  PrivateExecutionResult,
6
6
  TxEffect,
7
7
  TxSimulationResult,
8
8
  inBlockSchemaFor,
9
9
  TxHash,
10
+ TxProvingResult,
10
11
  } from '@aztec/circuit-types';
11
- import { TxExecutionRequest, TxReceipt, Tx, AztecAddress, Fr } from '@aztec/aztec.js';
12
- import { serializeExecutionRequestInit, deserializeExecutionRequestInit } from './transaction-utils.js';
12
+ import { GasSettings } from '@aztec/circuits.js';
13
+ import {
14
+ AuthWitness,
15
+ AztecAddress,
16
+ Fr,
17
+ FunctionSelector,
18
+ HashedValues,
19
+ NoFeePaymentMethod,
20
+ TxExecutionRequest,
21
+ TxReceipt,
22
+ Tx,
23
+ } from '@aztec/aztec.js';
24
+ import { AbiTypeSchema, type FunctionType } from '@aztec/foundation/abi';
13
25
 
14
26
  import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
27
+ import type { ExecutionRequestInit, FeeOptions } from '@aztec/aztec.js/entrypoint';
28
+
29
+ interface SerializedFunctionCall {
30
+ name: string;
31
+ to: string;
32
+ selector: string;
33
+ type: string;
34
+ isStatic: boolean;
35
+ args: string[];
36
+ returnTypes: string[];
37
+ }
15
38
 
16
39
  /**
17
40
  * Serializer for the aztec_createTxExecutionRequest RPC method.
@@ -25,34 +48,96 @@ export class AztecCreateTxExecutionRequestSerializer
25
48
  >
26
49
  {
27
50
  params = {
28
- serialize: (
51
+ serialize: async (
29
52
  method: string,
30
53
  value: AztecWalletMethodMap['aztec_createTxExecutionRequest']['params'],
31
- ): JSONRPCSerializedData => {
54
+ ): Promise<JSONRPCSerializedData> => {
32
55
  const { exec } = value;
56
+
57
+ const calls = exec.calls.map((call: FunctionCall) => {
58
+ return {
59
+ name: call.name,
60
+ to: jsonStringify(call.to),
61
+ selector: jsonStringify(call.selector),
62
+ type: call.type,
63
+ isStatic: call.isStatic,
64
+ args: call.args.map((arg) => jsonStringify(arg)),
65
+ returnTypes: call.returnTypes.map((r) => jsonStringify(r)),
66
+ };
67
+ });
68
+ const authWitnesses = exec.authWitnesses ? exec.authWitnesses.map((w) => jsonStringify(w)) : undefined;
69
+ const hashedArguments = exec.hashedArguments
70
+ ? exec.hashedArguments.map((h) => jsonStringify(h))
71
+ : undefined;
72
+ const fee = { gasSettings: jsonStringify(exec.fee.gasSettings) };
73
+ const nonce = exec.nonce ? jsonStringify(exec.nonce) : undefined;
74
+
33
75
  return {
34
76
  method,
35
- serialized: serializeExecutionRequestInit(exec),
77
+ serialized: JSON.stringify({
78
+ calls,
79
+ fee,
80
+ authWitnesses,
81
+ hashedArguments,
82
+ nonce,
83
+ cancellable: exec.cancellable,
84
+ }),
36
85
  };
37
86
  },
38
- deserialize: (
39
- method: string,
87
+ deserialize: async (
88
+ _method: string,
40
89
  data: JSONRPCSerializedData,
41
- ): AztecWalletMethodMap['aztec_createTxExecutionRequest']['params'] => {
42
- const exec = deserializeExecutionRequestInit(data.serialized);
90
+ ): Promise<AztecWalletMethodMap['aztec_createTxExecutionRequest']['params']> => {
91
+ const parsed = JSON.parse(data.serialized);
92
+
93
+ const calls: FunctionCall[] = await Promise.all(
94
+ parsed.calls.map(async (call: SerializedFunctionCall) => {
95
+ return new FunctionCall(
96
+ call.name,
97
+ await jsonParseWithSchema(call.to, AztecAddress.schema),
98
+ await jsonParseWithSchema(call.selector, FunctionSelector.schema),
99
+ call.type as FunctionType,
100
+ call.isStatic,
101
+ await Promise.all(call.args.map(async (arg: string) => jsonParseWithSchema(arg, Fr.schema))),
102
+ await Promise.all(
103
+ call.returnTypes.map(async (t: string) => jsonParseWithSchema(t, AbiTypeSchema)),
104
+ ),
105
+ );
106
+ }),
107
+ );
108
+ const authWitnesses = parsed.authWitnesses
109
+ ? parsed.authWitnesses.map(async (w: string) => await jsonParseWithSchema(w, AuthWitness.schema))
110
+ : undefined;
111
+ const hashedArguments = parsed.hashedArguments
112
+ ? parsed.hashedArguments.map(async (h: string) => await jsonParseWithSchema(h, HashedValues.schema))
113
+ : undefined;
114
+ const cancellable = parsed.cancellable;
115
+ const nonce = parsed.nonce ? await jsonParseWithSchema(parsed.nonce, Fr.schema) : undefined;
116
+
117
+ const fee: FeeOptions = {
118
+ paymentMethod: new NoFeePaymentMethod(), // Default, caller should override
119
+ gasSettings: await jsonParseWithSchema(parsed.fee.gasSettings, GasSettings.schema),
120
+ };
121
+
122
+ const exec: ExecutionRequestInit = { calls, fee };
123
+ if (authWitnesses) exec.authWitnesses = authWitnesses;
124
+ if (hashedArguments) exec.hashedArguments = hashedArguments;
125
+ if (nonce) exec.nonce = nonce;
126
+ if (cancellable) exec.cancellable = cancellable;
127
+
43
128
  return { exec };
44
129
  },
45
130
  };
46
131
 
47
132
  result = {
48
- serialize: (method: string, value: TxExecutionRequest): JSONRPCSerializedData => {
133
+ serialize: async (method: string, value: TxExecutionRequest): Promise<JSONRPCSerializedData> => {
49
134
  return {
50
135
  method,
51
136
  serialized: jsonStringify(value),
52
137
  };
53
138
  },
54
- deserialize: (method: string, data: JSONRPCSerializedData): TxExecutionRequest => {
55
- return jsonParseWithSchema(data.serialized, TxExecutionRequest.schema);
139
+ deserialize: async (_method: string, data: JSONRPCSerializedData): Promise<TxExecutionRequest> => {
140
+ return await jsonParseWithSchema(data.serialized, TxExecutionRequest.schema);
56
141
  },
57
142
  };
58
143
  }
@@ -69,10 +154,10 @@ export class AztecProveTxSerializer
69
154
  >
70
155
  {
71
156
  params = {
72
- serialize: (
157
+ serialize: async (
73
158
  method: string,
74
159
  value: AztecWalletMethodMap['aztec_proveTx']['params'],
75
- ): JSONRPCSerializedData => {
160
+ ): Promise<JSONRPCSerializedData> => {
76
161
  const { txRequest, privateExecutionResult } = value;
77
162
  return {
78
163
  method,
@@ -82,27 +167,30 @@ export class AztecProveTxSerializer
82
167
  }),
83
168
  };
84
169
  },
85
- deserialize: (
86
- method: string,
170
+ deserialize: async (
171
+ _method: string,
87
172
  data: JSONRPCSerializedData,
88
- ): AztecWalletMethodMap['aztec_proveTx']['params'] => {
173
+ ): Promise<AztecWalletMethodMap['aztec_proveTx']['params']> => {
89
174
  const { txRequest, privateExecutionResult } = JSON.parse(data.serialized);
90
175
  return {
91
- txRequest: jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
92
- privateExecutionResult: jsonParseWithSchema(privateExecutionResult, PrivateExecutionResult.schema),
176
+ txRequest: await jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
177
+ privateExecutionResult: await jsonParseWithSchema(
178
+ privateExecutionResult,
179
+ PrivateExecutionResult.schema,
180
+ ),
93
181
  };
94
182
  },
95
183
  };
96
184
 
97
185
  result = {
98
- serialize: (method: string, value: TxProvingResult): JSONRPCSerializedData => {
186
+ serialize: async (method: string, value: TxProvingResult): Promise<JSONRPCSerializedData> => {
99
187
  return {
100
188
  method,
101
189
  serialized: jsonStringify(value),
102
190
  };
103
191
  },
104
- deserialize: (method: string, data: JSONRPCSerializedData): TxProvingResult => {
105
- return jsonParseWithSchema(data.serialized, TxProvingResult.schema);
192
+ deserialize: async (_method: string, data: JSONRPCSerializedData): Promise<TxProvingResult> => {
193
+ return await jsonParseWithSchema(data.serialized, TxProvingResult.schema);
106
194
  },
107
195
  };
108
196
  }
@@ -119,39 +207,39 @@ export class AztecSendTxSerializer
119
207
  >
120
208
  {
121
209
  params = {
122
- serialize: (
210
+ serialize: async (
123
211
  method: string,
124
212
  value: AztecWalletMethodMap['aztec_sendTx']['params'],
125
- ): JSONRPCSerializedData => {
213
+ ): Promise<JSONRPCSerializedData> => {
126
214
  const { tx } = value;
127
215
  return {
128
216
  method,
129
217
  serialized: jsonStringify(tx),
130
218
  };
131
219
  },
132
- deserialize: (
133
- method: string,
220
+ deserialize: async (
221
+ _method: string,
134
222
  data: JSONRPCSerializedData,
135
- ): AztecWalletMethodMap['aztec_sendTx']['params'] => {
136
- return { tx: jsonParseWithSchema(data.serialized, Tx.schema) };
223
+ ): Promise<AztecWalletMethodMap['aztec_sendTx']['params']> => {
224
+ return { tx: await jsonParseWithSchema(data.serialized, Tx.schema) };
137
225
  },
138
226
  };
139
227
 
140
228
  result = {
141
- serialize: (
229
+ serialize: async (
142
230
  method: string,
143
231
  value: AztecWalletMethodMap['aztec_sendTx']['result'],
144
- ): JSONRPCSerializedData => {
232
+ ): Promise<JSONRPCSerializedData> => {
145
233
  return {
146
234
  method,
147
235
  serialized: jsonStringify(value),
148
236
  };
149
237
  },
150
- deserialize: (
151
- method: string,
238
+ deserialize: async (
239
+ _method: string,
152
240
  data: JSONRPCSerializedData,
153
- ): AztecWalletMethodMap['aztec_sendTx']['result'] => {
154
- return jsonParseWithSchema(data.serialized, TxHash.schema);
241
+ ): Promise<AztecWalletMethodMap['aztec_sendTx']['result']> => {
242
+ return await jsonParseWithSchema(data.serialized, TxHash.schema);
155
243
  },
156
244
  };
157
245
  }
@@ -168,40 +256,40 @@ export class AztecGetTxEffectSerializer
168
256
  >
169
257
  {
170
258
  params = {
171
- serialize: (
259
+ serialize: async (
172
260
  method: string,
173
261
  value: AztecWalletMethodMap['aztec_getTxEffect']['params'],
174
- ): JSONRPCSerializedData => {
262
+ ): Promise<JSONRPCSerializedData> => {
175
263
  const { txHash } = value;
176
264
  return {
177
265
  method,
178
266
  serialized: jsonStringify(txHash),
179
267
  };
180
268
  },
181
- deserialize: (
182
- method: string,
269
+ deserialize: async (
270
+ _method: string,
183
271
  data: JSONRPCSerializedData,
184
- ): AztecWalletMethodMap['aztec_getTxEffect']['params'] => {
185
- const txHash = jsonParseWithSchema(data.serialized, TxHash.schema);
272
+ ): Promise<AztecWalletMethodMap['aztec_getTxEffect']['params']> => {
273
+ const txHash = await jsonParseWithSchema(data.serialized, TxHash.schema);
186
274
  return { txHash };
187
275
  },
188
276
  };
189
277
 
190
278
  result = {
191
- serialize: (
279
+ serialize: async (
192
280
  method: string,
193
281
  value: AztecWalletMethodMap['aztec_getTxEffect']['result'],
194
- ): JSONRPCSerializedData => {
282
+ ): Promise<JSONRPCSerializedData> => {
195
283
  return {
196
284
  method,
197
285
  serialized: jsonStringify(value),
198
286
  };
199
287
  },
200
- deserialize: (
201
- method: string,
288
+ deserialize: async (
289
+ _method: string,
202
290
  data: JSONRPCSerializedData,
203
- ): AztecWalletMethodMap['aztec_getTxEffect']['result'] => {
204
- return jsonParseWithSchema(data.serialized, inBlockSchemaFor(TxEffect.schema));
291
+ ): Promise<AztecWalletMethodMap['aztec_getTxEffect']['result']> => {
292
+ return await jsonParseWithSchema(data.serialized, inBlockSchemaFor(TxEffect.schema));
205
293
  },
206
294
  };
207
295
  }
@@ -218,34 +306,34 @@ export class AztecGetTxReceiptSerializer
218
306
  >
219
307
  {
220
308
  params = {
221
- serialize: (
309
+ serialize: async (
222
310
  method: string,
223
311
  value: AztecWalletMethodMap['aztec_getTxReceipt']['params'],
224
- ): JSONRPCSerializedData => {
312
+ ): Promise<JSONRPCSerializedData> => {
225
313
  const { txHash } = value;
226
314
  return {
227
315
  method,
228
316
  serialized: jsonStringify(txHash),
229
317
  };
230
318
  },
231
- deserialize: (
232
- method: string,
319
+ deserialize: async (
320
+ _method: string,
233
321
  data: JSONRPCSerializedData,
234
- ): AztecWalletMethodMap['aztec_getTxReceipt']['params'] => {
235
- const txHash = jsonParseWithSchema(data.serialized, TxHash.schema);
322
+ ): Promise<AztecWalletMethodMap['aztec_getTxReceipt']['params']> => {
323
+ const txHash = await jsonParseWithSchema(data.serialized, TxHash.schema);
236
324
  return { txHash };
237
325
  },
238
326
  };
239
327
 
240
328
  result = {
241
- serialize: (method: string, value: TxReceipt): JSONRPCSerializedData => {
329
+ serialize: async (method: string, value: TxReceipt): Promise<JSONRPCSerializedData> => {
242
330
  return {
243
331
  method,
244
332
  serialized: jsonStringify(value),
245
333
  };
246
334
  },
247
- deserialize: (method: string, data: JSONRPCSerializedData): TxReceipt => {
248
- return jsonParseWithSchema(data.serialized, TxReceipt.schema);
335
+ deserialize: async (_method: string, data: JSONRPCSerializedData): Promise<TxReceipt> => {
336
+ return await jsonParseWithSchema(data.serialized, TxReceipt.schema);
249
337
  },
250
338
  };
251
339
  }
@@ -262,10 +350,10 @@ export class AztecSimulateTxSerializer
262
350
  >
263
351
  {
264
352
  params = {
265
- serialize: (
353
+ serialize: async (
266
354
  method: string,
267
355
  value: AztecWalletMethodMap['aztec_simulateTx']['params'],
268
- ): JSONRPCSerializedData => {
356
+ ): Promise<JSONRPCSerializedData> => {
269
357
  const { txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile } = value;
270
358
  return {
271
359
  method,
@@ -279,16 +367,16 @@ export class AztecSimulateTxSerializer
279
367
  }),
280
368
  };
281
369
  },
282
- deserialize: (
283
- method: string,
370
+ deserialize: async (
371
+ _method: string,
284
372
  data: JSONRPCSerializedData,
285
- ): AztecWalletMethodMap['aztec_simulateTx']['params'] => {
373
+ ): Promise<AztecWalletMethodMap['aztec_simulateTx']['params']> => {
286
374
  const { txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile } =
287
375
  JSON.parse(data.serialized);
288
376
  return {
289
- txRequest: jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
377
+ txRequest: await jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
290
378
  simulatePublic,
291
- msgSender: jsonParseWithSchema(msgSender, AztecAddress.schema),
379
+ msgSender: await jsonParseWithSchema(msgSender, AztecAddress.schema),
292
380
  skipTxValidation,
293
381
  enforceFeePayment,
294
382
  profile,
@@ -297,14 +385,14 @@ export class AztecSimulateTxSerializer
297
385
  };
298
386
 
299
387
  result = {
300
- serialize: (method: string, value: TxSimulationResult): JSONRPCSerializedData => {
388
+ serialize: async (method: string, value: TxSimulationResult): Promise<JSONRPCSerializedData> => {
301
389
  return {
302
390
  method,
303
391
  serialized: jsonStringify(value),
304
392
  };
305
393
  },
306
- deserialize: (method: string, data: JSONRPCSerializedData): TxSimulationResult => {
307
- return jsonParseWithSchema(data.serialized, TxSimulationResult.schema);
394
+ deserialize: async (_method: string, data: JSONRPCSerializedData): Promise<TxSimulationResult> => {
395
+ return await jsonParseWithSchema(data.serialized, TxSimulationResult.schema);
308
396
  },
309
397
  };
310
398
  }
package/src/types.ts CHANGED
@@ -2,7 +2,6 @@ import type {
2
2
  AuthWitness,
3
3
  AztecAddress,
4
4
  ContractArtifact,
5
- ContractClassWithId,
6
5
  ContractInstanceWithAddress,
7
6
  ExtendedNote,
8
7
  Fr,
@@ -35,6 +34,8 @@ import type {
35
34
  TxSimulationResult,
36
35
  GetPublicLogsResponse,
37
36
  GetContractClassLogsResponse,
37
+ ContractMetadata,
38
+ ContractClassMetadata,
38
39
  } from '@aztec/circuit-types';
39
40
  import type { GasFees, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js';
40
41
  import type { JSONRPCEventMap, JSONRPCMiddleware } from '@walletmesh/jsonrpc';
@@ -213,12 +214,11 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
213
214
  /* Contracts */
214
215
 
215
216
  aztec_getContracts: { result: AztecAddress[] };
216
- aztec_getContractInstance: { params: { address: AztecAddress }; result: ContractInstanceWithAddress };
217
- aztec_getContractClass: { params: { id: Fr }; result: ContractClassWithId };
218
- aztec_getContractArtifact: { params: { id: Fr }; result: ContractArtifact };
219
- aztec_isContractClassPubliclyRegistered: { params: { id: Fr }; result: boolean };
220
- aztec_isContractPubliclyDeployed: { params: { address: AztecAddress }; result: boolean };
221
- aztec_isContractInitialized: { params: { address: AztecAddress }; result: boolean };
217
+ aztec_getContractMetadata: { params: { address: AztecAddress }; result: ContractMetadata };
218
+ aztec_getContractClassMetadata: {
219
+ params: { id: Fr; includeArtifact?: boolean };
220
+ result: ContractClassMetadata;
221
+ };
222
222
 
223
223
  /**
224
224
  * Registers a contract instance in the user's PXE.
@@ -226,7 +226,7 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
226
226
  * @returns True if registration was successful
227
227
  */
228
228
  aztec_registerContract: {
229
- params: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact };
229
+ params: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact | undefined };
230
230
  result: boolean;
231
231
  };
232
232