Only apply hack if exactly metadata from kusama 1032 (#1695)

This commit is contained in:
Amaury Martiny
2020-01-03 12:05:27 +01:00
committed by GitHub
parent 1ca3b295a4
commit 774f41e6db
5 changed files with 6652 additions and 3 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ import { Registry } from '@polkadot/types/types';
import { bnToU8a, isHex, hexToU8a, u8aConcat } from '@polkadot/util';
import hackKusama1032 from './v10/static.polkadot';
import { MAGIC_NUMBER } from './MagicNumber';
import MetadataVersioned from './MetadataVersioned';
@@ -28,9 +29,9 @@ export default class Metadata extends MetadataVersioned {
* There was a fk-up in the metadata upgrade process: Kusama's metadata got
* updated to a non-backward-compatible way, but the metadata version
* stayed at v9. Then v10 was merged in Substrate but not Kusama. Here,
* we're just saying that if it's a v9 metadata, decode as v10.
* we're just saying that if it's Kusama's metadata, decode as v10.
*/
if (isHex(_value) && _value.startsWith('0x6d65746109')) {
if (isHex(_value) && _value === hackKusama1032) {
return Metadata.decodeMetadata(registry, _value.replace('0x6d65746109', '0x6d6574610a'));
}
@@ -4,7 +4,9 @@
import { TypeRegistry } from '@polkadot/types';
import polkadotJson from './static-polkadot.json';
import substrateJson from './static-substrate.json';
import polkadotData from './static.polkadot';
import substrateData from './static';
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
@@ -17,3 +19,13 @@ describe('MetadataV10 (substrate)', (): void => {
defaultValues(registry, substrateData);
});
describe('MetadataV10 (polkadot)', (): void => {
const registry = new TypeRegistry();
decodeLatestSubstrate(registry, 10, polkadotData, polkadotJson);
toLatest(registry, 10, polkadotData);
defaultValues(registry, polkadotData);
});
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ import substrateJson from './static-substrate.json';
import substrateData from './static';
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
describe.skip('MetadataV9 (substrate)', (): void => {
describe('MetadataV9 (substrate)', (): void => {
const registry = new TypeRegistry();
decodeLatestSubstrate(registry, 9, substrateData, substrateJson);