mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-06-13 02:51:01 +00:00
release: v16.5.36 - npm package structure fix
- Published from build/ directories for correct npm structure - Updated common dependencies to 14.0.25 - Added AuthorizeCall signed extension support - All packages now have index.js at root level
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"author": "PezkuwiChain <dev@pezkuwichain.io>",
|
||||
"bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
|
||||
"description": "Type generation scripts",
|
||||
"engines": {
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"type": "module",
|
||||
"types": "./index.d.ts",
|
||||
"version": "16.5.22",
|
||||
"version": "16.5.34",
|
||||
"main": "./cjs/index.js",
|
||||
"module": "./index.js",
|
||||
"bin": {
|
||||
@@ -527,19 +527,19 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@pezkuwi/api": "16.5.22",
|
||||
"@pezkuwi/api-augment": "16.5.22",
|
||||
"@pezkuwi/api-derive": "16.5.22",
|
||||
"@pezkuwi/rpc-augment": "16.5.22",
|
||||
"@pezkuwi/rpc-provider": "16.5.22",
|
||||
"@pezkuwi/types": "16.5.22",
|
||||
"@pezkuwi/types-augment": "16.5.22",
|
||||
"@pezkuwi/types-codec": "16.5.22",
|
||||
"@pezkuwi/types-create": "16.5.22",
|
||||
"@pezkuwi/types-support": "16.5.22",
|
||||
"@pezkuwi/util": "14.0.13",
|
||||
"@pezkuwi/util-crypto": "14.0.13",
|
||||
"@pezkuwi/x-ws": "14.0.13",
|
||||
"@pezkuwi/api": "16.5.34",
|
||||
"@pezkuwi/api-augment": "16.5.34",
|
||||
"@pezkuwi/api-derive": "16.5.34",
|
||||
"@pezkuwi/rpc-augment": "16.5.34",
|
||||
"@pezkuwi/rpc-provider": "16.5.34",
|
||||
"@pezkuwi/types": "16.5.34",
|
||||
"@pezkuwi/types-augment": "16.5.34",
|
||||
"@pezkuwi/types-codec": "16.5.34",
|
||||
"@pezkuwi/types-create": "16.5.34",
|
||||
"@pezkuwi/types-support": "16.5.34",
|
||||
"@pezkuwi/util": "14.0.23",
|
||||
"@pezkuwi/util-crypto": "14.0.23",
|
||||
"@pezkuwi/x-ws": "14.0.23",
|
||||
"comment-parser": "^1.4.1",
|
||||
"handlebars": "^4.7.8",
|
||||
"tslib": "^2.8.1",
|
||||
|
||||
@@ -224,17 +224,53 @@ function generateLookupTypes (registry: Registry, filtered: [PortableType, TypeD
|
||||
),
|
||||
interfaces: []
|
||||
};
|
||||
const items = filtered
|
||||
.map(([, typeDef]) => {
|
||||
// Deep rebrand the type names (including nested sub types) before generating interfaces
|
||||
const rebranded = deepRebrandTypeDef(typeDef);
|
||||
// Special type mappings: PezkuwiChain types that should extend standard types
|
||||
const TYPE_MAPPINGS: Record<string, string> = {
|
||||
PezspCoreCryptoAccountId32: 'AccountId32',
|
||||
PezspRuntimeMultiAddress: 'MultiAddress'
|
||||
};
|
||||
|
||||
return rebranded.lookupNameRoot && rebranded.lookupName
|
||||
? exportInterface(rebranded.lookupIndex, rebranded.lookupName, rebranded.lookupNameRoot)
|
||||
: typeEncoders[rebranded.info](registry, imports.definitions, rebranded, imports);
|
||||
})
|
||||
.filter((t): t is string => !!t)
|
||||
.map((t) => t.replace(/\nexport /, '\n'));
|
||||
// Add imports for AccountId32 and MultiAddress - needed for all lookup files that use TYPE_MAPPINGS
|
||||
const runtimePath = '@pezkuwi/types/interfaces/runtime';
|
||||
if (imports.localTypes[runtimePath]) {
|
||||
imports.localTypes[runtimePath]['AccountId32'] = true;
|
||||
imports.localTypes[runtimePath]['MultiAddress'] = true;
|
||||
}
|
||||
|
||||
// For non-bizinikiwi files, add base type definitions at the start
|
||||
const baseTypeDefs: string[] = [];
|
||||
if (subPath && subPath !== 'bizinikiwi') {
|
||||
// Add PezspCoreCryptoAccountId32 and PezspRuntimeMultiAddress definitions
|
||||
// These extend the standard types and are needed in all lookup files
|
||||
baseTypeDefs.push(
|
||||
' /** @name PezspCoreCryptoAccountId32 (0) */\n interface PezspCoreCryptoAccountId32 extends AccountId32 {}',
|
||||
' /** @name PezspRuntimeMultiAddress (1) */\n interface PezspRuntimeMultiAddress extends MultiAddress {}'
|
||||
);
|
||||
}
|
||||
|
||||
const items = [
|
||||
...baseTypeDefs,
|
||||
...filtered
|
||||
.map(([, typeDef]) => {
|
||||
// Deep rebrand the type names (including nested sub types) before generating interfaces
|
||||
const rebranded = deepRebrandTypeDef(typeDef);
|
||||
|
||||
// Check for special type mappings first - skip if already in base types for this file
|
||||
if (rebranded.lookupName && TYPE_MAPPINGS[rebranded.lookupName]) {
|
||||
// For bizinikiwi, include the mapping; for others, skip (already in baseTypeDefs)
|
||||
if (subPath === 'bizinikiwi') {
|
||||
return exportInterface(rebranded.lookupIndex, rebranded.lookupName, TYPE_MAPPINGS[rebranded.lookupName]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return rebranded.lookupNameRoot && rebranded.lookupName
|
||||
? exportInterface(rebranded.lookupIndex, rebranded.lookupName, rebranded.lookupNameRoot)
|
||||
: typeEncoders[rebranded.info](registry, imports.definitions, rebranded, imports);
|
||||
})
|
||||
.filter((t): t is string => !!t)
|
||||
.map((t) => t.replace(/\nexport /, '\n'))
|
||||
];
|
||||
|
||||
writeFile(path.join(destDir, `types${subPath ? `-${subPath}` : ''}.ts`), () => generateLookupTypesTmpl({
|
||||
headerType: 'defs',
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @pezkuwi/dev
|
||||
|
||||
export const packageInfo = { name: '@pezkuwi/typegen', path: 'auto', type: 'auto', version: '16.5.18' };
|
||||
export const packageInfo = { name: '@pezkuwi/typegen', path: 'auto', type: 'auto', version: '16.5.34' };
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { UInt } from '@pezkuwi/types-codec';
|
||||
import type { TypeDef } from '@pezkuwi/types-create/types';
|
||||
import type { ModuleTypes, TypeImports } from './imports.js';
|
||||
|
||||
import { GenericAccountId, GenericCall, GenericLookupSource, GenericVote } from '@pezkuwi/types/generic';
|
||||
import { GenericAccountId, GenericCall, GenericLookupSource, GenericMultiAddress, GenericVote } from '@pezkuwi/types/generic';
|
||||
import { AllConvictions } from '@pezkuwi/types/interfaces/democracy/definitions';
|
||||
import { AbstractInt, bool, Compact, Enum, Null, Option, Struct, Tuple, Vec, WrapperKeepOpaque, WrapperOpaque } from '@pezkuwi/types-codec';
|
||||
import { getTypeDef, TypeDefInfo } from '@pezkuwi/types-create';
|
||||
@@ -44,6 +44,18 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
||||
return ['null'];
|
||||
}
|
||||
|
||||
// Handle lookup types by name pattern before class-based checks
|
||||
// Lookup types like PezspRuntimeMultiAddress may not be properly registered as children of GenericMultiAddress
|
||||
if (type.includes('MultiAddress') || type.endsWith('RuntimeMultiAddress')) {
|
||||
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
||||
|
||||
return possibleTypes;
|
||||
} else if (type.includes('AccountId32') || type.endsWith('CryptoAccountId32')) {
|
||||
possibleTypes.push('string', 'Uint8Array');
|
||||
|
||||
return possibleTypes;
|
||||
}
|
||||
|
||||
const Clazz = registry.createClass(type);
|
||||
|
||||
if (isChildClass(Vec, Clazz)) {
|
||||
@@ -68,6 +80,10 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
||||
throw new Error(`Unhandled subtype in Vec, ${stringify(subDef)}`);
|
||||
}
|
||||
}
|
||||
} else if (isChildClass(GenericMultiAddress, Clazz)) {
|
||||
// MultiAddress can accept string addresses, Uint8Array, or various address variants
|
||||
// Check before Enum since GenericMultiAddress extends Enum
|
||||
possibleTypes.push('AccountId', 'AccountIndex', 'Address', 'LookupSource', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(Enum, Clazz)) {
|
||||
const { defKeys, isBasic } = new (Clazz as CodecClass)(registry) as Enum;
|
||||
const keys = defKeys.filter((v) => !v.startsWith('__Unused'));
|
||||
|
||||
@@ -257,6 +257,12 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
if (sub.type === 'u8') {
|
||||
// Use lookupName if available (e.g., PezspCoreCryptoAccountId32) instead of generic U8aFixed
|
||||
if (typeDef.lookupName) {
|
||||
setImports(definitions, imports, [rebrandTypeName(typeDef.lookupName)]);
|
||||
|
||||
return rebrandTypeName(typeDef.lookupName);
|
||||
}
|
||||
setImports(definitions, imports, ['U8aFixed']);
|
||||
|
||||
return 'U8aFixed';
|
||||
|
||||
Reference in New Issue
Block a user