@latticexyz/protocol-parser 2.0.0-alpha.1.222

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.
@@ -0,0 +1,221 @@
1
+ import { Hex } from "viem";
2
+ import { staticAbiTypes } from "./schemaAbiTypes";
3
+
4
+ // Fixed-length ABI types
5
+
6
+ export { staticAbiTypes };
7
+
8
+ export type StaticAbiType = (typeof staticAbiTypes)[number];
9
+
10
+ export type StaticPrimitiveType = number | bigint | boolean | Hex;
11
+
12
+ export const staticAbiTypeToDefaultValue = {
13
+ uint8: 0,
14
+ uint16: 0,
15
+ uint24: 0,
16
+ uint32: 0,
17
+ uint40: 0,
18
+ uint48: 0,
19
+ uint56: 0n,
20
+ uint64: 0n,
21
+ uint72: 0n,
22
+ uint80: 0n,
23
+ uint88: 0n,
24
+ uint96: 0n,
25
+ uint104: 0n,
26
+ uint112: 0n,
27
+ uint120: 0n,
28
+ uint128: 0n,
29
+ uint136: 0n,
30
+ uint144: 0n,
31
+ uint152: 0n,
32
+ uint160: 0n,
33
+ uint168: 0n,
34
+ uint176: 0n,
35
+ uint184: 0n,
36
+ uint192: 0n,
37
+ uint200: 0n,
38
+ uint208: 0n,
39
+ uint216: 0n,
40
+ uint224: 0n,
41
+ uint232: 0n,
42
+ uint240: 0n,
43
+ uint248: 0n,
44
+ uint256: 0n,
45
+
46
+ int8: 0,
47
+ int16: 0,
48
+ int24: 0,
49
+ int32: 0,
50
+ int40: 0,
51
+ int48: 0,
52
+ int56: 0n,
53
+ int64: 0n,
54
+ int72: 0n,
55
+ int80: 0n,
56
+ int88: 0n,
57
+ int96: 0n,
58
+ int104: 0n,
59
+ int112: 0n,
60
+ int120: 0n,
61
+ int128: 0n,
62
+ int136: 0n,
63
+ int144: 0n,
64
+ int152: 0n,
65
+ int160: 0n,
66
+ int168: 0n,
67
+ int176: 0n,
68
+ int184: 0n,
69
+ int192: 0n,
70
+ int200: 0n,
71
+ int208: 0n,
72
+ int216: 0n,
73
+ int224: 0n,
74
+ int232: 0n,
75
+ int240: 0n,
76
+ int248: 0n,
77
+ int256: 0n,
78
+
79
+ bytes1: "0x00",
80
+ bytes2: "0x0000",
81
+ bytes3: "0x000000",
82
+ bytes4: "0x00000000",
83
+ bytes5: "0x0000000000",
84
+ bytes6: "0x000000000000",
85
+ bytes7: "0x00000000000000",
86
+ bytes8: "0x0000000000000000",
87
+ bytes9: "0x000000000000000000",
88
+ bytes10: "0x00000000000000000000",
89
+ bytes11: "0x0000000000000000000000",
90
+ bytes12: "0x000000000000000000000000",
91
+ bytes13: "0x00000000000000000000000000",
92
+ bytes14: "0x0000000000000000000000000000",
93
+ bytes15: "0x000000000000000000000000000000",
94
+ bytes16: "0x00000000000000000000000000000000",
95
+ bytes17: "0x0000000000000000000000000000000000",
96
+ bytes18: "0x000000000000000000000000000000000000",
97
+ bytes19: "0x00000000000000000000000000000000000000",
98
+ bytes20: "0x0000000000000000000000000000000000000000",
99
+ bytes21: "0x000000000000000000000000000000000000000000",
100
+ bytes22: "0x00000000000000000000000000000000000000000000",
101
+ bytes23: "0x0000000000000000000000000000000000000000000000",
102
+ bytes24: "0x000000000000000000000000000000000000000000000000",
103
+ bytes25: "0x00000000000000000000000000000000000000000000000000",
104
+ bytes26: "0x0000000000000000000000000000000000000000000000000000",
105
+ bytes27: "0x000000000000000000000000000000000000000000000000000000",
106
+ bytes28: "0x00000000000000000000000000000000000000000000000000000000",
107
+ bytes29: "0x0000000000000000000000000000000000000000000000000000000000",
108
+ bytes30: "0x000000000000000000000000000000000000000000000000000000000000",
109
+ bytes31: "0x00000000000000000000000000000000000000000000000000000000000000",
110
+ bytes32: "0x0000000000000000000000000000000000000000000000000000000000000000",
111
+
112
+ bool: false,
113
+ address: "0x0000000000000000000000000000000000000000",
114
+ } as const satisfies Record<StaticAbiType, StaticPrimitiveType>;
115
+
116
+ export type StaticAbiTypeToPrimitiveType<TStaticAbiType extends StaticAbiType = StaticAbiType> =
117
+ (typeof staticAbiTypeToDefaultValue)[TStaticAbiType];
118
+
119
+ export const staticAbiTypeToByteLength = {
120
+ uint8: 1,
121
+ uint16: 2,
122
+ uint24: 3,
123
+ uint32: 4,
124
+ uint40: 5,
125
+ uint48: 6,
126
+ uint56: 7,
127
+ uint64: 9,
128
+ uint72: 9,
129
+ uint80: 10,
130
+ uint88: 11,
131
+ uint96: 12,
132
+ uint104: 13,
133
+ uint112: 14,
134
+ uint120: 15,
135
+ uint128: 16,
136
+ uint136: 17,
137
+ uint144: 18,
138
+ uint152: 19,
139
+ uint160: 20,
140
+ uint168: 21,
141
+ uint176: 22,
142
+ uint184: 23,
143
+ uint192: 24,
144
+ uint200: 25,
145
+ uint208: 26,
146
+ uint216: 27,
147
+ uint224: 28,
148
+ uint232: 29,
149
+ uint240: 30,
150
+ uint248: 31,
151
+ uint256: 32,
152
+
153
+ int8: 1,
154
+ int16: 2,
155
+ int24: 3,
156
+ int32: 4,
157
+ int40: 5,
158
+ int48: 6,
159
+ int56: 7,
160
+ int64: 9,
161
+ int72: 9,
162
+ int80: 10,
163
+ int88: 11,
164
+ int96: 12,
165
+ int104: 13,
166
+ int112: 14,
167
+ int120: 15,
168
+ int128: 16,
169
+ int136: 17,
170
+ int144: 18,
171
+ int152: 19,
172
+ int160: 20,
173
+ int168: 21,
174
+ int176: 22,
175
+ int184: 23,
176
+ int192: 24,
177
+ int200: 25,
178
+ int208: 26,
179
+ int216: 27,
180
+ int224: 28,
181
+ int232: 29,
182
+ int240: 30,
183
+ int248: 31,
184
+ int256: 32,
185
+
186
+ bytes1: 1,
187
+ bytes2: 2,
188
+ bytes3: 3,
189
+ bytes4: 4,
190
+ bytes5: 5,
191
+ bytes6: 6,
192
+ bytes7: 7,
193
+ bytes8: 8,
194
+ bytes9: 9,
195
+ bytes10: 10,
196
+ bytes11: 11,
197
+ bytes12: 12,
198
+ bytes13: 13,
199
+ bytes14: 14,
200
+ bytes15: 15,
201
+ bytes16: 16,
202
+ bytes17: 17,
203
+ bytes18: 18,
204
+ bytes19: 19,
205
+ bytes20: 20,
206
+ bytes21: 21,
207
+ bytes22: 22,
208
+ bytes23: 23,
209
+ bytes24: 24,
210
+ bytes25: 25,
211
+ bytes26: 26,
212
+ bytes27: 27,
213
+ bytes28: 28,
214
+ bytes29: 29,
215
+ bytes30: 30,
216
+ bytes31: 31,
217
+ bytes32: 32,
218
+
219
+ bool: 1,
220
+ address: 20,
221
+ } as const satisfies Record<StaticAbiType, number>;
package/src/utils.ts ADDED
@@ -0,0 +1,5 @@
1
+ export type TupleSplit<T, N extends number, O extends readonly any[] = readonly []> = O["length"] extends N
2
+ ? [O, T]
3
+ : T extends readonly [infer F, ...infer R]
4
+ ? TupleSplit<readonly [...R], N, readonly [...O, F]>
5
+ : [O, T];