Check and match both specName/specVersion for registries (#3820)
This commit is contained in:
@@ -31,11 +31,13 @@ function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<s
|
||||
const modules = metadata.asLatest.modules;
|
||||
|
||||
// decorate the errors
|
||||
modules.forEach((section, _sectionIndex): void => {
|
||||
const sectionIndex = metadata.version >= 12 ? section.index.toNumber() : _sectionIndex;
|
||||
const sectionName = stringCamelCase(section.name);
|
||||
modules.forEach(({ errors, index, name }, _sectionIndex): void => {
|
||||
const sectionIndex = metadata.version >= 12
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const sectionName = stringCamelCase(name);
|
||||
|
||||
section.errors.forEach(({ docs, name }, index): void => {
|
||||
errors.forEach(({ docs, name }, index): void => {
|
||||
const eventIndex = new Uint8Array([sectionIndex, index]);
|
||||
|
||||
metadataErrors[u8aToHex(eventIndex)] = {
|
||||
@@ -54,13 +56,13 @@ function injectEvents (registry: Registry, metadata: Metadata, metadataEvents: R
|
||||
// decorate the events
|
||||
metadata.asLatest.modules
|
||||
.filter(({ events }) => events.isSome)
|
||||
.forEach((section, _sectionIndex): void => {
|
||||
.forEach(({ events, index, name }, _sectionIndex): void => {
|
||||
const sectionIndex = metadata.version >= 12
|
||||
? section.index.toNumber()
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const sectionName = stringCamelCase(section.name);
|
||||
const sectionName = stringCamelCase(name);
|
||||
|
||||
section.events.unwrap().forEach((meta, methodIndex): void => {
|
||||
events.unwrap().forEach((meta, methodIndex): void => {
|
||||
const methodName = meta.name.toString();
|
||||
const typeDef = meta.args.map((arg) => getTypeDef(arg));
|
||||
let Types: Constructor<Codec>[] | null = null;
|
||||
|
||||
@@ -18,7 +18,9 @@ export function decorateErrors (_: Registry, { modules }: MetadataLatest, metaVe
|
||||
return result;
|
||||
}
|
||||
|
||||
const sectionIndex = metaVersion >= 12 ? index.toNumber() : _sectionIndex;
|
||||
const sectionIndex = metaVersion >= 12
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
|
||||
result[stringCamelCase(name)] = errors.reduce((newModule: ModuleErrors, meta, errorIndex): ModuleErrors => {
|
||||
// we don't camelCase the error name
|
||||
|
||||
@@ -16,7 +16,9 @@ export function decorateEvents (_: Registry, { modules }: MetadataLatest, metaVe
|
||||
return modules
|
||||
.filter(({ events }) => events.isSome)
|
||||
.reduce((result: Events, { events, index, name }, _sectionIndex): Events => {
|
||||
const sectionIndex = metaVersion >= 12 ? index.toNumber() : _sectionIndex;
|
||||
const sectionIndex = metaVersion >= 12
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
|
||||
result[stringCamelCase(name)] = events.unwrap().reduce((newModule: ModuleEvents, meta, eventIndex): ModuleEvents => {
|
||||
// we don't camelCase the event name
|
||||
|
||||
@@ -14,7 +14,9 @@ export function decorateExtrinsics (registry: Registry, { modules }: MetadataLat
|
||||
return modules
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.reduce((result: Extrinsics, { calls, index, name }, _sectionIndex): Extrinsics => {
|
||||
const sectionIndex = metaVersion >= 12 ? index.toNumber() : _sectionIndex;
|
||||
const sectionIndex = metaVersion >= 12
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: ModuleExtrinsics, callMetadata, methodIndex): ModuleExtrinsics => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { Registry } from '../../types';
|
||||
* @internal
|
||||
**/
|
||||
export function toV12 (registry: Registry, { extrinsic, modules }: MetadataV11): MetadataV12 {
|
||||
return registry.createType('MetadataLatest', {
|
||||
return registry.createType('MetadataV12', {
|
||||
extrinsic,
|
||||
modules: modules.map((mod): ModuleMetadataV12 =>
|
||||
registry.createType('ModuleMetadataV12', {
|
||||
|
||||
Reference in New Issue
Block a user