Remove nodeCompat (#1130)
This commit is contained in:
@@ -30,7 +30,6 @@ import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, isFunction, isObject, isUndefined, logger, u8aToHex } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
import injectNodeCompat from './nodeCompat';
|
||||
import createSubmittable, { SubmittableExtrinsic } from './SubmittableExtrinsic';
|
||||
import { decorateSections } from './util/decorate';
|
||||
|
||||
@@ -514,8 +513,6 @@ export default abstract class ApiBase<ApiType> {
|
||||
this._genesisHash = this._options.source.genesisHash;
|
||||
}
|
||||
|
||||
injectNodeCompat(this._runtimeVersion as RuntimeVersion);
|
||||
|
||||
const extrinsics = extrinsicsFromMeta(this.runtimeMetadata);
|
||||
const storage = storageFromMeta(this.runtimeMetadata);
|
||||
const constants = constantsFromMeta(this.runtimeMetadata);
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import { EventRecord0to76, RuntimeVersion, getTypeRegistry } from '@polkadot/types';
|
||||
|
||||
interface Compat {
|
||||
// an array of the spec-name and spec_version that denotes the first version that
|
||||
// does not support this feature. i.e. for EventRecord between 0-76, the new version
|
||||
// went live at 77 - hence the version here denotes 77
|
||||
nodeSpecs: [string, number][];
|
||||
types: {
|
||||
[index: string]: Constructor;
|
||||
};
|
||||
}
|
||||
|
||||
const ANY_VERSION = 0xffffff;
|
||||
|
||||
const types: Compat[] = [
|
||||
{
|
||||
nodeSpecs: [
|
||||
['node', 77],
|
||||
['polkadot', 1000],
|
||||
['node-template', ANY_VERSION]
|
||||
],
|
||||
types: {
|
||||
EventRecord: EventRecord0to76
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export default function injectNodeCompat ({ specName, specVersion }: RuntimeVersion): void {
|
||||
types
|
||||
.filter(({ nodeSpecs }): boolean =>
|
||||
nodeSpecs.some(([name, version]): boolean =>
|
||||
specName.eq(name) &&
|
||||
specVersion.ltn(version)
|
||||
)
|
||||
)
|
||||
.forEach(({ types }): void => {
|
||||
getTypeRegistry().register(types);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user