@walletmesh/aztec-rpc-wallet 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,7 +1,18 @@
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
2
|
-
import { AztecAddress, TxHash, Tx } from '@aztec/aztec.js';
|
3
|
-
|
4
|
-
|
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 {
|
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
|
-
|
23
|
-
const
|
24
|
-
|
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
|
34
|
-
const
|
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
|
-
|
140
|
-
)
|
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(
|
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 '
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
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';
|
6
11
|
import { TxExecutionRequest, TxReceipt, Tx, AztecAddress } from '@aztec/aztec.js';
|
12
|
+
import { serializeExecutionRequestInit, deserializeExecutionRequestInit } from './transaction-utils.js';
|
7
13
|
|
8
|
-
import {
|
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:
|
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 =
|
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:
|
51
|
+
serialized: jsonStringify(value),
|
46
52
|
};
|
47
53
|
},
|
48
|
-
deserialize: (
|
49
|
-
return
|
54
|
+
deserialize: (_method: string, data: JSONRPCSerializedData): TxExecutionRequest => {
|
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:
|
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
|
89
|
+
const { txRequest, privateExecutionResult } = JSON.parse(data.serialized);
|
84
90
|
return {
|
85
|
-
txRequest: TxExecutionRequest.
|
86
|
-
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:
|
101
|
+
serialized: jsonStringify(value),
|
97
102
|
};
|
98
103
|
},
|
99
|
-
deserialize: (
|
100
|
-
return
|
104
|
+
deserialize: (_method: string, data: JSONRPCSerializedData): TxProvingResult => {
|
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:
|
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
|
-
|
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:
|
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
|
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:
|
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 =
|
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:
|
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)
|
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:
|
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 =
|
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:
|
244
|
+
serialized: jsonStringify(value),
|
243
245
|
};
|
244
246
|
},
|
245
|
-
deserialize: (
|
246
|
-
return
|
247
|
+
deserialize: (_method: string, data: JSONRPCSerializedData): TxReceipt => {
|
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:
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
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
|
288
|
-
|
289
|
-
);
|
286
|
+
const { txRequest, simulatePublic, msgSender, skipTxValidation, enforceFeePayment, profile } =
|
287
|
+
JSON.parse(data.serialized);
|
290
288
|
return {
|
291
|
-
txRequest: TxExecutionRequest.
|
289
|
+
txRequest: jsonParseWithSchema(txRequest, TxExecutionRequest.schema),
|
292
290
|
simulatePublic,
|
293
|
-
msgSender: msgSender
|
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:
|
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
|
-
deserialize: (
|
320
|
-
|
321
|
-
decodeBase64(data.serialized),
|
322
|
-
);
|
323
|
-
return new TxSimulationResult(
|
324
|
-
SerializablePrivateExecutionResult.fromJSON(privateExecutionResult),
|
325
|
-
publicInputs,
|
326
|
-
publicOutput,
|
327
|
-
profileResult,
|
328
|
-
);
|
306
|
+
deserialize: (_method: string, data: JSONRPCSerializedData): TxSimulationResult => {
|
307
|
+
return jsonParseWithSchema(data.serialized, TxSimulationResult.schema);
|
329
308
|
},
|
330
309
|
};
|
331
310
|
}
|