@walletmesh/aztec-rpc-wallet 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/aztecRemoteWallet.d.ts +5 -9
- package/dist/aztecRemoteWallet.d.ts.map +1 -1
- package/dist/aztecRemoteWallet.js +7 -31
- package/dist/contractArtifactCache.d.ts.map +1 -1
- package/dist/contractArtifactCache.js +20 -9
- package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
- package/dist/handlers/aztecAccountWallet.js +12 -46
- package/dist/serializers/account.d.ts +16 -16
- package/dist/serializers/account.d.ts.map +1 -1
- package/dist/serializers/account.js +43 -43
- package/dist/serializers/contract.d.ts +22 -76
- package/dist/serializers/contract.d.ts.map +1 -1
- package/dist/serializers/contract.js +68 -120
- package/dist/serializers/index.d.ts +0 -4
- package/dist/serializers/index.d.ts.map +1 -1
- package/dist/serializers/index.js +15 -20
- package/dist/serializers/log.d.ts +16 -16
- package/dist/serializers/log.d.ts.map +1 -1
- package/dist/serializers/log.js +43 -43
- package/dist/serializers/note.d.ts +12 -12
- package/dist/serializers/note.d.ts.map +1 -1
- package/dist/serializers/note.js +32 -32
- package/dist/serializers/transaction.d.ts +25 -26
- package/dist/serializers/transaction.d.ts.map +1 -1
- package/dist/serializers/transaction.js +92 -44
- package/dist/types.d.ts +10 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/docs/README.md +264 -0
- package/docs/classes/AztecChainProvider.md +553 -0
- package/docs/classes/AztecChainWallet.md +409 -0
- package/docs/classes/AztecProvider.md +1112 -0
- package/docs/classes/AztecWalletError.md +213 -0
- package/docs/classes/ContractArtifactCache.md +81 -0
- package/docs/globals.md +34 -0
- package/docs/interfaces/AztecWalletBaseMethodMap.md +135 -0
- package/docs/interfaces/AztecWalletEventMap.md +17 -0
- package/docs/interfaces/AztecWalletMethodMap.md +1020 -0
- package/docs/type-aliases/AztecChainId.md +11 -0
- package/docs/type-aliases/AztecChainWalletMiddleware.md +13 -0
- package/docs/type-aliases/AztecWalletContext.md +29 -0
- package/docs/type-aliases/AztecWalletMethodHandler.md +37 -0
- package/docs/type-aliases/AztecWalletMiddleware.md +13 -0
- package/docs/type-aliases/AztecWalletRouterClient.md +13 -0
- package/docs/type-aliases/TransactionFunctionCall.md +33 -0
- package/docs/type-aliases/TransactionParams.md +27 -0
- package/docs/variables/AztecWalletErrorMap.md +13 -0
- package/package.json +9 -9
- package/src/aztecRemoteWallet.test.ts +28 -66
- package/src/aztecRemoteWallet.ts +10 -37
- package/src/chainProvider.test.ts +117 -38
- package/src/contractArtifactCache.test.ts +28 -45
- package/src/contractArtifactCache.ts +20 -10
- package/src/handlers/aztecAccountWallet.test.ts +16 -89
- package/src/handlers/aztecAccountWallet.ts +20 -79
- package/src/provider.test.ts +3 -2
- package/src/serializers/account.test.ts +19 -20
- package/src/serializers/account.ts +52 -52
- package/src/serializers/contract.test.ts +4 -140
- package/src/serializers/contract.ts +93 -166
- package/src/serializers/index.test.ts +30 -28
- package/src/serializers/index.ts +15 -21
- package/src/serializers/log.test.ts +42 -48
- package/src/serializers/log.ts +54 -54
- package/src/serializers/note.test.ts +43 -16
- package/src/serializers/note.ts +39 -39
- package/src/serializers/transaction.test.ts +48 -41
- package/src/serializers/transaction.ts +146 -58
- package/src/types.ts +8 -8
- package/src/wallet.test.ts +3 -3
- package/dist/serializers/transaction-utils.d.ts +0 -51
- package/dist/serializers/transaction-utils.d.ts.map +0 -1
- package/dist/serializers/transaction-utils.js +0 -103
- package/src/serializers/transaction-utils.ts +0 -174
@@ -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 {
|
12
|
-
import {
|
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:
|
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: (
|
87
|
+
deserialize: async (
|
39
88
|
_method: string,
|
40
89
|
data: JSONRPCSerializedData,
|
41
|
-
): AztecWalletMethodMap['aztec_createTxExecutionRequest']['params'] => {
|
42
|
-
const
|
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: (
|
170
|
+
deserialize: async (
|
86
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(
|
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: (
|
220
|
+
deserialize: async (
|
133
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: (
|
238
|
+
deserialize: async (
|
151
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: (
|
269
|
+
deserialize: async (
|
182
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: (
|
288
|
+
deserialize: async (
|
201
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: (
|
319
|
+
deserialize: async (
|
232
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: (
|
370
|
+
deserialize: async (
|
283
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';
|
@@ -180,7 +181,7 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
|
|
180
181
|
};
|
181
182
|
|
182
183
|
/* Capsules */
|
183
|
-
aztec_addCapsule: { params: { capsule: Fr[] }; result:
|
184
|
+
aztec_addCapsule: { params: { contract: AztecAddress; storageSlot: Fr; capsule: Fr[] }; result: undefined };
|
184
185
|
|
185
186
|
/* Accounts */
|
186
187
|
aztec_getAddress: { result: AztecAddress };
|
@@ -213,12 +214,11 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
|
|
213
214
|
/* Contracts */
|
214
215
|
|
215
216
|
aztec_getContracts: { result: AztecAddress[] };
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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.
|
package/src/wallet.test.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
2
|
-
import type { AccountWallet, PXE
|
2
|
+
import type { AccountWallet, PXE } from '@aztec/aztec.js';
|
3
3
|
import { JSONRPCWalletClient } from '@walletmesh/router';
|
4
4
|
import { AztecChainWallet } from './wallet.js';
|
5
5
|
import { ContractArtifactCache } from './contractArtifactCache.js';
|
@@ -36,7 +36,7 @@ describe('AztecChainWallet', () => {
|
|
36
36
|
aztecWallet = new AztecChainWallet(pxe, wallet, transport);
|
37
37
|
|
38
38
|
// Setup fallback handler and serializer
|
39
|
-
const mockHandler = vi.fn().mockImplementation(async (context, method,
|
39
|
+
const mockHandler = vi.fn().mockImplementation(async (context, method, _params) => {
|
40
40
|
if (!isAztecWalletContext(context)) {
|
41
41
|
throw new AztecWalletError('unknownInternalError', 'Invalid context');
|
42
42
|
}
|
@@ -249,7 +249,7 @@ describe('AztecChainWallet', () => {
|
|
249
249
|
};
|
250
250
|
|
251
251
|
// Setup request handler to throw error for invalid method
|
252
|
-
const handleRequest = async (
|
252
|
+
const handleRequest = async (_msg: unknown) => {
|
253
253
|
throw new AztecWalletError('invalidRequest', 'Invalid method');
|
254
254
|
};
|
255
255
|
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @module transaction-utils
|
3
|
-
* Utilities for serializing and deserializing Aztec transaction execution requests.
|
4
|
-
* These utilities handle the conversion between native Aztec types and JSON-RPC compatible formats.
|
5
|
-
*/
|
6
|
-
import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
7
|
-
/**
|
8
|
-
* Serializes an ExecutionRequestInit object to a string for JSON-RPC transport.
|
9
|
-
* This function converts a native Aztec transaction execution request into a format
|
10
|
-
* that can be safely transmitted over JSON-RPC, handling the conversion of complex
|
11
|
-
* types like addresses, field elements, and function selectors to strings.
|
12
|
-
*
|
13
|
-
* Note: The fee payment method is not serialized as it contains async methods.
|
14
|
-
* The deserializer will use a default NoFeePaymentMethod which should be replaced
|
15
|
-
* by the caller with an appropriate implementation.
|
16
|
-
*
|
17
|
-
* @param init - The ExecutionRequestInit object to serialize, containing:
|
18
|
-
* - calls: Array of function calls to execute
|
19
|
-
* - fee: Gas settings and payment method
|
20
|
-
* - authWitnesses: Optional authentication proofs
|
21
|
-
* - hashedArguments: Optional pre-hashed arguments
|
22
|
-
* - nonce: Optional transaction nonce
|
23
|
-
* - cancellable: Optional cancellation flag
|
24
|
-
* @returns A JSON string representation of the serialized data, with all complex
|
25
|
-
* Aztec types converted to string representations
|
26
|
-
* @throws If any of the complex types cannot be serialized
|
27
|
-
*/
|
28
|
-
export declare function serializeExecutionRequestInit(init: ExecutionRequestInit): string;
|
29
|
-
/**
|
30
|
-
* Deserializes a string into an ExecutionRequestInit object for use in the Aztec protocol.
|
31
|
-
* This function reconstructs a native Aztec transaction execution request from its
|
32
|
-
* JSON-RPC serialized form, converting string representations back into their
|
33
|
-
* appropriate Aztec types.
|
34
|
-
*
|
35
|
-
* Note: A default NoFeePaymentMethod is used for the fee payment method.
|
36
|
-
* The caller should override this with the appropriate implementation based on
|
37
|
-
* their fee payment requirements.
|
38
|
-
*
|
39
|
-
* @param data - The serialized string data containing:
|
40
|
-
* - calls: Array of serialized function calls
|
41
|
-
* - fee: Serialized gas settings
|
42
|
-
* - authWitnesses: Optional serialized authentication proofs
|
43
|
-
* - hashedArguments: Optional serialized hashed arguments
|
44
|
-
* - nonce: Optional serialized nonce
|
45
|
-
* - cancellable: Optional cancellation flag
|
46
|
-
* @returns The deserialized ExecutionRequestInit object with all string representations
|
47
|
-
* converted back to their native Aztec types
|
48
|
-
* @throws If any of the serialized data cannot be properly deserialized into valid Aztec types
|
49
|
-
*/
|
50
|
-
export declare function deserializeExecutionRequestInit(data: string): ExecutionRequestInit;
|
51
|
-
//# sourceMappingURL=transaction-utils.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"transaction-utils.d.ts","sourceRoot":"","sources":["../../src/serializers/transaction-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAiDvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAiChF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAsClF"}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @module transaction-utils
|
3
|
-
* Utilities for serializing and deserializing Aztec transaction execution requests.
|
4
|
-
* These utilities handle the conversion between native Aztec types and JSON-RPC compatible formats.
|
5
|
-
*/
|
6
|
-
import { HashedValues, FunctionCall, AuthWitness } from '@aztec/circuit-types';
|
7
|
-
import { AztecAddress, Fr, FunctionSelector, GasSettings } from '@aztec/circuits.js';
|
8
|
-
import { NoFeePaymentMethod } from '@aztec/aztec.js';
|
9
|
-
/**
|
10
|
-
* Serializes an ExecutionRequestInit object to a string for JSON-RPC transport.
|
11
|
-
* This function converts a native Aztec transaction execution request into a format
|
12
|
-
* that can be safely transmitted over JSON-RPC, handling the conversion of complex
|
13
|
-
* types like addresses, field elements, and function selectors to strings.
|
14
|
-
*
|
15
|
-
* Note: The fee payment method is not serialized as it contains async methods.
|
16
|
-
* The deserializer will use a default NoFeePaymentMethod which should be replaced
|
17
|
-
* by the caller with an appropriate implementation.
|
18
|
-
*
|
19
|
-
* @param init - The ExecutionRequestInit object to serialize, containing:
|
20
|
-
* - calls: Array of function calls to execute
|
21
|
-
* - fee: Gas settings and payment method
|
22
|
-
* - authWitnesses: Optional authentication proofs
|
23
|
-
* - hashedArguments: Optional pre-hashed arguments
|
24
|
-
* - nonce: Optional transaction nonce
|
25
|
-
* - cancellable: Optional cancellation flag
|
26
|
-
* @returns A JSON string representation of the serialized data, with all complex
|
27
|
-
* Aztec types converted to string representations
|
28
|
-
* @throws If any of the complex types cannot be serialized
|
29
|
-
*/
|
30
|
-
export function serializeExecutionRequestInit(init) {
|
31
|
-
const serialized = {
|
32
|
-
calls: init.calls.map((call) => ({
|
33
|
-
name: call.name,
|
34
|
-
to: call.to.toString(),
|
35
|
-
selector: call.selector.toString(),
|
36
|
-
type: call.type,
|
37
|
-
isStatic: call.isStatic,
|
38
|
-
args: call.args.map((arg) => arg.toString()),
|
39
|
-
returnTypes: call.returnTypes,
|
40
|
-
})),
|
41
|
-
fee: {
|
42
|
-
gasSettings: init.fee.gasSettings.toBuffer().toString('base64'),
|
43
|
-
},
|
44
|
-
};
|
45
|
-
if (init.authWitnesses) {
|
46
|
-
serialized.authWitnesses = init.authWitnesses.map((w) => w.toString());
|
47
|
-
}
|
48
|
-
if (init.hashedArguments) {
|
49
|
-
serialized.hashedArguments = init.hashedArguments.map((ha) => ha.toBuffer().toString('base64'));
|
50
|
-
}
|
51
|
-
if (init.nonce) {
|
52
|
-
serialized.nonce = init.nonce.toString();
|
53
|
-
}
|
54
|
-
if (init.cancellable !== undefined) {
|
55
|
-
serialized.cancellable = init.cancellable;
|
56
|
-
}
|
57
|
-
return JSON.stringify(serialized);
|
58
|
-
}
|
59
|
-
/**
|
60
|
-
* Deserializes a string into an ExecutionRequestInit object for use in the Aztec protocol.
|
61
|
-
* This function reconstructs a native Aztec transaction execution request from its
|
62
|
-
* JSON-RPC serialized form, converting string representations back into their
|
63
|
-
* appropriate Aztec types.
|
64
|
-
*
|
65
|
-
* Note: A default NoFeePaymentMethod is used for the fee payment method.
|
66
|
-
* The caller should override this with the appropriate implementation based on
|
67
|
-
* their fee payment requirements.
|
68
|
-
*
|
69
|
-
* @param data - The serialized string data containing:
|
70
|
-
* - calls: Array of serialized function calls
|
71
|
-
* - fee: Serialized gas settings
|
72
|
-
* - authWitnesses: Optional serialized authentication proofs
|
73
|
-
* - hashedArguments: Optional serialized hashed arguments
|
74
|
-
* - nonce: Optional serialized nonce
|
75
|
-
* - cancellable: Optional cancellation flag
|
76
|
-
* @returns The deserialized ExecutionRequestInit object with all string representations
|
77
|
-
* converted back to their native Aztec types
|
78
|
-
* @throws If any of the serialized data cannot be properly deserialized into valid Aztec types
|
79
|
-
*/
|
80
|
-
export function deserializeExecutionRequestInit(data) {
|
81
|
-
const parsed = JSON.parse(data);
|
82
|
-
const result = {
|
83
|
-
calls: parsed.calls.map((call) => new FunctionCall(call.name, AztecAddress.fromString(call.to), FunctionSelector.fromString(call.selector), call.type, call.isStatic, call.args.map((arg) => Fr.fromString(arg)), call.returnTypes)),
|
84
|
-
fee: {
|
85
|
-
gasSettings: GasSettings.fromBuffer(Buffer.from(parsed.fee.gasSettings, 'base64')),
|
86
|
-
paymentMethod: new NoFeePaymentMethod(), // Default, caller should override
|
87
|
-
},
|
88
|
-
};
|
89
|
-
if (parsed.authWitnesses) {
|
90
|
-
result.authWitnesses = parsed.authWitnesses.map((w) => AuthWitness.fromString(w));
|
91
|
-
}
|
92
|
-
if (parsed.hashedArguments) {
|
93
|
-
result.hashedArguments = parsed.hashedArguments.map((ha) => HashedValues.fromBuffer(Buffer.from(ha, 'base64')));
|
94
|
-
}
|
95
|
-
if (parsed.nonce) {
|
96
|
-
result.nonce = Fr.fromString(parsed.nonce);
|
97
|
-
}
|
98
|
-
if (parsed.cancellable !== undefined) {
|
99
|
-
result.cancellable = parsed.cancellable;
|
100
|
-
}
|
101
|
-
return result;
|
102
|
-
}
|
103
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24tdXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcy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