@latticexyz/schema-type 2.0.0-alpha.1.21 → 2.0.0-alpha.1.210
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/dist/typescript/index.js +1 -8
- package/dist/typescript/index.js.map +1 -1
- package/package.json +14 -10
- package/src/typescript/index.ts +4 -15
- package/src/typescript/mappings/AbiTypeToDefaultValue.ts +208 -0
- package/src/typescript/mappings/AbiTypeToPrimitiveType.ts +12 -0
- package/src/typescript/{AbiTypeToSchemaType.ts → mappings/AbiTypeToSchemaType.ts} +2 -2
- package/src/typescript/{SchemaTypeArrayToElement.ts → mappings/SchemaTypeArrayToElement.ts} +4 -4
- package/src/typescript/{SchemaTypeToAbiType.ts → mappings/SchemaTypeToAbiType.ts} +1 -1
- package/src/typescript/mappings/SchemaTypeToPrimitiveType.ts +9 -0
- package/src/typescript/mappings/index.ts +5 -0
- package/src/typescript/{SchemaTypeToPrimitive.ts → mappings/types.test-d.ts} +25 -2
- package/src/typescript/{AbiTypes.ts → types/AbiTypes.ts} +2 -2
- package/src/typescript/{ArraySchemaType.ts → types/ArraySchemaType.ts} +1 -1
- package/src/typescript/types/DynamicSchemaType.ts +4 -0
- package/src/typescript/types/StaticAbiTypes.ts +10 -0
- package/src/typescript/types/StaticArray.ts +3 -0
- package/src/typescript/types/StaticSchemaType.ts +4 -0
- package/src/typescript/types/index.ts +8 -0
- package/src/typescript/{encodeSchema.ts → utils/encodeSchema.ts} +2 -2
- package/src/typescript/utils/getAbiTypeDefaultValue.ts +11 -0
- package/src/typescript/{getStaticByteLength.ts → utils/getStaticByteLength.ts} +1 -1
- package/src/typescript/utils/index.ts +3 -0
- package/dist/typescript/AbiTypeToSchemaType.d.ts +0 -4
- package/dist/typescript/AbiTypeToSchemaType.js +0 -3
- package/dist/typescript/AbiTypeToSchemaType.js.map +0 -1
- package/dist/typescript/AbiTypes.d.ts +0 -4
- package/dist/typescript/AbiTypes.js +0 -3
- package/dist/typescript/AbiTypes.js.map +0 -1
- package/dist/typescript/ArraySchemaType.d.ts +0 -2
- package/dist/typescript/ArraySchemaType.js +0 -2
- package/dist/typescript/ArraySchemaType.js.map +0 -1
- package/dist/typescript/DynamicSchemaType.d.ts +0 -3
- package/dist/typescript/DynamicSchemaType.js +0 -2
- package/dist/typescript/DynamicSchemaType.js.map +0 -1
- package/dist/typescript/SchemaType.d.ts +0 -200
- package/dist/typescript/SchemaType.js +0 -204
- package/dist/typescript/SchemaType.js.map +0 -1
- package/dist/typescript/SchemaTypeArrayToElement.d.ts +0 -201
- package/dist/typescript/SchemaTypeArrayToElement.js +0 -102
- package/dist/typescript/SchemaTypeArrayToElement.js.map +0 -1
- package/dist/typescript/SchemaTypeToAbiType.d.ts +0 -200
- package/dist/typescript/SchemaTypeToAbiType.js +0 -202
- package/dist/typescript/SchemaTypeToAbiType.js.map +0 -1
- package/dist/typescript/SchemaTypeToPrimitive.d.ts +0 -201
- package/dist/typescript/SchemaTypeToPrimitive.js +0 -2
- package/dist/typescript/SchemaTypeToPrimitive.js.map +0 -1
- package/dist/typescript/StaticAbiTypes.d.ts +0 -4
- package/dist/typescript/StaticAbiTypes.js +0 -5
- package/dist/typescript/StaticAbiTypes.js.map +0 -1
- package/dist/typescript/StaticSchemaType.d.ts +0 -3
- package/dist/typescript/StaticSchemaType.js +0 -2
- package/dist/typescript/StaticSchemaType.js.map +0 -1
- package/dist/typescript/encodeSchema.d.ts +0 -8
- package/dist/typescript/encodeSchema.js +0 -43
- package/dist/typescript/encodeSchema.js.map +0 -1
- package/dist/typescript/getStaticByteLength.d.ts +0 -2
- package/dist/typescript/getStaticByteLength.js +0 -26
- package/dist/typescript/getStaticByteLength.js.map +0 -1
- package/dist/typescript/index.d.ts +0 -14
- package/src/typescript/DynamicSchemaType.ts +0 -4
- package/src/typescript/StaticAbiTypes.ts +0 -10
- package/src/typescript/StaticSchemaType.ts +0 -4
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { SchemaType } from "./SchemaType.js";
|
|
2
|
-
export type SchemaTypeToPrimitive = {
|
|
3
|
-
[SchemaType.UINT8]: number;
|
|
4
|
-
[SchemaType.UINT16]: number;
|
|
5
|
-
[SchemaType.UINT24]: number;
|
|
6
|
-
[SchemaType.UINT32]: number;
|
|
7
|
-
[SchemaType.UINT40]: number;
|
|
8
|
-
[SchemaType.UINT48]: number;
|
|
9
|
-
[SchemaType.UINT56]: bigint;
|
|
10
|
-
[SchemaType.UINT64]: bigint;
|
|
11
|
-
[SchemaType.UINT72]: bigint;
|
|
12
|
-
[SchemaType.UINT80]: bigint;
|
|
13
|
-
[SchemaType.UINT88]: bigint;
|
|
14
|
-
[SchemaType.UINT96]: bigint;
|
|
15
|
-
[SchemaType.UINT104]: bigint;
|
|
16
|
-
[SchemaType.UINT112]: bigint;
|
|
17
|
-
[SchemaType.UINT120]: bigint;
|
|
18
|
-
[SchemaType.UINT128]: bigint;
|
|
19
|
-
[SchemaType.UINT136]: bigint;
|
|
20
|
-
[SchemaType.UINT144]: bigint;
|
|
21
|
-
[SchemaType.UINT152]: bigint;
|
|
22
|
-
[SchemaType.UINT160]: bigint;
|
|
23
|
-
[SchemaType.UINT168]: bigint;
|
|
24
|
-
[SchemaType.UINT176]: bigint;
|
|
25
|
-
[SchemaType.UINT184]: bigint;
|
|
26
|
-
[SchemaType.UINT192]: bigint;
|
|
27
|
-
[SchemaType.UINT200]: bigint;
|
|
28
|
-
[SchemaType.UINT208]: bigint;
|
|
29
|
-
[SchemaType.UINT216]: bigint;
|
|
30
|
-
[SchemaType.UINT224]: bigint;
|
|
31
|
-
[SchemaType.UINT232]: bigint;
|
|
32
|
-
[SchemaType.UINT240]: bigint;
|
|
33
|
-
[SchemaType.UINT248]: bigint;
|
|
34
|
-
[SchemaType.UINT256]: bigint;
|
|
35
|
-
[SchemaType.INT8]: number;
|
|
36
|
-
[SchemaType.INT16]: number;
|
|
37
|
-
[SchemaType.INT24]: number;
|
|
38
|
-
[SchemaType.INT32]: number;
|
|
39
|
-
[SchemaType.INT40]: number;
|
|
40
|
-
[SchemaType.INT48]: number;
|
|
41
|
-
[SchemaType.INT56]: bigint;
|
|
42
|
-
[SchemaType.INT64]: bigint;
|
|
43
|
-
[SchemaType.INT72]: bigint;
|
|
44
|
-
[SchemaType.INT80]: bigint;
|
|
45
|
-
[SchemaType.INT88]: bigint;
|
|
46
|
-
[SchemaType.INT96]: bigint;
|
|
47
|
-
[SchemaType.INT104]: bigint;
|
|
48
|
-
[SchemaType.INT112]: bigint;
|
|
49
|
-
[SchemaType.INT120]: bigint;
|
|
50
|
-
[SchemaType.INT128]: bigint;
|
|
51
|
-
[SchemaType.INT136]: bigint;
|
|
52
|
-
[SchemaType.INT144]: bigint;
|
|
53
|
-
[SchemaType.INT152]: bigint;
|
|
54
|
-
[SchemaType.INT160]: bigint;
|
|
55
|
-
[SchemaType.INT168]: bigint;
|
|
56
|
-
[SchemaType.INT176]: bigint;
|
|
57
|
-
[SchemaType.INT184]: bigint;
|
|
58
|
-
[SchemaType.INT192]: bigint;
|
|
59
|
-
[SchemaType.INT200]: bigint;
|
|
60
|
-
[SchemaType.INT208]: bigint;
|
|
61
|
-
[SchemaType.INT216]: bigint;
|
|
62
|
-
[SchemaType.INT224]: bigint;
|
|
63
|
-
[SchemaType.INT232]: bigint;
|
|
64
|
-
[SchemaType.INT240]: bigint;
|
|
65
|
-
[SchemaType.INT248]: bigint;
|
|
66
|
-
[SchemaType.INT256]: bigint;
|
|
67
|
-
[SchemaType.BYTES1]: string;
|
|
68
|
-
[SchemaType.BYTES2]: string;
|
|
69
|
-
[SchemaType.BYTES3]: string;
|
|
70
|
-
[SchemaType.BYTES4]: string;
|
|
71
|
-
[SchemaType.BYTES5]: string;
|
|
72
|
-
[SchemaType.BYTES6]: string;
|
|
73
|
-
[SchemaType.BYTES7]: string;
|
|
74
|
-
[SchemaType.BYTES8]: string;
|
|
75
|
-
[SchemaType.BYTES9]: string;
|
|
76
|
-
[SchemaType.BYTES10]: string;
|
|
77
|
-
[SchemaType.BYTES11]: string;
|
|
78
|
-
[SchemaType.BYTES12]: string;
|
|
79
|
-
[SchemaType.BYTES13]: string;
|
|
80
|
-
[SchemaType.BYTES14]: string;
|
|
81
|
-
[SchemaType.BYTES15]: string;
|
|
82
|
-
[SchemaType.BYTES16]: string;
|
|
83
|
-
[SchemaType.BYTES17]: string;
|
|
84
|
-
[SchemaType.BYTES18]: string;
|
|
85
|
-
[SchemaType.BYTES19]: string;
|
|
86
|
-
[SchemaType.BYTES20]: string;
|
|
87
|
-
[SchemaType.BYTES21]: string;
|
|
88
|
-
[SchemaType.BYTES22]: string;
|
|
89
|
-
[SchemaType.BYTES23]: string;
|
|
90
|
-
[SchemaType.BYTES24]: string;
|
|
91
|
-
[SchemaType.BYTES25]: string;
|
|
92
|
-
[SchemaType.BYTES26]: string;
|
|
93
|
-
[SchemaType.BYTES27]: string;
|
|
94
|
-
[SchemaType.BYTES28]: string;
|
|
95
|
-
[SchemaType.BYTES29]: string;
|
|
96
|
-
[SchemaType.BYTES30]: string;
|
|
97
|
-
[SchemaType.BYTES31]: string;
|
|
98
|
-
[SchemaType.BYTES32]: string;
|
|
99
|
-
[SchemaType.BOOL]: boolean;
|
|
100
|
-
[SchemaType.ADDRESS]: string;
|
|
101
|
-
[SchemaType.UINT8_ARRAY]: number[];
|
|
102
|
-
[SchemaType.UINT16_ARRAY]: number[];
|
|
103
|
-
[SchemaType.UINT24_ARRAY]: number[];
|
|
104
|
-
[SchemaType.UINT32_ARRAY]: number[];
|
|
105
|
-
[SchemaType.UINT40_ARRAY]: number[];
|
|
106
|
-
[SchemaType.UINT48_ARRAY]: number[];
|
|
107
|
-
[SchemaType.UINT56_ARRAY]: bigint[];
|
|
108
|
-
[SchemaType.UINT64_ARRAY]: bigint[];
|
|
109
|
-
[SchemaType.UINT72_ARRAY]: bigint[];
|
|
110
|
-
[SchemaType.UINT80_ARRAY]: bigint[];
|
|
111
|
-
[SchemaType.UINT88_ARRAY]: bigint[];
|
|
112
|
-
[SchemaType.UINT96_ARRAY]: bigint[];
|
|
113
|
-
[SchemaType.UINT104_ARRAY]: bigint[];
|
|
114
|
-
[SchemaType.UINT112_ARRAY]: bigint[];
|
|
115
|
-
[SchemaType.UINT120_ARRAY]: bigint[];
|
|
116
|
-
[SchemaType.UINT128_ARRAY]: bigint[];
|
|
117
|
-
[SchemaType.UINT136_ARRAY]: bigint[];
|
|
118
|
-
[SchemaType.UINT144_ARRAY]: bigint[];
|
|
119
|
-
[SchemaType.UINT152_ARRAY]: bigint[];
|
|
120
|
-
[SchemaType.UINT160_ARRAY]: bigint[];
|
|
121
|
-
[SchemaType.UINT168_ARRAY]: bigint[];
|
|
122
|
-
[SchemaType.UINT176_ARRAY]: bigint[];
|
|
123
|
-
[SchemaType.UINT184_ARRAY]: bigint[];
|
|
124
|
-
[SchemaType.UINT192_ARRAY]: bigint[];
|
|
125
|
-
[SchemaType.UINT200_ARRAY]: bigint[];
|
|
126
|
-
[SchemaType.UINT208_ARRAY]: bigint[];
|
|
127
|
-
[SchemaType.UINT216_ARRAY]: bigint[];
|
|
128
|
-
[SchemaType.UINT224_ARRAY]: bigint[];
|
|
129
|
-
[SchemaType.UINT232_ARRAY]: bigint[];
|
|
130
|
-
[SchemaType.UINT240_ARRAY]: bigint[];
|
|
131
|
-
[SchemaType.UINT248_ARRAY]: bigint[];
|
|
132
|
-
[SchemaType.UINT256_ARRAY]: bigint[];
|
|
133
|
-
[SchemaType.INT8_ARRAY]: number[];
|
|
134
|
-
[SchemaType.INT16_ARRAY]: number[];
|
|
135
|
-
[SchemaType.INT24_ARRAY]: number[];
|
|
136
|
-
[SchemaType.INT32_ARRAY]: number[];
|
|
137
|
-
[SchemaType.INT40_ARRAY]: number[];
|
|
138
|
-
[SchemaType.INT48_ARRAY]: number[];
|
|
139
|
-
[SchemaType.INT56_ARRAY]: bigint[];
|
|
140
|
-
[SchemaType.INT64_ARRAY]: bigint[];
|
|
141
|
-
[SchemaType.INT72_ARRAY]: bigint[];
|
|
142
|
-
[SchemaType.INT80_ARRAY]: bigint[];
|
|
143
|
-
[SchemaType.INT88_ARRAY]: bigint[];
|
|
144
|
-
[SchemaType.INT96_ARRAY]: bigint[];
|
|
145
|
-
[SchemaType.INT104_ARRAY]: bigint[];
|
|
146
|
-
[SchemaType.INT112_ARRAY]: bigint[];
|
|
147
|
-
[SchemaType.INT120_ARRAY]: bigint[];
|
|
148
|
-
[SchemaType.INT128_ARRAY]: bigint[];
|
|
149
|
-
[SchemaType.INT136_ARRAY]: bigint[];
|
|
150
|
-
[SchemaType.INT144_ARRAY]: bigint[];
|
|
151
|
-
[SchemaType.INT152_ARRAY]: bigint[];
|
|
152
|
-
[SchemaType.INT160_ARRAY]: bigint[];
|
|
153
|
-
[SchemaType.INT168_ARRAY]: bigint[];
|
|
154
|
-
[SchemaType.INT176_ARRAY]: bigint[];
|
|
155
|
-
[SchemaType.INT184_ARRAY]: bigint[];
|
|
156
|
-
[SchemaType.INT192_ARRAY]: bigint[];
|
|
157
|
-
[SchemaType.INT200_ARRAY]: bigint[];
|
|
158
|
-
[SchemaType.INT208_ARRAY]: bigint[];
|
|
159
|
-
[SchemaType.INT216_ARRAY]: bigint[];
|
|
160
|
-
[SchemaType.INT224_ARRAY]: bigint[];
|
|
161
|
-
[SchemaType.INT232_ARRAY]: bigint[];
|
|
162
|
-
[SchemaType.INT240_ARRAY]: bigint[];
|
|
163
|
-
[SchemaType.INT248_ARRAY]: bigint[];
|
|
164
|
-
[SchemaType.INT256_ARRAY]: bigint[];
|
|
165
|
-
[SchemaType.BYTES1_ARRAY]: string[];
|
|
166
|
-
[SchemaType.BYTES2_ARRAY]: string[];
|
|
167
|
-
[SchemaType.BYTES3_ARRAY]: string[];
|
|
168
|
-
[SchemaType.BYTES4_ARRAY]: string[];
|
|
169
|
-
[SchemaType.BYTES5_ARRAY]: string[];
|
|
170
|
-
[SchemaType.BYTES6_ARRAY]: string[];
|
|
171
|
-
[SchemaType.BYTES7_ARRAY]: string[];
|
|
172
|
-
[SchemaType.BYTES8_ARRAY]: string[];
|
|
173
|
-
[SchemaType.BYTES9_ARRAY]: string[];
|
|
174
|
-
[SchemaType.BYTES10_ARRAY]: string[];
|
|
175
|
-
[SchemaType.BYTES11_ARRAY]: string[];
|
|
176
|
-
[SchemaType.BYTES12_ARRAY]: string[];
|
|
177
|
-
[SchemaType.BYTES13_ARRAY]: string[];
|
|
178
|
-
[SchemaType.BYTES14_ARRAY]: string[];
|
|
179
|
-
[SchemaType.BYTES15_ARRAY]: string[];
|
|
180
|
-
[SchemaType.BYTES16_ARRAY]: string[];
|
|
181
|
-
[SchemaType.BYTES17_ARRAY]: string[];
|
|
182
|
-
[SchemaType.BYTES18_ARRAY]: string[];
|
|
183
|
-
[SchemaType.BYTES19_ARRAY]: string[];
|
|
184
|
-
[SchemaType.BYTES20_ARRAY]: string[];
|
|
185
|
-
[SchemaType.BYTES21_ARRAY]: string[];
|
|
186
|
-
[SchemaType.BYTES22_ARRAY]: string[];
|
|
187
|
-
[SchemaType.BYTES23_ARRAY]: string[];
|
|
188
|
-
[SchemaType.BYTES24_ARRAY]: string[];
|
|
189
|
-
[SchemaType.BYTES25_ARRAY]: string[];
|
|
190
|
-
[SchemaType.BYTES26_ARRAY]: string[];
|
|
191
|
-
[SchemaType.BYTES27_ARRAY]: string[];
|
|
192
|
-
[SchemaType.BYTES28_ARRAY]: string[];
|
|
193
|
-
[SchemaType.BYTES29_ARRAY]: string[];
|
|
194
|
-
[SchemaType.BYTES30_ARRAY]: string[];
|
|
195
|
-
[SchemaType.BYTES31_ARRAY]: string[];
|
|
196
|
-
[SchemaType.BYTES32_ARRAY]: string[];
|
|
197
|
-
[SchemaType.BOOL_ARRAY]: boolean[];
|
|
198
|
-
[SchemaType.ADDRESS_ARRAY]: string[];
|
|
199
|
-
[SchemaType.BYTES]: string;
|
|
200
|
-
[SchemaType.STRING]: string;
|
|
201
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaTypeToPrimitive.js","sourceRoot":"","sources":["../../src/typescript/SchemaTypeToPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AbiTypes } from "./AbiTypes.js";
|
|
2
|
-
import { AbiTypeToSchemaType } from "./AbiTypeToSchemaType.js";
|
|
3
|
-
import { getStaticByteLength } from "./getStaticByteLength.js";
|
|
4
|
-
export const StaticAbiTypes = AbiTypes.filter((abiType) => getStaticByteLength(AbiTypeToSchemaType[abiType]) > 0);
|
|
5
|
-
//# sourceMappingURL=StaticAbiTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StaticAbiTypes.js","sourceRoot":"","sources":["../../src/typescript/StaticAbiTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAK/D,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAC3C,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAChD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StaticSchemaType.js","sourceRoot":"","sources":["../../src/typescript/StaticSchemaType.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SchemaType } from "./SchemaType.js";
|
|
2
|
-
/**
|
|
3
|
-
* Encode a table schema into a bytes32 hex string
|
|
4
|
-
* Port of `Schema.sol` from `@latticexyz/store`
|
|
5
|
-
* @param schema The schema to encode SchemaType[]
|
|
6
|
-
* @returns The encoded schema as a 32 byte hex string
|
|
7
|
-
*/
|
|
8
|
-
export declare function encodeSchema(schema: SchemaType[]): Uint8Array;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { getStaticByteLength } from "./getStaticByteLength.js";
|
|
2
|
-
/**
|
|
3
|
-
* Encode a table schema into a bytes32 hex string
|
|
4
|
-
* Port of `Schema.sol` from `@latticexyz/store`
|
|
5
|
-
* @param schema The schema to encode SchemaType[]
|
|
6
|
-
* @returns The encoded schema as a 32 byte hex string
|
|
7
|
-
*/
|
|
8
|
-
export function encodeSchema(schema) {
|
|
9
|
-
if (schema.length > 28)
|
|
10
|
-
throw new Error("Schema can only have up to 28 fields");
|
|
11
|
-
const encodedSchema = new Uint8Array(32);
|
|
12
|
-
let length = 0;
|
|
13
|
-
let staticFields = 0;
|
|
14
|
-
// Compute the length of the schema and the number of static fields
|
|
15
|
-
// and store the schema types in the encoded schema
|
|
16
|
-
let hasDynamicFields = false;
|
|
17
|
-
for (let i = 0; i < schema.length; i++) {
|
|
18
|
-
const staticByteLength = getStaticByteLength(schema[i]);
|
|
19
|
-
// Increase the static field count if the field is static
|
|
20
|
-
if (staticByteLength > 0) {
|
|
21
|
-
// Revert if we have seen a dynamic field before, but now we see a static field
|
|
22
|
-
if (hasDynamicFields)
|
|
23
|
-
throw new Error("Static fields must come before dynamic fields in the schema");
|
|
24
|
-
staticFields++;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Flag that we have seen a dynamic field
|
|
28
|
-
hasDynamicFields = true;
|
|
29
|
-
}
|
|
30
|
-
length += staticByteLength;
|
|
31
|
-
encodedSchema[i + 4] = schema[i];
|
|
32
|
-
}
|
|
33
|
-
// Require max 14 dynamic fields
|
|
34
|
-
const dynamicFields = schema.length - staticFields;
|
|
35
|
-
if (dynamicFields > 14)
|
|
36
|
-
throw new Error("Schema can only have up to 14 dynamic fields");
|
|
37
|
-
// Store total static length, and number of static and dynamic fields
|
|
38
|
-
new DataView(encodedSchema.buffer).setUint16(0, length); // 2 length bytes
|
|
39
|
-
encodedSchema[2] = staticFields; // number of static fields
|
|
40
|
-
encodedSchema[3] = dynamicFields; // number of dynamic fields
|
|
41
|
-
return encodedSchema;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=encodeSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeSchema.js","sourceRoot":"","sources":["../../src/typescript/encodeSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;;;;GAKG;AAEH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAChF,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACzC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,mEAAmE;IACnE,mDAAmD;IACnD,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,yDAAyD;QACzD,IAAI,gBAAgB,GAAG,CAAC,EAAE;YACxB,+EAA+E;YAC/E,IAAI,gBAAgB;gBAAE,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACrG,YAAY,EAAE,CAAC;SAChB;aAAM;YACL,yCAAyC;YACzC,gBAAgB,GAAG,IAAI,CAAC;SACzB;QAED,MAAM,IAAI,gBAAgB,CAAC;QAC3B,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KAClC;IAED,gCAAgC;IAChC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC;IACnD,IAAI,aAAa,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAExF,qEAAqE;IACrE,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,iBAAiB;IAC1E,aAAa,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,0BAA0B;IAC3D,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,2BAA2B;IAE7D,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SchemaType } from "./SchemaType.js";
|
|
2
|
-
export function getStaticByteLength(schemaType) {
|
|
3
|
-
const val = schemaType.valueOf();
|
|
4
|
-
if (val < 32) {
|
|
5
|
-
// uint8-256
|
|
6
|
-
return val + 1;
|
|
7
|
-
}
|
|
8
|
-
else if (val < 64) {
|
|
9
|
-
// int8-256, offset by 32
|
|
10
|
-
return val + 1 - 32;
|
|
11
|
-
}
|
|
12
|
-
else if (val < 96) {
|
|
13
|
-
// bytes1-32, offset by 64
|
|
14
|
-
return val + 1 - 64;
|
|
15
|
-
}
|
|
16
|
-
// Other static types
|
|
17
|
-
if (schemaType == SchemaType.BOOL) {
|
|
18
|
-
return 1;
|
|
19
|
-
}
|
|
20
|
-
else if (schemaType == SchemaType.ADDRESS) {
|
|
21
|
-
return 20;
|
|
22
|
-
}
|
|
23
|
-
// Return 0 for all dynamic types
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=getStaticByteLength.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStaticByteLength.js","sourceRoot":"","sources":["../../src/typescript/getStaticByteLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,UAAU,mBAAmB,CAAC,UAAsB;IACxD,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,GAAG,GAAG,EAAE,EAAE;QACZ,YAAY;QACZ,OAAO,GAAG,GAAG,CAAC,CAAC;KAChB;SAAM,IAAI,GAAG,GAAG,EAAE,EAAE;QACnB,yBAAyB;QACzB,OAAO,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;KACrB;SAAM,IAAI,GAAG,GAAG,EAAE,EAAE;QACnB,0BAA0B;QAC1B,OAAO,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;KACrB;IAED,qBAAqB;IACrB,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE;QACjC,OAAO,CAAC,CAAC;KACV;SAAM,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE;QAC3C,OAAO,EAAE,CAAC;KACX;IAED,iCAAiC;IACjC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type { StaticSchemaType } from "./StaticSchemaType.js";
|
|
2
|
-
export type { DynamicSchemaType } from "./DynamicSchemaType.js";
|
|
3
|
-
export type { ArraySchemaType } from "./ArraySchemaType.js";
|
|
4
|
-
export type { SchemaTypeToPrimitive } from "./SchemaTypeToPrimitive.js";
|
|
5
|
-
export type { AbiType } from "./AbiTypes.js";
|
|
6
|
-
export type { StaticAbiType } from "./StaticAbiTypes.js";
|
|
7
|
-
export { SchemaType } from "./SchemaType.js";
|
|
8
|
-
export { encodeSchema } from "./encodeSchema.js";
|
|
9
|
-
export { getStaticByteLength } from "./getStaticByteLength.js";
|
|
10
|
-
export { SchemaTypeArrayToElement } from "./SchemaTypeArrayToElement.js";
|
|
11
|
-
export { SchemaTypeToAbiType } from "./SchemaTypeToAbiType.js";
|
|
12
|
-
export { AbiTypeToSchemaType } from "./AbiTypeToSchemaType.js";
|
|
13
|
-
export { AbiTypes } from "./AbiTypes.js";
|
|
14
|
-
export { StaticAbiTypes } from "./StaticAbiTypes.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AbiTypes } from "./AbiTypes.js";
|
|
2
|
-
import { AbiTypeToSchemaType } from "./AbiTypeToSchemaType.js";
|
|
3
|
-
import { getStaticByteLength } from "./getStaticByteLength.js";
|
|
4
|
-
import { SchemaTypeToAbiType } from "./SchemaTypeToAbiType.js";
|
|
5
|
-
import { StaticSchemaType } from "./StaticSchemaType.js";
|
|
6
|
-
|
|
7
|
-
export type StaticAbiType = (typeof SchemaTypeToAbiType)[StaticSchemaType];
|
|
8
|
-
export const StaticAbiTypes = AbiTypes.filter(
|
|
9
|
-
(abiType) => getStaticByteLength(AbiTypeToSchemaType[abiType]) > 0
|
|
10
|
-
) as StaticAbiType[];
|