@walletmesh/aztec-rpc-wallet 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -0
- 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 -9
- package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
- package/dist/handlers/aztecAccountWallet.js +22 -22
- package/dist/serializers/account.d.ts +4 -7
- package/dist/serializers/account.d.ts.map +1 -1
- package/dist/serializers/account.js +28 -29
- package/dist/serializers/contract.d.ts +4 -56
- package/dist/serializers/contract.d.ts.map +1 -1
- package/dist/serializers/contract.js +62 -148
- 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 +36 -83
- package/dist/serializers/log.d.ts.map +1 -1
- package/dist/serializers/log.js +96 -107
- package/dist/serializers/note.d.ts +14 -17
- package/dist/serializers/note.d.ts.map +1 -1
- package/dist/serializers/note.js +52 -29
- 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 +82 -118
- package/dist/serializers/transaction.d.ts +3 -6
- package/dist/serializers/transaction.d.ts.map +1 -1
- package/dist/serializers/transaction.js +39 -50
- package/dist/types.d.ts +8 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +5 -5
- package/src/aztecRemoteWallet.test.ts +33 -29
- package/src/aztecRemoteWallet.ts +25 -14
- package/src/handlers/aztecAccountWallet.test.ts +78 -75
- package/src/handlers/aztecAccountWallet.ts +32 -35
- package/src/serializers/account.test.ts +18 -17
- package/src/serializers/account.ts +31 -49
- package/src/serializers/contract.test.ts +14 -16
- package/src/serializers/contract.ts +75 -164
- package/src/serializers/index.test.ts +20 -8
- package/src/serializers/index.ts +16 -20
- package/src/serializers/log.test.ts +201 -28
- package/src/serializers/log.ts +153 -146
- package/src/serializers/note.test.ts +26 -28
- package/src/serializers/note.ts +60 -36
- package/src/serializers/transaction-utils.ts +135 -211
- package/src/serializers/transaction.test.ts +190 -30
- package/src/serializers/transaction.ts +51 -72
- package/src/types.ts +9 -8
- 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
@@ -41,13 +41,13 @@ export const AZTEC_WALLET_METHODS: (keyof AztecWalletMethodMap)[] = [
|
|
41
41
|
'aztec_getTxReceipt',
|
42
42
|
'aztec_simulateTx',
|
43
43
|
'aztec_simulateUnconstrained',
|
44
|
-
'
|
44
|
+
'aztec_getNotes',
|
45
45
|
'aztec_addNote',
|
46
46
|
'aztec_addNullifiedNote',
|
47
|
-
'
|
47
|
+
'aztec_getPublicLogs',
|
48
48
|
'aztec_getContractClassLogs',
|
49
|
-
'
|
50
|
-
'
|
49
|
+
'aztec_getPrivateEvents',
|
50
|
+
'aztec_getPublicEvents',
|
51
51
|
] as const;
|
52
52
|
|
53
53
|
// Handler functions with proper type safety
|
@@ -331,11 +331,11 @@ async function handleGetPublicStorageAt(
|
|
331
331
|
return await wallet.getPublicStorageAt(params.contract, params.storageSlot);
|
332
332
|
}
|
333
333
|
|
334
|
-
async function
|
334
|
+
async function handleGetNotes(
|
335
335
|
wallet: AccountWallet,
|
336
|
-
params: AztecWalletMethodMap['
|
337
|
-
): Promise<AztecWalletMethodMap['
|
338
|
-
return await wallet.
|
336
|
+
params: AztecWalletMethodMap['aztec_getNotes']['params'],
|
337
|
+
): Promise<AztecWalletMethodMap['aztec_getNotes']['result']> {
|
338
|
+
return await wallet.getNotes(params.filter);
|
339
339
|
}
|
340
340
|
|
341
341
|
async function handleAddNote(
|
@@ -354,11 +354,11 @@ async function handleAddNullifiedNote(
|
|
354
354
|
return true;
|
355
355
|
}
|
356
356
|
|
357
|
-
async function
|
357
|
+
async function handleGetPublicLogs(
|
358
358
|
wallet: AccountWallet,
|
359
|
-
params: AztecWalletMethodMap['
|
360
|
-
): Promise<AztecWalletMethodMap['
|
361
|
-
return await wallet.
|
359
|
+
params: AztecWalletMethodMap['aztec_getPublicLogs']['params'],
|
360
|
+
): Promise<AztecWalletMethodMap['aztec_getPublicLogs']['result']> {
|
361
|
+
return await wallet.getPublicLogs(params.filter);
|
362
362
|
}
|
363
363
|
|
364
364
|
async function handleGetContractClassLogs(
|
@@ -368,20 +368,20 @@ async function handleGetContractClassLogs(
|
|
368
368
|
return await wallet.getContractClassLogs(params.filter);
|
369
369
|
}
|
370
370
|
|
371
|
-
async function
|
371
|
+
async function handleGetPrivateEvents(
|
372
372
|
wallet: AccountWallet,
|
373
|
-
params: AztecWalletMethodMap['
|
374
|
-
): Promise<AztecWalletMethodMap['
|
373
|
+
params: AztecWalletMethodMap['aztec_getPrivateEvents']['params'],
|
374
|
+
): Promise<AztecWalletMethodMap['aztec_getPrivateEvents']['result']> {
|
375
375
|
const { event, from, limit, vpks } = params;
|
376
|
-
return await wallet.
|
376
|
+
return await wallet.getPrivateEvents(event, from, limit, vpks);
|
377
377
|
}
|
378
378
|
|
379
|
-
async function
|
379
|
+
async function handleGetPublicEvents(
|
380
380
|
wallet: AccountWallet,
|
381
|
-
params: AztecWalletMethodMap['
|
382
|
-
): Promise<AztecWalletMethodMap['
|
381
|
+
params: AztecWalletMethodMap['aztec_getPublicEvents']['params'],
|
382
|
+
): Promise<AztecWalletMethodMap['aztec_getPublicEvents']['result']> {
|
383
383
|
const { event, from, limit } = params;
|
384
|
-
return await wallet.
|
384
|
+
return await wallet.getPublicEvents(event, from, limit);
|
385
385
|
}
|
386
386
|
|
387
387
|
async function handleL1ToL2MembershipWitness(
|
@@ -553,11 +553,8 @@ export async function aztecWalletHandler<M extends keyof AztecWalletMethodMap>(
|
|
553
553
|
);
|
554
554
|
|
555
555
|
// Notes methods
|
556
|
-
case '
|
557
|
-
return
|
558
|
-
context.wallet,
|
559
|
-
params as AztecWalletMethodMap['aztec_getIncomingNotes']['params'],
|
560
|
-
);
|
556
|
+
case 'aztec_getNotes':
|
557
|
+
return handleGetNotes(context.wallet, params as AztecWalletMethodMap['aztec_getNotes']['params']);
|
561
558
|
case 'aztec_addNote':
|
562
559
|
return handleAddNote(context.wallet, params as AztecWalletMethodMap['aztec_addNote']['params']);
|
563
560
|
case 'aztec_addNullifiedNote':
|
@@ -566,26 +563,26 @@ export async function aztecWalletHandler<M extends keyof AztecWalletMethodMap>(
|
|
566
563
|
params as AztecWalletMethodMap['aztec_addNullifiedNote']['params'],
|
567
564
|
);
|
568
565
|
|
569
|
-
// Logs methods
|
570
|
-
case '
|
571
|
-
return
|
566
|
+
// Logs and Events methods
|
567
|
+
case 'aztec_getPublicLogs':
|
568
|
+
return handleGetPublicLogs(
|
572
569
|
context.wallet,
|
573
|
-
params as AztecWalletMethodMap['
|
570
|
+
params as AztecWalletMethodMap['aztec_getPublicLogs']['params'],
|
574
571
|
);
|
575
572
|
case 'aztec_getContractClassLogs':
|
576
573
|
return handleGetContractClassLogs(
|
577
574
|
context.wallet,
|
578
575
|
params as AztecWalletMethodMap['aztec_getContractClassLogs']['params'],
|
579
576
|
);
|
580
|
-
case '
|
581
|
-
return
|
577
|
+
case 'aztec_getPrivateEvents':
|
578
|
+
return handleGetPrivateEvents(
|
582
579
|
context.wallet,
|
583
|
-
params as AztecWalletMethodMap['
|
580
|
+
params as AztecWalletMethodMap['aztec_getPrivateEvents']['params'],
|
584
581
|
);
|
585
|
-
case '
|
586
|
-
return
|
582
|
+
case 'aztec_getPublicEvents':
|
583
|
+
return handleGetPublicEvents(
|
587
584
|
context.wallet,
|
588
|
-
params as AztecWalletMethodMap['
|
585
|
+
params as AztecWalletMethodMap['aztec_getPublicEvents']['params'],
|
589
586
|
);
|
590
587
|
default:
|
591
588
|
throw new AztecWalletError('invalidRequest', `Method not supported: ${String(method)}`);
|
@@ -7,14 +7,14 @@ import {
|
|
7
7
|
aztecGetAuthWitnessSerializer,
|
8
8
|
} from './account.js';
|
9
9
|
import { decodeBase64 } from './types.js';
|
10
|
-
import {
|
10
|
+
import { schemas } from '@aztec/foundation/schemas';
|
11
11
|
|
12
12
|
describe('Account Serializers', () => {
|
13
13
|
describe('aztec_setScopes', () => {
|
14
14
|
const METHOD = 'aztec_setScopes';
|
15
15
|
|
16
|
-
it('should serialize and deserialize params', () => {
|
17
|
-
const scopes = [AztecAddress.random(), AztecAddress.random()];
|
16
|
+
it('should serialize and deserialize params', async () => {
|
17
|
+
const scopes = [await AztecAddress.random(), await AztecAddress.random()];
|
18
18
|
const params = { scopes };
|
19
19
|
|
20
20
|
const serialized = aztecSetScopesSerializer.params.serialize(METHOD, params);
|
@@ -38,9 +38,9 @@ describe('Account Serializers', () => {
|
|
38
38
|
describe('aztec_registerAccount', () => {
|
39
39
|
const METHOD = 'aztec_registerAccount';
|
40
40
|
|
41
|
-
it('should serialize and deserialize params', () => {
|
42
|
-
const secretKey = Fr.random();
|
43
|
-
const partialAddress = Fr.random();
|
41
|
+
it('should serialize and deserialize params', async () => {
|
42
|
+
const secretKey = await Fr.random();
|
43
|
+
const partialAddress = await Fr.random();
|
44
44
|
const params = { secretKey, partialAddress };
|
45
45
|
|
46
46
|
const serialized = aztecRegisterAccountSerializer.params.serialize(METHOD, params);
|
@@ -51,8 +51,8 @@ describe('Account Serializers', () => {
|
|
51
51
|
expect(deserialized.partialAddress.toString()).toBe(partialAddress.toString());
|
52
52
|
});
|
53
53
|
|
54
|
-
it('should serialize and deserialize result', () => {
|
55
|
-
const result = CompleteAddress.random();
|
54
|
+
it('should serialize and deserialize result', async () => {
|
55
|
+
const result = await CompleteAddress.random();
|
56
56
|
|
57
57
|
const serialized = aztecRegisterAccountSerializer.result.serialize(METHOD, result);
|
58
58
|
expect(serialized.method).toBe(METHOD);
|
@@ -65,8 +65,8 @@ describe('Account Serializers', () => {
|
|
65
65
|
describe('aztec_addAuthWitness', () => {
|
66
66
|
const METHOD = 'aztec_addAuthWitness';
|
67
67
|
|
68
|
-
it('should serialize and deserialize params', () => {
|
69
|
-
const authWitness = AuthWitness.random();
|
68
|
+
it('should serialize and deserialize params', async () => {
|
69
|
+
const authWitness = await AuthWitness.random();
|
70
70
|
const params = { authWitness };
|
71
71
|
|
72
72
|
const serialized = aztecAddAuthWitnessSerializer.params.serialize(METHOD, params);
|
@@ -90,8 +90,8 @@ describe('Account Serializers', () => {
|
|
90
90
|
describe('aztec_getAuthWitness', () => {
|
91
91
|
const METHOD = 'aztec_getAuthWitness';
|
92
92
|
|
93
|
-
it('should serialize and deserialize params', () => {
|
94
|
-
const messageHash = Fr.random();
|
93
|
+
it('should serialize and deserialize params', async () => {
|
94
|
+
const messageHash = await Fr.random();
|
95
95
|
const params = { messageHash };
|
96
96
|
|
97
97
|
const serialized = aztecGetAuthWitnessSerializer.params.serialize(METHOD, params);
|
@@ -101,8 +101,8 @@ describe('Account Serializers', () => {
|
|
101
101
|
expect(deserialized.messageHash.toString()).toBe(messageHash.toString());
|
102
102
|
});
|
103
103
|
|
104
|
-
it('should serialize and deserialize result', () => {
|
105
|
-
const result = [Fr.random(), Fr.random()];
|
104
|
+
it('should serialize and deserialize result', async () => {
|
105
|
+
const result = [await Fr.random(), await Fr.random()];
|
106
106
|
|
107
107
|
const serialized = aztecGetAuthWitnessSerializer.result.serialize(METHOD, result);
|
108
108
|
expect(serialized.method).toBe(METHOD);
|
@@ -113,12 +113,13 @@ describe('Account Serializers', () => {
|
|
113
113
|
});
|
114
114
|
|
115
115
|
describe('Base64 encoding/decoding', () => {
|
116
|
-
it('should properly encode and decode data', () => {
|
117
|
-
const messageHash = Fr.random();
|
116
|
+
it('should properly encode and decode data', async () => {
|
117
|
+
const messageHash = await Fr.random();
|
118
|
+
|
118
119
|
const serialized = aztecGetAuthWitnessSerializer.params.serialize('aztec_getAuthWitness', {
|
119
120
|
messageHash,
|
120
121
|
});
|
121
|
-
const decoded =
|
122
|
+
const decoded = schemas.Fr.parse(JSON.parse(serialized.serialized));
|
122
123
|
expect(decoded.toString()).toBe(messageHash.toString());
|
123
124
|
});
|
124
125
|
});
|
@@ -1,18 +1,11 @@
|
|
1
1
|
import type { AztecWalletMethodMap } from '../types.js';
|
2
|
-
import type { JSONRPCSerializedData, JSONRPCSerializer } from '
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
aztecAddressSerializer,
|
6
|
-
completeAddressSerializer,
|
7
|
-
frSerializer,
|
8
|
-
authWitnessSerializer,
|
9
|
-
} from './core.js';
|
10
|
-
import type { PartialAddress, AztecAddress } from '@aztec/aztec.js';
|
2
|
+
import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
|
3
|
+
import type { PartialAddress } from '@aztec/aztec.js';
|
4
|
+
import { CompleteAddress, AuthWitness, AztecAddress, Fr } from '@aztec/aztec.js';
|
11
5
|
|
12
6
|
/**
|
13
7
|
* Serializer for the aztec_setScopes RPC method.
|
14
8
|
* Handles serialization of account scope settings between JSON-RPC format and native Aztec types.
|
15
|
-
* Scopes define which contracts can interact with an account.
|
16
9
|
*/
|
17
10
|
export class AztecSetScopesSerializer
|
18
11
|
implements
|
@@ -35,9 +28,9 @@ export class AztecSetScopesSerializer
|
|
35
28
|
const { scopes } = value;
|
36
29
|
return {
|
37
30
|
method,
|
38
|
-
serialized:
|
39
|
-
|
40
|
-
),
|
31
|
+
serialized: JSON.stringify({
|
32
|
+
scopes: scopes.map((s) => s.toString()),
|
33
|
+
}),
|
41
34
|
};
|
42
35
|
},
|
43
36
|
/**
|
@@ -50,10 +43,10 @@ export class AztecSetScopesSerializer
|
|
50
43
|
method: string,
|
51
44
|
data: JSONRPCSerializedData,
|
52
45
|
): AztecWalletMethodMap['aztec_setScopes']['params'] => {
|
53
|
-
const scopes = JSON.parse(
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
const { scopes } = JSON.parse(data.serialized);
|
47
|
+
return {
|
48
|
+
scopes: scopes.map((s: string) => AztecAddress.fromString(s)),
|
49
|
+
};
|
57
50
|
},
|
58
51
|
};
|
59
52
|
|
@@ -67,7 +60,7 @@ export class AztecSetScopesSerializer
|
|
67
60
|
serialize: (method: string, value: boolean): JSONRPCSerializedData => {
|
68
61
|
return {
|
69
62
|
method,
|
70
|
-
serialized:
|
63
|
+
serialized: JSON.stringify(value),
|
71
64
|
};
|
72
65
|
},
|
73
66
|
/**
|
@@ -77,7 +70,7 @@ export class AztecSetScopesSerializer
|
|
77
70
|
* @returns Boolean indicating success
|
78
71
|
*/
|
79
72
|
deserialize: (method: string, data: JSONRPCSerializedData): boolean => {
|
80
|
-
return JSON.parse(
|
73
|
+
return JSON.parse(data.serialized);
|
81
74
|
},
|
82
75
|
};
|
83
76
|
}
|
@@ -85,7 +78,6 @@ export class AztecSetScopesSerializer
|
|
85
78
|
/**
|
86
79
|
* Serializer for the aztec_registerAccount RPC method.
|
87
80
|
* Handles serialization of account registration data between JSON-RPC format and native Aztec types.
|
88
|
-
* Account registration involves creating a new account with a secret key and partial address.
|
89
81
|
*/
|
90
82
|
export class AztecRegisterAccountSerializer
|
91
83
|
implements
|
@@ -108,12 +100,10 @@ export class AztecRegisterAccountSerializer
|
|
108
100
|
const { secretKey, partialAddress } = value;
|
109
101
|
return {
|
110
102
|
method,
|
111
|
-
serialized:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
]),
|
116
|
-
),
|
103
|
+
serialized: JSON.stringify({
|
104
|
+
secretKey: secretKey.toString(),
|
105
|
+
partialAddress: partialAddress.toString(),
|
106
|
+
}),
|
117
107
|
};
|
118
108
|
},
|
119
109
|
/**
|
@@ -126,10 +116,10 @@ export class AztecRegisterAccountSerializer
|
|
126
116
|
method: string,
|
127
117
|
data: JSONRPCSerializedData,
|
128
118
|
): AztecWalletMethodMap['aztec_registerAccount']['params'] => {
|
129
|
-
const
|
119
|
+
const { secretKey, partialAddress } = JSON.parse(data.serialized);
|
130
120
|
return {
|
131
|
-
secretKey:
|
132
|
-
partialAddress:
|
121
|
+
secretKey: Fr.fromString(secretKey),
|
122
|
+
partialAddress: Fr.fromString(partialAddress) as PartialAddress,
|
133
123
|
};
|
134
124
|
},
|
135
125
|
};
|
@@ -141,13 +131,10 @@ export class AztecRegisterAccountSerializer
|
|
141
131
|
* @param value - The complete address of the registered account
|
142
132
|
* @returns Serialized complete address
|
143
133
|
*/
|
144
|
-
serialize: (
|
145
|
-
method: string,
|
146
|
-
value: AztecWalletMethodMap['aztec_registerAccount']['result'],
|
147
|
-
): JSONRPCSerializedData => {
|
134
|
+
serialize: (method: string, value: CompleteAddress): JSONRPCSerializedData => {
|
148
135
|
return {
|
149
136
|
method,
|
150
|
-
serialized:
|
137
|
+
serialized: JSON.stringify(value.toString()),
|
151
138
|
};
|
152
139
|
},
|
153
140
|
/**
|
@@ -156,11 +143,8 @@ export class AztecRegisterAccountSerializer
|
|
156
143
|
* @param data - The serialized complete address
|
157
144
|
* @returns Deserialized complete address
|
158
145
|
*/
|
159
|
-
deserialize: (
|
160
|
-
|
161
|
-
data: JSONRPCSerializedData,
|
162
|
-
): AztecWalletMethodMap['aztec_registerAccount']['result'] => {
|
163
|
-
return completeAddressSerializer.deserialize(decodeBase64(data.serialized));
|
146
|
+
deserialize: (method: string, data: JSONRPCSerializedData): CompleteAddress => {
|
147
|
+
return CompleteAddress.fromString(JSON.parse(data.serialized));
|
164
148
|
},
|
165
149
|
};
|
166
150
|
}
|
@@ -168,7 +152,6 @@ export class AztecRegisterAccountSerializer
|
|
168
152
|
/**
|
169
153
|
* Serializer for the aztec_addAuthWitness RPC method.
|
170
154
|
* Handles serialization of authentication witness data between JSON-RPC format and native Aztec types.
|
171
|
-
* Auth witnesses are used to prove transaction authorization.
|
172
155
|
*/
|
173
156
|
export class AztecAddAuthWitnessSerializer
|
174
157
|
implements
|
@@ -191,7 +174,7 @@ export class AztecAddAuthWitnessSerializer
|
|
191
174
|
const { authWitness } = value;
|
192
175
|
return {
|
193
176
|
method,
|
194
|
-
serialized:
|
177
|
+
serialized: JSON.stringify(authWitness.toString()),
|
195
178
|
};
|
196
179
|
},
|
197
180
|
/**
|
@@ -204,7 +187,7 @@ export class AztecAddAuthWitnessSerializer
|
|
204
187
|
method: string,
|
205
188
|
data: JSONRPCSerializedData,
|
206
189
|
): AztecWalletMethodMap['aztec_addAuthWitness']['params'] => {
|
207
|
-
const authWitness =
|
190
|
+
const authWitness = AuthWitness.fromString(JSON.parse(data.serialized));
|
208
191
|
return { authWitness };
|
209
192
|
},
|
210
193
|
};
|
@@ -219,7 +202,7 @@ export class AztecAddAuthWitnessSerializer
|
|
219
202
|
serialize: (method: string, value: boolean): JSONRPCSerializedData => {
|
220
203
|
return {
|
221
204
|
method,
|
222
|
-
serialized:
|
205
|
+
serialized: JSON.stringify(value),
|
223
206
|
};
|
224
207
|
},
|
225
208
|
/**
|
@@ -229,7 +212,7 @@ export class AztecAddAuthWitnessSerializer
|
|
229
212
|
* @returns Boolean indicating success
|
230
213
|
*/
|
231
214
|
deserialize: (method: string, data: JSONRPCSerializedData): boolean => {
|
232
|
-
return JSON.parse(
|
215
|
+
return JSON.parse(data.serialized);
|
233
216
|
},
|
234
217
|
};
|
235
218
|
}
|
@@ -237,7 +220,6 @@ export class AztecAddAuthWitnessSerializer
|
|
237
220
|
/**
|
238
221
|
* Serializer for the aztec_getAuthWitness RPC method.
|
239
222
|
* Handles serialization of authentication witness retrieval between JSON-RPC format and native Aztec types.
|
240
|
-
* Retrieves auth witnesses associated with a specific message hash.
|
241
223
|
*/
|
242
224
|
export class AztecGetAuthWitnessSerializer
|
243
225
|
implements
|
@@ -260,7 +242,7 @@ export class AztecGetAuthWitnessSerializer
|
|
260
242
|
const { messageHash } = value;
|
261
243
|
return {
|
262
244
|
method,
|
263
|
-
serialized:
|
245
|
+
serialized: JSON.stringify(messageHash.toString()),
|
264
246
|
};
|
265
247
|
},
|
266
248
|
/**
|
@@ -273,7 +255,7 @@ export class AztecGetAuthWitnessSerializer
|
|
273
255
|
method: string,
|
274
256
|
data: JSONRPCSerializedData,
|
275
257
|
): AztecWalletMethodMap['aztec_getAuthWitness']['params'] => {
|
276
|
-
const messageHash =
|
258
|
+
const messageHash = Fr.fromString(JSON.parse(data.serialized));
|
277
259
|
return { messageHash };
|
278
260
|
},
|
279
261
|
};
|
@@ -291,7 +273,7 @@ export class AztecGetAuthWitnessSerializer
|
|
291
273
|
): JSONRPCSerializedData => {
|
292
274
|
return {
|
293
275
|
method,
|
294
|
-
serialized:
|
276
|
+
serialized: JSON.stringify(value.map((w) => w.toString())),
|
295
277
|
};
|
296
278
|
},
|
297
279
|
/**
|
@@ -304,7 +286,7 @@ export class AztecGetAuthWitnessSerializer
|
|
304
286
|
method: string,
|
305
287
|
data: JSONRPCSerializedData,
|
306
288
|
): AztecWalletMethodMap['aztec_getAuthWitness']['result'] => {
|
307
|
-
return JSON.parse(
|
289
|
+
return JSON.parse(data.serialized).map((w: string) => Fr.fromString(w));
|
308
290
|
},
|
309
291
|
};
|
310
292
|
}
|
@@ -20,12 +20,10 @@ import {
|
|
20
20
|
type ContractNote,
|
21
21
|
} from '@aztec/foundation/abi';
|
22
22
|
import { randomContractArtifact, randomDeployedContract } from '@aztec/circuit-types';
|
23
|
-
import { aztecAddressSerializer, frSerializer } from './core.js';
|
24
|
-
|
25
23
|
describe('Contract Serializers', () => {
|
26
24
|
describe('aztec_getContractInstance', () => {
|
27
|
-
it('should serialize and deserialize params', () => {
|
28
|
-
const address = AztecAddress.random();
|
25
|
+
it('should serialize and deserialize params', async () => {
|
26
|
+
const address = await AztecAddress.random();
|
29
27
|
const params = { address };
|
30
28
|
|
31
29
|
const serialized = aztecGetContractInstanceSerializer.params.serialize(
|
@@ -41,9 +39,9 @@ describe('Contract Serializers', () => {
|
|
41
39
|
expect(deserialized.address.toString()).toBe(address.toString());
|
42
40
|
});
|
43
41
|
|
44
|
-
it('should serialize and deserialize result', () => {
|
42
|
+
it('should serialize and deserialize result', async () => {
|
45
43
|
// Create a contract instance with all required fields
|
46
|
-
const result = SerializableContractInstance.random().withAddress(AztecAddress.random());
|
44
|
+
const result = (await SerializableContractInstance.random()).withAddress(await AztecAddress.random());
|
47
45
|
|
48
46
|
const serialized = aztecGetContractInstanceSerializer.result.serialize(
|
49
47
|
'aztec_getContractInstance',
|
@@ -64,8 +62,8 @@ describe('Contract Serializers', () => {
|
|
64
62
|
});
|
65
63
|
|
66
64
|
describe('aztec_getContractClass', () => {
|
67
|
-
it('should serialize and deserialize params', () => {
|
68
|
-
const id = Fr.random();
|
65
|
+
it('should serialize and deserialize params', async () => {
|
66
|
+
const id = await Fr.random();
|
69
67
|
const params = { id };
|
70
68
|
|
71
69
|
const serialized = aztecGetContractClassSerializer.params.serialize('aztec_getContractClass', params);
|
@@ -78,8 +76,8 @@ describe('Contract Serializers', () => {
|
|
78
76
|
expect(deserialized.id.toString()).toBe(id.toString());
|
79
77
|
});
|
80
78
|
|
81
|
-
it('should serialize and deserialize result', () => {
|
82
|
-
const artifact = randomContractArtifact();
|
79
|
+
it('should serialize and deserialize result', async () => {
|
80
|
+
const artifact = await randomContractArtifact();
|
83
81
|
const result = getContractClassFromArtifact(artifact);
|
84
82
|
const serialized = aztecGetContractClassSerializer.result.serialize('aztec_getContractClass', result);
|
85
83
|
expect(serialized.method).toBe('aztec_getContractClass');
|
@@ -97,8 +95,8 @@ describe('Contract Serializers', () => {
|
|
97
95
|
});
|
98
96
|
|
99
97
|
describe('aztec_getContractArtifact', () => {
|
100
|
-
it('should serialize and deserialize params', () => {
|
101
|
-
const id = Fr.random();
|
98
|
+
it('should serialize and deserialize params', async () => {
|
99
|
+
const id = await Fr.random();
|
102
100
|
const serialized = aztecGetContractArtifactSerializer.params.serialize('aztec_getContractArtifact', {
|
103
101
|
id,
|
104
102
|
});
|
@@ -111,8 +109,8 @@ describe('Contract Serializers', () => {
|
|
111
109
|
expect(deserialized.id.toString()).toBe(id.toString());
|
112
110
|
});
|
113
111
|
|
114
|
-
it('should serialize and deserialize result', () => {
|
115
|
-
const result = randomContractArtifact();
|
112
|
+
it('should serialize and deserialize result', async () => {
|
113
|
+
const result = await randomContractArtifact();
|
116
114
|
const serialized = aztecGetContractArtifactSerializer.result.serialize(
|
117
115
|
'aztec_getContractArtifact',
|
118
116
|
result,
|
@@ -128,8 +126,8 @@ describe('Contract Serializers', () => {
|
|
128
126
|
});
|
129
127
|
|
130
128
|
describe('aztec_registerContract', () => {
|
131
|
-
it('should serialize and deserialize params', () => {
|
132
|
-
const { instance, artifact } = randomDeployedContract();
|
129
|
+
it('should serialize and deserialize params', async () => {
|
130
|
+
const { instance, artifact } = await randomDeployedContract();
|
133
131
|
const serialized = aztecRegisterContractSerializer.params.serialize('aztec_registerContract', {
|
134
132
|
instance,
|
135
133
|
artifact,
|