Scale-info v0 -> v1 conversion (as needed by contracts) (#3987)
* Scale-info v0 -> v1 conversion (as needed by contracts) * Renames * V1 types same as v0 where applicable
This commit is contained in:
@@ -32,7 +32,7 @@ import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, A
|
||||
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityInfoTo198, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement, RegistrationTo198 } 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, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, 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, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableRegistryV14, PortableType, PortableTypeV14, 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, 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, AccountId20, AccountId32, 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 { 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 { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, Si1Field, Si1LookupTypeId, Si1Path, Si1Type, Si1TypeDef, Si1TypeDefArray, Si1TypeDefBitSequence, Si1TypeDefCompact, Si1TypeDefComposite, Si1TypeDefPrimitive, Si1TypeDefSequence, Si1TypeDefTuple, Si1TypeDefVariant, Si1TypeParameter, Si1Variant, 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';
|
||||
@@ -676,7 +676,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
PhragmenScore: PhragmenScore;
|
||||
Points: Points;
|
||||
PortableRegistry: PortableRegistry;
|
||||
PortableRegistryV14: PortableRegistryV14;
|
||||
PortableType: PortableType;
|
||||
PortableTypeV14: PortableTypeV14;
|
||||
Precommits: Precommits;
|
||||
PrefabWasmModule: PrefabWasmModule;
|
||||
PrefixedStorageKey: PrefixedStorageKey;
|
||||
@@ -813,6 +815,21 @@ declare module '@polkadot/types/types/registry' {
|
||||
Si0TypeDefVariant: Si0TypeDefVariant;
|
||||
Si0TypeParameter: Si0TypeParameter;
|
||||
Si0Variant: Si0Variant;
|
||||
Si1Field: Si1Field;
|
||||
Si1LookupTypeId: Si1LookupTypeId;
|
||||
Si1Path: Si1Path;
|
||||
Si1Type: Si1Type;
|
||||
Si1TypeDef: Si1TypeDef;
|
||||
Si1TypeDefArray: Si1TypeDefArray;
|
||||
Si1TypeDefBitSequence: Si1TypeDefBitSequence;
|
||||
Si1TypeDefCompact: Si1TypeDefCompact;
|
||||
Si1TypeDefComposite: Si1TypeDefComposite;
|
||||
Si1TypeDefPrimitive: Si1TypeDefPrimitive;
|
||||
Si1TypeDefSequence: Si1TypeDefSequence;
|
||||
Si1TypeDefTuple: Si1TypeDefTuple;
|
||||
Si1TypeDefVariant: Si1TypeDefVariant;
|
||||
Si1TypeParameter: Si1TypeParameter;
|
||||
Si1Variant: Si1Variant;
|
||||
SiField: SiField;
|
||||
Signature: Signature;
|
||||
SignedAvailabilityBitfield: SignedAvailabilityBitfield;
|
||||
|
||||
+9
-10
@@ -1,19 +1,18 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Vec } from '../codec/Vec';
|
||||
import type { PortableType } from '../interfaces/metadata';
|
||||
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../interfaces/scaleInfo';
|
||||
import type { Text } from '../primitive/Text';
|
||||
import type { Type } from '../primitive/Type';
|
||||
import type { Registry, TypeDef } from '../types';
|
||||
import type { Vec } from '../../codec';
|
||||
import type { PortableType } from '../../interfaces/metadata';
|
||||
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../../interfaces/scaleInfo';
|
||||
import type { Text, Type } from '../../primitive';
|
||||
import type { Registry, TypeDef } from '../../types';
|
||||
|
||||
import { assert, isNumber, isString, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { Struct } from '../codec/Struct';
|
||||
import { withTypeString } from '../create/encodeTypes';
|
||||
import { getTypeDef } from '../create/getTypeDef';
|
||||
import { TypeDefInfo } from '../types';
|
||||
import { Struct } from '../../codec/Struct';
|
||||
import { withTypeString } from '../../create/encodeTypes';
|
||||
import { getTypeDef } from '../../create/getTypeDef';
|
||||
import { TypeDefInfo } from '../../types';
|
||||
|
||||
// Just a placeholder for a type.unrwapOr()
|
||||
const TYPE_UNWRAP = { toNumber: () => -1 };
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { GenericPortableRegistry } from './PortableRegistry';
|
||||
export { toV1 as convertSiV0toV1 } from './toV1';
|
||||
@@ -0,0 +1,133 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { PortableType, Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefComposite, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefVariant, Si1Field, Si1TypeDef } from '../../interfaces';
|
||||
import type { Registry } from '../../types';
|
||||
|
||||
function convertArray (registry: Registry, { len, type }: Si0TypeDefArray): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Array: {
|
||||
len,
|
||||
type: type.toNumber()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertBitSequence (registry: Registry, { bitOrderType, bitStoreType }: Si0TypeDefBitSequence): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
BitSequence: {
|
||||
bitOrderType: bitOrderType.toNumber(),
|
||||
bitStoreType: bitStoreType.toNumber()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertCompact (registry: Registry, { type }: Si0TypeDefSequence): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Compact: {
|
||||
type: type.toNumber()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertComposite (registry: Registry, { fields }: Si0TypeDefComposite): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Composite: {
|
||||
fields: convertFields(registry, fields)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertFields (registry: Registry, fields: Si0Field[]): Si1Field[] {
|
||||
return fields.map(({ docs, name, type, typeName }) =>
|
||||
registry.createType('Si1Field', {
|
||||
docs,
|
||||
name,
|
||||
type: type.toNumber(),
|
||||
typeName
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function convertPhantom (registry: Registry, path: Si0Path): Si1TypeDef {
|
||||
console.warn(`Converting phantom type ${path.map((p) => p.toString()).join('::')} to empty tuple`);
|
||||
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Tuple: []
|
||||
});
|
||||
}
|
||||
|
||||
function convertPrimitive (registry: Registry, prim: Si0TypeDefPrimitive): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Primitive: prim.toString()
|
||||
});
|
||||
}
|
||||
|
||||
function convertSequence (registry: Registry, { type }: Si0TypeDefSequence): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Sequence: {
|
||||
type: type.toNumber()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertTuple (registry: Registry, types: Si0LookupTypeId[]): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Tuple: types.map((t) => t.toNumber())
|
||||
});
|
||||
}
|
||||
|
||||
function convertVariant (registry: Registry, { variants }: Si0TypeDefVariant): Si1TypeDef {
|
||||
return registry.createType('Si1TypeDef', {
|
||||
Variant: {
|
||||
variants: variants.map(({ discriminant, docs, fields, name }, index) =>
|
||||
registry.createType('Si1Variant', {
|
||||
docs,
|
||||
fields: convertFields(registry, fields),
|
||||
index: discriminant.isSome
|
||||
? discriminant.unwrap().toNumber()
|
||||
: index,
|
||||
name
|
||||
})
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function convertDef (registry: Registry, { def, path }: Si0Type): Si1TypeDef {
|
||||
if (def.isArray) {
|
||||
return convertArray(registry, def.asArray);
|
||||
} else if (def.isBitSequence) {
|
||||
return convertBitSequence(registry, def.asBitSequence);
|
||||
} else if (def.isCompact) {
|
||||
return convertCompact(registry, def.asCompact);
|
||||
} else if (def.isComposite) {
|
||||
return convertComposite(registry, def.asComposite);
|
||||
} else if (def.isPhantom) {
|
||||
return convertPhantom(registry, path);
|
||||
} else if (def.isPrimitive) {
|
||||
return convertPrimitive(registry, def.asPrimitive);
|
||||
} else if (def.isSequence) {
|
||||
return convertSequence(registry, def.asSequence);
|
||||
} else if (def.isTuple) {
|
||||
return convertTuple(registry, def.asTuple);
|
||||
} else if (def.isVariant) {
|
||||
return convertVariant(registry, def.asVariant);
|
||||
}
|
||||
|
||||
throw new Error(`Cannot convert type ${def.toString()}`);
|
||||
}
|
||||
|
||||
export function toV1 (registry: Registry, types: Si0Type[]): PortableType[] {
|
||||
return types.map((t, id) =>
|
||||
registry.createType('PortableType', {
|
||||
id,
|
||||
type: {
|
||||
def: convertDef(registry, t),
|
||||
docs: [],
|
||||
params: t.params.map((p) => p.toNumber()),
|
||||
path: t.path.map((p) => p.toString())
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -26,6 +26,10 @@ export default {
|
||||
...v13,
|
||||
...v14,
|
||||
|
||||
// registry mapping to latest
|
||||
PortableRegistry: 'PortableRegistryV14',
|
||||
PortableType: 'PortableTypeV14',
|
||||
|
||||
// latest mappings
|
||||
ErrorMetadataLatest: 'ErrorMetadataV14',
|
||||
EventMetadataLatest: 'EventMetadataV14',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Bytes, Enum, GenericPortableRegistry, Option, Struct, Text, Type, Vec, bool, u8 } from '@polkadot/types';
|
||||
import type { SiField, SiLookupTypeId, SiType } from '@polkadot/types/interfaces/scaleInfo';
|
||||
import type { Si1Field, Si1LookupTypeId, Si1Type, SiLookupTypeId } from '@polkadot/types/interfaces/scaleInfo';
|
||||
|
||||
/** @name ErrorMetadataLatest */
|
||||
export interface ErrorMetadataLatest extends ErrorMetadataV14 {}
|
||||
@@ -22,7 +22,7 @@ export interface ErrorMetadataV13 extends ErrorMetadataV12 {}
|
||||
/** @name ErrorMetadataV14 */
|
||||
export interface ErrorMetadataV14 extends Struct {
|
||||
readonly name: Text;
|
||||
readonly fields: Vec<SiField>;
|
||||
readonly fields: Vec<Si1Field>;
|
||||
readonly index: u8;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly args: Vec<Type>;
|
||||
@@ -52,7 +52,7 @@ export interface EventMetadataV13 extends EventMetadataV12 {}
|
||||
/** @name EventMetadataV14 */
|
||||
export interface EventMetadataV14 extends Struct {
|
||||
readonly name: Text;
|
||||
readonly fields: Vec<SiField>;
|
||||
readonly fields: Vec<Si1Field>;
|
||||
readonly index: u8;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly args: Vec<Type>;
|
||||
@@ -129,7 +129,7 @@ export interface FunctionMetadataV13 extends FunctionMetadataV12 {}
|
||||
/** @name FunctionMetadataV14 */
|
||||
export interface FunctionMetadataV14 extends Struct {
|
||||
readonly name: Text;
|
||||
readonly fields: Vec<SiField>;
|
||||
readonly fields: Vec<Si1Field>;
|
||||
readonly index: u8;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly args: Vec<FunctionArgumentMetadataV14>;
|
||||
@@ -327,12 +327,18 @@ export interface PalletStorageMetadataV14 extends Struct {
|
||||
}
|
||||
|
||||
/** @name PortableRegistry */
|
||||
export interface PortableRegistry extends GenericPortableRegistry {}
|
||||
export interface PortableRegistry extends PortableRegistryV14 {}
|
||||
|
||||
/** @name PortableRegistryV14 */
|
||||
export interface PortableRegistryV14 extends GenericPortableRegistry {}
|
||||
|
||||
/** @name PortableType */
|
||||
export interface PortableType extends Struct {
|
||||
readonly id: SiLookupTypeId;
|
||||
readonly type: SiType;
|
||||
export interface PortableType extends PortableTypeV14 {}
|
||||
|
||||
/** @name PortableTypeV14 */
|
||||
export interface PortableTypeV14 extends Struct {
|
||||
readonly id: Si1LookupTypeId;
|
||||
readonly type: Si1Type;
|
||||
}
|
||||
|
||||
/** @name SignedExtensionMetadataLatest */
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
|
||||
import type { DefinitionsTypes } from '../../types';
|
||||
|
||||
import { SiVariant } from '../scaleInfo/definitions';
|
||||
import { Si1Variant } from '../scaleInfo/v1';
|
||||
|
||||
export const v14: DefinitionsTypes = {
|
||||
// registry
|
||||
PortableRegistry: 'GenericPortableRegistry',
|
||||
PortableType: {
|
||||
id: 'SiLookupTypeId',
|
||||
type: 'SiType'
|
||||
PortableRegistryV14: 'GenericPortableRegistry',
|
||||
PortableTypeV14: {
|
||||
id: 'Si1LookupTypeId',
|
||||
type: 'Si1Type'
|
||||
},
|
||||
|
||||
// compatibility with earlier layouts, i.e. don't break previous users
|
||||
ErrorMetadataV14: {
|
||||
...SiVariant,
|
||||
...Si1Variant,
|
||||
args: 'Vec<Type>'
|
||||
},
|
||||
EventMetadataV14: {
|
||||
...SiVariant,
|
||||
...Si1Variant,
|
||||
args: 'Vec<Type>'
|
||||
},
|
||||
FunctionArgumentMetadataV14: 'FunctionArgumentMetadataV13',
|
||||
FunctionMetadataV14: {
|
||||
...SiVariant,
|
||||
...Si1Variant,
|
||||
args: 'Vec<FunctionArgumentMetadataV14>'
|
||||
},
|
||||
|
||||
|
||||
@@ -4,78 +4,32 @@
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
import { v0 } from './v0';
|
||||
import { v1 } from './v1';
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export const SiVariant = {
|
||||
name: 'Text',
|
||||
fields: 'Vec<SiField>',
|
||||
index: 'u8',
|
||||
docs: 'Vec<Text>'
|
||||
};
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
...v0,
|
||||
SiField: {
|
||||
name: 'Option<Text>',
|
||||
type: 'SiLookupTypeId',
|
||||
typeName: 'Option<Text>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
SiLookupTypeId: 'Compact<u32>',
|
||||
SiPath: 'Vec<Text>',
|
||||
SiType: {
|
||||
path: 'SiPath',
|
||||
params: 'Vec<SiTypeParameter>',
|
||||
def: 'SiTypeDef',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
SiTypeDef: {
|
||||
_enum: {
|
||||
Composite: 'SiTypeDefComposite',
|
||||
Variant: 'SiTypeDefVariant',
|
||||
Sequence: 'SiTypeDefSequence',
|
||||
Array: 'SiTypeDefArray',
|
||||
Tuple: 'SiTypeDefTuple',
|
||||
Primitive: 'SiTypeDefPrimitive',
|
||||
Compact: 'SiTypeDefCompact',
|
||||
BitSequence: 'SiTypeDefBitSequence',
|
||||
// NOTE: This is specific to the implementation for pre-v14 metadata
|
||||
// compatibility (always keep this as the last entry in the enum)
|
||||
HistoricMetaCompat: 'Type'
|
||||
}
|
||||
},
|
||||
SiTypeDefArray: {
|
||||
len: 'u32',
|
||||
type: 'SiLookupTypeId'
|
||||
},
|
||||
SiTypeDefBitSequence: {
|
||||
bitStoreType: 'SiLookupTypeId',
|
||||
bitOrderType: 'SiLookupTypeId'
|
||||
},
|
||||
SiTypeDefCompact: {
|
||||
type: 'SiLookupTypeId'
|
||||
},
|
||||
SiTypeDefComposite: {
|
||||
fields: 'Vec<SiField>'
|
||||
},
|
||||
SiTypeDefPrimitive: {
|
||||
_enum: ['Bool', 'Char', 'Str', 'U8', 'U16', 'U32', 'U64', 'U128', 'U256', 'I8', 'I16', 'I32', 'I64', 'I128', 'I256']
|
||||
},
|
||||
SiTypeDefSequence: {
|
||||
type: 'SiLookupTypeId'
|
||||
},
|
||||
SiTypeDefTuple: 'Vec<SiLookupTypeId>',
|
||||
SiTypeParameter: {
|
||||
name: 'Text',
|
||||
type: 'Option<SiLookupTypeId>'
|
||||
},
|
||||
SiTypeDefVariant: {
|
||||
variants: 'Vec<SiVariant>'
|
||||
},
|
||||
SiVariant
|
||||
...v1,
|
||||
|
||||
// latest mappings
|
||||
SiField: 'Si1Field',
|
||||
SiLookupTypeId: 'Si1LookupTypeId',
|
||||
SiPath: 'Si1Path',
|
||||
SiType: 'Si1Type',
|
||||
SiTypeDef: 'Si1TypeDef',
|
||||
SiTypeDefArray: 'Si1TypeDefArray',
|
||||
SiTypeDefBitSequence: 'Si1TypeDefBitSequence',
|
||||
SiTypeDefCompact: 'Si1TypeDefCompact',
|
||||
SiTypeDefComposite: 'Si1TypeDefComposite',
|
||||
SiTypeDefPrimitive: 'Si1TypeDefPrimitive',
|
||||
SiTypeDefSequence: 'Si1TypeDefSequence',
|
||||
SiTypeDefTuple: 'Si1TypeDefTuple',
|
||||
SiTypeParameter: 'Si1TypeParameter',
|
||||
SiTypeDefVariant: 'Si1TypeDefVariant',
|
||||
SiVariant: 'Si1Variant'
|
||||
}
|
||||
} as Definitions;
|
||||
|
||||
@@ -118,116 +118,145 @@ export interface Si0Variant extends Struct {
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name SiField */
|
||||
export interface SiField extends Struct {
|
||||
/** @name Si1Field */
|
||||
export interface Si1Field extends Struct {
|
||||
readonly name: Option<Text>;
|
||||
readonly type: SiLookupTypeId;
|
||||
readonly type: Si1LookupTypeId;
|
||||
readonly typeName: Option<Text>;
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name SiLookupTypeId */
|
||||
export interface SiLookupTypeId extends Compact<u32> {}
|
||||
/** @name Si1LookupTypeId */
|
||||
export interface Si1LookupTypeId extends Compact<u32> {}
|
||||
|
||||
/** @name SiPath */
|
||||
export interface SiPath extends Vec<Text> {}
|
||||
/** @name Si1Path */
|
||||
export interface Si1Path extends Si0Path {}
|
||||
|
||||
/** @name SiType */
|
||||
export interface SiType extends Struct {
|
||||
readonly path: SiPath;
|
||||
readonly params: Vec<SiTypeParameter>;
|
||||
readonly def: SiTypeDef;
|
||||
/** @name Si1Type */
|
||||
export interface Si1Type extends Struct {
|
||||
readonly path: Si1Path;
|
||||
readonly params: Vec<Si1TypeParameter>;
|
||||
readonly def: Si1TypeDef;
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name SiTypeDef */
|
||||
export interface SiTypeDef extends Enum {
|
||||
/** @name Si1TypeDef */
|
||||
export interface Si1TypeDef extends Enum {
|
||||
readonly isComposite: boolean;
|
||||
readonly asComposite: SiTypeDefComposite;
|
||||
readonly asComposite: Si1TypeDefComposite;
|
||||
readonly isVariant: boolean;
|
||||
readonly asVariant: SiTypeDefVariant;
|
||||
readonly asVariant: Si1TypeDefVariant;
|
||||
readonly isSequence: boolean;
|
||||
readonly asSequence: SiTypeDefSequence;
|
||||
readonly asSequence: Si1TypeDefSequence;
|
||||
readonly isArray: boolean;
|
||||
readonly asArray: SiTypeDefArray;
|
||||
readonly asArray: Si1TypeDefArray;
|
||||
readonly isTuple: boolean;
|
||||
readonly asTuple: SiTypeDefTuple;
|
||||
readonly asTuple: Si1TypeDefTuple;
|
||||
readonly isPrimitive: boolean;
|
||||
readonly asPrimitive: SiTypeDefPrimitive;
|
||||
readonly asPrimitive: Si1TypeDefPrimitive;
|
||||
readonly isCompact: boolean;
|
||||
readonly asCompact: SiTypeDefCompact;
|
||||
readonly asCompact: Si1TypeDefCompact;
|
||||
readonly isBitSequence: boolean;
|
||||
readonly asBitSequence: SiTypeDefBitSequence;
|
||||
readonly asBitSequence: Si1TypeDefBitSequence;
|
||||
readonly isHistoricMetaCompat: boolean;
|
||||
readonly asHistoricMetaCompat: Type;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefArray */
|
||||
export interface SiTypeDefArray extends Struct {
|
||||
/** @name Si1TypeDefArray */
|
||||
export interface Si1TypeDefArray extends Struct {
|
||||
readonly len: u32;
|
||||
readonly type: SiLookupTypeId;
|
||||
readonly type: Si1LookupTypeId;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefBitSequence */
|
||||
export interface SiTypeDefBitSequence extends Struct {
|
||||
readonly bitStoreType: SiLookupTypeId;
|
||||
readonly bitOrderType: SiLookupTypeId;
|
||||
/** @name Si1TypeDefBitSequence */
|
||||
export interface Si1TypeDefBitSequence extends Struct {
|
||||
readonly bitStoreType: Si1LookupTypeId;
|
||||
readonly bitOrderType: Si1LookupTypeId;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefCompact */
|
||||
export interface SiTypeDefCompact extends Struct {
|
||||
readonly type: SiLookupTypeId;
|
||||
/** @name Si1TypeDefCompact */
|
||||
export interface Si1TypeDefCompact extends Struct {
|
||||
readonly type: Si1LookupTypeId;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefComposite */
|
||||
export interface SiTypeDefComposite extends Struct {
|
||||
readonly fields: Vec<SiField>;
|
||||
/** @name Si1TypeDefComposite */
|
||||
export interface Si1TypeDefComposite extends Struct {
|
||||
readonly fields: Vec<Si1Field>;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefPrimitive */
|
||||
export interface SiTypeDefPrimitive 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 Si1TypeDefPrimitive */
|
||||
export interface Si1TypeDefPrimitive extends Si0TypeDefPrimitive {}
|
||||
|
||||
/** @name Si1TypeDefSequence */
|
||||
export interface Si1TypeDefSequence extends Struct {
|
||||
readonly type: Si1LookupTypeId;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefSequence */
|
||||
export interface SiTypeDefSequence extends Struct {
|
||||
readonly type: SiLookupTypeId;
|
||||
/** @name Si1TypeDefTuple */
|
||||
export interface Si1TypeDefTuple extends Vec<Si1LookupTypeId> {}
|
||||
|
||||
/** @name Si1TypeDefVariant */
|
||||
export interface Si1TypeDefVariant extends Struct {
|
||||
readonly variants: Vec<Si1Variant>;
|
||||
}
|
||||
|
||||
/** @name SiTypeDefTuple */
|
||||
export interface SiTypeDefTuple extends Vec<SiLookupTypeId> {}
|
||||
|
||||
/** @name SiTypeDefVariant */
|
||||
export interface SiTypeDefVariant extends Struct {
|
||||
readonly variants: Vec<SiVariant>;
|
||||
}
|
||||
|
||||
/** @name SiTypeParameter */
|
||||
export interface SiTypeParameter extends Struct {
|
||||
/** @name Si1TypeParameter */
|
||||
export interface Si1TypeParameter extends Struct {
|
||||
readonly name: Text;
|
||||
readonly type: Option<SiLookupTypeId>;
|
||||
readonly type: Option<Si1LookupTypeId>;
|
||||
}
|
||||
|
||||
/** @name SiVariant */
|
||||
export interface SiVariant extends Struct {
|
||||
/** @name Si1Variant */
|
||||
export interface Si1Variant extends Struct {
|
||||
readonly name: Text;
|
||||
readonly fields: Vec<SiField>;
|
||||
readonly fields: Vec<Si1Field>;
|
||||
readonly index: u8;
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name SiField */
|
||||
export interface SiField extends Si1Field {}
|
||||
|
||||
/** @name SiLookupTypeId */
|
||||
export interface SiLookupTypeId extends Si1LookupTypeId {}
|
||||
|
||||
/** @name SiPath */
|
||||
export interface SiPath extends Si1Path {}
|
||||
|
||||
/** @name SiType */
|
||||
export interface SiType extends Si1Type {}
|
||||
|
||||
/** @name SiTypeDef */
|
||||
export interface SiTypeDef extends Si1TypeDef {}
|
||||
|
||||
/** @name SiTypeDefArray */
|
||||
export interface SiTypeDefArray extends Si1TypeDefArray {}
|
||||
|
||||
/** @name SiTypeDefBitSequence */
|
||||
export interface SiTypeDefBitSequence extends Si1TypeDefBitSequence {}
|
||||
|
||||
/** @name SiTypeDefCompact */
|
||||
export interface SiTypeDefCompact extends Si1TypeDefCompact {}
|
||||
|
||||
/** @name SiTypeDefComposite */
|
||||
export interface SiTypeDefComposite extends Si1TypeDefComposite {}
|
||||
|
||||
/** @name SiTypeDefPrimitive */
|
||||
export interface SiTypeDefPrimitive extends Si1TypeDefPrimitive {}
|
||||
|
||||
/** @name SiTypeDefSequence */
|
||||
export interface SiTypeDefSequence extends Si1TypeDefSequence {}
|
||||
|
||||
/** @name SiTypeDefTuple */
|
||||
export interface SiTypeDefTuple extends Si1TypeDefTuple {}
|
||||
|
||||
/** @name SiTypeDefVariant */
|
||||
export interface SiTypeDefVariant extends Si1TypeDefVariant {}
|
||||
|
||||
/** @name SiTypeParameter */
|
||||
export interface SiTypeParameter extends Si1TypeParameter {}
|
||||
|
||||
/** @name SiVariant */
|
||||
export interface SiVariant extends Si1Variant {}
|
||||
|
||||
export type PHANTOM_SCALEINFO = 'scaleInfo';
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// 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 Si1Variant = {
|
||||
name: 'Text',
|
||||
fields: 'Vec<Si1Field>',
|
||||
index: 'u8',
|
||||
docs: 'Vec<Text>'
|
||||
};
|
||||
|
||||
export const v1: DefinitionsTypes = {
|
||||
Si1Field: {
|
||||
name: 'Option<Text>',
|
||||
type: 'Si1LookupTypeId',
|
||||
typeName: 'Option<Text>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
Si1LookupTypeId: 'Compact<u32>',
|
||||
Si1Path: 'Si0Path',
|
||||
Si1Type: {
|
||||
path: 'Si1Path',
|
||||
params: 'Vec<Si1TypeParameter>',
|
||||
def: 'Si1TypeDef',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
Si1TypeDef: {
|
||||
_enum: {
|
||||
Composite: 'Si1TypeDefComposite',
|
||||
Variant: 'Si1TypeDefVariant',
|
||||
Sequence: 'Si1TypeDefSequence',
|
||||
Array: 'Si1TypeDefArray',
|
||||
Tuple: 'Si1TypeDefTuple',
|
||||
Primitive: 'Si1TypeDefPrimitive',
|
||||
Compact: 'Si1TypeDefCompact',
|
||||
BitSequence: 'Si1TypeDefBitSequence',
|
||||
// NOTE: This is specific to the implementation for pre-v14 metadata
|
||||
// compatibility (always keep this as the last entry in the enum)
|
||||
HistoricMetaCompat: 'Type'
|
||||
}
|
||||
},
|
||||
Si1TypeDefArray: {
|
||||
len: 'u32',
|
||||
type: 'Si1LookupTypeId'
|
||||
},
|
||||
Si1TypeDefBitSequence: {
|
||||
bitStoreType: 'Si1LookupTypeId',
|
||||
bitOrderType: 'Si1LookupTypeId'
|
||||
},
|
||||
Si1TypeDefCompact: {
|
||||
type: 'Si1LookupTypeId'
|
||||
},
|
||||
Si1TypeDefComposite: {
|
||||
fields: 'Vec<Si1Field>'
|
||||
},
|
||||
Si1TypeDefPrimitive: 'Si0TypeDefPrimitive',
|
||||
Si1TypeDefSequence: {
|
||||
type: 'Si1LookupTypeId'
|
||||
},
|
||||
Si1TypeDefTuple: 'Vec<Si1LookupTypeId>',
|
||||
Si1TypeParameter: {
|
||||
name: 'Text',
|
||||
type: 'Option<Si1LookupTypeId>'
|
||||
},
|
||||
Si1TypeDefVariant: {
|
||||
variants: 'Vec<Si1Variant>'
|
||||
},
|
||||
Si1Variant
|
||||
};
|
||||
Reference in New Issue
Block a user