@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -4
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/aztecRemoteWallet.d.ts +7 -6
  5. package/dist/aztecRemoteWallet.d.ts.map +1 -1
  6. package/dist/aztecRemoteWallet.js +15 -10
  7. package/dist/chainProvider.d.ts.map +1 -1
  8. package/dist/chainProvider.js +1 -1
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +1 -1
  11. package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
  12. package/dist/handlers/aztecAccountWallet.js +23 -23
  13. package/dist/handlers/transactions.d.ts.map +1 -1
  14. package/dist/handlers/transactions.js +11 -3
  15. package/dist/serializers/account.d.ts +19 -22
  16. package/dist/serializers/account.d.ts.map +1 -1
  17. package/dist/serializers/account.js +44 -45
  18. package/dist/serializers/contract.d.ts +11 -63
  19. package/dist/serializers/contract.d.ts.map +1 -1
  20. package/dist/serializers/contract.js +67 -153
  21. package/dist/serializers/index.d.ts +1 -4
  22. package/dist/serializers/index.d.ts.map +1 -1
  23. package/dist/serializers/index.js +12 -12
  24. package/dist/serializers/log.d.ts +38 -85
  25. package/dist/serializers/log.d.ts.map +1 -1
  26. package/dist/serializers/log.js +106 -115
  27. package/dist/serializers/note.d.ts +24 -27
  28. package/dist/serializers/note.d.ts.map +1 -1
  29. package/dist/serializers/note.js +67 -41
  30. package/dist/serializers/transaction-utils.d.ts +44 -100
  31. package/dist/serializers/transaction-utils.d.ts.map +1 -1
  32. package/dist/serializers/transaction-utils.js +89 -116
  33. package/dist/serializers/transaction.d.ts +15 -18
  34. package/dist/serializers/transaction.d.ts.map +1 -1
  35. package/dist/serializers/transaction.js +51 -62
  36. package/dist/types.d.ts +9 -9
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +1 -1
  39. package/package.json +9 -9
  40. package/src/aztecRemoteWallet.test.ts +34 -33
  41. package/src/aztecRemoteWallet.ts +25 -15
  42. package/src/chainProvider.ts +1 -7
  43. package/src/errors.ts +0 -1
  44. package/src/handlers/aztecAccountWallet.test.ts +78 -75
  45. package/src/handlers/aztecAccountWallet.ts +33 -36
  46. package/src/handlers/transactions.ts +16 -2
  47. package/src/serializers/account.test.ts +18 -17
  48. package/src/serializers/account.ts +46 -64
  49. package/src/serializers/contract.test.ts +14 -16
  50. package/src/serializers/contract.ts +77 -171
  51. package/src/serializers/index.test.ts +20 -8
  52. package/src/serializers/index.ts +16 -32
  53. package/src/serializers/log.test.ts +201 -28
  54. package/src/serializers/log.ts +162 -153
  55. package/src/serializers/note.test.ts +26 -28
  56. package/src/serializers/note.ts +71 -48
  57. package/src/serializers/transaction-utils.ts +147 -210
  58. package/src/serializers/transaction.test.ts +190 -30
  59. package/src/serializers/transaction.ts +62 -83
  60. package/src/types.ts +10 -9
  61. package/tsconfig.json +1 -1
  62. package/vitest.config.ts +1 -1
  63. package/dist/serializers/contract-utils.d.ts +0 -40
  64. package/dist/serializers/contract-utils.d.ts.map +0 -1
  65. package/dist/serializers/contract-utils.js +0 -102
  66. package/dist/serializers/core.d.ts +0 -110
  67. package/dist/serializers/core.d.ts.map +0 -1
  68. package/dist/serializers/core.js +0 -130
  69. package/dist/serializers/types.d.ts +0 -49
  70. package/dist/serializers/types.d.ts.map +0 -1
  71. package/dist/serializers/types.js +0 -22
  72. package/src/serializers/contract-utils.ts +0 -104
  73. package/src/serializers/core.test.ts +0 -56
  74. package/src/serializers/core.ts +0 -141
  75. package/src/serializers/types.ts +0 -58
package/src/types.ts CHANGED
@@ -25,15 +25,16 @@ import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
25
25
  import type { AbiDecoded } from '@aztec/foundation/abi';
26
26
  import type {
27
27
  InBlock,
28
- IncomingNotesFilter,
28
+ NotesFilter,
29
29
  EventMetadataDefinition,
30
30
  PrivateExecutionResult,
31
31
  TxEffect,
32
32
  TxProvingResult,
33
33
  UniqueNote,
34
- GetUnencryptedLogsResponse,
35
34
  PXEInfo,
36
35
  TxSimulationResult,
36
+ GetPublicLogsResponse,
37
+ GetContractClassLogsResponse,
37
38
  } from '@aztec/circuit-types';
38
39
  import type { GasFees, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js';
39
40
  import type { JSONRPCEventMap, JSONRPCMiddleware } from '@walletmesh/jsonrpc';
@@ -225,7 +226,7 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
225
226
  * @returns True if registration was successful
226
227
  */
227
228
  aztec_registerContract: {
228
- params: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact };
229
+ params: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact | undefined };
229
230
  result: boolean;
230
231
  };
231
232
 
@@ -265,18 +266,18 @@ export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
265
266
  };
266
267
 
267
268
  /* Notes */
268
- aztec_getIncomingNotes: { params: { filter: IncomingNotesFilter }; result: UniqueNote[] };
269
+ aztec_getNotes: { params: { filter: NotesFilter }; result: UniqueNote[] };
269
270
  aztec_addNote: { params: { note: ExtendedNote }; result: boolean };
270
271
  aztec_addNullifiedNote: { params: { note: ExtendedNote }; result: boolean };
271
272
 
272
- /* Logs */
273
- aztec_getUnencryptedLogs: { params: { filter: LogFilter }; result: GetUnencryptedLogsResponse };
274
- aztec_getContractClassLogs: { params: { filter: LogFilter }; result: GetUnencryptedLogsResponse };
275
- aztec_getEncryptedEvents: {
273
+ /* Logs and Events */
274
+ aztec_getPublicLogs: { params: { filter: LogFilter }; result: GetPublicLogsResponse };
275
+ aztec_getContractClassLogs: { params: { filter: LogFilter }; result: GetContractClassLogsResponse };
276
+ aztec_getPrivateEvents: {
276
277
  params: { event: EventMetadataDefinition; from: number; limit: number; vpks?: Point[] };
277
278
  result: unknown[];
278
279
  };
279
- aztec_getUnencryptedEvents: {
280
+ aztec_getPublicEvents: {
280
281
  params: { event: EventMetadataDefinition; from: number; limit: number };
281
282
  result: unknown[];
282
283
  };
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../tsconfig.base.json",
2
+ "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "src",
5
5
  "outDir": "dist",
package/vitest.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- testTimeout: 200, // .2 second timeout
5
+ testTimeout: 1000, // 1 second timeout
6
6
  coverage: {
7
7
  include: ['src/**/*.ts', '!src/**/types.ts', '!src/**/index.ts', '!src/**/*.test.ts'],
8
8
  },
@@ -1,40 +0,0 @@
1
- import type { ContractClassWithId } from '@aztec/circuits.js';
2
- /**
3
- * Serializes a ContractClassWithId instance to a JSON string.
4
- * Handles the conversion of complex Aztec types (Fr, Buffer, FunctionSelector) to their string representations.
5
- *
6
- * The serialization process handles the following contract components:
7
- * - version: Contract class version number
8
- * - artifactHash: Fr value representing the hash of the contract artifact
9
- * - privateFunctions: Array of private function definitions with selectors and VK hashes
10
- * - publicFunctions: Array of public function definitions with selectors and bytecode
11
- * - packedBytecode: Buffer containing the contract's packed bytecode
12
- * - id: Fr value representing the contract class ID
13
- *
14
- * @param contract - The contract class with ID to serialize
15
- * @returns JSON string representation of the contract class
16
- * @throws If any contract components cannot be properly serialized
17
- */
18
- export declare function serializeContractClassWithId(contract: ContractClassWithId): string;
19
- /**
20
- * Deserializes a JSON string into a ContractClassWithId instance.
21
- * Reconstructs complex Aztec types from their string representations.
22
- *
23
- * The deserialization process handles:
24
- * - version: Preserved as-is
25
- * - artifactHash: Reconstructed as Fr from hex string
26
- * - privateFunctions: Array of functions with:
27
- * * selector: Reconstructed as FunctionSelector
28
- * * vkHash: Reconstructed as Fr
29
- * - publicFunctions: Array of functions with:
30
- * * selector: Reconstructed as FunctionSelector
31
- * * bytecode: Reconstructed as Buffer
32
- * - packedBytecode: Reconstructed as Buffer from hex string
33
- * - id: Reconstructed as Fr from hex string
34
- *
35
- * @param json - The JSON string to deserialize, previously created by serializeContractClassWithId
36
- * @returns Reconstructed ContractClassWithId instance
37
- * @throws If the JSON string is malformed or contains invalid data
38
- */
39
- export declare function deserializeContractClassWithId(json: string): ContractClassWithId;
40
- //# sourceMappingURL=contract-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-utils.d.ts","sourceRoot":"","sources":["../../src/serializers/contract-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAmC,MAAM,oBAAoB,CAAC;AAI/F;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CAkClF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CA2BhF"}
@@ -1,102 +0,0 @@
1
- import { FunctionSelector } from '@aztec/foundation/abi';
2
- import { Fr } from '@aztec/aztec.js';
3
- /**
4
- * Serializes a ContractClassWithId instance to a JSON string.
5
- * Handles the conversion of complex Aztec types (Fr, Buffer, FunctionSelector) to their string representations.
6
- *
7
- * The serialization process handles the following contract components:
8
- * - version: Contract class version number
9
- * - artifactHash: Fr value representing the hash of the contract artifact
10
- * - privateFunctions: Array of private function definitions with selectors and VK hashes
11
- * - publicFunctions: Array of public function definitions with selectors and bytecode
12
- * - packedBytecode: Buffer containing the contract's packed bytecode
13
- * - id: Fr value representing the contract class ID
14
- *
15
- * @param contract - The contract class with ID to serialize
16
- * @returns JSON string representation of the contract class
17
- * @throws If any contract components cannot be properly serialized
18
- */
19
- export function serializeContractClassWithId(contract) {
20
- return JSON.stringify(contract, (key, value) => {
21
- let result = value;
22
- switch (key) {
23
- case 'version':
24
- result = value;
25
- break;
26
- case 'artifactHash':
27
- result = value.toString();
28
- break;
29
- case 'privateFunctions':
30
- result = value.map((fn) => ({
31
- selector: fn.selector.toString(),
32
- vkHash: fn.vkHash.toString(),
33
- }));
34
- break;
35
- case 'publicFunctions':
36
- result = value.map((fn) => ({
37
- selector: fn.selector.toString(),
38
- bytecode: fn.bytecode.toString('hex'),
39
- }));
40
- break;
41
- case 'packedBytecode':
42
- result = value.toString('hex');
43
- break;
44
- case 'id':
45
- result = value.toString();
46
- break;
47
- default:
48
- console.warn(`serializeContractClassWithId: Unknown key: ${key}`);
49
- break;
50
- }
51
- return result;
52
- });
53
- }
54
- /**
55
- * Deserializes a JSON string into a ContractClassWithId instance.
56
- * Reconstructs complex Aztec types from their string representations.
57
- *
58
- * The deserialization process handles:
59
- * - version: Preserved as-is
60
- * - artifactHash: Reconstructed as Fr from hex string
61
- * - privateFunctions: Array of functions with:
62
- * * selector: Reconstructed as FunctionSelector
63
- * * vkHash: Reconstructed as Fr
64
- * - publicFunctions: Array of functions with:
65
- * * selector: Reconstructed as FunctionSelector
66
- * * bytecode: Reconstructed as Buffer
67
- * - packedBytecode: Reconstructed as Buffer from hex string
68
- * - id: Reconstructed as Fr from hex string
69
- *
70
- * @param json - The JSON string to deserialize, previously created by serializeContractClassWithId
71
- * @returns Reconstructed ContractClassWithId instance
72
- * @throws If the JSON string is malformed or contains invalid data
73
- */
74
- export function deserializeContractClassWithId(json) {
75
- return JSON.parse(json, (key, value) => {
76
- switch (key) {
77
- case 'version':
78
- return value;
79
- case 'artifactHash':
80
- return Fr.fromHexString(value);
81
- case 'privateFunctions':
82
- return value.map((fn) => ({
83
- selector: FunctionSelector.fromString(fn.selector),
84
- vkHash: Fr.fromHexString(fn.vkHash),
85
- }));
86
- case 'publicFunctions':
87
- return value.map((fn) => ({
88
- selector: FunctionSelector.fromString(fn.selector),
89
- bytecode: Buffer.from(fn.bytecode, 'hex'),
90
- }));
91
- case 'packedBytecode':
92
- return Buffer.from(value, 'hex');
93
- case 'id':
94
- return Fr.fromHexString(value);
95
- default:
96
- console.warn(`deserializeContractClassWithId: Unknown key: ${key}`);
97
- break;
98
- }
99
- return value;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Q0FBQyxHQUFHLENBQUMsQ0FBQyxFQUF3QyxFQUFFLEVBQUUsQ0FBQyxDQUFDO29CQUM5RCxRQUFRLEVBQUUsZ0JBQWdCLENBQUMsVUFBVSxDQUFDLEVBQUUsQ0FBQyxRQUFRLENBQUM7b0JBQ2xELE1BQU0sRUFBRSxFQUFFLENBQUMsYUFBYSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUM7aUJBQ3BDLENBQUMsQ0FBQyxDQUFDO1lBQ04sS0FBSyxpQkFBaUI7Z0JBQ3BCLE9BQU8sS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQTBDLEVBQUUsRUFBRSxDQUFDLENBQUM7b0JBQ2hFLFFBQVEsRUFBRSxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsRUFBRSxDQUFDLFFBQVEsQ0FBQztvQkFDbEQsUUFBUSxFQUFFLE1BQU0sQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLFFBQVEsRUFBRSxLQUFLLENBQUM7aUJBQzFDLENBQUMsQ0FBQyxDQUFDO1lBQ04sS0FBSyxnQkFBZ0I7Z0JBQ25CLE9BQU8sTUFBTSxDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUM7WUFDbkMsS0FBSyxJQUFJO2dCQUNQLE9BQU8sRUFBRSxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNqQztnQkFDRSxPQUFPLENBQUMsSUFBSSxDQUFDLGdEQUFnRCxHQUFHLEVBQUUsQ0FBQyxDQUFDO2dCQUNwRSxNQUFNO1FBQ1YsQ0FBQztRQUNELE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQyxDQUFDLENBQUM7QUFDTCxDQUFDIn0=
@@ -1,110 +0,0 @@
1
- import { Fr, AztecAddress, CompleteAddress, AuthWitness, TxHash } from '@aztec/aztec.js';
2
- import type { TypeSerializer } from './types.js';
3
- /**
4
- * Serializer for Fr (field element) values in the Aztec protocol.
5
- * Handles conversion of field elements to/from base64-encoded strings for RPC transport.
6
- * Field elements are fundamental to Aztec's cryptographic operations.
7
- */
8
- export declare class FrSerializer implements TypeSerializer<Fr> {
9
- /**
10
- * Converts an Fr value to a base64-encoded string.
11
- * @param value - The field element to serialize
12
- * @returns Base64-encoded string representation
13
- */
14
- serialize(value: Fr): string;
15
- /**
16
- * Reconstructs an Fr value from a base64-encoded string.
17
- * @param data - The base64-encoded string to deserialize
18
- * @returns Reconstructed field element
19
- * @throws If the input string is not a valid field element representation
20
- */
21
- deserialize(data: string): Fr;
22
- }
23
- /**
24
- * Serializer for Aztec protocol addresses.
25
- * Handles conversion of AztecAddress instances to/from base64-encoded strings.
26
- * Aztec addresses represent accounts and contracts in the protocol.
27
- */
28
- export declare class AztecAddressSerializer implements TypeSerializer<AztecAddress> {
29
- /**
30
- * Converts an AztecAddress to a base64-encoded string.
31
- * @param value - The Aztec address to serialize
32
- * @returns Base64-encoded string representation
33
- */
34
- serialize(value: AztecAddress): string;
35
- /**
36
- * Reconstructs an AztecAddress from a base64-encoded string.
37
- * @param data - The base64-encoded string to deserialize
38
- * @returns Reconstructed Aztec address
39
- * @throws If the input string is not a valid address representation
40
- */
41
- deserialize(data: string): AztecAddress;
42
- }
43
- /**
44
- * Serializer for complete Aztec addresses that include additional metadata.
45
- * CompleteAddress extends AztecAddress with extra information needed for certain operations.
46
- */
47
- export declare class CompleteAddressSerializer implements TypeSerializer<CompleteAddress> {
48
- /**
49
- * Converts a CompleteAddress to a base64-encoded string.
50
- * @param value - The complete address to serialize
51
- * @returns Base64-encoded string representation
52
- */
53
- serialize(value: CompleteAddress): string;
54
- /**
55
- * Reconstructs a CompleteAddress from a base64-encoded string.
56
- * @param data - The base64-encoded string to deserialize
57
- * @returns Reconstructed complete address
58
- * @throws If the input string is not a valid complete address representation
59
- */
60
- deserialize(data: string): CompleteAddress;
61
- }
62
- /**
63
- * Serializer for authentication witnesses in the Aztec protocol.
64
- * AuthWitness values are used to prove transaction authorization.
65
- */
66
- export declare class AuthWitnessSerializer implements TypeSerializer<AuthWitness> {
67
- /**
68
- * Converts an AuthWitness to a base64-encoded string.
69
- * @param value - The authentication witness to serialize
70
- * @returns Base64-encoded string representation
71
- */
72
- serialize(value: AuthWitness): string;
73
- /**
74
- * Reconstructs an AuthWitness from a base64-encoded string.
75
- * @param data - The base64-encoded string to deserialize
76
- * @returns Reconstructed authentication witness
77
- * @throws If the input string is not a valid auth witness representation
78
- */
79
- deserialize(data: string): AuthWitness;
80
- }
81
- /**
82
- * Serializer for transaction hashes in the Aztec protocol.
83
- * TxHash values uniquely identify transactions and are used for lookups and references.
84
- */
85
- export declare class TxHashSerializer implements TypeSerializer<TxHash> {
86
- /**
87
- * Converts a TxHash to a base64-encoded string.
88
- * @param value - The transaction hash to serialize
89
- * @returns Base64-encoded string representation
90
- */
91
- serialize(value: TxHash): string;
92
- /**
93
- * Reconstructs a TxHash from a base64-encoded string.
94
- * @param data - The base64-encoded string to deserialize
95
- * @returns Reconstructed transaction hash
96
- * @throws If the input string is not a valid transaction hash representation
97
- */
98
- deserialize(data: string): TxHash;
99
- }
100
- /**
101
- * Pre-instantiated serializer instances for common Aztec types.
102
- * These singletons should be used instead of creating new instances
103
- * to ensure consistent serialization across the application.
104
- */
105
- export declare const frSerializer: FrSerializer;
106
- export declare const aztecAddressSerializer: AztecAddressSerializer;
107
- export declare const completeAddressSerializer: CompleteAddressSerializer;
108
- export declare const authWitnessSerializer: AuthWitnessSerializer;
109
- export declare const txHashSerializer: TxHashSerializer;
110
- //# sourceMappingURL=core.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/serializers/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD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{ Fr, AztecAddress, CompleteAddress, AuthWitness, TxHash } from '@aztec/aztec.js';
2
- import { encodeBase64, decodeBase64 } from './types.js';
3
- /**
4
- * Serializer for Fr (field element) values in the Aztec protocol.
5
- * Handles conversion of field elements to/from base64-encoded strings for RPC transport.
6
- * Field elements are fundamental to Aztec's cryptographic operations.
7
- */
8
- export class FrSerializer {
9
- /**
10
- * Converts an Fr value to a base64-encoded string.
11
- * @param value - The field element to serialize
12
- * @returns Base64-encoded string representation
13
- */
14
- serialize(value) {
15
- return encodeBase64(value.toString());
16
- }
17
- /**
18
- * Reconstructs an Fr value from a base64-encoded string.
19
- * @param data - The base64-encoded string to deserialize
20
- * @returns Reconstructed field element
21
- * @throws If the input string is not a valid field element representation
22
- */
23
- deserialize(data) {
24
- return Fr.fromHexString(decodeBase64(data));
25
- }
26
- }
27
- /**
28
- * Serializer for Aztec protocol addresses.
29
- * Handles conversion of AztecAddress instances to/from base64-encoded strings.
30
- * Aztec addresses represent accounts and contracts in the protocol.
31
- */
32
- export class AztecAddressSerializer {
33
- /**
34
- * Converts an AztecAddress to a base64-encoded string.
35
- * @param value - The Aztec address to serialize
36
- * @returns Base64-encoded string representation
37
- */
38
- serialize(value) {
39
- return encodeBase64(value.toString());
40
- }
41
- /**
42
- * Reconstructs an AztecAddress from a base64-encoded string.
43
- * @param data - The base64-encoded string to deserialize
44
- * @returns Reconstructed Aztec address
45
- * @throws If the input string is not a valid address representation
46
- */
47
- deserialize(data) {
48
- return AztecAddress.fromString(decodeBase64(data));
49
- }
50
- }
51
- /**
52
- * Serializer for complete Aztec addresses that include additional metadata.
53
- * CompleteAddress extends AztecAddress with extra information needed for certain operations.
54
- */
55
- export class CompleteAddressSerializer {
56
- /**
57
- * Converts a CompleteAddress to a base64-encoded string.
58
- * @param value - The complete address to serialize
59
- * @returns Base64-encoded string representation
60
- */
61
- serialize(value) {
62
- return encodeBase64(value.toString());
63
- }
64
- /**
65
- * Reconstructs a CompleteAddress from a base64-encoded string.
66
- * @param data - The base64-encoded string to deserialize
67
- * @returns Reconstructed complete address
68
- * @throws If the input string is not a valid complete address representation
69
- */
70
- deserialize(data) {
71
- return CompleteAddress.fromString(decodeBase64(data));
72
- }
73
- }
74
- /**
75
- * Serializer for authentication witnesses in the Aztec protocol.
76
- * AuthWitness values are used to prove transaction authorization.
77
- */
78
- export class AuthWitnessSerializer {
79
- /**
80
- * Converts an AuthWitness to a base64-encoded string.
81
- * @param value - The authentication witness to serialize
82
- * @returns Base64-encoded string representation
83
- */
84
- serialize(value) {
85
- return encodeBase64(value.toString());
86
- }
87
- /**
88
- * Reconstructs an AuthWitness from a base64-encoded string.
89
- * @param data - The base64-encoded string to deserialize
90
- * @returns Reconstructed authentication witness
91
- * @throws If the input string is not a valid auth witness representation
92
- */
93
- deserialize(data) {
94
- return AuthWitness.fromString(decodeBase64(data));
95
- }
96
- }
97
- /**
98
- * Serializer for transaction hashes in the Aztec protocol.
99
- * TxHash values uniquely identify transactions and are used for lookups and references.
100
- */
101
- export class TxHashSerializer {
102
- /**
103
- * Converts a TxHash to a base64-encoded string.
104
- * @param value - The transaction hash to serialize
105
- * @returns Base64-encoded string representation
106
- */
107
- serialize(value) {
108
- return encodeBase64(value.toString());
109
- }
110
- /**
111
- * Reconstructs a TxHash from a base64-encoded string.
112
- * @param data - The base64-encoded string to deserialize
113
- * @returns Reconstructed transaction hash
114
- * @throws If the input string is not a valid transaction hash representation
115
- */
116
- deserialize(data) {
117
- return TxHash.fromString(decodeBase64(data));
118
- }
119
- }
120
- /**
121
- * Pre-instantiated serializer instances for common Aztec types.
122
- * These singletons should be used instead of creating new instances
123
- * to ensure consistent serialization across the application.
124
- */
125
- export const frSerializer = new FrSerializer();
126
- export const aztecAddressSerializer = new AztecAddressSerializer();
127
- export const completeAddressSerializer = new CompleteAddressSerializer();
128
- export const authWitnessSerializer = new AuthWitnessSerializer();
129
- export const txHashSerializer = new TxHashSerializer();
130
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozL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UFDO0FBQ25FLE1BQU0sQ0FBQyxNQUFNLHlCQUF5QixHQUFHLElBQUkseUJBQXlCLEVBQUUsQ0FBQztBQUN6RSxNQUFNLENBQUMsTUFBTSxxQkFBcUIsR0FBRyxJQUFJLHFCQUFxQixFQUFFLENBQUM7QUFDakUsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUcsSUFBSSxnQkFBZ0IsRUFBRSxDQUFDIn0=
@@ -1,49 +0,0 @@
1
- import type { JSONRPCSerializedData, JSONRPCSerializer } from '@walletmesh/jsonrpc';
2
- /**
3
- * Base interface for type-specific serializers in the Aztec RPC wallet.
4
- * Provides a standardized way to convert Aztec-specific types to and from string representations
5
- * for network transmission. Each Aztec type (Fr, AztecAddress, etc.) implements this interface
6
- * to ensure consistent serialization across the RPC layer.
7
- *
8
- * @typeParam T - The Aztec type being serialized (e.g., Fr, AztecAddress, TxHash)
9
- */
10
- export interface TypeSerializer<T> {
11
- /**
12
- * Converts a value to its string representation for network transmission.
13
- * Implementations should ensure the serialized form can be correctly deserialized
14
- * back to the original type.
15
- *
16
- * @param value - The Aztec type value to serialize
17
- * @returns A string representation suitable for network transmission
18
- */
19
- serialize(value: T): string;
20
- /**
21
- * Reconstructs a value from its string representation.
22
- * Implementations should validate the input string and throw appropriate errors
23
- * if the data cannot be correctly deserialized.
24
- *
25
- * @param data - The string data to deserialize, previously created by serialize()
26
- * @returns The reconstructed Aztec type value
27
- * @throws If the data is invalid or cannot be deserialized
28
- */
29
- deserialize(data: string): T;
30
- }
31
- export type { JSONRPCSerializedData, JSONRPCSerializer };
32
- /**
33
- * Helper function to encode data as base64 for safe network transmission.
34
- * Used throughout the serializers to ensure consistent encoding of binary data.
35
- *
36
- * @param data - The string data to encode
37
- * @returns Base64 encoded string
38
- */
39
- export declare function encodeBase64(data: string): string;
40
- /**
41
- * Helper function to decode base64 data back to its original form.
42
- * Used throughout the serializers to decode data received over the network.
43
- *
44
- * @param data - The base64 encoded string to decode
45
- * @returns Original decoded string
46
- * @throws If the input is not valid base64
47
- */
48
- export declare function decodeBase64(data: string): string;
49
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/serializers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;IAE5B;;;;;;;;OAQG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC;CAC9B;AAGD,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Helper function to encode data as base64 for safe network transmission.
3
- * Used throughout the serializers to ensure consistent encoding of binary data.
4
- *
5
- * @param data - The string data to encode
6
- * @returns Base64 encoded string
7
- */
8
- export function encodeBase64(data) {
9
- return btoa(data);
10
- }
11
- /**
12
- * Helper function to decode base64 data back to its original form.
13
- * Used throughout the serializers to decode data received over the network.
14
- *
15
- * @param data - The base64 encoded string to decode
16
- * @returns Original decoded string
17
- * @throws If the input is not valid base64
18
- */
19
- export function decodeBase64(data) {
20
- return atob(data);
21
- }
22
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VyaWFsaXplcnMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0NBOzs7Ozs7R0FNRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQUMsSUFBWTtJQUN2QyxPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNwQixDQUFDO0FBRUQ7Ozs7Ozs7R0FPRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQUMsSUFBWTtJQUN2QyxPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztBQUNwQixDQUFDIn0=
@@ -1,104 +0,0 @@
1
- import type { ContractClassWithId, PrivateFunction, PublicFunction } from '@aztec/circuits.js';
2
- import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi';
3
- import { Fr } from '@aztec/aztec.js';
4
-
5
- /**
6
- * Serializes a ContractClassWithId instance to a JSON string.
7
- * Handles the conversion of complex Aztec types (Fr, Buffer, FunctionSelector) to their string representations.
8
- *
9
- * The serialization process handles the following contract components:
10
- * - version: Contract class version number
11
- * - artifactHash: Fr value representing the hash of the contract artifact
12
- * - privateFunctions: Array of private function definitions with selectors and VK hashes
13
- * - publicFunctions: Array of public function definitions with selectors and bytecode
14
- * - packedBytecode: Buffer containing the contract's packed bytecode
15
- * - id: Fr value representing the contract class ID
16
- *
17
- * @param contract - The contract class with ID to serialize
18
- * @returns JSON string representation of the contract class
19
- * @throws If any contract components cannot be properly serialized
20
- */
21
- export function serializeContractClassWithId(contract: ContractClassWithId): string {
22
- return JSON.stringify(contract, (key, value) => {
23
- let result = value;
24
- switch (key) {
25
- case 'version':
26
- result = value;
27
- break;
28
- case 'artifactHash':
29
- result = value.toString();
30
- break;
31
- case 'privateFunctions':
32
- result = value.map((fn: PrivateFunction) => ({
33
- selector: fn.selector.toString(),
34
- vkHash: fn.vkHash.toString(),
35
- }));
36
- break;
37
- case 'publicFunctions':
38
- result = value.map((fn: PublicFunction) => ({
39
- selector: fn.selector.toString(),
40
- bytecode: fn.bytecode.toString('hex'),
41
- }));
42
- break;
43
- case 'packedBytecode':
44
- result = value.toString('hex');
45
- break;
46
- case 'id':
47
- result = value.toString();
48
- break;
49
- default:
50
- console.warn(`serializeContractClassWithId: Unknown key: ${key}`);
51
- break;
52
- }
53
- return result;
54
- });
55
- }
56
-
57
- /**
58
- * Deserializes a JSON string into a ContractClassWithId instance.
59
- * Reconstructs complex Aztec types from their string representations.
60
- *
61
- * The deserialization process handles:
62
- * - version: Preserved as-is
63
- * - artifactHash: Reconstructed as Fr from hex string
64
- * - privateFunctions: Array of functions with:
65
- * * selector: Reconstructed as FunctionSelector
66
- * * vkHash: Reconstructed as Fr
67
- * - publicFunctions: Array of functions with:
68
- * * selector: Reconstructed as FunctionSelector
69
- * * bytecode: Reconstructed as Buffer
70
- * - packedBytecode: Reconstructed as Buffer from hex string
71
- * - id: Reconstructed as Fr from hex string
72
- *
73
- * @param json - The JSON string to deserialize, previously created by serializeContractClassWithId
74
- * @returns Reconstructed ContractClassWithId instance
75
- * @throws If the JSON string is malformed or contains invalid data
76
- */
77
- export function deserializeContractClassWithId(json: string): ContractClassWithId {
78
- return JSON.parse(json, (key, value) => {
79
- switch (key) {
80
- case 'version':
81
- return value;
82
- case 'artifactHash':
83
- return Fr.fromHexString(value);
84
- case 'privateFunctions':
85
- return value.map((fn: { selector: string; vkHash: string }) => ({
86
- selector: FunctionSelector.fromString(fn.selector),
87
- vkHash: Fr.fromHexString(fn.vkHash),
88
- }));
89
- case 'publicFunctions':
90
- return value.map((fn: { selector: string; bytecode: string }) => ({
91
- selector: FunctionSelector.fromString(fn.selector),
92
- bytecode: Buffer.from(fn.bytecode, 'hex'),
93
- }));
94
- case 'packedBytecode':
95
- return Buffer.from(value, 'hex');
96
- case 'id':
97
- return Fr.fromHexString(value);
98
- default:
99
- console.warn(`deserializeContractClassWithId: Unknown key: ${key}`);
100
- break;
101
- }
102
- return value;
103
- });
104
- }