Adjust scale-info types (updated v14, contracts rename) (#3776)

* Adjust scale-info types (updated v14, contracts rename)

* Adjust v14 metadata

* PortableRegistry -> lookup

* Rewrite json
This commit is contained in:
Jaco
2021-07-16 13:57:44 +02:00
committed by GitHub
parent 311740a1a2
commit d62bfc55ac
14 changed files with 37919 additions and 73064 deletions
+54 -9
View File
@@ -32,7 +32,7 @@ import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, A
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableType, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
@@ -44,7 +44,7 @@ import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { SiField, SiLookupTypeId, SiPath, SiType, SiType0, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPhantom, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
@@ -126,7 +126,7 @@ declare module '@polkadot/types/types/registry' {
'Compact<SessionIndex>': Compact<SessionIndex>;
'Compact<SetId>': Compact<SetId>;
'Compact<SetIndex>': Compact<SetIndex>;
'Compact<SiLookupTypeId>': Compact<SiLookupTypeId>;
'Compact<Si0LookupTypeId>': Compact<Si0LookupTypeId>;
'Compact<Slot>': Compact<Slot>;
'Compact<SlotNumber>': Compact<SlotNumber>;
'Compact<SpanIndex>': Compact<SpanIndex>;
@@ -731,6 +731,7 @@ declare module '@polkadot/types/types/registry' {
'Option<PluralityJunction>': Option<PluralityJunction>;
'Option<Points>': Option<Points>;
'Option<PortableRegistry>': Option<PortableRegistry>;
'Option<PortableType>': Option<PortableType>;
'Option<Precommits>': Option<Precommits>;
'Option<PrefabWasmModule>': Option<PrefabWasmModule>;
'Option<PrefixedStorageKey>': Option<PrefixedStorageKey>;
@@ -841,6 +842,22 @@ declare module '@polkadot/types/types/registry' {
'Option<SessionKeys9B>': Option<SessionKeys9B>;
'Option<SetId>': Option<SetId>;
'Option<SetIndex>': Option<SetIndex>;
'Option<Si0Field>': Option<Si0Field>;
'Option<Si0LookupTypeId>': Option<Si0LookupTypeId>;
'Option<Si0Path>': Option<Si0Path>;
'Option<Si0Type>': Option<Si0Type>;
'Option<Si0TypeDef>': Option<Si0TypeDef>;
'Option<Si0TypeDefArray>': Option<Si0TypeDefArray>;
'Option<Si0TypeDefBitSequence>': Option<Si0TypeDefBitSequence>;
'Option<Si0TypeDefCompact>': Option<Si0TypeDefCompact>;
'Option<Si0TypeDefComposite>': Option<Si0TypeDefComposite>;
'Option<Si0TypeDefPhantom>': Option<Si0TypeDefPhantom>;
'Option<Si0TypeDefPrimitive>': Option<Si0TypeDefPrimitive>;
'Option<Si0TypeDefSequence>': Option<Si0TypeDefSequence>;
'Option<Si0TypeDefTuple>': Option<Si0TypeDefTuple>;
'Option<Si0TypeDefVariant>': Option<Si0TypeDefVariant>;
'Option<Si0TypeParameter>': Option<Si0TypeParameter>;
'Option<Si0Variant>': Option<Si0Variant>;
'Option<SiField>': Option<SiField>;
'Option<Signature>': Option<Signature>;
'Option<SignedAvailabilityBitfield>': Option<SignedAvailabilityBitfield>;
@@ -857,13 +874,11 @@ declare module '@polkadot/types/types/registry' {
'Option<SiLookupTypeId>': Option<SiLookupTypeId>;
'Option<SiPath>': Option<SiPath>;
'Option<SiType>': Option<SiType>;
'Option<SiType0>': Option<SiType0>;
'Option<SiTypeDef>': Option<SiTypeDef>;
'Option<SiTypeDefArray>': Option<SiTypeDefArray>;
'Option<SiTypeDefBitSequence>': Option<SiTypeDefBitSequence>;
'Option<SiTypeDefCompact>': Option<SiTypeDefCompact>;
'Option<SiTypeDefComposite>': Option<SiTypeDefComposite>;
'Option<SiTypeDefPhantom>': Option<SiTypeDefPhantom>;
'Option<SiTypeDefPrimitive>': Option<SiTypeDefPrimitive>;
'Option<SiTypeDefSequence>': Option<SiTypeDefSequence>;
'Option<SiTypeDefTuple>': Option<SiTypeDefTuple>;
@@ -1627,6 +1642,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<PluralityJunction>': Vec<PluralityJunction>;
'Vec<Points>': Vec<Points>;
'Vec<PortableRegistry>': Vec<PortableRegistry>;
'Vec<PortableType>': Vec<PortableType>;
'Vec<Precommits>': Vec<Precommits>;
'Vec<PrefabWasmModule>': Vec<PrefabWasmModule>;
'Vec<PrefixedStorageKey>': Vec<PrefixedStorageKey>;
@@ -1737,6 +1753,22 @@ declare module '@polkadot/types/types/registry' {
'Vec<SessionKeys9B>': Vec<SessionKeys9B>;
'Vec<SetId>': Vec<SetId>;
'Vec<SetIndex>': Vec<SetIndex>;
'Vec<Si0Field>': Vec<Si0Field>;
'Vec<Si0LookupTypeId>': Vec<Si0LookupTypeId>;
'Vec<Si0Path>': Vec<Si0Path>;
'Vec<Si0Type>': Vec<Si0Type>;
'Vec<Si0TypeDef>': Vec<Si0TypeDef>;
'Vec<Si0TypeDefArray>': Vec<Si0TypeDefArray>;
'Vec<Si0TypeDefBitSequence>': Vec<Si0TypeDefBitSequence>;
'Vec<Si0TypeDefCompact>': Vec<Si0TypeDefCompact>;
'Vec<Si0TypeDefComposite>': Vec<Si0TypeDefComposite>;
'Vec<Si0TypeDefPhantom>': Vec<Si0TypeDefPhantom>;
'Vec<Si0TypeDefPrimitive>': Vec<Si0TypeDefPrimitive>;
'Vec<Si0TypeDefSequence>': Vec<Si0TypeDefSequence>;
'Vec<Si0TypeDefTuple>': Vec<Si0TypeDefTuple>;
'Vec<Si0TypeDefVariant>': Vec<Si0TypeDefVariant>;
'Vec<Si0TypeParameter>': Vec<Si0TypeParameter>;
'Vec<Si0Variant>': Vec<Si0Variant>;
'Vec<SiField>': Vec<SiField>;
'Vec<Signature>': Vec<Signature>;
'Vec<SignedAvailabilityBitfield>': Vec<SignedAvailabilityBitfield>;
@@ -1753,13 +1785,11 @@ declare module '@polkadot/types/types/registry' {
'Vec<SiLookupTypeId>': Vec<SiLookupTypeId>;
'Vec<SiPath>': Vec<SiPath>;
'Vec<SiType>': Vec<SiType>;
'Vec<SiType0>': Vec<SiType0>;
'Vec<SiTypeDef>': Vec<SiTypeDef>;
'Vec<SiTypeDefArray>': Vec<SiTypeDefArray>;
'Vec<SiTypeDefBitSequence>': Vec<SiTypeDefBitSequence>;
'Vec<SiTypeDefCompact>': Vec<SiTypeDefCompact>;
'Vec<SiTypeDefComposite>': Vec<SiTypeDefComposite>;
'Vec<SiTypeDefPhantom>': Vec<SiTypeDefPhantom>;
'Vec<SiTypeDefPrimitive>': Vec<SiTypeDefPrimitive>;
'Vec<SiTypeDefSequence>': Vec<SiTypeDefSequence>;
'Vec<SiTypeDefTuple>': Vec<SiTypeDefTuple>;
@@ -2523,6 +2553,7 @@ declare module '@polkadot/types/types/registry' {
PluralityJunction: PluralityJunction;
Points: Points;
PortableRegistry: PortableRegistry;
PortableType: PortableType;
Precommits: Precommits;
PrefabWasmModule: PrefabWasmModule;
PrefixedStorageKey: PrefixedStorageKey;
@@ -2633,6 +2664,22 @@ declare module '@polkadot/types/types/registry' {
SessionKeys9B: SessionKeys9B;
SetId: SetId;
SetIndex: SetIndex;
Si0Field: Si0Field;
Si0LookupTypeId: Si0LookupTypeId;
Si0Path: Si0Path;
Si0Type: Si0Type;
Si0TypeDef: Si0TypeDef;
Si0TypeDefArray: Si0TypeDefArray;
Si0TypeDefBitSequence: Si0TypeDefBitSequence;
Si0TypeDefCompact: Si0TypeDefCompact;
Si0TypeDefComposite: Si0TypeDefComposite;
Si0TypeDefPhantom: Si0TypeDefPhantom;
Si0TypeDefPrimitive: Si0TypeDefPrimitive;
Si0TypeDefSequence: Si0TypeDefSequence;
Si0TypeDefTuple: Si0TypeDefTuple;
Si0TypeDefVariant: Si0TypeDefVariant;
Si0TypeParameter: Si0TypeParameter;
Si0Variant: Si0Variant;
SiField: SiField;
Signature: Signature;
SignedAvailabilityBitfield: SignedAvailabilityBitfield;
@@ -2649,13 +2696,11 @@ declare module '@polkadot/types/types/registry' {
SiLookupTypeId: SiLookupTypeId;
SiPath: SiPath;
SiType: SiType;
SiType0: SiType0;
SiTypeDef: SiTypeDef;
SiTypeDefArray: SiTypeDefArray;
SiTypeDefBitSequence: SiTypeDefBitSequence;
SiTypeDefCompact: SiTypeDefCompact;
SiTypeDefComposite: SiTypeDefComposite;
SiTypeDefPhantom: SiTypeDefPhantom;
SiTypeDefPrimitive: SiTypeDefPrimitive;
SiTypeDefSequence: SiTypeDefSequence;
SiTypeDefTuple: SiTypeDefTuple;
@@ -19,7 +19,7 @@ const layout = {
},
ContractLayoutCell: {
key: 'ContractLayoutKey',
ty: 'SiLookupTypeId'
ty: 'Si0LookupTypeId'
},
ContractLayoutEnum: {
dispatchKey: 'ContractLayoutKey',
@@ -67,7 +67,7 @@ const spec = {
events: 'Vec<ContractEventSpec>',
docs: 'Vec<Text>'
},
ContractDisplayName: 'SiPath',
ContractDisplayName: 'Si0Path',
ContractEventParamSpec: {
name: 'Text',
indexed: 'bool',
@@ -94,7 +94,7 @@ const spec = {
},
ContractSelector: '[u8; 4]',
ContractTypeSpec: {
type: 'SiLookupTypeId',
type: 'Si0LookupTypeId',
displayName: 'ContractDisplayName'
}
};
@@ -110,8 +110,8 @@ export default {
source: 'ContractProjectSource',
contract: 'ContractProjectContract',
// expanded scale registry: RegistryReadOnly
// NOTE Previous generation of the SiType definition
types: 'Vec<SiType0>',
// NOTE Previous generation of the Si0Type definition
types: 'Vec<Si0Type>',
// renamed from layout (ignored for now, incomplete)
// storage: 'ContractStorageLayout',
spec: 'ContractContractSpec'
@@ -2,7 +2,7 @@
/* eslint-disable */
import type { BTreeMap, Bytes, Enum, Option, Raw, Struct, Text, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { SiLookupTypeId, SiPath, SiType0 } from '@polkadot/types/interfaces/scaleInfo';
import type { Si0LookupTypeId, Si0Path, Si0Type } from '@polkadot/types/interfaces/scaleInfo';
/** @name ContractConstructorSpec */
export interface ContractConstructorSpec extends Struct {
@@ -31,7 +31,7 @@ export interface ContractCryptoHasher extends Enum {
export interface ContractDiscriminant extends u32 {}
/** @name ContractDisplayName */
export interface ContractDisplayName extends SiPath {}
export interface ContractDisplayName extends Si0Path {}
/** @name ContractEventParamSpec */
export interface ContractEventParamSpec extends Struct {
@@ -59,7 +59,7 @@ export interface ContractLayoutArray extends Struct {
/** @name ContractLayoutCell */
export interface ContractLayoutCell extends Struct {
readonly key: ContractLayoutKey;
readonly ty: SiLookupTypeId;
readonly ty: Si0LookupTypeId;
}
/** @name ContractLayoutEnum */
@@ -118,7 +118,7 @@ export interface ContractProject extends Struct {
readonly metadataVersion: Text;
readonly source: ContractProjectSource;
readonly contract: ContractProjectContract;
readonly types: Vec<SiType0>;
readonly types: Vec<Si0Type>;
readonly spec: ContractContractSpec;
}
@@ -161,7 +161,7 @@ export interface ContractStorageLayout extends Enum {
/** @name ContractTypeSpec */
export interface ContractTypeSpec extends Struct {
readonly type: SiLookupTypeId;
readonly type: Si0LookupTypeId;
readonly displayName: ContractDisplayName;
}
@@ -156,7 +156,7 @@ export interface MetadataV13 extends Struct {
/** @name MetadataV14 */
export interface MetadataV14 extends Struct {
readonly types: PortableRegistry;
readonly lookup: PortableRegistry;
readonly pallets: Vec<PalletMetadataV14>;
readonly extrinsic: ExtrinsicMetadataV14;
}
@@ -304,7 +304,13 @@ export interface PalletStorageMetadataV14 extends Struct {
/** @name PortableRegistry */
export interface PortableRegistry extends Struct {
readonly types: Vec<SiType>;
readonly types: Vec<PortableType>;
}
/** @name PortableType */
export interface PortableType extends Struct {
readonly id: SiLookupTypeId;
readonly type: SiType;
}
/** @name SignedExtensionMetadataLatest */
@@ -9,7 +9,11 @@ import type { DefinitionsTypes } from '../../types';
export const v14: DefinitionsTypes = {
// registry
PortableRegistry: {
types: 'Vec<SiType>'
types: 'Vec<PortableType>'
},
PortableType: {
id: 'SiLookupTypeId',
type: 'SiType'
},
// V14
@@ -19,7 +23,7 @@ export const v14: DefinitionsTypes = {
signedExtensions: 'Vec<SignedExtensionMetadataV14>'
},
MetadataV14: {
types: 'PortableRegistry',
lookup: 'PortableRegistry',
pallets: 'Vec<PalletMetadataV14>',
extrinsic: 'ExtrinsicMetadataV14'
},
@@ -3,19 +3,22 @@
import type { Definitions } from '../../types';
import { v0 } from './v0';
// order important in structs... :)
/* eslint-disable sort-keys */
export default {
rpc: {},
types: {
...v0,
SiField: {
name: 'Option<Text>',
type: 'SiLookupTypeId',
typeName: 'Option<Text>',
docs: 'Vec<Text>'
},
SiLookupTypeId: 'u32',
SiLookupTypeId: 'Compact<u32>',
SiPath: 'Vec<Text>',
SiType: {
path: 'SiPath',
@@ -23,11 +26,6 @@ export default {
def: 'SiTypeDef',
docs: 'Vec<Text>'
},
SiType0: {
path: 'SiPath',
params: 'Vec<SiLookupTypeId>',
def: 'SiTypeDef'
},
SiTypeDef: {
_enum: {
Composite: 'SiTypeDefComposite',
@@ -37,7 +35,6 @@ export default {
Tuple: 'SiTypeDefTuple',
Primitive: 'SiTypeDefPrimitive',
Compact: 'SiTypeDefCompact',
Phantom: 'SiTypeDefPhantom',
BitSequence: 'SiTypeDefBitSequence',
// NOTE: This is specific to the implementation for pre-v14 metadata
// compatibility (always keep this as the last entry in the enum)
@@ -58,7 +55,6 @@ export default {
SiTypeDefComposite: {
fields: 'Vec<SiField>'
},
SiTypeDefPhantom: 'Null',
SiTypeDefVariant: {
variants: 'Vec<SiVariant>'
},
@@ -76,8 +72,7 @@ export default {
SiVariant: {
name: 'Text',
fields: 'Vec<SiField>',
index: 'Option<u8>',
discriminant: 'Option<u64>',
index: 'u8',
docs: 'Vec<Text>'
}
}
+118 -16
View File
@@ -1,7 +1,122 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Enum, Null, Option, Struct, Text, Type, Vec, u32, u64, u8 } from '@polkadot/types';
import type { Compact, Enum, Null, Option, Struct, Text, Type, Vec, u32, u64, u8 } from '@polkadot/types';
/** @name Si0Field */
export interface Si0Field extends Struct {
readonly name: Option<Text>;
readonly type: Si0LookupTypeId;
readonly typeName: Option<Text>;
readonly docs: Vec<Text>;
}
/** @name Si0LookupTypeId */
export interface Si0LookupTypeId extends u32 {}
/** @name Si0Path */
export interface Si0Path extends Vec<Text> {}
/** @name Si0Type */
export interface Si0Type extends Struct {
readonly path: Si0Path;
readonly params: Vec<Si0LookupTypeId>;
readonly def: Si0TypeDef;
}
/** @name Si0TypeDef */
export interface Si0TypeDef extends Enum {
readonly isComposite: boolean;
readonly asComposite: Si0TypeDefComposite;
readonly isVariant: boolean;
readonly asVariant: Si0TypeDefVariant;
readonly isSequence: boolean;
readonly asSequence: Si0TypeDefSequence;
readonly isArray: boolean;
readonly asArray: Si0TypeDefArray;
readonly isTuple: boolean;
readonly asTuple: Si0TypeDefTuple;
readonly isPrimitive: boolean;
readonly asPrimitive: Si0TypeDefPrimitive;
readonly isCompact: boolean;
readonly asCompact: Si0TypeDefCompact;
readonly isPhantom: boolean;
readonly asPhantom: Si0TypeDefPhantom;
readonly isBitSequence: boolean;
readonly asBitSequence: Si0TypeDefBitSequence;
}
/** @name Si0TypeDefArray */
export interface Si0TypeDefArray extends Struct {
readonly len: u32;
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefBitSequence */
export interface Si0TypeDefBitSequence extends Struct {
readonly bitStoreType: Si0LookupTypeId;
readonly bitOrderType: Si0LookupTypeId;
}
/** @name Si0TypeDefCompact */
export interface Si0TypeDefCompact extends Struct {
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefComposite */
export interface Si0TypeDefComposite extends Struct {
readonly fields: Vec<Si0Field>;
}
/** @name Si0TypeDefPhantom */
export interface Si0TypeDefPhantom extends Null {}
/** @name Si0TypeDefPrimitive */
export interface Si0TypeDefPrimitive extends Enum {
readonly isBool: boolean;
readonly isChar: boolean;
readonly isStr: boolean;
readonly isU8: boolean;
readonly isU16: boolean;
readonly isU32: boolean;
readonly isU64: boolean;
readonly isU128: boolean;
readonly isU256: boolean;
readonly isI8: boolean;
readonly isI16: boolean;
readonly isI32: boolean;
readonly isI64: boolean;
readonly isI128: boolean;
readonly isI256: boolean;
}
/** @name Si0TypeDefSequence */
export interface Si0TypeDefSequence extends Struct {
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefTuple */
export interface Si0TypeDefTuple extends Vec<Si0LookupTypeId> {}
/** @name Si0TypeDefVariant */
export interface Si0TypeDefVariant extends Struct {
readonly variants: Vec<Si0Variant>;
}
/** @name Si0TypeParameter */
export interface Si0TypeParameter extends Struct {
readonly name: Text;
readonly type: Option<Si0LookupTypeId>;
}
/** @name Si0Variant */
export interface Si0Variant extends Struct {
readonly name: Text;
readonly fields: Vec<Si0Field>;
readonly index: Option<u8>;
readonly discriminant: Option<u64>;
readonly docs: Vec<Text>;
}
/** @name SiField */
export interface SiField extends Struct {
@@ -12,7 +127,7 @@ export interface SiField extends Struct {
}
/** @name SiLookupTypeId */
export interface SiLookupTypeId extends u32 {}
export interface SiLookupTypeId extends Compact<u32> {}
/** @name SiPath */
export interface SiPath extends Vec<Text> {}
@@ -25,13 +140,6 @@ export interface SiType extends Struct {
readonly docs: Vec<Text>;
}
/** @name SiType0 */
export interface SiType0 extends Struct {
readonly path: SiPath;
readonly params: Vec<SiLookupTypeId>;
readonly def: SiTypeDef;
}
/** @name SiTypeDef */
export interface SiTypeDef extends Enum {
readonly isComposite: boolean;
@@ -48,8 +156,6 @@ export interface SiTypeDef extends Enum {
readonly asPrimitive: SiTypeDefPrimitive;
readonly isCompact: boolean;
readonly asCompact: SiTypeDefCompact;
readonly isPhantom: boolean;
readonly asPhantom: SiTypeDefPhantom;
readonly isBitSequence: boolean;
readonly asBitSequence: SiTypeDefBitSequence;
readonly isHistoricMetaCompat: boolean;
@@ -78,9 +184,6 @@ export interface SiTypeDefComposite extends Struct {
readonly fields: Vec<SiField>;
}
/** @name SiTypeDefPhantom */
export interface SiTypeDefPhantom extends Null {}
/** @name SiTypeDefPrimitive */
export interface SiTypeDefPrimitive extends Enum {
readonly isBool: boolean;
@@ -123,8 +226,7 @@ export interface SiTypeParameter extends Struct {
export interface SiVariant extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly index: Option<u8>;
readonly discriminant: Option<u64>;
readonly index: u8;
readonly docs: Vec<Text>;
}
@@ -0,0 +1,72 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsTypes } from '../../types';
// order important in structs... :)
/* eslint-disable sort-keys */
export const v0: DefinitionsTypes = {
Si0Field: {
name: 'Option<Text>',
type: 'Si0LookupTypeId',
typeName: 'Option<Text>',
docs: 'Vec<Text>'
},
Si0LookupTypeId: 'u32',
Si0Path: 'Vec<Text>',
Si0Type: {
path: 'Si0Path',
params: 'Vec<Si0LookupTypeId>',
def: 'Si0TypeDef'
},
Si0TypeDef: {
_enum: {
Composite: 'Si0TypeDefComposite',
Variant: 'Si0TypeDefVariant',
Sequence: 'Si0TypeDefSequence',
Array: 'Si0TypeDefArray',
Tuple: 'Si0TypeDefTuple',
Primitive: 'Si0TypeDefPrimitive',
Compact: 'Si0TypeDefCompact',
Phantom: 'Si0TypeDefPhantom',
BitSequence: 'Si0TypeDefBitSequence'
}
},
Si0TypeDefArray: {
len: 'u32',
type: 'Si0LookupTypeId'
},
Si0TypeDefBitSequence: {
bitStoreType: 'Si0LookupTypeId',
bitOrderType: 'Si0LookupTypeId'
},
Si0TypeDefCompact: {
type: 'Si0LookupTypeId'
},
Si0TypeDefComposite: {
fields: 'Vec<Si0Field>'
},
Si0TypeDefPhantom: 'Null',
Si0TypeDefVariant: {
variants: 'Vec<Si0Variant>'
},
Si0TypeDefPrimitive: {
_enum: ['Bool', 'Char', 'Str', 'U8', 'U16', 'U32', 'U64', 'U128', 'U256', 'I8', 'I16', 'I32', 'I64', 'I128', 'I256']
},
Si0TypeDefSequence: {
type: 'Si0LookupTypeId'
},
Si0TypeDefTuple: 'Vec<Si0LookupTypeId>',
Si0TypeParameter: {
name: 'Text',
type: 'Option<Si0LookupTypeId>'
},
Si0Variant: {
name: 'Text',
fields: 'Vec<Si0Field>',
index: 'Option<u8>',
discriminant: 'Option<u64>',
docs: 'Vec<Text>'
}
};
@@ -6,21 +6,42 @@ import type { MetadataAll } from '../../interfaces/metadata';
import { TypeRegistry } from '../../create';
import { Metadata } from '../Metadata';
import substrateData from './static';
import substrateJson from './static-substrate.json';
import substrateTypes from './static-types.json';
describe('MetadataV14 (substrate)', (): void => {
// FIXME This is to be replaced with the proper version (here as a stop-gap)
it('parses', (): void => {
const registry = new TypeRegistry();
const metadata = new Metadata(registry, substrateData);
const all = metadata.get('metadata') as MetadataAll;
const v14 = all.asV14;
const jsonStruct = v14.toJSON();
const jsonTypes = v14.lookup.types.toJSON();
expect(all).toBeDefined();
delete (jsonStruct as Record<string, unknown>).lookup;
// console.error(JSON.stringify(all.toJSON()));
// console.error(JSON.stringify(
// all.asV14.types.types.map((t, __INDEX) => ({
// __INDEX,
// ...t.toJSON()
// }))
// ));
const allJson = {
magicNumber: 1635018093,
metadata: {
v14: jsonStruct
}
};
try {
expect(allJson).toEqual(substrateJson);
} catch (error) {
console.error(JSON.stringify(allJson));
throw error;
}
try {
expect(jsonTypes).toEqual(substrateTypes);
} catch (error) {
console.error(JSON.stringify(jsonTypes));
throw error;
}
});
});
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long