Remove deprecated types (up to metadata V5) (#1939)
This commit is contained in:
@@ -29,21 +29,21 @@ export function decodeLatestSubstrate<Modules extends Codec> (registry: Registry
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function toLatest<Modules extends Codec> (registry: Registry, version: number, rpcData: string): void {
|
||||
export function toLatest<Modules extends Codec> (registry: Registry, version: number, rpcData: string, withThrow = true): void {
|
||||
it(`converts v${version} to latest`, (): void => {
|
||||
const metadata = new Metadata(registry, rpcData)[`asV${version}` as keyof Metadata];
|
||||
const metadataLatest = new Metadata(registry, rpcData).asLatest;
|
||||
|
||||
expect(
|
||||
getUniqTypes(registry, metadata as unknown as MetadataInterface<Modules>, true)
|
||||
getUniqTypes(registry, metadata as unknown as MetadataInterface<Modules>, withThrow)
|
||||
).toEqual(
|
||||
getUniqTypes(registry, metadataLatest, true)
|
||||
getUniqTypes(registry, metadataLatest, withThrow)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function defaultValues (registry: Registry, rpcData: string): void {
|
||||
export function defaultValues (registry: Registry, rpcData: string, withThrow = true): void {
|
||||
describe('storage with default values', (): void => {
|
||||
const metadata = new Metadata(registry, rpcData);
|
||||
|
||||
@@ -56,11 +56,17 @@ export function defaultValues (registry: Registry, rpcData: string): void {
|
||||
|
||||
it(`creates default types for ${location}`, (): void => {
|
||||
expect(
|
||||
(): Codec => {
|
||||
(): void => {
|
||||
try {
|
||||
return createTypeUnsafe(registry, inner, [fallback]);
|
||||
createTypeUnsafe(registry, inner, [fallback]);
|
||||
} catch (error) {
|
||||
throw new Error(`${location}:: ${error.message}`);
|
||||
const message = `${location}:: ${error.message}`;
|
||||
|
||||
if (withThrow) {
|
||||
throw new Error(message);
|
||||
} else {
|
||||
console.warn(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
).not.toThrow();
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('Metadata', (): void => {
|
||||
}
|
||||
});
|
||||
|
||||
toLatest(registry, 0, rpcData);
|
||||
toLatest(registry, 0, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData);
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('MetadataV1', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 1, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 1, rpcData);
|
||||
toLatest(registry, 1, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData);
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('MetadataV2', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 2, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 2, rpcData);
|
||||
toLatest(registry, 2, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData);
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('MetadataV3', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 3, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 3, rpcData);
|
||||
toLatest(registry, 3, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData);
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('MetadataV4', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 4, rpcData, staticSubstrate);
|
||||
|
||||
toLatest(registry, 4, rpcData);
|
||||
toLatest(registry, 4, rpcData, false);
|
||||
|
||||
defaultValues(registry, rpcData);
|
||||
defaultValues(registry, rpcData, false);
|
||||
});
|
||||
|
||||
@@ -15,9 +15,9 @@ describe('MetadataV5 (substrate)', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 5, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 5, substrateData);
|
||||
toLatest(registry, 5, substrateData, false);
|
||||
|
||||
defaultValues(registry, substrateData);
|
||||
defaultValues(registry, substrateData, false);
|
||||
});
|
||||
|
||||
describe('MetadataV5 (polkadot)', (): void => {
|
||||
@@ -25,7 +25,7 @@ describe('MetadataV5 (polkadot)', (): void => {
|
||||
|
||||
decodeLatestSubstrate(registry, 5, polkadotData, polkadotJson);
|
||||
|
||||
toLatest(registry, 5, polkadotData);
|
||||
toLatest(registry, 5, polkadotData, false);
|
||||
|
||||
defaultValues(registry, polkadotData);
|
||||
defaultValues(registry, polkadotData, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user