mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-04-24 23:57:56 +00:00
chore: update to version 16.5.9, align with pezkuwichain brand and fix tests
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { Definitions } from '@pezkuwi/types/types';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateDefaultConsts(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean, customLookupDefinitions?: Definitions): void;
|
||||
@@ -0,0 +1,87 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
|
||||
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||
import { stringCamelCase } from '@pezkuwi/util';
|
||||
import { compareName, createImports, formatType, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
|
||||
import { ignoreUnusedLookups } from './lookup.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('consts'));
|
||||
/** @internal */
|
||||
function generateForMeta(meta, dest, extraTypes, isStrict, customLookupDefinitions) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = {
|
||||
'@pezkuwi/types-augment': {
|
||||
lookup: {
|
||||
...lookupDefinitions,
|
||||
...customLookupDefinitions
|
||||
}
|
||||
},
|
||||
'@pezkuwi/types/interfaces': defaultDefs,
|
||||
...extraTypes
|
||||
};
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const { lookup, pallets, registry } = meta.asLatest;
|
||||
const usedTypes = new Set([]);
|
||||
const modules = pallets
|
||||
.filter(({ constants }) => constants.length > 0)
|
||||
.map(({ constants, name }) => {
|
||||
if (!isStrict) {
|
||||
setImports(allDefs, imports, ['Codec']);
|
||||
}
|
||||
const items = constants
|
||||
.map(({ deprecationInfo, docs, name, type }) => {
|
||||
const typeDef = lookup.getTypeDef(type);
|
||||
const returnType = rebrandTypeName(typeDef.lookupName || '') || formatType(registry, allDefs, typeDef, imports);
|
||||
if (!deprecationInfo.isNotDeprecated) {
|
||||
const deprecationNotice = getDeprecationNotice(deprecationInfo, stringCamelCase(name), 'Constant');
|
||||
const items = docs.length
|
||||
? ['', deprecationNotice]
|
||||
: [deprecationNotice];
|
||||
docs.push(...items.map((text) => registry.createType('Text', text)));
|
||||
}
|
||||
// Add the type to the list of used types
|
||||
if (!(imports.primitiveTypes[returnType])) {
|
||||
usedTypes.add(returnType);
|
||||
}
|
||||
setImports(allDefs, imports, [returnType]);
|
||||
return {
|
||||
docs,
|
||||
name: stringCamelCase(name),
|
||||
type: returnType
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
// filter out the unused lookup types from imports
|
||||
ignoreUnusedLookups([...usedTypes], imports);
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedConst']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultConsts(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
|
||||
const { metadata } = initMeta(data, extraTypes);
|
||||
return generateForMeta(metadata, dest, extraTypes, isStrict, customLookupDefinitions);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateDefaultErrors(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean): void;
|
||||
@@ -0,0 +1,55 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import { stringCamelCase } from '@pezkuwi/util';
|
||||
import { compareName, createImports, initMeta, readTemplate, writeFile } from '../util/index.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('errors'));
|
||||
/** @internal */
|
||||
function generateForMeta(meta, dest, isStrict) {
|
||||
writeFile(dest, () => {
|
||||
const imports = createImports({});
|
||||
const { lookup, pallets } = meta.asLatest;
|
||||
const modules = pallets
|
||||
.filter(({ errors }) => errors.isSome)
|
||||
.map((data) => {
|
||||
const name = data.name;
|
||||
const errors = data.errors.unwrap();
|
||||
const deprecationInfo = errors.deprecationInfo.toJSON();
|
||||
return {
|
||||
items: lookup.getSiType(errors.type).def.asVariant.variants
|
||||
.map(({ docs, index, name }) => {
|
||||
const rawStatus = deprecationInfo?.[index.toNumber()];
|
||||
if (rawStatus) {
|
||||
const deprecationVariantInfo = meta.registry.createTypeUnsafe('VariantDeprecationInfoV16', [rawStatus]);
|
||||
const deprecationNotice = getDeprecationNotice(deprecationVariantInfo, name.toString());
|
||||
const notice = docs.length ? ['', deprecationNotice] : [deprecationNotice];
|
||||
docs.push(...notice.map((text) => meta.registry.createType('Text', text)));
|
||||
}
|
||||
return {
|
||||
docs,
|
||||
name: name.toString()
|
||||
};
|
||||
})
|
||||
.sort(compareName),
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedError']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultErrors(dest, data, extraTypes = {}, isStrict = false) {
|
||||
const { metadata } = initMeta(data, extraTypes);
|
||||
return generateForMeta(metadata, dest, isStrict);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { Definitions } from '@pezkuwi/types/types';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateDefaultEvents(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean, customLookupDefinitions?: Definitions): void;
|
||||
@@ -0,0 +1,135 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
|
||||
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||
import { stringCamelCase } from '@pezkuwi/util';
|
||||
import { compareName, createImports, formatType, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
|
||||
import { ignoreUnusedLookups } from './lookup.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('events'));
|
||||
const ALIAS = [
|
||||
'symbol',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'debugger',
|
||||
'default',
|
||||
'delete',
|
||||
'do',
|
||||
'else',
|
||||
'export',
|
||||
'extends',
|
||||
'false',
|
||||
'finally',
|
||||
'for',
|
||||
'function',
|
||||
'if',
|
||||
'import',
|
||||
'in',
|
||||
'instanceof',
|
||||
'new',
|
||||
'null',
|
||||
'return',
|
||||
'static',
|
||||
'super',
|
||||
'switch',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typeof',
|
||||
'var',
|
||||
'void',
|
||||
'while',
|
||||
'with',
|
||||
'yield'
|
||||
];
|
||||
/** @internal */
|
||||
function generateForMeta(meta, dest, extraTypes, isStrict, customLookupDefinitions) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = {
|
||||
'@pezkuwi/types-augment': {
|
||||
lookup: {
|
||||
...lookupDefinitions,
|
||||
...customLookupDefinitions
|
||||
}
|
||||
},
|
||||
'@pezkuwi/types/interfaces': defaultDefs,
|
||||
...extraTypes
|
||||
};
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const { lookup, pallets, registry } = meta.asLatest;
|
||||
const usedTypes = new Set([]);
|
||||
const modules = pallets
|
||||
.filter(({ events }) => events.isSome)
|
||||
.map((data) => {
|
||||
const name = data.name;
|
||||
const events = data.events.unwrap();
|
||||
const deprecationInfo = events.deprecationInfo.toJSON();
|
||||
return {
|
||||
items: lookup.getSiType(events.type).def.asVariant.variants
|
||||
.map(({ docs, fields, index, name }) => {
|
||||
const rawStatus = deprecationInfo?.[index.toNumber()];
|
||||
if (rawStatus) {
|
||||
const deprecationVariantInfo = meta.registry.createTypeUnsafe('VariantDeprecationInfoV16', [rawStatus]);
|
||||
const deprecationNotice = getDeprecationNotice(deprecationVariantInfo, name.toString());
|
||||
const notice = docs.length ? ['', deprecationNotice] : [deprecationNotice];
|
||||
docs.push(...notice.map((text) => meta.registry.createType('Text', text)));
|
||||
}
|
||||
const args = fields
|
||||
.map(({ type }) => lookup.getTypeDef(type))
|
||||
.map((typeDef) => {
|
||||
const arg = rebrandTypeName(typeDef.lookupName || '') || formatType(registry, allDefs, typeDef, imports);
|
||||
// Add the type to the list of used types
|
||||
if (!(imports.primitiveTypes[arg])) {
|
||||
usedTypes.add(arg);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
const names = fields
|
||||
.map(({ name }) => registry.lookup.sanitizeField(name)[0])
|
||||
.filter((n) => !!n);
|
||||
setImports(allDefs, imports, args);
|
||||
return {
|
||||
docs,
|
||||
name: name.toString(),
|
||||
type: names.length !== 0 && names.length === args.length
|
||||
? `[${names.map((n, i) => `${ALIAS.includes(n) ? `${n}_` : n}: ${args[i]}`).join(', ')}], { ${names.map((n, i) => `${n}: ${args[i]}`).join(', ')} }`
|
||||
: `[${args.join(', ')}]`
|
||||
};
|
||||
})
|
||||
.sort(compareName),
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
// filter out the unused lookup types from imports
|
||||
ignoreUnusedLookups([...usedTypes], imports);
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedEvent']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultEvents(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
|
||||
const { metadata } = initMeta(data, extraTypes);
|
||||
return generateForMeta(metadata, dest, extraTypes, isStrict, customLookupDefinitions);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { ModuleTypes } from '../util/imports.js';
|
||||
/** @internal */
|
||||
export declare function generateInterfaceTypes(importDefinitions: Record<string, Record<string, ModuleTypes>>, dest: string): void;
|
||||
export declare function generateDefaultInterface(): void;
|
||||
@@ -0,0 +1,59 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import { Json, Raw } from '@pezkuwi/types/codec';
|
||||
import { TypeRegistry } from '@pezkuwi/types/create';
|
||||
import * as defaultDefinitions from '@pezkuwi/types/interfaces/definitions';
|
||||
import * as defaultPrimitives from '@pezkuwi/types/primitive';
|
||||
import { createImports, readTemplate, setImports, writeFile } from '../util/index.js';
|
||||
const primitiveClasses = {
|
||||
...defaultPrimitives,
|
||||
Json,
|
||||
Raw
|
||||
};
|
||||
const generateInterfaceTypesTemplate = Handlebars.compile(readTemplate('interfaceRegistry'));
|
||||
/** @internal */
|
||||
export function generateInterfaceTypes(importDefinitions, dest) {
|
||||
const registry = new TypeRegistry();
|
||||
writeFile(dest, () => {
|
||||
Object.entries(importDefinitions).reduce((acc, def) => Object.assign(acc, def), {});
|
||||
const imports = createImports(importDefinitions);
|
||||
const definitions = imports.definitions;
|
||||
const items = [];
|
||||
// first we create imports for our known classes from the API
|
||||
Object
|
||||
.keys(primitiveClasses)
|
||||
.filter((name) => !name.includes('Generic'))
|
||||
.forEach((primitiveName) => {
|
||||
setImports(definitions, imports, [primitiveName]);
|
||||
items.push(primitiveName);
|
||||
});
|
||||
const existingTypes = {};
|
||||
// ensure we have everything registered since we will get the definition
|
||||
// form the available types (so any unknown should show after this)
|
||||
Object.values(definitions).forEach(({ types }) => {
|
||||
registry.register(types);
|
||||
});
|
||||
// create imports for everything that we have available
|
||||
Object.values(definitions).forEach(({ types }) => {
|
||||
setImports(definitions, imports, Object.keys(types));
|
||||
const uniqueTypes = Object.keys(types).filter((type) => !existingTypes[type]);
|
||||
uniqueTypes.forEach((type) => {
|
||||
existingTypes[type] = true;
|
||||
items.push(type);
|
||||
});
|
||||
});
|
||||
return generateInterfaceTypesTemplate({
|
||||
headerType: 'defs',
|
||||
imports,
|
||||
items: items.sort((a, b) => a.localeCompare(b)),
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
export function generateDefaultInterface() {
|
||||
generateInterfaceTypes({ '@pezkuwi/types/interfaces': defaultDefinitions }, 'packages/types-augment/src/registry/interfaces.ts');
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type TypeImports } from '../util/index.js';
|
||||
export declare function generateDefaultLookup(destDir?: string, staticData?: HexString): void;
|
||||
export declare function ignoreUnusedLookups(usedTypes: string[], imports: TypeImports): void;
|
||||
@@ -0,0 +1,235 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import path from 'node:path';
|
||||
import * as defaultDefinitions from '@pezkuwi/types/interfaces/definitions';
|
||||
import staticAhDicle from '@pezkuwi/types-support/metadata/v15/asset-hub-dicle-hex';
|
||||
import staticAhPezkuwi from '@pezkuwi/types-support/metadata/v15/asset-hub-pezkuwi-hex';
|
||||
import staticBizinikiwi from '@pezkuwi/types-support/metadata/v15/bizinikiwi-hex';
|
||||
import staticDicle from '@pezkuwi/types-support/metadata/v15/dicle-hex';
|
||||
import staticPezkuwi from '@pezkuwi/types-support/metadata/v15/pezkuwi-hex';
|
||||
import { isString, stringify } from '@pezkuwi/util';
|
||||
import { createImports, exportInterface, initMeta, readTemplate, rebrandTypeName, writeFile } from '../util/index.js';
|
||||
import { typeEncoders } from './tsDef.js';
|
||||
function deepRebrandTypeDef(typeDef, isTopLevel = true) {
|
||||
const rebrandedLookupName = typeDef.lookupName ? rebrandTypeName(typeDef.lookupName) : typeDef.lookupName;
|
||||
const rebranded = {
|
||||
...typeDef,
|
||||
type: rebrandTypeName(typeDef.type),
|
||||
// For top-level types: set name from lookupName (mimics original: typeDef.name = typeDef.lookupName)
|
||||
// For sub types (enum variants, struct fields): preserve the original name (field/variant name)
|
||||
name: isTopLevel ? (rebrandedLookupName || typeDef.name) : typeDef.name,
|
||||
lookupName: rebrandedLookupName,
|
||||
lookupNameRoot: typeDef.lookupNameRoot ? rebrandTypeName(typeDef.lookupNameRoot) : typeDef.lookupNameRoot
|
||||
};
|
||||
// Recursively rebrand sub types (mark as not top-level)
|
||||
if (typeDef.sub) {
|
||||
if (Array.isArray(typeDef.sub)) {
|
||||
rebranded.sub = typeDef.sub.map((s) => deepRebrandTypeDef(s, false));
|
||||
}
|
||||
else {
|
||||
rebranded.sub = deepRebrandTypeDef(typeDef.sub, false);
|
||||
}
|
||||
}
|
||||
return rebranded;
|
||||
}
|
||||
const WITH_TYPEDEF = false;
|
||||
const generateLookupDefsTmpl = Handlebars.compile(readTemplate('lookup/defs'));
|
||||
const generateLookupDefsNamedTmpl = Handlebars.compile(readTemplate('lookup/defs-named'));
|
||||
const generateLookupIndexTmpl = Handlebars.compile(readTemplate('lookup/index'));
|
||||
const generateLookupTypesTmpl = Handlebars.compile(readTemplate('lookup/types'));
|
||||
const generateRegistryTmpl = Handlebars.compile(readTemplate('interfaceRegistry'));
|
||||
function generateParamType(registry, { name, type }) {
|
||||
if (type.isSome) {
|
||||
const link = registry.lookup.types[type.unwrap().toNumber()];
|
||||
if (link.type.path.length) {
|
||||
return generateTypeDocs(registry, null, link.type.path, link.type.params);
|
||||
}
|
||||
}
|
||||
return name.toString();
|
||||
}
|
||||
function generateTypeDocs(registry, id, path, params) {
|
||||
return `${id ? `${registry.createLookupType(id)}${path.length ? ': ' : ''}` : ''}${path.map((p) => p.toString()).join('::')}${params.length ? `<${params.map((p) => generateParamType(registry, p)).join(', ')}>` : ''}`;
|
||||
}
|
||||
function formatObject(lines) {
|
||||
const max = lines.length - 1;
|
||||
return [
|
||||
'{',
|
||||
...lines.map((l, index) => (l.endsWith(',') || l.endsWith('{') || index === max || lines[index + 1].endsWith('}') || lines[index + 1].endsWith('}'))
|
||||
? l
|
||||
: `${l},`),
|
||||
'}'
|
||||
];
|
||||
}
|
||||
function expandSet(parsed) {
|
||||
return formatObject(Object.entries(parsed).reduce((all, [k, v]) => {
|
||||
all.push(`${k}: ${v}`);
|
||||
return all;
|
||||
}, []));
|
||||
}
|
||||
function expandObject(parsed) {
|
||||
if (parsed._set) {
|
||||
return expandSet(parsed._set);
|
||||
}
|
||||
return formatObject(Object.entries(parsed).reduce((all, [k, v]) => {
|
||||
const inner = isString(v)
|
||||
? expandType(v)
|
||||
: Array.isArray(v)
|
||||
? [`[${v.map((e) => `'${e}'`).join(', ')}]`]
|
||||
: expandObject(v);
|
||||
inner.forEach((l, index) => {
|
||||
all.push(`${index === 0
|
||||
? `${k}: ${l}`
|
||||
: `${l}`}`);
|
||||
});
|
||||
return all;
|
||||
}, []));
|
||||
}
|
||||
function expandType(encoded) {
|
||||
if (!encoded.startsWith('{')) {
|
||||
return [`'${rebrandTypeName(encoded)}'`];
|
||||
}
|
||||
return expandObject(JSON.parse(encoded));
|
||||
}
|
||||
function expandDefToString({ lookupNameRoot, type }, indent) {
|
||||
if (lookupNameRoot) {
|
||||
return `'${rebrandTypeName(lookupNameRoot)}'`;
|
||||
}
|
||||
const lines = expandType(type);
|
||||
let inc = 0;
|
||||
return lines.map((l, index) => {
|
||||
let r;
|
||||
if (l.endsWith('{')) {
|
||||
r = index === 0
|
||||
? l
|
||||
: `${' '.padStart(indent + inc)}${l}`;
|
||||
inc += 2;
|
||||
}
|
||||
else {
|
||||
if (l.endsWith('},') || l.endsWith('}')) {
|
||||
inc -= 2;
|
||||
}
|
||||
r = index === 0
|
||||
? l
|
||||
: `${' '.padStart(indent + inc)}${l}`;
|
||||
}
|
||||
return r;
|
||||
}).join('\n');
|
||||
}
|
||||
function getFilteredTypes(lookup, exclude = []) {
|
||||
const named = lookup.types.filter(({ id }) => !!lookup.getTypeDef(id).lookupName);
|
||||
const names = named.map(({ id }) => lookup.getName(id));
|
||||
return named
|
||||
.filter((_, index) => !names.some((n, iindex) => index > iindex &&
|
||||
n === names[index]))
|
||||
.map((p) => [p, lookup.getTypeDef(p.id)])
|
||||
.filter(([, typeDef]) => !exclude.includes(typeDef.lookupName || '<invalid>'));
|
||||
}
|
||||
function generateLookupDefs(registry, filtered, destDir, subPath) {
|
||||
writeFile(path.join(destDir, `${subPath || 'definitions'}.ts`), () => {
|
||||
const all = filtered.map(([{ id, type: { params, path } }, typeDef]) => {
|
||||
const typeLookup = registry.createLookupType(id);
|
||||
const def = expandDefToString(typeDef, subPath ? 2 : 4);
|
||||
return {
|
||||
docs: [
|
||||
generateTypeDocs(registry, id, path, params),
|
||||
WITH_TYPEDEF
|
||||
? `@typeDef ${stringify(typeDef)}`
|
||||
: null
|
||||
].filter((d) => !!d),
|
||||
type: { def, typeLookup, typeName: typeDef.lookupName ? rebrandTypeName(typeDef.lookupName) : undefined }
|
||||
};
|
||||
});
|
||||
const max = all.length - 1;
|
||||
return (subPath ? generateLookupDefsNamedTmpl : generateLookupDefsTmpl)({
|
||||
defs: all.map(({ docs, type }, i) => {
|
||||
const { def, typeLookup, typeName } = type;
|
||||
return {
|
||||
defs: [
|
||||
[typeName || typeLookup, `${def}${i !== max ? ',' : ''}`]
|
||||
].map(([n, t]) => `${n}: ${t}`),
|
||||
docs
|
||||
};
|
||||
}),
|
||||
headerType: 'defs'
|
||||
});
|
||||
});
|
||||
}
|
||||
function generateLookupTypes(registry, filtered, destDir, subPath) {
|
||||
const imports = {
|
||||
...createImports({ '@pezkuwi/types/interfaces': defaultDefinitions }, { types: {} }),
|
||||
interfaces: []
|
||||
};
|
||||
const items = filtered
|
||||
.map(([, typeDef]) => {
|
||||
// Deep rebrand the type names (including nested sub types) before generating interfaces
|
||||
const rebranded = deepRebrandTypeDef(typeDef);
|
||||
return rebranded.lookupNameRoot && rebranded.lookupName
|
||||
? exportInterface(rebranded.lookupIndex, rebranded.lookupName, rebranded.lookupNameRoot)
|
||||
: typeEncoders[rebranded.info](registry, imports.definitions, rebranded, imports);
|
||||
})
|
||||
.filter((t) => !!t)
|
||||
.map((t) => t.replace(/\nexport /, '\n'));
|
||||
writeFile(path.join(destDir, `types${subPath ? `-${subPath}` : ''}.ts`), () => generateLookupTypesTmpl({
|
||||
headerType: 'defs',
|
||||
imports,
|
||||
items: items.map((l) => l
|
||||
.split('\n')
|
||||
.map((l) => l.length ? ` ${l}` : '')
|
||||
.join('\n')),
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
]
|
||||
}), true);
|
||||
writeFile(path.join(destDir, 'index.ts'), () => generateLookupIndexTmpl({ headerType: 'defs' }), true);
|
||||
}
|
||||
function generateRegistry(_registry, filtered, destDir, subPath) {
|
||||
writeFile(path.join(destDir, `${subPath}.ts`), () => {
|
||||
const items = filtered
|
||||
.map(([, { lookupName }]) => lookupName ? rebrandTypeName(lookupName) : lookupName)
|
||||
.filter((n) => !!n)
|
||||
.sort()
|
||||
.reduce((all, n) => all.includes(n) ? all : all.concat(n), []);
|
||||
const imports = createImports({}, { types: {} });
|
||||
imports.lookupTypes = items.reduce((all, n) => ({ ...all, [n]: true }), {});
|
||||
return generateRegistryTmpl({
|
||||
headerType: 'defs',
|
||||
imports,
|
||||
items,
|
||||
types: []
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
function generateLookup(destDir, entries) {
|
||||
entries.reduce((exclude, [subPath, staticMeta]) => {
|
||||
const { lookup, registry } = initMeta(staticMeta).metadata.asLatest;
|
||||
const filtered = getFilteredTypes(lookup, exclude);
|
||||
generateLookupDefs(registry, filtered, destDir, subPath);
|
||||
generateLookupTypes(registry, filtered, destDir, subPath);
|
||||
generateRegistry(registry, filtered, destDir, subPath === 'lookup' ? 'registry' : `../registry/${subPath}`);
|
||||
return exclude.concat(...filtered
|
||||
.map(([, typeDef]) => typeDef.lookupName)
|
||||
.filter((n) => !!n));
|
||||
}, []);
|
||||
}
|
||||
export function generateDefaultLookup(destDir = 'packages/types-augment/src/lookup', staticData) {
|
||||
generateLookup(destDir, staticData
|
||||
? [['lookup', staticData]]
|
||||
: [
|
||||
['bizinikiwi', staticBizinikiwi],
|
||||
['pezkuwi', staticPezkuwi],
|
||||
['dicle', staticDicle],
|
||||
['assetHubPezkuwi', staticAhPezkuwi],
|
||||
['assetHubDicle', staticAhDicle]
|
||||
]);
|
||||
}
|
||||
export function ignoreUnusedLookups(usedTypes, imports) {
|
||||
const usedStringified = usedTypes.toString();
|
||||
const [lookupKey, typeDefinitions] = Object.entries(imports.localTypes).find(([typeModule, _]) => typeModule.includes('/lookup')) || ['', {}];
|
||||
Object.keys(typeDefinitions).forEach((typeDef) => {
|
||||
if (!(usedStringified.includes(typeDef))) {
|
||||
delete (imports.localTypes[lookupKey])[typeDef];
|
||||
}
|
||||
});
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import type { Definitions } from '@pezkuwi/types/types';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateDefaultQuery(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean, customLookupDefinitions?: Definitions): void;
|
||||
@@ -0,0 +1,136 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
|
||||
import { unwrapStorageSi } from '@pezkuwi/types/util';
|
||||
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||
import { stringCamelCase } from '@pezkuwi/util';
|
||||
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
|
||||
import { ignoreUnusedLookups } from './lookup.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('query'));
|
||||
/** @internal */
|
||||
function entrySignature(lookup, allDefs, registry, section, storageEntry, imports) {
|
||||
try {
|
||||
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
|
||||
if (storageEntry.type.isPlain) {
|
||||
const typeDef = lookup.getTypeDef(storageEntry.type.asPlain);
|
||||
setImports(allDefs, imports, [
|
||||
rebrandTypeName(typeDef.lookupName || typeDef.type),
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null
|
||||
]);
|
||||
return [storageEntry.modifier.isOptional, '', '', formatType(registry, allDefs, outputType, imports)];
|
||||
}
|
||||
else if (storageEntry.type.isMap) {
|
||||
const { hashers, key, value } = storageEntry.type.asMap;
|
||||
const keyDefs = hashers.length === 1
|
||||
? [lookup.getTypeDef(key)]
|
||||
: lookup.getSiType(key).def.asTuple.map((k) => lookup.getTypeDef(k));
|
||||
const similarTypes = keyDefs.map((k) => getSimilarTypes(registry, allDefs, k.lookupName || k.type, imports));
|
||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||
const defValue = lookup.getTypeDef(value);
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes.reduce((all, t) => all.concat(t), []),
|
||||
storageEntry.modifier.isOptional
|
||||
? 'Option'
|
||||
: null,
|
||||
rebrandTypeName(defValue.lookupName || defValue.type)
|
||||
]);
|
||||
return [
|
||||
storageEntry.modifier.isOptional,
|
||||
keyDefs.map((k) => formatType(registry, allDefs, k.lookupName || k.type, imports)).join(', '),
|
||||
keyTypes.map((t, i) => `arg${keyTypes.length === 1 ? '' : (i + 1)}: ${t}`).join(', '),
|
||||
rebrandTypeName(outputType.lookupName || '') || formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
}
|
||||
throw new Error(`Expected Plain or Map type, found ${storageEntry.type.type}`);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`entrySignature: Cannot create signature for query ${section}.${storageEntry.name.toString()}:: ${error.message}`);
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
function generateForMeta(registry, meta, dest, extraTypes, isStrict, customLookupDefinitions) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = {
|
||||
'@pezkuwi/types-augment': {
|
||||
lookup: {
|
||||
...lookupDefinitions,
|
||||
...customLookupDefinitions
|
||||
}
|
||||
},
|
||||
'@pezkuwi/types/interfaces': defaultDefs,
|
||||
...extraTypes
|
||||
};
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const { lookup, pallets } = meta.asLatest;
|
||||
const usedTypes = new Set([]);
|
||||
const modules = pallets
|
||||
.filter(({ storage }) => storage.isSome)
|
||||
.map(({ name, storage }) => {
|
||||
const items = storage.unwrap().items
|
||||
.map((storageEntry) => {
|
||||
const { deprecationInfo, docs, name } = storageEntry;
|
||||
const [isOptional, args, params, _returnType] = entrySignature(lookup, allDefs, registry, name.toString(), storageEntry, imports);
|
||||
if (!deprecationInfo.isNotDeprecated) {
|
||||
const deprecationNotice = getDeprecationNotice(deprecationInfo, stringCamelCase(name));
|
||||
const items = docs.length
|
||||
? ['', deprecationNotice]
|
||||
: [deprecationNotice];
|
||||
docs.push(...items.map((text) => registry.createType('Text', text)));
|
||||
}
|
||||
// Add the type and args to the list of used types
|
||||
if (!(imports.primitiveTypes[_returnType])) {
|
||||
usedTypes.add(_returnType);
|
||||
}
|
||||
if (!(imports.primitiveTypes[args])) {
|
||||
usedTypes.add(args);
|
||||
}
|
||||
const returnType = isOptional
|
||||
? `Option<${_returnType}>`
|
||||
: _returnType;
|
||||
return {
|
||||
args,
|
||||
docs,
|
||||
entryType: 'AugmentedQuery',
|
||||
name: stringCamelCase(storageEntry.name),
|
||||
params,
|
||||
returnType
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
imports.typesTypes['Observable'] = true;
|
||||
// filter out the unused lookup types from imports
|
||||
ignoreUnusedLookups([...usedTypes], imports);
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedQuery', 'QueryableStorageEntry']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultQuery(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
|
||||
const { metadata, registry } = initMeta(data, extraTypes);
|
||||
return generateForMeta(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions);
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import type { TypeRegistry } from '@pezkuwi/types/create';
|
||||
import type { Definitions } from '@pezkuwi/types/types';
|
||||
import type { ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateRpcTypes(registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: ExtraTypes): void;
|
||||
export declare function generateDefaultRpc(dest?: string, extraTypes?: ExtraTypes): void;
|
||||
@@ -0,0 +1,110 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefinitions from '@pezkuwi/types/interfaces/definitions';
|
||||
import staticBizinikiwi from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
||||
import { createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util/index.js';
|
||||
const StorageKeyType = 'StorageKey | string | Uint8Array | any';
|
||||
const generateRpcTypesTemplate = Handlebars.compile(readTemplate('rpc'));
|
||||
/** @internal */
|
||||
export function generateRpcTypes(registry, importDefinitions, dest, extraTypes) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = { '@pezkuwi/types/interfaces': importDefinitions, ...extraTypes };
|
||||
const imports = createImports(allTypes);
|
||||
const definitions = imports.definitions;
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const rpcKeys = Object
|
||||
.keys(definitions)
|
||||
.filter((key) => Object.keys(definitions[key].rpc || {}).length !== 0)
|
||||
.sort();
|
||||
const additional = {};
|
||||
const modules = rpcKeys.map((sectionFullName) => {
|
||||
const rpc = definitions[sectionFullName].rpc || {};
|
||||
const section = sectionFullName.split('/').pop();
|
||||
const allMethods = Object.keys(rpc).sort().map((methodName) => {
|
||||
const def = rpc[methodName];
|
||||
let args;
|
||||
let type;
|
||||
let generic;
|
||||
// These are too hard to type with generics, do manual overrides
|
||||
if (section === 'state') {
|
||||
setImports(allDefs, imports, ['Codec', 'Hash', 'StorageKey', 'Vec']);
|
||||
if (methodName === 'getStorage') {
|
||||
generic = 'T = Codec';
|
||||
args = [`key: ${StorageKeyType}, block?: Hash | Uint8Array | string`];
|
||||
type = 'T';
|
||||
}
|
||||
else if (methodName === 'queryStorage') {
|
||||
generic = 'T = Codec[]';
|
||||
args = [`keys: Vec<StorageKey> | (${StorageKeyType})[], fromBlock?: Hash | Uint8Array | string, toBlock?: Hash | Uint8Array | string`];
|
||||
type = '[Hash, T][]';
|
||||
}
|
||||
else if (methodName === 'queryStorageAt') {
|
||||
generic = 'T = Codec[]';
|
||||
args = [`keys: Vec<StorageKey> | (${StorageKeyType})[], at?: Hash | Uint8Array | string`];
|
||||
type = 'T';
|
||||
}
|
||||
else if (methodName === 'subscribeStorage') {
|
||||
generic = 'T = Codec[]';
|
||||
args = [`keys?: Vec<StorageKey> | (${StorageKeyType})[]`];
|
||||
type = 'T';
|
||||
}
|
||||
}
|
||||
if (args === undefined) {
|
||||
setImports(allDefs, imports, [def.type]);
|
||||
args = def.params.map((param) => {
|
||||
const similarTypes = getSimilarTypes(registry, definitions, param.type, imports);
|
||||
setImports(allDefs, imports, [param.type, ...similarTypes]);
|
||||
return `${param.name}${param.isOptional ? '?' : ''}: ${similarTypes.join(' | ')}`;
|
||||
});
|
||||
type = formatType(registry, allDefs, def.type, imports);
|
||||
generic = '';
|
||||
}
|
||||
const item = {
|
||||
args: args.join(', '),
|
||||
docs: def.deprecated
|
||||
? [`@deprecated ${def.deprecated}`, def.description]
|
||||
: [def.description],
|
||||
generic,
|
||||
name: methodName,
|
||||
type
|
||||
};
|
||||
if (def.aliasSection) {
|
||||
if (!additional[def.aliasSection]) {
|
||||
additional[def.aliasSection] = {
|
||||
items: [],
|
||||
name: def.aliasSection
|
||||
};
|
||||
}
|
||||
additional[def.aliasSection].items.push(item);
|
||||
return null;
|
||||
}
|
||||
return item;
|
||||
}).filter((item) => !!item);
|
||||
return {
|
||||
items: allMethods,
|
||||
name: section || 'unknown'
|
||||
};
|
||||
}).concat(...Object.values(additional)).sort((a, b) => a.name.localeCompare(b.name));
|
||||
imports.typesTypes['Observable'] = true;
|
||||
return generateRpcTypesTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/rpc-core/types',
|
||||
types: ['AugmentedRpc']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
export function generateDefaultRpc(dest = 'packages/rpc-augment/src/augment/jsonrpc.ts', extraTypes = {}) {
|
||||
const { registry } = initMeta(staticBizinikiwi, extraTypes);
|
||||
generateRpcTypes(registry, defaultDefinitions, dest, extraTypes);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { Metadata } from '@pezkuwi/types/metadata/Metadata';
|
||||
import type { Definitions, Registry } from '@pezkuwi/types/types';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateCallTypes(registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void;
|
||||
export declare function generateDefaultRuntime(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean, customLookupDefinitions?: Definitions): void;
|
||||
@@ -0,0 +1,228 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
|
||||
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||
import { objectSpread, stringCamelCase } from '@pezkuwi/util';
|
||||
import { blake2AsHex } from '@pezkuwi/util-crypto';
|
||||
import { createImports, formatType, getSimilarTypes, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const generateCallsTypesTemplate = Handlebars.compile(readTemplate('calls'));
|
||||
const aliases = {
|
||||
AssetHubZagrosRuntimeRuntimeCall: 'RuntimeCall',
|
||||
AssetHubPezkuwiRuntimeRuntimeCall: 'RuntimeCall',
|
||||
AssetHubDicleRuntimeOriginCaller: 'OriginCaller',
|
||||
AssetHubDicleRuntimeRuntimeCall: 'RuntimeCall',
|
||||
DicleRuntimeConstantsProxyProxyType: 'ProxyType',
|
||||
KitchensinkRuntimeRuntimeCall: 'RuntimeCall',
|
||||
KitchensinkRuntimeRuntimeParametersKey: 'RuntimeParametersKey',
|
||||
OpaqueValue: 'Bytes',
|
||||
PezkuwiTeyrchainPrimitivesPrimitivesId: 'ParaId',
|
||||
PezkuwiTeyrchainPrimitivesPrimitivesValidationCodeHash: 'ValidationCodeHash',
|
||||
PezkuwiPrimitivesV7SlashingOpaqueKeyOwnershipProof: 'OpaqueKeyOwnershipProof',
|
||||
PezkuwiPrimitivesV8SlashingOpaqueKeyOwnershipProof: 'OpaqueKeyOwnershipProof',
|
||||
PezkuwiRuntimeRuntimeCall: 'RuntimeCall',
|
||||
PrimitiveTypesH160: 'H160',
|
||||
PrimitiveTypesH256: 'H256',
|
||||
PrimitiveTypesU256: 'U256',
|
||||
PezspConsensusBabeOpaqueKeyOwnershipProof: 'OpaqueKeyOwnershipProof',
|
||||
PezspConsensusSlotsSlot: 'Slot',
|
||||
PezspConsensusSlotsSlotDuration: 'SlotDuration',
|
||||
PezspCoreCryptoAccountId32: 'AccountId32',
|
||||
PezspCoreOpaqueMetadata: 'OpaqueMetadata',
|
||||
PezspRuntimeOpaqueValue: 'Bytes',
|
||||
PezspRuntimeUncheckedExtrinsic: 'Extrinsic',
|
||||
StagingDicleRuntimeOriginCaller: 'OriginCaller',
|
||||
StagingDicleRuntimeRuntimeCall: 'RuntimeCall',
|
||||
StagingDicleRuntimeRuntimeParameters: 'RuntimeParameters',
|
||||
StagingDicleRuntimeRuntimeParametersKey: 'RuntimeParametersKey',
|
||||
StagingZagrosRuntimeRuntimeCall: 'RuntimeCall'
|
||||
};
|
||||
const getTypesViaAlias = (registry, id) => {
|
||||
const rawTypeName = registry.lookup.getName(id) || registry.lookup.getTypeDef(id).type;
|
||||
const typeName = rebrandTypeName(rawTypeName);
|
||||
if (aliases[typeName]) {
|
||||
return aliases[typeName];
|
||||
}
|
||||
return typeName;
|
||||
};
|
||||
/** @internal */
|
||||
function getMethods(registry, methods) {
|
||||
const result = {};
|
||||
methods.forEach((m) => {
|
||||
const { deprecationInfo, docs, inputs, name, output } = m;
|
||||
let description = docs.map((d) => d.toString()).join();
|
||||
if (!deprecationInfo.isNotDeprecated) {
|
||||
const deprecationNotice = getDeprecationNotice(deprecationInfo, stringCamelCase(name));
|
||||
const notice = description.length ? `\n * ${deprecationNotice}` : ` * ${deprecationNotice}`;
|
||||
description += notice;
|
||||
}
|
||||
result[name.toString()] = {
|
||||
description,
|
||||
params: inputs.map(({ name, type }) => {
|
||||
return { name: name.toString(), type: getTypesViaAlias(registry, type) };
|
||||
}),
|
||||
type: getTypesViaAlias(registry, output)
|
||||
};
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/** @internal */
|
||||
function getRuntimeDefViaMetadata(registry) {
|
||||
const result = {};
|
||||
const { apis } = registry.metadata;
|
||||
for (let i = 0, count = apis.length; i < count; i++) {
|
||||
const { methods, name } = apis[i];
|
||||
result[name.toString()] = [{
|
||||
methods: getMethods(registry, methods),
|
||||
// We set the version to 0 here since it will not be relevant when we are grabbing the runtime apis
|
||||
// from the Metadata.
|
||||
version: 0
|
||||
}];
|
||||
}
|
||||
return Object.entries(result);
|
||||
}
|
||||
/** @internal */
|
||||
function getDefs(apis, defs, registry) {
|
||||
const named = {};
|
||||
const all = Object.values(defs);
|
||||
const isApiInMetadata = registry.metadata.apis.length > 0;
|
||||
if (isApiInMetadata) {
|
||||
const sections = getRuntimeDefViaMetadata(registry);
|
||||
for (let j = 0, jcount = sections.length; j < jcount; j++) {
|
||||
const [_section, secs] = sections[j];
|
||||
const sec = secs[0];
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const section = stringCamelCase(_section);
|
||||
const methods = Object.entries(sec.methods);
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let j = 0, jcount = all.length; j < jcount; j++) {
|
||||
const set = all[j].runtime;
|
||||
if (set) {
|
||||
const sections = Object.entries(set);
|
||||
for (let i = 0, scount = sections.length; i < scount; i++) {
|
||||
const [_section, sec] = sections[i];
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const api = apis?.find(([h]) => h === sectionHash);
|
||||
if (api) {
|
||||
const ver = sec.find(({ version }) => version === api[1]);
|
||||
if (ver) {
|
||||
const methods = Object.entries(ver.methods);
|
||||
const mcount = methods.length;
|
||||
if (mcount) {
|
||||
const section = stringCamelCase(_section);
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
for (let m = 0; m < mcount; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${method}`, section, sectionHash, version: ver.version }, def);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.warn(`Unable to find matching version for runtime ${_section}, expected ${api[1]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return named;
|
||||
}
|
||||
/** @internal */
|
||||
export function generateCallTypes(registry, meta, dest, extraTypes, isStrict, customLookupDefinitions) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = {
|
||||
'@pezkuwi/types-augment': {
|
||||
lookup: {
|
||||
...lookupDefinitions,
|
||||
...customLookupDefinitions
|
||||
}
|
||||
},
|
||||
'@pezkuwi/types/interfaces': defaultDefs,
|
||||
...extraTypes
|
||||
};
|
||||
const imports = createImports(allTypes);
|
||||
// find the system.Version in metadata
|
||||
let apis = null;
|
||||
const sysp = meta.asLatest.pallets.find(({ name }) => name.eq('System'));
|
||||
if (sysp) {
|
||||
const verc = sysp.constants.find(({ name }) => name.eq('Version'));
|
||||
if (verc) {
|
||||
apis = registry.createType('RuntimeVersion', verc.value).apis.map(([k, v]) => [k.toHex(), v.toNumber()]);
|
||||
}
|
||||
else {
|
||||
console.error('Unable to find System.Version pallet, skipping API extraction');
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error('Unable to find System pallet, skipping API extraction');
|
||||
}
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const definitions = getDefs(apis, imports.definitions, registry);
|
||||
const callKeys = Object.keys(definitions);
|
||||
const modules = callKeys.map((section) => {
|
||||
const calls = definitions[section];
|
||||
const allMethods = Object.keys(calls).sort().map((methodName) => {
|
||||
const def = calls[methodName];
|
||||
setImports(allDefs, imports, [def.type]);
|
||||
const args = def.params.map((param) => {
|
||||
const similarTypes = getSimilarTypes(registry, imports.definitions, param.type, imports);
|
||||
setImports(allDefs, imports, [param.type, ...similarTypes]);
|
||||
return `${param.name}: ${similarTypes.join(' | ')}`;
|
||||
});
|
||||
return {
|
||||
args: args.join(', '),
|
||||
docs: [def.description],
|
||||
name: methodName,
|
||||
sectionHash: def.sectionHash,
|
||||
sectionName: def.section,
|
||||
sectionVersion: def.version,
|
||||
type: formatType(registry, allDefs, def.type, imports)
|
||||
};
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
return {
|
||||
items: allMethods,
|
||||
name: section || 'unknown',
|
||||
sectionHash: allMethods.length && allMethods[0].sectionHash,
|
||||
sectionName: allMethods.length && allMethods[0].sectionName,
|
||||
sectionVersion: allMethods.length && allMethods[0].sectionVersion
|
||||
};
|
||||
}).filter(({ items }) => items.length).sort((a, b) => a.name.localeCompare(b.name));
|
||||
if (modules.length) {
|
||||
imports.typesTypes['Observable'] = true;
|
||||
}
|
||||
return generateCallsTypesTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedCall', 'DecoratedCallBase']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
export function generateDefaultRuntime(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
|
||||
const { metadata, registry } = initMeta(data, extraTypes);
|
||||
generateCallTypes(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions);
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import type { Registry } from '@pezkuwi/types/types';
|
||||
import type { TypeDef } from '@pezkuwi/types-create/types';
|
||||
import type { ModuleTypes } from '../util/imports.js';
|
||||
import type { TypeImports } from '../util/index.js';
|
||||
import { TypeDefInfo } from '@pezkuwi/types-create';
|
||||
/** @internal */
|
||||
export declare function createGetter(definitions: Record<string, ModuleTypes>, name: string | undefined, type: string, imports: TypeImports): string;
|
||||
export declare const typeEncoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string>;
|
||||
/** @internal */
|
||||
export declare function generateTsDefFor(registry: Registry, importDefinitions: Record<string, Record<string, ModuleTypes>>, defName: string, { types }: {
|
||||
types: Record<string, any>;
|
||||
}, outputDir: string): void;
|
||||
/** @internal */
|
||||
export declare function generateTsDef(importDefinitions: Record<string, Record<string, ModuleTypes>>, outputDir: string, generatingPackage: string): void;
|
||||
/** @internal */
|
||||
export declare function generateDefaultTsDef(): void;
|
||||
@@ -0,0 +1,246 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import path from 'node:path';
|
||||
import { TypeRegistry } from '@pezkuwi/types/create';
|
||||
import * as defaultDefinitions from '@pezkuwi/types/interfaces/definitions';
|
||||
import { getTypeDef, TypeDefInfo } from '@pezkuwi/types-create';
|
||||
import { assert, isString, stringify, stringPascalCase } from '@pezkuwi/util';
|
||||
import { createImports, exportInterface, formatType, readTemplate, setImports, writeFile } from '../util/index.js';
|
||||
const generateTsDefIndexTemplate = Handlebars.compile(readTemplate('tsDef/index'));
|
||||
const generateTsDefModuleTypesTemplate = Handlebars.compile(readTemplate('tsDef/moduleTypes'));
|
||||
const generateTsDefTypesTemplate = Handlebars.compile(readTemplate('tsDef/types'));
|
||||
/** @internal */
|
||||
export function createGetter(definitions, name = '', type, imports) {
|
||||
setImports(definitions, imports, [type]);
|
||||
return ` readonly ${name}: ${type};\n`;
|
||||
}
|
||||
/** @internal */
|
||||
function errorUnhandled(_, _definitions, def, _imports) {
|
||||
throw new Error(`Generate: ${def.name || ''}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
}
|
||||
/** @internal */
|
||||
function tsExport(registry, definitions, def, imports) {
|
||||
return exportInterface(def.lookupIndex, def.name, formatType(registry, definitions, def, imports, false));
|
||||
}
|
||||
/** @internal */
|
||||
function tsEnum(registry, definitions, { lookupIndex, name: enumName, sub }, imports, withShortcut = false) {
|
||||
setImports(definitions, imports, ['Enum']);
|
||||
const indent = withShortcut ? ' ' : '';
|
||||
const named = sub.filter(({ name }) => !!name && !name.startsWith('__Unused'));
|
||||
const keys = named.map((def) => {
|
||||
const { info, lookupName, name = '', sub, type } = def;
|
||||
const getter = stringPascalCase(name.replace(' ', '_'));
|
||||
const isComplex = [TypeDefInfo.Option, TypeDefInfo.Range, TypeDefInfo.RangeInclusive, TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||
let extractedLookupName;
|
||||
// When the parent type does not have a lookupName, and the sub type is the same
|
||||
// type as the parent we can take the lookupName from the sub.
|
||||
// This is specific to `StagingXcmV4Junction`.
|
||||
// see: https://github.com/pezkuwichain/pezkuwi-api/pull/5812
|
||||
if (sub && !Array.isArray(sub) && type.includes(`${sub.type};`)) {
|
||||
if (sub.lookupName === 'StagingXcmV4Junction') {
|
||||
extractedLookupName = sub.lookupName;
|
||||
}
|
||||
else if (sub.lookupName === 'StagingXcmV5Junction') {
|
||||
extractedLookupName = `Vec<${sub.lookupName}>`;
|
||||
}
|
||||
}
|
||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `as${getter}`, lookupName || extractedLookupName || (isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports, withShortcut) : type), imports);
|
||||
const isGetter = info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
switch (info) {
|
||||
case TypeDefInfo.Compact:
|
||||
case TypeDefInfo.Plain:
|
||||
case TypeDefInfo.Range:
|
||||
case TypeDefInfo.RangeInclusive:
|
||||
case TypeDefInfo.Result:
|
||||
case TypeDefInfo.Si:
|
||||
case TypeDefInfo.Struct:
|
||||
case TypeDefInfo.Tuple:
|
||||
case TypeDefInfo.Vec:
|
||||
case TypeDefInfo.BTreeMap:
|
||||
case TypeDefInfo.BTreeSet:
|
||||
case TypeDefInfo.Option:
|
||||
case TypeDefInfo.VecFixed:
|
||||
case TypeDefInfo.WrapperKeepOpaque:
|
||||
case TypeDefInfo.WrapperOpaque:
|
||||
return `${indent}${isGetter}${indent}${asGetter}`;
|
||||
case TypeDefInfo.DoNotConstruct:
|
||||
case TypeDefInfo.Null:
|
||||
return `${indent}${isGetter}`;
|
||||
default:
|
||||
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled type ${TypeDefInfo[info]}, ${stringify(def)}`);
|
||||
}
|
||||
});
|
||||
return exportInterface(lookupIndex, enumName, 'Enum', `${keys.join('')} ${indent}readonly type: ${named.map(({ name = '' }) => `'${stringPascalCase(name.replace(' ', '_'))}'`).join(' | ')};\n`, withShortcut);
|
||||
}
|
||||
function tsInt(_, definitions, def, imports, type = 'Int') {
|
||||
setImports(definitions, imports, [type]);
|
||||
return exportInterface(def.lookupIndex, def.name, type);
|
||||
}
|
||||
/** @internal */
|
||||
function tsNull(_registry, definitions, { lookupIndex = -1, name }, imports) {
|
||||
setImports(definitions, imports, ['Null']);
|
||||
// * @description extends [[${base}]]
|
||||
const doc = `/** @name ${name || ''}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
|
||||
return `${doc}export type ${name || ''} = Null;`;
|
||||
}
|
||||
/** @internal */
|
||||
function tsResultGetter(registry, definitions, resultName = '', getter, def, imports) {
|
||||
const { info, lookupName, type } = def;
|
||||
const asGetter = type === 'Null'
|
||||
? ''
|
||||
: createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||
const isGetter = createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
switch (info) {
|
||||
case TypeDefInfo.Option:
|
||||
case TypeDefInfo.Plain:
|
||||
case TypeDefInfo.Si:
|
||||
case TypeDefInfo.Tuple:
|
||||
case TypeDefInfo.Vec:
|
||||
case TypeDefInfo.BTreeMap:
|
||||
case TypeDefInfo.BTreeSet:
|
||||
case TypeDefInfo.WrapperKeepOpaque:
|
||||
case TypeDefInfo.WrapperOpaque:
|
||||
return `${isGetter}${asGetter}`;
|
||||
case TypeDefInfo.Null:
|
||||
return `${isGetter}`;
|
||||
default:
|
||||
throw new Error(`Result: ${resultName}: Unhandled type ${TypeDefInfo[info]}, ${stringify(def)}`);
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
function tsResult(registry, definitions, def, imports) {
|
||||
const [okDef, errorDef] = def.sub;
|
||||
const inner = [
|
||||
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
|
||||
].join('');
|
||||
setImports(definitions, imports, [def.type]);
|
||||
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||
? def.lookupName
|
||||
: formatType(registry, definitions, def, imports, false);
|
||||
return exportInterface(def.lookupIndex, def.name, fmtType, inner);
|
||||
}
|
||||
/** @internal */
|
||||
function tsSi(_registry, _definitions, typeDef, _imports) {
|
||||
// FIXME
|
||||
return `// SI: ${stringify(typeDef)}`;
|
||||
}
|
||||
/** @internal */
|
||||
function tsSet(_, definitions, { lookupIndex, name: setName, sub }, imports) {
|
||||
setImports(definitions, imports, ['Set']);
|
||||
const types = sub.map(({ name }) => {
|
||||
assert(name, 'Invalid TypeDef found, no name specified');
|
||||
return createGetter(definitions, `is${name}`, 'boolean', imports);
|
||||
});
|
||||
return exportInterface(lookupIndex, setName, 'Set', types.join(''));
|
||||
}
|
||||
/** @internal */
|
||||
function tsStruct(registry, definitions, { lookupIndex, name: structName, sub }, imports) {
|
||||
setImports(definitions, imports, ['Struct']);
|
||||
const keys = sub.map((def) => {
|
||||
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||
? def.lookupName
|
||||
: def.info === TypeDefInfo.Enum
|
||||
? `${tsEnum(registry, definitions, def, imports, true)} & Enum`
|
||||
: formatType(registry, definitions, def, imports, false);
|
||||
return createGetter(definitions, def.name, fmtType, imports);
|
||||
});
|
||||
return exportInterface(lookupIndex, structName, 'Struct', keys.join(''));
|
||||
}
|
||||
/** @internal */
|
||||
function tsUInt(registry, definitions, def, imports) {
|
||||
return tsInt(registry, definitions, def, imports, 'UInt');
|
||||
}
|
||||
/** @internal */
|
||||
function tsVec(registry, definitions, def, imports) {
|
||||
const type = def.sub.type;
|
||||
if (type === 'u8') {
|
||||
if (def.info === TypeDefInfo.VecFixed) {
|
||||
setImports(definitions, imports, ['U8aFixed']);
|
||||
return exportInterface(def.lookupIndex, def.name, 'U8aFixed');
|
||||
}
|
||||
else {
|
||||
setImports(definitions, imports, ['Bytes']);
|
||||
return exportInterface(def.lookupIndex, def.name, 'Bytes');
|
||||
}
|
||||
}
|
||||
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||
? def.lookupName
|
||||
: formatType(registry, definitions, def, imports, false);
|
||||
return exportInterface(def.lookupIndex, def.name, fmtType);
|
||||
}
|
||||
export const typeEncoders = {
|
||||
[TypeDefInfo.BTreeMap]: tsExport,
|
||||
[TypeDefInfo.BTreeSet]: tsExport,
|
||||
[TypeDefInfo.Compact]: tsExport,
|
||||
[TypeDefInfo.DoNotConstruct]: tsExport,
|
||||
[TypeDefInfo.Enum]: tsEnum,
|
||||
[TypeDefInfo.HashMap]: tsExport,
|
||||
[TypeDefInfo.Int]: tsInt,
|
||||
[TypeDefInfo.Linkage]: errorUnhandled,
|
||||
[TypeDefInfo.Null]: tsNull,
|
||||
[TypeDefInfo.Option]: tsExport,
|
||||
[TypeDefInfo.Plain]: tsExport,
|
||||
[TypeDefInfo.Range]: tsExport,
|
||||
[TypeDefInfo.RangeInclusive]: tsExport,
|
||||
[TypeDefInfo.Result]: tsResult,
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Si]: tsSi,
|
||||
[TypeDefInfo.Struct]: tsStruct,
|
||||
[TypeDefInfo.Tuple]: tsExport,
|
||||
[TypeDefInfo.UInt]: tsUInt,
|
||||
[TypeDefInfo.Vec]: tsVec,
|
||||
[TypeDefInfo.VecFixed]: tsVec,
|
||||
[TypeDefInfo.WrapperKeepOpaque]: tsExport,
|
||||
[TypeDefInfo.WrapperOpaque]: tsExport
|
||||
};
|
||||
/** @internal */
|
||||
function generateInterfaces(registry, definitions, { types }, imports) {
|
||||
return Object.entries(types).map(([name, type]) => {
|
||||
const def = getTypeDef(isString(type) ? type : stringify(type), { name });
|
||||
return [name, typeEncoders[def.info](registry, definitions, def, imports)];
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateTsDefFor(registry, importDefinitions, defName, { types }, outputDir) {
|
||||
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] };
|
||||
const definitions = imports.definitions;
|
||||
const interfaces = generateInterfaces(registry, definitions, { types }, imports);
|
||||
const items = interfaces.sort((a, b) => a[0].localeCompare(b[0])).map(([, definition]) => definition);
|
||||
writeFile(path.join(outputDir, defName, 'types.ts'), () => generateTsDefModuleTypesTemplate({
|
||||
headerType: 'defs',
|
||||
imports,
|
||||
items,
|
||||
name: defName,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types/augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
]
|
||||
}), true);
|
||||
writeFile(path.join(outputDir, defName, 'index.ts'), () => generateTsDefIndexTemplate({ headerType: 'defs' }), true);
|
||||
}
|
||||
/** @internal */
|
||||
export function generateTsDef(importDefinitions, outputDir, generatingPackage) {
|
||||
const registry = new TypeRegistry();
|
||||
writeFile(path.join(outputDir, 'types.ts'), () => {
|
||||
const definitions = importDefinitions[generatingPackage];
|
||||
Object.entries(definitions).forEach(([defName, obj]) => {
|
||||
console.log(`\tExtracting interfaces for ${defName}`);
|
||||
generateTsDefFor(registry, importDefinitions, defName, obj, outputDir);
|
||||
});
|
||||
return generateTsDefTypesTemplate({
|
||||
headerType: 'defs',
|
||||
items: Object.keys(definitions)
|
||||
});
|
||||
});
|
||||
writeFile(path.join(outputDir, 'index.ts'), () => generateTsDefIndexTemplate({ headerType: 'defs' }), true);
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultTsDef() {
|
||||
generateTsDef({ '@pezkuwi/types/interfaces': defaultDefinitions }, 'packages/types/src/interfaces', '@pezkuwi/types/interfaces');
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import type { Definitions } from '@pezkuwi/types/types';
|
||||
import type { HexString } from '@pezkuwi/util/types';
|
||||
import { type ExtraTypes } from './types.js';
|
||||
/** @internal */
|
||||
export declare function generateDefaultTx(dest: string, data: HexString, extraTypes?: ExtraTypes, isStrict?: boolean, customLookupDefinitions?: Definitions): void;
|
||||
@@ -0,0 +1,117 @@
|
||||
import Handlebars from 'handlebars';
|
||||
import * as defaultDefs from '@pezkuwi/types/interfaces/definitions';
|
||||
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||
import { stringCamelCase } from '@pezkuwi/util';
|
||||
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, rebrandTypeName, setImports, writeFile } from '../util/index.js';
|
||||
import { ignoreUnusedLookups } from './lookup.js';
|
||||
import { getDeprecationNotice } from './types.js';
|
||||
const MAPPED_NAMES = {
|
||||
class: 'clazz',
|
||||
new: 'updated'
|
||||
};
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('tx'));
|
||||
function mapName(_name) {
|
||||
const name = stringCamelCase(_name);
|
||||
return MAPPED_NAMES[name] || name;
|
||||
}
|
||||
/** @internal */
|
||||
function generateForMeta(registry, meta, dest, extraTypes, isStrict, customLookupDefinitions) {
|
||||
writeFile(dest, () => {
|
||||
const allTypes = {
|
||||
'@pezkuwi/types-augment': {
|
||||
lookup: {
|
||||
...lookupDefinitions,
|
||||
...customLookupDefinitions
|
||||
}
|
||||
},
|
||||
'@pezkuwi/types/interfaces': defaultDefs,
|
||||
...extraTypes
|
||||
};
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const { lookup, pallets } = meta.asLatest;
|
||||
const usedTypes = new Set([]);
|
||||
const modules = pallets
|
||||
.sort(compareName)
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.map((data) => {
|
||||
const name = data.name;
|
||||
const calls = data.calls.unwrap();
|
||||
const deprecationInfo = calls.deprecationInfo.toJSON();
|
||||
setImports(allDefs, imports, ['SubmittableExtrinsic']);
|
||||
const sectionName = stringCamelCase(name);
|
||||
const items = lookup.getSiType(calls.type).def.asVariant.variants
|
||||
.map(({ docs, fields, index, name }) => {
|
||||
const rawStatus = deprecationInfo?.[index.toNumber()];
|
||||
if (rawStatus) {
|
||||
const deprecationVariantInfo = meta.registry.createTypeUnsafe('VariantDeprecationInfoV16', [rawStatus]);
|
||||
const deprecationNotice = getDeprecationNotice(deprecationVariantInfo, name.toString(), 'Call');
|
||||
const notice = docs.length ? ['', deprecationNotice] : [deprecationNotice];
|
||||
docs.push(...notice.map((text) => meta.registry.createType('Text', text)));
|
||||
}
|
||||
const typesInfo = fields.map(({ name, type, typeName }, index) => {
|
||||
const typeDef = registry.lookup.getTypeDef(type);
|
||||
return [
|
||||
name.isSome
|
||||
? mapName(name.unwrap())
|
||||
: `param${index}`,
|
||||
rebrandTypeName(typeName.isSome
|
||||
? typeName.toString()
|
||||
: typeDef.type),
|
||||
rebrandTypeName(typeDef.isFromSi
|
||||
? typeDef.type
|
||||
: typeDef.lookupName || typeDef.type)
|
||||
];
|
||||
});
|
||||
const params = typesInfo
|
||||
.map(([name, , typeStr]) => {
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports);
|
||||
setImports(allDefs, imports, [typeStr, ...similarTypes]);
|
||||
// Add the type to the list of used types
|
||||
if (!(imports.primitiveTypes[typeStr])) {
|
||||
usedTypes.add(typeStr);
|
||||
}
|
||||
return `${name}: ${similarTypes.join(' | ')}`;
|
||||
})
|
||||
.join(', ');
|
||||
return {
|
||||
args: typesInfo.map(([, , typeStr]) => formatType(registry, allDefs, typeStr, imports)).join(', '),
|
||||
docs,
|
||||
name: stringCamelCase(name),
|
||||
params
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
return {
|
||||
items,
|
||||
name: sectionName
|
||||
};
|
||||
})
|
||||
.sort(compareName);
|
||||
// filter out the unused lookup types from imports
|
||||
ignoreUnusedLookups([...usedTypes], imports);
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath) => ({
|
||||
file: packagePath.replace('@pezkuwi/types-augment', '@pezkuwi/types'),
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@pezkuwi/api-base/types',
|
||||
types: ['ApiTypes', 'AugmentedSubmittable', 'SubmittableExtrinsic', 'SubmittableExtrinsicFunction']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
export function generateDefaultTx(dest, data, extraTypes = {}, isStrict = false, customLookupDefinitions) {
|
||||
const { metadata, registry } = initMeta(data, extraTypes);
|
||||
return generateForMeta(registry, metadata, dest, extraTypes, isStrict, customLookupDefinitions);
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import type { Option, Text } from '@pezkuwi/types-codec';
|
||||
export type ExtraTypes = Record<string, Record<string, {
|
||||
runtime?: Record<string, any>;
|
||||
types: Record<string, any>;
|
||||
}>>;
|
||||
export declare function getDeprecationNotice<T extends {
|
||||
isDeprecated: boolean;
|
||||
asDeprecated: {
|
||||
note: Text;
|
||||
since: Option<Text>;
|
||||
};
|
||||
}>(deprecationInfo: T, name: string, label?: string): string;
|
||||
@@ -0,0 +1,13 @@
|
||||
export function getDeprecationNotice(deprecationInfo, name, label) {
|
||||
let deprecationNotice = '@deprecated';
|
||||
if (deprecationInfo.isDeprecated) {
|
||||
const { note, since } = deprecationInfo.asDeprecated;
|
||||
const sinceText = since.isSome ? ` Since ${since.unwrap().toString()}.` : '';
|
||||
deprecationNotice += ` ${note.toString()}${sinceText}`;
|
||||
}
|
||||
else {
|
||||
const labelText = label ? `${label} ` : '';
|
||||
deprecationNotice += ` ${labelText}${name} has been deprecated`;
|
||||
}
|
||||
return deprecationNotice;
|
||||
}
|
||||
+515
-19
@@ -15,11 +15,13 @@
|
||||
},
|
||||
"sideEffects": [
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
"./cjs/packageDetect.js"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "16.5.6",
|
||||
"main": "index.js",
|
||||
"types": "./index.d.ts",
|
||||
"version": "16.5.9",
|
||||
"main": "./cjs/index.js",
|
||||
"module": "./index.js",
|
||||
"bin": {
|
||||
"pezkuwi-types-chain-info": "./scripts/pezkuwi-types-chain-info.mjs",
|
||||
"pezkuwi-types-from-chain": "./scripts/pezkuwi-types-from-chain.mjs",
|
||||
@@ -27,26 +29,520 @@
|
||||
"pezkuwi-types-internal-interfaces": "./scripts/pezkuwi-types-internal-interfaces.mjs",
|
||||
"pezkuwi-types-internal-metadata": "./scripts/pezkuwi-types-internal-metadata.mjs"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"module": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/index.d.ts",
|
||||
"default": "./cjs/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
}
|
||||
},
|
||||
"./augment": {
|
||||
"module": {
|
||||
"types": "./augment.d.ts",
|
||||
"default": "./augment.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/augment.d.ts",
|
||||
"default": "./cjs/augment.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./augment.d.ts",
|
||||
"default": "./augment.js"
|
||||
}
|
||||
},
|
||||
"./bundle": {
|
||||
"module": {
|
||||
"types": "./bundle.d.ts",
|
||||
"default": "./bundle.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/bundle.d.ts",
|
||||
"default": "./cjs/bundle.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./bundle.d.ts",
|
||||
"default": "./bundle.js"
|
||||
}
|
||||
},
|
||||
"./cjs/*": "./cjs/*.js",
|
||||
"./cjs/package.json": "./cjs/package.json",
|
||||
"./extractChain": {
|
||||
"module": {
|
||||
"types": "./extractChain.d.ts",
|
||||
"default": "./extractChain.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/extractChain.d.ts",
|
||||
"default": "./cjs/extractChain.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./extractChain.d.ts",
|
||||
"default": "./extractChain.js"
|
||||
}
|
||||
},
|
||||
"./fromChain": {
|
||||
"module": {
|
||||
"types": "./fromChain.d.ts",
|
||||
"default": "./fromChain.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/fromChain.d.ts",
|
||||
"default": "./cjs/fromChain.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./fromChain.d.ts",
|
||||
"default": "./fromChain.js"
|
||||
}
|
||||
},
|
||||
"./fromDefs": {
|
||||
"module": {
|
||||
"types": "./fromDefs.d.ts",
|
||||
"default": "./fromDefs.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/fromDefs.d.ts",
|
||||
"default": "./cjs/fromDefs.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./fromDefs.d.ts",
|
||||
"default": "./fromDefs.js"
|
||||
}
|
||||
},
|
||||
"./generate": {
|
||||
"module": {
|
||||
"types": "./generate/index.d.ts",
|
||||
"default": "./generate/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/index.d.ts",
|
||||
"default": "./cjs/generate/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/index.d.ts",
|
||||
"default": "./generate/index.js"
|
||||
}
|
||||
},
|
||||
"./generate/consts": {
|
||||
"module": {
|
||||
"types": "./generate/consts.d.ts",
|
||||
"default": "./generate/consts.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/consts.d.ts",
|
||||
"default": "./cjs/generate/consts.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/consts.d.ts",
|
||||
"default": "./generate/consts.js"
|
||||
}
|
||||
},
|
||||
"./generate/errors": {
|
||||
"module": {
|
||||
"types": "./generate/errors.d.ts",
|
||||
"default": "./generate/errors.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/errors.d.ts",
|
||||
"default": "./cjs/generate/errors.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/errors.d.ts",
|
||||
"default": "./generate/errors.js"
|
||||
}
|
||||
},
|
||||
"./generate/events": {
|
||||
"module": {
|
||||
"types": "./generate/events.d.ts",
|
||||
"default": "./generate/events.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/events.d.ts",
|
||||
"default": "./cjs/generate/events.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/events.d.ts",
|
||||
"default": "./generate/events.js"
|
||||
}
|
||||
},
|
||||
"./generate/interfaceRegistry": {
|
||||
"module": {
|
||||
"types": "./generate/interfaceRegistry.d.ts",
|
||||
"default": "./generate/interfaceRegistry.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/interfaceRegistry.d.ts",
|
||||
"default": "./cjs/generate/interfaceRegistry.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/interfaceRegistry.d.ts",
|
||||
"default": "./generate/interfaceRegistry.js"
|
||||
}
|
||||
},
|
||||
"./generate/lookup": {
|
||||
"module": {
|
||||
"types": "./generate/lookup.d.ts",
|
||||
"default": "./generate/lookup.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/lookup.d.ts",
|
||||
"default": "./cjs/generate/lookup.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/lookup.d.ts",
|
||||
"default": "./generate/lookup.js"
|
||||
}
|
||||
},
|
||||
"./generate/query": {
|
||||
"module": {
|
||||
"types": "./generate/query.d.ts",
|
||||
"default": "./generate/query.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/query.d.ts",
|
||||
"default": "./cjs/generate/query.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/query.d.ts",
|
||||
"default": "./generate/query.js"
|
||||
}
|
||||
},
|
||||
"./generate/rpc": {
|
||||
"module": {
|
||||
"types": "./generate/rpc.d.ts",
|
||||
"default": "./generate/rpc.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/rpc.d.ts",
|
||||
"default": "./cjs/generate/rpc.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/rpc.d.ts",
|
||||
"default": "./generate/rpc.js"
|
||||
}
|
||||
},
|
||||
"./generate/runtime": {
|
||||
"module": {
|
||||
"types": "./generate/runtime.d.ts",
|
||||
"default": "./generate/runtime.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/runtime.d.ts",
|
||||
"default": "./cjs/generate/runtime.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/runtime.d.ts",
|
||||
"default": "./generate/runtime.js"
|
||||
}
|
||||
},
|
||||
"./generate/tsDef": {
|
||||
"module": {
|
||||
"types": "./generate/tsDef.d.ts",
|
||||
"default": "./generate/tsDef.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/tsDef.d.ts",
|
||||
"default": "./cjs/generate/tsDef.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/tsDef.d.ts",
|
||||
"default": "./generate/tsDef.js"
|
||||
}
|
||||
},
|
||||
"./generate/tx": {
|
||||
"module": {
|
||||
"types": "./generate/tx.d.ts",
|
||||
"default": "./generate/tx.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/tx.d.ts",
|
||||
"default": "./cjs/generate/tx.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/tx.d.ts",
|
||||
"default": "./generate/tx.js"
|
||||
}
|
||||
},
|
||||
"./generate/types": {
|
||||
"module": {
|
||||
"types": "./generate/types.d.ts",
|
||||
"default": "./generate/types.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/generate/types.d.ts",
|
||||
"default": "./cjs/generate/types.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./generate/types.d.ts",
|
||||
"default": "./generate/types.js"
|
||||
}
|
||||
},
|
||||
"./interfacesTs": {
|
||||
"module": {
|
||||
"types": "./interfacesTs.d.ts",
|
||||
"default": "./interfacesTs.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/interfacesTs.d.ts",
|
||||
"default": "./cjs/interfacesTs.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./interfacesTs.d.ts",
|
||||
"default": "./interfacesTs.js"
|
||||
}
|
||||
},
|
||||
"./metadataMd": {
|
||||
"module": {
|
||||
"types": "./metadataMd.d.ts",
|
||||
"default": "./metadataMd.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/metadataMd.d.ts",
|
||||
"default": "./cjs/metadataMd.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./metadataMd.d.ts",
|
||||
"default": "./metadataMd.js"
|
||||
}
|
||||
},
|
||||
"./package.json": {
|
||||
"require": "./cjs/package.json",
|
||||
"default": "./package.json"
|
||||
},
|
||||
"./packageDetect": {
|
||||
"module": {
|
||||
"types": "./packageDetect.d.ts",
|
||||
"default": "./packageDetect.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/packageDetect.d.ts",
|
||||
"default": "./cjs/packageDetect.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./packageDetect.d.ts",
|
||||
"default": "./packageDetect.js"
|
||||
}
|
||||
},
|
||||
"./packageInfo": {
|
||||
"module": {
|
||||
"types": "./packageInfo.d.ts",
|
||||
"default": "./packageInfo.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/packageInfo.d.ts",
|
||||
"default": "./cjs/packageInfo.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./packageInfo.d.ts",
|
||||
"default": "./packageInfo.js"
|
||||
}
|
||||
},
|
||||
"./packageInfo.js": {
|
||||
"module": {
|
||||
"types": "./packageInfo.d.ts",
|
||||
"default": "./packageInfo.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/packageInfo.d.ts",
|
||||
"default": "./cjs/packageInfo.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./packageInfo.d.ts",
|
||||
"default": "./packageInfo.js"
|
||||
}
|
||||
},
|
||||
"./scripts/pezkuwi-types-chain-info": "./scripts/pezkuwi-types-chain-info.mjs",
|
||||
"./scripts/pezkuwi-types-chain-info.mjs": "./scripts/pezkuwi-types-chain-info.mjs",
|
||||
"./scripts/pezkuwi-types-from-chain": "./scripts/pezkuwi-types-from-chain.mjs",
|
||||
"./scripts/pezkuwi-types-from-chain.mjs": "./scripts/pezkuwi-types-from-chain.mjs",
|
||||
"./scripts/pezkuwi-types-from-defs": "./scripts/pezkuwi-types-from-defs.mjs",
|
||||
"./scripts/pezkuwi-types-from-defs.mjs": "./scripts/pezkuwi-types-from-defs.mjs",
|
||||
"./scripts/pezkuwi-types-internal-interfaces": "./scripts/pezkuwi-types-internal-interfaces.mjs",
|
||||
"./scripts/pezkuwi-types-internal-interfaces.mjs": "./scripts/pezkuwi-types-internal-interfaces.mjs",
|
||||
"./scripts/pezkuwi-types-internal-metadata": "./scripts/pezkuwi-types-internal-metadata.mjs",
|
||||
"./scripts/pezkuwi-types-internal-metadata.mjs": "./scripts/pezkuwi-types-internal-metadata.mjs",
|
||||
"./templates/calls.hbs": "./templates/calls.hbs",
|
||||
"./templates/consts.hbs": "./templates/consts.hbs",
|
||||
"./templates/docs.hbs": "./templates/docs.hbs",
|
||||
"./templates/errors.hbs": "./templates/errors.hbs",
|
||||
"./templates/events.hbs": "./templates/events.hbs",
|
||||
"./templates/header.hbs": "./templates/header.hbs",
|
||||
"./templates/interfaceRegistry.hbs": "./templates/interfaceRegistry.hbs",
|
||||
"./templates/lookup/defs-named.hbs": "./templates/lookup/defs-named.hbs",
|
||||
"./templates/lookup/defs.hbs": "./templates/lookup/defs.hbs",
|
||||
"./templates/lookup/index.hbs": "./templates/lookup/index.hbs",
|
||||
"./templates/lookup/types.hbs": "./templates/lookup/types.hbs",
|
||||
"./templates/query.hbs": "./templates/query.hbs",
|
||||
"./templates/rpc.hbs": "./templates/rpc.hbs",
|
||||
"./templates/tsDef/index.hbs": "./templates/tsDef/index.hbs",
|
||||
"./templates/tsDef/moduleTypes.hbs": "./templates/tsDef/moduleTypes.hbs",
|
||||
"./templates/tsDef/types.hbs": "./templates/tsDef/types.hbs",
|
||||
"./templates/tx.hbs": "./templates/tx.hbs",
|
||||
"./util": {
|
||||
"module": {
|
||||
"types": "./util/index.d.ts",
|
||||
"default": "./util/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/index.d.ts",
|
||||
"default": "./cjs/util/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/index.d.ts",
|
||||
"default": "./util/index.js"
|
||||
}
|
||||
},
|
||||
"./util/assert": {
|
||||
"module": {
|
||||
"types": "./util/assert.d.ts",
|
||||
"default": "./util/assert.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/assert.d.ts",
|
||||
"default": "./cjs/util/assert.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/assert.d.ts",
|
||||
"default": "./util/assert.js"
|
||||
}
|
||||
},
|
||||
"./util/derived": {
|
||||
"module": {
|
||||
"types": "./util/derived.d.ts",
|
||||
"default": "./util/derived.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/derived.d.ts",
|
||||
"default": "./cjs/util/derived.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/derived.d.ts",
|
||||
"default": "./util/derived.js"
|
||||
}
|
||||
},
|
||||
"./util/docs": {
|
||||
"module": {
|
||||
"types": "./util/docs.d.ts",
|
||||
"default": "./util/docs.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/docs.d.ts",
|
||||
"default": "./cjs/util/docs.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/docs.d.ts",
|
||||
"default": "./util/docs.js"
|
||||
}
|
||||
},
|
||||
"./util/file": {
|
||||
"module": {
|
||||
"types": "./util/file.d.ts",
|
||||
"default": "./util/file.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/file.d.ts",
|
||||
"default": "./cjs/util/file.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/file.d.ts",
|
||||
"default": "./util/file.js"
|
||||
}
|
||||
},
|
||||
"./util/formatting": {
|
||||
"module": {
|
||||
"types": "./util/formatting.d.ts",
|
||||
"default": "./util/formatting.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/formatting.d.ts",
|
||||
"default": "./cjs/util/formatting.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/formatting.d.ts",
|
||||
"default": "./util/formatting.js"
|
||||
}
|
||||
},
|
||||
"./util/imports": {
|
||||
"module": {
|
||||
"types": "./util/imports.d.ts",
|
||||
"default": "./util/imports.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/imports.d.ts",
|
||||
"default": "./cjs/util/imports.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/imports.d.ts",
|
||||
"default": "./util/imports.js"
|
||||
}
|
||||
},
|
||||
"./util/initMeta": {
|
||||
"module": {
|
||||
"types": "./util/initMeta.d.ts",
|
||||
"default": "./util/initMeta.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/initMeta.d.ts",
|
||||
"default": "./cjs/util/initMeta.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/initMeta.d.ts",
|
||||
"default": "./util/initMeta.js"
|
||||
}
|
||||
},
|
||||
"./util/register": {
|
||||
"module": {
|
||||
"types": "./util/register.d.ts",
|
||||
"default": "./util/register.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/register.d.ts",
|
||||
"default": "./cjs/util/register.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/register.d.ts",
|
||||
"default": "./util/register.js"
|
||||
}
|
||||
},
|
||||
"./util/wsMeta": {
|
||||
"module": {
|
||||
"types": "./util/wsMeta.d.ts",
|
||||
"default": "./util/wsMeta.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./cjs/util/wsMeta.d.ts",
|
||||
"default": "./cjs/util/wsMeta.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./util/wsMeta.d.ts",
|
||||
"default": "./util/wsMeta.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@pezkuwi/api": "16.5.4",
|
||||
"@pezkuwi/api-augment": "16.5.4",
|
||||
"@pezkuwi/api-derive": "16.5.4",
|
||||
"@pezkuwi/rpc-augment": "16.5.4",
|
||||
"@pezkuwi/rpc-provider": "16.5.4",
|
||||
"@pezkuwi/types": "16.5.4",
|
||||
"@pezkuwi/types-augment": "16.5.4",
|
||||
"@pezkuwi/types-codec": "16.5.4",
|
||||
"@pezkuwi/types-create": "16.5.4",
|
||||
"@pezkuwi/types-support": "16.5.4",
|
||||
"@pezkuwi/util": "^14.0.1",
|
||||
"@pezkuwi/util-crypto": "^14.0.1",
|
||||
"@pezkuwi/x-ws": "^14.0.1",
|
||||
"@pezkuwi/api": "16.5.9",
|
||||
"@pezkuwi/api-augment": "16.5.9",
|
||||
"@pezkuwi/api-derive": "16.5.9",
|
||||
"@pezkuwi/rpc-augment": "16.5.9",
|
||||
"@pezkuwi/rpc-provider": "16.5.9",
|
||||
"@pezkuwi/types": "16.5.9",
|
||||
"@pezkuwi/types-augment": "16.5.9",
|
||||
"@pezkuwi/types-codec": "16.5.9",
|
||||
"@pezkuwi/types-create": "16.5.9",
|
||||
"@pezkuwi/types-support": "16.5.9",
|
||||
"@pezkuwi/util": "14.0.11",
|
||||
"@pezkuwi/util-crypto": "14.0.11",
|
||||
"@pezkuwi/x-ws": "14.0.11",
|
||||
"comment-parser": "^1.4.1",
|
||||
"handlebars": "^4.7.8",
|
||||
"tslib": "^2.8.1",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/yargs": "^17.0.33"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.4' };
|
||||
export const packageInfo = { name: '@pezkuwi/typegen', path: 'auto', type: 'auto', version: '16.5.9' };
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/calls';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedCall<ApiType extends ApiTypes> = AugmentedCall<ApiType>;
|
||||
export type __DecoratedCallBase<ApiType extends ApiTypes> = DecoratedCallBase<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/calls' {
|
||||
interface AugmentedCalls<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
/** {{{sectionHash}}}/{{{sectionVersion}}} */
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedCall<ApiType, ({{{args}}}) => Observable<{{{type}}}>>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedCalls
|
||||
} // declare module
|
||||
@@ -0,0 +1,28 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/consts';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/consts' {
|
||||
interface AugmentedConsts<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: {{{type}}} & AugmentedConst<ApiType>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedConsts
|
||||
} // declare module
|
||||
@@ -0,0 +1,7 @@
|
||||
{{#if docs.length}}
|
||||
/**
|
||||
{{#each docs}}
|
||||
* {{#trim}}{{{this}}}{{/trim}}
|
||||
{{/each}}
|
||||
**/
|
||||
{{/if}}
|
||||
@@ -0,0 +1,28 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/errors';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedError<ApiType extends ApiTypes> = AugmentedError<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/errors' {
|
||||
interface AugmentedErrors<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedError<ApiType>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedErrors
|
||||
} // declare module
|
||||
@@ -0,0 +1,28 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/events';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedEvent<ApiType extends ApiTypes> = AugmentedEvent<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/events' {
|
||||
interface AugmentedEvents<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedEvent<ApiType, {{{type}}}>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedEvents
|
||||
} // declare module
|
||||
@@ -0,0 +1,2 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-{{headerType}}`, do not edit
|
||||
/* eslint-disable */
|
||||
@@ -0,0 +1,15 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/types/types/registry';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
declare module '@pezkuwi/types/types/registry' {
|
||||
interface InterfaceTypes {
|
||||
{{#each items}}
|
||||
{{{this}}}: {{{this}}};
|
||||
{{/each}}
|
||||
} // InterfaceTypes
|
||||
} // declare module
|
||||
@@ -0,0 +1,12 @@
|
||||
{{> header }}
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export default {
|
||||
{{#each defs}}
|
||||
{{> docs}}
|
||||
{{#each defs}}
|
||||
{{{this}}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
{{> header }}
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
{{#each defs}}
|
||||
{{> docs}}
|
||||
{{#each defs}}
|
||||
{{{this}}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
{{> header }}
|
||||
|
||||
export * from './types.js';
|
||||
@@ -0,0 +1,14 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/types/lookup';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
declare module '@pezkuwi/types/lookup' {
|
||||
{{#each items}}
|
||||
{{{this}}}
|
||||
|
||||
{{/each}}
|
||||
} // declare module
|
||||
@@ -0,0 +1,29 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/storage';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedQuery<ApiType extends ApiTypes> = AugmentedQuery<ApiType, () => unknown>;
|
||||
export type __QueryableStorageEntry<ApiType extends ApiTypes> = QueryableStorageEntry<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/storage' {
|
||||
interface AugmentedQueries<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: {{{entryType}}}<ApiType, ({{{params}}}) => Observable<{{{returnType}}}>, [{{{args}}}]>{{#unless @root.isStrict}} & QueryableStorageEntry<ApiType, [{{{args}}}]>{{/unless}};
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedQueries
|
||||
} // declare module
|
||||
@@ -0,0 +1,22 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/rpc-core/types/jsonrpc';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedRpc = AugmentedRpc<() => unknown>;
|
||||
|
||||
declare module '@pezkuwi/rpc-core/types/jsonrpc' {
|
||||
interface RpcInterface {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedRpc<{{#if generic}}<{{{generic}}}>{{/if}}({{{args}}}) => Observable<{{{type}}}>>;
|
||||
{{/each}}
|
||||
};
|
||||
{{/each}}
|
||||
} // RpcInterface
|
||||
} // declare module
|
||||
@@ -0,0 +1,3 @@
|
||||
{{> header }}
|
||||
|
||||
export * from './types.js';
|
||||
@@ -0,0 +1,10 @@
|
||||
{{> header }}
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
{{#each items}}
|
||||
{{{this}}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
export type PHANTOM_{{#upper}}{{{name}}}{{/upper}} = '{{{name}}}';
|
||||
@@ -0,0 +1,7 @@
|
||||
{{> header }}
|
||||
|
||||
{{#each items}}
|
||||
export * from './{{{this}}}/types.js';
|
||||
{{/each}}
|
||||
|
||||
export type PHANTOM_GENERATED = 'generated';
|
||||
@@ -0,0 +1,30 @@
|
||||
{{> header }}
|
||||
|
||||
// import type lookup before we augment - in some environments
|
||||
// this is required to allow for ambient/previous definitions
|
||||
import '@pezkuwi/api-base/types/submittable';
|
||||
|
||||
{{{ importsAll }}}
|
||||
|
||||
export type __AugmentedSubmittable = AugmentedSubmittable<() => unknown>;
|
||||
export type __SubmittableExtrinsic<ApiType extends ApiTypes> = SubmittableExtrinsic<ApiType>;
|
||||
export type __SubmittableExtrinsicFunction<ApiType extends ApiTypes> = SubmittableExtrinsicFunction<ApiType>;
|
||||
|
||||
declare module '@pezkuwi/api-base/types/submittable' {
|
||||
interface AugmentedSubmittables<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedSubmittable<({{{params}}}) => SubmittableExtrinsic<ApiType>, [{{{args}}}]>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
{{/unless}}
|
||||
};
|
||||
{{/each}}
|
||||
} // AugmentedSubmittables
|
||||
} // declare module
|
||||
Reference in New Issue
Block a user