Remove nodeCompat (#1130)

This commit is contained in:
Jaco Greeff
2019-07-15 17:57:42 +02:00
committed by GitHub
parent 77932dccab
commit b77b3db235
2 changed files with 0 additions and 49 deletions
-3
View File
@@ -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);
-46
View File
@@ -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);
});
}