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
+1 -1
View File
@@ -49,7 +49,7 @@ export class Abi {
this.registry.setMetaTypes(this.project.types); this.registry.setMetaTypes(this.project.types);
this.project.types.forEach((_, index) => this.project.types.forEach((_, index) =>
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) }) this.registry.getMetaTypeDef({ type: this.registry.createType('Si0LookupTypeId', index + this.registry.typeOffset) })
); );
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) => this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
this.#createMessage(spec, index, { this.#createMessage(spec, index, {
+16 -16
View File
@@ -1,19 +1,19 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors // Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType0, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces'; import type { ChainProperties, ContractDisplayName, Si0Field, Si0LookupTypeId, Si0Type, Si0TypeDefArray, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0Variant } from '@polkadot/types/interfaces';
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types'; import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
import { TypeDefInfo, TypeRegistry, withTypeString } from '@polkadot/types'; import { TypeDefInfo, TypeRegistry, withTypeString } from '@polkadot/types';
import { assert, isUndefined } from '@polkadot/util'; import { assert, isUndefined } from '@polkadot/util';
interface PartialTypeSpec { interface PartialTypeSpec {
readonly type: SiLookupTypeId; readonly type: Si0LookupTypeId;
readonly displayName?: ContractDisplayName; readonly displayName?: ContractDisplayName;
} }
// convert the offset into project-specific, index-1 // convert the offset into project-specific, index-1
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number { export function getRegistryOffset (id: Si0LookupTypeId, typeOffset: number): number {
return id.toNumber() - typeOffset; return id.toNumber() - typeOffset;
} }
@@ -29,7 +29,7 @@ export class MetaRegistry extends TypeRegistry {
public readonly typeOffset; public readonly typeOffset;
#siTypes: SiType0[] = []; #siTypes: Si0Type[] = [];
constructor (metadataVersion: string, chainProperties?: ChainProperties) { constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super(); super();
@@ -44,7 +44,7 @@ export class MetaRegistry extends TypeRegistry {
} }
} }
public setMetaTypes (metaTypes: SiType0[]): void { public setMetaTypes (metaTypes: Si0Type[]): void {
this.#siTypes = metaTypes; this.#siTypes = metaTypes;
} }
@@ -83,15 +83,15 @@ export class MetaRegistry extends TypeRegistry {
return typeDef; return typeDef;
} }
#getMetaType = (id: SiLookupTypeId): SiType0 => { #getMetaType = (id: Si0LookupTypeId): Si0Type => {
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)]; const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`); assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
return this.createType('SiType0', type); return this.createType('Si0Type', type);
} }
#extract = (type: SiType0, id: SiLookupTypeId): TypeDef => { #extract = (type: Si0Type, id: Si0LookupTypeId): TypeDef => {
const path = [...type.path]; const path = [...type.path];
const isPrimitivePath = !!path.length && ( const isPrimitivePath = !!path.length && (
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) || (path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
@@ -136,7 +136,7 @@ export class MetaRegistry extends TypeRegistry {
}); });
} }
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => { #extractArray = ({ len: length, type }: Si0TypeDefArray): Omit<TypeDef, 'type'> => {
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256'); assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
return { return {
@@ -146,7 +146,7 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractFields = (fields: SiField[]): Omit<TypeDef, 'type'> => { #extractFields = (fields: Si0Field[]): Omit<TypeDef, 'type'> => {
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([ const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
isAllNamed && name.isSome, isAllNamed && name.isSome,
isAllUnnamed && name.isNone isAllUnnamed && name.isNone
@@ -174,7 +174,7 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractPrimitive = (type: SiType0): TypeDef => { #extractPrimitive = (type: Si0Type): TypeDef => {
const typeStr = type.def.asPrimitive.type.toString(); const typeStr = type.def.asPrimitive.type.toString();
return { return {
@@ -183,14 +183,14 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractPrimitivePath = (type: SiType0): TypeDef => { #extractPrimitivePath = (type: Si0Type): TypeDef => {
return { return {
info: TypeDefInfo.Plain, info: TypeDefInfo.Plain,
type: type.path[type.path.length - 1].toString() type: type.path[type.path.length - 1].toString()
}; };
} }
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => { #extractSequence = ({ type }: Si0TypeDefSequence, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`); assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
return { return {
@@ -199,7 +199,7 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractTuple = (ids: SiTypeDefTuple): Omit<TypeDef, 'type'> => { #extractTuple = (ids: Si0TypeDefTuple): Omit<TypeDef, 'type'> => {
return ids.length === 1 return ids.length === 1
? this.getMetaTypeDef({ type: ids[0] }) ? this.getMetaTypeDef({ type: ids[0] })
: { : {
@@ -208,7 +208,7 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractVariant = ({ variants }: SiTypeDefVariant, id: SiLookupTypeId): Omit<TypeDef, 'type'> => { #extractVariant = ({ variants }: Si0TypeDefVariant, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
const { params, path } = this.#getMetaType(id); const { params, path } = this.#getMetaType(id);
const specialVariant = path[0].toString(); const specialVariant = path[0].toString();
@@ -231,7 +231,7 @@ export class MetaRegistry extends TypeRegistry {
}; };
} }
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => { #extractVariantSub = (variants: Si0Variant[]): TypeDef[] => {
return variants.every(({ fields }) => fields.length === 0) return variants.every(({ fields }) => fields.length === 0)
? variants.map(({ discriminant, name }) => ({ ? variants.map(({ discriminant, name }) => ({
...( ...(
+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 { 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 { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery'; 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 { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain'; import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences'; 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 { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc'; 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 { 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 { 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 { 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'; 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<SessionIndex>': Compact<SessionIndex>;
'Compact<SetId>': Compact<SetId>; 'Compact<SetId>': Compact<SetId>;
'Compact<SetIndex>': Compact<SetIndex>; 'Compact<SetIndex>': Compact<SetIndex>;
'Compact<SiLookupTypeId>': Compact<SiLookupTypeId>; 'Compact<Si0LookupTypeId>': Compact<Si0LookupTypeId>;
'Compact<Slot>': Compact<Slot>; 'Compact<Slot>': Compact<Slot>;
'Compact<SlotNumber>': Compact<SlotNumber>; 'Compact<SlotNumber>': Compact<SlotNumber>;
'Compact<SpanIndex>': Compact<SpanIndex>; 'Compact<SpanIndex>': Compact<SpanIndex>;
@@ -731,6 +731,7 @@ declare module '@polkadot/types/types/registry' {
'Option<PluralityJunction>': Option<PluralityJunction>; 'Option<PluralityJunction>': Option<PluralityJunction>;
'Option<Points>': Option<Points>; 'Option<Points>': Option<Points>;
'Option<PortableRegistry>': Option<PortableRegistry>; 'Option<PortableRegistry>': Option<PortableRegistry>;
'Option<PortableType>': Option<PortableType>;
'Option<Precommits>': Option<Precommits>; 'Option<Precommits>': Option<Precommits>;
'Option<PrefabWasmModule>': Option<PrefabWasmModule>; 'Option<PrefabWasmModule>': Option<PrefabWasmModule>;
'Option<PrefixedStorageKey>': Option<PrefixedStorageKey>; 'Option<PrefixedStorageKey>': Option<PrefixedStorageKey>;
@@ -841,6 +842,22 @@ declare module '@polkadot/types/types/registry' {
'Option<SessionKeys9B>': Option<SessionKeys9B>; 'Option<SessionKeys9B>': Option<SessionKeys9B>;
'Option<SetId>': Option<SetId>; 'Option<SetId>': Option<SetId>;
'Option<SetIndex>': Option<SetIndex>; '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<SiField>': Option<SiField>;
'Option<Signature>': Option<Signature>; 'Option<Signature>': Option<Signature>;
'Option<SignedAvailabilityBitfield>': Option<SignedAvailabilityBitfield>; 'Option<SignedAvailabilityBitfield>': Option<SignedAvailabilityBitfield>;
@@ -857,13 +874,11 @@ declare module '@polkadot/types/types/registry' {
'Option<SiLookupTypeId>': Option<SiLookupTypeId>; 'Option<SiLookupTypeId>': Option<SiLookupTypeId>;
'Option<SiPath>': Option<SiPath>; 'Option<SiPath>': Option<SiPath>;
'Option<SiType>': Option<SiType>; 'Option<SiType>': Option<SiType>;
'Option<SiType0>': Option<SiType0>;
'Option<SiTypeDef>': Option<SiTypeDef>; 'Option<SiTypeDef>': Option<SiTypeDef>;
'Option<SiTypeDefArray>': Option<SiTypeDefArray>; 'Option<SiTypeDefArray>': Option<SiTypeDefArray>;
'Option<SiTypeDefBitSequence>': Option<SiTypeDefBitSequence>; 'Option<SiTypeDefBitSequence>': Option<SiTypeDefBitSequence>;
'Option<SiTypeDefCompact>': Option<SiTypeDefCompact>; 'Option<SiTypeDefCompact>': Option<SiTypeDefCompact>;
'Option<SiTypeDefComposite>': Option<SiTypeDefComposite>; 'Option<SiTypeDefComposite>': Option<SiTypeDefComposite>;
'Option<SiTypeDefPhantom>': Option<SiTypeDefPhantom>;
'Option<SiTypeDefPrimitive>': Option<SiTypeDefPrimitive>; 'Option<SiTypeDefPrimitive>': Option<SiTypeDefPrimitive>;
'Option<SiTypeDefSequence>': Option<SiTypeDefSequence>; 'Option<SiTypeDefSequence>': Option<SiTypeDefSequence>;
'Option<SiTypeDefTuple>': Option<SiTypeDefTuple>; 'Option<SiTypeDefTuple>': Option<SiTypeDefTuple>;
@@ -1627,6 +1642,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<PluralityJunction>': Vec<PluralityJunction>; 'Vec<PluralityJunction>': Vec<PluralityJunction>;
'Vec<Points>': Vec<Points>; 'Vec<Points>': Vec<Points>;
'Vec<PortableRegistry>': Vec<PortableRegistry>; 'Vec<PortableRegistry>': Vec<PortableRegistry>;
'Vec<PortableType>': Vec<PortableType>;
'Vec<Precommits>': Vec<Precommits>; 'Vec<Precommits>': Vec<Precommits>;
'Vec<PrefabWasmModule>': Vec<PrefabWasmModule>; 'Vec<PrefabWasmModule>': Vec<PrefabWasmModule>;
'Vec<PrefixedStorageKey>': Vec<PrefixedStorageKey>; 'Vec<PrefixedStorageKey>': Vec<PrefixedStorageKey>;
@@ -1737,6 +1753,22 @@ declare module '@polkadot/types/types/registry' {
'Vec<SessionKeys9B>': Vec<SessionKeys9B>; 'Vec<SessionKeys9B>': Vec<SessionKeys9B>;
'Vec<SetId>': Vec<SetId>; 'Vec<SetId>': Vec<SetId>;
'Vec<SetIndex>': Vec<SetIndex>; '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<SiField>': Vec<SiField>;
'Vec<Signature>': Vec<Signature>; 'Vec<Signature>': Vec<Signature>;
'Vec<SignedAvailabilityBitfield>': Vec<SignedAvailabilityBitfield>; 'Vec<SignedAvailabilityBitfield>': Vec<SignedAvailabilityBitfield>;
@@ -1753,13 +1785,11 @@ declare module '@polkadot/types/types/registry' {
'Vec<SiLookupTypeId>': Vec<SiLookupTypeId>; 'Vec<SiLookupTypeId>': Vec<SiLookupTypeId>;
'Vec<SiPath>': Vec<SiPath>; 'Vec<SiPath>': Vec<SiPath>;
'Vec<SiType>': Vec<SiType>; 'Vec<SiType>': Vec<SiType>;
'Vec<SiType0>': Vec<SiType0>;
'Vec<SiTypeDef>': Vec<SiTypeDef>; 'Vec<SiTypeDef>': Vec<SiTypeDef>;
'Vec<SiTypeDefArray>': Vec<SiTypeDefArray>; 'Vec<SiTypeDefArray>': Vec<SiTypeDefArray>;
'Vec<SiTypeDefBitSequence>': Vec<SiTypeDefBitSequence>; 'Vec<SiTypeDefBitSequence>': Vec<SiTypeDefBitSequence>;
'Vec<SiTypeDefCompact>': Vec<SiTypeDefCompact>; 'Vec<SiTypeDefCompact>': Vec<SiTypeDefCompact>;
'Vec<SiTypeDefComposite>': Vec<SiTypeDefComposite>; 'Vec<SiTypeDefComposite>': Vec<SiTypeDefComposite>;
'Vec<SiTypeDefPhantom>': Vec<SiTypeDefPhantom>;
'Vec<SiTypeDefPrimitive>': Vec<SiTypeDefPrimitive>; 'Vec<SiTypeDefPrimitive>': Vec<SiTypeDefPrimitive>;
'Vec<SiTypeDefSequence>': Vec<SiTypeDefSequence>; 'Vec<SiTypeDefSequence>': Vec<SiTypeDefSequence>;
'Vec<SiTypeDefTuple>': Vec<SiTypeDefTuple>; 'Vec<SiTypeDefTuple>': Vec<SiTypeDefTuple>;
@@ -2523,6 +2553,7 @@ declare module '@polkadot/types/types/registry' {
PluralityJunction: PluralityJunction; PluralityJunction: PluralityJunction;
Points: Points; Points: Points;
PortableRegistry: PortableRegistry; PortableRegistry: PortableRegistry;
PortableType: PortableType;
Precommits: Precommits; Precommits: Precommits;
PrefabWasmModule: PrefabWasmModule; PrefabWasmModule: PrefabWasmModule;
PrefixedStorageKey: PrefixedStorageKey; PrefixedStorageKey: PrefixedStorageKey;
@@ -2633,6 +2664,22 @@ declare module '@polkadot/types/types/registry' {
SessionKeys9B: SessionKeys9B; SessionKeys9B: SessionKeys9B;
SetId: SetId; SetId: SetId;
SetIndex: SetIndex; 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; SiField: SiField;
Signature: Signature; Signature: Signature;
SignedAvailabilityBitfield: SignedAvailabilityBitfield; SignedAvailabilityBitfield: SignedAvailabilityBitfield;
@@ -2649,13 +2696,11 @@ declare module '@polkadot/types/types/registry' {
SiLookupTypeId: SiLookupTypeId; SiLookupTypeId: SiLookupTypeId;
SiPath: SiPath; SiPath: SiPath;
SiType: SiType; SiType: SiType;
SiType0: SiType0;
SiTypeDef: SiTypeDef; SiTypeDef: SiTypeDef;
SiTypeDefArray: SiTypeDefArray; SiTypeDefArray: SiTypeDefArray;
SiTypeDefBitSequence: SiTypeDefBitSequence; SiTypeDefBitSequence: SiTypeDefBitSequence;
SiTypeDefCompact: SiTypeDefCompact; SiTypeDefCompact: SiTypeDefCompact;
SiTypeDefComposite: SiTypeDefComposite; SiTypeDefComposite: SiTypeDefComposite;
SiTypeDefPhantom: SiTypeDefPhantom;
SiTypeDefPrimitive: SiTypeDefPrimitive; SiTypeDefPrimitive: SiTypeDefPrimitive;
SiTypeDefSequence: SiTypeDefSequence; SiTypeDefSequence: SiTypeDefSequence;
SiTypeDefTuple: SiTypeDefTuple; SiTypeDefTuple: SiTypeDefTuple;
@@ -19,7 +19,7 @@ const layout = {
}, },
ContractLayoutCell: { ContractLayoutCell: {
key: 'ContractLayoutKey', key: 'ContractLayoutKey',
ty: 'SiLookupTypeId' ty: 'Si0LookupTypeId'
}, },
ContractLayoutEnum: { ContractLayoutEnum: {
dispatchKey: 'ContractLayoutKey', dispatchKey: 'ContractLayoutKey',
@@ -67,7 +67,7 @@ const spec = {
events: 'Vec<ContractEventSpec>', events: 'Vec<ContractEventSpec>',
docs: 'Vec<Text>' docs: 'Vec<Text>'
}, },
ContractDisplayName: 'SiPath', ContractDisplayName: 'Si0Path',
ContractEventParamSpec: { ContractEventParamSpec: {
name: 'Text', name: 'Text',
indexed: 'bool', indexed: 'bool',
@@ -94,7 +94,7 @@ const spec = {
}, },
ContractSelector: '[u8; 4]', ContractSelector: '[u8; 4]',
ContractTypeSpec: { ContractTypeSpec: {
type: 'SiLookupTypeId', type: 'Si0LookupTypeId',
displayName: 'ContractDisplayName' displayName: 'ContractDisplayName'
} }
}; };
@@ -110,8 +110,8 @@ export default {
source: 'ContractProjectSource', source: 'ContractProjectSource',
contract: 'ContractProjectContract', contract: 'ContractProjectContract',
// expanded scale registry: RegistryReadOnly // expanded scale registry: RegistryReadOnly
// NOTE Previous generation of the SiType definition // NOTE Previous generation of the Si0Type definition
types: 'Vec<SiType0>', types: 'Vec<Si0Type>',
// renamed from layout (ignored for now, incomplete) // renamed from layout (ignored for now, incomplete)
// storage: 'ContractStorageLayout', // storage: 'ContractStorageLayout',
spec: 'ContractContractSpec' spec: 'ContractContractSpec'
@@ -2,7 +2,7 @@
/* eslint-disable */ /* eslint-disable */
import type { BTreeMap, Bytes, Enum, Option, Raw, Struct, Text, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types'; 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 */ /** @name ContractConstructorSpec */
export interface ContractConstructorSpec extends Struct { export interface ContractConstructorSpec extends Struct {
@@ -31,7 +31,7 @@ export interface ContractCryptoHasher extends Enum {
export interface ContractDiscriminant extends u32 {} export interface ContractDiscriminant extends u32 {}
/** @name ContractDisplayName */ /** @name ContractDisplayName */
export interface ContractDisplayName extends SiPath {} export interface ContractDisplayName extends Si0Path {}
/** @name ContractEventParamSpec */ /** @name ContractEventParamSpec */
export interface ContractEventParamSpec extends Struct { export interface ContractEventParamSpec extends Struct {
@@ -59,7 +59,7 @@ export interface ContractLayoutArray extends Struct {
/** @name ContractLayoutCell */ /** @name ContractLayoutCell */
export interface ContractLayoutCell extends Struct { export interface ContractLayoutCell extends Struct {
readonly key: ContractLayoutKey; readonly key: ContractLayoutKey;
readonly ty: SiLookupTypeId; readonly ty: Si0LookupTypeId;
} }
/** @name ContractLayoutEnum */ /** @name ContractLayoutEnum */
@@ -118,7 +118,7 @@ export interface ContractProject extends Struct {
readonly metadataVersion: Text; readonly metadataVersion: Text;
readonly source: ContractProjectSource; readonly source: ContractProjectSource;
readonly contract: ContractProjectContract; readonly contract: ContractProjectContract;
readonly types: Vec<SiType0>; readonly types: Vec<Si0Type>;
readonly spec: ContractContractSpec; readonly spec: ContractContractSpec;
} }
@@ -161,7 +161,7 @@ export interface ContractStorageLayout extends Enum {
/** @name ContractTypeSpec */ /** @name ContractTypeSpec */
export interface ContractTypeSpec extends Struct { export interface ContractTypeSpec extends Struct {
readonly type: SiLookupTypeId; readonly type: Si0LookupTypeId;
readonly displayName: ContractDisplayName; readonly displayName: ContractDisplayName;
} }
@@ -156,7 +156,7 @@ export interface MetadataV13 extends Struct {
/** @name MetadataV14 */ /** @name MetadataV14 */
export interface MetadataV14 extends Struct { export interface MetadataV14 extends Struct {
readonly types: PortableRegistry; readonly lookup: PortableRegistry;
readonly pallets: Vec<PalletMetadataV14>; readonly pallets: Vec<PalletMetadataV14>;
readonly extrinsic: ExtrinsicMetadataV14; readonly extrinsic: ExtrinsicMetadataV14;
} }
@@ -304,7 +304,13 @@ export interface PalletStorageMetadataV14 extends Struct {
/** @name PortableRegistry */ /** @name PortableRegistry */
export interface PortableRegistry extends Struct { 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 */ /** @name SignedExtensionMetadataLatest */
@@ -9,7 +9,11 @@ import type { DefinitionsTypes } from '../../types';
export const v14: DefinitionsTypes = { export const v14: DefinitionsTypes = {
// registry // registry
PortableRegistry: { PortableRegistry: {
types: 'Vec<SiType>' types: 'Vec<PortableType>'
},
PortableType: {
id: 'SiLookupTypeId',
type: 'SiType'
}, },
// V14 // V14
@@ -19,7 +23,7 @@ export const v14: DefinitionsTypes = {
signedExtensions: 'Vec<SignedExtensionMetadataV14>' signedExtensions: 'Vec<SignedExtensionMetadataV14>'
}, },
MetadataV14: { MetadataV14: {
types: 'PortableRegistry', lookup: 'PortableRegistry',
pallets: 'Vec<PalletMetadataV14>', pallets: 'Vec<PalletMetadataV14>',
extrinsic: 'ExtrinsicMetadataV14' extrinsic: 'ExtrinsicMetadataV14'
}, },
@@ -3,19 +3,22 @@
import type { Definitions } from '../../types'; import type { Definitions } from '../../types';
import { v0 } from './v0';
// order important in structs... :) // order important in structs... :)
/* eslint-disable sort-keys */ /* eslint-disable sort-keys */
export default { export default {
rpc: {}, rpc: {},
types: { types: {
...v0,
SiField: { SiField: {
name: 'Option<Text>', name: 'Option<Text>',
type: 'SiLookupTypeId', type: 'SiLookupTypeId',
typeName: 'Option<Text>', typeName: 'Option<Text>',
docs: 'Vec<Text>' docs: 'Vec<Text>'
}, },
SiLookupTypeId: 'u32', SiLookupTypeId: 'Compact<u32>',
SiPath: 'Vec<Text>', SiPath: 'Vec<Text>',
SiType: { SiType: {
path: 'SiPath', path: 'SiPath',
@@ -23,11 +26,6 @@ export default {
def: 'SiTypeDef', def: 'SiTypeDef',
docs: 'Vec<Text>' docs: 'Vec<Text>'
}, },
SiType0: {
path: 'SiPath',
params: 'Vec<SiLookupTypeId>',
def: 'SiTypeDef'
},
SiTypeDef: { SiTypeDef: {
_enum: { _enum: {
Composite: 'SiTypeDefComposite', Composite: 'SiTypeDefComposite',
@@ -37,7 +35,6 @@ export default {
Tuple: 'SiTypeDefTuple', Tuple: 'SiTypeDefTuple',
Primitive: 'SiTypeDefPrimitive', Primitive: 'SiTypeDefPrimitive',
Compact: 'SiTypeDefCompact', Compact: 'SiTypeDefCompact',
Phantom: 'SiTypeDefPhantom',
BitSequence: 'SiTypeDefBitSequence', BitSequence: 'SiTypeDefBitSequence',
// NOTE: This is specific to the implementation for pre-v14 metadata // NOTE: This is specific to the implementation for pre-v14 metadata
// compatibility (always keep this as the last entry in the enum) // compatibility (always keep this as the last entry in the enum)
@@ -58,7 +55,6 @@ export default {
SiTypeDefComposite: { SiTypeDefComposite: {
fields: 'Vec<SiField>' fields: 'Vec<SiField>'
}, },
SiTypeDefPhantom: 'Null',
SiTypeDefVariant: { SiTypeDefVariant: {
variants: 'Vec<SiVariant>' variants: 'Vec<SiVariant>'
}, },
@@ -76,8 +72,7 @@ export default {
SiVariant: { SiVariant: {
name: 'Text', name: 'Text',
fields: 'Vec<SiField>', fields: 'Vec<SiField>',
index: 'Option<u8>', index: 'u8',
discriminant: 'Option<u64>',
docs: 'Vec<Text>' docs: 'Vec<Text>'
} }
} }
+118 -16
View File
@@ -1,7 +1,122 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */ /* 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 */ /** @name SiField */
export interface SiField extends Struct { export interface SiField extends Struct {
@@ -12,7 +127,7 @@ export interface SiField extends Struct {
} }
/** @name SiLookupTypeId */ /** @name SiLookupTypeId */
export interface SiLookupTypeId extends u32 {} export interface SiLookupTypeId extends Compact<u32> {}
/** @name SiPath */ /** @name SiPath */
export interface SiPath extends Vec<Text> {} export interface SiPath extends Vec<Text> {}
@@ -25,13 +140,6 @@ export interface SiType extends Struct {
readonly docs: Vec<Text>; readonly docs: Vec<Text>;
} }
/** @name SiType0 */
export interface SiType0 extends Struct {
readonly path: SiPath;
readonly params: Vec<SiLookupTypeId>;
readonly def: SiTypeDef;
}
/** @name SiTypeDef */ /** @name SiTypeDef */
export interface SiTypeDef extends Enum { export interface SiTypeDef extends Enum {
readonly isComposite: boolean; readonly isComposite: boolean;
@@ -48,8 +156,6 @@ export interface SiTypeDef extends Enum {
readonly asPrimitive: SiTypeDefPrimitive; readonly asPrimitive: SiTypeDefPrimitive;
readonly isCompact: boolean; readonly isCompact: boolean;
readonly asCompact: SiTypeDefCompact; readonly asCompact: SiTypeDefCompact;
readonly isPhantom: boolean;
readonly asPhantom: SiTypeDefPhantom;
readonly isBitSequence: boolean; readonly isBitSequence: boolean;
readonly asBitSequence: SiTypeDefBitSequence; readonly asBitSequence: SiTypeDefBitSequence;
readonly isHistoricMetaCompat: boolean; readonly isHistoricMetaCompat: boolean;
@@ -78,9 +184,6 @@ export interface SiTypeDefComposite extends Struct {
readonly fields: Vec<SiField>; readonly fields: Vec<SiField>;
} }
/** @name SiTypeDefPhantom */
export interface SiTypeDefPhantom extends Null {}
/** @name SiTypeDefPrimitive */ /** @name SiTypeDefPrimitive */
export interface SiTypeDefPrimitive extends Enum { export interface SiTypeDefPrimitive extends Enum {
readonly isBool: boolean; readonly isBool: boolean;
@@ -123,8 +226,7 @@ export interface SiTypeParameter extends Struct {
export interface SiVariant extends Struct { export interface SiVariant extends Struct {
readonly name: Text; readonly name: Text;
readonly fields: Vec<SiField>; readonly fields: Vec<SiField>;
readonly index: Option<u8>; readonly index: u8;
readonly discriminant: Option<u64>;
readonly docs: Vec<Text>; 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 { TypeRegistry } from '../../create';
import { Metadata } from '../Metadata'; import { Metadata } from '../Metadata';
import substrateData from './static'; import substrateData from './static';
import substrateJson from './static-substrate.json';
import substrateTypes from './static-types.json';
describe('MetadataV14 (substrate)', (): void => { describe('MetadataV14 (substrate)', (): void => {
// FIXME This is to be replaced with the proper version (here as a stop-gap)
it('parses', (): void => { it('parses', (): void => {
const registry = new TypeRegistry(); const registry = new TypeRegistry();
const metadata = new Metadata(registry, substrateData); const metadata = new Metadata(registry, substrateData);
const all = metadata.get('metadata') as MetadataAll; 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())); const allJson = {
// console.error(JSON.stringify( magicNumber: 1635018093,
// all.asV14.types.types.map((t, __INDEX) => ({ metadata: {
// __INDEX, v14: jsonStruct
// ...t.toJSON() }
// })) };
// ));
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