mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-04-22 03:17:56 +00:00
31467f90d4
- @pezkuwi/papi-utils (rebrand of @polkadot-api/utils) - @pezkuwi/bizinikiwi-bindings (rebrand of @polkadot-api/substrate-bindings) - @pezkuwi/metadata-builders (rebrand of @polkadot-api/metadata-builders) - @pezkuwi/merkleize-metadata (rebrand of @polkadot-api/merkleize-metadata) All @polkadot-api references replaced with @pezkuwi equivalents.
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
const unifyMetadata = (metadata) => {
|
|
if ("magicNumber" in metadata) metadata = metadata.metadata;
|
|
if ("tag" in metadata) {
|
|
if (metadata.tag !== "v14" && metadata.tag !== "v15" && metadata.tag !== "v16")
|
|
throw new Error("Only metadata 14, 15, and 16 are supported");
|
|
metadata = metadata.value;
|
|
}
|
|
if ("signedExtensionsByVersion" in metadata.extrinsic) {
|
|
return { version: 16, ...metadata };
|
|
}
|
|
if ("custom" in metadata) {
|
|
const { lookup: lookup2, extrinsic: extrinsic2, custom, apis, pallets: pallets2, outerEnums } = metadata;
|
|
return {
|
|
version: 15,
|
|
lookup: lookup2,
|
|
pallets: pallets2.map((p) => ({
|
|
...p,
|
|
calls: p.calls != null ? { type: p.calls } : void 0,
|
|
events: p.events != null ? { type: p.events } : void 0,
|
|
errors: p.errors != null ? { type: p.errors } : void 0,
|
|
viewFns: [],
|
|
associatedTypes: []
|
|
})),
|
|
extrinsic: { ...extrinsic2, version: [extrinsic2.version] },
|
|
apis,
|
|
outerEnums,
|
|
custom
|
|
};
|
|
}
|
|
const { lookup, extrinsic, pallets } = metadata;
|
|
return {
|
|
version: 14,
|
|
lookup,
|
|
pallets: pallets.map((p) => ({
|
|
...p,
|
|
calls: p.calls != null ? { type: p.calls } : void 0,
|
|
events: p.events != null ? { type: p.events } : void 0,
|
|
errors: p.errors != null ? { type: p.errors } : void 0,
|
|
viewFns: [],
|
|
associatedTypes: []
|
|
})),
|
|
extrinsic: { ...extrinsic, version: [extrinsic.version] },
|
|
apis: []
|
|
};
|
|
};
|
|
|
|
export { unifyMetadata };
|
|
//# sourceMappingURL=unified.mjs.map
|