Compare commits

...
60 Commits
Author SHA1 Message Date
Github Actions 4a63026b14 [CI Skip] release/stable 5.2.1
skip-checks: true
2021-07-26 06:19:38 +00:00
Jaco a40ce72298 5.2.1 (#3810) 2021-07-26 08:07:12 +02:00
Github Actions f302d8de69 [CI Skip] release/beta 5.1.2-13
skip-checks: true
2021-07-26 05:51:34 +00:00
Lezek123 fcaebbdbb2 BTreeSet and BTreeMap - encoding and serialization fixes (#3789)
* BTreeSet and BTreeMap - encoding and serialization fixes

* Fix linter issues

* BTreeSet/BTreeMap: Support for Struct and Enum sorting

* Cleanup sorting function
2021-07-26 07:41:25 +02:00
Github Actions 9e7037af04 [CI Skip] release/beta 5.1.2-12
skip-checks: true
2021-07-25 05:41:15 +00:00
Jaco 68efac60df Allow struct alias on PortableRegistry (#3808)
* Allow struct aliasses on PortableRegistry

* Add resrved alias

* Naing adjustment

* No name for flattenned Tuple

* Add docs
2021-07-25 07:30:57 +02:00
Github Actions d763f49e8b [CI Skip] release/beta 5.1.2-11
skip-checks: true
2021-07-24 13:59:55 +00:00
Jaco 77ffd7c153 Metadata v13 to v14 conversion (#3807) 2021-07-24 15:50:06 +02:00
Jaco d1506154bd PortableRegistry support for BTreeMap (#3806)
* PortableRegistry support for BTreeMap

* Update packages/types/src/generic/PortableRegistry.ts
2021-07-24 15:49:39 +02:00
Github Actions b1254685da [CI Skip] release/beta 5.1.2-10
skip-checks: true
2021-07-24 06:43:27 +00:00
Jaco 81a2a2c688 Adjust type encoding (#3805)
* Adjust type encoding

* Adjust

* displayName adjustments
2021-07-24 08:32:36 +02:00
Github Actions 1fed997080 [CI Skip] release/beta 5.1.2-9
skip-checks: true
2021-07-23 16:13:24 +00:00
Jaco 6e620e3bb3 Short-circuit full type (with lookupIndex) (#3804)
* Short-circuit full type (with lookupIndex)

* Defaults for type expansion

* Tuple with extra spaces removed

* Fill in generated types

* Adjust generation

* Adjust tests

* Adjust
2021-07-23 18:04:14 +02:00
Github Actions 6e4c62ea99 [CI Skip] release/beta 5.1.2-8
skip-checks: true
2021-07-23 10:02:58 +00:00
Jaco 8972d2ffe9 Add type string generation to PortableRegistry (#3802)
* Add type string generation to PortableRegistry

* createClass updates

* Add missing field
2021-07-23 11:51:40 +02:00
Github Actions 091d2d30e0 [CI Skip] release/beta 5.1.2-7
skip-checks: true
2021-07-22 18:26:01 +00:00
Jaco ae7ded1767 Extensive formatting for TypeDef -> string (#3800)
* Extensive formatting for TypeDef -> string

* Remove helpers
2021-07-22 20:15:44 +02:00
Github Actions 8aa3550354 [CI Skip] release/beta 5.1.2-6
skip-checks: true
2021-07-22 17:48:31 +00:00
Jaco 196d3c5995 Pass registry to formatters (#3799) 2021-07-22 19:39:40 +02:00
Github Actions 592407d691 [CI Skip] release/beta 5.1.2-5
skip-checks: true
2021-07-22 11:28:43 +00:00
Jaco 1e3a1bb51c Allow for type overrides via path (#3797) 2021-07-22 13:18:31 +02:00
Github Actions 2ca23a85d0 [CI Skip] release/beta 5.1.2-4
skip-checks: true
2021-07-22 09:52:22 +00:00
Jaco 1a04b4a72e Fix lookup type expansion (#3796) 2021-07-22 11:43:08 +02:00
Github Actions 6dfe7c4f56 [CI Skip] release/beta 5.1.2-3
skip-checks: true
2021-07-22 09:01:44 +00:00
Jaco 3f9f7bd649 Flatten PortableRegistry type creation (#3795) 2021-07-22 10:51:56 +02:00
Github Actions e02e1302b2 [CI Skip] release/beta 5.1.2-2
skip-checks: true
2021-07-21 12:33:19 +00:00
Jaco a64dec3487 v14 static bump (w/ call param names) (#3788) 2021-07-21 14:22:16 +02:00
Github Actions 3415fbd121 [CI Skip] release/beta 5.1.2-1
skip-checks: true
2021-07-21 09:47:32 +00:00
Jaco 0be1d46be9 RPC-core createType swap (#3786)
* RPC-core createType swap

* CHANGELOG

* createType complexity
2021-07-21 11:36:10 +02:00
Github Actions 9309e9f3a1 [CI Skip] release/beta 5.1.2-0
skip-checks: true
2021-07-20 12:27:49 +00:00
Jaco 6dd019343d Adjust generation sorting (#3785) 2021-07-20 14:14:14 +02:00
Github Actions 20f18c72e5 [CI Skip] release/stable 5.1.1
skip-checks: true
2021-07-19 13:14:57 +00:00
Jaco 6a31cbe1a2 5.1.1 (#3783)
* 5.1.1

* Bump common
2021-07-19 15:01:07 +02:00
Jaco acba636d16 Latest v14 metadata (#3782) 2021-07-19 14:27:10 +02:00
Github Actions 6356fe0571 [CI Skip] release/beta 5.0.2-12
skip-checks: true
2021-07-19 08:27:44 +00:00
Jaco 3e17824539 Move Lookup check to registry (#3780) 2021-07-19 10:17:26 +02:00
Github Actions db9e580f82 [CI Skip] release/beta 5.0.2-11
skip-checks: true
2021-07-17 09:47:49 +00:00
Jaco 5ffcba6dd5 Adjust with current scale-info outputs (#3779)
* Adjust with current scale-info outputs

* Linting

* Exhaustive check for encoders
2021-07-17 11:36:19 +02:00
Github Actions 731846088c [CI Skip] release/beta 5.0.2-10
skip-checks: true
2021-07-16 14:50:41 +00:00
Jaco 8b87689489 Add PortableRegistry for v14 lookups (#3778) 2021-07-16 16:39:38 +02:00
Github Actions 5a299adddc [CI Skip] release/beta 5.0.2-9
skip-checks: true
2021-07-16 13:42:49 +00:00
Jaco 99bb6cfe71 Additional AccountId{20, 32} mappings (#3777) 2021-07-16 15:31:18 +02:00
Github Actions ad9a8605d7 [CI Skip] release/beta 5.0.2-8
skip-checks: true
2021-07-16 12:07:44 +00:00
Jaco d62bfc55ac Adjust scale-info types (updated v14, contracts rename) (#3776)
* Adjust scale-info types (updated v14, contracts rename)

* Adjust v14 metadata

* PortableRegistry -> lookup

* Rewrite json
2021-07-16 13:57:44 +02:00
Github Actions 311740a1a2 [CI Skip] release/beta 5.0.2-7
skip-checks: true
2021-07-15 08:45:19 +00:00
Jaco 3285f1f122 v14 Type changes (#3774)
* v14 Type changes

* Registry
2021-07-15 10:34:41 +02:00
Github Actions 2a9711a3cb [CI Skip] release/beta 5.0.2-6
skip-checks: true
2021-07-14 05:53:10 +00:00
Jaco 3ea7cb47ce Update v14 types (#3771) 2021-07-14 07:42:30 +02:00
Github Actions 82fc46881a [CI Skip] release/beta 5.0.2-5
skip-checks: true
2021-07-13 20:55:31 +00:00
Denis Tsai e7758ad54c realign AccountKey20Junction to polkadot xcm's Junction enum (#3770) 2021-07-13 22:43:08 +02:00
Github Actions 7d3ab4c5c1 [CI Skip] release/beta 5.0.2-4
skip-checks: true
2021-07-13 10:01:59 +00:00
Jaco 6c87a6f0af Partial latest to v14 mapping (#3767) 2021-07-13 11:52:10 +02:00
Github Actions fc5e4afe44 [CI Skip] release/beta 5.0.2-3
skip-checks: true
2021-07-13 09:38:21 +00:00
Jaco 48ef04b8ca Metadata v14 types (#3765)
* Metadata v14 types

* Linting w/ CHANGELOG

* Previous-gen SiType as SiType0
2021-07-13 11:28:44 +02:00
Github Actions 1b526fe618 [CI Skip] release/beta 5.0.2-2
skip-checks: true
2021-07-13 06:45:10 +00:00
Ian He 8d6bd931f3 add user additional rpcs during api.clone() (#3764) 2021-07-13 08:35:46 +02:00
Github Actions b317a8eb9b [CI Skip] release/beta 5.0.2-1
skip-checks: true
2021-07-12 10:14:40 +00:00
Jaco 8e65545a3c Allow nested struct generation (#3760)
* Allow nested struct generation

* CHANGELOG

* Update packages/typegen/src/util/formatting.ts

* Rebuild
2021-07-12 12:04:41 +02:00
Github Actions 4ded189697 [CI Skip] release/beta 5.0.2-0
skip-checks: true
2021-07-12 09:51:43 +00:00
Jaco b503441341 Update ParaPastCodeMeta with ReplacementTimes (#3758) 2021-07-12 11:39:46 +02:00
100 changed files with 44882 additions and 5127 deletions
+36
View File
@@ -1,5 +1,41 @@
# CHANGELOG
## 5.2.1 Jul 26, 2021
Upgrade priority: Low. Recommended for users of `BTreeMap` and `BTreeSet`
Contributed:
- Perform sorting on `BTree{Map, Set}`, aligning with Substrate (Thanks to https://github.com/Lezek123)
Changes:
- Adjust RPC to use registry.createType with optionality (required for metadata v14)
- Adjust alphabetical sorting for TS type generation
- Adjustments for upcoming metadata v14 in type creation & `PortableRegistry`
- Provide the capability to convert v13 Metadata to upcoming v14
## 5.1.1 Jul 19, 2021
Upgrade priority: Low. Recommended for users of XCM with type fixes.
- **Breaking changes** With the support for v14 metadata parsing, the `documentation` fields on metadata was renamed to `docs` for consistency, aligning with the SCALE type generators.
Contributed:
- Don't clear rpc decoration on Api clone (Thanks to https://github.com/ianhe8x)
- Align Xcm Junction type with Substrate (Thanks to https://github.com/dt665m)
Changes:
- Update `ParaPastCodeMeta` with `ReplacementTimes`
- Add mappings for `AccountId20` & `AccountId32` types
- Adjust scale-info types with Substrate (mapping for api-contracts to old)
- Allow nested structs in enum definitions & generation
- Allow for parsing of v14 metadata (not enabled by default, not merged into Substrate as of yet)
## 5.0.1 Jul 11, 2021
Upgrade priority: Low. Recommended for users of current-generation Substrate chains.
+4 -4
View File
@@ -26,14 +26,14 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/core": "^7.14.8",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@babel/runtime": "^7.14.8",
"@polkadot/dev": "^0.62.57",
"@polkadot/ts": "^0.4.4",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.23",
"@types/jest": "^26.0.24",
"copyfiles": "^2.4.1"
},
"version": "5.0.1"
"version": "5.2.1"
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -19,10 +19,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/api": "5.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/api": "5.2.1",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3",
"rxjs": "^7.2.0"
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ export class Abi {
this.registry.setMetaTypes(this.project.types);
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.#createMessage(spec, index, {
+18 -18
View File
@@ -1,19 +1,19 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, 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 { TypeDefInfo, TypeRegistry, withTypeString } from '@polkadot/types';
import { assert, isUndefined } from '@polkadot/util';
interface PartialTypeSpec {
readonly type: SiLookupTypeId;
readonly type: Si0LookupTypeId;
readonly displayName?: ContractDisplayName;
}
// 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;
}
@@ -29,7 +29,7 @@ export class MetaRegistry extends TypeRegistry {
public readonly typeOffset;
#siTypes: SiType[] = [];
#siTypes: Si0Type[] = [];
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super();
@@ -44,7 +44,7 @@ export class MetaRegistry extends TypeRegistry {
}
}
public setMetaTypes (metaTypes: SiType[]): void {
public setMetaTypes (metaTypes: Si0Type[]): void {
this.#siTypes = metaTypes;
}
@@ -83,15 +83,15 @@ export class MetaRegistry extends TypeRegistry {
return typeDef;
}
#getMetaType = (id: SiLookupTypeId): SiType => {
#getMetaType = (id: Si0LookupTypeId): Si0Type => {
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
return this.createType('SiType', type);
return this.createType('Si0Type', type);
}
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
#extract = (type: Si0Type, id: Si0LookupTypeId): TypeDef => {
const path = [...type.path];
const isPrimitivePath = !!path.length && (
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
@@ -119,7 +119,7 @@ export class MetaRegistry extends TypeRegistry {
const displayName = path.pop()?.toString();
return withTypeString({
return withTypeString(this, {
...(displayName
? { displayName }
: {}
@@ -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');
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 }) => ([
isAllNamed && name.isSome,
isAllUnnamed && name.isNone
@@ -174,7 +174,7 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractPrimitive = (type: SiType): TypeDef => {
#extractPrimitive = (type: Si0Type): TypeDef => {
const typeStr = type.def.asPrimitive.type.toString();
return {
@@ -183,14 +183,14 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractPrimitivePath = (type: SiType): TypeDef => {
#extractPrimitivePath = (type: Si0Type): TypeDef => {
return {
info: TypeDefInfo.Plain,
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()}`);
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
? 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 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)
? variants.map(({ discriminant, name }) => ({
...(
@@ -243,7 +243,7 @@ export class MetaRegistry extends TypeRegistry {
name: name.toString(),
type: 'Null'
}))
: variants.map(({ fields, name }) => withTypeString({
: variants.map(({ fields, name }) => withTypeString(this, {
...this.#extractFields(fields),
name: name.toString()
}));
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '5.2.1' };
@@ -158,12 +158,12 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
@@ -181,7 +181,7 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"info": 6,
@@ -198,4 +198,4 @@
"info": 5,
"type": "Option<AccountId>"
}
]
]
@@ -206,12 +206,12 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
@@ -229,7 +229,7 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"displayName": "ValueEntry",
@@ -427,4 +427,4 @@
],
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
}
]
]
@@ -63,12 +63,12 @@
"type": "AccountId"
}
],
"type": "(u32, AccountId)",
"type": "(u32,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32, AccountId)\"}}"
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
},
{
"info": 10,
@@ -84,7 +84,7 @@
"type": "AccountId"
}
],
"type": "(u32, AccountId)"
"type": "(u32,AccountId)"
},
{
"displayName": "AccountId",
@@ -409,7 +409,7 @@
"type": "{\"_enum\":{\"Confirmed\":\"()\",\"ConfirmationsNeeded\":\"u32\"}}"
}
],
"type": "(u32, ConfirmationStatus)"
"type": "(u32,ConfirmationStatus)"
},
{
"displayName": "ConfirmationStatus",
@@ -511,4 +511,4 @@
"info": 5,
"type": "Option<Vec<u8>>"
}
]
]
@@ -158,12 +158,12 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
@@ -181,7 +181,7 @@
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"info": 6,
@@ -202,4 +202,4 @@
"info": 5,
"type": "Option<AccountId>"
}
]
]
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -19,16 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/api": "5.0.1",
"@polkadot/rpc-core": "5.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1",
"@polkadot/util-crypto": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/api": "5.2.1",
"@polkadot/rpc-core": "5.2.1",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3",
"@polkadot/util-crypto": "^7.0.3",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.0.1",
"@polkadot/rpc-provider": "5.0.1"
"@polkadot/keyring": "^7.0.3",
"@polkadot/rpc-provider": "5.2.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '5.2.1' };
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -19,15 +19,15 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/api-derive": "5.0.1",
"@polkadot/keyring": "^7.0.1",
"@polkadot/rpc-core": "5.0.1",
"@polkadot/rpc-provider": "5.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/types-known": "5.0.1",
"@polkadot/util": "^7.0.1",
"@polkadot/util-crypto": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/api-derive": "5.2.1",
"@polkadot/keyring": "^7.0.3",
"@polkadot/rpc-core": "5.2.1",
"@polkadot/rpc-provider": "5.2.1",
"@polkadot/types": "5.2.1",
"@polkadot/types-known": "5.2.1",
"@polkadot/util": "^7.0.3",
"@polkadot/util-crypto": "^7.0.3",
"eventemitter3": "^4.0.7",
"rxjs": "^7.2.0"
}
+18 -18
View File
@@ -4413,24 +4413,6 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
/**
* Unlock any vested funds of a `target` account.
*
* The dispatch origin for this call must be _Signed_.
*
* - `target`: The account whose vested funds should be unlocked. Must have funds still
* locked under this pallet.
*
* Emits either `VestingCompleted` or `VestingUpdated`.
*
* # <weight>
* - `O(1)`.
* - DbWeight: 3 Reads, 3 Writes
* - Reads: Vesting Storage, Balances Locks, Target Account
* - Writes: Vesting Storage, Balances Locks, Target Account
* # </weight>
**/
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/**
* Create a vested transfer.
*
@@ -4450,6 +4432,24 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vestedTransfer: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
/**
* Unlock any vested funds of a `target` account.
*
* The dispatch origin for this call must be _Signed_.
*
* - `target`: The account whose vested funds should be unlocked. Must have funds still
* locked under this pallet.
*
* Emits either `VestingCompleted` or `VestingUpdated`.
*
* # <weight>
* - `O(1)`.
* - DbWeight: 3 Reads, 3 Writes
* - Reads: Vesting Storage, Balances Locks, Target Account
* - Writes: Vesting Storage, Balances Locks, Target Account
* # </weight>
**/
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/**
* Generic tx
**/
+8 -10
View File
@@ -4,7 +4,7 @@
import type { Observable } from 'rxjs';
import type { RpcInterface } from '@polkadot/rpc-core/types';
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
import type { Call, Hash, RpcMethods, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
@@ -265,9 +265,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
// manner to cater for both old and new:
// - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
// - when non-zero, remove anything that is not in the array (we don't do this)
protected _filterRpc (rpcMethods: RpcMethods, additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
const methods = rpcMethods.methods.map((t) => t.toString());
protected _filterRpc (methods: string[], additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
// add any specific user-base RPCs
if (Object.keys(additional).length !== 0) {
this._rpcCore.addUserInterfaces(additional);
@@ -407,7 +405,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
// Disable this where it occurs for each field we are decorating
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
@@ -490,7 +488,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _decorateStorageEntryAt<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageEntryAt<ApiType> {
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
// Disable this where it occurs for each field we are decorating
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
@@ -547,18 +545,18 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return decorateMethod((...args: unknown[]): Observable<Codec> => {
return this.hasSubscriptions
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(creator, args)]).pipe(
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(this.#registry, creator, args)]).pipe(
map(([data]) => data) // extract first/only result from list
)
: this._rpcCore.state.getStorage(extractStorageArgs(creator, args));
: this._rpcCore.state.getStorage(extractStorageArgs(this.#registry, creator, args));
}, {
methodName: creator.method,
overrideNoSub: (...args: unknown[]) => this._rpcCore.state.getStorage(extractStorageArgs(creator, args))
overrideNoSub: (...args: unknown[]) => this._rpcCore.state.getStorage(extractStorageArgs(this.#registry, creator, args))
});
}
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
const outputType = unwrapStorageType(decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
return this._rpcCore.state
.queryStorage<[Option<Raw>]>([decorated.key(...args)], ...range)
+2 -2
View File
@@ -213,7 +213,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
});
});
this._filterRpcMethods(methods);
this._filterRpc(methods, getSpecRpc(this.registry, source.runtimeChain, source.runtimeVersion.specName));
return [source.genesisHash, source.runtimeMetadata];
}
@@ -296,7 +296,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// initializes the registry & RPC
this._initRegistry(this.registry, chain, runtimeVersion, metadata, chainProps);
this._filterRpc(rpcMethods, getSpecRpc(this.registry, chain, runtimeVersion.specName));
this._filterRpc(rpcMethods.methods.map((t) => t.toString()), getSpecRpc(this.registry, chain, runtimeVersion.specName));
this._subscribeUpdates();
// setup the initial registry, when we have none
+1 -1
View File
@@ -21,7 +21,7 @@ function consts (api: ApiPromise): void {
console.log(
api.consts.foo.bar,
api.consts.balances.existentialDeposit.toNumber(),
api.consts.balances.existentialDeposit.meta.documentation.map((s): string => s.toString()).join('')
api.consts.balances.existentialDeposit.meta.docs.map((s): string => s.toString()).join('')
);
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/api', version: '5.2.1' };
+12 -12
View File
@@ -20,79 +20,79 @@ describe('extractStorageArgs', (): void => {
it('validates no-arg plain', (): void => {
expect(
extractStorageArgs(storage.timestamp.now, [])
extractStorageArgs(registry, storage.timestamp.now, [])
).toEqual([storage.timestamp.now]);
});
it('validates no-arg plain (with undefined, undefined)', (): void => {
expect(
extractStorageArgs(storage.timestamp.now, [undefined, undefined])
extractStorageArgs(registry, storage.timestamp.now, [undefined, undefined])
).toEqual([storage.timestamp.now]);
});
it('validates no-arg plain (failing when there are args)', (): void => {
expect(
(): unknown => extractStorageArgs(storage.timestamp.now, [123, 456])
(): unknown => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
).toThrow('timestamp.now() does not take any arguments, 2 found');
});
it('validates map, 1 arg', (): void => {
expect(
extractStorageArgs(storage.staking.payee, ['abc'])
extractStorageArgs(registry, storage.staking.payee, ['abc'])
).toEqual([storage.staking.payee, 'abc']);
});
it('validates map, 1 arg (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.payee, [])
extractStorageArgs(registry, storage.staking.payee, [])
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 0 found');
});
it('validates map, 1 arg (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.payee, ['abc', 'def'])
extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 2 found');
});
it('validates doublemap, 2 args', (): void => {
expect(
extractStorageArgs(storage.staking.erasStakers, [1, '0x1234'])
extractStorageArgs(registry, storage.staking.erasStakers, [1, '0x1234'])
).toEqual([storage.staking.erasStakers, [1, '0x1234']]);
});
it('validates doublemap, 2 args (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.erasStakers, [])
extractStorageArgs(registry, storage.staking.erasStakers, [])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
});
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.erasStakers, [123])
extractStorageArgs(registry, storage.staking.erasStakers, [123])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
});
// Linked maps have been removed
it.skip('validates linked map, no args', (): void => {
expect(
extractStorageArgs(storage.staking.validators, [])
extractStorageArgs(registry, storage.staking.validators, [])
).toEqual([storage.staking.validators]);
});
it.skip('validates linked map, single arg', (): void => {
expect(
extractStorageArgs(storage.staking.validators, [123])
extractStorageArgs(registry, storage.staking.validators, [123])
).toEqual([storage.staking.validators, 123]);
});
it.skip('validates linked map (failing with extra args)', (): void => {
expect(
(): any[] =>
extractStorageArgs(storage.staking.validators, [123, 456])
extractStorageArgs(registry, storage.staking.validators, [123, 456])
).toThrow('staking.validators(AccountId) is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, 2 found');
});
});
+13 -12
View File
@@ -3,26 +3,27 @@
import type { Type } from '@polkadot/types';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { Registry } from '@polkadot/types/types';
import { assert, isUndefined } from '@polkadot/util';
function sig ({ method, section }: StorageEntry, args: Type[]): string {
function sig (_: Registry, { method, section }: StorageEntry, args: Type[]): string {
return `${section}.${method}(${args.join(', ')})`;
}
function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
function doDoubleMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
const { key1, key2 } = creator.meta.type.asDoubleMap;
assert(args.length === 2, () => `${sig(creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
assert(args.length === 2, () => `${sig(registry, creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
// pass as tuple
return [creator, args as [any, any]];
}
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
function doMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
const { key } = creator.meta.type.asMap;
assert(args.length === 1, () => `${sig(creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
assert(args.length === 1, () => `${sig(registry, creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
// expand
return args.length
@@ -30,10 +31,10 @@ function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [Stora
: [creator];
}
function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
function doNMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
const { keyVec } = creator.meta.type.asNMap;
assert(args.length === keyVec.length, () => `${sig(creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
assert(args.length === keyVec.length, () => `${sig(registry, creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
// pass as tuple
return [creator, args];
@@ -41,18 +42,18 @@ function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]]
// sets up the arguments in the form of [creator, args] ready to be used in a storage
// call. Additionally, it verifies that the correct number of arguments have been passed
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
const args = _args.filter((arg) => !isUndefined(arg));
if (creator.meta.type.isDoubleMap) {
return doDoubleMap(creator, args);
return doDoubleMap(registry, creator, args);
} else if (creator.meta.type.isMap) {
return doMap(creator, args);
return doMap(registry, creator, args);
} else if (creator.meta.type.isNMap) {
return doNMap(creator, args);
return doNMap(registry, creator, args);
}
assert(args.length === 0, () => `${sig(creator, [])} does not take any arguments, ${args.length} found`);
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
// no args
return [creator];
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,13 +19,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/rpc-provider": "5.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/rpc-provider": "5.2.1",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.0.1"
"@polkadot/keyring": "^7.0.3"
}
}
+8 -22
View File
@@ -11,7 +11,7 @@ import type { RpcInterface, RpcInterfaceMethod } from './types';
import { Observable, publishReplay, refCount } from 'rxjs';
import { createClass, createTypeUnsafe, Option, rpcDefinitions } from '@polkadot/types';
import { rpcDefinitions } from '@polkadot/types';
import { assert, hexToU8a, isFunction, isNull, isUndefined, logger, memoize, u8aToU8a } from '@polkadot/util';
import { drr, refCountDelay } from './util';
@@ -339,7 +339,7 @@ export class RpcCore {
assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, () => `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
return inputs.map((input, index): Codec =>
createTypeUnsafe(registry, def.params[index].type, [input], { blockHash })
registry.createTypeUnsafe(def.params[index].type, [input], { blockHash })
);
}
@@ -366,7 +366,7 @@ export class RpcCore {
: mapped as unknown as Codec[];
}
return createTypeUnsafe(registry, rpc.type, [result], { blockHash });
return registry.createTypeUnsafe(rpc.type, [result], { blockHash });
}
private _formatStorageData (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, value: string | null): Codec {
@@ -432,29 +432,15 @@ export class RpcCore {
: ` entry ${entryIndex}:`;
try {
if (meta.modifier.isOptional) {
let inner = null;
if (!isEmpty) {
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
}
const option = new Option(registry, createClass(registry, type), inner);
if (blockHash) {
option.createdAtHash = registry.createType('Hash', blockHash);
}
return option;
}
return createTypeUnsafe(registry, type, [
return registry.createTypeUnsafe(type, [
isEmpty
? meta.fallback
? hexToU8a(meta.fallback.toHex())
: undefined
: input
], { blockHash, isPedantic: true });
: meta.modifier.isOptional
? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: true })
: input
], { blockHash, isOptional: meta.modifier.isOptional, isPedantic: !meta.modifier.isOptional });
} catch (error) {
throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${(error as Error).message}`);
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.2.1' };
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -19,18 +19,18 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1",
"@polkadot/util-crypto": "^7.0.1",
"@polkadot/x-fetch": "^7.0.1",
"@polkadot/x-global": "^7.0.1",
"@polkadot/x-ws": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3",
"@polkadot/util-crypto": "^7.0.3",
"@polkadot/x-fetch": "^7.0.3",
"@polkadot/x-global": "^7.0.3",
"@polkadot/x-ws": "^7.0.3",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^7.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/keyring": "^7.0.3",
"@polkadot/types": "5.2.1",
"mock-socket": "^9.0.3",
"nock": "^13.1.1"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.2.1' };
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -26,13 +26,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.14.6",
"@babel/core": "^7.14.8",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@polkadot/api": "5.0.1",
"@polkadot/rpc-provider": "5.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/api": "5.2.1",
"@polkadot/rpc-provider": "5.2.1",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.0.1"
+7 -7
View File
@@ -24,7 +24,6 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
}, {});
const modules = meta.asLatest.modules
.sort(compareName)
.filter((mod) => mod.constants.length > 0)
.map(({ constants, name }) => {
if (!isStrict) {
@@ -32,24 +31,25 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
}
const items = constants
.sort(compareName)
.map(({ documentation, name, type }) => {
const returnType = formatType(allDefs, type.toString(), imports);
.map(({ docs, name, type }) => {
const returnType = formatType(meta.registry, allDefs, type.toString(), imports);
setImports(allDefs, imports, [returnType]);
return {
docs: documentation,
docs,
name: stringCamelCase(name),
type: returnType
};
});
})
.sort(compareName);
return {
items,
name: stringCamelCase(name)
};
});
})
.sort(compareName);
const types = [
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
+6 -6
View File
@@ -19,17 +19,17 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void
const imports = createImports({});
const modules = meta.asLatest.modules
.sort(compareName)
.filter((mod) => mod.errors.length > 0)
.map(({ errors, name }) => ({
items: errors
.sort(compareName)
.map(({ documentation, name }) => ({
docs: documentation,
.map(({ docs, name }) => ({
docs,
name: name.toString()
})),
}))
.sort(compareName),
name: stringCamelCase(name)
}));
}))
.sort(compareName);
const types = [
{
+6 -6
View File
@@ -24,25 +24,25 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
}, {});
const modules = meta.asLatest.modules
.sort(compareName)
.filter((mod) => mod.events.isSome)
.map(({ events, name }) => ({
items: events
.unwrap()
.sort(compareName)
.map(({ args, documentation, name }) => {
const types = args.map((type) => formatType(allDefs, type.toString(), imports));
.map(({ args, docs, name }) => {
const types = args.map((type) => formatType(meta.registry, allDefs, type.toString(), imports));
setImports(allDefs, imports, types);
return {
docs: documentation,
docs,
name: name.toString(),
type: types.join(', ')
};
}),
}).sort(compareName),
name: stringCamelCase(name)
}));
}))
.sort(compareName);
const types = [
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
+16 -12
View File
@@ -18,12 +18,12 @@ import { ModuleTypes } from '../util/imports';
// From a storage entry metadata, we return [args, returnType]
/** @internal */
function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string, string] {
const outputType = unwrapStorageType(storageEntry.type, storageEntry.modifier.isOptional);
const outputType = unwrapStorageType(registry, storageEntry.type, storageEntry.modifier.isOptional);
if (storageEntry.type.isPlain) {
setImports(allDefs, imports, [storageEntry.type.asPlain.toString()]);
return ['', '', formatType(allDefs, outputType, imports)];
return ['', '', formatType(registry, allDefs, outputType, imports)];
} else if (storageEntry.type.isMap) {
const map = storageEntry.type.asMap;
@@ -36,9 +36,9 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
]);
return [
formatType(allDefs, map.key.toString(), imports),
formatType(registry, allDefs, map.key.toString(), imports),
`arg: ${similarTypes.join(' | ')}`,
formatType(allDefs, outputType, imports)
formatType(registry, allDefs, outputType, imports)
];
} else if (storageEntry.type.isDoubleMap) {
const dm = storageEntry.type.asDoubleMap;
@@ -57,9 +57,12 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
const key2Types = similarTypes2.join(' | ');
return [
[formatType(allDefs, dm.key1.toString(), imports), formatType(allDefs, dm.key2.toString(), imports)].join(', '),
[
formatType(registry, allDefs, dm.key1.toString(), imports),
formatType(registry, allDefs, dm.key2.toString(), imports)
].join(', '),
`arg1: ${key1Types}, arg2: ${key2Types}`,
formatType(allDefs, outputType, imports)
formatType(registry, allDefs, outputType, imports)
];
} else if (storageEntry.type.isNMap) {
const nmap = storageEntry.type.asNMap;
@@ -75,9 +78,9 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
const keyTypes = similarTypes.map((t) => t.join(' | '));
return [
nmap.keyVec.map((k) => formatType(allDefs, k.toString(), imports)).join(', '),
nmap.keyVec.map((k) => formatType(registry, allDefs, k.toString(), imports)).join(', '),
keyTypes.map((t, i) => `arg${i + 1}: ${t}`).join(', '),
formatType(allDefs, outputType, imports)
formatType(registry, allDefs, outputType, imports)
];
}
@@ -101,25 +104,26 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
.filter((mod) => !mod.storage.isNone)
.map(({ name, storage }) => {
const items = storage.unwrap().items
.sort(compareName)
.map((storageEntry) => {
const [args, params, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
return {
args,
docs: storageEntry.documentation,
docs: storageEntry.docs,
entryType: 'AugmentedQuery',
name: stringCamelCase(storageEntry.name),
params,
returnType
};
});
})
.sort(compareName);
return {
items,
name: stringCamelCase(name)
};
});
})
.sort(compareName);
imports.typesTypes.Observable = true;
+1 -1
View File
@@ -90,7 +90,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
return `${param.name}${param.isOptional ? '?' : ''}: ${similarTypes.join(' | ')}`;
});
type = formatType(allDefs, def.type, imports);
type = formatType(registry, allDefs, def.type, imports);
generic = '';
}
+64 -52
View File
@@ -2,12 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { TypeDef } from '@polkadot/types/create/types';
import type { Registry } from '@polkadot/types/types';
import type { ModuleTypes } from '../util/imports';
import Handlebars from 'handlebars';
import path from 'path';
import { getTypeDef } from '@polkadot/types/create';
import { getTypeDef, TypeRegistry } from '@polkadot/types/create';
import { TypeDefInfo } from '@polkadot/types/create/types';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { assert, isString, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util';
@@ -28,13 +29,13 @@ export function createGetter (definitions: Record<string, ModuleTypes>, name = '
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function errorUnhandled (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
function errorUnhandled (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
throw new Error(`Generate: ${def.name || ''}: Unhandled type ${TypeDefInfo[def.info]}`);
}
/** @internal */
function tsExport (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
return exportInterface(def.name, formatType(definitions, def, imports));
function tsExport (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
return exportInterface(def.name, formatType(registry, definitions, def, imports));
}
const tsBTreeMap = tsExport;
@@ -47,15 +48,16 @@ const tsPlain = tsExport;
const tsTuple = tsExport;
/** @internal */
function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
setImports(definitions, imports, ['Enum']);
const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => {
const keys = (sub as TypeDef[]).map((def, index): string => {
const { info, name = `unknown${index}`, type } = def;
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const isComplex = [TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
? ''
: createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports);
: createGetter(definitions, `as${getter}`, isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports) : type, imports);
const isGetter = info === TypeDefInfo.DoNotConstruct
? ''
: createGetter(definitions, `is${getter}`, 'boolean', imports);
@@ -63,6 +65,7 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
switch (info) {
case TypeDefInfo.Compact:
case TypeDefInfo.Plain:
case TypeDefInfo.Struct:
case TypeDefInfo.Tuple:
case TypeDefInfo.Vec:
case TypeDefInfo.Option:
@@ -80,18 +83,18 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
return exportInterface(enumName, 'Enum', keys.join(''));
}
function tsInt (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
function tsInt (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
setImports(definitions, imports, [type]);
return exportInterface(def.name, type);
}
/** @internal */
function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
const { info, type } = def;
const asGetter = type === 'Null'
? ''
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(definitions, def, imports) : type, imports);
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports) : type, imports);
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
switch (info) {
@@ -107,22 +110,28 @@ function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName =
}
/** @internal */
function tsResult (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
const [okDef, errorDef] = (def.sub as TypeDef[]);
const inner = [
tsResultGetter(definitions, def.name, 'Err', errorDef, imports),
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
// @deprecated, use Err
tsResultGetter(definitions, def.name, 'Error', errorDef, imports),
tsResultGetter(definitions, def.name, 'Ok', okDef, imports)
tsResultGetter(registry, definitions, def.name, 'Error', errorDef, imports),
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
].join('');
setImports(definitions, imports, [def.type]);
return exportInterface(def.name, formatType(definitions, def, imports), inner);
return exportInterface(def.name, formatType(registry, definitions, def, imports), inner);
}
/** @internal */
function tsSet (definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function tsSi (registry: Registry, definitions: Record<string, ModuleTypes>, { type }: TypeDef, imports: TypeImports): string {
throw new Error('Unable to generate string definition from TypeDefInfo.Si');
}
/** @internal */
function tsSet (_: Registry, definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
setImports(definitions, imports, ['Set']);
const types = (sub as TypeDef[]).map(({ name }): string => {
@@ -135,11 +144,11 @@ function tsSet (definitions: Record<string, ModuleTypes>, { name: setName, sub }
}
/** @internal */
function tsStruct (definitions: Record<string, ModuleTypes>, { name: structName, sub }: TypeDef, imports: TypeImports): string {
function tsStruct (registry: Registry, definitions: Record<string, ModuleTypes>, { name: structName, sub }: TypeDef, imports: TypeImports): string {
setImports(definitions, imports, ['Struct']);
const keys = (sub as TypeDef[]).map((typedef): string => {
const returnType = formatType(definitions, typedef, imports);
const returnType = formatType(registry, definitions, typedef, imports);
return createGetter(definitions, typedef.name, returnType, imports);
});
@@ -148,12 +157,12 @@ function tsStruct (definitions: Record<string, ModuleTypes>, { name: structName,
}
/** @internal */
function tsUInt (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
return tsInt(definitions, def, imports, 'UInt');
function tsUInt (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
return tsInt(registry, definitions, def, imports, 'UInt');
}
/** @internal */
function tsVec (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
function tsVec (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
const type = (def.sub as TypeDef).type;
if (def.info === TypeDefInfo.VecFixed && type === 'u8') {
@@ -162,39 +171,40 @@ function tsVec (definitions: Record<string, ModuleTypes>, def: TypeDef, imports:
return exportType(def.name, 'U8aFixed');
}
return exportInterface(def.name, formatType(definitions, def, imports));
return exportInterface(def.name, formatType(registry, definitions, def, imports));
}
/** @internal */
function generateInterfaces (definitions: Record<string, ModuleTypes>, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
// handlers are defined externally to use - this means that when we do a
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
// we are being explicit in having no handlers where we do not support (yet)
const generators = {
[TypeDefInfo.BTreeMap]: tsBTreeMap,
[TypeDefInfo.BTreeSet]: tsBTreeSet,
[TypeDefInfo.Compact]: tsCompact,
[TypeDefInfo.DoNotConstruct]: tsDoNotConstruct,
[TypeDefInfo.Enum]: tsEnum,
[TypeDefInfo.HashMap]: tsHashMap,
[TypeDefInfo.Int]: tsInt,
[TypeDefInfo.Linkage]: errorUnhandled,
[TypeDefInfo.Null]: errorUnhandled,
[TypeDefInfo.Option]: tsOption,
[TypeDefInfo.Plain]: tsPlain,
[TypeDefInfo.Result]: tsResult,
[TypeDefInfo.Set]: tsSet,
[TypeDefInfo.Struct]: tsStruct,
[TypeDefInfo.Tuple]: tsTuple,
[TypeDefInfo.UInt]: tsUInt,
[TypeDefInfo.Vec]: tsVec,
[TypeDefInfo.VecFixed]: tsVec
};
// handlers are defined externally to use - this means that when we do a
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
// we are being explicit in having no handlers where we do not support (yet)
const encoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
[TypeDefInfo.BTreeMap]: tsBTreeMap,
[TypeDefInfo.BTreeSet]: tsBTreeSet,
[TypeDefInfo.Compact]: tsCompact,
[TypeDefInfo.DoNotConstruct]: tsDoNotConstruct,
[TypeDefInfo.Enum]: tsEnum,
[TypeDefInfo.HashMap]: tsHashMap,
[TypeDefInfo.Int]: tsInt,
[TypeDefInfo.Linkage]: errorUnhandled,
[TypeDefInfo.Null]: errorUnhandled,
[TypeDefInfo.Option]: tsOption,
[TypeDefInfo.Plain]: tsPlain,
[TypeDefInfo.Result]: tsResult,
[TypeDefInfo.Set]: tsSet,
[TypeDefInfo.Si]: tsSi,
[TypeDefInfo.Struct]: tsStruct,
[TypeDefInfo.Tuple]: tsTuple,
[TypeDefInfo.UInt]: tsUInt,
[TypeDefInfo.Vec]: tsVec,
[TypeDefInfo.VecFixed]: tsVec
};
/** @internal */
function generateInterfaces (registry: Registry, definitions: Record<string, ModuleTypes>, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
return Object.entries(types).map(([name, type]): [string, string] => {
const def = getTypeDef(isString(type) ? type : stringify(type), { name });
return [name, generators[def.info](definitions, def, imports)];
return [name, encoders[def.info](registry, definitions, def, imports)];
});
}
@@ -208,10 +218,10 @@ const templateTypes = readTemplate('tsDef/types');
const generateTsDefTypesTemplate = Handlebars.compile(templateTypes);
/** @internal */
function generateTsDefFor (importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
function generateTsDefFor (registry: Registry, importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] } as Imports;
const definitions = imports.definitions;
const interfaces = generateInterfaces(definitions, { types }, imports);
const interfaces = generateInterfaces(registry, definitions, { types }, imports);
const items = interfaces.sort((a, b): number => a[0].localeCompare(b[0])).map(([, definition]): string => definition);
const importTypes = [
@@ -233,13 +243,15 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: Record<str
/** @internal */
export function generateTsDef (importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, outputDir: string, generatingPackage: string): void {
const registry = new TypeRegistry();
writeFile(path.join(outputDir, 'types.ts'), (): string => {
const definitions = importDefinitions[generatingPackage];
Object.entries(definitions).forEach(([defName, obj]): void => {
console.log(`\tExtracting interfaces for ${defName}`);
generateTsDefFor(importDefinitions, defName, obj, outputDir);
generateTsDefFor(registry, importDefinitions, defName, obj, outputDir);
});
return generateTsDefTypesTemplate({
+7 -7
View File
@@ -37,14 +37,12 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
}, {});
const modules = meta.asLatest.modules
.sort(compareName)
.filter(({ calls }) => calls.unwrapOr([]).length !== 0)
.map(({ calls, name }) => {
setImports(allDefs, imports, ['Call', 'Extrinsic', 'SubmittableExtrinsic']);
const items = calls.unwrap()
.sort(compareName)
.map(({ args, documentation, name }) => {
.map(({ args, docs, name }) => {
const params = args
.map(({ name, type }) => {
const typeStr = type.toString();
@@ -57,18 +55,20 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
.join(', ');
return {
args: args.map(({ type }) => formatType(allDefs, type.toString(), imports)).join(', '),
docs: documentation,
args: args.map(({ type }) => formatType(registry, allDefs, type.toString(), imports)).join(', '),
docs,
name: stringCamelCase(name),
params
};
});
})
.sort(compareName);
return {
items,
name: stringCamelCase(name)
};
});
})
.sort(compareName);
const types = [
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
+10 -10
View File
@@ -43,7 +43,7 @@ const DESC_RPC = 'The following sections contain RPC methods that are Remote Cal
const DESC_STORAGE = `The following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via \`api.query.<module>.<method>\`. ${STATIC_TEXT}`;
/** @internal */
function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
const md = docLines
.map((docLine) => docLine && docLine.substring(1)) // trim the leading space
.reduce((md, docLine): string => // generate paragraphs
@@ -94,7 +94,7 @@ function renderPage (page: Page): string {
md += `\n- **${bullet}**: ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
item[bullet] instanceof Vec
? documentationVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
? docsVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
: item[bullet]
}`;
});
@@ -180,7 +180,7 @@ function addConstants (metadata: MetadataLatest): string {
return {
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
name: `${methodName}: ` + '`' + func.type.toString() + '`',
...(func.documentation.length && { summary: func.documentation })
...(func.docs.length && { summary: func.docs })
};
}),
name: sectionName
@@ -211,12 +211,12 @@ function addStorage (metadata: MetadataLatest): string {
? ('`' + func.type.asNMap.keyVec.map((k) => k.toString()).join(', ') + '`')
: '';
const methodName = stringLowerFirst(func.name);
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
const outputType = unwrapStorageType(metadata.registry, func.type, func.modifier.isOptional);
return {
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
...(func.documentation.length && { summary: func.documentation })
...(func.docs.length && { summary: func.docs })
};
}),
name: sectionName
@@ -234,12 +234,12 @@ function addStorage (metadata: MetadataLatest): string {
? ('`' + meta.type.asDoubleMap.key1.toString() + ', ' + meta.type.asDoubleMap.key2.toString() + '`')
: '';
const methodName = stringLowerFirst(name);
const outputType = unwrapStorageType(meta.type, meta.modifier.isOptional);
const outputType = unwrapStorageType(metadata.registry, meta.type, meta.modifier.isOptional);
return {
interface: '`' + `api.query.substrate.${methodName}` + '`',
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
summary: meta.documentation
summary: meta.docs
};
}),
name: 'substrate'
@@ -268,7 +268,7 @@ function addExtrinsics (metadata: MetadataLatest): string {
return {
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
name: `${methodName}(${args})`,
...(func.documentation.length && { summary: func.documentation })
...(func.docs.length && { summary: func.docs })
};
}),
name: sectionName
@@ -295,7 +295,7 @@ function addEvents (metadata: MetadataLatest): string {
return {
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
name: `${methodName}(${args})`,
...(func.documentation.length && { summary: func.documentation })
...(func.docs.length && { summary: func.docs })
};
}),
name: stringCamelCase(meta.name)
@@ -317,7 +317,7 @@ function addErrors (metadata: MetadataLatest): string {
.map((error) => ({
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
name: error.name.toString(),
...(error.documentation.length && { summary: error.documentation })
...(error.docs.length && { summary: error.docs })
})),
name: stringLowerFirst(moduleMetadata.name)
})),
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '5.2.1' };
+2 -2
View File
@@ -54,7 +54,7 @@ export function getDerivedTypes (registry: Registry, definitions: Record<string,
});
}
const result = types.map((t) => formatType(definitions, t, imports)).map((t) => `'${t}': ${t};`);
const result = types.map((t) => formatType(registry, definitions, t, imports)).map((t) => `'${t}': ${t};`);
result.unshift(`${type}: ${type};`);
@@ -68,7 +68,7 @@ export function getDerivedTypes (registry: Registry, definitions: Record<string,
export function getSimilarTypes (registry: Registry, definitions: Record<string, ModuleTypes>, _type: string, imports: TypeImports): string[] {
const typeParts = _type.split('::');
const type = typeParts[typeParts.length - 1];
const possibleTypes = [formatType(definitions, type, imports)];
const possibleTypes = [formatType(registry, definitions, type, imports)];
if (type === 'Extrinsic') {
setImports(definitions, imports, ['IExtrinsic']);
+5 -1
View File
@@ -1,12 +1,16 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '@polkadot/types';
import { formatType } from './formatting';
describe('formatType', (): void => {
const registry = new TypeRegistry();
it('handles nested Tuples', (): void => {
expect(
formatType({}, '(AccountId, (Balance, u32), u64)', {
formatType(registry, {}, '(AccountId, (Balance, u32), u64)', {
codecTypes: {},
definitions: {},
extrinsicTypes: {},
+109 -168
View File
@@ -1,7 +1,10 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { TypeDef } from '@polkadot/types/create/types';
import type { Registry } from '@polkadot/types/types';
import Handlebars from 'handlebars';
@@ -83,92 +86,126 @@ export function exportType (name = '', base: string): string {
return exportInterface(name, base);
}
/**
* Given the inner `K` & `V`, return a `BTreeMap<K, V>` string
*/
/** @internal */
function formatBTreeMap (key: string, val: string): string {
return `BTreeMap<${key}, ${val}>`;
}
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => string> = {
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Compact']);
/**
* Given the inner `V`, return a `BTreeSet<V>` string
*/
/** @internal */
function formatBTreeSet (val: string): string {
return `BTreeSet<${val}>`;
}
return paramsNotation('Compact', formatType(registry, definitions, (typeDef.sub as TypeDef).type, imports));
},
[TypeDefInfo.DoNotConstruct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['DoNotConstruct']);
/**
* Given the inner `T`, return a `Compact<T>` string
*/
/** @internal */
function formatCompact (inner: string): string {
return paramsNotation('Compact', inner);
}
return 'DoNotConstruct';
},
[TypeDefInfo.Enum]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
throw new Error(`TypeDefInfo.Enum: Not implemented on ${stringify(typeDef)}`);
},
[TypeDefInfo.Int]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
throw new Error(`TypeDefInfo.Int: Not implemented on ${stringify(typeDef)}`);
},
[TypeDefInfo.UInt]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
throw new Error(`TypeDefInfo.UInt: Not implemented on ${stringify(typeDef)}`);
},
[TypeDefInfo.Null]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Null']);
/**
* Simple return
*/
/** @internal */
function formatDoNoConstruct (): string {
return 'DoNotConstruct';
}
return 'Null';
},
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Option']);
/**
* Given the inner `K` & `V`, return a `BTreeMap<K, V>` string
*/
/** @internal */
function formatHashMap (key: string, val: string): string {
return `HashMap<${key}, ${val}>`;
}
return paramsNotation('Option', formatType(registry, definitions, (typeDef.sub as TypeDef).type, imports));
},
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
return typeDef.type;
},
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
throw new Error(`TypeDefInfo.Set: Not implemented on ${stringify(typeDef)}`);
},
[TypeDefInfo.Si]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
throw new Error(`TypeDefInfo.Si: Not implemented on ${stringify(typeDef)}`);
},
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Struct']);
/**
* Given the inner `T`, return a `Vec<T>` string
*/
/** @internal */
function formatLinkage (inner: string): string {
return paramsNotation('Linkage', inner);
}
return `{ ${
((typeDef.sub as TypeDef[]).map(({ name, type }, index) => [
name || `unknown${index}`,
formatType(registry, definitions, type, imports)
])).map(([k, t]) => `${k}: ${t};`).join(' ')
} } & Struct`;
},
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['ITuple']);
/**
* Given the inner `O` & `E`, return a `Result<O, E>` string
*/
/** @internal */
function formatResult (innerOk: string, innerError: string): string {
return `Result<${innerOk}, ${innerError}>`;
}
// `(a,b)` gets transformed into `ITuple<[a, b]>`
return paramsNotation('ITuple', `[${
((typeDef.sub as TypeDef[]).map(({ type }) =>
formatType(registry, definitions, type, imports))
).join(', ')
}]`);
},
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Vec']);
/**
* Given the inner `T`, return a `Option<T>` string
*/
/** @internal */
function formatOption (inner: string): string {
return paramsNotation('Option', inner);
}
return paramsNotation('Vec', formatType(registry, definitions, (typeDef.sub as TypeDef).type, imports));
},
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
const type = (typeDef.sub as TypeDef).type;
/**
* Given the inners `T[]`, return a `ITuple<...T>` string
*/
/** @internal */
function formatTuple (inners: string[]): string {
return paramsNotation('ITuple', `[${inners.join(', ')}]`);
}
if (type === 'u8') {
setImports(definitions, imports, ['U8aFixed']);
/**
* Given the inner `T`, return a `Vec<T>` string
*/
/** @internal */
function formatVec (inner: string): string {
return paramsNotation('Vec', inner);
}
return 'U8aFixed';
}
setImports(definitions, imports, ['Vec']);
return paramsNotation('Vec', formatType(registry, definitions, type, imports));
},
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['BTreeMap']);
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
return `BTreeMap<${formatType(registry, definitions, keyDef.type, imports)}, ${formatType(registry, definitions, valDef.type, imports)}>`;
},
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['BTreeSet']);
const valDef = typeDef.sub as TypeDef;
return `BTreeSet<${formatType(registry, definitions, valDef.type, imports)}>`;
},
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['HashMap']);
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
return `HashMap<${formatType(registry, definitions, keyDef.type, imports)}, ${formatType(registry, definitions, valDef.type, imports)}>`;
},
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
const type = (typeDef.sub as TypeDef).type;
setImports(definitions, imports, ['Linkage']);
return paramsNotation('Linkage', formatType(registry, definitions, type, imports));
},
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports) => {
setImports(definitions, imports, ['Result']);
const [okDef, errorDef] = (typeDef.sub as TypeDef[]);
return `Result<${formatType(registry, definitions, okDef.type, imports)}, ${formatType(registry, definitions, errorDef.type, imports)}>`;
}
};
/**
* Correctly format a given type
*/
/** @internal */
// eslint-disable-next-line @typescript-eslint/ban-types
export function formatType (definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports): string {
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports): string {
let typeDef: TypeDef;
if (isString(type)) {
@@ -187,101 +224,5 @@ export function formatType (definitions: Record<string, ModuleTypes>, type: stri
setImports(definitions, imports, [typeDef.type]);
// FIXME Swap to Record<TypeDefInfo, fn> to check all types
switch (typeDef.info) {
case TypeDefInfo.Compact: {
setImports(definitions, imports, ['Compact']);
return formatCompact(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
}
case TypeDefInfo.DoNotConstruct: {
setImports(definitions, imports, ['DoNotConstruct']);
return formatDoNoConstruct();
}
case TypeDefInfo.Option: {
setImports(definitions, imports, ['Option']);
return formatOption(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
}
case TypeDefInfo.Plain: {
return typeDef.type;
}
case TypeDefInfo.Vec: {
setImports(definitions, imports, ['Vec']);
return formatVec(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
}
case TypeDefInfo.Tuple: {
setImports(definitions, imports, ['ITuple']);
// `(a,b)` gets transformed into `ITuple<[a, b]>`
return formatTuple(
((typeDef.sub as TypeDef[]).map((sub) => formatType(definitions, sub.type, imports)))
);
}
case TypeDefInfo.VecFixed: {
const type = (typeDef.sub as TypeDef).type;
if (type === 'u8') {
setImports(definitions, imports, ['U8aFixed']);
return 'U8aFixed';
}
setImports(definitions, imports, ['Vec']);
return formatVec(formatType(definitions, type, imports));
}
case TypeDefInfo.BTreeMap: {
setImports(definitions, imports, ['BTreeMap']);
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
return formatBTreeMap(formatType(definitions, keyDef.type, imports), formatType(definitions, valDef.type, imports));
}
case TypeDefInfo.BTreeSet: {
setImports(definitions, imports, ['BTreeSet']);
const valDef = typeDef.sub as TypeDef;
return formatBTreeSet(formatType(definitions, valDef.type, imports));
}
case TypeDefInfo.HashMap: {
setImports(definitions, imports, ['HashMap']);
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
return formatHashMap(formatType(definitions, keyDef.type, imports), formatType(definitions, valDef.type, imports));
}
case TypeDefInfo.Linkage: {
const type = (typeDef.sub as TypeDef).type;
setImports(definitions, imports, ['Linkage']);
return formatLinkage(formatType(definitions, type, imports));
}
case TypeDefInfo.Result: {
setImports(definitions, imports, ['Result']);
const [okDef, errorDef] = (typeDef.sub as TypeDef[]);
return formatResult(formatType(definitions, okDef.type, imports), formatType(definitions, errorDef.type, imports));
}
default: {
throw new Error(`Cannot format ${stringify(type)}`);
}
}
return formatters[typeDef.info](registry, typeDef, definitions, imports);
}
+5 -2
View File
@@ -9,5 +9,8 @@ export * from './imports';
export * from './initMeta';
export * from './register';
export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number =>
a.name.toString().localeCompare(b.name.toString());
type Cmp = { name: { toString(): string } };
export function compareName (a: Cmp, b: Cmp): number {
return a.name.toString().localeCompare(b.name.toString());
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,9 +19,9 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/networks": "^7.0.1",
"@polkadot/types": "5.0.1",
"@polkadot/util": "^7.0.1"
"@babel/runtime": "^7.14.8",
"@polkadot/networks": "^7.0.3",
"@polkadot/types": "5.2.1",
"@polkadot/util": "^7.0.3"
}
}
+1
View File
@@ -14,6 +14,7 @@ import typesModules from './modules';
import typesSpec from './spec';
import upgrades from './upgrades';
export { knownOrigins } from './knownOrigins';
export { packageInfo } from './packageInfo';
// flatten a VersionedType[] into a Record<string, string>
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// We want predictive ordering (manually managed)
/* eslint-disable sort-keys */
// FIXME: Need some sort of solution for specifying these
// Since we don't have insight into the origin specification, we can only define what we know about
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
export const knownOrigins: Record<string, string> = {
//
// (1) Defaults from Substrate
//
Council: 'CollectiveOrigin',
System: 'SystemOrigin',
TechnicalCommittee: 'CollectiveOrigin',
//
// (2) Defaults from Polkadot
//
Xcm: 'XcmOrigin',
XcmPallet: 'XcmOrigin',
//
// (3) Defaults from Acala
//
Authority: 'AuthorityOrigin',
GeneralCouncil: 'CollectiveOrigin'
};
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '5.2.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "5.0.1",
"version": "5.2.1",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -19,13 +19,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.14.6",
"@polkadot/util": "^7.0.1",
"@polkadot/util-crypto": "^7.0.1",
"@babel/runtime": "^7.14.8",
"@polkadot/util": "^7.0.3",
"@polkadot/util-crypto": "^7.0.3",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.0.1",
"@polkadot/keyring": "^7.0.3",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
}
+137 -47
View File
@@ -32,19 +32,19 @@ import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, A
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV13, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV13, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, NMapTypeLatest, NMapTypeV13, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableType, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateInfo, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateInfo, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, ReplacementTimes, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
import type { FeeDetails, InclusionFee, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { Approvals } from '@polkadot/types/interfaces/poll';
import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
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 { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
@@ -126,7 +126,7 @@ declare module '@polkadot/types/types/registry' {
'Compact<SessionIndex>': Compact<SessionIndex>;
'Compact<SetId>': Compact<SetId>;
'Compact<SetIndex>': Compact<SetIndex>;
'Compact<SiLookupTypeId>': Compact<SiLookupTypeId>;
'Compact<Si0LookupTypeId>': Compact<Si0LookupTypeId>;
'Compact<Slot>': Compact<Slot>;
'Compact<SlotNumber>': Compact<SlotNumber>;
'Compact<SpanIndex>': Compact<SpanIndex>;
@@ -162,6 +162,8 @@ declare module '@polkadot/types/types/registry' {
'Option<AbridgedHrmpChannel>': Option<AbridgedHrmpChannel>;
'Option<AccountData>': Option<AccountData>;
'Option<AccountId>': Option<AccountId>;
'Option<AccountId20>': Option<AccountId20>;
'Option<AccountId32>': Option<AccountId32>;
'Option<AccountId32Junction>': Option<AccountId32Junction>;
'Option<AccountIdOf>': Option<AccountIdOf>;
'Option<AccountIndex>': Option<AccountIndex>;
@@ -371,12 +373,6 @@ declare module '@polkadot/types/types/registry' {
'Option<DisputeStatement>': Option<DisputeStatement>;
'Option<DisputeStatementSet>': Option<DisputeStatementSet>;
'Option<DoubleEncodedCall>': Option<DoubleEncodedCall>;
'Option<DoubleMapTypeLatest>': Option<DoubleMapTypeLatest>;
'Option<DoubleMapTypeV10>': Option<DoubleMapTypeV10>;
'Option<DoubleMapTypeV11>': Option<DoubleMapTypeV11>;
'Option<DoubleMapTypeV12>': Option<DoubleMapTypeV12>;
'Option<DoubleMapTypeV13>': Option<DoubleMapTypeV13>;
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
'Option<DoubleVoteReport>': Option<DoubleVoteReport>;
'Option<DownwardMessage>': Option<DownwardMessage>;
'Option<EcdsaSignature>': Option<EcdsaSignature>;
@@ -460,6 +456,7 @@ declare module '@polkadot/types/types/registry' {
'Option<ExtrinsicMetadataV11>': Option<ExtrinsicMetadataV11>;
'Option<ExtrinsicMetadataV12>': Option<ExtrinsicMetadataV12>;
'Option<ExtrinsicMetadataV13>': Option<ExtrinsicMetadataV13>;
'Option<ExtrinsicMetadataV14>': Option<ExtrinsicMetadataV14>;
'Option<ExtrinsicOrHash>': Option<ExtrinsicOrHash>;
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
'Option<ExtrinsicPayloadUnknown>': Option<ExtrinsicPayloadUnknown>;
@@ -594,12 +591,6 @@ declare module '@polkadot/types/types/registry' {
'Option<LookupSource>': Option<LookupSource>;
'Option<LookupTarget>': Option<LookupTarget>;
'Option<LotteryConfig>': Option<LotteryConfig>;
'Option<MapTypeLatest>': Option<MapTypeLatest>;
'Option<MapTypeV10>': Option<MapTypeV10>;
'Option<MapTypeV11>': Option<MapTypeV11>;
'Option<MapTypeV12>': Option<MapTypeV12>;
'Option<MapTypeV13>': Option<MapTypeV13>;
'Option<MapTypeV9>': Option<MapTypeV9>;
'Option<MaybeRandomness>': Option<MaybeRandomness>;
'Option<MaybeVrf>': Option<MaybeVrf>;
'Option<MemberCount>': Option<MemberCount>;
@@ -615,6 +606,7 @@ declare module '@polkadot/types/types/registry' {
'Option<MetadataV11>': Option<MetadataV11>;
'Option<MetadataV12>': Option<MetadataV12>;
'Option<MetadataV13>': Option<MetadataV13>;
'Option<MetadataV14>': Option<MetadataV14>;
'Option<MetadataV9>': Option<MetadataV9>;
'Option<MmrLeafProof>': Option<MmrLeafProof>;
'Option<MmrRootHash>': Option<MmrRootHash>;
@@ -655,8 +647,6 @@ declare module '@polkadot/types/types/registry' {
'Option<NextAuthority>': Option<NextAuthority>;
'Option<NextConfigDescriptor>': Option<NextConfigDescriptor>;
'Option<NextConfigDescriptorV1>': Option<NextConfigDescriptorV1>;
'Option<NMapTypeLatest>': Option<NMapTypeLatest>;
'Option<NMapTypeV13>': Option<NMapTypeV13>;
'Option<NodeRole>': Option<NodeRole>;
'Option<Nominations>': Option<Nominations>;
'Option<NominatorIndex>': Option<NominatorIndex>;
@@ -685,8 +675,20 @@ declare module '@polkadot/types/types/registry' {
'Option<Owner>': Option<Owner>;
'Option<PageCounter>': Option<PageCounter>;
'Option<PageIndexData>': Option<PageIndexData>;
'Option<PalletCallMetadataLatest>': Option<PalletCallMetadataLatest>;
'Option<PalletCallMetadataV14>': Option<PalletCallMetadataV14>;
'Option<PalletConstantMetadataLatest>': Option<PalletConstantMetadataLatest>;
'Option<PalletConstantMetadataV14>': Option<PalletConstantMetadataV14>;
'Option<PalletErrorMetadataLatest>': Option<PalletErrorMetadataLatest>;
'Option<PalletErrorMetadataV14>': Option<PalletErrorMetadataV14>;
'Option<PalletEventMetadataLatest>': Option<PalletEventMetadataLatest>;
'Option<PalletEventMetadataV14>': Option<PalletEventMetadataV14>;
'Option<PalletId>': Option<PalletId>;
'Option<PalletMetadataLatest>': Option<PalletMetadataLatest>;
'Option<PalletMetadataV14>': Option<PalletMetadataV14>;
'Option<PalletsOrigin>': Option<PalletsOrigin>;
'Option<PalletStorageMetadataLatest>': Option<PalletStorageMetadataLatest>;
'Option<PalletStorageMetadataV14>': Option<PalletStorageMetadataV14>;
'Option<PalletVersion>': Option<PalletVersion>;
'Option<ParachainDispatchOrigin>': Option<ParachainDispatchOrigin>;
'Option<ParachainInherentData>': Option<ParachainInherentData>;
@@ -730,6 +732,8 @@ declare module '@polkadot/types/types/registry' {
'Option<PhragmenScore>': Option<PhragmenScore>;
'Option<PluralityJunction>': Option<PluralityJunction>;
'Option<Points>': Option<Points>;
'Option<PortableRegistry>': Option<PortableRegistry>;
'Option<PortableType>': Option<PortableType>;
'Option<Precommits>': Option<Precommits>;
'Option<PrefabWasmModule>': Option<PrefabWasmModule>;
'Option<PrefixedStorageKey>': Option<PrefixedStorageKey>;
@@ -789,6 +793,7 @@ declare module '@polkadot/types/types/registry' {
'Option<Remark>': Option<Remark>;
'Option<Renouncing>': Option<Renouncing>;
'Option<RentProjection>': Option<RentProjection>;
'Option<ReplacementTimes>': Option<ReplacementTimes>;
'Option<ReportedRoundStates>': Option<ReportedRoundStates>;
'Option<Reporter>': Option<Reporter>;
'Option<ReportIdOf>': Option<ReportIdOf>;
@@ -839,6 +844,22 @@ declare module '@polkadot/types/types/registry' {
'Option<SessionKeys9B>': Option<SessionKeys9B>;
'Option<SetId>': Option<SetId>;
'Option<SetIndex>': Option<SetIndex>;
'Option<Si0Field>': Option<Si0Field>;
'Option<Si0LookupTypeId>': Option<Si0LookupTypeId>;
'Option<Si0Path>': Option<Si0Path>;
'Option<Si0Type>': Option<Si0Type>;
'Option<Si0TypeDef>': Option<Si0TypeDef>;
'Option<Si0TypeDefArray>': Option<Si0TypeDefArray>;
'Option<Si0TypeDefBitSequence>': Option<Si0TypeDefBitSequence>;
'Option<Si0TypeDefCompact>': Option<Si0TypeDefCompact>;
'Option<Si0TypeDefComposite>': Option<Si0TypeDefComposite>;
'Option<Si0TypeDefPhantom>': Option<Si0TypeDefPhantom>;
'Option<Si0TypeDefPrimitive>': Option<Si0TypeDefPrimitive>;
'Option<Si0TypeDefSequence>': Option<Si0TypeDefSequence>;
'Option<Si0TypeDefTuple>': Option<Si0TypeDefTuple>;
'Option<Si0TypeDefVariant>': Option<Si0TypeDefVariant>;
'Option<Si0TypeParameter>': Option<Si0TypeParameter>;
'Option<Si0Variant>': Option<Si0Variant>;
'Option<SiField>': Option<SiField>;
'Option<Signature>': Option<Signature>;
'Option<SignedAvailabilityBitfield>': Option<SignedAvailabilityBitfield>;
@@ -846,6 +867,8 @@ declare module '@polkadot/types/types/registry' {
'Option<SignedBlock>': Option<SignedBlock>;
'Option<SignedBlockWithJustification>': Option<SignedBlockWithJustification>;
'Option<SignedBlockWithJustifications>': Option<SignedBlockWithJustifications>;
'Option<SignedExtensionMetadataLatest>': Option<SignedExtensionMetadataLatest>;
'Option<SignedExtensionMetadataV14>': Option<SignedExtensionMetadataV14>;
'Option<SignedSubmission>': Option<SignedSubmission>;
'Option<SignedSubmissionOf>': Option<SignedSubmissionOf>;
'Option<SignerPayload>': Option<SignerPayload>;
@@ -855,11 +878,14 @@ declare module '@polkadot/types/types/registry' {
'Option<SiType>': Option<SiType>;
'Option<SiTypeDef>': Option<SiTypeDef>;
'Option<SiTypeDefArray>': Option<SiTypeDefArray>;
'Option<SiTypeDefBitSequence>': Option<SiTypeDefBitSequence>;
'Option<SiTypeDefCompact>': Option<SiTypeDefCompact>;
'Option<SiTypeDefComposite>': Option<SiTypeDefComposite>;
'Option<SiTypeDefPrimitive>': Option<SiTypeDefPrimitive>;
'Option<SiTypeDefSequence>': Option<SiTypeDefSequence>;
'Option<SiTypeDefTuple>': Option<SiTypeDefTuple>;
'Option<SiTypeDefVariant>': Option<SiTypeDefVariant>;
'Option<SiTypeParameter>': Option<SiTypeParameter>;
'Option<SiVariant>': Option<SiVariant>;
'Option<SlashingSpans>': Option<SlashingSpans>;
'Option<SlashingSpansTo204>': Option<SlashingSpansTo204>;
@@ -887,24 +913,28 @@ declare module '@polkadot/types/types/registry' {
'Option<StorageEntryMetadataV11>': Option<StorageEntryMetadataV11>;
'Option<StorageEntryMetadataV12>': Option<StorageEntryMetadataV12>;
'Option<StorageEntryMetadataV13>': Option<StorageEntryMetadataV13>;
'Option<StorageEntryMetadataV14>': Option<StorageEntryMetadataV14>;
'Option<StorageEntryMetadataV9>': Option<StorageEntryMetadataV9>;
'Option<StorageEntryModifierLatest>': Option<StorageEntryModifierLatest>;
'Option<StorageEntryModifierV10>': Option<StorageEntryModifierV10>;
'Option<StorageEntryModifierV11>': Option<StorageEntryModifierV11>;
'Option<StorageEntryModifierV12>': Option<StorageEntryModifierV12>;
'Option<StorageEntryModifierV13>': Option<StorageEntryModifierV13>;
'Option<StorageEntryModifierV14>': Option<StorageEntryModifierV14>;
'Option<StorageEntryModifierV9>': Option<StorageEntryModifierV9>;
'Option<StorageEntryTypeLatest>': Option<StorageEntryTypeLatest>;
'Option<StorageEntryTypeV10>': Option<StorageEntryTypeV10>;
'Option<StorageEntryTypeV11>': Option<StorageEntryTypeV11>;
'Option<StorageEntryTypeV12>': Option<StorageEntryTypeV12>;
'Option<StorageEntryTypeV13>': Option<StorageEntryTypeV13>;
'Option<StorageEntryTypeV14>': Option<StorageEntryTypeV14>;
'Option<StorageEntryTypeV9>': Option<StorageEntryTypeV9>;
'Option<StorageHasher>': Option<StorageHasher>;
'Option<StorageHasherV10>': Option<StorageHasherV10>;
'Option<StorageHasherV11>': Option<StorageHasherV11>;
'Option<StorageHasherV12>': Option<StorageHasherV12>;
'Option<StorageHasherV13>': Option<StorageHasherV13>;
'Option<StorageHasherV14>': Option<StorageHasherV14>;
'Option<StorageHasherV9>': Option<StorageHasherV9>;
'Option<StorageKey>': Option<StorageKey>;
'Option<StorageKind>': Option<StorageKind>;
@@ -1045,6 +1075,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<AbridgedHrmpChannel>': Vec<AbridgedHrmpChannel>;
'Vec<AccountData>': Vec<AccountData>;
'Vec<AccountId>': Vec<AccountId>;
'Vec<AccountId20>': Vec<AccountId20>;
'Vec<AccountId32>': Vec<AccountId32>;
'Vec<AccountId32Junction>': Vec<AccountId32Junction>;
'Vec<AccountIdOf>': Vec<AccountIdOf>;
'Vec<AccountIndex>': Vec<AccountIndex>;
@@ -1254,12 +1286,6 @@ declare module '@polkadot/types/types/registry' {
'Vec<DisputeStatement>': Vec<DisputeStatement>;
'Vec<DisputeStatementSet>': Vec<DisputeStatementSet>;
'Vec<DoubleEncodedCall>': Vec<DoubleEncodedCall>;
'Vec<DoubleMapTypeLatest>': Vec<DoubleMapTypeLatest>;
'Vec<DoubleMapTypeV10>': Vec<DoubleMapTypeV10>;
'Vec<DoubleMapTypeV11>': Vec<DoubleMapTypeV11>;
'Vec<DoubleMapTypeV12>': Vec<DoubleMapTypeV12>;
'Vec<DoubleMapTypeV13>': Vec<DoubleMapTypeV13>;
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
'Vec<DoubleVoteReport>': Vec<DoubleVoteReport>;
'Vec<DownwardMessage>': Vec<DownwardMessage>;
'Vec<EcdsaSignature>': Vec<EcdsaSignature>;
@@ -1343,6 +1369,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<ExtrinsicMetadataV11>': Vec<ExtrinsicMetadataV11>;
'Vec<ExtrinsicMetadataV12>': Vec<ExtrinsicMetadataV12>;
'Vec<ExtrinsicMetadataV13>': Vec<ExtrinsicMetadataV13>;
'Vec<ExtrinsicMetadataV14>': Vec<ExtrinsicMetadataV14>;
'Vec<ExtrinsicOrHash>': Vec<ExtrinsicOrHash>;
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
'Vec<ExtrinsicPayloadUnknown>': Vec<ExtrinsicPayloadUnknown>;
@@ -1477,12 +1504,6 @@ declare module '@polkadot/types/types/registry' {
'Vec<LookupSource>': Vec<LookupSource>;
'Vec<LookupTarget>': Vec<LookupTarget>;
'Vec<LotteryConfig>': Vec<LotteryConfig>;
'Vec<MapTypeLatest>': Vec<MapTypeLatest>;
'Vec<MapTypeV10>': Vec<MapTypeV10>;
'Vec<MapTypeV11>': Vec<MapTypeV11>;
'Vec<MapTypeV12>': Vec<MapTypeV12>;
'Vec<MapTypeV13>': Vec<MapTypeV13>;
'Vec<MapTypeV9>': Vec<MapTypeV9>;
'Vec<MaybeRandomness>': Vec<MaybeRandomness>;
'Vec<MaybeVrf>': Vec<MaybeVrf>;
'Vec<MemberCount>': Vec<MemberCount>;
@@ -1498,6 +1519,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<MetadataV11>': Vec<MetadataV11>;
'Vec<MetadataV12>': Vec<MetadataV12>;
'Vec<MetadataV13>': Vec<MetadataV13>;
'Vec<MetadataV14>': Vec<MetadataV14>;
'Vec<MetadataV9>': Vec<MetadataV9>;
'Vec<MmrLeafProof>': Vec<MmrLeafProof>;
'Vec<MmrRootHash>': Vec<MmrRootHash>;
@@ -1538,8 +1560,6 @@ declare module '@polkadot/types/types/registry' {
'Vec<NextAuthority>': Vec<NextAuthority>;
'Vec<NextConfigDescriptor>': Vec<NextConfigDescriptor>;
'Vec<NextConfigDescriptorV1>': Vec<NextConfigDescriptorV1>;
'Vec<NMapTypeLatest>': Vec<NMapTypeLatest>;
'Vec<NMapTypeV13>': Vec<NMapTypeV13>;
'Vec<NodeRole>': Vec<NodeRole>;
'Vec<Nominations>': Vec<Nominations>;
'Vec<NominatorIndex>': Vec<NominatorIndex>;
@@ -1568,8 +1588,20 @@ declare module '@polkadot/types/types/registry' {
'Vec<Owner>': Vec<Owner>;
'Vec<PageCounter>': Vec<PageCounter>;
'Vec<PageIndexData>': Vec<PageIndexData>;
'Vec<PalletCallMetadataLatest>': Vec<PalletCallMetadataLatest>;
'Vec<PalletCallMetadataV14>': Vec<PalletCallMetadataV14>;
'Vec<PalletConstantMetadataLatest>': Vec<PalletConstantMetadataLatest>;
'Vec<PalletConstantMetadataV14>': Vec<PalletConstantMetadataV14>;
'Vec<PalletErrorMetadataLatest>': Vec<PalletErrorMetadataLatest>;
'Vec<PalletErrorMetadataV14>': Vec<PalletErrorMetadataV14>;
'Vec<PalletEventMetadataLatest>': Vec<PalletEventMetadataLatest>;
'Vec<PalletEventMetadataV14>': Vec<PalletEventMetadataV14>;
'Vec<PalletId>': Vec<PalletId>;
'Vec<PalletMetadataLatest>': Vec<PalletMetadataLatest>;
'Vec<PalletMetadataV14>': Vec<PalletMetadataV14>;
'Vec<PalletsOrigin>': Vec<PalletsOrigin>;
'Vec<PalletStorageMetadataLatest>': Vec<PalletStorageMetadataLatest>;
'Vec<PalletStorageMetadataV14>': Vec<PalletStorageMetadataV14>;
'Vec<PalletVersion>': Vec<PalletVersion>;
'Vec<ParachainDispatchOrigin>': Vec<ParachainDispatchOrigin>;
'Vec<ParachainInherentData>': Vec<ParachainInherentData>;
@@ -1613,6 +1645,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<PhragmenScore>': Vec<PhragmenScore>;
'Vec<PluralityJunction>': Vec<PluralityJunction>;
'Vec<Points>': Vec<Points>;
'Vec<PortableRegistry>': Vec<PortableRegistry>;
'Vec<PortableType>': Vec<PortableType>;
'Vec<Precommits>': Vec<Precommits>;
'Vec<PrefabWasmModule>': Vec<PrefabWasmModule>;
'Vec<PrefixedStorageKey>': Vec<PrefixedStorageKey>;
@@ -1672,6 +1706,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<Remark>': Vec<Remark>;
'Vec<Renouncing>': Vec<Renouncing>;
'Vec<RentProjection>': Vec<RentProjection>;
'Vec<ReplacementTimes>': Vec<ReplacementTimes>;
'Vec<ReportedRoundStates>': Vec<ReportedRoundStates>;
'Vec<Reporter>': Vec<Reporter>;
'Vec<ReportIdOf>': Vec<ReportIdOf>;
@@ -1722,6 +1757,22 @@ declare module '@polkadot/types/types/registry' {
'Vec<SessionKeys9B>': Vec<SessionKeys9B>;
'Vec<SetId>': Vec<SetId>;
'Vec<SetIndex>': Vec<SetIndex>;
'Vec<Si0Field>': Vec<Si0Field>;
'Vec<Si0LookupTypeId>': Vec<Si0LookupTypeId>;
'Vec<Si0Path>': Vec<Si0Path>;
'Vec<Si0Type>': Vec<Si0Type>;
'Vec<Si0TypeDef>': Vec<Si0TypeDef>;
'Vec<Si0TypeDefArray>': Vec<Si0TypeDefArray>;
'Vec<Si0TypeDefBitSequence>': Vec<Si0TypeDefBitSequence>;
'Vec<Si0TypeDefCompact>': Vec<Si0TypeDefCompact>;
'Vec<Si0TypeDefComposite>': Vec<Si0TypeDefComposite>;
'Vec<Si0TypeDefPhantom>': Vec<Si0TypeDefPhantom>;
'Vec<Si0TypeDefPrimitive>': Vec<Si0TypeDefPrimitive>;
'Vec<Si0TypeDefSequence>': Vec<Si0TypeDefSequence>;
'Vec<Si0TypeDefTuple>': Vec<Si0TypeDefTuple>;
'Vec<Si0TypeDefVariant>': Vec<Si0TypeDefVariant>;
'Vec<Si0TypeParameter>': Vec<Si0TypeParameter>;
'Vec<Si0Variant>': Vec<Si0Variant>;
'Vec<SiField>': Vec<SiField>;
'Vec<Signature>': Vec<Signature>;
'Vec<SignedAvailabilityBitfield>': Vec<SignedAvailabilityBitfield>;
@@ -1729,6 +1780,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<SignedBlock>': Vec<SignedBlock>;
'Vec<SignedBlockWithJustification>': Vec<SignedBlockWithJustification>;
'Vec<SignedBlockWithJustifications>': Vec<SignedBlockWithJustifications>;
'Vec<SignedExtensionMetadataLatest>': Vec<SignedExtensionMetadataLatest>;
'Vec<SignedExtensionMetadataV14>': Vec<SignedExtensionMetadataV14>;
'Vec<SignedSubmission>': Vec<SignedSubmission>;
'Vec<SignedSubmissionOf>': Vec<SignedSubmissionOf>;
'Vec<SignerPayload>': Vec<SignerPayload>;
@@ -1738,11 +1791,14 @@ declare module '@polkadot/types/types/registry' {
'Vec<SiType>': Vec<SiType>;
'Vec<SiTypeDef>': Vec<SiTypeDef>;
'Vec<SiTypeDefArray>': Vec<SiTypeDefArray>;
'Vec<SiTypeDefBitSequence>': Vec<SiTypeDefBitSequence>;
'Vec<SiTypeDefCompact>': Vec<SiTypeDefCompact>;
'Vec<SiTypeDefComposite>': Vec<SiTypeDefComposite>;
'Vec<SiTypeDefPrimitive>': Vec<SiTypeDefPrimitive>;
'Vec<SiTypeDefSequence>': Vec<SiTypeDefSequence>;
'Vec<SiTypeDefTuple>': Vec<SiTypeDefTuple>;
'Vec<SiTypeDefVariant>': Vec<SiTypeDefVariant>;
'Vec<SiTypeParameter>': Vec<SiTypeParameter>;
'Vec<SiVariant>': Vec<SiVariant>;
'Vec<SlashingSpans>': Vec<SlashingSpans>;
'Vec<SlashingSpansTo204>': Vec<SlashingSpansTo204>;
@@ -1770,24 +1826,28 @@ declare module '@polkadot/types/types/registry' {
'Vec<StorageEntryMetadataV11>': Vec<StorageEntryMetadataV11>;
'Vec<StorageEntryMetadataV12>': Vec<StorageEntryMetadataV12>;
'Vec<StorageEntryMetadataV13>': Vec<StorageEntryMetadataV13>;
'Vec<StorageEntryMetadataV14>': Vec<StorageEntryMetadataV14>;
'Vec<StorageEntryMetadataV9>': Vec<StorageEntryMetadataV9>;
'Vec<StorageEntryModifierLatest>': Vec<StorageEntryModifierLatest>;
'Vec<StorageEntryModifierV10>': Vec<StorageEntryModifierV10>;
'Vec<StorageEntryModifierV11>': Vec<StorageEntryModifierV11>;
'Vec<StorageEntryModifierV12>': Vec<StorageEntryModifierV12>;
'Vec<StorageEntryModifierV13>': Vec<StorageEntryModifierV13>;
'Vec<StorageEntryModifierV14>': Vec<StorageEntryModifierV14>;
'Vec<StorageEntryModifierV9>': Vec<StorageEntryModifierV9>;
'Vec<StorageEntryTypeLatest>': Vec<StorageEntryTypeLatest>;
'Vec<StorageEntryTypeV10>': Vec<StorageEntryTypeV10>;
'Vec<StorageEntryTypeV11>': Vec<StorageEntryTypeV11>;
'Vec<StorageEntryTypeV12>': Vec<StorageEntryTypeV12>;
'Vec<StorageEntryTypeV13>': Vec<StorageEntryTypeV13>;
'Vec<StorageEntryTypeV14>': Vec<StorageEntryTypeV14>;
'Vec<StorageEntryTypeV9>': Vec<StorageEntryTypeV9>;
'Vec<StorageHasher>': Vec<StorageHasher>;
'Vec<StorageHasherV10>': Vec<StorageHasherV10>;
'Vec<StorageHasherV11>': Vec<StorageHasherV11>;
'Vec<StorageHasherV12>': Vec<StorageHasherV12>;
'Vec<StorageHasherV13>': Vec<StorageHasherV13>;
'Vec<StorageHasherV14>': Vec<StorageHasherV14>;
'Vec<StorageHasherV9>': Vec<StorageHasherV9>;
'Vec<StorageKey>': Vec<StorageKey>;
'Vec<StorageKind>': Vec<StorageKind>;
@@ -1928,6 +1988,8 @@ declare module '@polkadot/types/types/registry' {
AbridgedHrmpChannel: AbridgedHrmpChannel;
AccountData: AccountData;
AccountId: AccountId;
AccountId20: AccountId20;
AccountId32: AccountId32;
AccountId32Junction: AccountId32Junction;
AccountIdOf: AccountIdOf;
AccountIndex: AccountIndex;
@@ -2137,12 +2199,6 @@ declare module '@polkadot/types/types/registry' {
DisputeStatement: DisputeStatement;
DisputeStatementSet: DisputeStatementSet;
DoubleEncodedCall: DoubleEncodedCall;
DoubleMapTypeLatest: DoubleMapTypeLatest;
DoubleMapTypeV10: DoubleMapTypeV10;
DoubleMapTypeV11: DoubleMapTypeV11;
DoubleMapTypeV12: DoubleMapTypeV12;
DoubleMapTypeV13: DoubleMapTypeV13;
DoubleMapTypeV9: DoubleMapTypeV9;
DoubleVoteReport: DoubleVoteReport;
DownwardMessage: DownwardMessage;
EcdsaSignature: EcdsaSignature;
@@ -2226,6 +2282,7 @@ declare module '@polkadot/types/types/registry' {
ExtrinsicMetadataV11: ExtrinsicMetadataV11;
ExtrinsicMetadataV12: ExtrinsicMetadataV12;
ExtrinsicMetadataV13: ExtrinsicMetadataV13;
ExtrinsicMetadataV14: ExtrinsicMetadataV14;
ExtrinsicOrHash: ExtrinsicOrHash;
ExtrinsicPayload: ExtrinsicPayload;
ExtrinsicPayloadUnknown: ExtrinsicPayloadUnknown;
@@ -2360,12 +2417,6 @@ declare module '@polkadot/types/types/registry' {
LookupSource: LookupSource;
LookupTarget: LookupTarget;
LotteryConfig: LotteryConfig;
MapTypeLatest: MapTypeLatest;
MapTypeV10: MapTypeV10;
MapTypeV11: MapTypeV11;
MapTypeV12: MapTypeV12;
MapTypeV13: MapTypeV13;
MapTypeV9: MapTypeV9;
MaybeRandomness: MaybeRandomness;
MaybeVrf: MaybeVrf;
MemberCount: MemberCount;
@@ -2381,6 +2432,7 @@ declare module '@polkadot/types/types/registry' {
MetadataV11: MetadataV11;
MetadataV12: MetadataV12;
MetadataV13: MetadataV13;
MetadataV14: MetadataV14;
MetadataV9: MetadataV9;
MmrLeafProof: MmrLeafProof;
MmrRootHash: MmrRootHash;
@@ -2421,8 +2473,6 @@ declare module '@polkadot/types/types/registry' {
NextAuthority: NextAuthority;
NextConfigDescriptor: NextConfigDescriptor;
NextConfigDescriptorV1: NextConfigDescriptorV1;
NMapTypeLatest: NMapTypeLatest;
NMapTypeV13: NMapTypeV13;
NodeRole: NodeRole;
Nominations: Nominations;
NominatorIndex: NominatorIndex;
@@ -2451,8 +2501,20 @@ declare module '@polkadot/types/types/registry' {
Owner: Owner;
PageCounter: PageCounter;
PageIndexData: PageIndexData;
PalletCallMetadataLatest: PalletCallMetadataLatest;
PalletCallMetadataV14: PalletCallMetadataV14;
PalletConstantMetadataLatest: PalletConstantMetadataLatest;
PalletConstantMetadataV14: PalletConstantMetadataV14;
PalletErrorMetadataLatest: PalletErrorMetadataLatest;
PalletErrorMetadataV14: PalletErrorMetadataV14;
PalletEventMetadataLatest: PalletEventMetadataLatest;
PalletEventMetadataV14: PalletEventMetadataV14;
PalletId: PalletId;
PalletMetadataLatest: PalletMetadataLatest;
PalletMetadataV14: PalletMetadataV14;
PalletsOrigin: PalletsOrigin;
PalletStorageMetadataLatest: PalletStorageMetadataLatest;
PalletStorageMetadataV14: PalletStorageMetadataV14;
PalletVersion: PalletVersion;
ParachainDispatchOrigin: ParachainDispatchOrigin;
ParachainInherentData: ParachainInherentData;
@@ -2496,6 +2558,8 @@ declare module '@polkadot/types/types/registry' {
PhragmenScore: PhragmenScore;
PluralityJunction: PluralityJunction;
Points: Points;
PortableRegistry: PortableRegistry;
PortableType: PortableType;
Precommits: Precommits;
PrefabWasmModule: PrefabWasmModule;
PrefixedStorageKey: PrefixedStorageKey;
@@ -2555,6 +2619,7 @@ declare module '@polkadot/types/types/registry' {
Remark: Remark;
Renouncing: Renouncing;
RentProjection: RentProjection;
ReplacementTimes: ReplacementTimes;
ReportedRoundStates: ReportedRoundStates;
Reporter: Reporter;
ReportIdOf: ReportIdOf;
@@ -2605,6 +2670,22 @@ declare module '@polkadot/types/types/registry' {
SessionKeys9B: SessionKeys9B;
SetId: SetId;
SetIndex: SetIndex;
Si0Field: Si0Field;
Si0LookupTypeId: Si0LookupTypeId;
Si0Path: Si0Path;
Si0Type: Si0Type;
Si0TypeDef: Si0TypeDef;
Si0TypeDefArray: Si0TypeDefArray;
Si0TypeDefBitSequence: Si0TypeDefBitSequence;
Si0TypeDefCompact: Si0TypeDefCompact;
Si0TypeDefComposite: Si0TypeDefComposite;
Si0TypeDefPhantom: Si0TypeDefPhantom;
Si0TypeDefPrimitive: Si0TypeDefPrimitive;
Si0TypeDefSequence: Si0TypeDefSequence;
Si0TypeDefTuple: Si0TypeDefTuple;
Si0TypeDefVariant: Si0TypeDefVariant;
Si0TypeParameter: Si0TypeParameter;
Si0Variant: Si0Variant;
SiField: SiField;
Signature: Signature;
SignedAvailabilityBitfield: SignedAvailabilityBitfield;
@@ -2612,6 +2693,8 @@ declare module '@polkadot/types/types/registry' {
SignedBlock: SignedBlock;
SignedBlockWithJustification: SignedBlockWithJustification;
SignedBlockWithJustifications: SignedBlockWithJustifications;
SignedExtensionMetadataLatest: SignedExtensionMetadataLatest;
SignedExtensionMetadataV14: SignedExtensionMetadataV14;
SignedSubmission: SignedSubmission;
SignedSubmissionOf: SignedSubmissionOf;
SignerPayload: SignerPayload;
@@ -2621,11 +2704,14 @@ declare module '@polkadot/types/types/registry' {
SiType: SiType;
SiTypeDef: SiTypeDef;
SiTypeDefArray: SiTypeDefArray;
SiTypeDefBitSequence: SiTypeDefBitSequence;
SiTypeDefCompact: SiTypeDefCompact;
SiTypeDefComposite: SiTypeDefComposite;
SiTypeDefPrimitive: SiTypeDefPrimitive;
SiTypeDefSequence: SiTypeDefSequence;
SiTypeDefTuple: SiTypeDefTuple;
SiTypeDefVariant: SiTypeDefVariant;
SiTypeParameter: SiTypeParameter;
SiVariant: SiVariant;
SlashingSpans: SlashingSpans;
SlashingSpansTo204: SlashingSpansTo204;
@@ -2653,24 +2739,28 @@ declare module '@polkadot/types/types/registry' {
StorageEntryMetadataV11: StorageEntryMetadataV11;
StorageEntryMetadataV12: StorageEntryMetadataV12;
StorageEntryMetadataV13: StorageEntryMetadataV13;
StorageEntryMetadataV14: StorageEntryMetadataV14;
StorageEntryMetadataV9: StorageEntryMetadataV9;
StorageEntryModifierLatest: StorageEntryModifierLatest;
StorageEntryModifierV10: StorageEntryModifierV10;
StorageEntryModifierV11: StorageEntryModifierV11;
StorageEntryModifierV12: StorageEntryModifierV12;
StorageEntryModifierV13: StorageEntryModifierV13;
StorageEntryModifierV14: StorageEntryModifierV14;
StorageEntryModifierV9: StorageEntryModifierV9;
StorageEntryTypeLatest: StorageEntryTypeLatest;
StorageEntryTypeV10: StorageEntryTypeV10;
StorageEntryTypeV11: StorageEntryTypeV11;
StorageEntryTypeV12: StorageEntryTypeV12;
StorageEntryTypeV13: StorageEntryTypeV13;
StorageEntryTypeV14: StorageEntryTypeV14;
StorageEntryTypeV9: StorageEntryTypeV9;
StorageHasher: StorageHasher;
StorageHasherV10: StorageHasherV10;
StorageHasherV11: StorageHasherV11;
StorageHasherV12: StorageHasherV12;
StorageHasherV13: StorageHasherV13;
StorageHasherV14: StorageHasherV14;
StorageHasherV9: StorageHasherV9;
StorageKey: StorageKey;
StorageKind: StorageKind;
+130 -2
View File
@@ -2,15 +2,52 @@
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '../create';
import { Text, U32 } from '../primitive';
import { BTreeMap, Struct } from '.';
import { I32, Text, U32 } from '../primitive';
import { Constructor } from '../types';
import { ITuple } from '../types/interfaces';
import { BTreeMap, Enum, Struct, Tuple } from '.';
const registry = new TypeRegistry();
class U32TextTuple extends (Tuple.with([U32, Text]) as unknown as Constructor<ITuple<[U32, Text]>>) {}
// Reason: We purposefully want `text` to be the first key of the struct and take priority during sorting
// eslint-disable-next-line sort-keys
class MockStruct extends Struct.with({ text: Text, int: I32 }) {}
class MockEnum extends Enum.with({
Key1: MockStruct,
Key2: MockStruct,
Key3: U32TextTuple
}) {}
const mockU32TextMap = new Map<Text, U32>();
const mockU32TupleMap = new Map<ITuple<[U32, Text]>, U32>();
const mockU32I32Map = new Map<I32, U32>();
const mockU32StructMap = new Map<MockStruct, U32>();
const mockU32EnumMap = new Map<MockEnum, U32>();
mockU32TextMap.set(new Text(registry, 'bazzing'), new U32(registry, 69));
mockU32TupleMap.set((new U32TextTuple(registry, [2, 'ba'])), new U32(registry, 42));
mockU32TupleMap.set((new U32TextTuple(registry, [2, 'b'])), new U32(registry, 7));
mockU32TupleMap.set((new U32TextTuple(registry, [1, 'baz'])), new U32(registry, 13));
mockU32I32Map.set(new I32(registry, 255), new U32(registry, 69));
mockU32I32Map.set(new I32(registry, -255), new U32(registry, 42));
mockU32I32Map.set(new I32(registry, 1000), new U32(registry, 7));
mockU32I32Map.set(new I32(registry, -1000), new U32(registry, 25));
mockU32I32Map.set(new I32(registry, 0), new U32(registry, 13));
mockU32StructMap.set(new MockStruct(registry, { int: 1, text: 'b' }), new U32(registry, 42));
mockU32StructMap.set(new MockStruct(registry, { int: -1, text: 'b' }), new U32(registry, 7));
mockU32StructMap.set(new MockStruct(registry, { int: -1, text: 'ba' }), new U32(registry, 25));
mockU32StructMap.set(new MockStruct(registry, { int: -2, text: 'baz' }), new U32(registry, 13));
mockU32EnumMap.set(new MockEnum(registry, { Key3: new U32TextTuple(registry, [2, 'ba']) }), new U32(registry, 13));
mockU32EnumMap.set(new MockEnum(registry, { Key3: new U32TextTuple(registry, [2, 'b']) }), new U32(registry, 42));
mockU32EnumMap.set(new MockEnum(registry, { Key2: new MockStruct(registry, { int: -1, text: 'b' }) }), new U32(registry, 7));
mockU32EnumMap.set(new MockEnum(registry, { Key1: new MockStruct(registry, { int: 1, text: 'b' }) }), new U32(registry, 25));
mockU32EnumMap.set(new MockEnum(registry, { Key1: new MockStruct(registry, { int: -1, text: 'b' }) }), new U32(registry, 69));
describe('BTreeMap', (): void => {
it('decodes null', (): void => {
expect(
@@ -54,6 +91,97 @@ describe('BTreeMap', (): void => {
).toEqual(13);
});
it('correctly sorts simple keys', (): void => {
expect(
Array.from(new (BTreeMap.with(I32, U32))(registry, mockU32I32Map).keys()).map((k) => k.toNumber())
).toEqual([-1000, -255, 0, 255, 1000]);
});
it('correctly sorts tuple keys', (): void => {
expect(
Array.from(new (BTreeMap.with(U32TextTuple, U32))(registry, mockU32TupleMap).keys()).map((k) => k.toJSON())
).toEqual([[1, 'baz'], [2, 'b'], [2, 'ba']]);
});
it('correctly sorts struct keys', (): void => {
expect(
Array.from(new (BTreeMap.with(MockStruct, U32))(registry, mockU32StructMap).keys()).map((k) => k.toJSON())
).toEqual([
{ int: -1, text: 'b' },
{ int: 1, text: 'b' },
{ int: -1, text: 'ba' },
{ int: -2, text: 'baz' }
]);
});
it('correctly sorts enum keys', (): void => {
expect(
Array.from(new (BTreeMap.with(MockEnum, U32))(registry, mockU32EnumMap).keys()).map((k) => k.toJSON())
).toEqual([
{ key1: { int: -1, text: 'b' } },
{ key1: { int: 1, text: 'b' } },
{ key2: { int: -1, text: 'b' } },
{ key3: [2, 'b'] },
{ key3: [2, 'ba'] }
]);
});
it('correctly serializes/deserializes to/from json with numeric keys', (): void => {
expect(
new (BTreeMap.with(I32, U32))(
registry,
new (BTreeMap.with(I32, U32))(registry, mockU32I32Map).toJSON()
).toJSON()
).toEqual({ '-1000': 25, '-255': 42, 0: 13, 1000: 7, 255: 69 });
});
it('correctly serializes/deserializes to/from json with text keys', (): void => {
expect(
new (BTreeMap.with(Text, U32))(
registry,
new (BTreeMap.with(Text, U32))(registry, mockU32TextMap).toJSON()
).toJSON()
).toEqual({ bazzing: 69 });
});
it('correctly serializes/deserializes to/from json with tuple keys', (): void => {
expect(
new (BTreeMap.with(U32TextTuple, U32))(
registry,
new (BTreeMap.with(U32TextTuple, U32))(registry, mockU32TupleMap).toJSON()
).toJSON()
).toEqual({ '[1,"baz"]': 13, '[2,"b"]': 7, '[2,"ba"]': 42 });
});
it('correctly serializes/deserializes to/from json with struct keys', (): void => {
expect(
new (BTreeMap.with(MockStruct, U32))(
registry,
new (BTreeMap.with(MockStruct, U32))(registry, mockU32StructMap).toJSON()
).toJSON()
).toEqual({
'{"text":"b","int":-1}': 7,
'{"text":"b","int":1}': 42,
'{"text":"ba","int":-1}': 25,
'{"text":"baz","int":-2}': 13
});
});
it('correctly serializes/deserializes to/from json with enum keys', (): void => {
expect(
new (BTreeMap.with(MockEnum, U32))(
registry,
new (BTreeMap.with(MockEnum, U32))(registry, mockU32EnumMap).toJSON()
).toJSON()
).toEqual({
'{"key1":{"text":"b","int":-1}}': 69,
'{"key1":{"text":"b","int":1}}': 25,
'{"key2":{"text":"b","int":-1}}': 7,
'{"key3":[2,"b"]}': 42,
'{"key3":[2,"ba"]}': 13
});
});
it('generates sane toRawTypes', (): void => {
expect(new (BTreeMap.with(Text, U32))(registry).toRawType()).toBe('BTreeMap<Text,u32>');
expect(new (BTreeMap.with(Text, Text))(registry).toRawType()).toBe('BTreeMap<Text,Text>');
+84 -2
View File
@@ -4,11 +4,24 @@
import type { CodecTo } from '../types';
import { TypeRegistry } from '../create';
import { Text, U32 } from '../primitive';
import { BTreeSet, Struct } from '.';
import { I32, Text, U32 } from '../primitive';
import { Constructor } from '../types';
import { ITuple } from '../types/interfaces';
import { Enum } from './Enum';
import { BTreeSet, Struct, Tuple } from '.';
const registry = new TypeRegistry();
class U32TextTuple extends (Tuple.with([U32, Text]) as unknown as Constructor<ITuple<[U32, Text]>>) {}
// Reason: We purposefully want `text` to be the first key of the struct and take priority during sorting
// eslint-disable-next-line sort-keys
class MockStruct extends Struct.with({ text: Text, int: I32 }) {}
class MockEnum extends Enum.with({
Key1: MockStruct,
Key2: MockStruct,
Key3: U32TextTuple
}) {}
const mockU32Set = new Set<U32>();
mockU32Set.add(new U32(registry, 2));
@@ -21,6 +34,34 @@ const mockU32SetObject = [2, 24, 30, 80];
const mockU32SetHexString = '0x1002000000180000001e00000050000000';
const mockU32SetUint8Array = Uint8Array.from([16, 2, 0, 0, 0, 24, 0, 0, 0, 30, 0, 0, 0, 80, 0, 0, 0]);
const mockI32SetObj = [1000, 0, 255, -255, -1000];
const mockTextSetObj = [
new Text(registry, 'baz'),
new Text(registry, 'b'),
new Text(registry, 'bb'),
new Text(registry, 'ba'),
new Text(registry, 'c')
];
const mockTupleSetObj = [
new U32TextTuple(registry, [2, 'ba']),
new U32TextTuple(registry, [2, 'bb']),
new U32TextTuple(registry, [2, 'b']),
new U32TextTuple(registry, [1, 'baz'])
];
const mockStructSetObj = [
new MockStruct(registry, { int: 1, text: 'b' }),
new MockStruct(registry, { int: -1, text: 'b' }),
new MockStruct(registry, { int: -1, text: 'ba' }),
new MockStruct(registry, { int: -2, text: 'baz' })
];
const mockEnumSetObj = [
new MockEnum(registry, { Key3: new U32TextTuple(registry, [2, 'ba']) }),
new MockEnum(registry, { Key3: new U32TextTuple(registry, [2, 'b']) }),
new MockEnum(registry, { Key2: new MockStruct(registry, { int: -1, text: 'b' }) }),
new MockEnum(registry, { Key1: new MockStruct(registry, { int: 1, text: 'b' }) }),
new MockEnum(registry, { Key1: new MockStruct(registry, { int: -1, text: 'b' }) })
];
describe('BTreeSet', (): void => {
describe('decoding', (): void => {
const testDecode = (type: string, input: any, output: string): void =>
@@ -94,6 +135,47 @@ describe('BTreeSet', (): void => {
).toEqual(17);
});
it('correctly sorts numeric values', (): void => {
expect(
Array.from(new (BTreeSet.with(I32))(registry, mockI32SetObj)).map((k) => k.toNumber())
).toEqual([-1000, -255, 0, 255, 1000]);
});
it('correctly sorts text values', (): void => {
expect(
Array.from(new (BTreeSet.with(Text))(registry, mockTextSetObj)).map((k) => k.toString())
).toEqual(['b', 'ba', 'baz', 'bb', 'c']);
});
it('correctly sorts complex tuple values', (): void => {
expect(
Array.from(new (BTreeSet.with(U32TextTuple))(registry, mockTupleSetObj)).map((k) => k.toJSON())
).toEqual([[1, 'baz'], [2, 'b'], [2, 'ba'], [2, 'bb']]);
});
it('correctly sorts complex struct values', (): void => {
expect(
Array.from(new (BTreeSet.with(MockStruct))(registry, mockStructSetObj)).map((k) => k.toJSON())
).toEqual([
{ int: -1, text: 'b' },
{ int: 1, text: 'b' },
{ int: -1, text: 'ba' },
{ int: -2, text: 'baz' }
]);
});
it('correctly sorts complex enum values', (): void => {
expect(
Array.from(new (BTreeSet.with(MockEnum))(registry, mockEnumSetObj)).map((k) => k.toJSON())
).toEqual([
{ key1: { int: -1, text: 'b' } },
{ key1: { int: 1, text: 'b' } },
{ key2: { int: -1, text: 'b' } },
{ key3: [2, 'b'] },
{ key3: [2, 'ba'] }
]);
});
it('generates sane toRawTypes', (): void => {
expect(new (BTreeSet.with(U32))(registry).toRawType()).toBe('BTreeSet<u32>');
expect(new (BTreeSet.with(Text))(registry).toRawType()).toBe('BTreeSet<Text>');
+2 -2
View File
@@ -6,7 +6,7 @@ import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../t
import { compactFromU8a, compactToU8a, isHex, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareSet, decodeU8a, typeToConstructor } from './utils';
import { compareSet, decodeU8a, sortSet, typeToConstructor } from './utils';
const l = logger('BTreeSet');
@@ -84,7 +84,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
readonly #ValClass: Constructor<V>;
constructor (registry: Registry, valType: Constructor<V> | keyof InterfaceTypes, rawValue?: Uint8Array | string | string[] | Set<any>) {
super(decodeSet(registry, valType, rawValue));
super(sortSet(decodeSet(registry, valType, rawValue)));
this.registry = registry;
this.#ValClass = typeToConstructor(registry, valType);
+12 -3
View File
@@ -6,7 +6,10 @@ import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../t
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareMap, decodeU8a, typeToConstructor } from './utils';
import { AbstractArray } from './AbstractArray';
import { Enum } from './Enum';
import { Struct } from './Struct';
import { compareMap, decodeU8a, sortMap, typeToConstructor } from './utils';
const l = logger('Map');
@@ -34,11 +37,15 @@ function decodeMapFromMap<K extends Codec = Codec, V extends Codec = Codec> (reg
const output = new Map<K, V>();
value.forEach((val: any, key: any) => {
const isComplex = KeyClass.prototype instanceof AbstractArray ||
KeyClass.prototype instanceof Struct ||
KeyClass.prototype instanceof Enum;
try {
output.set(
key instanceof KeyClass
? key
: new KeyClass(registry, key),
: new KeyClass(registry, isComplex ? JSON.parse(key) : key),
val instanceof ValClass
? val
: new ValClass(registry, val)
@@ -97,7 +104,9 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
readonly #type: string;
constructor (registry: Registry, keyType: Constructor<K> | keyof InterfaceTypes, valType: Constructor<V> | keyof InterfaceTypes, rawValue: Uint8Array | string | Map<any, any> | undefined, type: 'BTreeMap' | 'HashMap' = 'HashMap') {
super(decodeMap(registry, keyType, valType, rawValue));
const decoded = decodeMap(registry, keyType, valType, rawValue);
super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
this.registry = registry;
this.#KeyClass = typeToConstructor(registry, keyType);
+1
View File
@@ -7,3 +7,4 @@ export { compareSet } from './compareSet';
export { decodeU8a } from './decodeU8a';
export { mapToTypeMap } from './mapToTypeMap';
export { typeToConstructor } from './typeToConstructor';
export { sortAsc, sortSet, sortMap } from './sortValues';
@@ -0,0 +1,64 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Codec } from '../../types';
import { AbstractArray } from '../AbstractArray';
import { AbstractInt } from '../AbstractInt';
import { Enum, Struct } from '..';
type SortArg = Codec | Codec[] | number[] | number | Uint8Array
/** @internal **/
function isArrayLike (arg: SortArg): arg is AbstractArray<Codec> | Uint8Array | Codec[] | number[] {
return arg instanceof AbstractArray || arg instanceof Uint8Array || Array.isArray(arg);
}
/** @internal **/
function isCodec (arg: SortArg): arg is Codec {
return !!(arg && typeof (arg as Codec).toU8a === 'function');
}
/**
* Sort keys/values of BTreeSet/BTreeMap in acending order for encoding compatibility with Rust's BTreeSet/BTreeMap
* (https://doc.rust-lang.org/stable/std/collections/struct.BTreeSet.html)
* (https://doc.rust-lang.org/stable/std/collections/struct.BTreeMap.html)
*/
export function sortAsc<V extends SortArg = Codec> (a: V, b: V): number {
if (typeof a === 'number' && typeof b === 'number') {
return a - b;
} else if (a instanceof Struct && b instanceof Struct) {
return sortAsc(Array.from(a.values()), Array.from(b.values()));
} else if (a instanceof Enum && b instanceof Enum) {
return sortAsc(a.index, b.index) || sortAsc(a.value, b.value);
} else if (isArrayLike(a) && isArrayLike(b)) {
// Vec, Tuple, Bytes etc.
let sortRes = 0; const lenA = a.length; const lenB = b.length;
const minLen = Math.min(lenA, lenB);
for (let i = 0; i < minLen; ++i) {
sortRes = sortAsc(a[i], b[i]);
if (sortRes !== 0) {
return sortRes;
}
}
return lenA - lenB;
} else if (a instanceof AbstractInt && b instanceof AbstractInt) {
return a.cmp(b);
} else if (isCodec(a) && isCodec(b)) {
// Text, Bool etc.
return sortAsc(a.toU8a(true), b.toU8a(true));
} else {
throw new Error(`Attempting to sort unrecognized value: ${JSON.stringify(a)}`);
}
}
export function sortSet<V extends Codec = Codec> (set: Set<V>): Set<V> {
return new Set(Array.from(set).sort(sortAsc));
}
export function sortMap<K extends Codec = Codec, V extends Codec = Codec> (map: Map<K, V>): Map<K, V> {
return new Map(Array.from(map.entries()).sort(([keyA], [keyB]) => sortAsc(keyA, keyB)));
}
+51 -27
View File
@@ -8,12 +8,18 @@ import type { FromReg, TypeDef } from './types';
import { assert, isNumber, isUndefined, stringify } from '@polkadot/util';
import { BTreeMap, BTreeSet, CodecSet, Compact, DoNotConstruct, Enum, HashMap, Int, Option, Result, Struct, Tuple, U8aFixed, UInt, Vec, VecFixed } from '../codec';
import { Bytes, Null } from '../primitive';
import { getTypeDef } from './getTypeDef';
import { TypeDefInfo } from './types';
export function createClass<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K): Constructor<FromReg<T, K>> {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return getTypeClass<FromReg<T, K>>(registry, getTypeDef(type));
return getTypeClass<FromReg<T, K>>(
registry,
registry.isLookupType(type)
? registry.lookup.getTypeDef(type)
: getTypeDef(type)
);
}
// An unsafe version of the `createType` below. It's unsafe because the `type`
@@ -76,13 +82,17 @@ function createHashMap (value: TypeDef, Clazz: typeof BTreeMap | typeof HashMap)
}
const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => Constructor> = {
[TypeDefInfo.BTreeMap]: (registry: Registry, value: TypeDef): Constructor => createHashMap(value, BTreeMap),
[TypeDefInfo.BTreeMap]: (registry: Registry, value: TypeDef): Constructor =>
createHashMap(value, BTreeMap),
[TypeDefInfo.BTreeSet]: (registry: Registry, value: TypeDef): Constructor => BTreeSet.with(getSubType(value)),
[TypeDefInfo.BTreeSet]: (registry: Registry, value: TypeDef): Constructor =>
BTreeSet.with(getSubType(value)),
[TypeDefInfo.Compact]: (registry: Registry, value: TypeDef): Constructor => Compact.with(getSubType(value)),
[TypeDefInfo.Compact]: (registry: Registry, value: TypeDef): Constructor =>
Compact.with(getSubType(value)),
[TypeDefInfo.DoNotConstruct]: (registry: Registry, value: TypeDef): Constructor => DoNotConstruct.with(value.displayName),
[TypeDefInfo.DoNotConstruct]: (registry: Registry, value: TypeDef): Constructor =>
DoNotConstruct.with(value.displayName || value.type),
[TypeDefInfo.Enum]: (registry: Registry, value: TypeDef): Constructor => {
const subs = getSubDefArray(value);
@@ -98,9 +108,11 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
);
},
[TypeDefInfo.HashMap]: (registry: Registry, value: TypeDef): Constructor => createHashMap(value, HashMap),
[TypeDefInfo.HashMap]: (registry: Registry, value: TypeDef): Constructor =>
createHashMap(value, HashMap),
[TypeDefInfo.Int]: (registry: Registry, value: TypeDef): Constructor => createInt(value, Int),
[TypeDefInfo.Int]: (registry: Registry, value: TypeDef): Constructor =>
createInt(value, Int),
// We have circular deps between Linkage & Struct
[TypeDefInfo.Linkage]: (registry: Registry, value: TypeDef): Constructor => {
@@ -118,9 +130,11 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
[TypeDefInfo.Null]: (registry: Registry, _: TypeDef): Constructor => createClass(registry, 'Null'),
[TypeDefInfo.Null]: (registry: Registry, _: TypeDef): Constructor =>
Null,
[TypeDefInfo.Option]: (registry: Registry, value: TypeDef): Constructor => Option.with(getSubType(value)),
[TypeDefInfo.Option]: (registry: Registry, value: TypeDef): Constructor =>
Option.with(getSubType(value)),
[TypeDefInfo.Plain]: (registry: Registry, value: TypeDef): Constructor =>
registry.getOrUnknown(value.type),
@@ -145,18 +159,24 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
);
},
[TypeDefInfo.Struct]: (registry: Registry, value: TypeDef): Constructor => Struct.with(getTypeClassMap(value), value.alias),
[TypeDefInfo.Si]: (registry: Registry, value: TypeDef): Constructor =>
getTypeClass(registry, registry.lookup.getTypeDef(value.type)),
[TypeDefInfo.Tuple]: (registry: Registry, value: TypeDef): Constructor => Tuple.with(getTypeClassArray(value)),
[TypeDefInfo.Struct]: (registry: Registry, value: TypeDef): Constructor =>
Struct.with(getTypeClassMap(value), value.alias),
[TypeDefInfo.UInt]: (registry: Registry, value: TypeDef): Constructor => createInt(value, UInt),
[TypeDefInfo.Tuple]: (registry: Registry, value: TypeDef): Constructor =>
Tuple.with(getTypeClassArray(value)),
[TypeDefInfo.UInt]: (registry: Registry, value: TypeDef): Constructor =>
createInt(value, UInt),
[TypeDefInfo.Vec]: (registry: Registry, value: TypeDef): Constructor => {
const subType = getSubType(value);
return (
subType === 'u8'
? createClass(registry, 'Bytes')
? Bytes
: Vec.with(subType)
);
},
@@ -164,34 +184,38 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
[TypeDefInfo.VecFixed]: (registry: Registry, { displayName, length, sub }: TypeDef): Constructor => {
assert(isNumber(length) && !isUndefined(sub), 'Expected length & type information for fixed vector');
const subType = (sub as TypeDef).type as keyof InterfaceTypes;
return (
(sub as TypeDef).type === 'u8'
subType === 'u8'
? U8aFixed.with((length * 8) as U8aBitLength, displayName)
: VecFixed.with((sub as TypeDef).type as keyof InterfaceTypes, length)
: VecFixed.with(subType, length)
);
}
};
// Returns the type Class for construction
export function getTypeClass<T extends Codec = Codec> (registry: Registry, value: TypeDef): Constructor<T> {
let Type = registry.get<T>(value.type);
export function getTypeClass<T extends Codec = Codec> (registry: Registry, typeDef: TypeDef): Constructor<T> {
let Type = registry.get<T>(typeDef.type);
if (Type) {
return Type;
}
const getFn = infoMapping[value.info];
try {
Type = infoMapping[typeDef.info](registry, typeDef) as Constructor<T>;
assert(getFn, () => `Unable to construct class from ${stringify(value)}`);
assert(Type, 'No class created');
Type = getFn(registry, value) as Constructor<T>;
// don't clobber any existing
if (!Type.__fallbackType && typeDef.fallbackType) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore ...this is the only place we we actually assign this...
Type.__fallbackType = typeDef.fallbackType;
}
// don't clobber any existing
if (!Type.__fallbackType && value.fallbackType) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore ...this is the only place we we actually assign this...
Type.__fallbackType = value.fallbackType;
return Type;
} catch (error) {
throw new Error(`Unable to construct class from ${stringify(typeDef)}: ${(error as Error).message}`);
}
return Type;
}
+16 -16
View File
@@ -3,20 +3,16 @@
import type { Bytes } from '../primitive/Bytes';
import type { Codec, Constructor, InterfaceTypes, Registry } from '../types';
import type { FromReg } from './types';
import type { CreateOptions, FromReg } from './types';
import { assert, isHex, isU8a, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { Option } from '../codec/Option';
import { createClass } from './createClass';
interface CreateOptions {
blockHash?: Uint8Array | string | null;
isPedantic?: boolean;
}
// With isPedantic, actually check that the encoding matches that supplied. This
// is much slower, but verifies that we have the correct types defined
function checkInstance<T extends Codec = Codec, K extends string = string> (value: Uint8Array, created: FromReg<T, K>): void {
function checkInstance (created: FromReg<Codec, string>, value: Uint8Array): void {
const u8a = created.toU8a();
const rawType = created.toRawType();
@@ -30,25 +26,29 @@ function checkInstance<T extends Codec = Codec, K extends string = string> (valu
);
}
// Initializes a type with a value. This also checks for fallbacks and in the cases
// where isPedantic is specified (storage decoding), also check the format/structure
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: unknown[] = [], { blockHash, isPedantic }: CreateOptions = {}): FromReg<T, K> {
const created = new Type(registry, ...params);
const value = params[0];
function checkPedantic (created: FromReg<Codec, string>, [value]: unknown[], isPedantic = false): void {
if (isPedantic) {
if (isU8a(value)) {
checkInstance(value, created);
checkInstance(created, value);
} else if (isHex(value)) {
checkInstance(u8aToU8a(value), created);
checkInstance(created, u8aToU8a(value));
}
}
}
// Initializes a type with a value. This also checks for fallbacks and in the cases
// where isPedantic is specified (storage decoding), also check the format/structure
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: unknown[] = [], { blockHash, isOptional, isPedantic }: CreateOptions = {}): FromReg<T, K> {
const created = new (isOptional ? Option.with(Type) : Type)(registry, ...params);
checkPedantic(created, params, isPedantic);
if (blockHash) {
created.createdAtHash = createType(registry, 'Hash', blockHash);
}
return created;
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return created as any;
}
// An unsafe version of the `createType` below. It's unsafe because the `type`
@@ -2,12 +2,15 @@
// SPDX-License-Identifier: Apache-2.0
import { encodeTypeDef } from './encodeTypes';
import { TypeRegistry } from './registry';
import { TypeDefInfo } from './types';
describe('encodeTypeDef', (): void => {
const registry = new TypeRegistry();
it('correctly encodes a complex struct', (): void => {
expect(
JSON.parse(encodeTypeDef({
JSON.parse(encodeTypeDef(registry, {
info: TypeDefInfo.Struct,
sub: [
{
@@ -47,7 +50,7 @@ describe('encodeTypeDef', (): void => {
it('correctly encodes a complex struct (named)', (): void => {
expect(
JSON.parse(encodeTypeDef({
JSON.parse(encodeTypeDef(registry, {
info: TypeDefInfo.Struct,
sub: [
{
@@ -88,7 +91,7 @@ describe('encodeTypeDef', (): void => {
it('correctly encodes a complex enum', (): void => {
expect(
JSON.parse(encodeTypeDef({
JSON.parse(encodeTypeDef(registry, {
info: TypeDefInfo.Enum,
sub: [
{
@@ -148,7 +151,7 @@ describe('encodeTypeDef', (): void => {
it('correctly encodes a complex enum (named)', (): void => {
expect(
JSON.parse(encodeTypeDef({
JSON.parse(encodeTypeDef(registry, {
info: TypeDefInfo.Enum,
sub: [
{
+81 -41
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Registry } from '../types/registry';
import type { TypeDef } from './types';
import { assert, isNumber, isUndefined, stringify } from '@polkadot/util';
@@ -19,7 +20,7 @@ export function paramsNotation <T> (outer: string, inner?: T | T[], transform: (
}`;
}
function encodeWithParams (typeDef: TypeDef, outer: string): string {
function encodeWithParams (registry: Registry, typeDef: TypeDef, outer: string): string {
const { info, sub } = typeDef;
switch (info) {
@@ -31,25 +32,26 @@ function encodeWithParams (typeDef: TypeDef, outer: string): string {
case TypeDefInfo.Option:
case TypeDefInfo.Result:
case TypeDefInfo.Vec:
return paramsNotation(outer, sub, (param) => encodeTypeDef(param));
return paramsNotation(outer, sub, (param) => encodeTypeDef(registry, param));
}
throw new Error(`Unable to encode ${stringify(typeDef)} with params`);
}
function encodeDoNotConstruct ({ displayName }: TypeDef): string {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function encodeDoNotConstruct (registry: Registry, { displayName }: TypeDef): string {
return `DoNotConstruct<${displayName || 'Unknown'}>`;
}
function encodeSubTypes (sub: TypeDef[], asEnum?: boolean): string {
function encodeSubTypes (registry: Registry, sub: TypeDef[], asEnum?: boolean, extra?: Record<string, unknown>): string {
const names = sub.map(({ name }) => name);
assert(names.every((n) => !!n), () => `Subtypes does not have consistent names, ${names.join(', ')}`);
const inner = sub.reduce< Record<string, string>>((result, type) => ({
...result,
[type.name as string]: encodeTypeDef(type)
}), {});
[type.name as string]: encodeTypeDef(registry, type)
}), { ...(extra as Record<string, string>) });
return stringify(
asEnum
@@ -58,7 +60,7 @@ function encodeSubTypes (sub: TypeDef[], asEnum?: boolean): string {
);
}
function encodeEnum (typeDef: TypeDef): string {
function encodeEnum (registry: Registry, typeDef: TypeDef): string {
assert(typeDef.sub && Array.isArray(typeDef.sub), 'Unable to encode Enum type');
const sub = typeDef.sub;
@@ -67,28 +69,38 @@ function encodeEnum (typeDef: TypeDef): string {
// TODO We need to take the disciminant into account and auto-add empty entries
return sub.every(({ type }) => type === 'Null')
? stringify({ _enum: sub.map(({ name }, index) => `${name || `Empty${index}`}`) })
: encodeSubTypes(sub, true);
: encodeSubTypes(registry, sub, true);
}
function encodeStruct (typeDef: TypeDef): string {
function encodeStruct (registry: Registry, typeDef: TypeDef): string {
assert(typeDef.sub && Array.isArray(typeDef.sub), 'Unable to encode Struct type');
return encodeSubTypes(typeDef.sub);
return encodeSubTypes(registry, typeDef.sub, false, {
...(
typeDef.alias
? { alias: [...typeDef.alias.entries()].reduce<Record<string, string>>((all, [k, v]) => ({
...all,
[k]: v
}), {}) }
: {}
)
});
}
function encodeTuple (typeDef: TypeDef): string {
function encodeTuple (registry: Registry, typeDef: TypeDef): string {
assert(typeDef.sub && Array.isArray(typeDef.sub), 'Unable to encode Tuple type');
return `(${typeDef.sub.map((type) => encodeTypeDef(type)).join(', ')})`;
return `(${typeDef.sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
}
function encodeUInt ({ length }: TypeDef, type: 'Int' | 'UInt'): string {
function encodeUInt (registry: Registry, { length }: TypeDef, type: 'Int' | 'UInt'): string {
assert(isNumber(length), 'Unable to encode VecFixed type');
return `${type}<${length}>`;
}
function encodeVecFixed ({ length, sub }: TypeDef): string {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function encodeVecFixed (registry: Registry, { length, sub }: TypeDef): string {
assert(isNumber(length) && !isUndefined(sub) && !Array.isArray(sub), 'Unable to encode VecFixed type');
return `[${sub.type};${length}]`;
@@ -96,38 +108,61 @@ function encodeVecFixed ({ length, sub }: TypeDef): string {
// We setup a record here to ensure we have comprehensive coverage (any item not covered will result
// in a compile-time error with the missing index)
const encoders: Record<TypeDefInfo, (typeDef: TypeDef) => string> = {
[TypeDefInfo.BTreeMap]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'BTreeMap'),
[TypeDefInfo.BTreeSet]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'BTreeSet'),
[TypeDefInfo.Compact]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'Compact'),
[TypeDefInfo.DoNotConstruct]: (typeDef: TypeDef): string => encodeDoNotConstruct(typeDef),
[TypeDefInfo.Enum]: (typeDef: TypeDef): string => encodeEnum(typeDef),
[TypeDefInfo.HashMap]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'HashMap'),
[TypeDefInfo.Int]: (typeDef: TypeDef): string => encodeUInt(typeDef, 'Int'),
[TypeDefInfo.Linkage]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'Linkage'),
const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => string> = {
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'BTreeMap'),
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'BTreeSet'),
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'Compact'),
[TypeDefInfo.DoNotConstruct]: (registry: Registry, typeDef: TypeDef) =>
encodeDoNotConstruct(registry, typeDef),
[TypeDefInfo.Enum]: (registry: Registry, typeDef: TypeDef) =>
encodeEnum(registry, typeDef),
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'HashMap'),
[TypeDefInfo.Int]: (registry: Registry, typeDef: TypeDef) =>
encodeUInt(registry, typeDef, 'Int'),
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'Linkage'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
[TypeDefInfo.Null]: (typeDef: TypeDef): string => 'Null',
[TypeDefInfo.Option]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'Option'),
[TypeDefInfo.Plain]: (typeDef: TypeDef): string => typeDef.displayName || typeDef.type,
[TypeDefInfo.Result]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'Result'),
[TypeDefInfo.Set]: (typeDef: TypeDef): string => typeDef.type,
[TypeDefInfo.Struct]: (typeDef: TypeDef): string => encodeStruct(typeDef),
[TypeDefInfo.Tuple]: (typeDef: TypeDef): string => encodeTuple(typeDef),
[TypeDefInfo.UInt]: (typeDef: TypeDef): string => encodeUInt(typeDef, 'UInt'),
[TypeDefInfo.Vec]: (typeDef: TypeDef): string => encodeWithParams(typeDef, 'Vec'),
[TypeDefInfo.VecFixed]: (typeDef: TypeDef): string => encodeVecFixed(typeDef)
[TypeDefInfo.Null]: (registry: Registry, typeDef: TypeDef) =>
'Null',
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'Option'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef) =>
typeDef.displayName || typeDef.type,
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'Result'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef) =>
typeDef.type,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
[TypeDefInfo.Si]: (registry: Registry, typeDef: TypeDef) =>
typeDef.lookupName || typeDef.type,
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef) =>
encodeStruct(registry, typeDef),
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef) =>
encodeTuple(registry, typeDef),
[TypeDefInfo.UInt]: (registry: Registry, typeDef: TypeDef) =>
encodeUInt(registry, typeDef, 'UInt'),
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'Vec'),
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef) =>
encodeVecFixed(registry, typeDef)
};
function encodeType (typeDef: TypeDef): string {
function encodeType (registry: Registry, typeDef: TypeDef): string {
const encoder = encoders[typeDef.info];
assert(encoder, () => `Cannot encode type: ${stringify(typeDef)}`);
assert(encoder, () => `Cannot encode type ${stringify(typeDef)}`);
return encoder(typeDef);
return typeDef.lookupName || encoder(registry, typeDef);
}
export function encodeTypeDef (typeDef: TypeDef): string {
assert(!isUndefined(typeDef.info), () => `Invalid type definition with no instance info, ${stringify(typeDef)}`);
export function encodeTypeDef (registry: Registry, typeDef: TypeDef): string {
assert(!isUndefined(typeDef.info), () => `Invalid type definition with no instance info, typeDef=${stringify(typeDef)}`);
// In the case of contracts we do have the unfortunate situation where the displayName would
// refer to "Option" when it is an option. For these, string it out, only using when actually
@@ -136,12 +171,17 @@ export function encodeTypeDef (typeDef: TypeDef): string {
return typeDef.displayName;
}
return encodeType(typeDef);
return encodeType(registry, typeDef);
}
export function withTypeString (typeDef: Omit<TypeDef, 'type'>): TypeDef {
export function withTypeString (registry: Registry, typeDef: Omit<TypeDef, 'type'>): TypeDef {
const partial = { ...typeDef } as TypeDef;
// for the outer-most type, we ignore the lookupName
delete partial.lookupName;
return {
...typeDef,
type: encodeType(typeDef as TypeDef)
type: encodeType(registry, partial)
};
}
+43 -5
View File
@@ -4,8 +4,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, CodecHash, DispatchErrorModule, Hash } from '../interfaces/types';
import type { ChainProperties, CodecHash, DispatchErrorModule, Hash, MetadataLatest, PortableRegistry, SiLookupTypeId } from '../interfaces/types';
import type { CallFunction, Codec, CodecHasher, Constructor, InterfaceTypes, 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';
import { blake2AsU8a } from '@polkadot/util-crypto';
@@ -20,7 +21,7 @@ import * as definitions from '../interfaces/definitions';
import { decorateConstants, decorateExtrinsics } from '../metadata/decorate';
import { Metadata } from '../metadata/Metadata';
import { createClass, getTypeClass } from './createClass';
import { createType } from './createType';
import { createTypeUnsafe } from './createType';
import { getTypeDef } from './getTypeDef';
const l = logger('registry');
@@ -34,11 +35,11 @@ function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<s
const sectionIndex = metadata.version >= 12 ? section.index.toNumber() : _sectionIndex;
const sectionName = stringCamelCase(section.name);
section.errors.forEach(({ documentation, name }, index): void => {
section.errors.forEach(({ docs, name }, index): void => {
const eventIndex = new Uint8Array([sectionIndex, index]);
metadataErrors[u8aToHex(eventIndex)] = {
documentation: documentation.map((d) => d.toString()),
docs: docs.map((d) => d.toString()),
index,
method: name.toString(),
name: name.toString(),
@@ -114,6 +115,8 @@ export class TypeRegistry implements Registry {
#definitions = new Map<string, string>();
#metadata?: MetadataLatest;
readonly #metadataCalls: Record<string, CallFunction> = {};
readonly #metadataErrors: Record<string, RegistryError> = {};
@@ -195,10 +198,36 @@ export class TypeRegistry implements Registry {
return [formatBalance.getDefaults().unit];
}
/**
* @description Returns tru if the type is in a Compat format
*/
public isLookupType (value: string): boolean {
return /Lookup\d+$/.test(value);
}
/**
* @description Creates a lookup string from the supplied id
*/
public createLookupType (lookupId: SiLookupTypeId | number): string {
return `Lookup${lookupId.toString()}`;
}
public get knownTypes (): RegisteredTypes {
return this.#knownTypes;
}
public get lookup (): PortableRegistry {
throw new Error('Unimplemented');
// return this.metadata.lookup;
}
public get metadata (): MetadataLatest {
assert(this.#metadata, 'Metadata has not been set on this registry');
return this.#metadata;
}
public get unknownTypes (): string[] {
return [...this.#unknownTypes.keys()];
}
@@ -219,7 +248,14 @@ export class TypeRegistry implements Registry {
* @description Creates an instance of a type as registered
*/
public createType <K extends keyof InterfaceTypes> (type: K, ...params: unknown[]): InterfaceTypes[K] {
return createType(this, type, ...params);
return createTypeUnsafe(this, type, params);
}
/**
* @description Creates an instance of a type as registered
*/
public createTypeUnsafe <T extends Codec = Codec, K extends string = string> (type: K, params: unknown[], options?: CreateOptions): T {
return createTypeUnsafe(this, type, params, options);
}
// find a specific call
@@ -388,6 +424,8 @@ export class TypeRegistry implements Registry {
// sets the metadata
public setMetadata (metadata: Metadata, signedExtensions?: string[], userExtensions?: ExtDef): void {
this.#metadata = metadata.asLatest;
injectExtrinsics(this, metadata, this.#metadataCalls);
injectErrors(this, metadata, this.#metadataErrors);
injectEvents(this, metadata, this.#metadataEvents);
+11
View File
@@ -26,6 +26,7 @@ export enum TypeDefInfo {
Int,
UInt,
DoNotConstruct,
Si,
// anything not fully supported (keep this as the last entry)
Null
}
@@ -33,12 +34,22 @@ export enum TypeDefInfo {
export interface TypeDef {
alias?: Map<string, string>;
displayName?: string;
docs?: string[];
fallbackType?: string;
info: TypeDefInfo;
index?: number;
isFromSi?: boolean;
length?: number;
lookupIndex?: number;
lookupName?: string;
name?: string;
namespace?: string;
sub?: TypeDef | TypeDef[];
type: string;
}
export interface CreateOptions {
blockHash?: Uint8Array | string | null;
isOptional?: boolean;
isPedantic?: boolean;
}
+1 -1
View File
@@ -235,7 +235,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
method: call?.method,
section: call?.section,
...(isExpanded && call
? { documentation: call.meta.documentation.map((d) => d.toString()) }
? { docs: call.meta.docs.map((d) => d.toString()) }
: {}
)
};
+1 -1
View File
@@ -156,7 +156,7 @@ export class GenericEvent extends Struct implements IEvent<Codec[]> {
method: this.method,
section: this.section,
...(isExpanded
? { documentation: this.meta.documentation.map((d) => d.toString()) }
? { docs: this.meta.docs.map((d) => d.toString()) }
: {}
),
...super.toHuman(isExpanded)
@@ -0,0 +1,431 @@
// 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, SiType, SiTypeDefArray, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '../interfaces/scaleInfo';
import type { Type } from '../primitive/Type';
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';
// Alias the primitive enum with out known values
const PRIMITIVE_ALIAS: Record<string, string> = {
Char: 'u32', // Rust char is 4-bytes
Str: 'Text'
};
// ink! specific overrides
const PRIMITIVE_INK = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
// These are types where we have a specific decoding/encoding override + helpers
const PRIMITIVE_SP = [
'sp_core::crypto::AccountId32',
'sp_runtime::generic::era::Era',
'sp_runtime::multiaddress::MultiAddress',
'pallet_democracy::vote::Vote',
'pallet_identity::types::Data',
'primitive_types::H160',
'primitive_types::H256',
'primitive_types::H512'
];
// These we never use these as top-level names, they are wrappers
const WRAPPERS = ['Box', 'BTreeMap', 'Cow', 'Result', 'Option'];
// These are reserved and conflicts with built-in Codec definitions
const RESERVED = ['entries', 'hash', 'keys', 'size'];
function removeDuplicateNames (names: (string | null)[]): (string | null)[] {
return names.map((name, index): string | null =>
!name || names.some((o, i) => index !== i && name === o)
? null
: name
);
}
function extractNames (types: PortableType[]): Record<number, string> {
return removeDuplicateNames(
types.map(({ type: { path } }): string | null => {
if (!path.length) {
return null;
}
const parts = path.map((p) => stringUpperFirst(stringCamelCase(p)));
if (parts.length >= 2 && parts[parts.length - 1] === parts[parts.length - 2]) {
parts.pop();
}
const typeName = parts.join('');
return WRAPPERS.includes(typeName) || ['frame_support'].includes(path[0].toString())
? null
: typeName;
})
).reduce<Record<number, string>>((all, name, index) => {
if (name) {
all[index] = name;
}
return all;
}, {});
}
export class GenericPortableRegistry extends Struct {
#names: Record<number, string>;
#typeDefs: Record<number, TypeDef> = {};
constructor (registry: Registry, value?: Uint8Array) {
super(registry, {
types: 'Vec<PortableType>'
}, value);
this.#names = extractNames(this.types);
}
/**
* @description The types of the registry
*/
public get types (): Vec<PortableType> {
return this.get('types') as Vec<PortableType>;
}
/**
* @description Finds a specific type in the registry
*/
public getSiType (lookupId: SiLookupTypeId | string | number): SiType {
const found = this.types[this.#getLookupId(lookupId)];
assert(found, () => `PortableRegistry: Unable to find type with lookupId ${lookupId.toString()}`);
return found.type;
}
/**
* @description Lookup the type definition for the index
*/
public getTypeDef (lookupId: SiLookupTypeId | string | number): TypeDef {
const lookupIndex = this.#getLookupId(lookupId);
if (!this.#typeDefs[lookupIndex]) {
// we set first since we will get into circular lookups along the way
this.#typeDefs[lookupIndex] = {
info: TypeDefInfo.DoNotConstruct,
lookupIndex,
lookupName: this.#names[lookupIndex],
type: this.registry.createLookupType(lookupIndex)
};
const extracted = this.#extract(this.getSiType(lookupId), lookupIndex);
Object.keys(extracted).forEach((key): void => {
// these are safe since we are looking through the keys as set
this.#typeDefs[lookupIndex][key as 'info'] = extracted[key as 'info'];
});
}
return this.#typeDefs[lookupIndex];
}
#createSiDef (lookupId: SiLookupTypeId): TypeDef {
const typeDef = this.getTypeDef(lookupId);
const lookupIndex = lookupId.toNumber();
// Setup for a lookup on complex types
return [TypeDefInfo.Enum, TypeDefInfo.Struct].includes(typeDef.info)
? {
docs: typeDef.docs,
info: TypeDefInfo.Si,
lookupIndex,
lookupName: this.#names[lookupIndex],
type: this.registry.createLookupType(lookupId)
}
: typeDef;
}
#getLookupId (lookupId: SiLookupTypeId | string | number): number {
if (isString(lookupId)) {
assert(this.registry.isLookupType(lookupId), () => `PortableRegistry: Expected a lookup string type, found ${lookupId}`);
return parseInt(lookupId.replace('Lookup', ''), 10);
} else if (isNumber(lookupId)) {
return lookupId;
}
return lookupId.toNumber();
}
#extract (type: SiType, lookupIndex: number): TypeDef {
const path = [...type.path];
// We handle ink! here as well, although we still have a different registry there
const isPrimitivePath = !!path.length && (
(
path.length > 2 &&
path[0].eq('ink_env') &&
path[1].eq('types')
) ||
PRIMITIVE_INK.includes(path[path.length - 1].toString()) ||
PRIMITIVE_SP.includes(path.join('::'))
);
let typeDef: TypeDef;
try {
if (isPrimitivePath) {
typeDef = this.#extractPrimitivePath(lookupIndex, type);
} else if (type.def.isArray) {
typeDef = this.#extractArray(lookupIndex, type.def.asArray);
} else if (type.def.isCompact) {
typeDef = this.#extractCompact(lookupIndex, type.def.asCompact);
} else if (type.def.isComposite) {
typeDef = this.#extractComposite(lookupIndex, type, type.def.asComposite);
} else if (type.def.isHistoricMetaCompat) {
typeDef = this.#extractHistoric(lookupIndex, type.def.asHistoricMetaCompat);
} else if (type.def.isPrimitive) {
typeDef = this.#extractPrimitive(lookupIndex, type);
} else if (type.def.isSequence) {
typeDef = this.#extractSequence(lookupIndex, type.def.asSequence);
} else if (type.def.isTuple) {
typeDef = this.#extractTuple(lookupIndex, type.def.asTuple);
} else if (type.def.isVariant) {
typeDef = this.#extractVariant(lookupIndex, type, type.def.asVariant);
} else {
throw new Error(`Invalid type at index ${lookupIndex}: No handler for ${type.def.toString()}`);
}
} catch (error) {
throw new Error(`PortableRegistry: Error extracting ${stringify(type)}: ${(error as Error).message}`);
}
return {
docs: type.docs.map((d) => d.toString()),
namespace: path.join('::'),
...typeDef
};
}
#extractArray (_: number, { len: length, type }: SiTypeDefArray): TypeDef {
assert(!length || length.toNumber() <= 256, 'PortableRegistry: Only support for [Type; <length>], where length <= 256');
return withTypeString(this.registry, {
info: TypeDefInfo.VecFixed,
length: length.toNumber(),
sub: this.#createSiDef(type)
});
}
#extractCompact (_: number, { type }: SiTypeDefCompact): TypeDef {
return withTypeString(this.registry, {
info: TypeDefInfo.Compact,
sub: this.#createSiDef(type)
});
}
#extractComposite (lookupIndex: number, { params, path }: SiType, { fields }: SiTypeDefComposite): TypeDef {
if (path.length === 1 && path[0].eq('BTreeMap')) {
return withTypeString(this.registry, {
info: TypeDefInfo.BTreeMap,
sub: params.map(({ type }) => this.#createSiDef(type.unwrap()))
});
}
return this.#extractFields(lookupIndex, fields);
}
#extractFields (lookupIndex: number, fields: SiField[]): TypeDef {
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
isAllNamed && name.isSome,
isAllUnnamed && name.isNone
]),
[true, true]);
assert(isTuple || isStruct, 'PortableRegistry: Invalid fields type detected, expected either Tuple or Struct');
if (fields.length === 0) {
return {
info: TypeDefInfo.Null,
type: 'Null'
};
} else if (isTuple && fields.length === 1) {
return this.#createSiDef(fields[0].type);
}
const [sub, alias] = this.#extractFieldsAlias(fields);
return withTypeString(this.registry, {
info: isTuple // Tuple check first
? TypeDefInfo.Tuple
: TypeDefInfo.Struct,
...(
lookupIndex === -1
? {}
: {
lookupIndex,
lookupName: this.#names[lookupIndex]
}
),
...(
alias.size
? { alias }
: {}
),
sub
});
}
#extractFieldsAlias (fields: SiField[]): [TypeDef[], Map<string, string>] {
const alias = new Map<string, string>();
const sub = fields.map(({ docs, name, type }) => {
const typeDef = this.#createSiDef(type);
if (name.isNone) {
return typeDef;
}
let nameField = stringCamelCase(name.unwrap());
let nameOrig: string | null = null;
if (nameField.includes('#')) {
nameOrig = nameField;
nameField = nameOrig.replace(/#/g, '_');
} else if (RESERVED.includes(nameField)) {
nameOrig = nameField;
nameField = `${nameField}_`;
}
if (nameOrig) {
alias.set(nameField, nameOrig);
}
return {
...typeDef,
docs: docs.map((d) => d.toString()),
name: nameField
};
});
return [sub, alias];
}
#extractHistoric (_: number, type: Type): TypeDef {
return {
...getTypeDef(type),
displayName: type.toString(),
isFromSi: true
};
}
#extractPrimitive (_: number, type: SiType): TypeDef {
const typeStr = type.def.asPrimitive.type.toString();
return {
info: TypeDefInfo.Plain,
type: PRIMITIVE_ALIAS[typeStr] || typeStr.toLowerCase()
};
}
#extractPrimitivePath (_: number, type: SiType): TypeDef {
const displayName = type.path[type.path.length - 1].toString();
return {
displayName,
info: TypeDefInfo.Plain,
type: displayName
};
}
#extractSequence (lookupIndex: number, { type }: SiTypeDefSequence): TypeDef {
const sub = this.#createSiDef(type);
return withTypeString(this.registry, {
info: TypeDefInfo.Vec,
lookupIndex,
lookupName: this.#names[lookupIndex],
sub
});
}
#extractTuple (lookupIndex: number, ids: SiTypeDefTuple): TypeDef {
if (ids.length === 0) {
return {
info: TypeDefInfo.Null,
type: 'Null'
};
} else if (ids.length === 1) {
return this.getTypeDef(ids[0]);
}
const sub = ids.map((type) => this.#createSiDef(type));
return withTypeString(this.registry, {
info: TypeDefInfo.Tuple,
lookupIndex,
lookupName: this.#names[lookupIndex],
sub
});
}
#extractVariant (lookupIndex: number, { params, path }: SiType, { variants }: SiTypeDefVariant): TypeDef {
const specialVariant = path[0].toString();
if (specialVariant === 'Option') {
return withTypeString(this.registry, {
info: TypeDefInfo.Option,
sub: this.#createSiDef(params[0].type.unwrap())
});
} else if (specialVariant === 'Result') {
return withTypeString(this.registry, {
info: TypeDefInfo.Result,
sub: params.map(({ type }) => this.#createSiDef(type.unwrap())).map((def, index) => ({
name: ['Ok', 'Error'][index],
...def
}))
});
} else if (variants.length === 0) {
return {
info: TypeDefInfo.Null,
type: 'Null'
};
}
return this.#extractVariantEnum(lookupIndex, variants);
}
#extractVariantEnum (lookupIndex: number, variants: SiVariant[]): TypeDef {
const sub: (TypeDef & { name: string })[] = [];
// we may get entries out of order, arrange them first before creating with gaps filled
variants
.sort((a, b) => a.index.cmp(b.index))
.forEach(({ fields, index, name }) => {
const desired = index.toNumber();
while (sub.length !== desired) {
sub.push({
index: sub.length,
info: TypeDefInfo.Null,
name: `Unused${sub.length}`,
type: 'Null'
});
}
sub.push({
...this.#extractFields(-1, fields),
index: index.toNumber(),
name: name.toString()
});
});
return withTypeString(this.registry, {
info: TypeDefInfo.Enum,
lookupIndex,
lookupName: this.#names[lookupIndex],
sub
});
}
}
+1
View File
@@ -12,4 +12,5 @@ export { GenericConsensusEngineId } from './ConsensusEngineId';
export { GenericEvent, GenericEventData } from './Event';
export { GenericLookupSource } from './LookupSource';
export { GenericMultiAddress, GenericMultiAddress as GenericAddress } from './MultiAddress';
export { GenericPortableRegistry } from './PortableRegistry';
export { GenericVote } from './Vote';
@@ -19,7 +19,7 @@ const layout = {
},
ContractLayoutCell: {
key: 'ContractLayoutKey',
ty: 'SiLookupTypeId'
ty: 'Si0LookupTypeId'
},
ContractLayoutEnum: {
dispatchKey: 'ContractLayoutKey',
@@ -67,7 +67,7 @@ const spec = {
events: 'Vec<ContractEventSpec>',
docs: 'Vec<Text>'
},
ContractDisplayName: 'SiPath',
ContractDisplayName: 'Si0Path',
ContractEventParamSpec: {
name: 'Text',
indexed: 'bool',
@@ -94,7 +94,7 @@ const spec = {
},
ContractSelector: '[u8; 4]',
ContractTypeSpec: {
type: 'SiLookupTypeId',
type: 'Si0LookupTypeId',
displayName: 'ContractDisplayName'
}
};
@@ -110,17 +110,21 @@ export default {
source: 'ContractProjectSource',
contract: 'ContractProjectContract',
// expanded scale registry: RegistryReadOnly
types: 'Vec<SiType>',
// NOTE Previous generation of the Si0Type definition
types: 'Vec<Si0Type>',
// renamed from layout (ignored for now, incomplete)
// storage: 'ContractStorageLayout',
spec: 'ContractContractSpec'
},
ContractProjectContract: {
_alias: {
docs: 'documentation'
},
name: 'Text',
version: 'Text',
authors: 'Vec<Text>',
description: 'Option<Text>',
documentation: 'Option<Text>',
docs: 'Option<Text>',
repository: 'Option<Text>',
homepage: 'Option<Text>',
license: 'Option<Text>'
@@ -2,7 +2,7 @@
/* eslint-disable */
import type { BTreeMap, Bytes, Enum, Option, Raw, Struct, Text, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { SiLookupTypeId, SiPath, SiType } from '@polkadot/types/interfaces/scaleInfo';
import type { Si0LookupTypeId, Si0Path, Si0Type } from '@polkadot/types/interfaces/scaleInfo';
/** @name ContractConstructorSpec */
export interface ContractConstructorSpec extends Struct {
@@ -31,7 +31,7 @@ export interface ContractCryptoHasher extends Enum {
export interface ContractDiscriminant extends u32 {}
/** @name ContractDisplayName */
export interface ContractDisplayName extends SiPath {}
export interface ContractDisplayName extends Si0Path {}
/** @name ContractEventParamSpec */
export interface ContractEventParamSpec extends Struct {
@@ -59,7 +59,7 @@ export interface ContractLayoutArray extends Struct {
/** @name ContractLayoutCell */
export interface ContractLayoutCell extends Struct {
readonly key: ContractLayoutKey;
readonly ty: SiLookupTypeId;
readonly ty: Si0LookupTypeId;
}
/** @name ContractLayoutEnum */
@@ -118,7 +118,7 @@ export interface ContractProject extends Struct {
readonly metadataVersion: Text;
readonly source: ContractProjectSource;
readonly contract: ContractProjectContract;
readonly types: Vec<SiType>;
readonly types: Vec<Si0Type>;
readonly spec: ContractContractSpec;
}
@@ -128,7 +128,7 @@ export interface ContractProjectContract extends Struct {
readonly version: Text;
readonly authors: Vec<Text>;
readonly description: Option<Text>;
readonly documentation: Option<Text>;
readonly docs: Option<Text>;
readonly repository: Option<Text>;
readonly homepage: Option<Text>;
readonly license: Option<Text>;
@@ -161,7 +161,7 @@ export interface ContractStorageLayout extends Enum {
/** @name ContractTypeSpec */
export interface ContractTypeSpec extends Struct {
readonly type: SiLookupTypeId;
readonly type: Si0LookupTypeId;
readonly displayName: ContractDisplayName;
}
@@ -6,307 +6,54 @@
import type { Definitions } from '../../types';
export const AllHashers = {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Blake2_128Concat: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null,
// new in v11
Identity: null
};
import { AllHashers } from './hashers';
import { v9 } from './v9';
import { v10 } from './v10';
import { v11 } from './v11';
import { v12 } from './v12';
import { v13 } from './v13';
import { v14 } from './v14';
export { AllHashers };
export default {
rpc: {},
types: {
// v9
DoubleMapTypeV9: {
hasher: 'StorageHasherV9',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV9'
},
ErrorMetadataV9: {
name: 'Text',
documentation: 'Vec<Text>'
},
EventMetadataV9: {
name: 'Text',
args: 'Vec<Type>',
documentation: 'Vec<Text>'
},
FunctionArgumentMetadataV9: {
name: 'Text',
type: 'Type'
},
FunctionMetadataV9: {
name: 'Text',
args: 'Vec<FunctionArgumentMetadataV9>',
documentation: 'Vec<Text>'
},
MapTypeV9: {
hasher: 'StorageHasherV9',
key: 'Type',
value: 'Type',
linked: 'bool'
},
MetadataV9: {
modules: 'Vec<ModuleMetadataV9>'
},
ModuleConstantMetadataV9: {
name: 'Text',
type: 'Type',
value: 'Bytes',
documentation: 'Vec<Text>'
},
ModuleMetadataV9: {
name: 'Text',
storage: 'Option<StorageMetadataV9>',
calls: 'Option<Vec<FunctionMetadataV9>>',
events: 'Option<Vec<EventMetadataV9>>',
constants: 'Vec<ModuleConstantMetadataV9>',
errors: 'Vec<ErrorMetadataV9>'
},
StorageEntryMetadataV9: {
name: 'Text',
modifier: 'StorageEntryModifierV9',
type: 'StorageEntryTypeV9',
fallback: 'Bytes',
documentation: 'Vec<Text>'
},
StorageEntryModifierV9: {
_enum: ['Optional', 'Default', 'Required']
},
StorageEntryTypeV9: {
_enum: {
Plain: 'Type',
Map: 'MapTypeV9',
DoubleMap: 'DoubleMapTypeV9'
}
},
StorageHasherV9: {
_enum: {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null
}
},
StorageMetadataV9: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV9>'
},
...v9,
...v10,
...v11,
...v12,
...v13,
...v14,
// v10
DoubleMapTypeV10: {
hasher: 'StorageHasherV10',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV10'
},
ErrorMetadataV10: 'ErrorMetadataV9',
EventMetadataV10: 'EventMetadataV9',
FunctionArgumentMetadataV10: 'FunctionArgumentMetadataV9',
FunctionMetadataV10: 'FunctionMetadataV9',
MapTypeV10: {
hasher: 'StorageHasherV10',
key: 'Type',
value: 'Type',
linked: 'bool'
},
MetadataV10: {
modules: 'Vec<ModuleMetadataV10>'
},
ModuleConstantMetadataV10: 'ModuleConstantMetadataV9',
ModuleMetadataV10: {
name: 'Text',
storage: 'Option<StorageMetadataV10>',
calls: 'Option<Vec<FunctionMetadataV10>>',
events: 'Option<Vec<EventMetadataV10>>',
constants: 'Vec<ModuleConstantMetadataV10>',
errors: 'Vec<ErrorMetadataV10>'
},
StorageEntryModifierV10: 'StorageEntryModifierV9',
StorageEntryMetadataV10: {
name: 'Text',
modifier: 'StorageEntryModifierV10',
type: 'StorageEntryTypeV10',
fallback: 'Bytes',
documentation: 'Vec<Text>'
},
StorageEntryTypeV10: {
_enum: {
Plain: 'Type',
Map: 'MapTypeV10',
DoubleMap: 'DoubleMapTypeV10'
}
},
StorageMetadataV10: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV10>'
},
StorageHasherV10: {
_enum: {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Blake2_128Concat: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null
}
},
// v11
DoubleMapTypeV11: {
hasher: 'StorageHasherV11',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV11'
},
ErrorMetadataV11: 'ErrorMetadataV10',
EventMetadataV11: 'EventMetadataV10',
ExtrinsicMetadataV11: {
version: 'u8',
signedExtensions: 'Vec<Text>'
},
FunctionArgumentMetadataV11: 'FunctionArgumentMetadataV10',
FunctionMetadataV11: 'FunctionMetadataV10',
MapTypeV11: {
hasher: 'StorageHasherV11',
key: 'Type',
value: 'Type',
linked: 'bool'
},
MetadataV11: {
modules: 'Vec<ModuleMetadataV11>',
extrinsic: 'ExtrinsicMetadataV11'
},
ModuleConstantMetadataV11: 'ModuleConstantMetadataV10',
ModuleMetadataV11: {
name: 'Text',
storage: 'Option<StorageMetadataV11>',
calls: 'Option<Vec<FunctionMetadataV11>>',
events: 'Option<Vec<EventMetadataV11>>',
constants: 'Vec<ModuleConstantMetadataV11>',
errors: 'Vec<ErrorMetadataV11>'
},
StorageEntryModifierV11: 'StorageEntryModifierV10',
StorageEntryMetadataV11: {
name: 'Text',
modifier: 'StorageEntryModifierV11',
type: 'StorageEntryTypeV11',
fallback: 'Bytes',
documentation: 'Vec<Text>'
},
StorageEntryTypeV11: {
_enum: {
Plain: 'Type',
Map: 'MapTypeV11',
DoubleMap: 'DoubleMapTypeV11'
}
},
StorageMetadataV11: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV11>'
},
StorageHasherV11: {
_enum: AllHashers
},
// v12
DoubleMapTypeV12: 'DoubleMapTypeV11',
ErrorMetadataV12: 'ErrorMetadataV11',
EventMetadataV12: 'EventMetadataV11',
ExtrinsicMetadataV12: 'ExtrinsicMetadataV11',
FunctionArgumentMetadataV12: 'FunctionArgumentMetadataV11',
FunctionMetadataV12: 'FunctionMetadataV11',
MapTypeV12: 'MapTypeV11',
MetadataV12: {
modules: 'Vec<ModuleMetadataV12>',
extrinsic: 'ExtrinsicMetadataV12'
},
ModuleConstantMetadataV12: 'ModuleConstantMetadataV11',
ModuleMetadataV12: {
name: 'Text',
storage: 'Option<StorageMetadataV12>',
calls: 'Option<Vec<FunctionMetadataV12>>',
events: 'Option<Vec<EventMetadataV12>>',
constants: 'Vec<ModuleConstantMetadataV12>',
errors: 'Vec<ErrorMetadataV12>',
index: 'u8'
},
StorageEntryModifierV12: 'StorageEntryModifierV11',
StorageEntryMetadataV12: 'StorageEntryMetadataV11',
StorageEntryTypeV12: 'StorageEntryTypeV11',
StorageMetadataV12: 'StorageMetadataV11',
StorageHasherV12: 'StorageHasherV11',
// v13
DoubleMapTypeV13: 'DoubleMapTypeV12',
ErrorMetadataV13: 'ErrorMetadataV12',
EventMetadataV13: 'EventMetadataV12',
ExtrinsicMetadataV13: 'ExtrinsicMetadataV12',
FunctionArgumentMetadataV13: 'FunctionArgumentMetadataV12',
FunctionMetadataV13: 'FunctionMetadataV12',
MapTypeV13: 'MapTypeV12',
MetadataV13: {
modules: 'Vec<ModuleMetadataV13>',
extrinsic: 'ExtrinsicMetadataV13'
},
ModuleConstantMetadataV13: 'ModuleConstantMetadataV12',
ModuleMetadataV13: {
name: 'Text',
storage: 'Option<StorageMetadataV13>',
calls: 'Option<Vec<FunctionMetadataV13>>',
events: 'Option<Vec<EventMetadataV13>>',
constants: 'Vec<ModuleConstantMetadataV13>',
errors: 'Vec<ErrorMetadataV13>',
index: 'u8'
},
NMapTypeV13: {
keyVec: 'Vec<Type>',
hashers: 'Vec<StorageHasherV13>',
value: 'Type'
},
StorageEntryModifierV13: 'StorageEntryModifierV12',
StorageEntryMetadataV13: {
name: 'Text',
modifier: 'StorageEntryModifierV13',
type: 'StorageEntryTypeV13',
fallback: 'Bytes',
documentation: 'Vec<Text>'
},
StorageEntryTypeV13: {
_enum: {
Plain: 'Type',
Map: 'MapTypeV13',
DoubleMap: 'DoubleMapTypeV13',
NMap: 'NMapTypeV13'
}
},
StorageMetadataV13: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV13>'
},
StorageHasherV13: 'StorageHasherV12',
//
// will be available once v14 is the default
// TODO: Comment out all commented stuff below and remove block below
//
// ExtrinsicMetadataLatest: 'ExtrinsicMetadataV14',
// FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV13',
// FunctionMetadataLatest: 'FunctionMetadataV14',
// MetadataLatest: 'MetadataV14',
PalletCallMetadataLatest: 'PalletCallMetadataV14',
PalletConstantMetadataLatest: 'PalletConstantMetadataV14',
PalletErrorMetadataLatest: 'PalletErrorMetadataV14',
PalletEventMetadataLatest: 'PalletEventMetadataV14',
PalletMetadataLatest: 'PalletMetadataV14',
PalletStorageMetadataLatest: 'PalletStorageMetadataV14',
SignedExtensionMetadataLatest: 'SignedExtensionMetadataV14',
// StorageEntryMetadataLatest: 'StorageEntryMetadataV14',
// StorageEntryModifierLatest: 'StorageEntryModifierV14',
// StorageEntryTypeLatest: 'StorageEntryTypeV14',
// This always maps to the latest
DoubleMapTypeLatest: 'DoubleMapTypeV13',
ErrorMetadataLatest: 'ErrorMetadataV13',
EventMetadataLatest: 'EventMetadataV13',
ExtrinsicMetadataLatest: 'ExtrinsicMetadataV13',
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV13',
FunctionMetadataLatest: 'FunctionMetadataV13',
MapTypeLatest: 'MapTypeV13',
MetadataLatest: 'MetadataV13',
ModuleConstantMetadataLatest: 'ModuleConstantMetadataV13',
ModuleMetadataLatest: 'ModuleMetadataV13',
NMapTypeLatest: 'NMapTypeV13',
StorageEntryMetadataLatest: 'StorageEntryMetadataV13',
StorageEntryModifierLatest: 'StorageEntryModifierV13',
StorageEntryTypeLatest: 'StorageEntryTypeV13',
@@ -330,7 +77,8 @@ export default {
V10: 'MetadataV10',
V11: 'MetadataV11',
V12: 'MetadataV12',
V13: 'MetadataV13'
V13: 'MetadataV13',
V14: 'MetadataV14'
}
}
}
@@ -0,0 +1,16 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
export const AllHashers = {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Blake2_128Concat: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null,
// new in v11
Identity: null
};
+136 -94
View File
@@ -1,43 +1,8 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Bytes, Enum, Option, Struct, Text, Type, Vec, bool, u8 } from '@polkadot/types';
/** @name DoubleMapTypeLatest */
export interface DoubleMapTypeLatest extends DoubleMapTypeV13 {}
/** @name DoubleMapTypeV10 */
export interface DoubleMapTypeV10 extends Struct {
readonly hasher: StorageHasherV10;
readonly key1: Type;
readonly key2: Type;
readonly value: Type;
readonly key2Hasher: StorageHasherV10;
}
/** @name DoubleMapTypeV11 */
export interface DoubleMapTypeV11 extends Struct {
readonly hasher: StorageHasherV11;
readonly key1: Type;
readonly key2: Type;
readonly value: Type;
readonly key2Hasher: StorageHasherV11;
}
/** @name DoubleMapTypeV12 */
export interface DoubleMapTypeV12 extends DoubleMapTypeV11 {}
/** @name DoubleMapTypeV13 */
export interface DoubleMapTypeV13 extends DoubleMapTypeV12 {}
/** @name DoubleMapTypeV9 */
export interface DoubleMapTypeV9 extends Struct {
readonly hasher: StorageHasherV9;
readonly key1: Type;
readonly key2: Type;
readonly value: Type;
readonly key2Hasher: StorageHasherV9;
}
import type { Bytes, Enum, GenericPortableRegistry, Option, Struct, Text, Type, Vec, bool, u8 } from '@polkadot/types';
import type { SiLookupTypeId, SiType } from '@polkadot/types/interfaces/scaleInfo';
/** @name ErrorMetadataLatest */
export interface ErrorMetadataLatest extends ErrorMetadataV13 {}
@@ -57,7 +22,7 @@ export interface ErrorMetadataV13 extends ErrorMetadataV12 {}
/** @name ErrorMetadataV9 */
export interface ErrorMetadataV9 extends Struct {
readonly name: Text;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name EventMetadataLatest */
@@ -79,7 +44,7 @@ export interface EventMetadataV13 extends EventMetadataV12 {}
export interface EventMetadataV9 extends Struct {
readonly name: Text;
readonly args: Vec<Type>;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name ExtrinsicMetadataLatest */
@@ -97,6 +62,13 @@ export interface ExtrinsicMetadataV12 extends ExtrinsicMetadataV11 {}
/** @name ExtrinsicMetadataV13 */
export interface ExtrinsicMetadataV13 extends ExtrinsicMetadataV12 {}
/** @name ExtrinsicMetadataV14 */
export interface ExtrinsicMetadataV14 extends Struct {
readonly type: SiLookupTypeId;
readonly version: u8;
readonly signedExtensions: Vec<SignedExtensionMetadataV14>;
}
/** @name FunctionArgumentMetadataLatest */
export interface FunctionArgumentMetadataLatest extends FunctionArgumentMetadataV13 {}
@@ -137,40 +109,7 @@ export interface FunctionMetadataV13 extends FunctionMetadataV12 {}
export interface FunctionMetadataV9 extends Struct {
readonly name: Text;
readonly args: Vec<FunctionArgumentMetadataV9>;
readonly documentation: Vec<Text>;
}
/** @name MapTypeLatest */
export interface MapTypeLatest extends MapTypeV13 {}
/** @name MapTypeV10 */
export interface MapTypeV10 extends Struct {
readonly hasher: StorageHasherV10;
readonly key: Type;
readonly value: Type;
readonly linked: bool;
}
/** @name MapTypeV11 */
export interface MapTypeV11 extends Struct {
readonly hasher: StorageHasherV11;
readonly key: Type;
readonly value: Type;
readonly linked: bool;
}
/** @name MapTypeV12 */
export interface MapTypeV12 extends MapTypeV11 {}
/** @name MapTypeV13 */
export interface MapTypeV13 extends MapTypeV12 {}
/** @name MapTypeV9 */
export interface MapTypeV9 extends Struct {
readonly hasher: StorageHasherV9;
readonly key: Type;
readonly value: Type;
readonly linked: bool;
readonly docs: Vec<Text>;
}
/** @name MetadataAll */
@@ -185,6 +124,8 @@ export interface MetadataAll extends Enum {
readonly asV12: MetadataV12;
readonly isV13: boolean;
readonly asV13: MetadataV13;
readonly isV14: boolean;
readonly asV14: MetadataV14;
}
/** @name MetadataLatest */
@@ -213,6 +154,13 @@ export interface MetadataV13 extends Struct {
readonly extrinsic: ExtrinsicMetadataV13;
}
/** @name MetadataV14 */
export interface MetadataV14 extends Struct {
readonly lookup: PortableRegistry;
readonly pallets: Vec<PalletMetadataV14>;
readonly extrinsic: ExtrinsicMetadataV14;
}
/** @name MetadataV9 */
export interface MetadataV9 extends Struct {
readonly modules: Vec<ModuleMetadataV9>;
@@ -238,7 +186,7 @@ export interface ModuleConstantMetadataV9 extends Struct {
readonly name: Text;
readonly type: Type;
readonly value: Bytes;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name ModuleMetadataLatest */
@@ -296,14 +244,81 @@ export interface ModuleMetadataV9 extends Struct {
readonly errors: Vec<ErrorMetadataV9>;
}
/** @name NMapTypeLatest */
export interface NMapTypeLatest extends NMapTypeV13 {}
/** @name PalletCallMetadataLatest */
export interface PalletCallMetadataLatest extends PalletCallMetadataV14 {}
/** @name NMapTypeV13 */
export interface NMapTypeV13 extends Struct {
readonly keyVec: Vec<Type>;
readonly hashers: Vec<StorageHasherV13>;
readonly value: Type;
/** @name PalletCallMetadataV14 */
export interface PalletCallMetadataV14 extends Struct {
readonly type: SiLookupTypeId;
}
/** @name PalletConstantMetadataLatest */
export interface PalletConstantMetadataLatest extends PalletConstantMetadataV14 {}
/** @name PalletConstantMetadataV14 */
export interface PalletConstantMetadataV14 extends Struct {
readonly name: Text;
readonly type: SiLookupTypeId;
readonly value: Bytes;
readonly docs: Vec<Text>;
}
/** @name PalletErrorMetadataLatest */
export interface PalletErrorMetadataLatest extends PalletErrorMetadataV14 {}
/** @name PalletErrorMetadataV14 */
export interface PalletErrorMetadataV14 extends Struct {
readonly type: SiLookupTypeId;
}
/** @name PalletEventMetadataLatest */
export interface PalletEventMetadataLatest extends PalletEventMetadataV14 {}
/** @name PalletEventMetadataV14 */
export interface PalletEventMetadataV14 extends Struct {
readonly type: SiLookupTypeId;
}
/** @name PalletMetadataLatest */
export interface PalletMetadataLatest extends PalletMetadataV14 {}
/** @name PalletMetadataV14 */
export interface PalletMetadataV14 extends Struct {
readonly name: Text;
readonly storage: Option<PalletStorageMetadataV14>;
readonly calls: Option<PalletCallMetadataV14>;
readonly events: Option<PalletEventMetadataV14>;
readonly constants: Vec<PalletConstantMetadataV14>;
readonly errors: Option<PalletErrorMetadataV14>;
readonly index: u8;
}
/** @name PalletStorageMetadataLatest */
export interface PalletStorageMetadataLatest extends PalletStorageMetadataV14 {}
/** @name PalletStorageMetadataV14 */
export interface PalletStorageMetadataV14 extends Struct {
readonly prefix: Text;
readonly items: Vec<StorageEntryMetadataV14>;
}
/** @name PortableRegistry */
export interface PortableRegistry extends GenericPortableRegistry {}
/** @name PortableType */
export interface PortableType extends Struct {
readonly id: SiLookupTypeId;
readonly type: SiType;
}
/** @name SignedExtensionMetadataLatest */
export interface SignedExtensionMetadataLatest extends SignedExtensionMetadataV14 {}
/** @name SignedExtensionMetadataV14 */
export interface SignedExtensionMetadataV14 extends Struct {
readonly identifier: Text;
readonly type: SiLookupTypeId;
readonly additionalSigned: SiLookupTypeId;
}
/** @name StorageEntryMetadataLatest */
@@ -315,7 +330,7 @@ export interface StorageEntryMetadataV10 extends Struct {
readonly modifier: StorageEntryModifierV10;
readonly type: StorageEntryTypeV10;
readonly fallback: Bytes;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name StorageEntryMetadataV11 */
@@ -324,7 +339,7 @@ export interface StorageEntryMetadataV11 extends Struct {
readonly modifier: StorageEntryModifierV11;
readonly type: StorageEntryTypeV11;
readonly fallback: Bytes;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name StorageEntryMetadataV12 */
@@ -336,7 +351,16 @@ export interface StorageEntryMetadataV13 extends Struct {
readonly modifier: StorageEntryModifierV13;
readonly type: StorageEntryTypeV13;
readonly fallback: Bytes;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name StorageEntryMetadataV14 */
export interface StorageEntryMetadataV14 extends Struct {
readonly name: Text;
readonly modifier: StorageEntryModifierV14;
readonly type: StorageEntryTypeV14;
readonly fallback: Bytes;
readonly docs: Vec<Text>;
}
/** @name StorageEntryMetadataV9 */
@@ -345,7 +369,7 @@ export interface StorageEntryMetadataV9 extends Struct {
readonly modifier: StorageEntryModifierV9;
readonly type: StorageEntryTypeV9;
readonly fallback: Bytes;
readonly documentation: Vec<Text>;
readonly docs: Vec<Text>;
}
/** @name StorageEntryModifierLatest */
@@ -363,6 +387,9 @@ export interface StorageEntryModifierV12 extends StorageEntryModifierV11 {}
/** @name StorageEntryModifierV13 */
export interface StorageEntryModifierV13 extends StorageEntryModifierV12 {}
/** @name StorageEntryModifierV14 */
export interface StorageEntryModifierV14 extends StorageEntryModifierV13 {}
/** @name StorageEntryModifierV9 */
export interface StorageEntryModifierV9 extends Enum {
readonly isOptional: boolean;
@@ -378,9 +405,9 @@ export interface StorageEntryTypeV10 extends Enum {
readonly isPlain: boolean;
readonly asPlain: Type;
readonly isMap: boolean;
readonly asMap: MapTypeV10;
readonly asMap: { hasher: StorageHasherV10; key: Type; value: Type; linked: bool; } & Struct;
readonly isDoubleMap: boolean;
readonly asDoubleMap: DoubleMapTypeV10;
readonly asDoubleMap: { hasher: StorageHasherV10; key1: Type; key2: Type; value: Type; key2Hasher: StorageHasherV10; } & Struct;
}
/** @name StorageEntryTypeV11 */
@@ -388,9 +415,9 @@ export interface StorageEntryTypeV11 extends Enum {
readonly isPlain: boolean;
readonly asPlain: Type;
readonly isMap: boolean;
readonly asMap: MapTypeV11;
readonly asMap: { hasher: StorageHasherV11; key: Type; value: Type; linked: bool; } & Struct;
readonly isDoubleMap: boolean;
readonly asDoubleMap: DoubleMapTypeV11;
readonly asDoubleMap: { hasher: StorageHasherV11; key1: Type; key2: Type; value: Type; key2Hasher: StorageHasherV11; } & Struct;
}
/** @name StorageEntryTypeV12 */
@@ -401,11 +428,23 @@ export interface StorageEntryTypeV13 extends Enum {
readonly isPlain: boolean;
readonly asPlain: Type;
readonly isMap: boolean;
readonly asMap: MapTypeV13;
readonly asMap: { hasher: StorageHasherV13; key: Type; value: Type; linked: bool; } & Struct;
readonly isDoubleMap: boolean;
readonly asDoubleMap: DoubleMapTypeV13;
readonly asDoubleMap: { hasher: StorageHasherV13; key1: Type; key2: Type; value: Type; key2Hasher: StorageHasherV13; } & Struct;
readonly isNMap: boolean;
readonly asNMap: NMapTypeV13;
readonly asNMap: { keyVec: Vec<Type>; hashers: Vec<StorageHasherV13>; value: Type; } & Struct;
}
/** @name StorageEntryTypeV14 */
export interface StorageEntryTypeV14 extends Enum {
readonly isPlain: boolean;
readonly asPlain: SiLookupTypeId;
readonly isMap: boolean;
readonly asMap: { hasher: StorageHasherV14; key: SiLookupTypeId; value: SiLookupTypeId; } & Struct;
readonly isDoubleMap: boolean;
readonly asDoubleMap: { hasher: StorageHasherV14; key1: SiLookupTypeId; key2: SiLookupTypeId; value: SiLookupTypeId; key2Hasher: StorageHasherV14; } & Struct;
readonly isNMap: boolean;
readonly asNMap: { key: SiLookupTypeId; hashers: Vec<StorageHasherV14>; value: SiLookupTypeId; } & Struct;
}
/** @name StorageEntryTypeV9 */
@@ -413,9 +452,9 @@ export interface StorageEntryTypeV9 extends Enum {
readonly isPlain: boolean;
readonly asPlain: Type;
readonly isMap: boolean;
readonly asMap: MapTypeV9;
readonly asMap: { hasher: StorageHasherV9; key: Type; value: Type; linked: bool; } & Struct;
readonly isDoubleMap: boolean;
readonly asDoubleMap: DoubleMapTypeV9;
readonly asDoubleMap: { hasher: StorageHasherV9; key1: Type; key2: Type; value: Type; key2Hasher: StorageHasherV9; } & Struct;
}
/** @name StorageHasher */
@@ -448,6 +487,9 @@ export interface StorageHasherV12 extends StorageHasherV11 {}
/** @name StorageHasherV13 */
export interface StorageHasherV13 extends StorageHasherV12 {}
/** @name StorageHasherV14 */
export interface StorageHasherV14 extends StorageHasherV13 {}
/** @name StorageHasherV9 */
export interface StorageHasherV9 extends Enum {
readonly isBlake2128: boolean;
@@ -0,0 +1,67 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
export const v10: DefinitionsTypes = {
// v10
ErrorMetadataV10: 'ErrorMetadataV9',
EventMetadataV10: 'EventMetadataV9',
FunctionArgumentMetadataV10: 'FunctionArgumentMetadataV9',
FunctionMetadataV10: 'FunctionMetadataV9',
MetadataV10: {
modules: 'Vec<ModuleMetadataV10>'
},
ModuleConstantMetadataV10: 'ModuleConstantMetadataV9',
ModuleMetadataV10: {
name: 'Text',
storage: 'Option<StorageMetadataV10>',
calls: 'Option<Vec<FunctionMetadataV10>>',
events: 'Option<Vec<EventMetadataV10>>',
constants: 'Vec<ModuleConstantMetadataV10>',
errors: 'Vec<ErrorMetadataV10>'
},
StorageEntryModifierV10: 'StorageEntryModifierV9',
StorageEntryMetadataV10: {
name: 'Text',
modifier: 'StorageEntryModifierV10',
type: 'StorageEntryTypeV10',
fallback: 'Bytes',
docs: 'Vec<Text>'
},
StorageEntryTypeV10: {
_enum: {
Plain: 'Type',
Map: {
hasher: 'StorageHasherV10',
key: 'Type',
value: 'Type',
linked: 'bool'
},
DoubleMap: {
hasher: 'StorageHasherV10',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV10'
}
}
},
StorageMetadataV10: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV10>'
},
StorageHasherV10: {
_enum: {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Blake2_128Concat: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null
}
}
};
@@ -0,0 +1,67 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
import { AllHashers } from './hashers';
export const v11: DefinitionsTypes = {
// v11
ErrorMetadataV11: 'ErrorMetadataV10',
EventMetadataV11: 'EventMetadataV10',
ExtrinsicMetadataV11: {
version: 'u8',
signedExtensions: 'Vec<Text>'
},
FunctionArgumentMetadataV11: 'FunctionArgumentMetadataV10',
FunctionMetadataV11: 'FunctionMetadataV10',
MetadataV11: {
modules: 'Vec<ModuleMetadataV11>',
extrinsic: 'ExtrinsicMetadataV11'
},
ModuleConstantMetadataV11: 'ModuleConstantMetadataV10',
ModuleMetadataV11: {
name: 'Text',
storage: 'Option<StorageMetadataV11>',
calls: 'Option<Vec<FunctionMetadataV11>>',
events: 'Option<Vec<EventMetadataV11>>',
constants: 'Vec<ModuleConstantMetadataV11>',
errors: 'Vec<ErrorMetadataV11>'
},
StorageEntryModifierV11: 'StorageEntryModifierV10',
StorageEntryMetadataV11: {
name: 'Text',
modifier: 'StorageEntryModifierV11',
type: 'StorageEntryTypeV11',
fallback: 'Bytes',
docs: 'Vec<Text>'
},
StorageEntryTypeV11: {
_enum: {
Plain: 'Type',
Map: {
hasher: 'StorageHasherV11',
key: 'Type',
value: 'Type',
linked: 'bool'
},
DoubleMap: {
hasher: 'StorageHasherV11',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV11'
}
}
},
StorageMetadataV11: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV11>'
},
StorageHasherV11: {
_enum: AllHashers
}
};
@@ -0,0 +1,35 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
export const v12: DefinitionsTypes = {
// v12
ErrorMetadataV12: 'ErrorMetadataV11',
EventMetadataV12: 'EventMetadataV11',
ExtrinsicMetadataV12: 'ExtrinsicMetadataV11',
FunctionArgumentMetadataV12: 'FunctionArgumentMetadataV11',
FunctionMetadataV12: 'FunctionMetadataV11',
MetadataV12: {
modules: 'Vec<ModuleMetadataV12>',
extrinsic: 'ExtrinsicMetadataV12'
},
ModuleConstantMetadataV12: 'ModuleConstantMetadataV11',
ModuleMetadataV12: {
name: 'Text',
storage: 'Option<StorageMetadataV12>',
calls: 'Option<Vec<FunctionMetadataV12>>',
events: 'Option<Vec<EventMetadataV12>>',
constants: 'Vec<ModuleConstantMetadataV12>',
errors: 'Vec<ErrorMetadataV12>',
index: 'u8'
},
StorageEntryModifierV12: 'StorageEntryModifierV11',
StorageEntryMetadataV12: 'StorageEntryMetadataV11',
StorageEntryTypeV12: 'StorageEntryTypeV11',
StorageMetadataV12: 'StorageMetadataV11',
StorageHasherV12: 'StorageHasherV11'
};
@@ -0,0 +1,66 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
export const v13: DefinitionsTypes = {
// v13
ErrorMetadataV13: 'ErrorMetadataV12',
EventMetadataV13: 'EventMetadataV12',
ExtrinsicMetadataV13: 'ExtrinsicMetadataV12',
FunctionArgumentMetadataV13: 'FunctionArgumentMetadataV12',
FunctionMetadataV13: 'FunctionMetadataV12',
MetadataV13: {
modules: 'Vec<ModuleMetadataV13>',
extrinsic: 'ExtrinsicMetadataV13'
},
ModuleConstantMetadataV13: 'ModuleConstantMetadataV12',
ModuleMetadataV13: {
name: 'Text',
storage: 'Option<StorageMetadataV13>',
calls: 'Option<Vec<FunctionMetadataV13>>',
events: 'Option<Vec<EventMetadataV13>>',
constants: 'Vec<ModuleConstantMetadataV13>',
errors: 'Vec<ErrorMetadataV13>',
index: 'u8'
},
StorageEntryModifierV13: 'StorageEntryModifierV12',
StorageEntryMetadataV13: {
name: 'Text',
modifier: 'StorageEntryModifierV13',
type: 'StorageEntryTypeV13',
fallback: 'Bytes',
docs: 'Vec<Text>'
},
StorageEntryTypeV13: {
_enum: {
Plain: 'Type',
Map: {
hasher: 'StorageHasherV13',
key: 'Type',
value: 'Type',
linked: 'bool'
},
DoubleMap: {
hasher: 'StorageHasherV13',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV13'
},
NMap: {
keyVec: 'Vec<Type>',
hashers: 'Vec<StorageHasherV13>',
value: 'Type'
}
}
},
StorageMetadataV13: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV13>'
},
StorageHasherV13: 'StorageHasherV12'
};
@@ -0,0 +1,94 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
export const v14: DefinitionsTypes = {
// registry
PortableRegistry: 'GenericPortableRegistry',
PortableType: {
id: 'SiLookupTypeId',
type: 'SiType'
},
// V14
ExtrinsicMetadataV14: {
type: 'SiLookupTypeId',
version: 'u8',
signedExtensions: 'Vec<SignedExtensionMetadataV14>'
},
MetadataV14: {
lookup: 'PortableRegistry',
pallets: 'Vec<PalletMetadataV14>',
extrinsic: 'ExtrinsicMetadataV14'
},
PalletCallMetadataV14: {
type: 'SiLookupTypeId'
},
PalletConstantMetadataV14: {
name: 'Text',
type: 'SiLookupTypeId',
value: 'Bytes',
docs: 'Vec<Text>'
},
PalletErrorMetadataV14: {
type: 'SiLookupTypeId'
},
PalletEventMetadataV14: {
type: 'SiLookupTypeId'
},
PalletMetadataV14: {
name: 'Text',
storage: 'Option<PalletStorageMetadataV14>',
calls: 'Option<PalletCallMetadataV14>',
events: 'Option<PalletEventMetadataV14>',
constants: 'Vec<PalletConstantMetadataV14>',
errors: 'Option<PalletErrorMetadataV14>',
index: 'u8'
},
PalletStorageMetadataV14: {
prefix: 'Text',
// NOTE: Renamed from entries
items: 'Vec<StorageEntryMetadataV14>'
},
SignedExtensionMetadataV14: {
identifier: 'Text',
type: 'SiLookupTypeId',
additionalSigned: 'SiLookupTypeId'
},
StorageEntryMetadataV14: {
name: 'Text',
modifier: 'StorageEntryModifierV14',
type: 'StorageEntryTypeV14',
fallback: 'Bytes',
docs: 'Vec<Text>'
},
StorageEntryModifierV14: 'StorageEntryModifierV13',
StorageEntryTypeV14: {
_enum: {
Plain: 'SiLookupTypeId',
Map: {
hasher: 'StorageHasherV14',
key: 'SiLookupTypeId',
value: 'SiLookupTypeId'
},
DoubleMap: {
hasher: 'StorageHasherV14',
key1: 'SiLookupTypeId',
key2: 'SiLookupTypeId',
value: 'SiLookupTypeId',
key2Hasher: 'StorageHasherV14'
},
NMap: {
// NOTE: Renamed from "keys"
key: 'SiLookupTypeId',
hashers: 'Vec<StorageHasherV14>',
value: 'SiLookupTypeId'
}
}
},
StorageHasherV14: 'StorageHasherV13'
};
@@ -0,0 +1,87 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsTypes } from '../../types';
export const v9: DefinitionsTypes = {
// v9
ErrorMetadataV9: {
name: 'Text',
docs: 'Vec<Text>'
},
EventMetadataV9: {
name: 'Text',
args: 'Vec<Type>',
docs: 'Vec<Text>'
},
FunctionArgumentMetadataV9: {
name: 'Text',
type: 'Type'
},
FunctionMetadataV9: {
name: 'Text',
args: 'Vec<FunctionArgumentMetadataV9>',
docs: 'Vec<Text>'
},
MetadataV9: {
modules: 'Vec<ModuleMetadataV9>'
},
ModuleConstantMetadataV9: {
name: 'Text',
type: 'Type',
value: 'Bytes',
docs: 'Vec<Text>'
},
ModuleMetadataV9: {
name: 'Text',
storage: 'Option<StorageMetadataV9>',
calls: 'Option<Vec<FunctionMetadataV9>>',
events: 'Option<Vec<EventMetadataV9>>',
constants: 'Vec<ModuleConstantMetadataV9>',
errors: 'Vec<ErrorMetadataV9>'
},
StorageEntryMetadataV9: {
name: 'Text',
modifier: 'StorageEntryModifierV9',
type: 'StorageEntryTypeV9',
fallback: 'Bytes',
docs: 'Vec<Text>'
},
StorageEntryModifierV9: {
_enum: ['Optional', 'Default', 'Required']
},
StorageEntryTypeV9: {
_enum: {
Plain: 'Type',
Map: {
hasher: 'StorageHasherV9',
key: 'Type',
value: 'Type',
linked: 'bool'
},
DoubleMap: {
hasher: 'StorageHasherV9',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasherV9'
}
}
},
StorageHasherV9: {
_enum: {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Twox128: null,
Twox256: null,
Twox64Concat: null
}
},
StorageMetadataV9: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV9>'
}
};
@@ -296,7 +296,7 @@ export default {
_enum: ['Onboarding', 'Parathread', 'Parachain', 'UpgradingToParachain', 'DowngradingToParathread', 'OutgoingParathread', 'OutgoingParachain']
},
ParaPastCodeMeta: {
upgradeTimes: 'Vec<BlockNumber>',
upgradeTimes: 'Vec<ReplacementTimes>',
lastPruned: 'Option<BlockNumber>'
},
ParaScheduling: {
@@ -318,15 +318,19 @@ export default {
relayParentStorageRoot: 'Hash',
maxPovSize: 'u32'
},
RelayBlockNumber: 'u32',
RelayChainBlockNumber: 'RelayBlockNumber',
RelayHash: 'Hash',
RelayChainHash: 'RelayHash',
QueuedParathread: {
claim: 'ParathreadEntry',
coreOffset: 'u32'
},
RelayBlockNumber: 'u32',
RelayChainBlockNumber: 'RelayBlockNumber',
RelayHash: 'Hash',
RelayChainHash: 'RelayHash',
Remark: '[u8; 32]',
ReplacementTimes: {
expectedAt: 'BlockNumber',
activatedAt: 'BlockNumber'
},
Retriable: {
_enum: {
Never: 'Null',
@@ -454,7 +454,7 @@ export interface ParaLifecycle extends Enum {
/** @name ParaPastCodeMeta */
export interface ParaPastCodeMeta extends Struct {
readonly upgradeTimes: Vec<BlockNumber>;
readonly upgradeTimes: Vec<ReplacementTimes>;
readonly lastPruned: Option<BlockNumber>;
}
@@ -517,6 +517,12 @@ export interface RelayHash extends Hash {}
/** @name Remark */
export interface Remark extends U8aFixed {}
/** @name ReplacementTimes */
export interface ReplacementTimes extends Struct {
readonly expectedAt: BlockNumber;
readonly activatedAt: BlockNumber;
}
/** @name Retriable */
export interface Retriable extends Enum {
readonly isNever: boolean;
@@ -26,7 +26,9 @@ export default {
rpc: {},
types: {
...numberTypes,
AccountId: 'GenericAccountId',
AccountId: 'AccountId32',
AccountId20: 'GenericEthereumAccountId',
AccountId32: 'GenericAccountId',
AccountIdOf: 'AccountId',
AccountIndex: 'GenericAccountIndex',
Address: 'MultiAddress',
@@ -1,14 +1,20 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Bytes, Compact, DoNotConstruct, Enum, GenericAccountId, GenericAccountIndex, GenericBlock, GenericCall, GenericConsensusEngineId, GenericLookupSource, GenericMultiAddress, Int, Null, Option, StorageKey, Struct, U8aFixed, UInt, Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Bytes, Compact, DoNotConstruct, Enum, GenericAccountId, GenericAccountIndex, GenericBlock, GenericCall, GenericConsensusEngineId, GenericEthereumAccountId, GenericLookupSource, GenericMultiAddress, Int, Null, Option, StorageKey, Struct, U8aFixed, UInt, Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { ITuple } from '@polkadot/types/types';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { Signature } from '@polkadot/types/interfaces/extrinsics';
import type { SystemOrigin } from '@polkadot/types/interfaces/system';
/** @name AccountId */
export interface AccountId extends GenericAccountId {}
export interface AccountId extends AccountId32 {}
/** @name AccountId20 */
export interface AccountId20 extends GenericEthereumAccountId {}
/** @name AccountId32 */
export interface AccountId32 extends GenericAccountId {}
/** @name AccountIdOf */
export interface AccountIdOf extends AccountId {}
@@ -3,22 +3,28 @@
import type { Definitions } from '../../types';
import { v0 } from './v0';
// order important in structs... :)
/* eslint-disable sort-keys */
export default {
rpc: {},
types: {
...v0,
SiField: {
name: 'Option<Text>',
type: 'SiLookupTypeId'
type: 'SiLookupTypeId',
typeName: 'Option<Text>',
docs: 'Vec<Text>'
},
SiLookupTypeId: 'u32',
SiLookupTypeId: 'Compact<u32>',
SiPath: 'Vec<Text>',
SiType: {
path: 'SiPath',
params: 'Vec<SiLookupTypeId>',
def: 'SiTypeDef'
params: 'Vec<SiTypeParameter>',
def: 'SiTypeDef',
docs: 'Vec<Text>'
},
SiTypeDef: {
_enum: {
@@ -27,11 +33,23 @@ export default {
Sequence: 'SiTypeDefSequence',
Array: 'SiTypeDefArray',
Tuple: 'SiTypeDefTuple',
Primitive: 'SiTypeDefPrimitive'
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: 'u16',
len: 'u32',
type: 'SiLookupTypeId'
},
SiTypeDefBitSequence: {
bitStoreType: 'SiLookupTypeId',
bitOrderType: 'SiLookupTypeId'
},
SiTypeDefCompact: {
type: 'SiLookupTypeId'
},
SiTypeDefComposite: {
@@ -47,10 +65,15 @@ export default {
type: 'SiLookupTypeId'
},
SiTypeDefTuple: 'Vec<SiLookupTypeId>',
SiTypeParameter: {
name: 'Text',
type: 'Option<SiLookupTypeId>'
},
SiVariant: {
name: 'Text',
fields: 'Vec<SiField>',
discriminant: 'Option<u64>'
index: 'u8',
docs: 'Vec<Text>'
}
}
} as Definitions;
@@ -1,16 +1,133 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Enum, Option, Struct, Text, Vec, u16, u32, u64 } from '@polkadot/types';
import type { Compact, Enum, Null, Option, Struct, Text, Type, Vec, u32, u64, u8 } from '@polkadot/types';
/** @name Si0Field */
export interface Si0Field extends Struct {
readonly name: Option<Text>;
readonly type: Si0LookupTypeId;
readonly typeName: Option<Text>;
readonly docs: Vec<Text>;
}
/** @name Si0LookupTypeId */
export interface Si0LookupTypeId extends u32 {}
/** @name Si0Path */
export interface Si0Path extends Vec<Text> {}
/** @name Si0Type */
export interface Si0Type extends Struct {
readonly path: Si0Path;
readonly params: Vec<Si0LookupTypeId>;
readonly def: Si0TypeDef;
}
/** @name Si0TypeDef */
export interface Si0TypeDef extends Enum {
readonly isComposite: boolean;
readonly asComposite: Si0TypeDefComposite;
readonly isVariant: boolean;
readonly asVariant: Si0TypeDefVariant;
readonly isSequence: boolean;
readonly asSequence: Si0TypeDefSequence;
readonly isArray: boolean;
readonly asArray: Si0TypeDefArray;
readonly isTuple: boolean;
readonly asTuple: Si0TypeDefTuple;
readonly isPrimitive: boolean;
readonly asPrimitive: Si0TypeDefPrimitive;
readonly isCompact: boolean;
readonly asCompact: Si0TypeDefCompact;
readonly isPhantom: boolean;
readonly asPhantom: Si0TypeDefPhantom;
readonly isBitSequence: boolean;
readonly asBitSequence: Si0TypeDefBitSequence;
}
/** @name Si0TypeDefArray */
export interface Si0TypeDefArray extends Struct {
readonly len: u32;
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefBitSequence */
export interface Si0TypeDefBitSequence extends Struct {
readonly bitStoreType: Si0LookupTypeId;
readonly bitOrderType: Si0LookupTypeId;
}
/** @name Si0TypeDefCompact */
export interface Si0TypeDefCompact extends Struct {
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefComposite */
export interface Si0TypeDefComposite extends Struct {
readonly fields: Vec<Si0Field>;
}
/** @name Si0TypeDefPhantom */
export interface Si0TypeDefPhantom extends Null {}
/** @name Si0TypeDefPrimitive */
export interface Si0TypeDefPrimitive extends Enum {
readonly isBool: boolean;
readonly isChar: boolean;
readonly isStr: boolean;
readonly isU8: boolean;
readonly isU16: boolean;
readonly isU32: boolean;
readonly isU64: boolean;
readonly isU128: boolean;
readonly isU256: boolean;
readonly isI8: boolean;
readonly isI16: boolean;
readonly isI32: boolean;
readonly isI64: boolean;
readonly isI128: boolean;
readonly isI256: boolean;
}
/** @name Si0TypeDefSequence */
export interface Si0TypeDefSequence extends Struct {
readonly type: Si0LookupTypeId;
}
/** @name Si0TypeDefTuple */
export interface Si0TypeDefTuple extends Vec<Si0LookupTypeId> {}
/** @name Si0TypeDefVariant */
export interface Si0TypeDefVariant extends Struct {
readonly variants: Vec<Si0Variant>;
}
/** @name Si0TypeParameter */
export interface Si0TypeParameter extends Struct {
readonly name: Text;
readonly type: Option<Si0LookupTypeId>;
}
/** @name Si0Variant */
export interface Si0Variant extends Struct {
readonly name: Text;
readonly fields: Vec<Si0Field>;
readonly index: Option<u8>;
readonly discriminant: Option<u64>;
readonly docs: Vec<Text>;
}
/** @name SiField */
export interface SiField extends Struct {
readonly name: Option<Text>;
readonly type: SiLookupTypeId;
readonly typeName: Option<Text>;
readonly docs: Vec<Text>;
}
/** @name SiLookupTypeId */
export interface SiLookupTypeId extends u32 {}
export interface SiLookupTypeId extends Compact<u32> {}
/** @name SiPath */
export interface SiPath extends Vec<Text> {}
@@ -18,8 +135,9 @@ export interface SiPath extends Vec<Text> {}
/** @name SiType */
export interface SiType extends Struct {
readonly path: SiPath;
readonly params: Vec<SiLookupTypeId>;
readonly params: Vec<SiTypeParameter>;
readonly def: SiTypeDef;
readonly docs: Vec<Text>;
}
/** @name SiTypeDef */
@@ -36,11 +154,28 @@ export interface SiTypeDef extends Enum {
readonly asTuple: SiTypeDefTuple;
readonly isPrimitive: boolean;
readonly asPrimitive: SiTypeDefPrimitive;
readonly isCompact: boolean;
readonly asCompact: SiTypeDefCompact;
readonly isBitSequence: boolean;
readonly asBitSequence: SiTypeDefBitSequence;
readonly isHistoricMetaCompat: boolean;
readonly asHistoricMetaCompat: Type;
}
/** @name SiTypeDefArray */
export interface SiTypeDefArray extends Struct {
readonly len: u16;
readonly len: u32;
readonly type: SiLookupTypeId;
}
/** @name SiTypeDefBitSequence */
export interface SiTypeDefBitSequence extends Struct {
readonly bitStoreType: SiLookupTypeId;
readonly bitOrderType: SiLookupTypeId;
}
/** @name SiTypeDefCompact */
export interface SiTypeDefCompact extends Struct {
readonly type: SiLookupTypeId;
}
@@ -81,11 +216,18 @@ export interface SiTypeDefVariant extends Struct {
readonly variants: Vec<SiVariant>;
}
/** @name SiTypeParameter */
export interface SiTypeParameter extends Struct {
readonly name: Text;
readonly type: Option<SiLookupTypeId>;
}
/** @name SiVariant */
export interface SiVariant extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly discriminant: Option<u64>;
readonly index: u8;
readonly docs: Vec<Text>;
}
export type PHANTOM_SCALEINFO = 'scaleInfo';
@@ -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>'
}
};
@@ -154,7 +154,7 @@ const junction = {
},
AccountKey20Junction: {
network: 'NetworkId',
index: '[u8; 20]'
key: '[u8; 20]'
},
PluralityJunction: {
id: 'BodyId',
+1 -1
View File
@@ -20,7 +20,7 @@ export interface AccountIndex64Junction extends Struct {
/** @name AccountKey20Junction */
export interface AccountKey20Junction extends Struct {
readonly network: NetworkId;
readonly index: U8aFixed;
readonly key: U8aFixed;
}
/** @name AssetInstance */
@@ -78,7 +78,7 @@ function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _stora
}
/** @internal */
function extendHeadMeta (registry: Registry, { meta: { documentation, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (...args: unknown[]) => Raw): (...args: unknown[]) => StorageKey {
function extendHeadMeta (registry: Registry, { meta: { docs, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (...args: unknown[]) => Raw): (...args: unknown[]) => StorageKey {
const outputType = type.isMap
? type.asMap.key
: type.isDoubleMap
@@ -88,7 +88,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
// metadata with a fallback value using the type of the key, the normal
// meta fallback only applies to actual entry values, create one for head
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
documentation,
docs,
fallback: registry.createType('Bytes'),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
name,
@@ -8,7 +8,7 @@ import type { Registry } from '../../../types';
import { createFunction } from './createFunction';
interface SubstrateMetadata {
documentation: string;
docs: string;
type: string;
}
@@ -16,11 +16,11 @@ type Creator = (registry: Registry) => StorageEntry;
// Small helper function to factorize code on this page.
/** @internal */
function createRuntimeFunction (method: string, key: string, { documentation, type }: SubstrateMetadata): (registry: Registry) => StorageEntry {
function createRuntimeFunction (method: string, key: string, { docs, type }: SubstrateMetadata): (registry: Registry) => StorageEntry {
return (registry: Registry): StorageEntry =>
createFunction(registry, {
meta: {
documentation: registry.createType('Vec<Text>', [documentation]),
docs: registry.createType('Vec<Text>', [docs]),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
name: registry.createType('Text', method),
toJSON: (): any => key,
@@ -34,23 +34,23 @@ function createRuntimeFunction (method: string, key: string, { documentation, ty
export const substrate: Record<string, Creator> = {
changesTrieConfig: createRuntimeFunction('changesTrieConfig', ':changes_trie', {
documentation: ' Changes trie configuration is stored under this key.',
docs: ' Changes trie configuration is stored under this key.',
type: 'u32'
}),
childStorageKeyPrefix: createRuntimeFunction('childStorageKeyPrefix', ':child_storage:', {
documentation: ' Prefix of child storage keys.',
docs: ' Prefix of child storage keys.',
type: 'u32'
}),
code: createRuntimeFunction('code', ':code', {
documentation: ' Wasm code of the runtime.',
docs: ' Wasm code of the runtime.',
type: 'Bytes'
}),
extrinsicIndex: createRuntimeFunction('extrinsicIndex', ':extrinsic_index', {
documentation: ' Current extrinsic index (u32) is stored under this key.',
docs: ' Current extrinsic index (u32) is stored under this key.',
type: 'u32'
}),
heapPages: createRuntimeFunction('heapPages', ':heappages', {
documentation: ' Number of wasm linear memory pages required for execution of the runtime.',
docs: ' Number of wasm linear memory pages required for execution of the runtime.',
type: 'u64'
})
};
+1 -1
View File
@@ -54,7 +54,7 @@ export function defaultValues (registry: Registry, rpcData: string, withThrow =
metadata.asLatest.modules.filter(({ storage }): boolean => storage.isSome).forEach((mod): void => {
mod.storage.unwrap().items.forEach(({ fallback, modifier, name, type }): void => {
const inner = unwrapStorageType(type, modifier.isOptional);
const inner = unwrapStorageType(registry, type, modifier.isOptional);
const location = `${mod.name.toString()}.${name.toString()}: ${inner}`;
it(`creates default types for ${location}`, (): void => {
@@ -13,8 +13,8 @@ interface ModuleMetadataTrimmed {
name: Text;
}
function trimDocs (documentation: Vec<Text>): string[] {
const strings = documentation.map((doc) => doc.toString().trim());
function trimDocs (docs: Vec<Text>): string[] {
const strings = docs.map((doc) => doc.toString().trim());
const firstEmpty = strings.findIndex((doc) => !doc.length);
return firstEmpty === -1
@@ -28,10 +28,10 @@ function mapCalls (registry: Registry, _calls: Option<Vec<FunctionMetadataLatest
return registry.createType(
'Option<Vec<FunctionMetadataLatest>>' as any,
calls
? calls.map(({ args, documentation, name }) =>
? calls.map(({ args, docs, name }) =>
registry.createType('FunctionMetadataLatest', {
args,
documentation: trimDocs(documentation),
docs: trimDocs(docs),
name
})
)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -20
View File
@@ -4,29 +4,11 @@
import type { EventMetadataLatest, EventMetadataV13, FunctionMetadataLatest, FunctionMetadataV13, MetadataLatest, MetadataV13, ModuleConstantMetadataLatest, ModuleConstantMetadataV13, ModuleMetadataLatest, ModuleMetadataV13, StorageEntryMetadataLatest, StorageMetadataLatest, StorageMetadataV13 } from '../../interfaces/metadata';
import type { OverrideModuleType, Registry } from '../../types';
import { getModuleTypes } from '@polkadot/types-known';
import { getModuleTypes, knownOrigins } from '@polkadot/types-known';
import { stringCamelCase } from '@polkadot/util';
import { Type } from '../../primitive';
// FIXME: Need some sort of solution for specifying these
// Since we don't have insight into the origin specification, we can only define what we know about
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
const KNOWN_ORIGINS: Record<string, string> = {
/* eslint-disable sort-keys */
// Substrate
Council: 'CollectiveOrigin',
System: 'SystemOrigin',
TechnicalCommittee: 'CollectiveOrigin',
// Polkadot
Xcm: 'XcmOrigin',
XcmPallet: 'XcmOrigin',
// Acala
Authority: 'AuthorityOrigin',
GeneralCouncil: 'CollectiveOrigin'
/* eslint-enable sort-keys */
};
const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']];
/**
@@ -131,7 +113,7 @@ function registerOriginCaller (registry: Registry, modules: ModuleMetadataV13[],
result[`Empty${i}`] = 'Null';
}
result[name] = KNOWN_ORIGINS[name] || 'Null';
result[name] = knownOrigins[name] || 'Null';
return result;
}, {})
+325
View File
@@ -0,0 +1,325 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ErrorMetadataV13, EventMetadataV13, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionMetadataV13, MetadataV13, MetadataV14, ModuleConstantMetadataV13, ModuleMetadataV13, PalletCallMetadataV14, PalletConstantMetadataV14, PalletErrorMetadataV14, PalletEventMetadataV14, PalletMetadataV14, PalletStorageMetadataV14, StorageEntryMetadataV14, StorageEntryTypeV14, StorageMetadataV13 } from '../../interfaces/metadata';
import type { SiVariant } from '../../interfaces/scaleInfo';
import type { Text } from '../../primitive/Text';
import type { Type } from '../../primitive/Type';
import type { OverrideModuleType, Registry } from '../../types';
import { getModuleTypes, knownOrigins } from '@polkadot/types-known';
import { stringCamelCase } from '@polkadot/util';
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 {
const type = _type.toString();
const index = types.findIndex(({ def }) =>
def.HistoricMetaCompat === type
);
if (index !== -1) {
return index;
}
return types.push({
def: { HistoricMetaCompat: type }
}) - 1;
}
function variantType (modName: Text, variantType: string, types: TypeSpec[], variants: SiVariant[]): number {
return types.push({
def: {
Variant: { variants }
},
path: [`pallet_${modName.toString()}`, 'pallet', variantType]
}) - 1;
}
/**
* @internal
* generate & register the OriginCaller type
**/
function registerOriginCaller (registry: Registry, modules: ModuleMetadataV13[], metaVersion: number): void {
registry.register({
OriginCaller: {
_enum: modules
.map((mod, index): [string, number] => [
mod.name.toString(),
metaVersion >= 12
? mod.index.toNumber()
: index
])
.sort((a, b) => a[1] - b[1])
.reduce((result: Record<string, string>, [name, index]): Record<string, string> => {
for (let i = Object.keys(result).length; i < index; i++) {
result[`Empty${i}`] = 'Null';
}
result[name] = knownOrigins[name] || 'Null';
return result;
}, {})
}
});
}
/**
* Find and apply the correct type override
* @internal
**/
function setTypeOverride (sectionTypes: OverrideModuleType, types: Type[]): void {
types.forEach((type): void => {
const override = Object.keys(sectionTypes).find((aliased) => type.eq(aliased));
if (override) {
type.setOverride(sectionTypes[override]);
} else {
// FIXME: NOT happy with this approach, but gets over the initial hump cased by (Vec<Announcement>,BalanceOf)
const orig = type.toString();
const alias = Object
.entries(sectionTypes)
.reduce((result: string, [from, to]) =>
BOXES.reduce((result, [one, two]) =>
result.replace(`${one}${from}${two}`, `${one}${to}${two}`), result), orig);
if (orig !== alias) {
type.setOverride(alias);
}
}
});
}
/**
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
**/
function convertCalls (registry: Registry, types: TypeSpec[], 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(types, type) })
),
index,
name
});
});
return registry.createType('PalletCallMetadataV14', {
type: variantType(modName, 'Call', types, variants)
});
}
/**
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
*/
function convertConstants (registry: Registry, types: TypeSpec[], constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): PalletConstantMetadataV14[] {
return constants.map(({ docs, name, type, value }): PalletConstantMetadataV14 => {
setTypeOverride(sectionTypes, [type]);
return registry.createType('PalletConstantMetadataV14', {
docs,
name,
type: compatType(types, type),
value
});
});
}
/**
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function convertErrors (registry: Registry, types: TypeSpec[], modName: Text, errors: ErrorMetadataV13[], _sectionTypes: OverrideModuleType): PalletErrorMetadataV14 {
const variants = errors.map(({ docs, name }, index): SiVariant =>
registry.createType('SiVariant', {
docs,
fields: [],
index,
name
})
);
return registry.createType('PalletErrorMetadataV14', {
type: variantType(modName, 'Error', types, variants)
});
}
/**
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
**/
function convertEvents (registry: Registry, types: TypeSpec[], 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((type) =>
registry.createType('SiField', { type: compatType(types, type) })
),
index,
name
});
});
return registry.createType('PalletEventMetadataV14', {
type: variantType(modName, 'Event', types, variants)
});
}
/**
* Apply module-specific storage type overrides (always part of toV14)
* @internal
**/
function convertStorage (registry: Registry, types: TypeSpec[], { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): PalletStorageMetadataV14 {
return registry.createType('PalletStorageMetadataV14', {
items: items.map(({ docs, fallback, modifier, name, type }): StorageEntryMetadataV14 => {
let entryType: StorageEntryTypeV14;
if (type.isPlain) {
const plain = type.asPlain;
setTypeOverride(sectionTypes, [plain]);
entryType = registry.createType('StorageEntryTypeV14', {
Plain: compatType(types, plain)
});
} else if (type.isMap) {
const map = type.asMap;
setTypeOverride(sectionTypes, [map.value, map.key]);
entryType = registry.createType('StorageEntryTypeV14', {
Map: {
hasher: map.hasher,
key: compatType(types, map.key),
value: compatType(types, map.value)
}
});
} else if (type.isDoubleMap) {
const dm = type.asDoubleMap;
setTypeOverride(sectionTypes, [dm.value, dm.key1, dm.key2]);
entryType = registry.createType('StorageEntryTypeV14', {
DoubleMap: {
hasher: dm.hasher,
key1: compatType(types, dm.key1),
key2: compatType(types, dm.key2),
key2Hasher: dm.key2Hasher,
value: compatType(types, dm.value)
}
});
} else {
const nm = type.asNMap;
setTypeOverride(sectionTypes, [nm.value, ...nm.keyVec]);
const key = types.push({
def: {
Tuple: nm.keyVec.map((type) =>
compatType(types, type)
)
}
}) - 1;
entryType = registry.createType('StorageEntryTypeV14', {
NMap: {
hashers: nm.hashers,
key,
value: compatType(types, nm.value)
}
});
}
return registry.createType('StorageEntryMetadataV14', {
docs,
fallback,
modifier,
name,
type: entryType
});
}),
prefix
});
}
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function convertExtrinsic (registry: Registry, _types: TypeSpec[], { signedExtensions, version }: ExtrinsicMetadataV13): ExtrinsicMetadataV14 {
return registry.createType('ExtrinsicMetadataV14', {
signedExtensions: signedExtensions.map((identifier) => ({
identifier,
type: 0 // we don't map the fields at all
})),
type: 0, // Map to extrinsic like in v14?
version: version
});
}
/** @internal */
function createPallet (registry: Registry, types: TypeSpec[], 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, types, mod.name, calls, sectionTypes),
constants: convertConstants(registry, types, constants, sectionTypes),
errors: errors && convertErrors(registry, types, mod.name, errors, sectionTypes),
events: events && convertEvents(registry, types, mod.name, events, sectionTypes),
index: mod.index,
name: mod.name,
storage: storage && convertStorage(registry, types, storage, sectionTypes)
});
}
/**
* Convert the Metadata to v14
* @internal
**/
export function toV14 (registry: Registry, v13: MetadataV13, metaVersion: number): MetadataV14 {
// the types that we will pass
const types: TypeSpec[] = [];
compatType(types, 'Null'); // position 0 always has Null
registerOriginCaller(registry, v13.modules, metaVersion);
const extrinsic = convertExtrinsic(registry, types, v13.extrinsic);
const pallets = v13.modules.map((mod) =>
createPallet(registry, types, mod, {
calls: mod.calls.unwrapOr(null),
constants: mod.constants,
errors: mod.errors.length ? mod.errors : null,
events: mod.events.unwrapOr(null),
storage: mod.storage.unwrapOr(null)
})
);
return registry.createType('MetadataV14', {
extrinsic,
lookup: {
types: types.map((type, id) =>
registry.createType('PortableType', { id, type })
)
},
pallets
});
}
@@ -0,0 +1,47 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { MetadataAll } from '../../interfaces/metadata';
import { TypeRegistry } from '../../create';
import { Metadata } from '../Metadata';
import substrateData from './static';
import substrateJson from './static-substrate.json';
import substrateTypes from './static-types.json';
describe('MetadataV14 (substrate)', (): void => {
// FIXME This is to be replaced with the proper version (here as a stop-gap)
it('parses', (): void => {
const registry = new TypeRegistry();
const metadata = new Metadata(registry, substrateData);
const all = metadata.get('metadata') as MetadataAll;
const v14 = all.asV14;
const jsonStruct = v14.toJSON();
const jsonTypes = v14.lookup.types.toJSON();
delete (jsonStruct as Record<string, unknown>).lookup;
const allJson = {
magicNumber: 1635018093,
metadata: {
v14: jsonStruct
}
};
try {
expect(allJson).toEqual(substrateJson);
} catch (error) {
console.error(JSON.stringify(allJson));
throw error;
}
try {
expect(jsonTypes).toEqual(substrateTypes);
} catch (error) {
console.error(JSON.stringify(jsonTypes));
throw error;
}
});
});
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '5.0.1' };
export const packageInfo = { name: '@polkadot/types', version: '5.2.1' };
+6 -6
View File
@@ -33,7 +33,7 @@ const HASHER_MAP: Record<keyof typeof AllHashers, [number, boolean]> = {
};
/** @internal */
export function unwrapStorageType (type: StorageEntryTypeLatest, isOptional?: boolean): keyof InterfaceTypes {
export function unwrapStorageType (_: Registry, type: StorageEntryTypeLatest, isOptional?: boolean): keyof InterfaceTypes {
const outputType = type.isPlain
? type.asPlain.toString()
: type.isMap
@@ -142,16 +142,16 @@ function getMeta (value: StorageKey | StorageEntry | [StorageEntry, unknown]): S
}
/** @internal */
function getType (value: StorageKey | StorageEntry | [StorageEntry, unknown]): string {
function getType (registry: Registry, value: StorageKey | StorageEntry | [StorageEntry, unknown]): string {
if (value instanceof StorageKey) {
return value.outputType;
} else if (isFunction(value)) {
return unwrapStorageType(value.meta.type);
return unwrapStorageType(registry, value.meta.type);
} else if (Array.isArray(value)) {
const [fn] = value;
if (fn.meta) {
return unwrapStorageType(fn.meta.type);
return unwrapStorageType(registry, fn.meta.type);
}
}
@@ -183,7 +183,7 @@ export class StorageKey<A extends AnyTuple = AnyTuple> extends Bytes implements
super(registry, key);
this._outputType = getType(value as StorageKey);
this._outputType = getType(registry, value as StorageKey);
// decode the args (as applicable based on the key and the hashers, after all init)
this.setMeta(getMeta(value as StorageKey), override.section || section, override.method || method);
@@ -237,7 +237,7 @@ export class StorageKey<A extends AnyTuple = AnyTuple> extends Bytes implements
this._section = section || this._section;
if (meta) {
this._outputType = unwrapStorageType(meta.type);
this._outputType = unwrapStorageType(this.registry, meta.type);
}
try {
+10 -1
View File
@@ -3,8 +3,11 @@
import type { Observable } from 'rxjs';
import type { BN } from '@polkadot/util';
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 { SiLookupTypeId } from '../interfaces/scaleInfo';
import type { ChainProperties } from '../interfaces/system';
import type { Metadata } from '../metadata';
import type { CallFunction } from './calls';
@@ -33,7 +36,7 @@ export type RegistryTypes =
{ _set: Record<string, number> }>;
export interface RegistryError {
documentation: string[];
docs: string[];
index: number;
// compat
method: string;
@@ -100,6 +103,8 @@ export interface Registry {
readonly chainSS58: number | undefined;
readonly chainTokens: string[];
readonly knownTypes: RegisteredTypes;
readonly lookup: PortableRegistry;
readonly metadata: MetadataLatest;
readonly unknownTypes: string[];
readonly signedExtensions: string[];
@@ -111,8 +116,12 @@ export interface Registry {
// keep this as a generic Codec, however the actual impl. returns the correct
findMetaEvent (eventIndex: Uint8Array): Constructor<any>;
isLookupType (value: string): boolean;
createLookupType (lookupId: SiLookupTypeId | number): string;
createClass <K extends keyof InterfaceTypes> (type: K): Constructor<InterfaceTypes[K]>;
createType <K extends keyof InterfaceTypes> (type: K, ...params: unknown[]): InterfaceTypes[K];
createTypeUnsafe <T extends Codec = Codec, K extends string = string> (type: K, params: unknown[], options?: CreateOptions): T;
get <T extends Codec = Codec> (name: string, withUnknown?: boolean): Constructor<T> | undefined;
getChainProperties (): ChainProperties | undefined;
getClassName (clazz: Constructor): string | undefined;
+189 -189
View File
@@ -57,37 +57,37 @@ __metadata:
languageName: node
linkType: hard
"@babel/core@npm:7.14.6, @babel/core@npm:^7.1.0, @babel/core@npm:^7.14.6, @babel/core@npm:^7.7.2, @babel/core@npm:^7.7.5":
version: 7.14.6
resolution: "@babel/core@npm:7.14.6"
"@babel/core@npm:7.14.8, @babel/core@npm:^7.1.0, @babel/core@npm:^7.14.6, @babel/core@npm:^7.14.8, @babel/core@npm:^7.7.2, @babel/core@npm:^7.7.5":
version: 7.14.8
resolution: "@babel/core@npm:7.14.8"
dependencies:
"@babel/code-frame": ^7.14.5
"@babel/generator": ^7.14.5
"@babel/generator": ^7.14.8
"@babel/helper-compilation-targets": ^7.14.5
"@babel/helper-module-transforms": ^7.14.5
"@babel/helpers": ^7.14.6
"@babel/parser": ^7.14.6
"@babel/helper-module-transforms": ^7.14.8
"@babel/helpers": ^7.14.8
"@babel/parser": ^7.14.8
"@babel/template": ^7.14.5
"@babel/traverse": ^7.14.5
"@babel/types": ^7.14.5
"@babel/traverse": ^7.14.8
"@babel/types": ^7.14.8
convert-source-map: ^1.7.0
debug: ^4.1.0
gensync: ^1.0.0-beta.2
json5: ^2.1.2
semver: ^6.3.0
source-map: ^0.5.0
checksum: 6ede604d8de7a103c087b96a58548a3d27efb9e53de6ecc84f4b4ca947cd91f02b0289fc04557b04eb6e31243dbeabdcdb8fd520a1780f284333f56eb1b58913
checksum: 4c9a5b21020791659095a514f11c81159a96477037682183f23a1084732e0e3dbb58986e14ebf3a03a31230a75d8b2e1d23644ca84204eddf70018cba983035f
languageName: node
linkType: hard
"@babel/generator@npm:^7.14.5, @babel/generator@npm:^7.7.2":
version: 7.14.5
resolution: "@babel/generator@npm:7.14.5"
"@babel/generator@npm:^7.14.8, @babel/generator@npm:^7.7.2":
version: 7.14.8
resolution: "@babel/generator@npm:7.14.8"
dependencies:
"@babel/types": ^7.14.5
"@babel/types": ^7.14.8
jsesc: ^2.5.1
source-map: ^0.5.0
checksum: 7fcfeaf17e8e76ea91c66dc86c776d2112f52ce0315d3f4ca6a74b6eada0be1592d1ea6286d7241d3f634b63717ceef5d180d041a0b3dca9d071ba2e5fa7c77b
checksum: 0fdec7e1991fc3973d241e4c5e7d69f8c4ab063359695e6a019e4a5a0139a768ddce91d0705d7bd8a28f3befb5abde68355e19745fcdb45c40a26cf53d879191
languageName: node
linkType: hard
@@ -226,19 +226,19 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-module-transforms@npm:^7.14.5":
version: 7.14.5
resolution: "@babel/helper-module-transforms@npm:7.14.5"
"@babel/helper-module-transforms@npm:^7.14.5, @babel/helper-module-transforms@npm:^7.14.8":
version: 7.14.8
resolution: "@babel/helper-module-transforms@npm:7.14.8"
dependencies:
"@babel/helper-module-imports": ^7.14.5
"@babel/helper-replace-supers": ^7.14.5
"@babel/helper-simple-access": ^7.14.5
"@babel/helper-simple-access": ^7.14.8
"@babel/helper-split-export-declaration": ^7.14.5
"@babel/helper-validator-identifier": ^7.14.5
"@babel/helper-validator-identifier": ^7.14.8
"@babel/template": ^7.14.5
"@babel/traverse": ^7.14.5
"@babel/types": ^7.14.5
checksum: f5d64c0242ec8949ee09069a634d28ae750ab22f9533ea90eab9eaf3405032a33b0b329a63fac0a7901482efb8a388a06279f7544225a0bc3c1b92b306ab2b6e
"@babel/traverse": ^7.14.8
"@babel/types": ^7.14.8
checksum: 527b3383c40788b04c815da1ded4ac8cdc21e3356517fc81bcd03b319c1b58901638bb641a6f0cd00f493c7a31a8ae7123213d59c1d4f57cec32185b5d9f79a2
languageName: node
linkType: hard
@@ -281,12 +281,12 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-simple-access@npm:^7.14.5":
version: 7.14.5
resolution: "@babel/helper-simple-access@npm:7.14.5"
"@babel/helper-simple-access@npm:^7.14.5, @babel/helper-simple-access@npm:^7.14.8":
version: 7.14.8
resolution: "@babel/helper-simple-access@npm:7.14.8"
dependencies:
"@babel/types": ^7.14.5
checksum: cd795416bd10dd2f1bdebb36f1af08bf263024fdbf789cfda5dd1fbf4fea1fd0375e21d0bcb910a7d49b09b7480340797dcdfc888fbc895aeae45c145358ad75
"@babel/types": ^7.14.8
checksum: c1dae88c956154c854bb1679d19b9158ff1c8241329a4a70026ec16c594b9637e73647e5a1a0f9b7c47b2309201f633c259fb41d06a800496283debce6a67fab
languageName: node
linkType: hard
@@ -308,10 +308,10 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-validator-identifier@npm:^7.14.5":
version: 7.14.5
resolution: "@babel/helper-validator-identifier@npm:7.14.5"
checksum: 6366bceab4498785defc083a1bd96344f788d90a1aa7a6f18d6813c1d3d134640bfc05690453c0b79bbfc820472cf5b29110dfddaca1f8e2763dfe1bd5df0b88
"@babel/helper-validator-identifier@npm:^7.14.5, @babel/helper-validator-identifier@npm:^7.14.8":
version: 7.14.8
resolution: "@babel/helper-validator-identifier@npm:7.14.8"
checksum: f21ad9a9f0a66a02e0e5f62d505cbeb9e01a7ac5bd34be0af9f916f0b6d8d40718efaf51b656b41759e3454703090b4d386105f1f97f6598ee5a3f8eb98adc6a
languageName: node
linkType: hard
@@ -334,14 +334,14 @@ __metadata:
languageName: node
linkType: hard
"@babel/helpers@npm:^7.14.6":
version: 7.14.6
resolution: "@babel/helpers@npm:7.14.6"
"@babel/helpers@npm:^7.14.8":
version: 7.14.8
resolution: "@babel/helpers@npm:7.14.8"
dependencies:
"@babel/template": ^7.14.5
"@babel/traverse": ^7.14.5
"@babel/types": ^7.14.5
checksum: fe4e73975b062a8b8b95f499f4ac1064c9a53d4ee83cc273c2420250f6a46b59f1f5e35050d41ebe04efd7885a28ceea6f4f16d8eb091e24622f2a4a5eb20f23
"@babel/traverse": ^7.14.8
"@babel/types": ^7.14.8
checksum: 2f1358c19fc1ee744c183f81b499b73977da7d3d3f7a881d457b235754394a503e4717353f29364bd5feb7fa406b1edd1aab92b5ab0765dba945fb559eeb1c65
languageName: node
linkType: hard
@@ -356,12 +356,12 @@ __metadata:
languageName: node
linkType: hard
"@babel/parser@npm:^7.0.0, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.6, @babel/parser@npm:^7.7.2":
version: 7.14.7
resolution: "@babel/parser@npm:7.14.7"
"@babel/parser@npm:^7.0.0, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.5, @babel/parser@npm:^7.14.8, @babel/parser@npm:^7.7.2":
version: 7.14.8
resolution: "@babel/parser@npm:7.14.8"
bin:
parser: ./bin/babel-parser.js
checksum: 0d7acc8cf9c19ccd0e80ab0608953f32f4375f3867c080211270e7bb4bb94c551fd1fc3f49b3cc92a4eec356cf507801f5c93c4c72996968bdc4c28815fe0550
checksum: 9e532b2bbe690fff8cdaf8c25cfecb684ebe9e9d50d30cd775852dd711649ddb964368b26fda55786404fadf500f944043fb0f731b765104ad857d677dd29ce5
languageName: node
linkType: hard
@@ -1360,12 +1360,12 @@ __metadata:
languageName: node
linkType: hard
"@babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.8.4":
version: 7.14.6
resolution: "@babel/runtime@npm:7.14.6"
"@babel/runtime@npm:^7.14.6, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.8.4":
version: 7.14.8
resolution: "@babel/runtime@npm:7.14.8"
dependencies:
regenerator-runtime: ^0.13.4
checksum: 927ffed7871f2ed29f967a8dad7a72aa10662f93b6735a89d664a161fa4dc2074b8947ca159a8a0a49cec9a71c8de473d7c2b22d3de0ee4d7dd06d24a7f98018
checksum: d2dd0ce51ddab78ac93928b04042425145d0dc8cc2b70150d47934f8703f55702eb0b2894f9bd47f66794ad04d8bb03a6a847d0138fbb7aa0b970b5ccd5cc8b7
languageName: node
linkType: hard
@@ -1380,30 +1380,30 @@ __metadata:
languageName: node
linkType: hard
"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.14.5, @babel/traverse@npm:^7.7.2":
version: 7.14.5
resolution: "@babel/traverse@npm:7.14.5"
"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.14.5, @babel/traverse@npm:^7.14.8, @babel/traverse@npm:^7.7.2":
version: 7.14.8
resolution: "@babel/traverse@npm:7.14.8"
dependencies:
"@babel/code-frame": ^7.14.5
"@babel/generator": ^7.14.5
"@babel/generator": ^7.14.8
"@babel/helper-function-name": ^7.14.5
"@babel/helper-hoist-variables": ^7.14.5
"@babel/helper-split-export-declaration": ^7.14.5
"@babel/parser": ^7.14.5
"@babel/types": ^7.14.5
"@babel/parser": ^7.14.8
"@babel/types": ^7.14.8
debug: ^4.1.0
globals: ^11.1.0
checksum: 3f4cf5ed685db7fef76d4242cbb14d111db0ea0a7cca163edd29e09ace13312ce085595e7d90fedae2e14e40448a116c222b1060e1c799b87266b8ed92492a3d
checksum: f635f99b1b09dfe60105bb162103346f78e058351231e33e9c11a17fabf6d56b4f87837ad14a0f82242c6dd0b97fecd90064735f1e11d47b7429a1c3e99a5ece
languageName: node
linkType: hard
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.14.5, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3":
version: 7.14.5
resolution: "@babel/types@npm:7.14.5"
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.14.5, @babel/types@npm:^7.14.8, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3":
version: 7.14.8
resolution: "@babel/types@npm:7.14.8"
dependencies:
"@babel/helper-validator-identifier": ^7.14.5
"@babel/helper-validator-identifier": ^7.14.8
to-fast-properties: ^2.0.0
checksum: 7c1ab6e8bdf438d44236034cab10f7d0f1971179bc405dca26733a9b89dd87dd692dc49a238a7495075bc41a9a17fb6f08b4d1da45ea6ddcce1e5c8593574aea
checksum: d4ebd2e0e52f05cbcb3ded434d9fb49db73c239d98c4f7bd27beaf32fcd7c81aa30618237e87d53505d5e65fd20d688cb4237b6fa927a04831129a6044f2e4b5
languageName: node
linkType: hard
@@ -1866,43 +1866,43 @@ __metadata:
version: 0.0.0-use.local
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/api": 5.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/api": 5.2.1
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
rxjs: ^7.2.0
languageName: unknown
linkType: soft
"@polkadot/api-derive@5.0.1, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@5.2.1, @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.14.6
"@polkadot/api": 5.0.1
"@polkadot/keyring": ^7.0.1
"@polkadot/rpc-core": 5.0.1
"@polkadot/rpc-provider": 5.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@polkadot/util-crypto": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/api": 5.2.1
"@polkadot/keyring": ^7.0.3
"@polkadot/rpc-core": 5.2.1
"@polkadot/rpc-provider": 5.2.1
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
"@polkadot/util-crypto": ^7.0.3
rxjs: ^7.2.0
languageName: unknown
linkType: soft
"@polkadot/api@5.0.1, @polkadot/api@workspace:packages/api":
"@polkadot/api@5.2.1, @polkadot/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@polkadot/api@workspace:packages/api"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/api-derive": 5.0.1
"@polkadot/keyring": ^7.0.1
"@polkadot/rpc-core": 5.0.1
"@polkadot/rpc-provider": 5.0.1
"@polkadot/types": 5.0.1
"@polkadot/types-known": 5.0.1
"@polkadot/util": ^7.0.1
"@polkadot/util-crypto": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/api-derive": 5.2.1
"@polkadot/keyring": ^7.0.3
"@polkadot/rpc-core": 5.2.1
"@polkadot/rpc-provider": 5.2.1
"@polkadot/types": 5.2.1
"@polkadot/types-known": 5.2.1
"@polkadot/util": ^7.0.3
"@polkadot/util-crypto": ^7.0.3
eventemitter3: ^4.0.7
rxjs: ^7.2.0
languageName: unknown
@@ -2001,54 +2001,54 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/keyring@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/keyring@npm:7.0.1"
"@polkadot/keyring@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/keyring@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/util": 7.0.1
"@polkadot/util-crypto": 7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/util": 7.0.3
"@polkadot/util-crypto": 7.0.3
peerDependencies:
"@polkadot/util": 7.0.1
"@polkadot/util-crypto": 7.0.1
checksum: 84e18c48823087df1347edae92080fb19dc83ef53f2559c9529faaa5e89f9af6cd7df7e762826b23f88e0a39f34f47dbd9cd0ac43c8299c59201313608bf8a4c
"@polkadot/util": 7.0.3
"@polkadot/util-crypto": 7.0.3
checksum: 6fd48479318c86059a6647d546443f694b5aa34da35dacdc470656773d2c36a3c486f517480f26aa64fa881be8d2c9ba67ee54dfca13b0e94cffd00ee9d6674f
languageName: node
linkType: hard
"@polkadot/networks@npm:7.0.1, @polkadot/networks@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/networks@npm:7.0.1"
"@polkadot/networks@npm:7.0.3, @polkadot/networks@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/networks@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
checksum: 85af50564e31ba181c4f1851c938fad148627df99651c966352359a95e85b8e0d7f41d9775ad4f056c81e7a455f011fb70b2e2130f45836851d5018b85bb8bd4
"@babel/runtime": ^7.14.8
checksum: 774cf76beaef69321abc648b0b254ce4bf94001445ce4139b4ff5cf649060187e27425e737602ad4b8385492ad1dffc9ff53a200d8f2f75382659e461fc00620
languageName: node
linkType: hard
"@polkadot/rpc-core@5.0.1, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@5.2.1, @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.14.6
"@polkadot/keyring": ^7.0.1
"@polkadot/rpc-provider": 5.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/keyring": ^7.0.3
"@polkadot/rpc-provider": 5.2.1
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
rxjs: ^7.2.0
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@5.0.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@5.2.1, @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.14.6
"@polkadot/keyring": ^7.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@polkadot/util-crypto": ^7.0.1
"@polkadot/x-fetch": ^7.0.1
"@polkadot/x-global": ^7.0.1
"@polkadot/x-ws": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/keyring": ^7.0.3
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
"@polkadot/util-crypto": ^7.0.3
"@polkadot/x-fetch": ^7.0.3
"@polkadot/x-global": ^7.0.3
"@polkadot/x-ws": ^7.0.3
eventemitter3: ^4.0.7
mock-socket: ^9.0.3
nock: ^13.1.1
@@ -2068,13 +2068,13 @@ __metadata:
version: 0.0.0-use.local
resolution: "@polkadot/typegen@workspace:packages/typegen"
dependencies:
"@babel/core": ^7.14.6
"@babel/core": ^7.14.8
"@babel/register": ^7.14.5
"@babel/runtime": ^7.14.6
"@polkadot/api": 5.0.1
"@polkadot/rpc-provider": 5.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/api": 5.2.1
"@polkadot/rpc-provider": 5.2.1
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
"@types/websocket": ^1.0.3
"@types/yargs": ^17.0.2
handlebars: ^4.7.7
@@ -2089,40 +2089,40 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-known@5.0.1, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@5.2.1, @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.14.6
"@polkadot/networks": ^7.0.1
"@polkadot/types": 5.0.1
"@polkadot/util": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/networks": ^7.0.3
"@polkadot/types": 5.2.1
"@polkadot/util": ^7.0.3
languageName: unknown
linkType: soft
"@polkadot/types@5.0.1, @polkadot/types@workspace:packages/types":
"@polkadot/types@5.2.1, @polkadot/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@polkadot/types@workspace:packages/types"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/keyring": ^7.0.1
"@polkadot/util": ^7.0.1
"@polkadot/util-crypto": ^7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/keyring": ^7.0.3
"@polkadot/util": ^7.0.3
"@polkadot/util-crypto": ^7.0.3
"@types/bn.js": ^4.11.6
bn.js: ^4.11.9
rxjs: ^7.2.0
languageName: unknown
linkType: soft
"@polkadot/util-crypto@npm:7.0.1, @polkadot/util-crypto@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/util-crypto@npm:7.0.1"
"@polkadot/util-crypto@npm:7.0.3, @polkadot/util-crypto@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/util-crypto@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/networks": 7.0.1
"@polkadot/util": 7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/networks": 7.0.3
"@polkadot/util": 7.0.3
"@polkadot/wasm-crypto": ^4.1.2
"@polkadot/x-randomvalues": 7.0.1
"@polkadot/x-randomvalues": 7.0.3
base-x: ^3.0.8
base64-js: ^1.5.1
blakejs: ^1.1.1
@@ -2135,23 +2135,23 @@ __metadata:
tweetnacl: ^1.0.3
xxhashjs: ^0.2.2
peerDependencies:
"@polkadot/util": 7.0.1
checksum: 177308a3a7a23880e83516eb8e099259fa35b9700d1a8ba2008a6e426d4fe78b0c4f63462e4c158e8e1c0f7969eb00159b4db5acb7cb3bb1a5a9c8740ca55796
"@polkadot/util": 7.0.3
checksum: f1d34c36f337486cc45e501c12268de6a037bd89100e929c3775b2d7162ec3b2ad984991fc8817455bc418d53adb0273c24a898e97d9efaa6a6e3de2828b8890
languageName: node
linkType: hard
"@polkadot/util@npm:7.0.1, @polkadot/util@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/util@npm:7.0.1"
"@polkadot/util@npm:7.0.3, @polkadot/util@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/util@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-textdecoder": 7.0.1
"@polkadot/x-textencoder": 7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/x-textdecoder": 7.0.3
"@polkadot/x-textencoder": 7.0.3
"@types/bn.js": ^4.11.6
bn.js: ^4.11.9
camelcase: ^5.3.1
ip-regex: ^4.3.0
checksum: 85dcdf27f492652aa6a720c9925ba5e72b616f3b92260cba61d27b4aecc221207548c47a60b6bc715ce89dfb4ec4a0f30410cb556752326f529ed823ec8cfccb
checksum: e72d3d292e458d1c025922760b91b46dfd2c61f326747ff68435887e275bac9e1d3f1fd66fadf1d02c8664f7479de73e6a8c7ddb9394c039181d43c94bd65287
languageName: node
linkType: hard
@@ -2187,66 +2187,66 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/x-fetch@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/x-fetch@npm:7.0.1"
"@polkadot/x-fetch@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/x-fetch@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-global": 7.0.1
"@types/node-fetch": ^2.5.11
"@babel/runtime": ^7.14.8
"@polkadot/x-global": 7.0.3
"@types/node-fetch": ^2.5.12
node-fetch: ^2.6.1
checksum: cd1a53243da5063a1b0fd428e7bb11b9c2a9168079455f64b90189c6ef4738a8150305c2d244cfff8d2b2f7c15cf961d32f2521cf37523013a94dc778743b7a6
checksum: 00ecb052395fb519b81cd4f7b7e69b89bf6e9b4592f8b7a1bb57c773d53b5d3203607869ab02ddc123ffa2f3186e2fd8d5c7ec86dc0f13c9f2977b795ec3ee10
languageName: node
linkType: hard
"@polkadot/x-global@npm:7.0.1, @polkadot/x-global@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/x-global@npm:7.0.1"
"@polkadot/x-global@npm:7.0.3, @polkadot/x-global@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/x-global@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
checksum: 6ea6f2068d0a01535e762fdd9a4202b2eb5d3ab3225ef4ecfe51d3d3728198a66bff6cf64776a6a2a06620379b13761b86b31a23fc68332946c0a991b8cb5f43
"@babel/runtime": ^7.14.8
checksum: 1a3cd2ca683c7afc8bc29eb036eb2b0cd96df366041d2f5dff4135507172f72a53289c4cef23b7023a9ee48b2b031a5bbb52fcee29871905bf14d67a75a186c2
languageName: node
linkType: hard
"@polkadot/x-randomvalues@npm:7.0.1":
version: 7.0.1
resolution: "@polkadot/x-randomvalues@npm:7.0.1"
"@polkadot/x-randomvalues@npm:7.0.3":
version: 7.0.3
resolution: "@polkadot/x-randomvalues@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-global": 7.0.1
checksum: cc3a5041e40b56c948727643cbf7d05b483272c1740ffad6db773044d55d1ed2ae60f0b996ff6ecd356df3ca2ba6755a23ffa0b66fda582742add33d713c4076
"@babel/runtime": ^7.14.8
"@polkadot/x-global": 7.0.3
checksum: 3cc53437db3de937f1d0c15245d2737276920a9f4e88408ef56c92ebc4f5642c4e179f176b4e38c8b2d5dd2ce40f473d0d629e4224dc615484078c7a0eac61ef
languageName: node
linkType: hard
"@polkadot/x-textdecoder@npm:7.0.1":
version: 7.0.1
resolution: "@polkadot/x-textdecoder@npm:7.0.1"
"@polkadot/x-textdecoder@npm:7.0.3":
version: 7.0.3
resolution: "@polkadot/x-textdecoder@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-global": 7.0.1
checksum: b051eea9c1918e175578da30d022074c6890d71d9e45cffcc1d1af99b887a4fc42f7053770f34b7ff5989cd05c4867f50d7a734728cf4bfca05d1c9d31f24ff5
"@babel/runtime": ^7.14.8
"@polkadot/x-global": 7.0.3
checksum: ba517cadb6438e5eb2080daa2cb158d79bbe8a3c2eb37f2d82cf55b2e965426fb5a51e82487a35976df8fdb70b42ec9d53101cbf33ac9a6ca811a1a87e2296f8
languageName: node
linkType: hard
"@polkadot/x-textencoder@npm:7.0.1":
version: 7.0.1
resolution: "@polkadot/x-textencoder@npm:7.0.1"
"@polkadot/x-textencoder@npm:7.0.3":
version: 7.0.3
resolution: "@polkadot/x-textencoder@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-global": 7.0.1
checksum: 10384f54969bd0690ccbbf0a56dfd93e80dc5126a01bc0fa9ffafca3c64dec17178ec8596b053992ced5465fb6e074a8694fe5d58fd5f50e0ea693b2ed6cd183
"@babel/runtime": ^7.14.8
"@polkadot/x-global": 7.0.3
checksum: 090a3894fc9c8921f73f0bfc86da0f298af503bf986694e7fde2524dab3562b627136685a33498b02f5a6e8c0ae5d8f8ec3b551db49b3e218ce0ef72cad35996
languageName: node
linkType: hard
"@polkadot/x-ws@npm:^7.0.1":
version: 7.0.1
resolution: "@polkadot/x-ws@npm:7.0.1"
"@polkadot/x-ws@npm:^7.0.3":
version: 7.0.3
resolution: "@polkadot/x-ws@npm:7.0.3"
dependencies:
"@babel/runtime": ^7.14.6
"@polkadot/x-global": 7.0.1
"@babel/runtime": ^7.14.8
"@polkadot/x-global": 7.0.3
"@types/websocket": ^1.0.3
websocket: ^1.0.34
checksum: de25547a83c9ff212b3254ea4b9a44efda6bc5b2f091c2567b9388d9a7d1d6f0906ce9e335880aa676752dde0dfef22a7c3c4b079c5fa25ddd54e55cbff51ce1
checksum: cf40adce17f014f91c49d1b25760dbe2ba7ac1a99fb7c62ed1416d5ccf85fd74b96043859a5c425b67982f9ab01abaf43b3116efaa157a7eb6fb66e4c1beef4f
languageName: node
linkType: hard
@@ -2510,13 +2510,13 @@ __metadata:
languageName: node
linkType: hard
"@types/jest@npm:^26.0.23":
version: 26.0.23
resolution: "@types/jest@npm:26.0.23"
"@types/jest@npm:^26.0.24":
version: 26.0.24
resolution: "@types/jest@npm:26.0.24"
dependencies:
jest-diff: ^26.0.0
pretty-format: ^26.0.0
checksum: 69db26061e6be34de2a440c8a470b651c53ba6ee0057614a278c4f756ff00281f46cc075b24e5bd761f399f175f49d0a5758b50dd921342a8592461548dea29a
checksum: ae39675412f08d884926254e9b12bfd2b5a4e4d204c94d3148cb942174a474930d0c60540133c968f22241d4712b7940c96cbc883096eb326a4d5b206fb78bd0
languageName: node
linkType: hard
@@ -2543,13 +2543,13 @@ __metadata:
languageName: node
linkType: hard
"@types/node-fetch@npm:^2.5.11":
version: 2.5.11
resolution: "@types/node-fetch@npm:2.5.11"
"@types/node-fetch@npm:^2.5.12":
version: 2.5.12
resolution: "@types/node-fetch@npm:2.5.12"
dependencies:
"@types/node": "*"
form-data: ^3.0.0
checksum: a52ee9a205ce3130404a1c8eb0a163aa013fb94c5c93150735dda55bd4d21a556713834b11f6f031721ad7c82d9d7f77d45436010cefc11e851f518dfeeaca3e
checksum: ad63c85ba6a9477b8e057ec8682257738130d98e8ece4e31141789bd99df9d9147985cc8bc0cb5c8983ed5aa6bb95d46df23d1e055f4ad5cf8b82fc69cf626c7
languageName: node
linkType: hard
@@ -9602,13 +9602,13 @@ resolve@^2.0.0-next.3:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@babel/core": ^7.14.6
"@babel/core": ^7.14.8
"@babel/register": ^7.14.5
"@babel/runtime": ^7.14.6
"@babel/runtime": ^7.14.8
"@polkadot/dev": ^0.62.57
"@polkadot/ts": ^0.4.4
"@polkadot/typegen": "workspace:packages/typegen"
"@types/jest": ^26.0.23
"@types/jest": ^26.0.24
copyfiles: ^2.4.1
languageName: unknown
linkType: soft