@pezkuwi/typegen 16.5.17 → 16.5.31
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/cjs/generate/lookup.js +39 -10
- package/cjs/packageInfo.js +1 -1
- package/cjs/util/derived.js +15 -0
- package/cjs/util/formatting.js +5 -0
- package/generate/lookup.js +39 -10
- package/package.json +15 -15
- package/packageInfo.js +1 -1
- package/util/derived.js +16 -1
- package/util/formatting.js +5 -0
package/cjs/generate/lookup.js
CHANGED
|
@@ -163,16 +163,45 @@ function generateLookupTypes(registry, filtered, destDir, subPath) {
|
|
|
163
163
|
...(0, index_js_1.createImports)({ '@pezkuwi/types/interfaces': defaultDefinitions }, { types: {} }),
|
|
164
164
|
interfaces: []
|
|
165
165
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
.
|
|
175
|
-
.
|
|
166
|
+
// Special type mappings: PezkuwiChain types that should extend standard types
|
|
167
|
+
const TYPE_MAPPINGS = {
|
|
168
|
+
PezspCoreCryptoAccountId32: 'AccountId32',
|
|
169
|
+
PezspRuntimeMultiAddress: 'MultiAddress'
|
|
170
|
+
};
|
|
171
|
+
// Add imports for AccountId32 and MultiAddress - needed for all lookup files that use TYPE_MAPPINGS
|
|
172
|
+
const runtimePath = '@pezkuwi/types/interfaces/runtime';
|
|
173
|
+
if (imports.localTypes[runtimePath]) {
|
|
174
|
+
imports.localTypes[runtimePath]['AccountId32'] = true;
|
|
175
|
+
imports.localTypes[runtimePath]['MultiAddress'] = true;
|
|
176
|
+
}
|
|
177
|
+
// For non-bizinikiwi files, add base type definitions at the start
|
|
178
|
+
const baseTypeDefs = [];
|
|
179
|
+
if (subPath && subPath !== 'bizinikiwi') {
|
|
180
|
+
// Add PezspCoreCryptoAccountId32 and PezspRuntimeMultiAddress definitions
|
|
181
|
+
// These extend the standard types and are needed in all lookup files
|
|
182
|
+
baseTypeDefs.push(' /** @name PezspCoreCryptoAccountId32 (0) */\n interface PezspCoreCryptoAccountId32 extends AccountId32 {}', ' /** @name PezspRuntimeMultiAddress (1) */\n interface PezspRuntimeMultiAddress extends MultiAddress {}');
|
|
183
|
+
}
|
|
184
|
+
const items = [
|
|
185
|
+
...baseTypeDefs,
|
|
186
|
+
...filtered
|
|
187
|
+
.map(([, typeDef]) => {
|
|
188
|
+
// Deep rebrand the type names (including nested sub types) before generating interfaces
|
|
189
|
+
const rebranded = deepRebrandTypeDef(typeDef);
|
|
190
|
+
// Check for special type mappings first - skip if already in base types for this file
|
|
191
|
+
if (rebranded.lookupName && TYPE_MAPPINGS[rebranded.lookupName]) {
|
|
192
|
+
// For bizinikiwi, include the mapping; for others, skip (already in baseTypeDefs)
|
|
193
|
+
if (subPath === 'bizinikiwi') {
|
|
194
|
+
return (0, index_js_1.exportInterface)(rebranded.lookupIndex, rebranded.lookupName, TYPE_MAPPINGS[rebranded.lookupName]);
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return rebranded.lookupNameRoot && rebranded.lookupName
|
|
199
|
+
? (0, index_js_1.exportInterface)(rebranded.lookupIndex, rebranded.lookupName, rebranded.lookupNameRoot)
|
|
200
|
+
: tsDef_js_1.typeEncoders[rebranded.info](registry, imports.definitions, rebranded, imports);
|
|
201
|
+
})
|
|
202
|
+
.filter((t) => !!t)
|
|
203
|
+
.map((t) => t.replace(/\nexport /, '\n'))
|
|
204
|
+
];
|
|
176
205
|
(0, index_js_1.writeFile)(node_path_1.default.join(destDir, `types${subPath ? `-${subPath}` : ''}.ts`), () => generateLookupTypesTmpl({
|
|
177
206
|
headerType: 'defs',
|
|
178
207
|
imports,
|
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@pezkuwi/typegen', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.5.
|
|
4
|
+
exports.packageInfo = { name: '@pezkuwi/typegen', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.5.31' };
|
package/cjs/util/derived.js
CHANGED
|
@@ -32,6 +32,16 @@ function getSimilarTypes(registry, definitions, _type, imports) {
|
|
|
32
32
|
else if (type === '()') {
|
|
33
33
|
return ['null'];
|
|
34
34
|
}
|
|
35
|
+
// Handle lookup types by name pattern before class-based checks
|
|
36
|
+
// Lookup types like PezspRuntimeMultiAddress may not be properly registered as children of GenericMultiAddress
|
|
37
|
+
if (type.includes('MultiAddress') || type.endsWith('RuntimeMultiAddress')) {
|
|
38
|
+
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
|
39
|
+
return possibleTypes;
|
|
40
|
+
}
|
|
41
|
+
else if (type.includes('AccountId32') || type.endsWith('CryptoAccountId32')) {
|
|
42
|
+
possibleTypes.push('string', 'Uint8Array');
|
|
43
|
+
return possibleTypes;
|
|
44
|
+
}
|
|
35
45
|
const Clazz = registry.createClass(type);
|
|
36
46
|
if ((0, util_1.isChildClass)(types_codec_1.Vec, Clazz)) {
|
|
37
47
|
const vecDef = (0, types_create_1.getTypeDef)(type);
|
|
@@ -56,6 +66,11 @@ function getSimilarTypes(registry, definitions, _type, imports) {
|
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
}
|
|
69
|
+
else if ((0, util_1.isChildClass)(generic_1.GenericMultiAddress, Clazz)) {
|
|
70
|
+
// MultiAddress can accept string addresses, Uint8Array, or various address variants
|
|
71
|
+
// Check before Enum since GenericMultiAddress extends Enum
|
|
72
|
+
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
|
73
|
+
}
|
|
59
74
|
else if ((0, util_1.isChildClass)(types_codec_1.Enum, Clazz)) {
|
|
60
75
|
const { defKeys, isBasic } = new Clazz(registry);
|
|
61
76
|
const keys = defKeys.filter((v) => !v.startsWith('__Unused'));
|
package/cjs/util/formatting.js
CHANGED
|
@@ -187,6 +187,11 @@ const formatters = {
|
|
|
187
187
|
[types_create_1.TypeDefInfo.VecFixed]: (registry, typeDef, definitions, imports, withShortcut) => {
|
|
188
188
|
const sub = typeDef.sub;
|
|
189
189
|
if (sub.type === 'u8') {
|
|
190
|
+
// Use lookupName if available (e.g., PezspCoreCryptoAccountId32) instead of generic U8aFixed
|
|
191
|
+
if (typeDef.lookupName) {
|
|
192
|
+
(0, imports_js_1.setImports)(definitions, imports, [rebrandTypeName(typeDef.lookupName)]);
|
|
193
|
+
return rebrandTypeName(typeDef.lookupName);
|
|
194
|
+
}
|
|
190
195
|
(0, imports_js_1.setImports)(definitions, imports, ['U8aFixed']);
|
|
191
196
|
return 'U8aFixed';
|
|
192
197
|
}
|
package/generate/lookup.js
CHANGED
|
@@ -158,16 +158,45 @@ function generateLookupTypes(registry, filtered, destDir, subPath) {
|
|
|
158
158
|
...createImports({ '@pezkuwi/types/interfaces': defaultDefinitions }, { types: {} }),
|
|
159
159
|
interfaces: []
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
.
|
|
170
|
-
.
|
|
161
|
+
// Special type mappings: PezkuwiChain types that should extend standard types
|
|
162
|
+
const TYPE_MAPPINGS = {
|
|
163
|
+
PezspCoreCryptoAccountId32: 'AccountId32',
|
|
164
|
+
PezspRuntimeMultiAddress: 'MultiAddress'
|
|
165
|
+
};
|
|
166
|
+
// Add imports for AccountId32 and MultiAddress - needed for all lookup files that use TYPE_MAPPINGS
|
|
167
|
+
const runtimePath = '@pezkuwi/types/interfaces/runtime';
|
|
168
|
+
if (imports.localTypes[runtimePath]) {
|
|
169
|
+
imports.localTypes[runtimePath]['AccountId32'] = true;
|
|
170
|
+
imports.localTypes[runtimePath]['MultiAddress'] = true;
|
|
171
|
+
}
|
|
172
|
+
// For non-bizinikiwi files, add base type definitions at the start
|
|
173
|
+
const baseTypeDefs = [];
|
|
174
|
+
if (subPath && subPath !== 'bizinikiwi') {
|
|
175
|
+
// Add PezspCoreCryptoAccountId32 and PezspRuntimeMultiAddress definitions
|
|
176
|
+
// These extend the standard types and are needed in all lookup files
|
|
177
|
+
baseTypeDefs.push(' /** @name PezspCoreCryptoAccountId32 (0) */\n interface PezspCoreCryptoAccountId32 extends AccountId32 {}', ' /** @name PezspRuntimeMultiAddress (1) */\n interface PezspRuntimeMultiAddress extends MultiAddress {}');
|
|
178
|
+
}
|
|
179
|
+
const items = [
|
|
180
|
+
...baseTypeDefs,
|
|
181
|
+
...filtered
|
|
182
|
+
.map(([, typeDef]) => {
|
|
183
|
+
// Deep rebrand the type names (including nested sub types) before generating interfaces
|
|
184
|
+
const rebranded = deepRebrandTypeDef(typeDef);
|
|
185
|
+
// Check for special type mappings first - skip if already in base types for this file
|
|
186
|
+
if (rebranded.lookupName && TYPE_MAPPINGS[rebranded.lookupName]) {
|
|
187
|
+
// For bizinikiwi, include the mapping; for others, skip (already in baseTypeDefs)
|
|
188
|
+
if (subPath === 'bizinikiwi') {
|
|
189
|
+
return exportInterface(rebranded.lookupIndex, rebranded.lookupName, TYPE_MAPPINGS[rebranded.lookupName]);
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return rebranded.lookupNameRoot && rebranded.lookupName
|
|
194
|
+
? exportInterface(rebranded.lookupIndex, rebranded.lookupName, rebranded.lookupNameRoot)
|
|
195
|
+
: typeEncoders[rebranded.info](registry, imports.definitions, rebranded, imports);
|
|
196
|
+
})
|
|
197
|
+
.filter((t) => !!t)
|
|
198
|
+
.map((t) => t.replace(/\nexport /, '\n'))
|
|
199
|
+
];
|
|
171
200
|
writeFile(path.join(destDir, `types${subPath ? `-${subPath}` : ''}.ts`), () => generateLookupTypesTmpl({
|
|
172
201
|
headerType: 'defs',
|
|
173
202
|
imports,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author": "
|
|
2
|
+
"author": "PezkuwiChain <dev@pezkuwichain.io>",
|
|
3
3
|
"bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
|
|
4
4
|
"description": "Type generation scripts",
|
|
5
5
|
"engines": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/packageDetect.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "16.5.
|
|
21
|
+
"version": "16.5.31",
|
|
22
22
|
"bin": {
|
|
23
23
|
"pezkuwi-types-chain-info": "./scripts/pezkuwi-types-chain-info.mjs",
|
|
24
24
|
"pezkuwi-types-from-chain": "./scripts/pezkuwi-types-from-chain.mjs",
|
|
@@ -527,19 +527,19 @@
|
|
|
527
527
|
}
|
|
528
528
|
},
|
|
529
529
|
"dependencies": {
|
|
530
|
-
"@pezkuwi/api": "16.5.
|
|
531
|
-
"@pezkuwi/api-augment": "16.5.
|
|
532
|
-
"@pezkuwi/api-derive": "16.5.
|
|
533
|
-
"@pezkuwi/rpc-augment": "16.5.
|
|
534
|
-
"@pezkuwi/rpc-provider": "16.5.
|
|
535
|
-
"@pezkuwi/types": "16.5.
|
|
536
|
-
"@pezkuwi/types-augment": "16.5.
|
|
537
|
-
"@pezkuwi/types-codec": "16.5.
|
|
538
|
-
"@pezkuwi/types-create": "16.5.
|
|
539
|
-
"@pezkuwi/types-support": "16.5.
|
|
540
|
-
"@pezkuwi/util": "14.0.
|
|
541
|
-
"@pezkuwi/util-crypto": "14.0.
|
|
542
|
-
"@pezkuwi/x-ws": "14.0.
|
|
530
|
+
"@pezkuwi/api": "16.5.31",
|
|
531
|
+
"@pezkuwi/api-augment": "16.5.31",
|
|
532
|
+
"@pezkuwi/api-derive": "16.5.31",
|
|
533
|
+
"@pezkuwi/rpc-augment": "16.5.31",
|
|
534
|
+
"@pezkuwi/rpc-provider": "16.5.31",
|
|
535
|
+
"@pezkuwi/types": "16.5.31",
|
|
536
|
+
"@pezkuwi/types-augment": "16.5.31",
|
|
537
|
+
"@pezkuwi/types-codec": "16.5.31",
|
|
538
|
+
"@pezkuwi/types-create": "16.5.31",
|
|
539
|
+
"@pezkuwi/types-support": "16.5.31",
|
|
540
|
+
"@pezkuwi/util": "14.0.20",
|
|
541
|
+
"@pezkuwi/util-crypto": "14.0.20",
|
|
542
|
+
"@pezkuwi/x-ws": "14.0.20",
|
|
543
543
|
"comment-parser": "^1.4.1",
|
|
544
544
|
"handlebars": "^4.7.8",
|
|
545
545
|
"tslib": "^2.8.1",
|
package/packageInfo.js
CHANGED
|
@@ -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.
|
|
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.31' };
|
package/util/derived.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenericAccountId, GenericCall, GenericLookupSource, GenericVote } from '@pezkuwi/types/generic';
|
|
1
|
+
import { GenericAccountId, GenericCall, GenericLookupSource, GenericMultiAddress, GenericVote } from '@pezkuwi/types/generic';
|
|
2
2
|
import { AllConvictions } from '@pezkuwi/types/interfaces/democracy/definitions';
|
|
3
3
|
import { AbstractInt, bool, Compact, Enum, Null, Option, Struct, Tuple, Vec, WrapperKeepOpaque, WrapperOpaque } from '@pezkuwi/types-codec';
|
|
4
4
|
import { getTypeDef, TypeDefInfo } from '@pezkuwi/types-create';
|
|
@@ -29,6 +29,16 @@ export function getSimilarTypes(registry, definitions, _type, imports) {
|
|
|
29
29
|
else if (type === '()') {
|
|
30
30
|
return ['null'];
|
|
31
31
|
}
|
|
32
|
+
// Handle lookup types by name pattern before class-based checks
|
|
33
|
+
// Lookup types like PezspRuntimeMultiAddress may not be properly registered as children of GenericMultiAddress
|
|
34
|
+
if (type.includes('MultiAddress') || type.endsWith('RuntimeMultiAddress')) {
|
|
35
|
+
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
|
36
|
+
return possibleTypes;
|
|
37
|
+
}
|
|
38
|
+
else if (type.includes('AccountId32') || type.endsWith('CryptoAccountId32')) {
|
|
39
|
+
possibleTypes.push('string', 'Uint8Array');
|
|
40
|
+
return possibleTypes;
|
|
41
|
+
}
|
|
32
42
|
const Clazz = registry.createClass(type);
|
|
33
43
|
if (isChildClass(Vec, Clazz)) {
|
|
34
44
|
const vecDef = getTypeDef(type);
|
|
@@ -53,6 +63,11 @@ export function getSimilarTypes(registry, definitions, _type, imports) {
|
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
}
|
|
66
|
+
else if (isChildClass(GenericMultiAddress, Clazz)) {
|
|
67
|
+
// MultiAddress can accept string addresses, Uint8Array, or various address variants
|
|
68
|
+
// Check before Enum since GenericMultiAddress extends Enum
|
|
69
|
+
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
|
70
|
+
}
|
|
56
71
|
else if (isChildClass(Enum, Clazz)) {
|
|
57
72
|
const { defKeys, isBasic } = new Clazz(registry);
|
|
58
73
|
const keys = defKeys.filter((v) => !v.startsWith('__Unused'));
|
package/util/formatting.js
CHANGED
|
@@ -180,6 +180,11 @@ const formatters = {
|
|
|
180
180
|
[TypeDefInfo.VecFixed]: (registry, typeDef, definitions, imports, withShortcut) => {
|
|
181
181
|
const sub = typeDef.sub;
|
|
182
182
|
if (sub.type === 'u8') {
|
|
183
|
+
// Use lookupName if available (e.g., PezspCoreCryptoAccountId32) instead of generic U8aFixed
|
|
184
|
+
if (typeDef.lookupName) {
|
|
185
|
+
setImports(definitions, imports, [rebrandTypeName(typeDef.lookupName)]);
|
|
186
|
+
return rebrandTypeName(typeDef.lookupName);
|
|
187
|
+
}
|
|
183
188
|
setImports(definitions, imports, ['U8aFixed']);
|
|
184
189
|
return 'U8aFixed';
|
|
185
190
|
}
|