@walletmesh/aztec-rpc-wallet 0.1.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 +7 -0
- package/LICENSE +201 -0
- package/README.md +260 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/aztecRemoteWallet.d.ts +73 -0
- package/dist/aztecRemoteWallet.d.ts.map +1 -0
- package/dist/aztecRemoteWallet.js +354 -0
- package/dist/chainProvider.d.ts +56 -0
- package/dist/chainProvider.d.ts.map +1 -0
- package/dist/chainProvider.js +98 -0
- package/dist/contractArtifactCache.d.ts +50 -0
- package/dist/contractArtifactCache.d.ts.map +1 -0
- package/dist/contractArtifactCache.js +66 -0
- package/dist/errors.d.ts +50 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +62 -0
- package/dist/handlers/aztecAccountWallet.d.ts +4 -0
- package/dist/handlers/aztecAccountWallet.d.ts.map +1 -0
- package/dist/handlers/aztecAccountWallet.js +329 -0
- package/dist/handlers/transactions.d.ts +21 -0
- package/dist/handlers/transactions.d.ts.map +1 -0
- package/dist/handlers/transactions.js +90 -0
- package/dist/handlers.d.ts +27 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +55 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/provider.d.ts +105 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +160 -0
- package/dist/serializers/account.d.ts +167 -0
- package/dist/serializers/account.d.ts.map +1 -0
- package/dist/serializers/account.js +245 -0
- package/dist/serializers/contract-utils.d.ts +40 -0
- package/dist/serializers/contract-utils.d.ts.map +1 -0
- package/dist/serializers/contract-utils.js +102 -0
- package/dist/serializers/contract.d.ts +168 -0
- package/dist/serializers/contract.d.ts.map +1 -0
- package/dist/serializers/contract.js +268 -0
- package/dist/serializers/core.d.ts +110 -0
- package/dist/serializers/core.d.ts.map +1 -0
- package/dist/serializers/core.js +130 -0
- package/dist/serializers/index.d.ts +28 -0
- package/dist/serializers/index.d.ts.map +1 -0
- package/dist/serializers/index.js +159 -0
- package/dist/serializers/log.d.ts +113 -0
- package/dist/serializers/log.d.ts.map +1 -0
- package/dist/serializers/log.js +231 -0
- package/dist/serializers/note.d.ts +127 -0
- package/dist/serializers/note.d.ts.map +1 -0
- package/dist/serializers/note.js +182 -0
- package/dist/serializers/transaction-utils.d.ts +107 -0
- package/dist/serializers/transaction-utils.d.ts.map +1 -0
- package/dist/serializers/transaction-utils.js +130 -0
- package/dist/serializers/transaction.d.ts +103 -0
- package/dist/serializers/transaction.d.ts.map +1 -0
- package/dist/serializers/transaction.js +238 -0
- package/dist/serializers/types.d.ts +49 -0
- package/dist/serializers/types.d.ts.map +1 -0
- package/dist/serializers/types.js +22 -0
- package/dist/types.d.ts +391 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/wallet.d.ts +62 -0
- package/dist/wallet.d.ts.map +1 -0
- package/dist/wallet.js +77 -0
- package/package.json +44 -0
- package/src/aztecRemoteWallet.test.ts +542 -0
- package/src/aztecRemoteWallet.ts +484 -0
- package/src/chainProvider.test.ts +322 -0
- package/src/chainProvider.ts +122 -0
- package/src/contractArtifactCache.test.ts +126 -0
- package/src/contractArtifactCache.ts +75 -0
- package/src/errors.ts +71 -0
- package/src/handlers/aztecAccountWallet.test.ts +720 -0
- package/src/handlers/aztecAccountWallet.ts +593 -0
- package/src/handlers/transactions.ts +110 -0
- package/src/handlers.test.ts +270 -0
- package/src/handlers.ts +70 -0
- package/src/index.test.ts +23 -0
- package/src/index.ts +64 -0
- package/src/provider.test.ts +276 -0
- package/src/provider.ts +189 -0
- package/src/serializers/account.test.ts +125 -0
- package/src/serializers/account.ts +319 -0
- package/src/serializers/contract-utils.ts +104 -0
- package/src/serializers/contract.test.ts +162 -0
- package/src/serializers/contract.ts +350 -0
- package/src/serializers/core.test.ts +56 -0
- package/src/serializers/core.ts +141 -0
- package/src/serializers/index.test.ts +122 -0
- package/src/serializers/index.ts +213 -0
- package/src/serializers/log.test.ts +119 -0
- package/src/serializers/log.ts +283 -0
- package/src/serializers/note.test.ts +100 -0
- package/src/serializers/note.ts +227 -0
- package/src/serializers/transaction-utils.ts +237 -0
- package/src/serializers/transaction.test.ts +153 -0
- package/src/serializers/transaction.ts +342 -0
- package/src/serializers/types.ts +58 -0
- package/src/types.ts +295 -0
- package/src/wallet.test.ts +275 -0
- package/src/wallet.ts +94 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.json +11 -0
- package/typedoc.json +15 -0
- package/vitest.config.ts +10 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
import { PrivateExecutionResult, TxProvingResult } from '@aztec/circuit-types';
|
2
|
+
import type {
|
3
|
+
CountedContractClassLog,
|
4
|
+
CountedPublicExecutionRequest,
|
5
|
+
NoteAndSlot,
|
6
|
+
PublicExecutionRequest,
|
7
|
+
} from '@aztec/circuit-types';
|
8
|
+
import type {
|
9
|
+
ClientIvcProof,
|
10
|
+
PrivateCircuitPublicInputs,
|
11
|
+
PrivateKernelTailCircuitPublicInputs,
|
12
|
+
} from '@aztec/circuits.js';
|
13
|
+
import { Fr } from '@aztec/aztec.js';
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Interface representing the serialized form of a private execution result.
|
17
|
+
* Contains all data needed to reconstruct a PrivateExecutionResult instance.
|
18
|
+
*/
|
19
|
+
interface SerializedPrivateExecutionResultData {
|
20
|
+
acir: string;
|
21
|
+
vk: string;
|
22
|
+
partialWitness: [number, string][];
|
23
|
+
publicInputs: PrivateCircuitPublicInputs;
|
24
|
+
noteHashLeafIndexMap: [string, string][];
|
25
|
+
newNotes: NoteAndSlot[];
|
26
|
+
noteHashNullifierCounterMap: [number, number][];
|
27
|
+
returnValues: string[];
|
28
|
+
nestedExecutions: SerializedPrivateExecutionResultData[];
|
29
|
+
enqueuedPublicFunctionCalls: CountedPublicExecutionRequest[];
|
30
|
+
publicTeardownFunctionCall: PublicExecutionRequest;
|
31
|
+
contractClassLogs: CountedContractClassLog[];
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Extends PrivateExecutionResult to add serialization capabilities.
|
36
|
+
* Provides methods to convert private execution results to/from JSON format for RPC transport.
|
37
|
+
*/
|
38
|
+
export class SerializablePrivateExecutionResult extends PrivateExecutionResult {
|
39
|
+
/**
|
40
|
+
* Creates a SerializablePrivateExecutionResult from a PrivateExecutionResult instance.
|
41
|
+
* @param result - The PrivateExecutionResult to convert
|
42
|
+
* @returns A new SerializablePrivateExecutionResult instance
|
43
|
+
*/
|
44
|
+
static from(result: PrivateExecutionResult): SerializablePrivateExecutionResult {
|
45
|
+
return new SerializablePrivateExecutionResult(
|
46
|
+
result.acir,
|
47
|
+
result.vk,
|
48
|
+
result.partialWitness,
|
49
|
+
result.publicInputs,
|
50
|
+
result.noteHashLeafIndexMap,
|
51
|
+
result.newNotes,
|
52
|
+
result.noteHashNullifierCounterMap,
|
53
|
+
result.returnValues,
|
54
|
+
result.nestedExecutions,
|
55
|
+
result.enqueuedPublicFunctionCalls,
|
56
|
+
result.publicTeardownFunctionCall,
|
57
|
+
result.contractClassLogs,
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Converts the execution result to a JSON-serializable format.
|
63
|
+
* Handles conversion of complex types like Buffers, Maps, and nested execution results.
|
64
|
+
* @returns The serialized execution result data
|
65
|
+
*/
|
66
|
+
toJSON(): SerializedPrivateExecutionResultData {
|
67
|
+
return {
|
68
|
+
acir: this.acir.toString('base64'),
|
69
|
+
vk: this.vk.toString('base64'),
|
70
|
+
partialWitness: Array.from(this.partialWitness.entries()),
|
71
|
+
publicInputs: this.publicInputs,
|
72
|
+
noteHashLeafIndexMap: Array.from(this.noteHashLeafIndexMap.entries()).map(([k, v]) => [
|
73
|
+
k.toString(),
|
74
|
+
v.toString(),
|
75
|
+
]),
|
76
|
+
newNotes: this.newNotes,
|
77
|
+
noteHashNullifierCounterMap: Array.from(this.noteHashNullifierCounterMap.entries()),
|
78
|
+
returnValues: this.returnValues.map((fr: Fr) => fr.toString()),
|
79
|
+
nestedExecutions: this.nestedExecutions.map((exec: PrivateExecutionResult) =>
|
80
|
+
exec instanceof SerializablePrivateExecutionResult
|
81
|
+
? exec.toJSON()
|
82
|
+
: new SerializablePrivateExecutionResult(
|
83
|
+
exec.acir,
|
84
|
+
exec.vk,
|
85
|
+
exec.partialWitness,
|
86
|
+
exec.publicInputs,
|
87
|
+
exec.noteHashLeafIndexMap,
|
88
|
+
exec.newNotes,
|
89
|
+
exec.noteHashNullifierCounterMap,
|
90
|
+
exec.returnValues,
|
91
|
+
exec.nestedExecutions,
|
92
|
+
exec.enqueuedPublicFunctionCalls,
|
93
|
+
exec.publicTeardownFunctionCall,
|
94
|
+
exec.contractClassLogs,
|
95
|
+
).toJSON(),
|
96
|
+
),
|
97
|
+
enqueuedPublicFunctionCalls: this.enqueuedPublicFunctionCalls,
|
98
|
+
publicTeardownFunctionCall: this.publicTeardownFunctionCall,
|
99
|
+
contractClassLogs: this.contractClassLogs,
|
100
|
+
};
|
101
|
+
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Creates a SerializablePrivateExecutionResult from JSON data.
|
105
|
+
* @param json - JSON string or pre-parsed data object
|
106
|
+
* @returns A new SerializablePrivateExecutionResult instance
|
107
|
+
*/
|
108
|
+
static fromJSON(json: string | SerializedPrivateExecutionResultData): SerializablePrivateExecutionResult {
|
109
|
+
const data: SerializedPrivateExecutionResultData = typeof json === 'string' ? JSON.parse(json) : json;
|
110
|
+
|
111
|
+
return new SerializablePrivateExecutionResult(
|
112
|
+
Buffer.from(data.acir, 'base64'),
|
113
|
+
Buffer.from(data.vk, 'base64'),
|
114
|
+
new Map(data.partialWitness),
|
115
|
+
data.publicInputs,
|
116
|
+
new Map(data.noteHashLeafIndexMap.map(([k, v]) => [BigInt(k), BigInt(v)])),
|
117
|
+
data.newNotes,
|
118
|
+
new Map(data.noteHashNullifierCounterMap),
|
119
|
+
data.returnValues.map((str: string) => Fr.fromString(str)),
|
120
|
+
data.nestedExecutions.map((exec: SerializedPrivateExecutionResultData) =>
|
121
|
+
SerializablePrivateExecutionResult.fromJSON(exec),
|
122
|
+
),
|
123
|
+
data.enqueuedPublicFunctionCalls,
|
124
|
+
data.publicTeardownFunctionCall,
|
125
|
+
data.contractClassLogs,
|
126
|
+
);
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Compares this execution result with another for equality.
|
131
|
+
* @param other - The execution result to compare against
|
132
|
+
* @returns True if the execution results are equivalent
|
133
|
+
*/
|
134
|
+
equals(other: PrivateExecutionResult): boolean {
|
135
|
+
const thisJson = JSON.stringify(SerializablePrivateExecutionResult.from(this).toJSON());
|
136
|
+
const otherJson = JSON.stringify(SerializablePrivateExecutionResult.from(other).toJSON());
|
137
|
+
return thisJson === otherJson;
|
138
|
+
}
|
139
|
+
|
140
|
+
toComparable(): SerializedPrivateExecutionResultData {
|
141
|
+
return JSON.parse(JSON.stringify(this.toJSON()));
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Interface representing the serialized form of a transaction proving result.
|
147
|
+
* Contains the private execution result, public inputs, and client IVC proof.
|
148
|
+
*/
|
149
|
+
interface SerializedTxProvingResultData {
|
150
|
+
privateExecutionResult: ReturnType<SerializablePrivateExecutionResult['toJSON']>;
|
151
|
+
publicInputs: PrivateKernelTailCircuitPublicInputs;
|
152
|
+
clientIvcProof: ClientIvcProof;
|
153
|
+
}
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Extends TxProvingResult to add serialization capabilities.
|
157
|
+
* Provides methods to convert transaction proving results to/from JSON format for RPC transport.
|
158
|
+
*/
|
159
|
+
export class SerializableTxProvingResult extends TxProvingResult {
|
160
|
+
/**
|
161
|
+
* Creates a SerializableTxProvingResult from a TxProvingResult instance.
|
162
|
+
* @param result - The TxProvingResult to convert
|
163
|
+
* @returns A new SerializableTxProvingResult instance
|
164
|
+
*/
|
165
|
+
static from(result: TxProvingResult): SerializableTxProvingResult {
|
166
|
+
return new SerializableTxProvingResult(
|
167
|
+
result.privateExecutionResult,
|
168
|
+
result.publicInputs,
|
169
|
+
result.clientIvcProof,
|
170
|
+
);
|
171
|
+
}
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Converts the proving result to a JSON-serializable format.
|
175
|
+
* @returns The serialized proving result data
|
176
|
+
*/
|
177
|
+
toJSON(): SerializedTxProvingResultData {
|
178
|
+
return {
|
179
|
+
privateExecutionResult: SerializablePrivateExecutionResult.from(this.privateExecutionResult).toJSON(),
|
180
|
+
publicInputs: this.publicInputs,
|
181
|
+
clientIvcProof: this.clientIvcProof,
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Creates a SerializableTxProvingResult from JSON data.
|
187
|
+
* @param json - JSON string or pre-parsed data object
|
188
|
+
* @returns A new SerializableTxProvingResult instance
|
189
|
+
*/
|
190
|
+
static fromJSON(json: string | SerializedTxProvingResultData): SerializableTxProvingResult {
|
191
|
+
const data: SerializedTxProvingResultData = typeof json === 'string' ? JSON.parse(json) : json;
|
192
|
+
|
193
|
+
return new SerializableTxProvingResult(
|
194
|
+
SerializablePrivateExecutionResult.fromJSON(data.privateExecutionResult),
|
195
|
+
data.publicInputs,
|
196
|
+
data.clientIvcProof,
|
197
|
+
);
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Compares this proving result with another for equality.
|
202
|
+
* @param other - The proving result to compare against
|
203
|
+
* @returns True if the proving results are equivalent
|
204
|
+
*/
|
205
|
+
equals(other: TxProvingResult): boolean {
|
206
|
+
const thisJson = JSON.stringify(SerializableTxProvingResult.from(this).toJSON());
|
207
|
+
const otherJson = JSON.stringify(SerializableTxProvingResult.from(other).toJSON());
|
208
|
+
return thisJson === otherJson;
|
209
|
+
}
|
210
|
+
|
211
|
+
toComparable(): SerializedTxProvingResultData {
|
212
|
+
return JSON.parse(JSON.stringify(this.toJSON()));
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Utility function to compare two PrivateExecutionResult instances for equality.
|
218
|
+
* @param a - First execution result
|
219
|
+
* @param b - Second execution result
|
220
|
+
* @returns True if the execution results are equivalent
|
221
|
+
*/
|
222
|
+
export function comparePrivateExecutionResults(
|
223
|
+
a: PrivateExecutionResult,
|
224
|
+
b: PrivateExecutionResult,
|
225
|
+
): boolean {
|
226
|
+
return SerializablePrivateExecutionResult.from(a).equals(b);
|
227
|
+
}
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Utility function to compare two TxProvingResult instances for equality.
|
231
|
+
* @param a - First proving result
|
232
|
+
* @param b - Second proving result
|
233
|
+
* @returns True if the proving results are equivalent
|
234
|
+
*/
|
235
|
+
export function compareTxProvingResults(a: TxProvingResult, b: TxProvingResult): boolean {
|
236
|
+
return SerializableTxProvingResult.from(a).equals(b);
|
237
|
+
}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
2
|
+
import { AztecAddress, TxHash, Tx } from '@aztec/aztec.js';
|
3
|
+
|
4
|
+
import { PrivateExecutionResult, TxProvingResult } from '@aztec/circuit-types';
|
5
|
+
import {
|
6
|
+
aztecCreateTxExecutionRequestSerializer,
|
7
|
+
aztecSendTxSerializer,
|
8
|
+
aztecGetTxEffectSerializer,
|
9
|
+
aztecGetTxReceiptSerializer,
|
10
|
+
aztecSimulateTxSerializer,
|
11
|
+
aztecProveTxSerializer,
|
12
|
+
} from './transaction.js';
|
13
|
+
import { TxExecutionRequest } from '@aztec/aztec.js';
|
14
|
+
|
15
|
+
import { comparePrivateExecutionResults, compareTxProvingResults } from './transaction-utils.js';
|
16
|
+
|
17
|
+
describe('Transaction Serializers', () => {
|
18
|
+
describe('aztec_createTxExecutionRequest', () => {
|
19
|
+
const METHOD = 'aztec_createTxExecutionRequest';
|
20
|
+
|
21
|
+
it('should serialize and deserialize params', () => {
|
22
|
+
// Create a request using random() and convert to plain object
|
23
|
+
const request = TxExecutionRequest.random();
|
24
|
+
const params = { exec: JSON.parse(JSON.stringify(request)) };
|
25
|
+
|
26
|
+
const serialized = aztecCreateTxExecutionRequestSerializer.params.serialize(METHOD, params);
|
27
|
+
expect(serialized.method).toBe(METHOD);
|
28
|
+
|
29
|
+
const deserialized = aztecCreateTxExecutionRequestSerializer.params.deserialize(METHOD, serialized);
|
30
|
+
expect(JSON.stringify(deserialized.exec)).toBe(JSON.stringify(params.exec));
|
31
|
+
});
|
32
|
+
|
33
|
+
it('should serialize and deserialize result', () => {
|
34
|
+
const result = TxExecutionRequest.random();
|
35
|
+
|
36
|
+
const serialized = aztecCreateTxExecutionRequestSerializer.result.serialize(METHOD, result);
|
37
|
+
expect(serialized.method).toBe(METHOD);
|
38
|
+
|
39
|
+
const deserialized = aztecCreateTxExecutionRequestSerializer.result.deserialize(METHOD, serialized);
|
40
|
+
expect(deserialized.toString()).toBe(result.toString());
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
44
|
+
describe('aztec_getTxEffect', () => {
|
45
|
+
const METHOD = 'aztec_getTxEffect';
|
46
|
+
|
47
|
+
it('should serialize and deserialize params', () => {
|
48
|
+
const txHash = TxHash.random();
|
49
|
+
const params = { txHash };
|
50
|
+
|
51
|
+
const serialized = aztecGetTxEffectSerializer.params.serialize(METHOD, params);
|
52
|
+
expect(serialized.method).toBe(METHOD);
|
53
|
+
|
54
|
+
const deserialized = aztecGetTxEffectSerializer.params.deserialize(METHOD, serialized);
|
55
|
+
expect(deserialized.txHash.toString()).toBe(txHash.toString());
|
56
|
+
});
|
57
|
+
});
|
58
|
+
|
59
|
+
describe('aztec_getTxReceipt', () => {
|
60
|
+
const METHOD = 'aztec_getTxReceipt';
|
61
|
+
|
62
|
+
it('should serialize and deserialize params', () => {
|
63
|
+
const txHash = TxHash.random();
|
64
|
+
const params = { txHash };
|
65
|
+
|
66
|
+
const serialized = aztecGetTxReceiptSerializer.params.serialize(METHOD, params);
|
67
|
+
expect(serialized.method).toBe(METHOD);
|
68
|
+
|
69
|
+
const deserialized = aztecGetTxReceiptSerializer.params.deserialize(METHOD, serialized);
|
70
|
+
expect(deserialized.txHash.toString()).toBe(txHash.toString());
|
71
|
+
});
|
72
|
+
});
|
73
|
+
|
74
|
+
describe('aztec_sendTx', () => {
|
75
|
+
const METHOD = 'aztec_sendTx';
|
76
|
+
|
77
|
+
it('should serialize and deserialize params', () => {
|
78
|
+
const tx = Tx.random();
|
79
|
+
const params = { tx };
|
80
|
+
|
81
|
+
const serialized = aztecSendTxSerializer.params.serialize(METHOD, params);
|
82
|
+
expect(serialized.method).toBe(METHOD);
|
83
|
+
|
84
|
+
const deserialized = aztecSendTxSerializer.params.deserialize(METHOD, serialized);
|
85
|
+
expect(deserialized.tx.toBuffer().toString('hex')).toBe(tx.toBuffer().toString('hex'));
|
86
|
+
});
|
87
|
+
|
88
|
+
it('should serialize and deserialize result', () => {
|
89
|
+
const result = TxHash.random();
|
90
|
+
|
91
|
+
const serialized = aztecSendTxSerializer.result.serialize(METHOD, result);
|
92
|
+
expect(serialized.method).toBe(METHOD);
|
93
|
+
|
94
|
+
const deserialized = aztecSendTxSerializer.result.deserialize(METHOD, serialized);
|
95
|
+
expect(deserialized.toString()).toBe(result.toString());
|
96
|
+
});
|
97
|
+
});
|
98
|
+
|
99
|
+
describe('aztec_simulateTx', () => {
|
100
|
+
const METHOD = 'aztec_simulateTx';
|
101
|
+
|
102
|
+
it('should serialize and deserialize params', () => {
|
103
|
+
const params = {
|
104
|
+
txRequest: TxExecutionRequest.random(),
|
105
|
+
simulatePublic: true,
|
106
|
+
msgSender: AztecAddress.random(),
|
107
|
+
skipTxValidation: false,
|
108
|
+
enforceFeePayment: true,
|
109
|
+
profile: false,
|
110
|
+
};
|
111
|
+
|
112
|
+
const serialized = aztecSimulateTxSerializer.params.serialize(METHOD, params);
|
113
|
+
expect(serialized.method).toBe(METHOD);
|
114
|
+
|
115
|
+
const deserialized = aztecSimulateTxSerializer.params.deserialize(METHOD, serialized);
|
116
|
+
expect(deserialized.txRequest.toString()).toBe((params.txRequest as TxExecutionRequest).toString());
|
117
|
+
expect(deserialized.simulatePublic).toBe(params.simulatePublic);
|
118
|
+
expect(deserialized.msgSender?.toString()).toBe(params.msgSender.toString());
|
119
|
+
expect(deserialized.skipTxValidation).toBe(params.skipTxValidation);
|
120
|
+
expect(deserialized.enforceFeePayment).toBe(params.enforceFeePayment);
|
121
|
+
expect(deserialized.profile).toBe(params.profile);
|
122
|
+
});
|
123
|
+
});
|
124
|
+
|
125
|
+
describe('aztec_proveTx', () => {
|
126
|
+
const METHOD = 'aztec_proveTx';
|
127
|
+
|
128
|
+
it('should serialize and deserialize params', () => {
|
129
|
+
const txRequest = TxExecutionRequest.random();
|
130
|
+
const privateExecutionResult = PrivateExecutionResult.random();
|
131
|
+
const params = { txRequest, privateExecutionResult };
|
132
|
+
|
133
|
+
const serialized = aztecProveTxSerializer.params.serialize(METHOD, params);
|
134
|
+
expect(serialized.method).toBe(METHOD);
|
135
|
+
|
136
|
+
const deserialized = aztecProveTxSerializer.params.deserialize(METHOD, serialized);
|
137
|
+
expect(deserialized.txRequest.toString()).toBe(txRequest.toString());
|
138
|
+
expect(
|
139
|
+
comparePrivateExecutionResults(privateExecutionResult, deserialized.privateExecutionResult),
|
140
|
+
).toBe(true);
|
141
|
+
});
|
142
|
+
|
143
|
+
it('should serialize and deserialize result', () => {
|
144
|
+
const result = TxProvingResult.random();
|
145
|
+
|
146
|
+
const serialized = aztecProveTxSerializer.result.serialize(METHOD, result);
|
147
|
+
expect(serialized.method).toBe(METHOD);
|
148
|
+
|
149
|
+
const deserialized = aztecProveTxSerializer.result.deserialize(METHOD, serialized);
|
150
|
+
expect(compareTxProvingResults(result, deserialized)).toBe(true);
|
151
|
+
});
|
152
|
+
});
|
153
|
+
});
|