@pezkuwi/typegen 16.5.16 → 16.5.18

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 (307) hide show
  1. package/build/LICENSE +201 -0
  2. package/build/README.md +3 -0
  3. package/build/augment.js +2 -0
  4. package/build/bundle.js +2 -0
  5. package/build/cjs/augment.d.ts +2 -0
  6. package/build/cjs/augment.js +4 -0
  7. package/build/cjs/bundle.d.ts +2 -0
  8. package/build/cjs/bundle.js +7 -0
  9. package/build/cjs/extractChain.js +44 -0
  10. package/build/cjs/fromChain.js +95 -0
  11. package/build/cjs/fromDefs.js +82 -0
  12. package/build/cjs/generate/consts.d.ts +5 -0
  13. package/build/cjs/generate/consts.js +91 -0
  14. package/build/cjs/generate/errors.d.ts +4 -0
  15. package/build/cjs/generate/errors.js +59 -0
  16. package/build/cjs/generate/events.d.ts +5 -0
  17. package/build/cjs/generate/events.js +139 -0
  18. package/build/cjs/generate/index.js +23 -0
  19. package/build/cjs/generate/interfaceRegistry.d.ts +4 -0
  20. package/build/cjs/generate/interfaceRegistry.js +64 -0
  21. package/build/cjs/generate/lookup.d.ts +4 -0
  22. package/build/cjs/generate/lookup.js +240 -0
  23. package/build/cjs/generate/query.d.ts +5 -0
  24. package/build/cjs/generate/query.js +140 -0
  25. package/build/cjs/generate/rpc.d.ts +6 -0
  26. package/build/cjs/generate/rpc.js +115 -0
  27. package/build/cjs/generate/runtime.d.ts +7 -0
  28. package/build/cjs/generate/runtime.js +233 -0
  29. package/build/cjs/generate/tsDef.d.ts +16 -0
  30. package/build/cjs/generate/tsDef.js +254 -0
  31. package/build/cjs/generate/tx.d.ts +5 -0
  32. package/build/cjs/generate/tx.js +121 -0
  33. package/build/cjs/generate/types.d.ts +12 -0
  34. package/build/cjs/generate/types.js +16 -0
  35. package/build/cjs/index.js +5 -0
  36. package/build/cjs/interfacesTs.js +28 -0
  37. package/build/cjs/metadataMd.js +652 -0
  38. package/build/cjs/packageInfo.js +4 -0
  39. package/build/cjs/util/assert.js +15 -0
  40. package/build/cjs/util/derived.js +128 -0
  41. package/build/cjs/util/docs.js +10 -0
  42. package/build/cjs/util/file.js +33 -0
  43. package/build/cjs/util/formatting.js +237 -0
  44. package/build/cjs/util/imports.js +126 -0
  45. package/build/cjs/util/index.js +39 -0
  46. package/build/cjs/util/initMeta.js +22 -0
  47. package/build/cjs/util/register.js +10 -0
  48. package/build/cjs/util/wsMeta.js +60 -0
  49. package/build/extractChain.d.ts +1 -0
  50. package/build/extractChain.js +40 -0
  51. package/build/fromChain.d.ts +1 -0
  52. package/build/fromChain.js +91 -0
  53. package/build/fromDefs.d.ts +1 -0
  54. package/build/fromDefs.js +78 -0
  55. package/build/generate/consts.d.ts +5 -0
  56. package/build/generate/consts.js +87 -0
  57. package/build/generate/errors.d.ts +4 -0
  58. package/build/generate/errors.js +55 -0
  59. package/build/generate/events.d.ts +5 -0
  60. package/build/generate/events.js +135 -0
  61. package/build/generate/index.d.ts +10 -0
  62. package/build/generate/index.js +10 -0
  63. package/build/generate/interfaceRegistry.d.ts +4 -0
  64. package/build/generate/interfaceRegistry.js +59 -0
  65. package/build/generate/lookup.d.ts +4 -0
  66. package/build/generate/lookup.js +235 -0
  67. package/build/generate/query.d.ts +5 -0
  68. package/build/generate/query.js +136 -0
  69. package/build/generate/rpc.d.ts +6 -0
  70. package/build/generate/rpc.js +110 -0
  71. package/build/generate/runtime.d.ts +7 -0
  72. package/build/generate/runtime.js +228 -0
  73. package/build/generate/tsDef.d.ts +16 -0
  74. package/build/generate/tsDef.js +246 -0
  75. package/build/generate/tx.d.ts +5 -0
  76. package/build/generate/tx.js +117 -0
  77. package/build/generate/types.d.ts +12 -0
  78. package/build/generate/types.js +13 -0
  79. package/build/index.d.ts +2 -0
  80. package/build/index.js +2 -0
  81. package/build/interfacesTs.d.ts +1 -0
  82. package/build/interfacesTs.js +24 -0
  83. package/build/metadataMd.d.ts +1 -0
  84. package/build/metadataMd.js +648 -0
  85. package/build/package.json +548 -0
  86. package/build/packageDetect.d.ts +1 -0
  87. package/build/packageDetect.js +6 -0
  88. package/build/packageInfo.d.ts +6 -0
  89. package/build/packageInfo.js +1 -0
  90. package/build/scripts/pezkuwi-types-chain-info.mjs +7 -0
  91. package/build/scripts/pezkuwi-types-from-chain.mjs +7 -0
  92. package/build/scripts/pezkuwi-types-from-defs.mjs +7 -0
  93. package/build/scripts/pezkuwi-types-internal-interfaces.mjs +7 -0
  94. package/build/scripts/pezkuwi-types-internal-metadata.mjs +7 -0
  95. package/build/templates/calls.hbs +30 -0
  96. package/build/templates/consts.hbs +28 -0
  97. package/build/templates/docs.hbs +7 -0
  98. package/build/templates/errors.hbs +28 -0
  99. package/build/templates/events.hbs +28 -0
  100. package/build/templates/header.hbs +2 -0
  101. package/build/templates/interfaceRegistry.hbs +15 -0
  102. package/build/templates/lookup/defs-named.hbs +12 -0
  103. package/build/templates/lookup/defs.hbs +15 -0
  104. package/build/templates/lookup/index.hbs +3 -0
  105. package/build/templates/lookup/types.hbs +14 -0
  106. package/build/templates/query.hbs +29 -0
  107. package/build/templates/rpc.hbs +22 -0
  108. package/build/templates/tsDef/index.hbs +3 -0
  109. package/build/templates/tsDef/moduleTypes.hbs +10 -0
  110. package/build/templates/tsDef/types.hbs +7 -0
  111. package/build/templates/tx.hbs +30 -0
  112. package/build/util/assert.d.ts +2 -0
  113. package/build/util/assert.js +10 -0
  114. package/build/util/derived.d.ts +4 -0
  115. package/build/util/derived.js +125 -0
  116. package/build/util/docs.d.ts +1 -0
  117. package/build/util/docs.js +6 -0
  118. package/build/util/file.d.ts +2 -0
  119. package/build/util/file.js +28 -0
  120. package/build/util/formatting.d.ts +11 -0
  121. package/build/util/formatting.js +230 -0
  122. package/build/util/imports.d.ts +23 -0
  123. package/build/util/imports.js +121 -0
  124. package/build/util/index.d.ts +16 -0
  125. package/build/util/index.js +34 -0
  126. package/build/util/initMeta.d.ts +12 -0
  127. package/build/util/initMeta.js +19 -0
  128. package/build/util/register.d.ts +4 -0
  129. package/build/util/register.js +7 -0
  130. package/build/util/wsMeta.d.ts +4 -0
  131. package/build/util/wsMeta.js +55 -0
  132. package/build-tsc-cjs/packageDetect.js +8 -0
  133. package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
  134. package/build-tsc-esm/generate/consts.js +87 -0
  135. package/build-tsc-esm/generate/errors.js +55 -0
  136. package/build-tsc-esm/generate/events.js +135 -0
  137. package/build-tsc-esm/generate/interfaceRegistry.js +59 -0
  138. package/build-tsc-esm/generate/lookup.js +235 -0
  139. package/build-tsc-esm/generate/query.js +136 -0
  140. package/build-tsc-esm/generate/rpc.js +110 -0
  141. package/build-tsc-esm/generate/runtime.js +228 -0
  142. package/build-tsc-esm/generate/tsDef.js +246 -0
  143. package/build-tsc-esm/generate/tx.js +117 -0
  144. package/build-tsc-esm/generate/types.js +13 -0
  145. package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
  146. package/package.json +27 -27
  147. package/src/augment.ts +5 -0
  148. package/src/bundle.ts +5 -0
  149. package/src/extractChain.ts +54 -0
  150. package/src/fromChain.ts +123 -0
  151. package/src/fromDefs.ts +106 -0
  152. package/src/generate/consts.ts +112 -0
  153. package/src/generate/errors.ts +75 -0
  154. package/src/generate/events.ts +165 -0
  155. package/src/generate/index.ts +13 -0
  156. package/src/generate/interfaceRegistry.ts +85 -0
  157. package/src/generate/lookup.ts +322 -0
  158. package/src/generate/query.ts +169 -0
  159. package/src/generate/rpc.ts +158 -0
  160. package/src/generate/runtime.ts +293 -0
  161. package/src/generate/tsDef.ts +321 -0
  162. package/src/generate/tx.ts +152 -0
  163. package/src/generate/types.ts +26 -0
  164. package/src/index.ts +6 -0
  165. package/src/interfacesTs.ts +35 -0
  166. package/src/metadataMd.ts +844 -0
  167. package/src/packageDetect.ts +14 -0
  168. package/src/packageInfo.ts +6 -0
  169. package/src/templates/calls.hbs +30 -0
  170. package/src/templates/consts.hbs +28 -0
  171. package/src/templates/docs.hbs +7 -0
  172. package/src/templates/errors.hbs +28 -0
  173. package/src/templates/events.hbs +28 -0
  174. package/src/templates/header.hbs +2 -0
  175. package/src/templates/interfaceRegistry.hbs +15 -0
  176. package/src/templates/lookup/defs-named.hbs +12 -0
  177. package/src/templates/lookup/defs.hbs +15 -0
  178. package/src/templates/lookup/index.hbs +3 -0
  179. package/src/templates/lookup/types.hbs +14 -0
  180. package/src/templates/query.hbs +29 -0
  181. package/src/templates/rpc.hbs +22 -0
  182. package/src/templates/tsDef/index.hbs +3 -0
  183. package/src/templates/tsDef/moduleTypes.hbs +10 -0
  184. package/src/templates/tsDef/types.hbs +7 -0
  185. package/src/templates/tx.hbs +30 -0
  186. package/src/util/assert.ts +18 -0
  187. package/src/util/derived.spec.ts +58 -0
  188. package/src/util/derived.ts +133 -0
  189. package/src/util/docs.ts +13 -0
  190. package/src/util/file.ts +42 -0
  191. package/src/util/formatting.spec.ts +30 -0
  192. package/src/util/formatting.ts +322 -0
  193. package/src/util/imports.ts +164 -0
  194. package/src/util/index.ts +42 -0
  195. package/src/util/initMeta.ts +37 -0
  196. package/src/util/register.ts +12 -0
  197. package/src/util/wsMeta.ts +70 -0
  198. package/tsconfig.build.json +28 -0
  199. package/tsconfig.build.tsbuildinfo +1 -0
  200. package/tsconfig.scripts.json +19 -0
  201. package/tsconfig.spec.json +17 -0
  202. package/tsconfig.spec.tsbuildinfo +1 -0
  203. /package/{cjs → build}/augment.d.ts +0 -0
  204. /package/{cjs → build}/bundle.d.ts +0 -0
  205. /package/{extractChain.d.ts → build/cjs/extractChain.d.ts} +0 -0
  206. /package/{fromChain.d.ts → build/cjs/fromChain.d.ts} +0 -0
  207. /package/{fromDefs.d.ts → build/cjs/fromDefs.d.ts} +0 -0
  208. /package/{generate → build/cjs/generate}/index.d.ts +0 -0
  209. /package/{index.d.ts → build/cjs/index.d.ts} +0 -0
  210. /package/{interfacesTs.d.ts → build/cjs/interfacesTs.d.ts} +0 -0
  211. /package/{metadataMd.d.ts → build/cjs/metadataMd.d.ts} +0 -0
  212. /package/{cjs → build/cjs}/package.json +0 -0
  213. /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
  214. /package/{cjs → build/cjs}/packageDetect.js +0 -0
  215. /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
  216. /package/{util → build/cjs/util}/assert.d.ts +0 -0
  217. /package/{util → build/cjs/util}/derived.d.ts +0 -0
  218. /package/{util → build/cjs/util}/docs.d.ts +0 -0
  219. /package/{util → build/cjs/util}/file.d.ts +0 -0
  220. /package/{util → build/cjs/util}/formatting.d.ts +0 -0
  221. /package/{util → build/cjs/util}/imports.d.ts +0 -0
  222. /package/{util → build/cjs/util}/index.d.ts +0 -0
  223. /package/{util → build/cjs/util}/initMeta.d.ts +0 -0
  224. /package/{util → build/cjs/util}/register.d.ts +0 -0
  225. /package/{util → build/cjs/util}/wsMeta.d.ts +0 -0
  226. /package/{augment.d.ts → build-tsc/augment.d.ts} +0 -0
  227. /package/{bundle.d.ts → build-tsc/bundle.d.ts} +0 -0
  228. /package/{cjs → build-tsc}/extractChain.d.ts +0 -0
  229. /package/{cjs → build-tsc}/fromChain.d.ts +0 -0
  230. /package/{cjs → build-tsc}/fromDefs.d.ts +0 -0
  231. /package/{cjs → build-tsc}/generate/consts.d.ts +0 -0
  232. /package/{cjs → build-tsc}/generate/errors.d.ts +0 -0
  233. /package/{cjs → build-tsc}/generate/events.d.ts +0 -0
  234. /package/{cjs → build-tsc}/generate/index.d.ts +0 -0
  235. /package/{cjs → build-tsc}/generate/interfaceRegistry.d.ts +0 -0
  236. /package/{cjs → build-tsc}/generate/lookup.d.ts +0 -0
  237. /package/{cjs → build-tsc}/generate/query.d.ts +0 -0
  238. /package/{cjs → build-tsc}/generate/rpc.d.ts +0 -0
  239. /package/{cjs → build-tsc}/generate/runtime.d.ts +0 -0
  240. /package/{cjs → build-tsc}/generate/tsDef.d.ts +0 -0
  241. /package/{cjs → build-tsc}/generate/tx.d.ts +0 -0
  242. /package/{cjs → build-tsc}/generate/types.d.ts +0 -0
  243. /package/{cjs → build-tsc}/index.d.ts +0 -0
  244. /package/{cjs → build-tsc}/interfacesTs.d.ts +0 -0
  245. /package/{cjs → build-tsc}/metadataMd.d.ts +0 -0
  246. /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
  247. /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
  248. /package/{cjs → build-tsc}/util/assert.d.ts +0 -0
  249. /package/{cjs → build-tsc}/util/derived.d.ts +0 -0
  250. /package/{cjs → build-tsc}/util/docs.d.ts +0 -0
  251. /package/{cjs → build-tsc}/util/file.d.ts +0 -0
  252. /package/{cjs → build-tsc}/util/formatting.d.ts +0 -0
  253. /package/{cjs → build-tsc}/util/imports.d.ts +0 -0
  254. /package/{cjs → build-tsc}/util/index.d.ts +0 -0
  255. /package/{cjs → build-tsc}/util/initMeta.d.ts +0 -0
  256. /package/{cjs → build-tsc}/util/register.d.ts +0 -0
  257. /package/{cjs → build-tsc}/util/wsMeta.d.ts +0 -0
  258. /package/{cjs → build-tsc-cjs}/augment.js +0 -0
  259. /package/{cjs → build-tsc-cjs}/bundle.js +0 -0
  260. /package/{cjs → build-tsc-cjs}/extractChain.js +0 -0
  261. /package/{cjs → build-tsc-cjs}/fromChain.js +0 -0
  262. /package/{cjs → build-tsc-cjs}/fromDefs.js +0 -0
  263. /package/{cjs → build-tsc-cjs}/generate/consts.js +0 -0
  264. /package/{cjs → build-tsc-cjs}/generate/errors.js +0 -0
  265. /package/{cjs → build-tsc-cjs}/generate/events.js +0 -0
  266. /package/{cjs → build-tsc-cjs}/generate/index.js +0 -0
  267. /package/{cjs → build-tsc-cjs}/generate/interfaceRegistry.js +0 -0
  268. /package/{cjs → build-tsc-cjs}/generate/lookup.js +0 -0
  269. /package/{cjs → build-tsc-cjs}/generate/query.js +0 -0
  270. /package/{cjs → build-tsc-cjs}/generate/rpc.js +0 -0
  271. /package/{cjs → build-tsc-cjs}/generate/runtime.js +0 -0
  272. /package/{cjs → build-tsc-cjs}/generate/tsDef.js +0 -0
  273. /package/{cjs → build-tsc-cjs}/generate/tx.js +0 -0
  274. /package/{cjs → build-tsc-cjs}/generate/types.js +0 -0
  275. /package/{cjs → build-tsc-cjs}/index.js +0 -0
  276. /package/{cjs → build-tsc-cjs}/interfacesTs.js +0 -0
  277. /package/{cjs → build-tsc-cjs}/metadataMd.js +0 -0
  278. /package/{cjs → build-tsc-cjs}/util/assert.js +0 -0
  279. /package/{cjs → build-tsc-cjs}/util/derived.js +0 -0
  280. /package/{cjs → build-tsc-cjs}/util/docs.js +0 -0
  281. /package/{cjs → build-tsc-cjs}/util/file.js +0 -0
  282. /package/{cjs → build-tsc-cjs}/util/formatting.js +0 -0
  283. /package/{cjs → build-tsc-cjs}/util/imports.js +0 -0
  284. /package/{cjs → build-tsc-cjs}/util/index.js +0 -0
  285. /package/{cjs → build-tsc-cjs}/util/initMeta.js +0 -0
  286. /package/{cjs → build-tsc-cjs}/util/register.js +0 -0
  287. /package/{cjs → build-tsc-cjs}/util/wsMeta.js +0 -0
  288. /package/{augment.js → build-tsc-esm/augment.js} +0 -0
  289. /package/{bundle.js → build-tsc-esm/bundle.js} +0 -0
  290. /package/{extractChain.js → build-tsc-esm/extractChain.js} +0 -0
  291. /package/{fromChain.js → build-tsc-esm/fromChain.js} +0 -0
  292. /package/{fromDefs.js → build-tsc-esm/fromDefs.js} +0 -0
  293. /package/{generate → build-tsc-esm/generate}/index.js +0 -0
  294. /package/{index.js → build-tsc-esm/index.js} +0 -0
  295. /package/{interfacesTs.js → build-tsc-esm/interfacesTs.js} +0 -0
  296. /package/{metadataMd.js → build-tsc-esm/metadataMd.js} +0 -0
  297. /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
  298. /package/{util → build-tsc-esm/util}/assert.js +0 -0
  299. /package/{util → build-tsc-esm/util}/derived.js +0 -0
  300. /package/{util → build-tsc-esm/util}/docs.js +0 -0
  301. /package/{util → build-tsc-esm/util}/file.js +0 -0
  302. /package/{util → build-tsc-esm/util}/formatting.js +0 -0
  303. /package/{util → build-tsc-esm/util}/imports.js +0 -0
  304. /package/{util → build-tsc-esm/util}/index.js +0 -0
  305. /package/{util → build-tsc-esm/util}/initMeta.js +0 -0
  306. /package/{util → build-tsc-esm/util}/register.js +0 -0
  307. /package/{util → build-tsc-esm/util}/wsMeta.js +0 -0
@@ -0,0 +1,117 @@
1
+ import Handlebars from 'handlebars';
2
+ import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
3
+ import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
4
+ import { stringCamelCase } from '@pezkuwi/util';
5
+ import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
6
+ import { ignoreUnusedLookups } from './lookup.js';
7
+ import { getDeprecationNotice } from './types.js';
8
+ const MAPPED_NAMES = {
9
+ class: 'clazz',
10
+ new: 'updated'
11
+ };
12
+ const generateForMetaTemplate = Handlebars.compile(readTemplate('tx'));
13
+ function mapName(_name) {
14
+ const name = stringCamelCase(_name);
15
+ return MAPPED_NAMES[name] || name;
16
+ }
17
+ /** @internal */
18
+ function generateForMeta(registry, meta, dest, extraTypes, isStrict, customLookupDefinitions) {
19
+ writeFile(dest, () => {
20
+ const allTypes = {
21
+ '@pezkuwi/types-augment': {
22
+ lookup: {
23
+ ...lookupDefinitions,
24
+ ...customLookupDefinitions
25
+ }
26
+ },
27
+ '@pezkuwi/types/interfaces': defaultDefs,
28
+ ...extraTypes
29
+ };
30
+ const imports = createImports(allTypes);
31
+ const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
32
+ return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
33
+ }, {});
34
+ const { lookup, pallets } = meta.asLatest;
35
+ const usedTypes = new Set([]);
36
+ const modules = pallets
37
+ .sort(compareName)
38
+ .filter(({ calls }) => calls.isSome)
39
+ .map((data) => {
40
+ const name = data.name;
41
+ const calls = data.calls.unwrap();
42
+ const deprecationInfo = calls.deprecationInfo.toJSON();
43
+ setImports(allDefs, imports, ['SubmittableExtrinsic']);
44
+ const sectionName = stringCamelCase(name);
45
+ const items = lookup.getSiType(calls.type).def.asVariant.variants
46
+ .map(({ docs, fields, index, name }) => {
47
+ const rawStatus = deprecationInfo?.[index.toNumber()];
48
+ if (rawStatus) {
49
+ const deprecationVariantInfo = meta.registry.createTypeUnsafe('VariantDeprecationInfoV16', [rawStatus]);
50
+ const deprecationNotice = getDeprecationNotice(deprecationVariantInfo, name.toString(), 'Call');
51
+ const notice = docs.length ? ['', deprecationNotice] : [deprecationNotice];
52
+ docs.push(...notice.map((text) => meta.registry.createType('Text', text)));
53
+ }
54
+ const typesInfo = fields.map(({ name, type, typeName }, index) => {
55
+ const typeDef = registry.lookup.getTypeDef(type);
56
+ return [
57
+ name.isSome
58
+ ? mapName(name.unwrap())
59
+ : `param${index}`,
60
+ rebrandTypeName(typeName.isSome
61
+ ? typeName.toString()
62
+ : typeDef.type),
63
+ rebrandTypeName(typeDef.isFromSi
64
+ ? typeDef.type
65
+ : typeDef.lookupName || typeDef.type)
66
+ ];
67
+ });
68
+ const params = typesInfo
69
+ .map(([name, , typeStr]) => {
70
+ const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports);
71
+ setImports(allDefs, imports, [typeStr, ...similarTypes]);
72
+ // Add the type to the list of used types
73
+ if (!(imports.primitiveTypes[typeStr])) {
74
+ usedTypes.add(typeStr);
75
+ }
76
+ return `${name}: ${similarTypes.join(' | ')}`;
77
+ })
78
+ .join(', ');
79
+ return {
80
+ args: typesInfo.map(([, , typeStr]) => formatType(registry, allDefs, typeStr, imports)).join(', '),
81
+ docs,
82
+ name: stringCamelCase(name),
83
+ params
84
+ };
85
+ })
86
+ .sort(compareName);
87
+ return {
88
+ items,
89
+ name: sectionName
90
+ };
91
+ })
92
+ .sort(compareName);
93
+ // filter out the unused lookup types from imports
94
+ ignoreUnusedLookups([...usedTypes], imports);
95
+ return generateForMetaTemplate({
96
+ headerType: 'chain',
97
+ imports,
98
+ isStrict,
99
+ modules,
100
+ types: [
101
+ ...Object.keys(imports.localTypes).sort().map((packagePath) => ({
102
+ file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
103
+ types: Object.keys(imports.localTypes[packagePath])
104
+ })),
105
+ {
106
+ file: '@pezkuwi/api-base/types',
107
+ types: ['ApiTypes', 'AugmentedSubmittable', 'SubmittableExtrinsic', 'SubmittableExtrinsicFunction']
108
+ }
109
+ ]
110
+ });
111
+ });
112
+ }
113
+ /** @internal */
114
+ export function generateDefaultTx(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
115
+ const { metadata, registry } = initMeta(data, extraTypes);
116
+ return generateForMeta(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions);
117
+ }
@@ -0,0 +1,13 @@
1
+ export function getDeprecationNotice(deprecationInfo, name, label) {
2
+ let deprecationNotice = '@deprecated';
3
+ if (deprecationInfo.isDeprecated) {
4
+ const { note, since } = deprecationInfo.asDeprecated;
5
+ const sinceText = since.isSome ? ` Since ${since.unwrap().toString()}.` : '';
6
+ deprecationNotice += ` ${note.toString()}${sinceText}`;
7
+ }
8
+ else {
9
+ const labelText = label ? `${label} ` : '';
10
+ deprecationNotice += ` ${labelText}${name} has been deprecated`;
11
+ }
12
+ return deprecationNotice;
13
+ }
@@ -1 +1 @@
1
- export const packageInfo = { name: '@pezkuwi/typegen', 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.16' };
1
+ export const packageInfo = { name: '@pezkuwi/typegen', 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' };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "author": "Dijital Kurdistan Tech Institute <dev@pezkuwichain.io>",
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
3
  "bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
4
4
  "description": "Type generation scripts",
5
5
  "engines": {
@@ -18,7 +18,10 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "16.5.16",
21
+ "types": "./index.d.ts",
22
+ "version": "16.5.18",
23
+ "main": "./cjs/index.js",
24
+ "module": "./index.js",
22
25
  "bin": {
23
26
  "pezkuwi-types-chain-info": "./scripts/pezkuwi-types-chain-info.mjs",
24
27
  "pezkuwi-types-from-chain": "./scripts/pezkuwi-types-from-chain.mjs",
@@ -26,12 +29,7 @@
26
29
  "pezkuwi-types-internal-interfaces": "./scripts/pezkuwi-types-internal-interfaces.mjs",
27
30
  "pezkuwi-types-internal-metadata": "./scripts/pezkuwi-types-internal-metadata.mjs"
28
31
  },
29
- "main": "./cjs/index.js",
30
- "module": "./cjs/index.js",
31
- "types": "./cjs/index.d.ts",
32
32
  "exports": {
33
- "./cjs/package.json": "./cjs/package.json",
34
- "./cjs/*": "./cjs/*.js",
35
33
  ".": {
36
34
  "module": {
37
35
  "types": "./index.d.ts",
@@ -74,6 +72,8 @@
74
72
  "default": "./bundle.js"
75
73
  }
76
74
  },
75
+ "./cjs/*": "./cjs/*.js",
76
+ "./cjs/package.json": "./cjs/package.json",
77
77
  "./extractChain": {
78
78
  "module": {
79
79
  "types": "./extractChain.d.ts",
@@ -330,7 +330,7 @@
330
330
  "default": "./packageDetect.js"
331
331
  }
332
332
  },
333
- "./packageInfo.js": {
333
+ "./packageInfo": {
334
334
  "module": {
335
335
  "types": "./packageInfo.d.ts",
336
336
  "default": "./packageInfo.js"
@@ -344,7 +344,7 @@
344
344
  "default": "./packageInfo.js"
345
345
  }
346
346
  },
347
- "./packageInfo": {
347
+ "./packageInfo.js": {
348
348
  "module": {
349
349
  "types": "./packageInfo.d.ts",
350
350
  "default": "./packageInfo.js"
@@ -358,16 +358,16 @@
358
358
  "default": "./packageInfo.js"
359
359
  }
360
360
  },
361
- "./scripts/pezkuwi-types-chain-info.mjs": "./scripts/pezkuwi-types-chain-info.mjs",
362
361
  "./scripts/pezkuwi-types-chain-info": "./scripts/pezkuwi-types-chain-info.mjs",
363
- "./scripts/pezkuwi-types-from-chain.mjs": "./scripts/pezkuwi-types-from-chain.mjs",
362
+ "./scripts/pezkuwi-types-chain-info.mjs": "./scripts/pezkuwi-types-chain-info.mjs",
364
363
  "./scripts/pezkuwi-types-from-chain": "./scripts/pezkuwi-types-from-chain.mjs",
365
- "./scripts/pezkuwi-types-from-defs.mjs": "./scripts/pezkuwi-types-from-defs.mjs",
364
+ "./scripts/pezkuwi-types-from-chain.mjs": "./scripts/pezkuwi-types-from-chain.mjs",
366
365
  "./scripts/pezkuwi-types-from-defs": "./scripts/pezkuwi-types-from-defs.mjs",
367
- "./scripts/pezkuwi-types-internal-interfaces.mjs": "./scripts/pezkuwi-types-internal-interfaces.mjs",
366
+ "./scripts/pezkuwi-types-from-defs.mjs": "./scripts/pezkuwi-types-from-defs.mjs",
368
367
  "./scripts/pezkuwi-types-internal-interfaces": "./scripts/pezkuwi-types-internal-interfaces.mjs",
369
- "./scripts/pezkuwi-types-internal-metadata.mjs": "./scripts/pezkuwi-types-internal-metadata.mjs",
368
+ "./scripts/pezkuwi-types-internal-interfaces.mjs": "./scripts/pezkuwi-types-internal-interfaces.mjs",
370
369
  "./scripts/pezkuwi-types-internal-metadata": "./scripts/pezkuwi-types-internal-metadata.mjs",
370
+ "./scripts/pezkuwi-types-internal-metadata.mjs": "./scripts/pezkuwi-types-internal-metadata.mjs",
371
371
  "./templates/calls.hbs": "./templates/calls.hbs",
372
372
  "./templates/consts.hbs": "./templates/consts.hbs",
373
373
  "./templates/docs.hbs": "./templates/docs.hbs",
@@ -527,19 +527,19 @@
527
527
  }
528
528
  },
529
529
  "dependencies": {
530
- "@pezkuwi/api": "16.5.15",
531
- "@pezkuwi/api-augment": "16.5.15",
532
- "@pezkuwi/api-derive": "16.5.15",
533
- "@pezkuwi/rpc-augment": "16.5.15",
534
- "@pezkuwi/rpc-provider": "16.5.15",
535
- "@pezkuwi/types": "16.5.15",
536
- "@pezkuwi/types-augment": "16.5.15",
537
- "@pezkuwi/types-codec": "16.5.15",
538
- "@pezkuwi/types-create": "16.5.15",
539
- "@pezkuwi/types-support": "16.5.15",
540
- "@pezkuwi/util": "14.0.12",
541
- "@pezkuwi/util-crypto": "14.0.12",
542
- "@pezkuwi/x-ws": "14.0.12",
530
+ "@pezkuwi/api": "16.5.9",
531
+ "@pezkuwi/api-augment": "16.5.9",
532
+ "@pezkuwi/api-derive": "16.5.9",
533
+ "@pezkuwi/rpc-augment": "16.5.9",
534
+ "@pezkuwi/rpc-provider": "16.5.9",
535
+ "@pezkuwi/types": "16.5.9",
536
+ "@pezkuwi/types-augment": "16.5.9",
537
+ "@pezkuwi/types-codec": "16.5.9",
538
+ "@pezkuwi/types-create": "16.5.9",
539
+ "@pezkuwi/types-support": "16.5.9",
540
+ "@pezkuwi/util": "14.0.11",
541
+ "@pezkuwi/util-crypto": "14.0.11",
542
+ "@pezkuwi/x-ws": "14.0.11",
543
543
  "comment-parser": "^1.4.1",
544
544
  "handlebars": "^4.7.8",
545
545
  "tslib": "^2.8.1",
package/src/augment.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import '@pezkuwi/api-augment';
5
+ import '@pezkuwi/rpc-augment';
package/src/bundle.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { packageInfo } from './packageInfo.js';
5
+ export { formatType } from './util/formatting.js';
@@ -0,0 +1,54 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Connects to the local chain and outputs a re-usable calls-only chain definition in the form
5
+ // export default { chain: 'Development', genesisHash: '0x27b6d5e0f4fdce1c4d20b82406f193acacce0c19e0d2c0e7ca47725c2572a06a', ss58Format: 42, tokenDecimals: 0, tokenSymbol: 'UNIT'; metaCalls: 'bWV0...4AAA==' };
6
+
7
+ import process from 'node:process';
8
+ import yargs from 'yargs';
9
+ import { hideBin } from 'yargs/helpers';
10
+
11
+ import { ApiPromise, WsProvider } from '@pezkuwi/api';
12
+
13
+ /** @internal */
14
+ async function run (ws: string): Promise<void> {
15
+ const provider = new WsProvider(ws);
16
+ const api = await ApiPromise.create({ provider, throwOnConnect: true });
17
+ const [chain, props] = await Promise.all([
18
+ api.rpc.system.chain(),
19
+ api.rpc.system.properties()
20
+ ]);
21
+
22
+ // output the chain info, for easy re-use
23
+ console.error(`// Generated via 'yarn run chain:info ${ws}'\n\nexport default {\n chain: '${chain.toString()}',\n genesisHash: '${api.genesisHash.toHex()}',\n specVersion: ${api.runtimeVersion.specVersion.toNumber()},\n ss58Format: ${props.ss58Format.unwrapOr(42).toString()},\n tokenDecimals: ${props.tokenDecimals.unwrapOr(0).toString()},\n tokenSymbol: '${props.tokenSymbol.unwrapOr('UNIT').toString()}',\n metaCalls: '${Buffer.from(api.runtimeMetadata.asCallsOnly.toU8a()).toString('base64')}'\n};`);
24
+
25
+ // show any missing types
26
+ api.runtimeMetadata.getUniqTypes(false);
27
+ }
28
+
29
+ interface ArgV { ws: string }
30
+
31
+ export function main (): void {
32
+ // retrieve and parse arguments - we do this globally, since this is a single command
33
+ const { ws } = yargs(hideBin(process.argv))
34
+ .usage('Usage: [options]')
35
+ .wrap(120)
36
+ .strict()
37
+ .options({
38
+ ws: {
39
+ default: 'ws://127.0.0.1:9944',
40
+ description: 'The API endpoint to connect to, e.g. wss://dicle-rpc.pezkuwi.io',
41
+ required: true,
42
+ type: 'string'
43
+ }
44
+ }).argv as ArgV;
45
+
46
+ run(ws)
47
+ .then((): void => {
48
+ process.exit(0);
49
+ })
50
+ .catch((error: Error) => {
51
+ console.error('FATAL:', error.message);
52
+ process.exit(-1);
53
+ });
54
+ }
@@ -0,0 +1,123 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Definitions, DefinitionsTypes } from '@pezkuwi/types/types';
5
+ import type { HexString } from '@pezkuwi/util/types';
6
+
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ import yargs from 'yargs';
10
+ import { hideBin } from 'yargs/helpers';
11
+
12
+ import { formatNumber, isHex } from '@pezkuwi/util';
13
+
14
+ import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultQuery, generateDefaultRpc, generateDefaultRuntime, generateDefaultTx } from './generate/index.js';
15
+ import { assertDir, assertFile, getMetadataViaWs, HEADER, writeFile } from './util/index.js';
16
+
17
+ async function generate (metaHex: HexString, pkg: string | undefined, output: string, isStrict?: boolean): Promise<void> {
18
+ console.log(`Generating from metadata, ${formatNumber((metaHex.length - 2) / 2)} bytes`);
19
+
20
+ const outputPath = assertDir(path.join(process.cwd(), output));
21
+ let extraTypes: Record<string, any> = {};
22
+ let customLookupDefinitions: Definitions = { rpc: {}, types: {} };
23
+
24
+ if (pkg) {
25
+ try {
26
+ const defCont = await import(
27
+ assertFile(path.join(outputPath, 'definitions.ts'))
28
+ ) as Record<string, any>;
29
+
30
+ extraTypes = {
31
+ [pkg]: defCont
32
+ };
33
+ } catch (error) {
34
+ console.error('ERROR: No custom definitions found:', (error as Error).message);
35
+ }
36
+ }
37
+
38
+ try {
39
+ const lookCont = await import(
40
+ assertFile(path.join(outputPath, 'lookup.ts'))
41
+ ) as { default: DefinitionsTypes };
42
+
43
+ customLookupDefinitions = {
44
+ rpc: {},
45
+ types: lookCont.default
46
+ };
47
+ } catch (error) {
48
+ console.error('ERROR: No lookup definitions found:', (error as Error).message);
49
+ }
50
+
51
+ generateDefaultConsts(path.join(outputPath, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
52
+ generateDefaultErrors(path.join(outputPath, 'augment-api-errors.ts'), metaHex, extraTypes, isStrict);
53
+ generateDefaultEvents(path.join(outputPath, 'augment-api-events.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
54
+ generateDefaultQuery(path.join(outputPath, 'augment-api-query.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
55
+ generateDefaultRpc(path.join(outputPath, 'augment-api-rpc.ts'), extraTypes);
56
+ generateDefaultRuntime(path.join(outputPath, 'augment-api-runtime.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
57
+ generateDefaultTx(path.join(outputPath, 'augment-api-tx.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
58
+
59
+ writeFile(path.join(outputPath, 'augment-api.ts'), (): string =>
60
+ [
61
+ HEADER('chain'),
62
+ ...[
63
+ ...['consts', 'errors', 'events', 'query', 'tx', 'rpc', 'runtime']
64
+ .filter((key) => !!key)
65
+ .map((key) => `./augment-api-${key}.js`)
66
+ ].map((path) => `import '${path}';\n`)
67
+ ].join('')
68
+ );
69
+
70
+ process.exit(0);
71
+ }
72
+
73
+ interface ArgV { endpoint: string; output: string; package?: string; strict?: boolean }
74
+
75
+ async function mainPromise (): Promise<void> {
76
+ const { endpoint, output, package: pkg, strict: isStrict } = yargs(hideBin(process.argv)).strict().options({
77
+ endpoint: {
78
+ description: 'The endpoint to connect to (e.g. wss://dicle-rpc.pezkuwi.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
79
+ required: true,
80
+ type: 'string'
81
+ },
82
+ output: {
83
+ description: 'The target directory to write the data to',
84
+ required: true,
85
+ type: 'string'
86
+ },
87
+ package: {
88
+ description: 'Optional package in output location (for extra definitions)',
89
+ type: 'string'
90
+ },
91
+ strict: {
92
+ description: 'Turns on strict mode, no output of catch-all generic versions',
93
+ type: 'boolean'
94
+ }
95
+ }).argv as ArgV;
96
+
97
+ let metaHex: HexString;
98
+
99
+ if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
100
+ metaHex = await getMetadataViaWs(endpoint);
101
+ } else {
102
+ metaHex = (
103
+ JSON.parse(
104
+ fs.readFileSync(assertFile(path.join(process.cwd(), endpoint)), 'utf-8')
105
+ ) as { result: HexString }
106
+ ).result;
107
+
108
+ if (!isHex(metaHex)) {
109
+ throw new Error('Invalid metadata file');
110
+ }
111
+ }
112
+
113
+ await generate(metaHex, pkg, output, isStrict);
114
+ }
115
+
116
+ export function main (): void {
117
+ mainPromise().catch((error) => {
118
+ console.error();
119
+ console.error(error);
120
+ console.error();
121
+ process.exit(1);
122
+ });
123
+ }
@@ -0,0 +1,106 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { HexString } from '@pezkuwi/util/types';
5
+
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import yargs from 'yargs';
9
+ import { hideBin } from 'yargs/helpers';
10
+
11
+ import * as bizinikiwiDefs from '@pezkuwi/types/interfaces/definitions';
12
+ import { isHex } from '@pezkuwi/util';
13
+
14
+ import { generateDefaultLookup } from './generate/index.js';
15
+ import { generateInterfaceTypes } from './generate/interfaceRegistry.js';
16
+ import { generateTsDef } from './generate/tsDef.js';
17
+ import { assertDir, assertFile, getMetadataViaWs } from './util/index.js';
18
+
19
+ interface ArgV { input: string; package: string; endpoint?: string; }
20
+
21
+ async function mainPromise (): Promise<void> {
22
+ const { endpoint, input, package: pkg } = yargs(hideBin(process.argv)).strict().options({
23
+ endpoint: {
24
+ description: 'The endpoint to connect to (e.g. wss://dicle-rpc.pezkuwi.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
25
+ type: 'string'
26
+ },
27
+ input: {
28
+ description: 'The directory to use for the user definitions',
29
+ required: true,
30
+ type: 'string'
31
+ },
32
+ package: {
33
+ description: 'The package name & path to use for the user types',
34
+ required: true,
35
+ type: 'string'
36
+ }
37
+ }).argv as ArgV;
38
+
39
+ const inputPath = assertDir(path.join(process.cwd(), input));
40
+ let userDefs: Record<string, any> = {};
41
+
42
+ try {
43
+ const defCont = await import(
44
+ assertFile(path.join(inputPath, 'definitions.ts'))
45
+ ) as Record<string, any>;
46
+
47
+ userDefs = defCont;
48
+ } catch (error) {
49
+ console.error('ERROR: Unable to load user definitions:', (error as Error).message);
50
+ }
51
+
52
+ const userKeys = Object.keys(userDefs);
53
+ const filteredBase = Object
54
+ .entries(bizinikiwiDefs as Record<string, unknown>)
55
+ .filter(([key]) => {
56
+ if (userKeys.includes(key)) {
57
+ console.warn(`Override found for ${key} in user types, ignoring in @pezkuwi/types`);
58
+
59
+ return false;
60
+ }
61
+
62
+ return true;
63
+ })
64
+ .reduce((defs: Record<string, any>, [key, value]) => {
65
+ defs[key] = value;
66
+
67
+ return defs;
68
+ }, {});
69
+
70
+ const allDefs = {
71
+ '@pezkuwi/types/interfaces': filteredBase,
72
+ [pkg]: userDefs
73
+ };
74
+
75
+ generateTsDef(allDefs, inputPath, pkg);
76
+ generateInterfaceTypes(allDefs, path.join(inputPath, 'augment-types.ts'));
77
+
78
+ if (endpoint) {
79
+ let metaHex: HexString;
80
+
81
+ if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
82
+ metaHex = await getMetadataViaWs(endpoint);
83
+ } else {
84
+ metaHex = (
85
+ JSON.parse(
86
+ fs.readFileSync(assertFile(path.join(process.cwd(), endpoint)), 'utf-8')
87
+ ) as { result: HexString }
88
+ ).result;
89
+
90
+ if (!isHex(metaHex)) {
91
+ throw new Error('Invalid metadata file');
92
+ }
93
+ }
94
+
95
+ generateDefaultLookup(inputPath, metaHex);
96
+ }
97
+ }
98
+
99
+ export function main (): void {
100
+ mainPromise().catch((error) => {
101
+ console.error();
102
+ console.error(error);
103
+ console.error();
104
+ process.exit(1);
105
+ });
106
+ }
@@ -0,0 +1,112 @@
1
+ // Copyright 2017-2025 @pezkuwi/typegen authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Metadata } from '@pezkuwi/types/metadata/Metadata';
5
+ import type { Definitions } from '@pezkuwi/types/types';
6
+ import type { HexString } from '@pezkuwi/util/types';
7
+
8
+ import Handlebars from 'handlebars';
9
+
10
+ import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
11
+ import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
12
+ import { stringCamelCase } from '@pezkuwi/util';
13
+
14
+ import { compareName, createImports, formatType, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
15
+ import { ignoreUnusedLookups } from './lookup.js';
16
+ import { type ExtraTypes, getDeprecationNotice } from './types.js';
17
+
18
+ const generateForMetaTemplate = Handlebars.compile(readTemplate('consts'));
19
+
20
+ /** @internal */
21
+ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
22
+ writeFile(dest, (): string => {
23
+ const allTypes = {
24
+ '@pezkuwi/types-augment': {
25
+ lookup: {
26
+ ...lookupDefinitions,
27
+ ...customLookupDefinitions
28
+ }
29
+ },
30
+ '@pezkuwi/types/interfaces': defaultDefs,
31
+ ...extraTypes
32
+ };
33
+ const imports = createImports(allTypes);
34
+ const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
35
+ return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
36
+ }, {});
37
+ const { lookup, pallets, registry } = meta.asLatest;
38
+ const usedTypes = new Set<string>([]);
39
+
40
+ const modules = pallets
41
+ .filter(({ constants }) => constants.length > 0)
42
+ .map(({ constants, name }) => {
43
+ if (!isStrict) {
44
+ setImports(allDefs, imports, ['Codec']);
45
+ }
46
+
47
+ const items = constants
48
+ .map(({ deprecationInfo, docs, name, type }) => {
49
+ const typeDef = lookup.getTypeDef(type);
50
+ const returnType = rebrandTypeName(typeDef.lookupName || '') || formatType(registry, allDefs, typeDef, imports);
51
+
52
+ if (!deprecationInfo.isNotDeprecated) {
53
+ const deprecationNotice = getDeprecationNotice(deprecationInfo, stringCamelCase(name), 'Constant');
54
+
55
+ const items = docs.length
56
+ ? ['', deprecationNotice]
57
+ : [deprecationNotice];
58
+
59
+ docs.push(...items.map((text) => registry.createType('Text', text)));
60
+ }
61
+
62
+ // Add the type to the list of used types
63
+ if (!(imports.primitiveTypes[returnType])) {
64
+ usedTypes.add(returnType);
65
+ }
66
+
67
+ setImports(allDefs, imports, [returnType]);
68
+
69
+ return {
70
+ docs,
71
+ name: stringCamelCase(name),
72
+ type: returnType
73
+ };
74
+ })
75
+ .sort(compareName);
76
+
77
+ return {
78
+ items,
79
+ name: stringCamelCase(name)
80
+ };
81
+ })
82
+ .sort(compareName);
83
+
84
+ // filter out the unused lookup types from imports
85
+ ignoreUnusedLookups([...usedTypes], imports);
86
+
87
+ return generateForMetaTemplate({
88
+ headerType: 'chain',
89
+ imports,
90
+ isStrict,
91
+ modules,
92
+ types: [
93
+ ...Object.keys(imports.localTypes).sort().map<{ file: string; types: string[] }>((packagePath) => ({
94
+ file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
95
+ types: Object.keys(imports.localTypes[packagePath])
96
+ })),
97
+ {
98
+ file: '@pezkuwi/api-base/types',
99
+ types: ['ApiTypes', 'AugmentedConst']
100
+ }
101
+ ]
102
+ });
103
+ });
104
+ }
105
+
106
+ // Call `generateForMeta()` with current static metadata
107
+ /** @internal */
108
+ export function generateDefaultConsts (dest: string, data: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void {
109
+ const { metadata } = initMeta(data, extraTypes);
110
+
111
+ return generateForMeta(metadata, dest, extraTypes, isStrict, customLookupDefinitions);
112
+ }