Compare commits

..
14 Commits
Author SHA1 Message Date
Github Actions 878f631745 [CI Skip] release/stable 6.1.1
skip-checks: true
2021-09-27 05:54:41 +00:00
Jaco d7753839a2 6.1.1 (#3994)
* 6.1.1

* bumps
2021-09-27 07:36:47 +02:00
Github Actions fc74d88bbb [CI Skip] release/beta 6.0.6-4
skip-checks: true
2021-09-24 08:24:35 +00:00
HackFisher 47bbeee14b fix OutboundLaneData types (#3992) 2021-09-24 10:05:56 +02:00
Github Actions ba01620ba1 [CI Skip] release/beta 6.0.6-3
skip-checks: true
2021-09-23 09:30:55 +00:00
Jaco 6e66387a8d CHANGELOG (#3986) 2021-09-23 11:10:10 +02:00
Github Actions c58687b3c6 [CI Skip] release/beta 6.0.6-2
skip-checks: true
2021-09-22 09:22:01 +00:00
Jaco 2801088b0a Scale-info v0 -> v1 conversion (as needed by contracts) (#3987)
* Scale-info v0 -> v1 conversion (as needed by contracts)

* Renames

* V1 types same as v0 where applicable
2021-09-22 11:01:39 +02:00
Github Actions fc5af92a03 [CI Skip] release/beta 6.0.6-1
skip-checks: true
2021-09-22 04:07:20 +00:00
Furqan A 8f8bb2aa23 fix: fixed 404 to the docs from the api readme (#3985) 2021-09-22 06:48:18 +03:00
Github Actions 3f69b3fc73 [CI Skip] release/beta 6.0.6-0
skip-checks: true
2021-09-20 18:48:01 +00:00
Jaco 4ea170a83a Add childstate_getStorageEntries RPC (#3980)
* Add `childstate_getStorageEntries` RPC

* Remove extra ,
2021-09-20 20:33:30 +02:00
Github Actions 26649c429a [CI Skip] release/stable 6.0.5
skip-checks: true
2021-09-20 13:57:16 +00:00
Jaco 7c57778389 6.0.5 (#3977) 2021-09-20 15:38:54 +02:00
41 changed files with 1081 additions and 1529 deletions
+2 -1
View File
@@ -32,4 +32,5 @@
6.0.2
6.0.3
6.0.4
6.0.4
6.0.5
+23
View File
@@ -1,5 +1,28 @@
# CHANGELOG
## 6.1.1 Sep 27, 2021
Contributed:
- Adjust bridges `OutboundLaneData` type (Thanks to https://github.com/HackFisher)
- Fix README 404 (Thanks to https://github.com/nblogist)
Changes:
- Add `childstate_getStorageEntries` RPC
- Allow for scale-info v0 -> v1 conversion
## 6.0.5 Sep 20, 2021
Upgrade priority: Low. Recommended for all users on 6.0.4 using `api.query.*.*.at` calls
Changes:
- Revert cross-registry (now-inactive) change introduced in 6.0.3
- Ensure `Option` is correctly imported for TS query generation
## 6.0.4 Sep 20, 2021
Upgrade priority: Low. Recommended for all users on 6.0.3 using `api.query.*.*.at` calls
+3 -3
View File
@@ -29,12 +29,12 @@
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/dev": "^0.62.67",
"@polkadot/dev": "^0.62.68",
"@polkadot/ts": "^0.4.8",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^27.0.1",
"@types/jest": "^27.0.2",
"copyfiles": "^2.4.1"
},
"version": "6.0.4",
"version": "6.1.1",
"packageManager": "yarn@3.0.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.4",
"@polkadot/types": "6.0.4",
"@polkadot/api": "6.1.1",
"@polkadot/types": "6.1.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.1.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -20,15 +20,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.4",
"@polkadot/rpc-core": "6.0.4",
"@polkadot/types": "6.0.4",
"@polkadot/api": "6.1.1",
"@polkadot/rpc-core": "6.1.1",
"@polkadot/types": "6.1.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-provider": "6.0.4"
"@polkadot/rpc-provider": "6.1.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: '6.0.4' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.1.1' };
+4 -4
View File
@@ -7,13 +7,13 @@ The API wrappers provide a standard interface for use -
- A static `.create(<optional ApiOptions>)` that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions `{ provider: <Optional WsProvider>, types: <Optional RegistryTypes> }`.
- The above is just a wrapper for `new Api(<optional ApiOptions>) `, exposing the `isReady` getter
- `api.rpc.<section>.<method>` provides access to actual RPC calls, be it for queries, submission or retrieving chain information
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc.html)
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc)
- `api.query.<section>.<method>` provides access to chain state queries. These are dynamically populated based on what the runtime provides
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage.html)
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage)
- `api.tx.<section>.<method>` provides the ability to create a transaction, like chain state, this list is populated from a runtime query
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics.html)
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics)
- `api.consts.<section>.<constant>` provides access to the module constants (parameter types).
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants.html)
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants)
## API Selection
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -20,12 +20,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.0.4",
"@polkadot/api-derive": "6.1.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-core": "6.0.4",
"@polkadot/rpc-provider": "6.0.4",
"@polkadot/types": "6.0.4",
"@polkadot/types-known": "6.0.4",
"@polkadot/rpc-core": "6.1.1",
"@polkadot/rpc-provider": "6.1.1",
"@polkadot/types": "6.1.1",
"@polkadot/types-known": "6.1.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"eventemitter3": "^4.0.7",
+4
View File
@@ -113,6 +113,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns a child storage entry at a specific block state
**/
getStorage: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<StorageData>>>;
/**
* Returns child storage entries for multiple keys at a specific block state
**/
getStorageEntries: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: Hash | string | Uint8Array) => Observable<Vec<Option<StorageData>>>>;
/**
* Returns the hash of a child storage entry at a block state
**/
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/api', version: '6.1.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.0.4",
"@polkadot/types": "6.0.4",
"@polkadot/rpc-provider": "6.1.1",
"@polkadot/types": "6.1.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.1.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -20,7 +20,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.0.4",
"@polkadot/types": "6.1.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"@polkadot/x-fetch": "^7.4.1",
@@ -30,7 +30,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types": "6.0.4",
"@polkadot/types": "6.1.1",
"mock-socket": "^9.0.3",
"nock": "^13.1.3"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.1.1' };
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -29,17 +29,17 @@
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.0.4",
"@polkadot/rpc-provider": "6.0.4",
"@polkadot/types": "6.0.4",
"@polkadot/types-support": "6.0.4",
"@polkadot/api": "6.1.1",
"@polkadot/rpc-provider": "6.1.1",
"@polkadot/types": "6.1.1",
"@polkadot/types-support": "6.1.1",
"@polkadot/util": "^7.4.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.1.1"
"yargs": "^17.2.1"
},
"devDependencies": {
"@types/websocket": "^1.0.4",
"@types/yargs": "^17.0.2"
"@types/yargs": "^17.0.3"
}
}
+9 -1
View File
@@ -24,7 +24,12 @@ function entrySignature (lookup: PortableRegistry, allDefs: Record<string, Modul
if (storageEntry.type.isPlain) {
const typeDef = lookup.getTypeDef(storageEntry.type.asPlain);
setImports(allDefs, imports, [typeDef.lookupName || typeDef.type]);
setImports(allDefs, imports, [
typeDef.lookupName || typeDef.type,
storageEntry.modifier.isOptional
? 'Option'
: null
]);
return [storageEntry.modifier.isOptional, '', '', formatType(registry, allDefs, outputType, imports)];
} else if (storageEntry.type.isMap) {
@@ -38,6 +43,9 @@ function entrySignature (lookup: PortableRegistry, allDefs: Record<string, Modul
setImports(allDefs, imports, [
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
storageEntry.modifier.isOptional
? 'Option'
: null,
defValue.lookupName
? undefined
: defValue.type
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/typegen', version: '6.1.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Known type definitions",
"main": "index.js",
@@ -21,7 +21,7 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/networks": "^7.4.1",
"@polkadot/types": "6.0.4",
"@polkadot/types": "6.1.1",
"@polkadot/util": "^7.4.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/types-known', version: '6.1.1' };
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-support",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Supporting files for types, mostly for testing",
"main": "index.js",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-support', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/types-support', version: '6.1.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "6.0.4",
"version": "6.1.1",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -26,7 +26,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types-support": "6.0.4",
"@polkadot/types-support": "6.1.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.12.0"
}
+19 -2
View File
@@ -32,7 +32,7 @@ import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, A
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityInfoTo198, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement, RegistrationTo198 } from '@polkadot/types/interfaces/identity';
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableType, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableRegistryV14, PortableType, PortableTypeV14, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
@@ -44,7 +44,7 @@ import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, AccountId20, AccountId32, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, Si1Field, Si1LookupTypeId, Si1Path, Si1Type, Si1TypeDef, Si1TypeDefArray, Si1TypeDefBitSequence, Si1TypeDefCompact, Si1TypeDefComposite, Si1TypeDefPrimitive, Si1TypeDefSequence, Si1TypeDefTuple, Si1TypeDefVariant, Si1TypeParameter, Si1Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
@@ -676,7 +676,9 @@ declare module '@polkadot/types/types/registry' {
PhragmenScore: PhragmenScore;
Points: Points;
PortableRegistry: PortableRegistry;
PortableRegistryV14: PortableRegistryV14;
PortableType: PortableType;
PortableTypeV14: PortableTypeV14;
Precommits: Precommits;
PrefabWasmModule: PrefabWasmModule;
PrefixedStorageKey: PrefixedStorageKey;
@@ -813,6 +815,21 @@ declare module '@polkadot/types/types/registry' {
Si0TypeDefVariant: Si0TypeDefVariant;
Si0TypeParameter: Si0TypeParameter;
Si0Variant: Si0Variant;
Si1Field: Si1Field;
Si1LookupTypeId: Si1LookupTypeId;
Si1Path: Si1Path;
Si1Type: Si1Type;
Si1TypeDef: Si1TypeDef;
Si1TypeDefArray: Si1TypeDefArray;
Si1TypeDefBitSequence: Si1TypeDefBitSequence;
Si1TypeDefCompact: Si1TypeDefCompact;
Si1TypeDefComposite: Si1TypeDefComposite;
Si1TypeDefPrimitive: Si1TypeDefPrimitive;
Si1TypeDefSequence: Si1TypeDefSequence;
Si1TypeDefTuple: Si1TypeDefTuple;
Si1TypeDefVariant: Si1TypeDefVariant;
Si1TypeParameter: Si1TypeParameter;
Si1Variant: Si1Variant;
SiField: SiField;
Signature: Signature;
SignedAvailabilityBitfield: SignedAvailabilityBitfield;
+1 -3
View File
@@ -3,7 +3,7 @@
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, CodecHash, DispatchErrorModule, Hash, MetadataLatest, PortableRegistry, SiLookupTypeId } from '../interfaces/types';
import type { CallFunction, Codec, CodecHasher, Constructor, DetectCodec, DetectConstructor, RegisteredTypes, Registry, RegistryError, RegistryTypes, TypeSpec } from '../types';
import type { CallFunction, Codec, CodecHasher, Constructor, DetectCodec, DetectConstructor, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
import type { CreateOptions } from './types';
import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, stringify, u8aToHex } from '@polkadot/util';
@@ -145,8 +145,6 @@ export class TypeRegistry implements Registry {
#userExtensions?: ExtDef;
public compatSpecs: TypeSpec[] = [];
public createdAtHash?: Hash;
constructor (createdAtHash?: Hash | Uint8Array | string) {
@@ -1,19 +1,18 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '../codec/Vec';
import type { PortableType } from '../interfaces/metadata';
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../interfaces/scaleInfo';
import type { Text } from '../primitive/Text';
import type { Type } from '../primitive/Type';
import type { Registry, TypeDef } from '../types';
import type { Vec } from '../../codec';
import type { PortableType } from '../../interfaces/metadata';
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '../../interfaces/scaleInfo';
import type { Text, Type } from '../../primitive';
import type { Registry, TypeDef } from '../../types';
import { assert, isNumber, isString, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util';
import { Struct } from '../codec/Struct';
import { withTypeString } from '../create/encodeTypes';
import { getTypeDef } from '../create/getTypeDef';
import { TypeDefInfo } from '../types';
import { Struct } from '../../codec/Struct';
import { withTypeString } from '../../create/encodeTypes';
import { getTypeDef } from '../../create/getTypeDef';
import { TypeDefInfo } from '../../types';
// Just a placeholder for a type.unrwapOr()
const TYPE_UNWRAP = { toNumber: () => -1 };
@@ -0,0 +1,5 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { GenericPortableRegistry } from './PortableRegistry';
export { toV1 as convertSiV0toV1 } from './toV1';
@@ -0,0 +1,133 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { PortableType, Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefComposite, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefVariant, Si1Field, Si1TypeDef } from '../../interfaces';
import type { Registry } from '../../types';
function convertArray (registry: Registry, { len, type }: Si0TypeDefArray): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Array: {
len,
type: type.toNumber()
}
});
}
function convertBitSequence (registry: Registry, { bitOrderType, bitStoreType }: Si0TypeDefBitSequence): Si1TypeDef {
return registry.createType('Si1TypeDef', {
BitSequence: {
bitOrderType: bitOrderType.toNumber(),
bitStoreType: bitStoreType.toNumber()
}
});
}
function convertCompact (registry: Registry, { type }: Si0TypeDefSequence): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Compact: {
type: type.toNumber()
}
});
}
function convertComposite (registry: Registry, { fields }: Si0TypeDefComposite): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Composite: {
fields: convertFields(registry, fields)
}
});
}
function convertFields (registry: Registry, fields: Si0Field[]): Si1Field[] {
return fields.map(({ docs, name, type, typeName }) =>
registry.createType('Si1Field', {
docs,
name,
type: type.toNumber(),
typeName
})
);
}
function convertPhantom (registry: Registry, path: Si0Path): Si1TypeDef {
console.warn(`Converting phantom type ${path.map((p) => p.toString()).join('::')} to empty tuple`);
return registry.createType('Si1TypeDef', {
Tuple: []
});
}
function convertPrimitive (registry: Registry, prim: Si0TypeDefPrimitive): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Primitive: prim.toString()
});
}
function convertSequence (registry: Registry, { type }: Si0TypeDefSequence): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Sequence: {
type: type.toNumber()
}
});
}
function convertTuple (registry: Registry, types: Si0LookupTypeId[]): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Tuple: types.map((t) => t.toNumber())
});
}
function convertVariant (registry: Registry, { variants }: Si0TypeDefVariant): Si1TypeDef {
return registry.createType('Si1TypeDef', {
Variant: {
variants: variants.map(({ discriminant, docs, fields, name }, index) =>
registry.createType('Si1Variant', {
docs,
fields: convertFields(registry, fields),
index: discriminant.isSome
? discriminant.unwrap().toNumber()
: index,
name
})
)
}
});
}
function convertDef (registry: Registry, { def, path }: Si0Type): Si1TypeDef {
if (def.isArray) {
return convertArray(registry, def.asArray);
} else if (def.isBitSequence) {
return convertBitSequence(registry, def.asBitSequence);
} else if (def.isCompact) {
return convertCompact(registry, def.asCompact);
} else if (def.isComposite) {
return convertComposite(registry, def.asComposite);
} else if (def.isPhantom) {
return convertPhantom(registry, path);
} else if (def.isPrimitive) {
return convertPrimitive(registry, def.asPrimitive);
} else if (def.isSequence) {
return convertSequence(registry, def.asSequence);
} else if (def.isTuple) {
return convertTuple(registry, def.asTuple);
} else if (def.isVariant) {
return convertVariant(registry, def.asVariant);
}
throw new Error(`Cannot convert type ${def.toString()}`);
}
export function toV1 (registry: Registry, types: Si0Type[]): PortableType[] {
return types.map((t, id) =>
registry.createType('PortableType', {
id,
type: {
def: convertDef(registry, t),
docs: [],
params: t.params.map((p) => p.toNumber()),
path: t.path.map((p) => p.toString())
}
})
);
}
@@ -66,9 +66,9 @@ export default {
_enum: ['Normal', 'RejectingOutboundMessages', 'Halted']
},
OutboundLaneData: {
latestGeneratedNonce: 'MessageNonce',
oldestUnprunedNonce: 'MessageNonce',
latestReceivedNonce: 'MessageNonce',
oldestUnprunedNonce: 'MessageNonce'
latestGeneratedNonce: 'MessageNonce'
},
OutboundMessageFee: 'Balance',
OutboundPayload: {
@@ -102,9 +102,9 @@ export interface OperatingMode extends Enum {
/** @name OutboundLaneData */
export interface OutboundLaneData extends Struct {
readonly latestGeneratedNonce: MessageNonce;
readonly latestReceivedNonce: MessageNonce;
readonly oldestUnprunedNonce: MessageNonce;
readonly latestReceivedNonce: MessageNonce;
readonly latestGeneratedNonce: MessageNonce;
}
/** @name OutboundMessageFee */
@@ -78,6 +78,26 @@ export default {
],
type: 'Option<StorageData>'
},
getStorageEntries: {
description: 'Returns child storage entries for multiple keys at a specific block state',
params: [
{
name: 'childKey',
type: 'PrefixedStorageKey'
},
{
name: 'keys',
type: 'Vec<StorageKey>'
},
{
name: 'at',
type: 'Hash',
isHistoric: true,
isOptional: true
}
],
type: 'Vec<Option<StorageData>>'
},
getStorageHash: {
description: 'Returns the hash of a child storage entry at a block state',
params: [
@@ -26,6 +26,10 @@ export default {
...v13,
...v14,
// registry mapping to latest
PortableRegistry: 'PortableRegistryV14',
PortableType: 'PortableTypeV14',
// latest mappings
ErrorMetadataLatest: 'ErrorMetadataV14',
EventMetadataLatest: 'EventMetadataV14',
@@ -2,7 +2,7 @@
/* eslint-disable */
import type { Bytes, Enum, GenericPortableRegistry, Option, Struct, Text, Type, Vec, bool, u8 } from '@polkadot/types';
import type { SiField, SiLookupTypeId, SiType } from '@polkadot/types/interfaces/scaleInfo';
import type { Si1Field, Si1LookupTypeId, Si1Type, SiLookupTypeId } from '@polkadot/types/interfaces/scaleInfo';
/** @name ErrorMetadataLatest */
export interface ErrorMetadataLatest extends ErrorMetadataV14 {}
@@ -22,7 +22,7 @@ export interface ErrorMetadataV13 extends ErrorMetadataV12 {}
/** @name ErrorMetadataV14 */
export interface ErrorMetadataV14 extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly fields: Vec<Si1Field>;
readonly index: u8;
readonly docs: Vec<Text>;
readonly args: Vec<Type>;
@@ -52,7 +52,7 @@ export interface EventMetadataV13 extends EventMetadataV12 {}
/** @name EventMetadataV14 */
export interface EventMetadataV14 extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly fields: Vec<Si1Field>;
readonly index: u8;
readonly docs: Vec<Text>;
readonly args: Vec<Type>;
@@ -129,7 +129,7 @@ export interface FunctionMetadataV13 extends FunctionMetadataV12 {}
/** @name FunctionMetadataV14 */
export interface FunctionMetadataV14 extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly fields: Vec<Si1Field>;
readonly index: u8;
readonly docs: Vec<Text>;
readonly args: Vec<FunctionArgumentMetadataV14>;
@@ -327,12 +327,18 @@ export interface PalletStorageMetadataV14 extends Struct {
}
/** @name PortableRegistry */
export interface PortableRegistry extends GenericPortableRegistry {}
export interface PortableRegistry extends PortableRegistryV14 {}
/** @name PortableRegistryV14 */
export interface PortableRegistryV14 extends GenericPortableRegistry {}
/** @name PortableType */
export interface PortableType extends Struct {
readonly id: SiLookupTypeId;
readonly type: SiType;
export interface PortableType extends PortableTypeV14 {}
/** @name PortableTypeV14 */
export interface PortableTypeV14 extends Struct {
readonly id: Si1LookupTypeId;
readonly type: Si1Type;
}
/** @name SignedExtensionMetadataLatest */
@@ -6,28 +6,28 @@
import type { DefinitionsTypes } from '../../types';
import { SiVariant } from '../scaleInfo/definitions';
import { Si1Variant } from '../scaleInfo/v1';
export const v14: DefinitionsTypes = {
// registry
PortableRegistry: 'GenericPortableRegistry',
PortableType: {
id: 'SiLookupTypeId',
type: 'SiType'
PortableRegistryV14: 'GenericPortableRegistry',
PortableTypeV14: {
id: 'Si1LookupTypeId',
type: 'Si1Type'
},
// compatibility with earlier layouts, i.e. don't break previous users
ErrorMetadataV14: {
...SiVariant,
...Si1Variant,
args: 'Vec<Type>'
},
EventMetadataV14: {
...SiVariant,
...Si1Variant,
args: 'Vec<Type>'
},
FunctionArgumentMetadataV14: 'FunctionArgumentMetadataV13',
FunctionMetadataV14: {
...SiVariant,
...Si1Variant,
args: 'Vec<FunctionArgumentMetadataV14>'
},
@@ -4,78 +4,32 @@
import type { Definitions } from '../../types';
import { v0 } from './v0';
import { v1 } from './v1';
// order important in structs... :)
/* eslint-disable sort-keys */
export const SiVariant = {
name: 'Text',
fields: 'Vec<SiField>',
index: 'u8',
docs: 'Vec<Text>'
};
export default {
rpc: {},
types: {
...v0,
SiField: {
name: 'Option<Text>',
type: 'SiLookupTypeId',
typeName: 'Option<Text>',
docs: 'Vec<Text>'
},
SiLookupTypeId: 'Compact<u32>',
SiPath: 'Vec<Text>',
SiType: {
path: 'SiPath',
params: 'Vec<SiTypeParameter>',
def: 'SiTypeDef',
docs: 'Vec<Text>'
},
SiTypeDef: {
_enum: {
Composite: 'SiTypeDefComposite',
Variant: 'SiTypeDefVariant',
Sequence: 'SiTypeDefSequence',
Array: 'SiTypeDefArray',
Tuple: 'SiTypeDefTuple',
Primitive: 'SiTypeDefPrimitive',
Compact: 'SiTypeDefCompact',
BitSequence: 'SiTypeDefBitSequence',
// NOTE: This is specific to the implementation for pre-v14 metadata
// compatibility (always keep this as the last entry in the enum)
HistoricMetaCompat: 'Type'
}
},
SiTypeDefArray: {
len: 'u32',
type: 'SiLookupTypeId'
},
SiTypeDefBitSequence: {
bitStoreType: 'SiLookupTypeId',
bitOrderType: 'SiLookupTypeId'
},
SiTypeDefCompact: {
type: 'SiLookupTypeId'
},
SiTypeDefComposite: {
fields: 'Vec<SiField>'
},
SiTypeDefPrimitive: {
_enum: ['Bool', 'Char', 'Str', 'U8', 'U16', 'U32', 'U64', 'U128', 'U256', 'I8', 'I16', 'I32', 'I64', 'I128', 'I256']
},
SiTypeDefSequence: {
type: 'SiLookupTypeId'
},
SiTypeDefTuple: 'Vec<SiLookupTypeId>',
SiTypeParameter: {
name: 'Text',
type: 'Option<SiLookupTypeId>'
},
SiTypeDefVariant: {
variants: 'Vec<SiVariant>'
},
SiVariant
...v1,
// latest mappings
SiField: 'Si1Field',
SiLookupTypeId: 'Si1LookupTypeId',
SiPath: 'Si1Path',
SiType: 'Si1Type',
SiTypeDef: 'Si1TypeDef',
SiTypeDefArray: 'Si1TypeDefArray',
SiTypeDefBitSequence: 'Si1TypeDefBitSequence',
SiTypeDefCompact: 'Si1TypeDefCompact',
SiTypeDefComposite: 'Si1TypeDefComposite',
SiTypeDefPrimitive: 'Si1TypeDefPrimitive',
SiTypeDefSequence: 'Si1TypeDefSequence',
SiTypeDefTuple: 'Si1TypeDefTuple',
SiTypeParameter: 'Si1TypeParameter',
SiTypeDefVariant: 'Si1TypeDefVariant',
SiVariant: 'Si1Variant'
}
} as Definitions;
@@ -118,116 +118,145 @@ export interface Si0Variant extends Struct {
readonly docs: Vec<Text>;
}
/** @name SiField */
export interface SiField extends Struct {
/** @name Si1Field */
export interface Si1Field extends Struct {
readonly name: Option<Text>;
readonly type: SiLookupTypeId;
readonly type: Si1LookupTypeId;
readonly typeName: Option<Text>;
readonly docs: Vec<Text>;
}
/** @name SiLookupTypeId */
export interface SiLookupTypeId extends Compact<u32> {}
/** @name Si1LookupTypeId */
export interface Si1LookupTypeId extends Compact<u32> {}
/** @name SiPath */
export interface SiPath extends Vec<Text> {}
/** @name Si1Path */
export interface Si1Path extends Si0Path {}
/** @name SiType */
export interface SiType extends Struct {
readonly path: SiPath;
readonly params: Vec<SiTypeParameter>;
readonly def: SiTypeDef;
/** @name Si1Type */
export interface Si1Type extends Struct {
readonly path: Si1Path;
readonly params: Vec<Si1TypeParameter>;
readonly def: Si1TypeDef;
readonly docs: Vec<Text>;
}
/** @name SiTypeDef */
export interface SiTypeDef extends Enum {
/** @name Si1TypeDef */
export interface Si1TypeDef extends Enum {
readonly isComposite: boolean;
readonly asComposite: SiTypeDefComposite;
readonly asComposite: Si1TypeDefComposite;
readonly isVariant: boolean;
readonly asVariant: SiTypeDefVariant;
readonly asVariant: Si1TypeDefVariant;
readonly isSequence: boolean;
readonly asSequence: SiTypeDefSequence;
readonly asSequence: Si1TypeDefSequence;
readonly isArray: boolean;
readonly asArray: SiTypeDefArray;
readonly asArray: Si1TypeDefArray;
readonly isTuple: boolean;
readonly asTuple: SiTypeDefTuple;
readonly asTuple: Si1TypeDefTuple;
readonly isPrimitive: boolean;
readonly asPrimitive: SiTypeDefPrimitive;
readonly asPrimitive: Si1TypeDefPrimitive;
readonly isCompact: boolean;
readonly asCompact: SiTypeDefCompact;
readonly asCompact: Si1TypeDefCompact;
readonly isBitSequence: boolean;
readonly asBitSequence: SiTypeDefBitSequence;
readonly asBitSequence: Si1TypeDefBitSequence;
readonly isHistoricMetaCompat: boolean;
readonly asHistoricMetaCompat: Type;
}
/** @name SiTypeDefArray */
export interface SiTypeDefArray extends Struct {
/** @name Si1TypeDefArray */
export interface Si1TypeDefArray extends Struct {
readonly len: u32;
readonly type: SiLookupTypeId;
readonly type: Si1LookupTypeId;
}
/** @name SiTypeDefBitSequence */
export interface SiTypeDefBitSequence extends Struct {
readonly bitStoreType: SiLookupTypeId;
readonly bitOrderType: SiLookupTypeId;
/** @name Si1TypeDefBitSequence */
export interface Si1TypeDefBitSequence extends Struct {
readonly bitStoreType: Si1LookupTypeId;
readonly bitOrderType: Si1LookupTypeId;
}
/** @name SiTypeDefCompact */
export interface SiTypeDefCompact extends Struct {
readonly type: SiLookupTypeId;
/** @name Si1TypeDefCompact */
export interface Si1TypeDefCompact extends Struct {
readonly type: Si1LookupTypeId;
}
/** @name SiTypeDefComposite */
export interface SiTypeDefComposite extends Struct {
readonly fields: Vec<SiField>;
/** @name Si1TypeDefComposite */
export interface Si1TypeDefComposite extends Struct {
readonly fields: Vec<Si1Field>;
}
/** @name SiTypeDefPrimitive */
export interface SiTypeDefPrimitive extends Enum {
readonly isBool: boolean;
readonly isChar: boolean;
readonly isStr: boolean;
readonly isU8: boolean;
readonly isU16: boolean;
readonly isU32: boolean;
readonly isU64: boolean;
readonly isU128: boolean;
readonly isU256: boolean;
readonly isI8: boolean;
readonly isI16: boolean;
readonly isI32: boolean;
readonly isI64: boolean;
readonly isI128: boolean;
readonly isI256: boolean;
/** @name Si1TypeDefPrimitive */
export interface Si1TypeDefPrimitive extends Si0TypeDefPrimitive {}
/** @name Si1TypeDefSequence */
export interface Si1TypeDefSequence extends Struct {
readonly type: Si1LookupTypeId;
}
/** @name SiTypeDefSequence */
export interface SiTypeDefSequence extends Struct {
readonly type: SiLookupTypeId;
/** @name Si1TypeDefTuple */
export interface Si1TypeDefTuple extends Vec<Si1LookupTypeId> {}
/** @name Si1TypeDefVariant */
export interface Si1TypeDefVariant extends Struct {
readonly variants: Vec<Si1Variant>;
}
/** @name SiTypeDefTuple */
export interface SiTypeDefTuple extends Vec<SiLookupTypeId> {}
/** @name SiTypeDefVariant */
export interface SiTypeDefVariant extends Struct {
readonly variants: Vec<SiVariant>;
}
/** @name SiTypeParameter */
export interface SiTypeParameter extends Struct {
/** @name Si1TypeParameter */
export interface Si1TypeParameter extends Struct {
readonly name: Text;
readonly type: Option<SiLookupTypeId>;
readonly type: Option<Si1LookupTypeId>;
}
/** @name SiVariant */
export interface SiVariant extends Struct {
/** @name Si1Variant */
export interface Si1Variant extends Struct {
readonly name: Text;
readonly fields: Vec<SiField>;
readonly fields: Vec<Si1Field>;
readonly index: u8;
readonly docs: Vec<Text>;
}
/** @name SiField */
export interface SiField extends Si1Field {}
/** @name SiLookupTypeId */
export interface SiLookupTypeId extends Si1LookupTypeId {}
/** @name SiPath */
export interface SiPath extends Si1Path {}
/** @name SiType */
export interface SiType extends Si1Type {}
/** @name SiTypeDef */
export interface SiTypeDef extends Si1TypeDef {}
/** @name SiTypeDefArray */
export interface SiTypeDefArray extends Si1TypeDefArray {}
/** @name SiTypeDefBitSequence */
export interface SiTypeDefBitSequence extends Si1TypeDefBitSequence {}
/** @name SiTypeDefCompact */
export interface SiTypeDefCompact extends Si1TypeDefCompact {}
/** @name SiTypeDefComposite */
export interface SiTypeDefComposite extends Si1TypeDefComposite {}
/** @name SiTypeDefPrimitive */
export interface SiTypeDefPrimitive extends Si1TypeDefPrimitive {}
/** @name SiTypeDefSequence */
export interface SiTypeDefSequence extends Si1TypeDefSequence {}
/** @name SiTypeDefTuple */
export interface SiTypeDefTuple extends Si1TypeDefTuple {}
/** @name SiTypeDefVariant */
export interface SiTypeDefVariant extends Si1TypeDefVariant {}
/** @name SiTypeParameter */
export interface SiTypeParameter extends Si1TypeParameter {}
/** @name SiVariant */
export interface SiVariant extends Si1Variant {}
export type PHANTOM_SCALEINFO = 'scaleInfo';
@@ -0,0 +1,73 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsTypes } from '../../types';
// order important in structs... :)
/* eslint-disable sort-keys */
export const Si1Variant = {
name: 'Text',
fields: 'Vec<Si1Field>',
index: 'u8',
docs: 'Vec<Text>'
};
export const v1: DefinitionsTypes = {
Si1Field: {
name: 'Option<Text>',
type: 'Si1LookupTypeId',
typeName: 'Option<Text>',
docs: 'Vec<Text>'
},
Si1LookupTypeId: 'Compact<u32>',
Si1Path: 'Si0Path',
Si1Type: {
path: 'Si1Path',
params: 'Vec<Si1TypeParameter>',
def: 'Si1TypeDef',
docs: 'Vec<Text>'
},
Si1TypeDef: {
_enum: {
Composite: 'Si1TypeDefComposite',
Variant: 'Si1TypeDefVariant',
Sequence: 'Si1TypeDefSequence',
Array: 'Si1TypeDefArray',
Tuple: 'Si1TypeDefTuple',
Primitive: 'Si1TypeDefPrimitive',
Compact: 'Si1TypeDefCompact',
BitSequence: 'Si1TypeDefBitSequence',
// NOTE: This is specific to the implementation for pre-v14 metadata
// compatibility (always keep this as the last entry in the enum)
HistoricMetaCompat: 'Type'
}
},
Si1TypeDefArray: {
len: 'u32',
type: 'Si1LookupTypeId'
},
Si1TypeDefBitSequence: {
bitStoreType: 'Si1LookupTypeId',
bitOrderType: 'Si1LookupTypeId'
},
Si1TypeDefCompact: {
type: 'Si1LookupTypeId'
},
Si1TypeDefComposite: {
fields: 'Vec<Si1Field>'
},
Si1TypeDefPrimitive: 'Si0TypeDefPrimitive',
Si1TypeDefSequence: {
type: 'Si1LookupTypeId'
},
Si1TypeDefTuple: 'Vec<Si1LookupTypeId>',
Si1TypeParameter: {
name: 'Text',
type: 'Option<Si1LookupTypeId>'
},
Si1TypeDefVariant: {
variants: 'Vec<Si1Variant>'
},
Si1Variant
};
+58 -35
View File
@@ -5,7 +5,7 @@ import type { ErrorMetadataV13, EventMetadataV13, ExtrinsicMetadataV13, Extrinsi
import type { SiVariant } from '../../interfaces/scaleInfo';
import type { Text } from '../../primitive/Text';
import type { Type } from '../../primitive/Type';
import type { OverrideModuleType, Registry, TypeSpec } from '../../types';
import type { OverrideModuleType, Registry } from '../../types';
import { getModuleTypes, knownOrigins } from '@polkadot/types-known';
import { stringCamelCase } from '@polkadot/util';
@@ -16,15 +16,26 @@ interface MapDef {
value: Type;
}
export interface TypeSpec {
def: {
HistoricMetaCompat?: string;
Tuple?: number[];
Variant?: {
variants: SiVariant[];
}
},
path?: string[];
}
const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']];
/**
* Creates a compatible type mapping
* @internal
**/
function compatType (types: TypeSpec[], _type: Text | string): number {
function compatType (compatTypes: TypeSpec[], _type: Text | string): number {
const type = _type.toString();
const index = types.findIndex(({ def }) =>
const index = compatTypes.findIndex(({ def }) =>
def.HistoricMetaCompat === type
);
@@ -32,13 +43,23 @@ function compatType (types: TypeSpec[], _type: Text | string): number {
return index;
}
return types.push({
def: { HistoricMetaCompat: type }
return compatTypes.push({
def: {
HistoricMetaCompat: type
}
}) - 1;
}
function variantType (modName: Text, variantType: string, types: TypeSpec[], variants: SiVariant[]): number {
return types.push({
function makeTupleType (compatTypes: TypeSpec[], entries: number[]): number {
return compatTypes.push({
def: {
Tuple: entries
}
}) - 1;
}
function makeVariantType (modName: Text, variantType: string, compatTypes: TypeSpec[], variants: SiVariant[]): number {
return compatTypes.push({
def: {
Variant: { variants }
},
@@ -104,14 +125,14 @@ function setTypeOverride (sectionTypes: OverrideModuleType, types: Type[]): void
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
**/
function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): PalletCallMetadataV14 {
function convertCalls (compatTypes: TypeSpec[], registry: Registry, modName: Text, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): PalletCallMetadataV14 {
const variants = calls.map(({ args, docs, name }, index): SiVariant => {
setTypeOverride(sectionTypes, args.map(({ type }) => type));
return registry.createType('SiVariant', {
docs,
fields: args.map(({ name, type }) =>
registry.createType('SiField', { name, type: compatType(registry.compatSpecs, type) })
registry.createType('SiField', { name, type: compatType(compatTypes, type) })
),
index,
name
@@ -119,7 +140,7 @@ function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadat
});
return registry.createType('PalletCallMetadataV14', {
type: variantType(modName, 'Call', registry.compatSpecs, variants)
type: makeVariantType(modName, 'Call', compatTypes, variants)
});
}
@@ -127,14 +148,14 @@ function convertCalls (registry: Registry, modName: Text, calls: FunctionMetadat
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
*/
function convertConstants (registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): PalletConstantMetadataV14[] {
function convertConstants (compatTypes: TypeSpec[], registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): PalletConstantMetadataV14[] {
return constants.map(({ docs, name, type, value }): PalletConstantMetadataV14 => {
setTypeOverride(sectionTypes, [type]);
return registry.createType('PalletConstantMetadataV14', {
docs,
name,
type: compatType(registry.compatSpecs, type),
type: compatType(compatTypes, type),
value
});
});
@@ -145,7 +166,7 @@ function convertConstants (registry: Registry, constants: ModuleConstantMetadata
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadataV13[], _sectionTypes: OverrideModuleType): PalletErrorMetadataV14 {
function convertErrors (compatTypes: TypeSpec[], registry: Registry, modName: Text, errors: ErrorMetadataV13[], _sectionTypes: OverrideModuleType): PalletErrorMetadataV14 {
const variants = errors.map(({ docs, name }, index): SiVariant =>
registry.createType('SiVariant', {
docs,
@@ -156,7 +177,7 @@ function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadata
);
return registry.createType('PalletErrorMetadataV14', {
type: variantType(modName, 'Error', registry.compatSpecs, variants)
type: makeVariantType(modName, 'Error', compatTypes, variants)
});
}
@@ -164,14 +185,14 @@ function convertErrors (registry: Registry, modName: Text, errors: ErrorMetadata
* Apply module-specific type overrides (always be done as part of toV14)
* @internal
**/
function convertEvents (registry: Registry, modName: Text, events: EventMetadataV13[], sectionTypes: OverrideModuleType): PalletEventMetadataV14 {
function convertEvents (compatTypes: TypeSpec[], registry: Registry, modName: Text, events: EventMetadataV13[], sectionTypes: OverrideModuleType): PalletEventMetadataV14 {
const variants = events.map(({ args, docs, name }, index): SiVariant => {
setTypeOverride(sectionTypes, args);
return registry.createType('SiVariant', {
docs,
fields: args.map((t) =>
registry.createType('SiField', { type: compatType(registry.compatSpecs, t) })
registry.createType('SiField', { type: compatType(compatTypes, t) })
),
index,
name
@@ -179,20 +200,20 @@ function convertEvents (registry: Registry, modName: Text, events: EventMetadata
});
return registry.createType('PalletEventMetadataV14', {
type: variantType(modName, 'Event', registry.compatSpecs, variants)
type: makeVariantType(modName, 'Event', compatTypes, variants)
});
}
function createMapEntry (registry: Registry, sectionTypes: OverrideModuleType, { hashers, keys, value }: MapDef): StorageEntryTypeV14 {
function createMapEntry (compatTypes: TypeSpec[], registry: Registry, sectionTypes: OverrideModuleType, { hashers, keys, value }: MapDef): StorageEntryTypeV14 {
setTypeOverride(sectionTypes, [value, ...(Array.isArray(keys) ? keys : [keys])]);
return registry.createType('StorageEntryTypeV14', {
Map: {
hashers,
key: hashers.length === 1
? compatType(registry.compatSpecs, keys[0])
: (registry.compatSpecs.push({ def: { Tuple: keys.map((t) => compatType(registry.compatSpecs, t)) } }) - 1),
value: compatType(registry.compatSpecs, value)
? compatType(compatTypes, keys[0])
: makeTupleType(compatTypes, keys.map((t) => compatType(compatTypes, t))),
value: compatType(compatTypes, value)
}
});
}
@@ -201,7 +222,7 @@ function createMapEntry (registry: Registry, sectionTypes: OverrideModuleType, {
* Apply module-specific storage type overrides (always part of toV14)
* @internal
**/
function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): PalletStorageMetadataV14 {
function convertStorage (compatTypes: TypeSpec[], registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): PalletStorageMetadataV14 {
return registry.createType('PalletStorageMetadataV14', {
items: items.map(({ docs, fallback, modifier, name, type }): StorageEntryMetadataV14 => {
let entryType: StorageEntryTypeV14;
@@ -212,12 +233,12 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV
setTypeOverride(sectionTypes, [plain]);
entryType = registry.createType('StorageEntryTypeV14', {
Plain: compatType(registry.compatSpecs, plain)
Plain: compatType(compatTypes, plain)
});
} else if (type.isMap) {
const map = type.asMap;
entryType = createMapEntry(registry, sectionTypes, {
entryType = createMapEntry(compatTypes, registry, sectionTypes, {
hashers: [map.hasher],
keys: [map.key],
value: map.value
@@ -225,7 +246,7 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV
} else if (type.isDoubleMap) {
const dm = type.asDoubleMap;
entryType = createMapEntry(registry, sectionTypes, {
entryType = createMapEntry(compatTypes, registry, sectionTypes, {
hashers: [dm.hasher, dm.key2Hasher],
keys: [dm.key1, dm.key2],
value: dm.value
@@ -233,7 +254,7 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV
} else {
const nm = type.asNMap;
entryType = createMapEntry(registry, sectionTypes, {
entryType = createMapEntry(compatTypes, registry, sectionTypes, {
hashers: nm.hashers,
keys: nm.keyVec,
value: nm.value
@@ -266,17 +287,17 @@ function convertExtrinsic (registry: Registry, { signedExtensions, version }: Ex
}
/** @internal */
function createPallet (registry: Registry, mod: ModuleMetadataV13, { calls, constants, errors, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], errors: ErrorMetadataV13[] | null, events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): PalletMetadataV14 {
function createPallet (compatTypes: TypeSpec[], registry: Registry, mod: ModuleMetadataV13, { calls, constants, errors, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], errors: ErrorMetadataV13[] | null, events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): PalletMetadataV14 {
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name));
return registry.createType('PalletMetadataV14', {
calls: calls && convertCalls(registry, mod.name, calls, sectionTypes),
constants: convertConstants(registry, constants, sectionTypes),
errors: errors && convertErrors(registry, mod.name, errors, sectionTypes),
events: events && convertEvents(registry, mod.name, events, sectionTypes),
calls: calls && convertCalls(compatTypes, registry, mod.name, calls, sectionTypes),
constants: convertConstants(compatTypes, registry, constants, sectionTypes),
errors: errors && convertErrors(compatTypes, registry, mod.name, errors, sectionTypes),
events: events && convertEvents(compatTypes, registry, mod.name, events, sectionTypes),
index: mod.index,
name: mod.name,
storage: storage && convertStorage(registry, storage, sectionTypes)
storage: storage && convertStorage(compatTypes, registry, storage, sectionTypes)
});
}
@@ -285,12 +306,14 @@ function createPallet (registry: Registry, mod: ModuleMetadataV13, { calls, cons
* @internal
**/
export function toV14 (registry: Registry, v13: MetadataV13, metaVersion: number): MetadataV14 {
compatType(registry.compatSpecs, 'Null'); // position 0 always has Null
const compatTypes: TypeSpec[] = [];
compatType(compatTypes, 'Null'); // position 0 always has Null
registerOriginCaller(registry, v13.modules, metaVersion);
const extrinsic = convertExtrinsic(registry, v13.extrinsic);
const pallets = v13.modules.map((mod) =>
createPallet(registry, mod, {
createPallet(compatTypes, registry, mod, {
calls: mod.calls.unwrapOr(null),
constants: mod.constants,
errors: mod.errors.length ? mod.errors : null,
@@ -302,7 +325,7 @@ export function toV14 (registry: Registry, v13: MetadataV13, metaVersion: number
return registry.createType('MetadataV14', {
extrinsic,
lookup: {
types: registry.compatSpecs.map((type, id) =>
types: compatTypes.map((type, id) =>
registry.createType('PortableType', { id, type })
)
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '6.0.4' };
export const packageInfo = { name: '@polkadot/types', version: '6.1.1' };
+1 -13
View File
@@ -7,7 +7,7 @@ import type { CreateOptions } from '../create/types';
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { MetadataLatest, PortableRegistry } from '../interfaces/metadata';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { SiField, SiLookupTypeId, SiVariant } from '../interfaces/scaleInfo';
import type { SiField, SiLookupTypeId } from '../interfaces/scaleInfo';
import type { ChainProperties } from '../interfaces/system';
import type { Metadata } from '../metadata';
import type { CallFunction } from './calls';
@@ -47,17 +47,6 @@ export interface RegistryError {
section: string;
}
export interface TypeSpec {
def: {
HistoricMetaCompat?: string;
Tuple?: number[];
Variant?: {
variants: SiVariant[];
}
},
path?: string[];
}
export interface OverrideVersionedType {
// min (v >= min) and max (v <= max)
minmax: [number | undefined | null, number | undefined | null] | [number?, number?] | (number | undefined | null)[];
@@ -123,7 +112,6 @@ export interface Registry {
readonly unknownTypes: string[];
readonly signedExtensions: string[];
compatSpecs: TypeSpec[];
createdAtHash?: Hash;
findMetaCall (callIndex: Uint8Array): CallFunction;
+529 -1262
View File
File diff suppressed because it is too large Load Diff