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);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@ import { MemberCount, ProposalIndex, Votes } from '@polkadot/types/interfaces/co
|
||||
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import { Conviction, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { Amount, AssetOf, ContractAccountInfo, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from '@polkadot/types/interfaces/deprecated';
|
||||
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import { Account, Log } from '@polkadot/types/interfaces/evm';
|
||||
@@ -427,31 +426,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
ReferendumInfo: ReferendumInfo;
|
||||
'Option<ReferendumInfo>': Option<ReferendumInfo>;
|
||||
'Vec<ReferendumInfo>': Vec<ReferendumInfo>;
|
||||
NewAccountOutcome: NewAccountOutcome;
|
||||
'Option<NewAccountOutcome>': Option<NewAccountOutcome>;
|
||||
'Vec<NewAccountOutcome>': Vec<NewAccountOutcome>;
|
||||
Amount: Amount;
|
||||
'Option<Amount>': Option<Amount>;
|
||||
'Vec<Amount>': Vec<Amount>;
|
||||
AssetOf: AssetOf;
|
||||
'Compact<AssetOf>': Compact<AssetOf>;
|
||||
'Option<AssetOf>': Option<AssetOf>;
|
||||
'Vec<AssetOf>': Vec<AssetOf>;
|
||||
ContractAccountInfo: ContractAccountInfo;
|
||||
'Option<ContractAccountInfo>': Option<ContractAccountInfo>;
|
||||
'Vec<ContractAccountInfo>': Vec<ContractAccountInfo>;
|
||||
LockPeriods: LockPeriods;
|
||||
'Option<LockPeriods>': Option<LockPeriods>;
|
||||
'Vec<LockPeriods>': Vec<LockPeriods>;
|
||||
InherentOfflineReport: InherentOfflineReport;
|
||||
'Option<InherentOfflineReport>': Option<InherentOfflineReport>;
|
||||
'Vec<InherentOfflineReport>': Vec<InherentOfflineReport>;
|
||||
SessionKey: SessionKey;
|
||||
'Option<SessionKey>': Option<SessionKey>;
|
||||
'Vec<SessionKey>': Vec<SessionKey>;
|
||||
OpaqueKey: OpaqueKey;
|
||||
'Option<OpaqueKey>': Option<OpaqueKey>;
|
||||
'Vec<OpaqueKey>': Vec<OpaqueKey>;
|
||||
ApprovalFlag: ApprovalFlag;
|
||||
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
|
||||
'Option<ApprovalFlag>': Option<ApprovalFlag>;
|
||||
|
||||
@@ -14,7 +14,6 @@ export { default as collective } from './collective/definitions';
|
||||
export { default as consensus } from './consensus/definitions';
|
||||
export { default as contracts } from './contracts/definitions';
|
||||
export { default as democracy } from './democracy/definitions';
|
||||
export { default as deprecated } from './deprecated/definitions';
|
||||
export { default as elections } from './elections/definitions';
|
||||
export { default as engine } from './engine/definitions';
|
||||
export { default as evm } from './evm/definitions';
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
// Metadata v0
|
||||
NewAccountOutcome: {
|
||||
_enum: ['NoHint', 'GoodHint', 'BadHint']
|
||||
},
|
||||
|
||||
// Metadata v1
|
||||
// :: fees
|
||||
Amount: 'Balance',
|
||||
AssetOf: 'u32',
|
||||
|
||||
// Metadata v2
|
||||
// :: contracts
|
||||
ContractAccountInfo: {
|
||||
trieId: 'Bytes',
|
||||
currentMemStored: 'u64'
|
||||
},
|
||||
|
||||
// Metadata v3
|
||||
// :: democracy
|
||||
LockPeriods: 'i8',
|
||||
|
||||
// Metadata v4
|
||||
// :: consensus
|
||||
InherentOfflineReport: '()',
|
||||
SessionKey: 'AccountId',
|
||||
|
||||
// Metadata v5
|
||||
// :: session
|
||||
OpaqueKey: 'Bytes'
|
||||
}
|
||||
};
|
||||
@@ -1,4 +0,0 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
export * from './types';
|
||||
@@ -1,38 +0,0 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { Enum, Struct } from '@polkadot/types/codec';
|
||||
import { Bytes, i8, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name Amount */
|
||||
export interface Amount extends Balance {}
|
||||
|
||||
/** @name AssetOf */
|
||||
export interface AssetOf extends u32 {}
|
||||
|
||||
/** @name ContractAccountInfo */
|
||||
export interface ContractAccountInfo extends Struct {
|
||||
readonly trieId: Bytes;
|
||||
readonly currentMemStored: u64;
|
||||
}
|
||||
|
||||
/** @name InherentOfflineReport */
|
||||
export interface InherentOfflineReport extends ITuple<[]> {}
|
||||
|
||||
/** @name LockPeriods */
|
||||
export interface LockPeriods extends i8 {}
|
||||
|
||||
/** @name NewAccountOutcome */
|
||||
export interface NewAccountOutcome extends Enum {
|
||||
readonly isNoHint: boolean;
|
||||
readonly isGoodHint: boolean;
|
||||
readonly isBadHint: boolean;
|
||||
}
|
||||
|
||||
/** @name OpaqueKey */
|
||||
export interface OpaqueKey extends Bytes {}
|
||||
|
||||
/** @name SessionKey */
|
||||
export interface SessionKey extends AccountId {}
|
||||
@@ -10,7 +10,6 @@ export * from './collective/types';
|
||||
export * from './consensus/types';
|
||||
export * from './contracts/types';
|
||||
export * from './democracy/types';
|
||||
export * from './deprecated/types';
|
||||
export * from './elections/types';
|
||||
export * from './engine/types';
|
||||
export * from './evm/types';
|
||||
|
||||
Reference in New Issue
Block a user