@walletmesh/aztec-rpc-wallet 0.1.0 → 0.2.0
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.
- package/CHANGELOG.md +18 -0
- package/README.md +4 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/aztecRemoteWallet.d.ts +7 -6
- package/dist/aztecRemoteWallet.d.ts.map +1 -1
- package/dist/aztecRemoteWallet.js +15 -10
- package/dist/chainProvider.d.ts.map +1 -1
- package/dist/chainProvider.js +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
- package/dist/handlers/aztecAccountWallet.js +23 -23
- package/dist/handlers/transactions.d.ts.map +1 -1
- package/dist/handlers/transactions.js +11 -3
- package/dist/serializers/account.d.ts +19 -22
- package/dist/serializers/account.d.ts.map +1 -1
- package/dist/serializers/account.js +44 -45
- package/dist/serializers/contract.d.ts +11 -63
- package/dist/serializers/contract.d.ts.map +1 -1
- package/dist/serializers/contract.js +67 -153
- package/dist/serializers/index.d.ts +1 -4
- package/dist/serializers/index.d.ts.map +1 -1
- package/dist/serializers/index.js +12 -12
- package/dist/serializers/log.d.ts +38 -85
- package/dist/serializers/log.d.ts.map +1 -1
- package/dist/serializers/log.js +106 -115
- package/dist/serializers/note.d.ts +24 -27
- package/dist/serializers/note.d.ts.map +1 -1
- package/dist/serializers/note.js +67 -41
- package/dist/serializers/transaction-utils.d.ts +44 -100
- package/dist/serializers/transaction-utils.d.ts.map +1 -1
- package/dist/serializers/transaction-utils.js +89 -116
- package/dist/serializers/transaction.d.ts +15 -18
- package/dist/serializers/transaction.d.ts.map +1 -1
- package/dist/serializers/transaction.js +51 -62
- package/dist/types.d.ts +9 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +9 -9
- package/src/aztecRemoteWallet.test.ts +34 -33
- package/src/aztecRemoteWallet.ts +25 -15
- package/src/chainProvider.ts +1 -7
- package/src/errors.ts +0 -1
- package/src/handlers/aztecAccountWallet.test.ts +78 -75
- package/src/handlers/aztecAccountWallet.ts +33 -36
- package/src/handlers/transactions.ts +16 -2
- package/src/serializers/account.test.ts +18 -17
- package/src/serializers/account.ts +46 -64
- package/src/serializers/contract.test.ts +14 -16
- package/src/serializers/contract.ts +77 -171
- package/src/serializers/index.test.ts +20 -8
- package/src/serializers/index.ts +16 -32
- package/src/serializers/log.test.ts +201 -28
- package/src/serializers/log.ts +162 -153
- package/src/serializers/note.test.ts +26 -28
- package/src/serializers/note.ts +71 -48
- package/src/serializers/transaction-utils.ts +147 -210
- package/src/serializers/transaction.test.ts +190 -30
- package/src/serializers/transaction.ts +62 -83
- package/src/types.ts +10 -9
- package/tsconfig.json +1 -1
- package/vitest.config.ts +1 -1
- package/dist/serializers/contract-utils.d.ts +0 -40
- package/dist/serializers/contract-utils.d.ts.map +0 -1
- package/dist/serializers/contract-utils.js +0 -102
- package/dist/serializers/core.d.ts +0 -110
- package/dist/serializers/core.d.ts.map +0 -1
- package/dist/serializers/core.js +0 -130
- package/dist/serializers/types.d.ts +0 -49
- package/dist/serializers/types.d.ts.map +0 -1
- package/dist/serializers/types.js +0 -22
- package/src/serializers/contract-utils.ts +0 -104
- package/src/serializers/core.test.ts +0 -56
- package/src/serializers/core.ts +0 -141
- package/src/serializers/types.ts +0 -58
@@ -1,15 +1,14 @@
|
|
1
1
|
import type { AztecWalletMethodMap } from '../types.js';
|
2
|
-
import type { JSONRPCSerializedData, JSONRPCSerializer } from '
|
3
|
-
import {
|
4
|
-
import { aztecAddressSerializer, frSerializer } from './core.js';
|
5
|
-
import { SerializableContractInstance } from '@aztec/circuits.js';
|
2
|
+
import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
|
3
|
+
import { SerializableContractInstance, ContractClassWithIdSchema } from '@aztec/circuits.js';
|
6
4
|
import { ContractArtifactSchema } from '@aztec/foundation/abi';
|
7
|
-
import {
|
5
|
+
import { AztecAddress, Fr } from '@aztec/aztec.js';
|
6
|
+
import type { ContractInstanceWithAddress } from '@aztec/aztec.js';
|
7
|
+
import { jsonStringify, jsonParseWithSchema } from '@aztec/foundation/json-rpc';
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Serializer for the aztec_getContractInstance RPC method.
|
11
11
|
* Handles serialization of contract instance queries and results between JSON-RPC format and native Aztec types.
|
12
|
-
* Used to retrieve deployed contract instances by their address.
|
13
12
|
*/
|
14
13
|
export class AztecGetContractInstanceSerializer
|
15
14
|
implements
|
@@ -28,25 +27,17 @@ export class AztecGetContractInstanceSerializer
|
|
28
27
|
serialize: (
|
29
28
|
method: string,
|
30
29
|
value: AztecWalletMethodMap['aztec_getContractInstance']['params'],
|
31
|
-
): JSONRPCSerializedData => {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
serialized: encodeBase64(aztecAddressSerializer.serialize(address)),
|
36
|
-
};
|
37
|
-
},
|
38
|
-
/**
|
39
|
-
* Deserializes contract instance query parameters from RPC transport.
|
40
|
-
* @param method - The RPC method name
|
41
|
-
* @param data - The serialized address data
|
42
|
-
* @returns Deserialized query parameters
|
43
|
-
*/
|
30
|
+
): JSONRPCSerializedData => ({
|
31
|
+
method,
|
32
|
+
serialized: jsonStringify(value.address),
|
33
|
+
}),
|
44
34
|
deserialize: (
|
45
|
-
|
35
|
+
_method: string,
|
46
36
|
data: JSONRPCSerializedData,
|
47
37
|
): AztecWalletMethodMap['aztec_getContractInstance']['params'] => {
|
48
|
-
|
49
|
-
|
38
|
+
return {
|
39
|
+
address: jsonParseWithSchema(data.serialized, AztecAddress.schema),
|
40
|
+
};
|
50
41
|
},
|
51
42
|
};
|
52
43
|
|
@@ -57,37 +48,18 @@ export class AztecGetContractInstanceSerializer
|
|
57
48
|
* @param value - The contract instance data including address and state
|
58
49
|
* @returns Serialized contract instance data
|
59
50
|
*/
|
60
|
-
serialize: (
|
61
|
-
method
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
address: aztecAddressSerializer.serialize(address),
|
73
|
-
}),
|
74
|
-
),
|
75
|
-
};
|
76
|
-
},
|
77
|
-
/**
|
78
|
-
* Deserializes the contract instance query result.
|
79
|
-
* @param method - The RPC method name
|
80
|
-
* @param data - The serialized contract instance data
|
81
|
-
* @returns Deserialized contract instance
|
82
|
-
*/
|
83
|
-
deserialize: (
|
84
|
-
method: string,
|
85
|
-
data: JSONRPCSerializedData,
|
86
|
-
): AztecWalletMethodMap['aztec_getContractInstance']['result'] => {
|
87
|
-
const { instance, address } = JSON.parse(decodeBase64(data.serialized));
|
88
|
-
const baseInstance = SerializableContractInstance.fromBuffer(Buffer.from(instance, 'hex'));
|
89
|
-
const deserializedAddress = aztecAddressSerializer.deserialize(address);
|
90
|
-
return baseInstance.withAddress(deserializedAddress);
|
51
|
+
serialize: (method: string, value: ContractInstanceWithAddress): JSONRPCSerializedData => ({
|
52
|
+
method,
|
53
|
+
serialized: JSON.stringify({
|
54
|
+
serializableContractInstance: new SerializableContractInstance(value).toBuffer(),
|
55
|
+
address: jsonStringify(value.address),
|
56
|
+
}),
|
57
|
+
}),
|
58
|
+
deserialize: (_method: string, data: JSONRPCSerializedData): ContractInstanceWithAddress => {
|
59
|
+
const parsed = JSON.parse(data.serialized);
|
60
|
+
return SerializableContractInstance.fromBuffer(
|
61
|
+
Buffer.from(parsed.serializableContractInstance),
|
62
|
+
).withAddress(jsonParseWithSchema(parsed.address, AztecAddress.schema));
|
91
63
|
},
|
92
64
|
};
|
93
65
|
}
|
@@ -95,7 +67,6 @@ export class AztecGetContractInstanceSerializer
|
|
95
67
|
/**
|
96
68
|
* Serializer for the aztec_getContractClass RPC method.
|
97
69
|
* Handles serialization of contract class queries and results between JSON-RPC format and native Aztec types.
|
98
|
-
* Used to retrieve contract class definitions by their ID.
|
99
70
|
*/
|
100
71
|
export class AztecGetContractClassSerializer
|
101
72
|
implements
|
@@ -114,25 +85,18 @@ export class AztecGetContractClassSerializer
|
|
114
85
|
serialize: (
|
115
86
|
method: string,
|
116
87
|
value: AztecWalletMethodMap['aztec_getContractClass']['params'],
|
117
|
-
): JSONRPCSerializedData => {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
},
|
124
|
-
/**
|
125
|
-
* Deserializes contract class query parameters from RPC transport.
|
126
|
-
* @param method - The RPC method name
|
127
|
-
* @param data - The serialized class ID data
|
128
|
-
* @returns Deserialized query parameters
|
129
|
-
*/
|
88
|
+
): JSONRPCSerializedData => ({
|
89
|
+
method,
|
90
|
+
serialized: JSON.stringify({
|
91
|
+
id: value.id.toString(),
|
92
|
+
}),
|
93
|
+
}),
|
130
94
|
deserialize: (
|
131
|
-
|
95
|
+
_method: string,
|
132
96
|
data: JSONRPCSerializedData,
|
133
97
|
): AztecWalletMethodMap['aztec_getContractClass']['params'] => {
|
134
|
-
const id =
|
135
|
-
return { id };
|
98
|
+
const { id } = JSON.parse(data.serialized);
|
99
|
+
return { id: Fr.fromString(id) };
|
136
100
|
},
|
137
101
|
};
|
138
102
|
|
@@ -146,25 +110,16 @@ export class AztecGetContractClassSerializer
|
|
146
110
|
serialize: (
|
147
111
|
method: string,
|
148
112
|
value: AztecWalletMethodMap['aztec_getContractClass']['result'],
|
149
|
-
): JSONRPCSerializedData => {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
serialized: encodeBase64(JSON.stringify(serialized)),
|
154
|
-
};
|
155
|
-
},
|
156
|
-
/**
|
157
|
-
* Deserializes the contract class query result.
|
158
|
-
* @param method - The RPC method name
|
159
|
-
* @param data - The serialized contract class data
|
160
|
-
* @returns Deserialized contract class with ID
|
161
|
-
*/
|
113
|
+
): JSONRPCSerializedData => ({
|
114
|
+
method,
|
115
|
+
serialized: JSON.stringify(value),
|
116
|
+
}),
|
162
117
|
deserialize: (
|
163
|
-
|
118
|
+
_method: string,
|
164
119
|
data: JSONRPCSerializedData,
|
165
120
|
): AztecWalletMethodMap['aztec_getContractClass']['result'] => {
|
166
|
-
const parsed = JSON.parse(
|
167
|
-
return
|
121
|
+
const parsed = JSON.parse(data.serialized);
|
122
|
+
return ContractClassWithIdSchema.parse(parsed);
|
168
123
|
},
|
169
124
|
};
|
170
125
|
}
|
@@ -172,7 +127,6 @@ export class AztecGetContractClassSerializer
|
|
172
127
|
/**
|
173
128
|
* Serializer for the aztec_getContractArtifact RPC method.
|
174
129
|
* Handles serialization of contract artifact queries and results between JSON-RPC format and native Aztec types.
|
175
|
-
* Used to retrieve contract artifacts (ABI, bytecode, etc.) by their ID.
|
176
130
|
*/
|
177
131
|
export class AztecGetContractArtifactSerializer
|
178
132
|
implements
|
@@ -191,25 +145,18 @@ export class AztecGetContractArtifactSerializer
|
|
191
145
|
serialize: (
|
192
146
|
method: string,
|
193
147
|
value: AztecWalletMethodMap['aztec_getContractArtifact']['params'],
|
194
|
-
): JSONRPCSerializedData => {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
},
|
201
|
-
/**
|
202
|
-
* Deserializes contract artifact query parameters from RPC transport.
|
203
|
-
* @param method - The RPC method name
|
204
|
-
* @param data - The serialized artifact ID data
|
205
|
-
* @returns Deserialized query parameters
|
206
|
-
*/
|
148
|
+
): JSONRPCSerializedData => ({
|
149
|
+
method,
|
150
|
+
serialized: JSON.stringify({
|
151
|
+
id: value.id.toString(),
|
152
|
+
}),
|
153
|
+
}),
|
207
154
|
deserialize: (
|
208
|
-
|
155
|
+
_method: string,
|
209
156
|
data: JSONRPCSerializedData,
|
210
157
|
): AztecWalletMethodMap['aztec_getContractArtifact']['params'] => {
|
211
|
-
const id =
|
212
|
-
return { id };
|
158
|
+
const { id } = JSON.parse(data.serialized);
|
159
|
+
return { id: Fr.fromString(id) };
|
213
160
|
},
|
214
161
|
};
|
215
162
|
|
@@ -223,32 +170,21 @@ export class AztecGetContractArtifactSerializer
|
|
223
170
|
serialize: (
|
224
171
|
method: string,
|
225
172
|
value: AztecWalletMethodMap['aztec_getContractArtifact']['result'],
|
226
|
-
): JSONRPCSerializedData => {
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
};
|
231
|
-
},
|
232
|
-
/**
|
233
|
-
* Deserializes the contract artifact query result.
|
234
|
-
* @param method - The RPC method name
|
235
|
-
* @param data - The serialized artifact data
|
236
|
-
* @returns Deserialized contract artifact
|
237
|
-
* @throws If the data doesn't match the contract artifact schema
|
238
|
-
*/
|
173
|
+
): JSONRPCSerializedData => ({
|
174
|
+
method,
|
175
|
+
serialized: JSON.stringify(ContractArtifactSchema.parse(value)),
|
176
|
+
}),
|
239
177
|
deserialize: (
|
240
|
-
|
178
|
+
_method: string,
|
241
179
|
data: JSONRPCSerializedData,
|
242
|
-
): AztecWalletMethodMap['aztec_getContractArtifact']['result'] =>
|
243
|
-
|
244
|
-
},
|
180
|
+
): AztecWalletMethodMap['aztec_getContractArtifact']['result'] =>
|
181
|
+
ContractArtifactSchema.parse(JSON.parse(data.serialized)),
|
245
182
|
};
|
246
183
|
}
|
247
184
|
|
248
185
|
/**
|
249
186
|
* Serializer for the aztec_registerContract RPC method.
|
250
187
|
* Handles serialization of contract registration requests between JSON-RPC format and native Aztec types.
|
251
|
-
* Used to register new contract instances with optional artifacts.
|
252
188
|
*/
|
253
189
|
export class AztecRegisterContractSerializer
|
254
190
|
implements
|
@@ -267,44 +203,24 @@ export class AztecRegisterContractSerializer
|
|
267
203
|
serialize: (
|
268
204
|
method: string,
|
269
205
|
value: AztecWalletMethodMap['aztec_registerContract']['params'],
|
270
|
-
): JSONRPCSerializedData => {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
const serializedArtifact = artifact ? JSON.stringify(artifact) : undefined;
|
280
|
-
|
281
|
-
return {
|
282
|
-
method,
|
283
|
-
serialized: encodeBase64(
|
284
|
-
JSON.stringify({
|
285
|
-
instance: serializedInstance,
|
286
|
-
artifact: serializedArtifact,
|
287
|
-
}),
|
288
|
-
),
|
289
|
-
};
|
290
|
-
},
|
291
|
-
/**
|
292
|
-
* Deserializes contract registration parameters from RPC transport.
|
293
|
-
* @param method - The RPC method name
|
294
|
-
* @param data - The serialized registration data
|
295
|
-
* @returns Deserialized registration parameters
|
296
|
-
*/
|
206
|
+
): JSONRPCSerializedData => ({
|
207
|
+
method,
|
208
|
+
serialized: JSON.stringify({
|
209
|
+
serializableContractInstance: new SerializableContractInstance(value.instance).toBuffer(),
|
210
|
+
address: value.instance.address.toString(),
|
211
|
+
artifact: value.artifact ? ContractArtifactSchema.parse(value.artifact) : undefined,
|
212
|
+
}),
|
213
|
+
}),
|
297
214
|
deserialize: (
|
298
|
-
|
215
|
+
_method: string,
|
299
216
|
data: JSONRPCSerializedData,
|
300
217
|
): AztecWalletMethodMap['aztec_registerContract']['params'] => {
|
301
|
-
const {
|
302
|
-
const { instance: instanceBuffer, address } = instance;
|
303
|
-
const baseInstance = SerializableContractInstance.fromBuffer(Buffer.from(instanceBuffer, 'base64'));
|
304
|
-
const deserializedAddress = aztecAddressSerializer.deserialize(address);
|
218
|
+
const { serializableContractInstance, address, artifact } = JSON.parse(data.serialized);
|
305
219
|
return {
|
306
|
-
instance:
|
307
|
-
|
220
|
+
instance: SerializableContractInstance.fromBuffer(
|
221
|
+
Buffer.from(serializableContractInstance),
|
222
|
+
).withAddress(AztecAddress.fromString(address)),
|
223
|
+
artifact: artifact ? ContractArtifactSchema.parse(artifact) : undefined,
|
308
224
|
};
|
309
225
|
},
|
310
226
|
};
|
@@ -319,24 +235,14 @@ export class AztecRegisterContractSerializer
|
|
319
235
|
serialize: (
|
320
236
|
method: string,
|
321
237
|
value: AztecWalletMethodMap['aztec_registerContract']['result'],
|
322
|
-
): JSONRPCSerializedData => {
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
};
|
327
|
-
},
|
328
|
-
/**
|
329
|
-
* Deserializes the contract registration result.
|
330
|
-
* @param method - The RPC method name
|
331
|
-
* @param data - The serialized result data
|
332
|
-
* @returns Boolean indicating success
|
333
|
-
*/
|
238
|
+
): JSONRPCSerializedData => ({
|
239
|
+
method,
|
240
|
+
serialized: JSON.stringify(value),
|
241
|
+
}),
|
334
242
|
deserialize: (
|
335
|
-
|
243
|
+
_method: string,
|
336
244
|
data: JSONRPCSerializedData,
|
337
|
-
): AztecWalletMethodMap['aztec_registerContract']['result'] =>
|
338
|
-
return JSON.parse(decodeBase64(data.serialized));
|
339
|
-
},
|
245
|
+
): AztecWalletMethodMap['aztec_registerContract']['result'] => JSON.parse(data.serialized),
|
340
246
|
};
|
341
247
|
}
|
342
248
|
|
@@ -2,6 +2,7 @@ import { describe, expect, it, beforeEach, vi } from 'vitest';
|
|
2
2
|
import { AztecWalletSerializer } from './index.js';
|
3
3
|
import { AztecAddress, Tx } from '@aztec/aztec.js';
|
4
4
|
import type { JSONRPCSerializer } from './types.js';
|
5
|
+
import type { AztecWalletMethodMap } from '../types.js';
|
5
6
|
|
6
7
|
describe('AztecWalletSerializer', () => {
|
7
8
|
// Test known method (using aztec_setScopes as an example)
|
@@ -14,8 +15,8 @@ describe('AztecWalletSerializer', () => {
|
|
14
15
|
const resultSerializer = (AztecWalletSerializer as Required<JSONRPCSerializer<unknown, unknown>>).result;
|
15
16
|
|
16
17
|
describe('params', () => {
|
17
|
-
it('should serialize params for known methods', () => {
|
18
|
-
const params = { scopes: [AztecAddress.random()] };
|
18
|
+
it('should serialize params for known methods', async () => {
|
19
|
+
const params = { scopes: [await AztecAddress.random()] };
|
19
20
|
const result = AztecWalletSerializer.params.serialize(knownMethod, params);
|
20
21
|
expect(result).toBeDefined();
|
21
22
|
expect(result.method).toBe(knownMethod);
|
@@ -97,26 +98,37 @@ describe('AztecWalletSerializer', () => {
|
|
97
98
|
});
|
98
99
|
|
99
100
|
describe('integration', () => {
|
100
|
-
it('should handle contract methods', () => {
|
101
|
+
it('should handle contract methods', async () => {
|
101
102
|
const method = 'aztec_getContractInstance';
|
102
|
-
const params = { address: AztecAddress.random() };
|
103
|
+
const params = { address: await AztecAddress.random() };
|
103
104
|
|
104
105
|
const serializedParams = AztecWalletSerializer.params.serialize(method, params);
|
105
106
|
expect(serializedParams).toBeDefined();
|
106
107
|
expect(serializedParams.method).toBe(method);
|
107
108
|
expect(typeof serializedParams.serialized).toBe('string');
|
109
|
+
|
110
|
+
const deserializedParams = AztecWalletSerializer.params.deserialize(
|
111
|
+
method,
|
112
|
+
serializedParams,
|
113
|
+
) as AztecWalletMethodMap['aztec_getContractInstance']['params'];
|
114
|
+
expect(deserializedParams.address.toString()).toBe(params.address.toString());
|
108
115
|
});
|
109
116
|
|
110
|
-
it('should handle transaction methods', () => {
|
117
|
+
it('should handle transaction methods', async () => {
|
111
118
|
const method = 'aztec_sendTx';
|
112
|
-
const
|
113
|
-
|
114
|
-
};
|
119
|
+
const tx = await Tx.random();
|
120
|
+
const params = { tx };
|
115
121
|
|
116
122
|
const serializedParams = AztecWalletSerializer.params.serialize(method, params);
|
117
123
|
expect(serializedParams).toBeDefined();
|
118
124
|
expect(serializedParams.method).toBe(method);
|
119
125
|
expect(typeof serializedParams.serialized).toBe('string');
|
126
|
+
|
127
|
+
const deserializedParams = AztecWalletSerializer.params.deserialize(
|
128
|
+
method,
|
129
|
+
serializedParams,
|
130
|
+
) as AztecWalletMethodMap['aztec_sendTx']['params'];
|
131
|
+
expect(deserializedParams.tx.toBuffer().toString('hex')).toBe(tx.toBuffer().toString('hex'));
|
120
132
|
});
|
121
133
|
});
|
122
134
|
});
|
package/src/serializers/index.ts
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
import type { AztecWalletMethodMap } from '../types.js';
|
2
|
-
import type {
|
3
|
-
import { encodeBase64 } from './types.js';
|
2
|
+
import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
|
4
3
|
|
5
4
|
/**
|
6
5
|
* Re-export all serializer types and implementations.
|
7
6
|
* This provides a single entry point for importing any serializer functionality.
|
8
7
|
*/
|
9
|
-
export * from './types.js';
|
10
|
-
export * from './core.js';
|
11
8
|
export * from './account.js';
|
12
9
|
export * from './contract.js';
|
13
10
|
export * from './transaction.js';
|
@@ -32,16 +29,15 @@ import {
|
|
32
29
|
aztecProveTxSerializer,
|
33
30
|
aztecSendTxSerializer,
|
34
31
|
aztecGetTxReceiptSerializer,
|
32
|
+
aztecGetTxEffectSerializer,
|
33
|
+
aztecSimulateTxSerializer,
|
35
34
|
} from './transaction.js';
|
35
|
+
import { aztecGetNotesSerializer, aztecAddNoteSerializer, aztecAddNullifiedNoteSerializer } from './note.js';
|
36
36
|
import {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
import {
|
42
|
-
aztecGetUnencryptedLogsSerializer,
|
43
|
-
aztecGetEncryptedEventsSerializer,
|
44
|
-
aztecGetUnencryptedEventsSerializer,
|
37
|
+
aztecGetPublicLogsSerializer,
|
38
|
+
aztecGetContractClassLogsSerializer,
|
39
|
+
aztecGetPrivateEventsSerializer,
|
40
|
+
aztecGetPublicEventsSerializer,
|
45
41
|
} from './log.js';
|
46
42
|
|
47
43
|
/**
|
@@ -50,18 +46,6 @@ import {
|
|
50
46
|
*/
|
51
47
|
type AztecMethodName = keyof AztecWalletMethodMap;
|
52
48
|
|
53
|
-
/**
|
54
|
-
* Type helper for extracting parameter types for a given method.
|
55
|
-
* @typeParam T - The method name to get parameters for
|
56
|
-
*/
|
57
|
-
type AztecMethodParams<T extends AztecMethodName> = AztecWalletMethodMap[T]['params'];
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Type helper for extracting result types for a given method.
|
61
|
-
* @typeParam T - The method name to get result type for
|
62
|
-
*/
|
63
|
-
type AztecMethodResult<T extends AztecMethodName> = AztecWalletMethodMap[T]['result'];
|
64
|
-
|
65
49
|
/**
|
66
50
|
* Registry of all available method serializers.
|
67
51
|
* Maps each RPC method name to its corresponding serializer implementation.
|
@@ -86,16 +70,19 @@ const methodSerializers: Record<AztecMethodName, JSONRPCSerializer<unknown, unkn
|
|
86
70
|
aztec_proveTx: aztecProveTxSerializer,
|
87
71
|
aztec_sendTx: aztecSendTxSerializer,
|
88
72
|
aztec_getTxReceipt: aztecGetTxReceiptSerializer,
|
73
|
+
aztec_getTxEffect: aztecGetTxEffectSerializer,
|
74
|
+
aztec_simulateTx: aztecSimulateTxSerializer,
|
89
75
|
|
90
76
|
// Note methods
|
91
|
-
|
77
|
+
aztec_getNotes: aztecGetNotesSerializer,
|
92
78
|
aztec_addNote: aztecAddNoteSerializer,
|
93
79
|
aztec_addNullifiedNote: aztecAddNullifiedNoteSerializer,
|
94
80
|
|
95
81
|
// Log methods
|
96
|
-
|
97
|
-
|
98
|
-
|
82
|
+
aztec_getPublicLogs: aztecGetPublicLogsSerializer,
|
83
|
+
aztec_getContractClassLogs: aztecGetContractClassLogsSerializer,
|
84
|
+
aztec_getPrivateEvents: aztecGetPrivateEventsSerializer,
|
85
|
+
aztec_getPublicEvents: aztecGetPublicEventsSerializer,
|
99
86
|
};
|
100
87
|
|
101
88
|
/**
|
@@ -109,7 +96,7 @@ const methodSerializers: Record<AztecMethodName, JSONRPCSerializer<unknown, unkn
|
|
109
96
|
function wrapUnknownValue(method: string, value: unknown): JSONRPCSerializedData {
|
110
97
|
return {
|
111
98
|
method,
|
112
|
-
serialized:
|
99
|
+
serialized: JSON.stringify(value),
|
113
100
|
};
|
114
101
|
}
|
115
102
|
|
@@ -208,6 +195,3 @@ export const AztecWalletSerializer: JSONRPCSerializer<unknown, unknown> = {
|
|
208
195
|
},
|
209
196
|
},
|
210
197
|
};
|
211
|
-
|
212
|
-
// Export the main serializer interface
|
213
|
-
export type { JSONRPCSerializer } from './types.js';
|