@latticexyz/schema-type 2.0.12-type-resolutions-effc7ab1 → 2.0.12-type-resolutions-8538f80e
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/cache/solidity-files-cache.json +1 -1
- package/package.json +3 -2
- package/src/solidity/SchemaType.sol +230 -0
- package/src/typescript/arrayAbiTypes.test.ts +78 -0
- package/src/typescript/arrayAbiTypes.ts +47 -0
- package/src/typescript/deprecated/SchemaType.ts +202 -0
- package/src/typescript/deprecated/mappings/AbiTypeToDefaultValue.ts +208 -0
- package/src/typescript/deprecated/mappings/AbiTypeToPrimitiveType.ts +12 -0
- package/src/typescript/deprecated/mappings/AbiTypeToSchemaType.ts +6 -0
- package/src/typescript/deprecated/mappings/SchemaTypeArrayToElement.ts +109 -0
- package/src/typescript/deprecated/mappings/SchemaTypeToAbiType.ts +210 -0
- package/src/typescript/deprecated/mappings/SchemaTypeToPrimitiveType.ts +9 -0
- package/src/typescript/deprecated/mappings/index.ts +5 -0
- package/src/typescript/deprecated/mappings/types.test-d.ts +233 -0
- package/src/typescript/deprecated/types/AbiTypes.ts +5 -0
- package/src/typescript/deprecated/types/ArraySchemaType.ts +101 -0
- package/src/typescript/deprecated/types/DynamicSchemaType.ts +4 -0
- package/src/typescript/deprecated/types/StaticAbiTypes.ts +10 -0
- package/src/typescript/deprecated/types/StaticArray.ts +3 -0
- package/src/typescript/deprecated/types/StaticSchemaType.ts +4 -0
- package/src/typescript/deprecated/types/index.ts +8 -0
- package/src/typescript/deprecated/utils/encodeSchema.ts +48 -0
- package/src/typescript/deprecated/utils/getAbiTypeDefaultValue.ts +11 -0
- package/src/typescript/deprecated/utils/getStaticByteLength.ts +25 -0
- package/src/typescript/deprecated/utils/index.ts +3 -0
- package/src/typescript/dynamicAbiTypes.test-d.ts +66 -0
- package/src/typescript/dynamicAbiTypes.ts +128 -0
- package/src/typescript/exports/deprecated.ts +4 -0
- package/src/typescript/exports/index.ts +5 -0
- package/src/typescript/exports/internal.ts +6 -0
- package/src/typescript/schemaAbiTypeToDefaultValue.ts +8 -0
- package/src/typescript/schemaAbiTypeToPrimitiveType.ts +7 -0
- package/src/typescript/schemaAbiTypes.test.ts +17 -0
- package/src/typescript/schemaAbiTypes.ts +219 -0
- package/src/typescript/staticAbiTypes.test-d.ts +58 -0
- package/src/typescript/staticAbiTypes.ts +223 -0
- package/src/typescript/utils.ts +25 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
import { SchemaAbiType } from "./schemaAbiTypes";
|
2
|
+
import { DynamicAbiTypeToPrimitiveType, dynamicAbiTypeToDefaultValue } from "./dynamicAbiTypes";
|
3
|
+
import { StaticAbiTypeToPrimitiveType, staticAbiTypeToDefaultValue } from "./staticAbiTypes";
|
4
|
+
|
5
|
+
export const schemaAbiTypeToDefaultValue = {
|
6
|
+
...staticAbiTypeToDefaultValue,
|
7
|
+
...dynamicAbiTypeToDefaultValue,
|
8
|
+
} as const satisfies Record<SchemaAbiType, StaticAbiTypeToPrimitiveType | DynamicAbiTypeToPrimitiveType>;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { schemaAbiTypeToDefaultValue } from "./schemaAbiTypeToDefaultValue";
|
2
|
+
import { SchemaAbiType } from "./schemaAbiTypes";
|
3
|
+
import { LiteralToBroad } from "./utils";
|
4
|
+
|
5
|
+
export type SchemaAbiTypeToPrimitiveType<T extends SchemaAbiType> = LiteralToBroad<
|
6
|
+
(typeof schemaAbiTypeToDefaultValue)[T]
|
7
|
+
>;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import fs from "node:fs/promises";
|
3
|
+
import { schemaAbiTypes } from "./schemaAbiTypes";
|
4
|
+
|
5
|
+
describe("schemaAbiTypes", () => {
|
6
|
+
it("should be in sync with SchemaType.sol", async () => {
|
7
|
+
const source = await fs.readFile(`${__dirname}/../solidity/SchemaType.sol`, "utf8");
|
8
|
+
const matches = source.match(/enum SchemaType \{([\s\S]+?)\}/);
|
9
|
+
const soliditySchemaTypes = matches?.[1].replace(/\s/g, "").split(",") ?? [];
|
10
|
+
|
11
|
+
const soliditySchemaTypesAsAbiTypes = soliditySchemaTypes.map((soliditySchemaType) =>
|
12
|
+
soliditySchemaType.replace(/_ARRAY$/, "[]").toLowerCase(),
|
13
|
+
);
|
14
|
+
|
15
|
+
expect(soliditySchemaTypesAsAbiTypes).toStrictEqual(schemaAbiTypes);
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,219 @@
|
|
1
|
+
import { AbiType } from "abitype";
|
2
|
+
import { TupleSplit } from "./utils";
|
3
|
+
|
4
|
+
// Keep this array in sync with SchemaType.sol enum
|
5
|
+
export const schemaAbiTypes = [
|
6
|
+
"uint8",
|
7
|
+
"uint16",
|
8
|
+
"uint24",
|
9
|
+
"uint32",
|
10
|
+
"uint40",
|
11
|
+
"uint48",
|
12
|
+
"uint56",
|
13
|
+
"uint64",
|
14
|
+
"uint72",
|
15
|
+
"uint80",
|
16
|
+
"uint88",
|
17
|
+
"uint96",
|
18
|
+
"uint104",
|
19
|
+
"uint112",
|
20
|
+
"uint120",
|
21
|
+
"uint128",
|
22
|
+
"uint136",
|
23
|
+
"uint144",
|
24
|
+
"uint152",
|
25
|
+
"uint160",
|
26
|
+
"uint168",
|
27
|
+
"uint176",
|
28
|
+
"uint184",
|
29
|
+
"uint192",
|
30
|
+
"uint200",
|
31
|
+
"uint208",
|
32
|
+
"uint216",
|
33
|
+
"uint224",
|
34
|
+
"uint232",
|
35
|
+
"uint240",
|
36
|
+
"uint248",
|
37
|
+
"uint256",
|
38
|
+
"int8",
|
39
|
+
"int16",
|
40
|
+
"int24",
|
41
|
+
"int32",
|
42
|
+
"int40",
|
43
|
+
"int48",
|
44
|
+
"int56",
|
45
|
+
"int64",
|
46
|
+
"int72",
|
47
|
+
"int80",
|
48
|
+
"int88",
|
49
|
+
"int96",
|
50
|
+
"int104",
|
51
|
+
"int112",
|
52
|
+
"int120",
|
53
|
+
"int128",
|
54
|
+
"int136",
|
55
|
+
"int144",
|
56
|
+
"int152",
|
57
|
+
"int160",
|
58
|
+
"int168",
|
59
|
+
"int176",
|
60
|
+
"int184",
|
61
|
+
"int192",
|
62
|
+
"int200",
|
63
|
+
"int208",
|
64
|
+
"int216",
|
65
|
+
"int224",
|
66
|
+
"int232",
|
67
|
+
"int240",
|
68
|
+
"int248",
|
69
|
+
"int256",
|
70
|
+
"bytes1",
|
71
|
+
"bytes2",
|
72
|
+
"bytes3",
|
73
|
+
"bytes4",
|
74
|
+
"bytes5",
|
75
|
+
"bytes6",
|
76
|
+
"bytes7",
|
77
|
+
"bytes8",
|
78
|
+
"bytes9",
|
79
|
+
"bytes10",
|
80
|
+
"bytes11",
|
81
|
+
"bytes12",
|
82
|
+
"bytes13",
|
83
|
+
"bytes14",
|
84
|
+
"bytes15",
|
85
|
+
"bytes16",
|
86
|
+
"bytes17",
|
87
|
+
"bytes18",
|
88
|
+
"bytes19",
|
89
|
+
"bytes20",
|
90
|
+
"bytes21",
|
91
|
+
"bytes22",
|
92
|
+
"bytes23",
|
93
|
+
"bytes24",
|
94
|
+
"bytes25",
|
95
|
+
"bytes26",
|
96
|
+
"bytes27",
|
97
|
+
"bytes28",
|
98
|
+
"bytes29",
|
99
|
+
"bytes30",
|
100
|
+
"bytes31",
|
101
|
+
"bytes32",
|
102
|
+
"bool",
|
103
|
+
"address",
|
104
|
+
"uint8[]",
|
105
|
+
"uint16[]",
|
106
|
+
"uint24[]",
|
107
|
+
"uint32[]",
|
108
|
+
"uint40[]",
|
109
|
+
"uint48[]",
|
110
|
+
"uint56[]",
|
111
|
+
"uint64[]",
|
112
|
+
"uint72[]",
|
113
|
+
"uint80[]",
|
114
|
+
"uint88[]",
|
115
|
+
"uint96[]",
|
116
|
+
"uint104[]",
|
117
|
+
"uint112[]",
|
118
|
+
"uint120[]",
|
119
|
+
"uint128[]",
|
120
|
+
"uint136[]",
|
121
|
+
"uint144[]",
|
122
|
+
"uint152[]",
|
123
|
+
"uint160[]",
|
124
|
+
"uint168[]",
|
125
|
+
"uint176[]",
|
126
|
+
"uint184[]",
|
127
|
+
"uint192[]",
|
128
|
+
"uint200[]",
|
129
|
+
"uint208[]",
|
130
|
+
"uint216[]",
|
131
|
+
"uint224[]",
|
132
|
+
"uint232[]",
|
133
|
+
"uint240[]",
|
134
|
+
"uint248[]",
|
135
|
+
"uint256[]",
|
136
|
+
"int8[]",
|
137
|
+
"int16[]",
|
138
|
+
"int24[]",
|
139
|
+
"int32[]",
|
140
|
+
"int40[]",
|
141
|
+
"int48[]",
|
142
|
+
"int56[]",
|
143
|
+
"int64[]",
|
144
|
+
"int72[]",
|
145
|
+
"int80[]",
|
146
|
+
"int88[]",
|
147
|
+
"int96[]",
|
148
|
+
"int104[]",
|
149
|
+
"int112[]",
|
150
|
+
"int120[]",
|
151
|
+
"int128[]",
|
152
|
+
"int136[]",
|
153
|
+
"int144[]",
|
154
|
+
"int152[]",
|
155
|
+
"int160[]",
|
156
|
+
"int168[]",
|
157
|
+
"int176[]",
|
158
|
+
"int184[]",
|
159
|
+
"int192[]",
|
160
|
+
"int200[]",
|
161
|
+
"int208[]",
|
162
|
+
"int216[]",
|
163
|
+
"int224[]",
|
164
|
+
"int232[]",
|
165
|
+
"int240[]",
|
166
|
+
"int248[]",
|
167
|
+
"int256[]",
|
168
|
+
"bytes1[]",
|
169
|
+
"bytes2[]",
|
170
|
+
"bytes3[]",
|
171
|
+
"bytes4[]",
|
172
|
+
"bytes5[]",
|
173
|
+
"bytes6[]",
|
174
|
+
"bytes7[]",
|
175
|
+
"bytes8[]",
|
176
|
+
"bytes9[]",
|
177
|
+
"bytes10[]",
|
178
|
+
"bytes11[]",
|
179
|
+
"bytes12[]",
|
180
|
+
"bytes13[]",
|
181
|
+
"bytes14[]",
|
182
|
+
"bytes15[]",
|
183
|
+
"bytes16[]",
|
184
|
+
"bytes17[]",
|
185
|
+
"bytes18[]",
|
186
|
+
"bytes19[]",
|
187
|
+
"bytes20[]",
|
188
|
+
"bytes21[]",
|
189
|
+
"bytes22[]",
|
190
|
+
"bytes23[]",
|
191
|
+
"bytes24[]",
|
192
|
+
"bytes25[]",
|
193
|
+
"bytes26[]",
|
194
|
+
"bytes27[]",
|
195
|
+
"bytes28[]",
|
196
|
+
"bytes29[]",
|
197
|
+
"bytes30[]",
|
198
|
+
"bytes31[]",
|
199
|
+
"bytes32[]",
|
200
|
+
"bool[]",
|
201
|
+
"address[]",
|
202
|
+
"bytes",
|
203
|
+
"string",
|
204
|
+
] as const satisfies readonly AbiType[];
|
205
|
+
|
206
|
+
export type SchemaAbiType = (typeof schemaAbiTypes)[number];
|
207
|
+
|
208
|
+
// These are defined here to keep the index position (98) consolidated, since we use it both in runtime code and type definition
|
209
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
210
|
+
export const staticAbiTypes = schemaAbiTypes.slice(0, 98) as any as TupleSplit<typeof schemaAbiTypes, 98>[0];
|
211
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
212
|
+
export const dynamicAbiTypes = schemaAbiTypes.slice(98) as any as TupleSplit<typeof schemaAbiTypes, 98>[1];
|
213
|
+
|
214
|
+
export type StaticAbiType = (typeof staticAbiTypes)[number];
|
215
|
+
export type DynamicAbiType = (typeof dynamicAbiTypes)[number];
|
216
|
+
|
217
|
+
export function isSchemaAbiType(abiType: unknown): abiType is SchemaAbiType {
|
218
|
+
return schemaAbiTypes.includes(abiType as SchemaAbiType);
|
219
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { describe, expectTypeOf, it } from "vitest";
|
2
|
+
import { Hex } from "viem";
|
3
|
+
import { StaticAbiTypeToPrimitiveType } from "./staticAbiTypes";
|
4
|
+
|
5
|
+
describe("StaticAbiTypeToPrimitiveType", () => {
|
6
|
+
it("maps uint8 to number", () => {
|
7
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"uint8">>().toBeNumber();
|
8
|
+
});
|
9
|
+
it("maps uint32 to number", () => {
|
10
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"uint32">>().toBeNumber();
|
11
|
+
});
|
12
|
+
it("maps uint48 to number", () => {
|
13
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"uint48">>().toBeNumber();
|
14
|
+
});
|
15
|
+
it("maps uint56 to number", () => {
|
16
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"uint56">>().toMatchTypeOf<bigint>();
|
17
|
+
});
|
18
|
+
it("maps uint256 to number", () => {
|
19
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"uint256">>().toMatchTypeOf<bigint>();
|
20
|
+
});
|
21
|
+
|
22
|
+
it("maps int8 to number", () => {
|
23
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"int8">>().toBeNumber();
|
24
|
+
});
|
25
|
+
it("maps int32 to number", () => {
|
26
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"int32">>().toBeNumber();
|
27
|
+
});
|
28
|
+
it("maps int48 to number", () => {
|
29
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"int48">>().toBeNumber();
|
30
|
+
});
|
31
|
+
it("maps int56 to number", () => {
|
32
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"int56">>().toMatchTypeOf<bigint>();
|
33
|
+
});
|
34
|
+
it("maps int256 to number", () => {
|
35
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"int256">>().toMatchTypeOf<bigint>();
|
36
|
+
});
|
37
|
+
|
38
|
+
it("maps bytes1 to hex", () => {
|
39
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"bytes1">>().toMatchTypeOf<Hex>();
|
40
|
+
});
|
41
|
+
it("maps bytes2 to hex", () => {
|
42
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"bytes2">>().toMatchTypeOf<Hex>();
|
43
|
+
});
|
44
|
+
it("maps bytes8 to hex", () => {
|
45
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"bytes8">>().toMatchTypeOf<Hex>();
|
46
|
+
});
|
47
|
+
it("maps bytes32 to hex", () => {
|
48
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"bytes32">>().toMatchTypeOf<Hex>();
|
49
|
+
});
|
50
|
+
|
51
|
+
it("maps bool to boolean", () => {
|
52
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"bool">>().toBeBoolean();
|
53
|
+
});
|
54
|
+
|
55
|
+
it("maps address to hex", () => {
|
56
|
+
expectTypeOf<StaticAbiTypeToPrimitiveType<"address">>().toMatchTypeOf<Hex>();
|
57
|
+
});
|
58
|
+
});
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import { Hex } from "viem";
|
2
|
+
import { StaticAbiType, staticAbiTypes } from "./schemaAbiTypes";
|
3
|
+
import { LiteralToBroad } from "./utils";
|
4
|
+
|
5
|
+
// Fixed-length ABI types
|
6
|
+
|
7
|
+
export type StaticPrimitiveType = number | bigint | boolean | Hex;
|
8
|
+
|
9
|
+
export const staticAbiTypeToDefaultValue = {
|
10
|
+
uint8: 0,
|
11
|
+
uint16: 0,
|
12
|
+
uint24: 0,
|
13
|
+
uint32: 0,
|
14
|
+
uint40: 0,
|
15
|
+
uint48: 0,
|
16
|
+
uint56: 0n,
|
17
|
+
uint64: 0n,
|
18
|
+
uint72: 0n,
|
19
|
+
uint80: 0n,
|
20
|
+
uint88: 0n,
|
21
|
+
uint96: 0n,
|
22
|
+
uint104: 0n,
|
23
|
+
uint112: 0n,
|
24
|
+
uint120: 0n,
|
25
|
+
uint128: 0n,
|
26
|
+
uint136: 0n,
|
27
|
+
uint144: 0n,
|
28
|
+
uint152: 0n,
|
29
|
+
uint160: 0n,
|
30
|
+
uint168: 0n,
|
31
|
+
uint176: 0n,
|
32
|
+
uint184: 0n,
|
33
|
+
uint192: 0n,
|
34
|
+
uint200: 0n,
|
35
|
+
uint208: 0n,
|
36
|
+
uint216: 0n,
|
37
|
+
uint224: 0n,
|
38
|
+
uint232: 0n,
|
39
|
+
uint240: 0n,
|
40
|
+
uint248: 0n,
|
41
|
+
uint256: 0n,
|
42
|
+
|
43
|
+
int8: 0,
|
44
|
+
int16: 0,
|
45
|
+
int24: 0,
|
46
|
+
int32: 0,
|
47
|
+
int40: 0,
|
48
|
+
int48: 0,
|
49
|
+
int56: 0n,
|
50
|
+
int64: 0n,
|
51
|
+
int72: 0n,
|
52
|
+
int80: 0n,
|
53
|
+
int88: 0n,
|
54
|
+
int96: 0n,
|
55
|
+
int104: 0n,
|
56
|
+
int112: 0n,
|
57
|
+
int120: 0n,
|
58
|
+
int128: 0n,
|
59
|
+
int136: 0n,
|
60
|
+
int144: 0n,
|
61
|
+
int152: 0n,
|
62
|
+
int160: 0n,
|
63
|
+
int168: 0n,
|
64
|
+
int176: 0n,
|
65
|
+
int184: 0n,
|
66
|
+
int192: 0n,
|
67
|
+
int200: 0n,
|
68
|
+
int208: 0n,
|
69
|
+
int216: 0n,
|
70
|
+
int224: 0n,
|
71
|
+
int232: 0n,
|
72
|
+
int240: 0n,
|
73
|
+
int248: 0n,
|
74
|
+
int256: 0n,
|
75
|
+
|
76
|
+
bytes1: "0x00",
|
77
|
+
bytes2: "0x0000",
|
78
|
+
bytes3: "0x000000",
|
79
|
+
bytes4: "0x00000000",
|
80
|
+
bytes5: "0x0000000000",
|
81
|
+
bytes6: "0x000000000000",
|
82
|
+
bytes7: "0x00000000000000",
|
83
|
+
bytes8: "0x0000000000000000",
|
84
|
+
bytes9: "0x000000000000000000",
|
85
|
+
bytes10: "0x00000000000000000000",
|
86
|
+
bytes11: "0x0000000000000000000000",
|
87
|
+
bytes12: "0x000000000000000000000000",
|
88
|
+
bytes13: "0x00000000000000000000000000",
|
89
|
+
bytes14: "0x0000000000000000000000000000",
|
90
|
+
bytes15: "0x000000000000000000000000000000",
|
91
|
+
bytes16: "0x00000000000000000000000000000000",
|
92
|
+
bytes17: "0x0000000000000000000000000000000000",
|
93
|
+
bytes18: "0x000000000000000000000000000000000000",
|
94
|
+
bytes19: "0x00000000000000000000000000000000000000",
|
95
|
+
bytes20: "0x0000000000000000000000000000000000000000",
|
96
|
+
bytes21: "0x000000000000000000000000000000000000000000",
|
97
|
+
bytes22: "0x00000000000000000000000000000000000000000000",
|
98
|
+
bytes23: "0x0000000000000000000000000000000000000000000000",
|
99
|
+
bytes24: "0x000000000000000000000000000000000000000000000000",
|
100
|
+
bytes25: "0x00000000000000000000000000000000000000000000000000",
|
101
|
+
bytes26: "0x0000000000000000000000000000000000000000000000000000",
|
102
|
+
bytes27: "0x000000000000000000000000000000000000000000000000000000",
|
103
|
+
bytes28: "0x00000000000000000000000000000000000000000000000000000000",
|
104
|
+
bytes29: "0x0000000000000000000000000000000000000000000000000000000000",
|
105
|
+
bytes30: "0x000000000000000000000000000000000000000000000000000000000000",
|
106
|
+
bytes31: "0x00000000000000000000000000000000000000000000000000000000000000",
|
107
|
+
bytes32: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
108
|
+
|
109
|
+
bool: false,
|
110
|
+
address: "0x0000000000000000000000000000000000000000",
|
111
|
+
} as const satisfies Record<StaticAbiType, StaticPrimitiveType>;
|
112
|
+
|
113
|
+
export type StaticAbiTypeToPrimitiveType<TStaticAbiType extends StaticAbiType = StaticAbiType> = LiteralToBroad<
|
114
|
+
(typeof staticAbiTypeToDefaultValue)[TStaticAbiType]
|
115
|
+
>;
|
116
|
+
|
117
|
+
export const staticAbiTypeToByteLength = {
|
118
|
+
uint8: 1,
|
119
|
+
uint16: 2,
|
120
|
+
uint24: 3,
|
121
|
+
uint32: 4,
|
122
|
+
uint40: 5,
|
123
|
+
uint48: 6,
|
124
|
+
uint56: 7,
|
125
|
+
uint64: 8,
|
126
|
+
uint72: 9,
|
127
|
+
uint80: 10,
|
128
|
+
uint88: 11,
|
129
|
+
uint96: 12,
|
130
|
+
uint104: 13,
|
131
|
+
uint112: 14,
|
132
|
+
uint120: 15,
|
133
|
+
uint128: 16,
|
134
|
+
uint136: 17,
|
135
|
+
uint144: 18,
|
136
|
+
uint152: 19,
|
137
|
+
uint160: 20,
|
138
|
+
uint168: 21,
|
139
|
+
uint176: 22,
|
140
|
+
uint184: 23,
|
141
|
+
uint192: 24,
|
142
|
+
uint200: 25,
|
143
|
+
uint208: 26,
|
144
|
+
uint216: 27,
|
145
|
+
uint224: 28,
|
146
|
+
uint232: 29,
|
147
|
+
uint240: 30,
|
148
|
+
uint248: 31,
|
149
|
+
uint256: 32,
|
150
|
+
|
151
|
+
int8: 1,
|
152
|
+
int16: 2,
|
153
|
+
int24: 3,
|
154
|
+
int32: 4,
|
155
|
+
int40: 5,
|
156
|
+
int48: 6,
|
157
|
+
int56: 7,
|
158
|
+
int64: 8,
|
159
|
+
int72: 9,
|
160
|
+
int80: 10,
|
161
|
+
int88: 11,
|
162
|
+
int96: 12,
|
163
|
+
int104: 13,
|
164
|
+
int112: 14,
|
165
|
+
int120: 15,
|
166
|
+
int128: 16,
|
167
|
+
int136: 17,
|
168
|
+
int144: 18,
|
169
|
+
int152: 19,
|
170
|
+
int160: 20,
|
171
|
+
int168: 21,
|
172
|
+
int176: 22,
|
173
|
+
int184: 23,
|
174
|
+
int192: 24,
|
175
|
+
int200: 25,
|
176
|
+
int208: 26,
|
177
|
+
int216: 27,
|
178
|
+
int224: 28,
|
179
|
+
int232: 29,
|
180
|
+
int240: 30,
|
181
|
+
int248: 31,
|
182
|
+
int256: 32,
|
183
|
+
|
184
|
+
bytes1: 1,
|
185
|
+
bytes2: 2,
|
186
|
+
bytes3: 3,
|
187
|
+
bytes4: 4,
|
188
|
+
bytes5: 5,
|
189
|
+
bytes6: 6,
|
190
|
+
bytes7: 7,
|
191
|
+
bytes8: 8,
|
192
|
+
bytes9: 9,
|
193
|
+
bytes10: 10,
|
194
|
+
bytes11: 11,
|
195
|
+
bytes12: 12,
|
196
|
+
bytes13: 13,
|
197
|
+
bytes14: 14,
|
198
|
+
bytes15: 15,
|
199
|
+
bytes16: 16,
|
200
|
+
bytes17: 17,
|
201
|
+
bytes18: 18,
|
202
|
+
bytes19: 19,
|
203
|
+
bytes20: 20,
|
204
|
+
bytes21: 21,
|
205
|
+
bytes22: 22,
|
206
|
+
bytes23: 23,
|
207
|
+
bytes24: 24,
|
208
|
+
bytes25: 25,
|
209
|
+
bytes26: 26,
|
210
|
+
bytes27: 27,
|
211
|
+
bytes28: 28,
|
212
|
+
bytes29: 29,
|
213
|
+
bytes30: 30,
|
214
|
+
bytes31: 31,
|
215
|
+
bytes32: 32,
|
216
|
+
|
217
|
+
bool: 1,
|
218
|
+
address: 20,
|
219
|
+
} as const satisfies Record<StaticAbiType, number>;
|
220
|
+
|
221
|
+
export function isStaticAbiType(abiType: unknown): abiType is StaticAbiType {
|
222
|
+
return staticAbiTypes.includes(abiType as StaticAbiType);
|
223
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Hex } from "viem";
|
2
|
+
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
4
|
+
export type TupleSplit<T, N extends number, O extends readonly any[] = readonly []> = O["length"] extends N
|
5
|
+
? [O, T]
|
6
|
+
: T extends readonly [infer F, ...infer R]
|
7
|
+
? TupleSplit<readonly [...R], N, readonly [...O, F]>
|
8
|
+
: [O, T];
|
9
|
+
|
10
|
+
export type LiteralToBroad<T> =
|
11
|
+
T extends Readonly<Array<infer Element>>
|
12
|
+
? readonly LiteralToBroad<Element>[]
|
13
|
+
: T extends Array<infer Element>
|
14
|
+
? LiteralToBroad<Element>[]
|
15
|
+
: T extends number
|
16
|
+
? number
|
17
|
+
: T extends bigint
|
18
|
+
? bigint
|
19
|
+
: T extends Hex
|
20
|
+
? Hex
|
21
|
+
: T extends boolean
|
22
|
+
? boolean
|
23
|
+
: T extends string
|
24
|
+
? string
|
25
|
+
: never;
|