diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e00508a0..052431cfb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # CHANGELOG +## 6.0.5 Sep 20, 2012 + +Upgrade priority: Low. Recommended for all users on 6.0.3 using `api.query.*.*.at` calls + +Changes: + +- Revert cross-registry (now-inactive) change introduced in 6.0.3 +- Ensure `Option` is correctly imported for TS query generation + + ## 6.0.4 Sep 20, 2021 Upgrade priority: Low. Recommended for all users on 6.0.3 using `api.query.*.*.at` calls diff --git a/package.json b/package.json index 94b680400b..c94df126af 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,6 @@ "@types/jest": "^27.0.1", "copyfiles": "^2.4.1" }, - "version": "6.0.4", + "version": "6.0.5", "packageManager": "yarn@3.0.1" } diff --git a/packages/api-contract/package.json b/packages/api-contract/package.json index 3218394d4b..eac9162444 100644 --- a/packages/api-contract/package.json +++ b/packages/api-contract/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/api-contract", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Interfaces for interacting with contracts and contract ABIs", "main": "index.js", @@ -20,8 +20,8 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme", "dependencies": { "@babel/runtime": "^7.15.4", - "@polkadot/api": "6.0.4", - "@polkadot/types": "6.0.4", + "@polkadot/api": "6.0.5", + "@polkadot/types": "6.0.5", "@polkadot/util": "^7.4.1", "rxjs": "^7.3.0" } diff --git a/packages/api-contract/src/packageInfo.ts b/packages/api-contract/src/packageInfo.ts index d0696eb52b..da194fa898 100644 --- a/packages/api-contract/src/packageInfo.ts +++ b/packages/api-contract/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/api-contract', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/api-contract', version: '6.0.5' }; diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index 81fdec8d00..e2d3e53307 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/api-derive", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Common functions used across Polkadot, derived from RPC calls and storage queries.", "main": "index.js", @@ -20,15 +20,15 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme", "dependencies": { "@babel/runtime": "^7.15.4", - "@polkadot/api": "6.0.4", - "@polkadot/rpc-core": "6.0.4", - "@polkadot/types": "6.0.4", + "@polkadot/api": "6.0.5", + "@polkadot/rpc-core": "6.0.5", + "@polkadot/types": "6.0.5", "@polkadot/util": "^7.4.1", "@polkadot/util-crypto": "^7.4.1", "rxjs": "^7.3.0" }, "devDependencies": { "@polkadot/keyring": "^7.4.1", - "@polkadot/rpc-provider": "6.0.4" + "@polkadot/rpc-provider": "6.0.5" } } diff --git a/packages/api-derive/src/packageInfo.ts b/packages/api-derive/src/packageInfo.ts index 99850a0bf0..e1f9d3820e 100644 --- a/packages/api-derive/src/packageInfo.ts +++ b/packages/api-derive/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/api-derive', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/api-derive', version: '6.0.5' }; diff --git a/packages/api/package.json b/packages/api/package.json index 01745f137e..72035367fd 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/api", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Promise and RxJS wrappers around the Polkadot JS RPC", "main": "index.js", @@ -20,12 +20,12 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", "dependencies": { "@babel/runtime": "^7.15.4", - "@polkadot/api-derive": "6.0.4", + "@polkadot/api-derive": "6.0.5", "@polkadot/keyring": "^7.4.1", - "@polkadot/rpc-core": "6.0.4", - "@polkadot/rpc-provider": "6.0.4", - "@polkadot/types": "6.0.4", - "@polkadot/types-known": "6.0.4", + "@polkadot/rpc-core": "6.0.5", + "@polkadot/rpc-provider": "6.0.5", + "@polkadot/types": "6.0.5", + "@polkadot/types-known": "6.0.5", "@polkadot/util": "^7.4.1", "@polkadot/util-crypto": "^7.4.1", "eventemitter3": "^4.0.7", diff --git a/packages/api/src/packageInfo.ts b/packages/api/src/packageInfo.ts index 0126e219ce..00726de541 100644 --- a/packages/api/src/packageInfo.ts +++ b/packages/api/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/api', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/api', version: '6.0.5' }; diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index 34c9eff3a4..875dfc4ed3 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/rpc-core", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "main": "index.js", @@ -20,8 +20,8 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme", "dependencies": { "@babel/runtime": "^7.15.4", - "@polkadot/rpc-provider": "6.0.4", - "@polkadot/types": "6.0.4", + "@polkadot/rpc-provider": "6.0.5", + "@polkadot/types": "6.0.5", "@polkadot/util": "^7.4.1", "rxjs": "^7.3.0" }, diff --git a/packages/rpc-core/src/packageInfo.ts b/packages/rpc-core/src/packageInfo.ts index cdd7d3f2ad..df6477ad61 100644 --- a/packages/rpc-core/src/packageInfo.ts +++ b/packages/rpc-core/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/rpc-core', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/rpc-core', version: '6.0.5' }; diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index 5cf7c9364e..a4faa34a9e 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/rpc-provider", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Transport providers for the API", "main": "index.js", @@ -20,7 +20,7 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme", "dependencies": { "@babel/runtime": "^7.15.4", - "@polkadot/types": "6.0.4", + "@polkadot/types": "6.0.5", "@polkadot/util": "^7.4.1", "@polkadot/util-crypto": "^7.4.1", "@polkadot/x-fetch": "^7.4.1", @@ -30,7 +30,7 @@ }, "devDependencies": { "@polkadot/keyring": "^7.4.1", - "@polkadot/types": "6.0.4", + "@polkadot/types": "6.0.5", "mock-socket": "^9.0.3", "nock": "^13.1.3" } diff --git a/packages/rpc-provider/src/packageInfo.ts b/packages/rpc-provider/src/packageInfo.ts index f24b21cf5f..7149e3ae6c 100644 --- a/packages/rpc-provider/src/packageInfo.ts +++ b/packages/rpc-provider/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.0.5' }; diff --git a/packages/typegen/package.json b/packages/typegen/package.json index 9e8511cb54..feda964e7d 100644 --- a/packages/typegen/package.json +++ b/packages/typegen/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/typegen", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Type generation scripts", "main": "index.js", @@ -29,10 +29,10 @@ "@babel/core": "^7.15.5", "@babel/register": "^7.15.3", "@babel/runtime": "^7.15.4", - "@polkadot/api": "6.0.4", - "@polkadot/rpc-provider": "6.0.4", - "@polkadot/types": "6.0.4", - "@polkadot/types-support": "6.0.4", + "@polkadot/api": "6.0.5", + "@polkadot/rpc-provider": "6.0.5", + "@polkadot/types": "6.0.5", + "@polkadot/types-support": "6.0.5", "@polkadot/util": "^7.4.1", "handlebars": "^4.7.7", "websocket": "^1.0.34", diff --git a/packages/typegen/src/generate/query.ts b/packages/typegen/src/generate/query.ts index 4c4685b4c6..fdacda8964 100644 --- a/packages/typegen/src/generate/query.ts +++ b/packages/typegen/src/generate/query.ts @@ -24,7 +24,12 @@ function entrySignature (lookup: PortableRegistry, allDefs: Record((all, t) => all.concat(t), []), + storageEntry.modifier.isOptional + ? 'Option' + : null, defValue.lookupName ? undefined : defValue.type diff --git a/packages/typegen/src/packageInfo.ts b/packages/typegen/src/packageInfo.ts index 8b46be0e9d..abb8935576 100644 --- a/packages/typegen/src/packageInfo.ts +++ b/packages/typegen/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/typegen', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/typegen', version: '6.0.5' }; diff --git a/packages/types-known/package.json b/packages/types-known/package.json index 83b609b211..6d006a14e2 100644 --- a/packages/types-known/package.json +++ b/packages/types-known/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/types-known", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Known type definitions", "main": "index.js", @@ -21,7 +21,7 @@ "dependencies": { "@babel/runtime": "^7.15.4", "@polkadot/networks": "^7.4.1", - "@polkadot/types": "6.0.4", + "@polkadot/types": "6.0.5", "@polkadot/util": "^7.4.1" } } diff --git a/packages/types-known/src/packageInfo.ts b/packages/types-known/src/packageInfo.ts index 6b64818001..a64843e8a4 100644 --- a/packages/types-known/src/packageInfo.ts +++ b/packages/types-known/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/types-known', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/types-known', version: '6.0.5' }; diff --git a/packages/types-support/package.json b/packages/types-support/package.json index edf19ec41d..3b23cea331 100644 --- a/packages/types-support/package.json +++ b/packages/types-support/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/types-support", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Supporting files for types, mostly for testing", "main": "index.js", diff --git a/packages/types-support/src/packageInfo.ts b/packages/types-support/src/packageInfo.ts index 9e17090a9e..5f1a80224b 100644 --- a/packages/types-support/src/packageInfo.ts +++ b/packages/types-support/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/types-support', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/types-support', version: '6.0.5' }; diff --git a/packages/types/package.json b/packages/types/package.json index 7b35dff552..f3cb87f336 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/types", - "version": "6.0.4", + "version": "6.0.5", "type": "module", "description": "Implementation of the Parity codec", "main": "index.js", @@ -26,7 +26,7 @@ }, "devDependencies": { "@polkadot/keyring": "^7.4.1", - "@polkadot/types-support": "6.0.4", + "@polkadot/types-support": "6.0.5", "@types/bn.js": "^4.11.6", "bn.js": "^4.12.0" } diff --git a/packages/types/src/create/registry.ts b/packages/types/src/create/registry.ts index cfba3938de..159d7848c8 100644 --- a/packages/types/src/create/registry.ts +++ b/packages/types/src/create/registry.ts @@ -3,7 +3,7 @@ import type { ExtDef } from '../extrinsic/signedExtensions/types'; import type { ChainProperties, CodecHash, DispatchErrorModule, Hash, MetadataLatest, PortableRegistry, SiLookupTypeId } from '../interfaces/types'; -import type { CallFunction, Codec, CodecHasher, Constructor, DetectCodec, DetectConstructor, RegisteredTypes, Registry, RegistryError, RegistryTypes, TypeSpec } from '../types'; +import type { CallFunction, Codec, CodecHasher, Constructor, DetectCodec, DetectConstructor, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types'; import type { CreateOptions } from './types'; import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, stringify, u8aToHex } from '@polkadot/util'; @@ -145,8 +145,6 @@ export class TypeRegistry implements Registry { #userExtensions?: ExtDef; - public compatSpecs: TypeSpec[] = []; - public createdAtHash?: Hash; constructor (createdAtHash?: Hash | Uint8Array | string) { diff --git a/packages/types/src/metadata/v13/toV14.ts b/packages/types/src/metadata/v13/toV14.ts index aacc72890f..0df599d448 100644 --- a/packages/types/src/metadata/v13/toV14.ts +++ b/packages/types/src/metadata/v13/toV14.ts @@ -5,7 +5,7 @@ import type { ErrorMetadataV13, EventMetadataV13, ExtrinsicMetadataV13, Extrinsi import type { SiVariant } from '../../interfaces/scaleInfo'; import type { Text } from '../../primitive/Text'; import type { Type } from '../../primitive/Type'; -import type { OverrideModuleType, Registry, TypeSpec } from '../../types'; +import type { OverrideModuleType, Registry } from '../../types'; import { getModuleTypes, knownOrigins } from '@polkadot/types-known'; import { stringCamelCase } from '@polkadot/util'; @@ -16,15 +16,26 @@ interface MapDef { value: Type; } +export interface TypeSpec { + def: { + HistoricMetaCompat?: string; + Tuple?: number[]; + Variant?: { + variants: SiVariant[]; + } + }, + path?: string[]; +} + const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']]; /** * Creates a compatible type mapping * @internal **/ -function compatType (types: TypeSpec[], _type: Text | string): number { +function compatType (compatTypes: TypeSpec[], _type: Text | string): number { const type = _type.toString(); - const index = types.findIndex(({ def }) => + const index = compatTypes.findIndex(({ def }) => def.HistoricMetaCompat === type ); @@ -32,13 +43,23 @@ function compatType (types: TypeSpec[], _type: Text | string): number { return index; } - return types.push({ - def: { HistoricMetaCompat: type } + return compatTypes.push({ + def: { + HistoricMetaCompat: type + } }) - 1; } -function variantType (modName: Text, variantType: string, types: TypeSpec[], variants: SiVariant[]): number { - return types.push({ +function makeTupleType (compatTypes: TypeSpec[], entries: number[]): number { + return compatTypes.push({ + def: { + Tuple: entries + } + }) - 1; +} + +function makeVariantType (modName: Text, variantType: string, compatTypes: TypeSpec[], variants: SiVariant[]): number { + return compatTypes.push({ def: { Variant: { variants } }, @@ -104,14 +125,14 @@ function setTypeOverride (sectionTypes: OverrideModuleType, types: Type[]): void * Apply module-specific type overrides (always be done as part of toV14) * @internal **/ -function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): PalletCallMetadataV14 { +function convertCalls (compatTypes: TypeSpec[], registry: Registry, modName: Text, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): PalletCallMetadataV14 { const variants = calls.map(({ args, docs, name }, index): SiVariant => { setTypeOverride(sectionTypes, args.map(({ type }) => type)); return registry.createType('SiVariant', { docs, fields: args.map(({ name, type }) => - registry.createType('SiField', { name, type: compatType(registry.compatSpecs, type) }) + registry.createType('SiField', { name, type: compatType(compatTypes, type) }) ), index, name @@ -119,7 +140,7 @@ function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadat }); return registry.createType('PalletCallMetadataV14', { - type: variantType(modName, 'Call', registry.compatSpecs, variants) + type: makeVariantType(modName, 'Call', compatTypes, variants) }); } @@ -127,14 +148,14 @@ function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadat * Apply module-specific type overrides (always be done as part of toV14) * @internal */ -function convertConstants (registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): PalletConstantMetadataV14[] { +function convertConstants (compatTypes: TypeSpec[], registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): PalletConstantMetadataV14[] { return constants.map(({ docs, name, type, value }): PalletConstantMetadataV14 => { setTypeOverride(sectionTypes, [type]); return registry.createType('PalletConstantMetadataV14', { docs, name, - type: compatType(registry.compatSpecs, type), + type: compatType(compatTypes, type), value }); }); @@ -145,7 +166,7 @@ function convertConstants (registry: Registry, constants: ModuleConstantMetadata * @internal */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadataV13[], _sectionTypes: OverrideModuleType): PalletErrorMetadataV14 { +function convertErrors (compatTypes: TypeSpec[], registry: Registry, modName: Text, errors: ErrorMetadataV13[], _sectionTypes: OverrideModuleType): PalletErrorMetadataV14 { const variants = errors.map(({ docs, name }, index): SiVariant => registry.createType('SiVariant', { docs, @@ -156,7 +177,7 @@ function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadata ); return registry.createType('PalletErrorMetadataV14', { - type: variantType(modName, 'Error', registry.compatSpecs, variants) + type: makeVariantType(modName, 'Error', compatTypes, variants) }); } @@ -164,14 +185,14 @@ function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadata * Apply module-specific type overrides (always be done as part of toV14) * @internal **/ -function convertEvents (registry: Registry, modName: Text, events: EventMetadataV13[], sectionTypes: OverrideModuleType): PalletEventMetadataV14 { +function convertEvents (compatTypes: TypeSpec[], registry: Registry, modName: Text, events: EventMetadataV13[], sectionTypes: OverrideModuleType): PalletEventMetadataV14 { const variants = events.map(({ args, docs, name }, index): SiVariant => { setTypeOverride(sectionTypes, args); return registry.createType('SiVariant', { docs, fields: args.map((t) => - registry.createType('SiField', { type: compatType(registry.compatSpecs, t) }) + registry.createType('SiField', { type: compatType(compatTypes, t) }) ), index, name @@ -179,20 +200,20 @@ function convertEvents (registry: Registry, modName: Text, events: EventMetadata }); return registry.createType('PalletEventMetadataV14', { - type: variantType(modName, 'Event', registry.compatSpecs, variants) + type: makeVariantType(modName, 'Event', compatTypes, variants) }); } -function createMapEntry (registry: Registry, sectionTypes: OverrideModuleType, { hashers, keys, value }: MapDef): StorageEntryTypeV14 { +function createMapEntry (compatTypes: TypeSpec[], registry: Registry, sectionTypes: OverrideModuleType, { hashers, keys, value }: MapDef): StorageEntryTypeV14 { setTypeOverride(sectionTypes, [value, ...(Array.isArray(keys) ? keys : [keys])]); return registry.createType('StorageEntryTypeV14', { Map: { hashers, key: hashers.length === 1 - ? compatType(registry.compatSpecs, keys[0]) - : (registry.compatSpecs.push({ def: { Tuple: keys.map((t) => compatType(registry.compatSpecs, t)) } }) - 1), - value: compatType(registry.compatSpecs, value) + ? compatType(compatTypes, keys[0]) + : makeTupleType(compatTypes, keys.map((t) => compatType(compatTypes, t))), + value: compatType(compatTypes, value) } }); } @@ -201,7 +222,7 @@ function createMapEntry (registry: Registry, sectionTypes: OverrideModuleType, { * Apply module-specific storage type overrides (always part of toV14) * @internal **/ -function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): PalletStorageMetadataV14 { +function convertStorage (compatTypes: TypeSpec[], registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): PalletStorageMetadataV14 { return registry.createType('PalletStorageMetadataV14', { items: items.map(({ docs, fallback, modifier, name, type }): StorageEntryMetadataV14 => { let entryType: StorageEntryTypeV14; @@ -212,12 +233,12 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV setTypeOverride(sectionTypes, [plain]); entryType = registry.createType('StorageEntryTypeV14', { - Plain: compatType(registry.compatSpecs, plain) + Plain: compatType(compatTypes, plain) }); } else if (type.isMap) { const map = type.asMap; - entryType = createMapEntry(registry, sectionTypes, { + entryType = createMapEntry(compatTypes, registry, sectionTypes, { hashers: [map.hasher], keys: [map.key], value: map.value @@ -225,7 +246,7 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV } else if (type.isDoubleMap) { const dm = type.asDoubleMap; - entryType = createMapEntry(registry, sectionTypes, { + entryType = createMapEntry(compatTypes, registry, sectionTypes, { hashers: [dm.hasher, dm.key2Hasher], keys: [dm.key1, dm.key2], value: dm.value @@ -233,7 +254,7 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV } else { const nm = type.asNMap; - entryType = createMapEntry(registry, sectionTypes, { + entryType = createMapEntry(compatTypes, registry, sectionTypes, { hashers: nm.hashers, keys: nm.keyVec, value: nm.value @@ -266,17 +287,17 @@ function convertExtrinsic (registry: Registry, { signedExtensions, version }: Ex } /** @internal */ -function createPallet (registry: Registry, mod: ModuleMetadataV13, { calls, constants, errors, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], errors: ErrorMetadataV13[] | null, events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): PalletMetadataV14 { +function createPallet (compatTypes: TypeSpec[], registry: Registry, mod: ModuleMetadataV13, { calls, constants, errors, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], errors: ErrorMetadataV13[] | null, events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): PalletMetadataV14 { const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name)); return registry.createType('PalletMetadataV14', { - calls: calls && convertCalls(registry, mod.name, calls, sectionTypes), - constants: convertConstants(registry, constants, sectionTypes), - errors: errors && convertErrors(registry, mod.name, errors, sectionTypes), - events: events && convertEvents(registry, mod.name, events, sectionTypes), + calls: calls && convertCalls(compatTypes, registry, mod.name, calls, sectionTypes), + constants: convertConstants(compatTypes, registry, constants, sectionTypes), + errors: errors && convertErrors(compatTypes, registry, mod.name, errors, sectionTypes), + events: events && convertEvents(compatTypes, registry, mod.name, events, sectionTypes), index: mod.index, name: mod.name, - storage: storage && convertStorage(registry, storage, sectionTypes) + storage: storage && convertStorage(compatTypes, registry, storage, sectionTypes) }); } @@ -285,12 +306,14 @@ function createPallet (registry: Registry, mod: ModuleMetadataV13, { calls, cons * @internal **/ export function toV14 (registry: Registry, v13: MetadataV13, metaVersion: number): MetadataV14 { - compatType(registry.compatSpecs, 'Null'); // position 0 always has Null + const compatTypes: TypeSpec[] = []; + + compatType(compatTypes, 'Null'); // position 0 always has Null registerOriginCaller(registry, v13.modules, metaVersion); const extrinsic = convertExtrinsic(registry, v13.extrinsic); const pallets = v13.modules.map((mod) => - createPallet(registry, mod, { + createPallet(compatTypes, registry, mod, { calls: mod.calls.unwrapOr(null), constants: mod.constants, errors: mod.errors.length ? mod.errors : null, @@ -302,7 +325,7 @@ export function toV14 (registry: Registry, v13: MetadataV13, metaVersion: number return registry.createType('MetadataV14', { extrinsic, lookup: { - types: registry.compatSpecs.map((type, id) => + types: compatTypes.map((type, id) => registry.createType('PortableType', { id, type }) ) }, diff --git a/packages/types/src/packageInfo.ts b/packages/types/src/packageInfo.ts index f445f1f738..61c95dcea0 100644 --- a/packages/types/src/packageInfo.ts +++ b/packages/types/src/packageInfo.ts @@ -3,4 +3,4 @@ // Auto-generated by @polkadot/dev, do not edit -export const packageInfo = { name: '@polkadot/types', version: '6.0.4' }; +export const packageInfo = { name: '@polkadot/types', version: '6.0.5' }; diff --git a/packages/types/src/types/registry.ts b/packages/types/src/types/registry.ts index b3da360a6d..bf9a6f3ed3 100644 --- a/packages/types/src/types/registry.ts +++ b/packages/types/src/types/registry.ts @@ -7,7 +7,7 @@ import type { CreateOptions } from '../create/types'; import type { ExtDef } from '../extrinsic/signedExtensions/types'; import type { MetadataLatest, PortableRegistry } from '../interfaces/metadata'; import type { CodecHash, Hash } from '../interfaces/runtime'; -import type { SiField, SiLookupTypeId, SiVariant } from '../interfaces/scaleInfo'; +import type { SiField, SiLookupTypeId } from '../interfaces/scaleInfo'; import type { ChainProperties } from '../interfaces/system'; import type { Metadata } from '../metadata'; import type { CallFunction } from './calls'; @@ -47,17 +47,6 @@ export interface RegistryError { section: string; } -export interface TypeSpec { - def: { - HistoricMetaCompat?: string; - Tuple?: number[]; - Variant?: { - variants: SiVariant[]; - } - }, - path?: string[]; -} - export interface OverrideVersionedType { // min (v >= min) and max (v <= max) minmax: [number | undefined | null, number | undefined | null] | [number?, number?] | (number | undefined | null)[]; @@ -123,7 +112,6 @@ export interface Registry { readonly unknownTypes: string[]; readonly signedExtensions: string[]; - compatSpecs: TypeSpec[]; createdAtHash?: Hash; findMetaCall (callIndex: Uint8Array): CallFunction; diff --git a/yarn.lock b/yarn.lock index 13a2277653..2d5ddefd2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1854,40 +1854,40 @@ __metadata: resolution: "@polkadot/api-contract@workspace:packages/api-contract" dependencies: "@babel/runtime": ^7.15.4 - "@polkadot/api": 6.0.4 - "@polkadot/types": 6.0.4 + "@polkadot/api": 6.0.5 + "@polkadot/types": 6.0.5 "@polkadot/util": ^7.4.1 rxjs: ^7.3.0 languageName: unknown linkType: soft -"@polkadot/api-derive@6.0.4, @polkadot/api-derive@workspace:packages/api-derive": +"@polkadot/api-derive@6.0.5, @polkadot/api-derive@workspace:packages/api-derive": version: 0.0.0-use.local resolution: "@polkadot/api-derive@workspace:packages/api-derive" dependencies: "@babel/runtime": ^7.15.4 - "@polkadot/api": 6.0.4 + "@polkadot/api": 6.0.5 "@polkadot/keyring": ^7.4.1 - "@polkadot/rpc-core": 6.0.4 - "@polkadot/rpc-provider": 6.0.4 - "@polkadot/types": 6.0.4 + "@polkadot/rpc-core": 6.0.5 + "@polkadot/rpc-provider": 6.0.5 + "@polkadot/types": 6.0.5 "@polkadot/util": ^7.4.1 "@polkadot/util-crypto": ^7.4.1 rxjs: ^7.3.0 languageName: unknown linkType: soft -"@polkadot/api@6.0.4, @polkadot/api@workspace:packages/api": +"@polkadot/api@6.0.5, @polkadot/api@workspace:packages/api": version: 0.0.0-use.local resolution: "@polkadot/api@workspace:packages/api" dependencies: "@babel/runtime": ^7.15.4 - "@polkadot/api-derive": 6.0.4 + "@polkadot/api-derive": 6.0.5 "@polkadot/keyring": ^7.4.1 - "@polkadot/rpc-core": 6.0.4 - "@polkadot/rpc-provider": 6.0.4 - "@polkadot/types": 6.0.4 - "@polkadot/types-known": 6.0.4 + "@polkadot/rpc-core": 6.0.5 + "@polkadot/rpc-provider": 6.0.5 + "@polkadot/types": 6.0.5 + "@polkadot/types-known": 6.0.5 "@polkadot/util": ^7.4.1 "@polkadot/util-crypto": ^7.4.1 eventemitter3: ^4.0.7 @@ -2012,26 +2012,26 @@ __metadata: languageName: node linkType: hard -"@polkadot/rpc-core@6.0.4, @polkadot/rpc-core@workspace:packages/rpc-core": +"@polkadot/rpc-core@6.0.5, @polkadot/rpc-core@workspace:packages/rpc-core": version: 0.0.0-use.local resolution: "@polkadot/rpc-core@workspace:packages/rpc-core" dependencies: "@babel/runtime": ^7.15.4 "@polkadot/keyring": ^7.4.1 - "@polkadot/rpc-provider": 6.0.4 - "@polkadot/types": 6.0.4 + "@polkadot/rpc-provider": 6.0.5 + "@polkadot/types": 6.0.5 "@polkadot/util": ^7.4.1 rxjs: ^7.3.0 languageName: unknown linkType: soft -"@polkadot/rpc-provider@6.0.4, @polkadot/rpc-provider@workspace:packages/rpc-provider": +"@polkadot/rpc-provider@6.0.5, @polkadot/rpc-provider@workspace:packages/rpc-provider": version: 0.0.0-use.local resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider" dependencies: "@babel/runtime": ^7.15.4 "@polkadot/keyring": ^7.4.1 - "@polkadot/types": 6.0.4 + "@polkadot/types": 6.0.5 "@polkadot/util": ^7.4.1 "@polkadot/util-crypto": ^7.4.1 "@polkadot/x-fetch": ^7.4.1 @@ -2059,10 +2059,10 @@ __metadata: "@babel/core": ^7.15.5 "@babel/register": ^7.15.3 "@babel/runtime": ^7.15.4 - "@polkadot/api": 6.0.4 - "@polkadot/rpc-provider": 6.0.4 - "@polkadot/types": 6.0.4 - "@polkadot/types-support": 6.0.4 + "@polkadot/api": 6.0.5 + "@polkadot/rpc-provider": 6.0.5 + "@polkadot/types": 6.0.5 + "@polkadot/types-support": 6.0.5 "@polkadot/util": ^7.4.1 "@types/websocket": ^1.0.4 "@types/yargs": ^17.0.2 @@ -2078,18 +2078,18 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/types-known@6.0.4, @polkadot/types-known@workspace:packages/types-known": +"@polkadot/types-known@6.0.5, @polkadot/types-known@workspace:packages/types-known": version: 0.0.0-use.local resolution: "@polkadot/types-known@workspace:packages/types-known" dependencies: "@babel/runtime": ^7.15.4 "@polkadot/networks": ^7.4.1 - "@polkadot/types": 6.0.4 + "@polkadot/types": 6.0.5 "@polkadot/util": ^7.4.1 languageName: unknown linkType: soft -"@polkadot/types-support@6.0.4, @polkadot/types-support@workspace:packages/types-support": +"@polkadot/types-support@6.0.5, @polkadot/types-support@workspace:packages/types-support": version: 0.0.0-use.local resolution: "@polkadot/types-support@workspace:packages/types-support" dependencies: @@ -2098,13 +2098,13 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/types@6.0.4, @polkadot/types@workspace:packages/types": +"@polkadot/types@6.0.5, @polkadot/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@polkadot/types@workspace:packages/types" dependencies: "@babel/runtime": ^7.15.4 "@polkadot/keyring": ^7.4.1 - "@polkadot/types-support": 6.0.4 + "@polkadot/types-support": 6.0.5 "@polkadot/util": ^7.4.1 "@polkadot/util-crypto": ^7.4.1 "@types/bn.js": ^4.11.6