@pezkuwi/types-create 16.5.20 → 16.5.22

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.
Files changed (168) hide show
  1. package/package.json +9 -9
  2. package/build/LICENSE +0 -201
  3. package/build/README.md +0 -3
  4. package/build/bundle.js +0 -3
  5. package/build/cjs/bundle.d.ts +0 -3
  6. package/build/cjs/bundle.js +0 -9
  7. package/build/cjs/create/class.js +0 -165
  8. package/build/cjs/create/index.js +0 -5
  9. package/build/cjs/create/type.js +0 -66
  10. package/build/cjs/exports.js +0 -5
  11. package/build/cjs/index.js +0 -5
  12. package/build/cjs/packageInfo.js +0 -4
  13. package/build/cjs/types/augmentRegistry.js +0 -3
  14. package/build/cjs/types/index.js +0 -6
  15. package/build/cjs/types/lookup.js +0 -2
  16. package/build/cjs/types/types.js +0 -29
  17. package/build/cjs/util/encodeTypes.js +0 -128
  18. package/build/cjs/util/getTypeDef.js +0 -195
  19. package/build/cjs/util/index.js +0 -7
  20. package/build/cjs/util/typeSplit.js +0 -60
  21. package/build/cjs/util/xcm.js +0 -9
  22. package/build/create/class.d.ts +0 -5
  23. package/build/create/class.js +0 -160
  24. package/build/create/index.d.ts +0 -2
  25. package/build/create/index.js +0 -2
  26. package/build/create/type.d.ts +0 -3
  27. package/build/create/type.js +0 -63
  28. package/build/exports.d.ts +0 -2
  29. package/build/exports.js +0 -2
  30. package/build/index.d.ts +0 -2
  31. package/build/index.js +0 -2
  32. package/build/package.json +0 -291
  33. package/build/packageDetect.d.ts +0 -1
  34. package/build/packageDetect.js +0 -4
  35. package/build/packageInfo.d.ts +0 -6
  36. package/build/packageInfo.js +0 -1
  37. package/build/types/augmentRegistry.d.ts +0 -11
  38. package/build/types/augmentRegistry.js +0 -1
  39. package/build/types/index.d.ts +0 -4
  40. package/build/types/index.js +0 -3
  41. package/build/types/lookup.d.ts +0 -14
  42. package/build/types/lookup.js +0 -1
  43. package/build/types/types.d.ts +0 -43
  44. package/build/types/types.js +0 -26
  45. package/build/util/encodeTypes.d.ts +0 -11
  46. package/build/util/encodeTypes.js +0 -123
  47. package/build/util/getTypeDef.d.ts +0 -8
  48. package/build/util/getTypeDef.js +0 -192
  49. package/build/util/index.d.ts +0 -4
  50. package/build/util/index.js +0 -4
  51. package/build/util/typeSplit.d.ts +0 -1
  52. package/build/util/typeSplit.js +0 -57
  53. package/build/util/xcm.d.ts +0 -2
  54. package/build/util/xcm.js +0 -5
  55. package/build-deno/README.md +0 -3
  56. package/build-deno/bundle.ts +0 -5
  57. package/build-deno/create/class.ts +0 -252
  58. package/build-deno/create/index.ts +0 -3
  59. package/build-deno/create/type.ts +0 -85
  60. package/build-deno/exports.ts +0 -3
  61. package/build-deno/index.ts +0 -4
  62. package/build-deno/mod.ts +0 -2
  63. package/build-deno/packageDetect.ts +0 -8
  64. package/build-deno/packageInfo.ts +0 -3
  65. package/build-deno/types/augmentRegistry.ts +0 -15
  66. package/build-deno/types/index.ts +0 -7
  67. package/build-deno/types/lookup.ts +0 -16
  68. package/build-deno/types/types.ts +0 -45
  69. package/build-deno/util/encodeTypes.ts +0 -201
  70. package/build-deno/util/getTypeDef.ts +0 -267
  71. package/build-deno/util/index.ts +0 -5
  72. package/build-deno/util/typeSplit.ts +0 -53
  73. package/build-deno/util/xcm.ts +0 -10
  74. package/build-tsc-cjs/packageDetect.js +0 -6
  75. package/src/bundle.ts +0 -9
  76. package/src/create/class.ts +0 -257
  77. package/src/create/index.ts +0 -5
  78. package/src/create/type.ts +0 -94
  79. package/src/exports.ts +0 -6
  80. package/src/index.ts +0 -6
  81. package/src/mod.ts +0 -4
  82. package/src/packageDetect.ts +0 -12
  83. package/src/packageInfo.ts +0 -6
  84. package/src/types/augmentRegistry.ts +0 -19
  85. package/src/types/index.ts +0 -11
  86. package/src/types/lookup.ts +0 -21
  87. package/src/types/types.ts +0 -47
  88. package/src/util/encodeTypes.spec.ts +0 -217
  89. package/src/util/encodeTypes.ts +0 -205
  90. package/src/util/getTypeDef.spec.ts +0 -704
  91. package/src/util/getTypeDef.ts +0 -279
  92. package/src/util/index.ts +0 -7
  93. package/src/util/typeSplit.spec.ts +0 -50
  94. package/src/util/typeSplit.ts +0 -56
  95. package/src/util/xcm.ts +0 -12
  96. package/tsconfig.build.json +0 -15
  97. package/tsconfig.build.tsbuildinfo +0 -1
  98. package/tsconfig.spec.json +0 -17
  99. package/tsconfig.spec.tsbuildinfo +0 -1
  100. /package/{build-tsc/bundle.d.ts → bundle.d.ts} +0 -0
  101. /package/{build-tsc-esm/bundle.js → bundle.js} +0 -0
  102. /package/{build → cjs}/bundle.d.ts +0 -0
  103. /package/{build-tsc-cjs → cjs}/bundle.js +0 -0
  104. /package/{build-tsc → cjs}/create/class.d.ts +0 -0
  105. /package/{build-tsc-cjs → cjs}/create/class.js +0 -0
  106. /package/{build-tsc → cjs}/create/index.d.ts +0 -0
  107. /package/{build-tsc-cjs → cjs}/create/index.js +0 -0
  108. /package/{build-tsc → cjs}/create/type.d.ts +0 -0
  109. /package/{build-tsc-cjs → cjs}/create/type.js +0 -0
  110. /package/{build-tsc → cjs}/exports.d.ts +0 -0
  111. /package/{build-tsc-cjs → cjs}/exports.js +0 -0
  112. /package/{build-tsc → cjs}/index.d.ts +0 -0
  113. /package/{build-tsc-cjs → cjs}/index.js +0 -0
  114. /package/{build/cjs → cjs}/package.json +0 -0
  115. /package/{build-tsc → cjs}/packageDetect.d.ts +0 -0
  116. /package/{build/cjs → cjs}/packageDetect.js +0 -0
  117. /package/{build-tsc → cjs}/packageInfo.d.ts +0 -0
  118. /package/{build-tsc-cjs → cjs}/packageInfo.js +0 -0
  119. /package/{build-tsc → cjs}/types/augmentRegistry.d.ts +0 -0
  120. /package/{build-tsc-cjs → cjs}/types/augmentRegistry.js +0 -0
  121. /package/{build-tsc → cjs}/types/index.d.ts +0 -0
  122. /package/{build-tsc-cjs → cjs}/types/index.js +0 -0
  123. /package/{build-tsc → cjs}/types/lookup.d.ts +0 -0
  124. /package/{build-tsc-cjs → cjs}/types/lookup.js +0 -0
  125. /package/{build-tsc → cjs}/types/types.d.ts +0 -0
  126. /package/{build-tsc-cjs → cjs}/types/types.js +0 -0
  127. /package/{build-tsc → cjs}/util/encodeTypes.d.ts +0 -0
  128. /package/{build-tsc-cjs → cjs}/util/encodeTypes.js +0 -0
  129. /package/{build-tsc → cjs}/util/getTypeDef.d.ts +0 -0
  130. /package/{build-tsc-cjs → cjs}/util/getTypeDef.js +0 -0
  131. /package/{build-tsc → cjs}/util/index.d.ts +0 -0
  132. /package/{build-tsc-cjs → cjs}/util/index.js +0 -0
  133. /package/{build-tsc → cjs}/util/typeSplit.d.ts +0 -0
  134. /package/{build-tsc-cjs → cjs}/util/typeSplit.js +0 -0
  135. /package/{build-tsc → cjs}/util/xcm.d.ts +0 -0
  136. /package/{build-tsc-cjs → cjs}/util/xcm.js +0 -0
  137. /package/{build/cjs/create → create}/class.d.ts +0 -0
  138. /package/{build-tsc-esm/create → create}/class.js +0 -0
  139. /package/{build/cjs/create → create}/index.d.ts +0 -0
  140. /package/{build-tsc-esm/create → create}/index.js +0 -0
  141. /package/{build/cjs/create → create}/type.d.ts +0 -0
  142. /package/{build-tsc-esm/create → create}/type.js +0 -0
  143. /package/{build/cjs/exports.d.ts → exports.d.ts} +0 -0
  144. /package/{build-tsc-esm/exports.js → exports.js} +0 -0
  145. /package/{build/cjs/index.d.ts → index.d.ts} +0 -0
  146. /package/{build-tsc-esm/index.js → index.js} +0 -0
  147. /package/{build/cjs/packageDetect.d.ts → packageDetect.d.ts} +0 -0
  148. /package/{build-tsc-esm/packageDetect.js → packageDetect.js} +0 -0
  149. /package/{build/cjs/packageInfo.d.ts → packageInfo.d.ts} +0 -0
  150. /package/{build-tsc-esm/packageInfo.js → packageInfo.js} +0 -0
  151. /package/{build/cjs/types → types}/augmentRegistry.d.ts +0 -0
  152. /package/{build-tsc-esm/types → types}/augmentRegistry.js +0 -0
  153. /package/{build/cjs/types → types}/index.d.ts +0 -0
  154. /package/{build-tsc-esm/types → types}/index.js +0 -0
  155. /package/{build/cjs/types → types}/lookup.d.ts +0 -0
  156. /package/{build-tsc-esm/types → types}/lookup.js +0 -0
  157. /package/{build/cjs/types → types}/types.d.ts +0 -0
  158. /package/{build-tsc-esm/types → types}/types.js +0 -0
  159. /package/{build/cjs/util → util}/encodeTypes.d.ts +0 -0
  160. /package/{build-tsc-esm/util → util}/encodeTypes.js +0 -0
  161. /package/{build/cjs/util → util}/getTypeDef.d.ts +0 -0
  162. /package/{build-tsc-esm/util → util}/getTypeDef.js +0 -0
  163. /package/{build/cjs/util → util}/index.d.ts +0 -0
  164. /package/{build-tsc-esm/util → util}/index.js +0 -0
  165. /package/{build/cjs/util → util}/typeSplit.d.ts +0 -0
  166. /package/{build-tsc-esm/util → util}/typeSplit.js +0 -0
  167. /package/{build/cjs/util → util}/xcm.d.ts +0 -0
  168. /package/{build-tsc-esm/util → util}/xcm.js +0 -0
@@ -1,291 +0,0 @@
1
- {
2
- "author": "Jaco Greeff <jacogr@gmail.com>",
3
- "bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
4
- "description": "Type creator helpers",
5
- "engines": {
6
- "node": ">=18"
7
- },
8
- "homepage": "https://github.com/pezkuwichain/pezkuwi-api/tree/master/packages/types-create#readme",
9
- "license": "Apache-2.0",
10
- "name": "@pezkuwi/types-create",
11
- "repository": {
12
- "directory": "packages/types-create",
13
- "type": "git",
14
- "url": "https://github.com/pezkuwichain/pezkuwi-api.git"
15
- },
16
- "sideEffects": [
17
- "./packageDetect.js",
18
- "./cjs/packageDetect.js"
19
- ],
20
- "type": "module",
21
- "version": "16.5.20",
22
- "main": "./cjs/index.js",
23
- "module": "./cjs/index.js",
24
- "types": "./cjs/index.d.ts",
25
- "exports": {
26
- "./cjs/package.json": "./cjs/package.json",
27
- "./cjs/*": "./cjs/*.js",
28
- ".": {
29
- "module": {
30
- "types": "./index.d.ts",
31
- "default": "./index.js"
32
- },
33
- "require": {
34
- "types": "./cjs/index.d.ts",
35
- "default": "./cjs/index.js"
36
- },
37
- "default": {
38
- "types": "./index.d.ts",
39
- "default": "./index.js"
40
- }
41
- },
42
- "./bundle": {
43
- "module": {
44
- "types": "./bundle.d.ts",
45
- "default": "./bundle.js"
46
- },
47
- "require": {
48
- "types": "./cjs/bundle.d.ts",
49
- "default": "./cjs/bundle.js"
50
- },
51
- "default": {
52
- "types": "./bundle.d.ts",
53
- "default": "./bundle.js"
54
- }
55
- },
56
- "./create": {
57
- "module": {
58
- "types": "./create/index.d.ts",
59
- "default": "./create/index.js"
60
- },
61
- "require": {
62
- "types": "./cjs/create/index.d.ts",
63
- "default": "./cjs/create/index.js"
64
- },
65
- "default": {
66
- "types": "./create/index.d.ts",
67
- "default": "./create/index.js"
68
- }
69
- },
70
- "./create/class": {
71
- "module": {
72
- "types": "./create/class.d.ts",
73
- "default": "./create/class.js"
74
- },
75
- "require": {
76
- "types": "./cjs/create/class.d.ts",
77
- "default": "./cjs/create/class.js"
78
- },
79
- "default": {
80
- "types": "./create/class.d.ts",
81
- "default": "./create/class.js"
82
- }
83
- },
84
- "./create/type": {
85
- "module": {
86
- "types": "./create/type.d.ts",
87
- "default": "./create/type.js"
88
- },
89
- "require": {
90
- "types": "./cjs/create/type.d.ts",
91
- "default": "./cjs/create/type.js"
92
- },
93
- "default": {
94
- "types": "./create/type.d.ts",
95
- "default": "./create/type.js"
96
- }
97
- },
98
- "./exports": {
99
- "module": {
100
- "types": "./exports.d.ts",
101
- "default": "./exports.js"
102
- },
103
- "require": {
104
- "types": "./cjs/exports.d.ts",
105
- "default": "./cjs/exports.js"
106
- },
107
- "default": {
108
- "types": "./exports.d.ts",
109
- "default": "./exports.js"
110
- }
111
- },
112
- "./package.json": {
113
- "require": "./cjs/package.json",
114
- "default": "./package.json"
115
- },
116
- "./packageDetect": {
117
- "module": {
118
- "types": "./packageDetect.d.ts",
119
- "default": "./packageDetect.js"
120
- },
121
- "require": {
122
- "types": "./cjs/packageDetect.d.ts",
123
- "default": "./cjs/packageDetect.js"
124
- },
125
- "default": {
126
- "types": "./packageDetect.d.ts",
127
- "default": "./packageDetect.js"
128
- }
129
- },
130
- "./packageInfo.js": {
131
- "module": {
132
- "types": "./packageInfo.d.ts",
133
- "default": "./packageInfo.js"
134
- },
135
- "require": {
136
- "types": "./cjs/packageInfo.d.ts",
137
- "default": "./cjs/packageInfo.js"
138
- },
139
- "default": {
140
- "types": "./packageInfo.d.ts",
141
- "default": "./packageInfo.js"
142
- }
143
- },
144
- "./packageInfo": {
145
- "module": {
146
- "types": "./packageInfo.d.ts",
147
- "default": "./packageInfo.js"
148
- },
149
- "require": {
150
- "types": "./cjs/packageInfo.d.ts",
151
- "default": "./cjs/packageInfo.js"
152
- },
153
- "default": {
154
- "types": "./packageInfo.d.ts",
155
- "default": "./packageInfo.js"
156
- }
157
- },
158
- "./types": {
159
- "module": {
160
- "types": "./types/index.d.ts",
161
- "default": "./types/index.js"
162
- },
163
- "require": {
164
- "types": "./cjs/types/index.d.ts",
165
- "default": "./cjs/types/index.js"
166
- },
167
- "default": {
168
- "types": "./types/index.d.ts",
169
- "default": "./types/index.js"
170
- }
171
- },
172
- "./types/augmentRegistry": {
173
- "module": {
174
- "types": "./types/augmentRegistry.d.ts",
175
- "default": "./types/augmentRegistry.js"
176
- },
177
- "require": {
178
- "types": "./cjs/types/augmentRegistry.d.ts",
179
- "default": "./cjs/types/augmentRegistry.js"
180
- },
181
- "default": {
182
- "types": "./types/augmentRegistry.d.ts",
183
- "default": "./types/augmentRegistry.js"
184
- }
185
- },
186
- "./types/lookup": {
187
- "module": {
188
- "types": "./types/lookup.d.ts",
189
- "default": "./types/lookup.js"
190
- },
191
- "require": {
192
- "types": "./cjs/types/lookup.d.ts",
193
- "default": "./cjs/types/lookup.js"
194
- },
195
- "default": {
196
- "types": "./types/lookup.d.ts",
197
- "default": "./types/lookup.js"
198
- }
199
- },
200
- "./types/types": {
201
- "module": {
202
- "types": "./types/types.d.ts",
203
- "default": "./types/types.js"
204
- },
205
- "require": {
206
- "types": "./cjs/types/types.d.ts",
207
- "default": "./cjs/types/types.js"
208
- },
209
- "default": {
210
- "types": "./types/types.d.ts",
211
- "default": "./types/types.js"
212
- }
213
- },
214
- "./util": {
215
- "module": {
216
- "types": "./util/index.d.ts",
217
- "default": "./util/index.js"
218
- },
219
- "require": {
220
- "types": "./cjs/util/index.d.ts",
221
- "default": "./cjs/util/index.js"
222
- },
223
- "default": {
224
- "types": "./util/index.d.ts",
225
- "default": "./util/index.js"
226
- }
227
- },
228
- "./util/encodeTypes": {
229
- "module": {
230
- "types": "./util/encodeTypes.d.ts",
231
- "default": "./util/encodeTypes.js"
232
- },
233
- "require": {
234
- "types": "./cjs/util/encodeTypes.d.ts",
235
- "default": "./cjs/util/encodeTypes.js"
236
- },
237
- "default": {
238
- "types": "./util/encodeTypes.d.ts",
239
- "default": "./util/encodeTypes.js"
240
- }
241
- },
242
- "./util/getTypeDef": {
243
- "module": {
244
- "types": "./util/getTypeDef.d.ts",
245
- "default": "./util/getTypeDef.js"
246
- },
247
- "require": {
248
- "types": "./cjs/util/getTypeDef.d.ts",
249
- "default": "./cjs/util/getTypeDef.js"
250
- },
251
- "default": {
252
- "types": "./util/getTypeDef.d.ts",
253
- "default": "./util/getTypeDef.js"
254
- }
255
- },
256
- "./util/typeSplit": {
257
- "module": {
258
- "types": "./util/typeSplit.d.ts",
259
- "default": "./util/typeSplit.js"
260
- },
261
- "require": {
262
- "types": "./cjs/util/typeSplit.d.ts",
263
- "default": "./cjs/util/typeSplit.js"
264
- },
265
- "default": {
266
- "types": "./util/typeSplit.d.ts",
267
- "default": "./util/typeSplit.js"
268
- }
269
- },
270
- "./util/xcm": {
271
- "module": {
272
- "types": "./util/xcm.d.ts",
273
- "default": "./util/xcm.js"
274
- },
275
- "require": {
276
- "types": "./cjs/util/xcm.d.ts",
277
- "default": "./cjs/util/xcm.js"
278
- },
279
- "default": {
280
- "types": "./util/xcm.d.ts",
281
- "default": "./util/xcm.js"
282
- }
283
- }
284
- },
285
- "dependencies": {
286
- "@pezkuwi/types": "16.5.9",
287
- "@pezkuwi/types-codec": "16.5.9",
288
- "@pezkuwi/util": "14.0.13",
289
- "tslib": "^2.8.1"
290
- }
291
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { packageInfo as codecInfo } from '@pezkuwi/types-codec/packageInfo';
2
- import { detectPackage } from '@pezkuwi/util';
3
- import { packageInfo } from './packageInfo.js';
4
- detectPackage(packageInfo, null, [codecInfo]);
@@ -1,6 +0,0 @@
1
- export declare const packageInfo: {
2
- name: string;
3
- path: string;
4
- type: string;
5
- version: string;
6
- };
@@ -1 +0,0 @@
1
- export const packageInfo = { name: '@pezkuwi/types-create', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.5.18' };
@@ -1,11 +0,0 @@
1
- import '@pezkuwi/types-codec/types/registry';
2
- import type { Codec, CodecClass, ICompact, INumber, LookupString } from '@pezkuwi/types-codec/types';
3
- import type { ILookup, TypeDef } from '@pezkuwi/types-create/types';
4
- declare module '@pezkuwi/types-codec/types/registry' {
5
- interface Registry {
6
- readonly lookup: ILookup;
7
- createLookupType(lookupId: ICompact<INumber> | number): LookupString;
8
- getUnsafe<T extends Codec = Codec, K extends string = string>(name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<T> | undefined;
9
- setLookup(lookup: ILookup): void;
10
- }
11
- }
@@ -1 +0,0 @@
1
- import '@pezkuwi/types-codec/types/registry';
@@ -1,4 +0,0 @@
1
- import './augmentRegistry.js';
2
- export type { CodecCreateOptions as CreateOptions } from '@pezkuwi/types-codec/types';
3
- export * from './lookup.js';
4
- export * from './types.js';
@@ -1,3 +0,0 @@
1
- import './augmentRegistry.js';
2
- export * from './lookup.js';
3
- export * from './types.js';
@@ -1,14 +0,0 @@
1
- import type { Option, Text } from '@pezkuwi/types-codec';
2
- import type { ICompact, INumber, LookupString } from '@pezkuwi/types-codec/types';
3
- import type { TypeDef } from './types.js';
4
- interface SiTypeBase {
5
- def: {
6
- asTuple: ICompact<INumber>[];
7
- };
8
- }
9
- export interface ILookup {
10
- getSiType(lookupId: ICompact<INumber> | LookupString | number): SiTypeBase;
11
- getTypeDef(lookupId: ICompact<INumber> | LookupString | number): TypeDef;
12
- sanitizeField(name: Option<Text>): [string | null, string | null];
13
- }
14
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- export declare enum TypeDefInfo {
2
- BTreeMap = 0,
3
- BTreeSet = 1,
4
- Compact = 2,
5
- DoNotConstruct = 3,
6
- Enum = 4,
7
- HashMap = 5,
8
- Int = 6,
9
- Linkage = 7,
10
- Null = 8,
11
- Option = 9,
12
- Plain = 10,
13
- Range = 11,
14
- RangeInclusive = 12,
15
- Result = 13,
16
- Set = 14,
17
- Si = 15,
18
- Struct = 16,
19
- Tuple = 17,
20
- UInt = 18,
21
- Vec = 19,
22
- VecFixed = 20,
23
- WrapperKeepOpaque = 21,
24
- WrapperOpaque = 22
25
- }
26
- export interface TypeDef {
27
- alias?: Map<string, string> | undefined;
28
- displayName?: string | undefined;
29
- docs?: string[] | undefined;
30
- fallbackType?: string | undefined;
31
- info: TypeDefInfo;
32
- index?: number;
33
- isFromSi?: boolean;
34
- length?: number;
35
- lookupIndex?: number;
36
- lookupName?: string | undefined;
37
- lookupNameRoot?: string | undefined;
38
- name?: string | undefined;
39
- namespace?: string | undefined;
40
- sub?: TypeDef | TypeDef[];
41
- type: string;
42
- typeName?: string | undefined;
43
- }
@@ -1,26 +0,0 @@
1
- export var TypeDefInfo;
2
- (function (TypeDefInfo) {
3
- TypeDefInfo[TypeDefInfo["BTreeMap"] = 0] = "BTreeMap";
4
- TypeDefInfo[TypeDefInfo["BTreeSet"] = 1] = "BTreeSet";
5
- TypeDefInfo[TypeDefInfo["Compact"] = 2] = "Compact";
6
- TypeDefInfo[TypeDefInfo["DoNotConstruct"] = 3] = "DoNotConstruct";
7
- TypeDefInfo[TypeDefInfo["Enum"] = 4] = "Enum";
8
- TypeDefInfo[TypeDefInfo["HashMap"] = 5] = "HashMap";
9
- TypeDefInfo[TypeDefInfo["Int"] = 6] = "Int";
10
- TypeDefInfo[TypeDefInfo["Linkage"] = 7] = "Linkage";
11
- TypeDefInfo[TypeDefInfo["Null"] = 8] = "Null";
12
- TypeDefInfo[TypeDefInfo["Option"] = 9] = "Option";
13
- TypeDefInfo[TypeDefInfo["Plain"] = 10] = "Plain";
14
- TypeDefInfo[TypeDefInfo["Range"] = 11] = "Range";
15
- TypeDefInfo[TypeDefInfo["RangeInclusive"] = 12] = "RangeInclusive";
16
- TypeDefInfo[TypeDefInfo["Result"] = 13] = "Result";
17
- TypeDefInfo[TypeDefInfo["Set"] = 14] = "Set";
18
- TypeDefInfo[TypeDefInfo["Si"] = 15] = "Si";
19
- TypeDefInfo[TypeDefInfo["Struct"] = 16] = "Struct";
20
- TypeDefInfo[TypeDefInfo["Tuple"] = 17] = "Tuple";
21
- TypeDefInfo[TypeDefInfo["UInt"] = 18] = "UInt";
22
- TypeDefInfo[TypeDefInfo["Vec"] = 19] = "Vec";
23
- TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
24
- TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
25
- TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
26
- })(TypeDefInfo || (TypeDefInfo = {}));
@@ -1,11 +0,0 @@
1
- import type { Registry } from '@pezkuwi/types-codec/types';
2
- import type { TypeDef } from '@pezkuwi/types-create/types';
3
- interface ToString {
4
- toString: () => string;
5
- }
6
- export declare function paramsNotation<T extends ToString>(outer: string, inner?: T | T[], transform?: (_: T) => string): string;
7
- export declare function encodeTypeDef(registry: Registry, typeDef: TypeDef): string;
8
- export declare function withTypeString(registry: Registry, typeDef: Omit<TypeDef, 'type'> & {
9
- type?: string;
10
- }): TypeDef;
11
- export {};
@@ -1,123 +0,0 @@
1
- import { isNumber, isUndefined, objectSpread, stringify } from '@pezkuwi/util';
2
- import { TypeDefInfo } from '../types/index.js';
3
- const stringIdentity = (value) => value.toString();
4
- const INFO_WRAP = ['BTreeMap', 'BTreeSet', 'Compact', 'HashMap', 'Option', 'Result', 'Vec'];
5
- export function paramsNotation(outer, inner, transform = stringIdentity) {
6
- return `${outer}${inner
7
- ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>`
8
- : ''}`;
9
- }
10
- function encodeWithParams(registry, typeDef, outer) {
11
- const { info, sub } = typeDef;
12
- switch (info) {
13
- case TypeDefInfo.BTreeMap:
14
- case TypeDefInfo.BTreeSet:
15
- case TypeDefInfo.Compact:
16
- case TypeDefInfo.HashMap:
17
- case TypeDefInfo.Linkage:
18
- case TypeDefInfo.Option:
19
- case TypeDefInfo.Range:
20
- case TypeDefInfo.RangeInclusive:
21
- case TypeDefInfo.Result:
22
- case TypeDefInfo.Vec:
23
- case TypeDefInfo.WrapperKeepOpaque:
24
- case TypeDefInfo.WrapperOpaque:
25
- return paramsNotation(outer, sub, (p) => encodeTypeDef(registry, p));
26
- }
27
- throw new Error(`Unable to encode ${stringify(typeDef)} with params`);
28
- }
29
- function encodeSubTypes(registry, sub, asEnum, extra) {
30
- const names = sub.map(({ name }) => name);
31
- if (!names.every((n) => !!n)) {
32
- throw new Error(`Subtypes does not have consistent names, ${names.join(', ')}`);
33
- }
34
- const inner = objectSpread({}, extra);
35
- for (let i = 0, count = sub.length; i < count; i++) {
36
- const def = sub[i];
37
- if (!def.name) {
38
- throw new Error(`No name found in ${stringify(def)}`);
39
- }
40
- inner[def.name] = encodeTypeDef(registry, def);
41
- }
42
- return stringify(asEnum
43
- ? { _enum: inner }
44
- : inner);
45
- }
46
- const encoders = {
47
- [TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
48
- [TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
49
- [TypeDefInfo.Compact]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Compact'),
50
- [TypeDefInfo.DoNotConstruct]: (registry, { displayName, lookupIndex, lookupName }) => `DoNotConstruct<${lookupName || displayName || (isUndefined(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`,
51
- [TypeDefInfo.Enum]: (registry, { sub }) => {
52
- if (!Array.isArray(sub)) {
53
- throw new Error('Unable to encode Enum type');
54
- }
55
- // c-like enums have all Null entries
56
- // TODO We need to take the disciminant into account and auto-add empty entries
57
- return sub.every(({ type }) => type === 'Null')
58
- ? stringify({ _enum: sub.map(({ name }, index) => `${name || `Empty${index}`}`) })
59
- : encodeSubTypes(registry, sub, true);
60
- },
61
- [TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
62
- [TypeDefInfo.Int]: (_registry, { length = 32 }) => `Int<${length}>`,
63
- [TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
64
- [TypeDefInfo.Null]: (_registry, _typeDef) => 'Null',
65
- [TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
66
- [TypeDefInfo.Plain]: (_registry, { displayName, type }) => displayName || type,
67
- [TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Range'),
68
- [TypeDefInfo.RangeInclusive]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'RangeInclusive'),
69
- [TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
70
- [TypeDefInfo.Set]: (_registry, { length = 8, sub }) => {
71
- if (!Array.isArray(sub)) {
72
- throw new Error('Unable to encode Set type');
73
- }
74
- return stringify({
75
- _set: sub.reduce((all, { index, name }, count) => objectSpread(all, { [`${name || `Unknown${index || count}`}`]: index || count }), { _bitLength: length || 8 })
76
- });
77
- },
78
- [TypeDefInfo.Si]: (_registry, { lookupName, type }) => lookupName || type,
79
- [TypeDefInfo.Struct]: (registry, { alias, sub }) => {
80
- if (!Array.isArray(sub)) {
81
- throw new Error('Unable to encode Struct type');
82
- }
83
- return encodeSubTypes(registry, sub, false, alias
84
- ? {
85
- _alias: [...alias.entries()].reduce((all, [k, v]) => objectSpread(all, { [k]: v }), {})
86
- }
87
- : {});
88
- },
89
- [TypeDefInfo.Tuple]: (registry, { sub }) => {
90
- if (!Array.isArray(sub)) {
91
- throw new Error('Unable to encode Tuple type');
92
- }
93
- return `(${sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
94
- },
95
- [TypeDefInfo.UInt]: (_registry, { length = 32 }) => `UInt<${length}>`,
96
- [TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
97
- [TypeDefInfo.VecFixed]: (_registry, { length, sub }) => {
98
- if (!isNumber(length) || !sub || Array.isArray(sub)) {
99
- throw new Error('Unable to encode VecFixed type');
100
- }
101
- return `[${sub.type};${length}]`;
102
- },
103
- [TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
104
- [TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
105
- };
106
- function encodeType(registry, typeDef, withLookup = true) {
107
- return withLookup && typeDef.lookupName
108
- ? typeDef.lookupName
109
- : encoders[typeDef.info](registry, typeDef);
110
- }
111
- export function encodeTypeDef(registry, typeDef) {
112
- // In the case of contracts we do have the unfortunate situation where the displayName would
113
- // refer to "Option" when it is an option. For these, string it out, only using when actually
114
- // not a top-level element to be used
115
- return (typeDef.displayName && !INFO_WRAP.some((i) => typeDef.displayName === i))
116
- ? typeDef.displayName
117
- : encodeType(registry, typeDef);
118
- }
119
- export function withTypeString(registry, typeDef) {
120
- return objectSpread({}, typeDef, {
121
- type: encodeType(registry, typeDef, false)
122
- });
123
- }
@@ -1,8 +0,0 @@
1
- import type { AnyString } from '@pezkuwi/types-codec/types';
2
- import type { TypeDef } from '@pezkuwi/types-create/types';
3
- interface TypeDefOptions {
4
- name?: string;
5
- displayName?: string;
6
- }
7
- export declare function getTypeDef(_type: AnyString, { displayName, name }?: TypeDefOptions, count?: number): TypeDef;
8
- export {};