Compare commits

...
84 Commits
Author SHA1 Message Date
Github Actions 05e3db01ba [CI Skip] release/stable 4.11.2
skip-checks: true
2021-05-24 06:51:49 +00:00
Jaco 6158c07e0a 4.11.2 (#3565) 2021-05-24 08:42:06 +02:00
Github Actions ce505aaf62 [CI Skip] release/stable 4.11.1
skip-checks: true
2021-05-23 16:47:01 +00:00
Jaco 09f9a48037 4.11 (#3564) 2021-05-23 18:37:27 +02:00
Github Actions 700c1cfcd4 [CI Skip] release/beta 4.10.2-10
skip-checks: true
2021-05-23 16:18:10 +00:00
Jaco 7d2463e53f Update entries/keys for max of 256 items per call (#3563) 2021-05-23 18:08:30 +02:00
Github Actions a2ecd9bd3b [CI Skip] release/beta 4.10.2-9
skip-checks: true
2021-05-23 15:50:40 +00:00
Jaco b0de692147 Under Node.js allow for WS receiving up to 16MB messages (#3562) 2021-05-23 17:40:13 +02:00
Github Actions dcd53c76d7 [CI Skip] release/beta 4.10.2-8
skip-checks: true
2021-05-23 15:11:24 +00:00
Jaco 6ed90c6111 Augment NMap entries (#3556)
* Augment NMap entries

* CHANGELOG

* DropLast generic helper

* Keys checkType

* Signular argument

* Adjust augmentation

* Adjust

* restore key types

* NMap iterKey

* NMap keys/entries

* Adjust creation

* Simplify

* Update

* CHANGELOG
2021-05-23 17:00:58 +02:00
Github Actions babef6d7bc [CI Skip] release/beta 4.10.2-7
skip-checks: true
2021-05-23 12:47:52 +00:00
Jaco e2205a65e9 Bump deps (#3560)
* Bump deps

* yargs typing
2021-05-23 14:39:32 +02:00
Github Actions 32d55dfb18 [CI Skip] release/beta 4.10.2-6
skip-checks: true
2021-05-21 05:40:12 +00:00
Jaco 60e0d0eae4 Cleanup Rococo known types (#3555)
* Clenup Rococo known types

* CHANGELOG
2021-05-21 07:28:35 +02:00
Github Actions 9cef1febe1 [CI Skip] release/beta 4.10.2-5
skip-checks: true
2021-05-21 05:07:42 +00:00
Jaco 4c9032fedc Add state_getChildReadProof RPC (#3554)
* Add state_getChildReadProof RPC

* CHANGELOG
2021-05-21 06:58:36 +02:00
Github Actions 5b6f222e5e [CI Skip] release/beta 4.10.2-4
skip-checks: true
2021-05-20 13:28:08 +00:00
Jaco 47235d01bf Add types for Bridges (#3552)
* Add types for Bridges

* Bump deps
2021-05-20 15:17:42 +02:00
Github Actions 32efe83136 [CI Skip] release/beta 4.10.2-3
skip-checks: true
2021-05-20 12:13:02 +00:00
Jaco c4c099e693 Add types for uniques (#3551) 2021-05-20 14:02:10 +02:00
Github Actions f26ca0e624 [CI Skip] release/beta 4.10.2-2
skip-checks: true
2021-05-20 08:50:31 +00:00
Jaco 5f496f1809 Fix metadata V13 decoding (on NMap) (#3548) 2021-05-20 10:39:26 +02:00
Github Actions f1cbf8cc70 [CI Skip] release/beta 4.10.2-1
skip-checks: true
2021-05-19 15:11:05 +00:00
Jaco 8b7fccb744 DisallowSigned extension (#3547) 2021-05-19 16:59:57 +02:00
Github Actions 66d3486674 [CI Skip] release/beta 4.10.2-0
skip-checks: true
2021-05-18 19:01:54 +00:00
Jaco 2dbd217f6d Alias &'static[u8] -> Text (#3545)
* Alias &'static[u8] -> Text

* Bytes
2021-05-18 20:53:34 +02:00
Jaco fea9ae8f97 Westend has 16 nominator slots (#3544)
* Westend has 16 nominator slots

* CHANGELOG
2021-05-18 20:53:06 +02:00
Jaco 4e81bbc43c Return additional error information from decodeU8a (#3540) 2021-05-18 12:57:48 +02:00
Github Actions 83650b8f28 [CI Skip] release/stable 4.10.1
skip-checks: true
2021-05-17 05:00:09 +00:00
Jaco 50a3501dd2 4.10 (#3539) 2021-05-17 06:49:57 +02:00
Github Actions 526a3fd139 [CI Skip] release/beta 4.9.3-24
skip-checks: true
2021-05-16 18:33:15 +00:00
Jaco 3b996b3444 CompactSolution for 24 nominees (#3537)
* CompactSolution for 24 nominees

* Westend & Rococo

* CompactAssignments: 'CompactAssignmentsTo265'

* With{16, 24}

* CompactAssignmentsWith16 in test

* With16 in historic types

* RawSolution alias

* Types

* Bump common
2021-05-16 20:22:54 +02:00
Github Actions c72c9e4a5e [CI Skip] release/beta 4.9.3-23
skip-checks: true
2021-05-15 05:50:42 +00:00
Jaco 60a71a5ac9 Bump static Substrate metadata (#3532) 2021-05-15 07:39:22 +02:00
Jaco 26c3ccccc3 Additional phragmenElection check (#3531) 2021-05-15 07:32:32 +02:00
Github Actions 963e25934d [CI Skip] release/beta 4.9.3-22
skip-checks: true
2021-05-15 04:54:15 +00:00
Jaco 55d9f8a062 Fix 9010 upgrade blocks (#3530)
* Fix 9010 upgrade blocks

* CHANGELOG
2021-05-15 06:43:51 +02:00
Github Actions 700c8ba21f [CI Skip] release/beta 4.9.3-21
skip-checks: true
2021-05-14 16:16:15 +00:00
Jaco cbc255b4e7 Cater for new phragmenElection module (#3528) 2021-05-14 19:07:47 +03:00
Jaco 2fe1e5031e Add Westend & Kusama blocks for 9100 (#3527) 2021-05-14 18:01:07 +02:00
Github Actions f2cdac7875 [CI Skip] release/beta 4.9.3-20
skip-checks: true
2021-05-13 19:29:42 +00:00
Jaco 165405bdc3 Contracts read for variable-length bytes (#3526) 2021-05-13 21:19:11 +02:00
Github Actions f86d71524d [CI Skip] release/beta 4.9.3-19
skip-checks: true
2021-05-13 15:34:14 +00:00
Jaco 4d6d59f1c5 Adjust Compact toBigInt() (#3525) 2021-05-13 17:23:46 +02:00
Github Actions 7a709898e5 [CI Skip] release/beta 4.9.3-18
skip-checks: true
2021-05-13 07:17:24 +00:00
Jaco 121bfc7913 VecFixed with hex inputs (& adjust isPedantic) (#3522)
* VecFixed with hex inputs (& adjust isPedantic)

* Update packages/types/src/codec/VecFixed.spec.ts

* Cleanups
2021-05-13 09:08:52 +02:00
Github Actions a04ccec445 [CI Skip] release/beta 4.9.3-17
skip-checks: true
2021-05-13 05:21:42 +00:00
Jaco 2611fc5e1a Handle Text is same way as Bytes (isPedantic mode) (#3521)
* Handle Text is same was as Bytes (isPedantic mode)

* Length on input

* tests

* raw decoding test
2021-05-13 07:10:44 +02:00
Github Actions cd5c306b22 [CI Skip] release/beta 4.9.3-16
skip-checks: true
2021-05-12 16:55:21 +00:00
Branan Riley ca6a7819f6 Update centrifuge-chain types for updated substrate used in parachain (#3520) 2021-05-12 18:44:35 +02:00
Github Actions 29c0ea9856 [CI Skip] release/beta 4.9.3-15
skip-checks: true
2021-05-12 13:21:30 +00:00
Jaco c82ed58d68 Bump common (#3519) 2021-05-12 15:11:14 +02:00
Github Actions 59a3867c50 [CI Skip] release/beta 4.9.3-14
skip-checks: true
2021-05-11 10:35:32 +00:00
Jaco 0fca4e6866 Raw getHeader value for metadata determination (#3490)
* Raw getHeader value for metadata determination

* Don't cache raw/json RPC calls

* getRuntimeVersion via .json RPC

* Minimal RuntimeVersion type

* getMetadata with isHistoric

* User .raw for Metadata

* Adjust types

* Updates

* Remove (now-unused) isCached

* Update packages/api/src/base/Init.ts

* Update packages/api/src/base/Init.ts

* Apply suggestions from code review

* Only decorate registry on scale

* tidy typings

* typing

* Linting updates

* CHANGELOG

* V2 contracts
2021-05-11 12:25:27 +02:00
Github Actions 3f9e65a179 [CI Skip] release/beta 4.9.3-13
skip-checks: true
2021-05-11 09:08:46 +00:00
Jaco 92bde9de6f Adjust ABI registry (#3516)
* Adjust ABI registry

* Remove V2 support

* instantiateWithCode mock
2021-05-11 10:58:20 +02:00
Github Actions 9b3158599c [CI Skip] release/beta 4.9.3-12
skip-checks: true
2021-05-11 08:12:16 +00:00
Jaco 206fb49df5 Cater for Abi type offsets in 1+ (#3514)
* Cater for Abi type offsets in 1+

* Update packages/api-contract/src/MetaRegistry.ts
2021-05-11 10:01:27 +02:00
Github Actions cc0ad9b04b [CI Skip] release/beta 4.9.3-11
skip-checks: true
2021-05-10 08:32:30 +00:00
Jaco 39902dd8ac Adjust DispatchError (#3513)
* Adjust DisptachError

* Merge master, rebuild generation
2021-05-10 11:23:15 +03:00
Github Actions 324e4ab89b [CI Skip] release/beta 4.9.3-10
skip-checks: true
2021-05-10 05:06:07 +00:00
KarishmaBothara 68bf0a487f Backward compatibility thing (#3511) 2021-05-10 06:56:04 +02:00
Github Actions 3acf7e0fd7 [CI Skip] release/beta 4.9.3-9
skip-checks: true
2021-05-10 04:45:08 +00:00
Jaco edaf13abe1 Updata cumulus types (#3512)
* Updata cumulus types

* yarn .lock
2021-05-10 06:33:20 +02:00
Github Actions b3649a70ce [CI Skip] release/beta 4.9.3-8
skip-checks: true
2021-05-09 07:58:08 +00:00
Jaco 80ab628643 Adjust contract call result decoding (#3510)
* Adjust types for node/node-template

* Adjust contract call result

* Adjust

* Raw directly

* CHANGELOG
2021-05-09 09:46:21 +02:00
Github Actions 76363c0142 [CI Skip] release/beta 4.9.3-7
skip-checks: true
2021-05-09 07:37:35 +00:00
Jaco 80c18c2201 Adjust types for node/node-template (#3509) 2021-05-09 09:27:23 +02:00
Github Actions fcf9b86b87 [CI Skip] release/beta 4.9.3-6
skip-checks: true
2021-05-07 12:52:17 +00:00
Jaco 1113a3d2f8 Use BN_* constants in contract default params (#3507) 2021-05-07 14:41:08 +02:00
Github Actions c899dbf893 [CI Skip] release/beta 4.9.3-5
skip-checks: true
2021-05-07 11:28:49 +00:00
Jaco be137b2a03 Fix ContractRx query result definitions (#3506) 2021-05-07 13:19:23 +02:00
Github Actions 122d780fe8 [CI Skip] release/beta 4.9.3-4
skip-checks: true
2021-05-07 08:57:49 +00:00
Jaco 12be027b18 Allow for Bounded* type usage (#3504)
* Allow for `Bounded*` type usage

* Adjust start index after found

* Adjust

* Add tests for bounded

* Bounded with length value

* adjust
2021-05-07 10:47:09 +02:00
Github Actions dfeef40037 [CI Skip] release/beta 4.9.3-3
skip-checks: true
2021-05-07 07:26:32 +00:00
Jaco a7b4fe4dd0 Adjust internal TS definitions for providers (#3503) 2021-05-07 09:16:10 +02:00
Github Actions f4ec64d6f5 [CI Skip] release/beta 4.9.3-2
skip-checks: true
2021-05-07 06:15:35 +00:00
JQQQ 9a0d39199e Allow rpc expose definition/ metadata (#3488)
* Expose rpc defination(meta)

* Fix lint

* Change def to meta
2021-05-07 08:04:55 +02:00
Github Actions 77d82d9511 [CI Skip] release/beta 4.9.3-1
skip-checks: true
2021-05-07 06:00:57 +00:00
Jaco 5464b91cc6 Bump dev (#3502) 2021-05-07 07:52:31 +02:00
Github Actions 64ff87952a [CI Skip] release/beta 4.9.3-0
skip-checks: true
2021-05-06 11:12:47 +00:00
WoeOm 0de39e4c52 adapt Darwinia, Crab Network types (#3498) 2021-05-06 13:03:16 +02:00
Github Actions 60bc384d22 [CI Skip] release/stable 4.9.2
skip-checks: true
2021-05-06 10:37:05 +00:00
Jaco Greeff ca7ea0e143 4.9.2 (publish failure on .1) 2021-05-06 13:26:36 +03:00
126 changed files with 2677 additions and 1423 deletions
+3 -1
View File
@@ -21,4 +21,6 @@
4.0.3
4.6.2
4.7.2
4.7.2
4.9.2
4.11.2
+59
View File
@@ -1,5 +1,64 @@
# CHANGELOG
## 4.11.2 May 24, 2021
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
Changes:
- Add backwards-compatible TS-only `AugmentedQueryDoubleMap` type (unused now in type generation)
## 4.11.1 May 23, 2021
Upgrade priority: Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
Changes:
- Fix metadata v13 storage decoding on `NMap`
- Add augmentation & keys/entries for NMap types
- Return additional error information from internal u8a decoding failures
- Adjust Westend types for 16 nominators-only
- Add support for `DisallowSigned` (as per shell runtime) extension
- Display small hex-slice with u8a decoding failures
- Add `state_getChildReadProof` RPC
- Cleanup Rococo known types (only as used)
- Under Node.js allow for WS receiving up to 16MB messages
- Update entries/keys for max of 256 items per call
## 4.10.1 May 17, 2021
Upgrade priority: Medium. Recommended for uses of Polkadot/Kusama 9010 runtimes.
- **Breaking change** Support for the contracts V2 compatibility has been dropped in `@polkadot/api-contract`
Contributed:
- Expose RPC definitions via `.meta` (Thanks to https://github.com/jiqiang90)
- Adjust staking derives for chain-specific optional fields (https://github.com/WoeOm)
- Update base Centrifuge types (Thanks to https://github.com/branan)
Changes:
- Allow for `Bounded*` type usage (as per latest Substrate)
- Adjust internal TS definitions for providers
- Fix `ContractRx` query result definitions (no extra Observable)
- Handle contract call RPC result directly as `Raw` (returned as hex)
- Use `BN_*` constants as non-specified defaults in contract interfaces
- Remove all type overrides for node/node-template (API tracks latest)
- Contracts ABI now supports metadata version where indexes are 0-based
- Remove support for the old-style V2 contracts from `@polkadot/api-contract`
- Adjust historic decoration, return as-at registry via `getHeader`, `getMetadata` & `getRuntimeVersion`
- Adjust `VecFixed` to allow for the handling of hex inputs
- Adjust `Compact<*>` to allow for wrapped `toBigInt()` conversions
- Fix `isPedantic` decoding to correctly handle `Text`
- Cater for new `phragmenElection` module naming
- Add Kusama & Westend 9010 upgrade blocks
- Adjust `CompactSolution` for 24 nominators
- Bump static metadata to latest Substrate
## 4.9.1 May 6, 2021
Upgrade priority: Medium. Required for the next v0.9.0 Polkadot/Kusama chain upgrades where parachains are used.
+4 -4
View File
@@ -25,14 +25,14 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.14.0",
"@babel/core": "^7.14.3",
"@babel/register": "^7.13.16",
"@babel/runtime": "^7.14.0",
"@polkadot/dev": "^0.62.12",
"@polkadot/ts": "^0.3.64",
"@polkadot/dev": "^0.62.16",
"@polkadot/ts": "^0.3.66",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.23",
"copyfiles": "^2.4.1"
},
"version": "4.9.1"
"version": "4.11.2"
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -20,10 +20,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.9.1",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/x-rxjs": "^6.3.1",
"@polkadot/api": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9"
}
}
+6 -9
View File
@@ -10,8 +10,6 @@ import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, i
import { MetaRegistry } from './MetaRegistry';
const EMPTY_U8A = new Uint8Array();
const l = logger('Abi');
function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string | number): T {
@@ -45,13 +43,13 @@ export class Abi {
assert(isObject(json) && !Array.isArray(json) && json.metadataVersion && isObject(json.spec) && !Array.isArray(json.spec) && Array.isArray(json.spec.constructors) && Array.isArray(json.spec.messages), 'Invalid JSON ABI structure supplied, expected a recent metadata version');
this.json = json;
this.registry = new MetaRegistry(chainProperties);
this.registry = new MetaRegistry(json.metadataVersion as string, chainProperties);
this.project = this.registry.createType('ContractProject', json);
this.registry.setMetaTypes(this.project.types);
this.project.types.forEach((_, index) =>
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + 1) })
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) })
);
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
this.#createMessage(spec, index, {
@@ -156,8 +154,8 @@ export class Abi {
index,
method: stringCamelCase(identifier),
selector: spec.selector,
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
this.#encodeArgs(spec, args, params, additional)
toU8a: (params: CodecArg[]) =>
this.#encodeArgs(spec, args, params)
};
return message;
@@ -187,14 +185,13 @@ export class Abi {
return message.fromU8a(trimmed.subarray(4));
}
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => {
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
return compactAddLength(
u8aConcat(
this.registry.createType('ContractSelector', selector).toU8a(),
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a()),
additional
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a())
)
);
}
+28 -20
View File
@@ -14,8 +14,8 @@ interface PartialTypeSpec {
}
// convert the offset into project-specific, index-1
export function getRegistryOffset (id: SiLookupTypeId): number {
return id.toNumber() - 1;
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number {
return id.toNumber() - typeOffset;
}
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
@@ -28,11 +28,16 @@ const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
export class MetaRegistry extends TypeRegistry {
public readonly metaTypeDefs: TypeDef[] = [];
public readonly typeOffset;
#siTypes: SiType[] = [];
constructor (chainProperties?: ChainProperties) {
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super();
// type indexes are 1-based pre-1.0 and 0-based post-1.0
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
if (chainProperties) {
this.setChainProperties(chainProperties);
}
@@ -43,7 +48,7 @@ export class MetaRegistry extends TypeRegistry {
}
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
const offset = getRegistryOffset(typeSpec.type);
const offset = getRegistryOffset(typeSpec.type, this.typeOffset);
let typeDef = this.metaTypeDefs[offset];
if (!typeDef) {
@@ -78,7 +83,7 @@ export class MetaRegistry extends TypeRegistry {
}
#getMetaType = (id: SiLookupTypeId): SiType => {
const type = this.#siTypes[getRegistryOffset(id)];
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
@@ -87,10 +92,13 @@ export class MetaRegistry extends TypeRegistry {
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
const path = [...type.path];
const pathFinal = path.length ? path[path.length - 1].toString() : '';
const isPrimitivePath = !!path.length && (
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
PRIMITIVE_ALWAYS.includes(path[path.length - 1].toString())
);
let typeDef: Omit<TypeDef, 'type'>;
if (type.path.join('::').startsWith('ink_env::types::') || PRIMITIVE_ALWAYS.includes(pathFinal)) {
if (isPrimitivePath) {
typeDef = this.#extractPrimitivePath(type);
} else if (type.def.isPrimitive) {
typeDef = this.#extractPrimitive(type);
@@ -128,7 +136,7 @@ export class MetaRegistry extends TypeRegistry {
}
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length > 256');
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
return {
info: TypeDefInfo.VecFixed,
@@ -144,27 +152,27 @@ export class MetaRegistry extends TypeRegistry {
]),
[true, true]);
let info;
// check for tuple first (no fields may be available)
if (isTuple) {
info = TypeDefInfo.Tuple;
} else if (isStruct) {
info = TypeDefInfo.Struct;
} else {
throw new Error('Invalid fields type detected, expected either Tuple or Struct');
}
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
const sub = fields.map(({ name, type }) => {
return {
...this.getMetaTypeDef({ type }),
...(name.isSome ? { name: name.unwrap().toString() } : {})
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
};
});
return isTuple && sub.length === 1
? sub[0]
: { info, sub };
: {
// check for tuple first (no fields may be available)
info: isTuple
? TypeDefInfo.Tuple
: TypeDefInfo.Struct,
sub
};
}
#extractPrimitive = (type: SiType): TypeDef => {
+2 -2
View File
@@ -5,7 +5,7 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AnyJson, Registry } from '@polkadot/types/types';
import { ApiBase } from '@polkadot/api/base';
import { assert } from '@polkadot/util';
import { assert, isFunction } from '@polkadot/util';
import { Abi } from '../Abi';
@@ -26,6 +26,6 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
assert(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
}
}
+16 -17
View File
@@ -10,13 +10,13 @@ import type { MapConstructorExec } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { isUndefined } from '@polkadot/util';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Contract } from './Contract';
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
import { createBluePrintTx, encodeSalt } from './util';
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly contract?: Contract<ApiType>;
@@ -52,20 +52,19 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const tx = withSalt
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
return tx.withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
))
);
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiate(
value,
gasLimit,
this.codeHash,
this.abi.findConstructor(constructorOrId).toU8a(params),
encodeSalt(salt)
)
.withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
))
);
}
}
+21 -42
View File
@@ -10,15 +10,14 @@ import type { MapConstructorExec } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, compactAddLength, isFunction, isUndefined, isWasm, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a } from '@polkadot/util-crypto';
import { assert, BN_ZERO, compactAddLength, isUndefined, isWasm, u8aToU8a } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Blueprint } from './Blueprint';
import { Contract } from './Contract';
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
import { createBluePrintTx, encodeSalt } from './util';
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly blueprint?: Blueprint<ApiType>;
@@ -57,45 +56,25 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return isFunction(this.api.tx.contracts.instantiateWithCode)
? this.#instantiateCurrent(constructorOrId, options, params)
: this.#instantiatePrev(constructorOrId, options, params);
}
#instantiateCurrent = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiateWithCode(value, gasLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
.withResultTransform(this.#transformEvents);
}
#instantiatePrev = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
assert(isFunction(this.api.tx.utility?.batch), 'Your chain does not include the utility pallet, for contracts v2 deployment, this is required');
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const codeHash = blake2AsU8a(this.code);
return this.api.tx.utility.batch([
this.api.tx.contracts.putCode(compactAddLength(this.code)),
withSalt
? this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included in the params itself
: this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded)
]).withResultTransform(this.#transformEvents);
}
#transformEvents = (result: ISubmittableResult): CodeSubmittableResult<ApiType> => {
return new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce(([blueprint, contract], { event }): [Blueprint<ApiType>?, Contract<ApiType>?] =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
: [blueprint, contract],
[] as [Blueprint<ApiType>?, Contract<ApiType>?])
) || []));
.instantiateWithCode(
value,
gasLimit,
compactAddLength(this.code),
this.abi.findConstructor(constructorOrId).toU8a(params),
encodeSalt(salt)
)
.withResultTransform((result: ISubmittableResult) =>
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
: [blueprint, contract],
[])
) || []))
);
}
}
+34 -55
View File
@@ -4,8 +4,8 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { Bytes } from '@polkadot/types';
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
@@ -13,15 +13,16 @@ import BN from 'bn.js';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { createTypeUnsafe } from '@polkadot/types';
import { assert, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { Abi } from '../Abi';
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
import { applyOnEvent, extractOptions, isOptions } from '../util';
import { Base } from './Base';
// As per Rust, 5 * GAS_PER_SEC
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
const l = logger('Contract');
@@ -50,33 +51,6 @@ export class ContractSubmittableResult extends SubmittableResult {
}
}
// map from a JSON result to current-style ContractExecResult
function mapExecResult (registry: Registry, json: Record<string, AnyJson>): ContractExecResult {
if (!Object.keys(json).some((key) => ['error', 'success'].includes(key))) {
return registry.createType('ContractExecResult', json);
}
const from = registry.createType('ContractExecResultTo260', json);
if (from.isSuccess) {
const s = from.asSuccess;
return registry.createType('ContractExecResult', {
gasConsumed: s.gasConsumed,
result: {
ok: {
data: s.data,
flags: s.flags
}
}
});
}
// in the old format error has no additional information,
// map it as-is with an "unknown" error
return registry.createType('ContractExecResult', { result: { err: { other: 'unknown' } } });
}
export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
/**
* @description The on-chain address for this contract
@@ -120,19 +94,24 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
const gasLimit = bnToBn(_gasLimit);
return gasLimit.lten(0)
return gasLimit.lte(BN_ZERO)
? isCall
? MAX_CALL_GAS
: (this.api.consts.system.blockWeights
? this.api.consts.system.blockWeights.maxBlock
: this.api.consts.system.maximumBlockWeight as Weight
).muln(64).divn(100)
).muln(64).div(BN_HUNDRED)
: gasLimit;
}
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
return this.api.tx.contracts
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
.call(
this.address,
value,
this.#getGas(gasLimit),
this.abi.findMessage(messageOrId).toU8a(params)
)
.withResultTransform((result: ISubmittableResult) =>
// ContractEmitted is the current generation, ContractExecution is the previous generation
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
@@ -151,7 +130,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
);
}
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
const message = this.abi.findMessage(messageOrId);
@@ -159,24 +138,24 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
this.api.rx.rpc.contracts.call.json({
dest: this.address,
gasLimit: this.#getGas(gasLimit, true),
inputData: message.toU8a(params),
origin,
value
}).pipe(map((json): ContractCallOutcome => {
const { debugMessage, gasConsumed, result } = mapExecResult(this.registry, json.toJSON());
return {
debugMessage,
gasConsumed,
output: result.isOk && message.returnType
? formatData(this.registry, result.asOk.data, message.returnType)
: null,
result
};
}))
this.api.rx.rpc.contracts
.call({
dest: this.address,
gasLimit: this.#getGas(gasLimit, true),
inputData: message.toU8a(params),
origin,
value
})
.pipe(
map(({ debugMessage, gasConsumed, result }): ContractCallOutcome => ({
debugMessage,
gasConsumed,
output: result.isOk && message.returnType
? createTypeUnsafe(this.registry, message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
: null,
result
}))
)
)
};
}
+1 -4
View File
@@ -11,10 +11,7 @@ export const mockApi = {
rx: {
tx: {
contracts: {
instantiate: (): never => {
throw new Error('mock');
},
putCode: (): never => {
instantiateWithCode: (): never => {
throw new Error('mock');
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ export interface ContractGeneric<O, T> {
}
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
? Observable<Observable<T>>
? Observable<T>
: Promise<ObsInnerType<Observable<T>>>;
export interface ContractCallSend<ApiType extends ApiTypes> {
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '4.11.2' };
+1 -1
View File
@@ -42,7 +42,7 @@ export interface AbiMessage {
method: string;
returnType?: TypeDef | null;
selector: ContractSelector;
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
toU8a: (params: CodecArg[]) => Uint8Array;
}
export type AbiConstructor = AbiMessage;
+1 -7
View File
@@ -2,24 +2,18 @@
// SPDX-License-Identifier: Apache-2.0
import type { SubmittableResult } from '@polkadot/api';
import type { Raw } from '@polkadot/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
import type { CodecArg } from '@polkadot/types/types';
import type { BlueprintOptions, ContractOptions } from './types';
import BN from 'bn.js';
import { createTypeUnsafe } from '@polkadot/types/create';
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
type TOptions = BlueprintOptions | ContractOptions;
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
}
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
if (result.isInBlock || result.isFinalized) {
const records = result.filterRecords('contracts', types);
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -20,16 +20,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.9.1",
"@polkadot/rpc-core": "4.9.1",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/util-crypto": "^6.3.1",
"@polkadot/x-rxjs": "^6.3.1",
"@polkadot/api": "4.11.2",
"@polkadot/rpc-core": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^6.3.1",
"@polkadot/rpc-provider": "4.9.1"
"@polkadot/keyring": "^6.5.1",
"@polkadot/rpc-provider": "4.11.2"
}
}
+5 -1
View File
@@ -41,7 +41,11 @@ function parseFlags (address: AccountId | Address | string | null | undefined, [
*/
export function flags (instanceId: string, api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
const councilSection = api.query.phragmenElection
? 'phragmenElection'
: api.query.electionsPhragmen
? 'electionsPhragmen'
: 'elections';
return combineLatest<FlagsIntermediate>([
address && api.query[councilSection]?.members
+2 -2
View File
@@ -44,11 +44,11 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
if (Array.isArray(locks)) {
// only get the locks that are valid until passed the current block
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
allLocked = lockedBreakdown.some(({ amount }) => amount.isMax());
allLocked = lockedBreakdown.some(({ amount }) => amount && amount.isMax());
vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0)));
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax());
const notAll = lockedBreakdown.filter(({ amount }) => amount && !amount.isMax());
if (notAll.length) {
lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
+4 -4
View File
@@ -21,7 +21,7 @@ function isVoter (value: VoteEntry): value is Voter {
}
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
)
@@ -29,7 +29,7 @@ function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][
}
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
)
@@ -61,7 +61,7 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
}
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
const elections = (api.query.electionsPhragmen || api.query.elections);
const elections = (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections);
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
map((entries): DeriveCouncilVotes =>
@@ -77,7 +77,7 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
(api.query.electionsPhragmen || api.query.elections).stakeOf
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf
? retrievePrev(api)
: retrieveCurrent(api)
);
+5 -1
View File
@@ -42,7 +42,11 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
}
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
const section = api.query.phragmenElection
? 'phragmenElection'
: api.query.electionsPhragmen
? 'electionsPhragmen'
: 'elections';
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
api.query.council.members,
+1 -1
View File
@@ -48,7 +48,7 @@ const deriveAvail: Record<string, string[]> = {
contracts: ['contracts'],
council: ['council'],
democracy: ['democracy'],
elections: ['electionsPhragmen', 'elections'],
elections: ['phragmenElection', 'electionsPhragmen', 'elections'],
imOnline: ['imOnline'],
membership: ['membership'],
parachains: ['parachains', 'registrar'],
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '4.11.2' };
@@ -28,7 +28,7 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, era
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
const valPoints = allValPoints[validatorId] || BN_ZERO;
const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
const expTotal = exposure.total.unwrap();
const expTotal = exposure.total?.unwrap() || BN_ZERO;
let avail = BN_ZERO;
let value: BN | undefined;
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -20,16 +20,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api-derive": "4.9.1",
"@polkadot/keyring": "^6.3.1",
"@polkadot/metadata": "4.9.1",
"@polkadot/rpc-core": "4.9.1",
"@polkadot/rpc-provider": "4.9.1",
"@polkadot/types": "4.9.1",
"@polkadot/types-known": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/util-crypto": "^6.3.1",
"@polkadot/x-rxjs": "^6.3.1",
"@polkadot/api-derive": "4.11.2",
"@polkadot/keyring": "^6.5.1",
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-core": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/types-known": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
}
+110 -36
View File
@@ -3,6 +3,7 @@
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Schedule } from '@polkadot/types/interfaces/contracts';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { EraIndex } from '@polkadot/types/interfaces/staking';
@@ -14,7 +15,6 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/consts' {
export interface AugmentedConsts<ApiType> {
babe: {
[key: string]: Codec;
/**
* The amount of time, in slots, that each epoch should last.
* NOTE: Currently it is not possible to change the epoch duration after
@@ -29,16 +29,22 @@ declare module '@polkadot/api/types/consts' {
* the probability of a slot being empty).
**/
expectedBlockTime: Moment & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
balances: {
[key: string]: Codec;
/**
* The minimum amount required to keep an account open.
**/
existentialDeposit: Balance & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
bounties: {
[key: string]: Codec;
/**
* Percentage of the curator fee that will be reserved upfront as deposit for bounty curator.
**/
@@ -67,9 +73,12 @@ declare module '@polkadot/api/types/consts' {
* Maximum acceptable reason length.
**/
maximumReasonLength: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
contracts: {
[key: string]: Codec;
/**
* The maximum number of tries that can be queued for deletion.
**/
@@ -104,20 +113,6 @@ declare module '@polkadot/api/types/consts' {
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
**/
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
/**
* The maximum length of a contract code in bytes. This limit applies to the instrumented
* version of the code. Therefore `instantiate_with_code` can fail even when supplying
* a wasm binary below this maximum size.
**/
maxCodeSize: u32 & AugmentedConst<ApiType>;
/**
* The maximum nesting level of a call/instantiate stack.
**/
maxDepth: u32 & AugmentedConst<ApiType>;
/**
* The maximum size of a storage value and event payload in bytes.
**/
maxValueSize: u32 & AugmentedConst<ApiType>;
/**
* The fraction of the deposit that should be used as rent per block.
*
@@ -126,6 +121,10 @@ declare module '@polkadot/api/types/consts' {
* This determines how high this rent payment is per block as a fraction of the deposit.
**/
rentFraction: Perbill & AugmentedConst<ApiType>;
/**
* Cost schedule and limits.
**/
schedule: Schedule & AugmentedConst<ApiType>;
/**
* Number of block delay an extrinsic claim surcharge has.
*
@@ -142,9 +141,12 @@ declare module '@polkadot/api/types/consts' {
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
democracy: {
[key: string]: Codec;
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
@@ -181,9 +183,12 @@ declare module '@polkadot/api/types/consts' {
* How often (in blocks) to check for new votes.
**/
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
electionProviderMultiPhase: {
[key: string]: Codec;
/**
* The repeat threshold of the offchain worker.
*
@@ -204,9 +209,12 @@ declare module '@polkadot/api/types/consts' {
* Duration of the unsigned phase.
**/
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
elections: {
[key: string]: Codec;
/**
* How much should be locked up in order to submit one's candidacy.
**/
@@ -240,9 +248,12 @@ declare module '@polkadot/api/types/consts' {
* The amount of bond that need to be locked for each vote (32 bytes).
**/
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
gilt: {
[key: string]: Codec;
/**
* Portion of the queue which is free from ordering and just a FIFO.
*
@@ -286,9 +297,12 @@ declare module '@polkadot/api/types/consts' {
* this value multiplied by `Period`.
**/
queueCount: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
identity: {
[key: string]: Codec;
/**
* The amount held on deposit for a registered identity
**/
@@ -317,21 +331,36 @@ declare module '@polkadot/api/types/consts' {
* another trie item whose value is the size of an account ID plus 32 bytes.
**/
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
indices: {
[key: string]: Codec;
/**
* The deposit needed for reserving an index.
**/
deposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
lottery: {
[key: string]: Codec;
/**
* The max number of calls available in a single lottery.
**/
maxCalls: u32 & AugmentedConst<ApiType>;
/**
* The Lottery's pallet id
**/
palletId: PalletId & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
multisig: {
[key: string]: Codec;
/**
* The base amount of currency needed to reserve for creating a multisig execution or to store
* a dispatch call for later.
@@ -345,9 +374,12 @@ declare module '@polkadot/api/types/consts' {
* The maximum amount of signatories allowed for a given multisig.
**/
maxSignatories: u16 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
proxy: {
[key: string]: Codec;
/**
* The base amount of currency needed to reserve for creating an announcement.
*
@@ -384,15 +416,23 @@ declare module '@polkadot/api/types/consts' {
* `32 + proxy_type.encode().len()` bytes of data.
**/
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
recovery: {
[key: string]: Codec;
/**
* The base amount of currency needed to reserve for creating a recovery configuration.
*
* This is held for an additional storage item whose value size is
* `2 + sizeof(BlockNumber, Balance)` bytes.
**/
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of currency needed per additional user when creating a recovery configuration.
*
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
**/
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
@@ -401,11 +441,20 @@ declare module '@polkadot/api/types/consts' {
maxFriends: u16 & AugmentedConst<ApiType>;
/**
* The base amount of currency needed to reserve for starting a recovery.
*
* This is primarily held for deterring malicious recovery attempts, and should
* have a value large enough that a bad actor would choose not to place this
* deposit. It also acts to fund additional storage item whose value size is
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
* threshold.
**/
recoveryDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
society: {
[key: string]: Codec;
/**
* The minimum amount of a deposit required for a bid to be made.
**/
@@ -440,9 +489,12 @@ declare module '@polkadot/api/types/consts' {
* doesn't vote or someone votes in the wrong way.
**/
wrongSideDeduction: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
staking: {
[key: string]: Codec;
/**
* Number of eras that staked funds must remain bonded for.
**/
@@ -470,9 +522,12 @@ declare module '@polkadot/api/types/consts' {
* intervention.
**/
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
system: {
[key: string]: Codec;
/**
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
**/
@@ -501,9 +556,12 @@ declare module '@polkadot/api/types/consts' {
* Get the chain's current version.
**/
version: RuntimeVersion & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
timestamp: {
[key: string]: Codec;
/**
* The minimum period between blocks. Beware that this is different to the *expected* period
* that the block production apparatus provides. Your chosen consensus system will generally
@@ -511,9 +569,12 @@ declare module '@polkadot/api/types/consts' {
* period on default settings.
**/
minimumPeriod: Moment & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
tips: {
[key: string]: Codec;
/**
* The amount held on deposit per byte within the tip report reason.
**/
@@ -534,9 +595,12 @@ declare module '@polkadot/api/types/consts' {
* The amount held on deposit for placing a tip report.
**/
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
transactionPayment: {
[key: string]: Codec;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
@@ -545,9 +609,12 @@ declare module '@polkadot/api/types/consts' {
* The polynomial that is applied in order to derive fee from weight.
**/
weightToFee: Vec<WeightToFeeCoefficient> & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
treasury: {
[key: string]: Codec;
/**
* Percentage of spare funds (if any) that are burnt per spend period.
**/
@@ -569,13 +636,20 @@ declare module '@polkadot/api/types/consts' {
* Period between successive spends.
**/
spendPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
vesting: {
[key: string]: Codec;
/**
* The minimum amount transferred to call `vested_transfer`.
**/
minVestedTransfer: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
}
+130 -54
View File
@@ -6,7 +6,6 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/errors' {
export interface AugmentedErrors<ApiType> {
assets: {
[key: string]: AugmentedError<ApiType>;
/**
* Invalid metadata given.
**/
@@ -43,10 +42,6 @@ declare module '@polkadot/api/types/errors' {
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
**/
NoProvider: AugmentedError<ApiType>;
/**
* A mint operation lead to an overflow.
**/
Overflow: AugmentedError<ApiType>;
/**
* No approval exists that would allow the transfer.
**/
@@ -59,9 +54,12 @@ declare module '@polkadot/api/types/errors' {
* The source account would not survive the transfer and it needs to stay alive.
**/
WouldDie: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
authorship: {
[key: string]: AugmentedError<ApiType>;
/**
* The uncle is genesis.
**/
@@ -90,9 +88,12 @@ declare module '@polkadot/api/types/errors' {
* Uncles already set in the block.
**/
UnclesAlreadySet: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
babe: {
[key: string]: AugmentedError<ApiType>;
/**
* A given equivocation report is valid but already previously reported.
**/
@@ -105,9 +106,12 @@ declare module '@polkadot/api/types/errors' {
* A key ownership proof provided as part of an equivocation report is invalid.
**/
InvalidKeyOwnershipProof: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
balances: {
[key: string]: AugmentedError<ApiType>;
/**
* Beneficiary account must pre-exist
**/
@@ -132,17 +136,16 @@ declare module '@polkadot/api/types/errors' {
* Account liquidity restrictions prevent withdrawal
**/
LiquidityRestrictions: AugmentedError<ApiType>;
/**
* Got an overflow after adding
**/
Overflow: AugmentedError<ApiType>;
/**
* Vesting balance too high to send value
**/
VestingBalance: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
bounties: {
[key: string]: AugmentedError<ApiType>;
/**
* Proposer's balance is too low.
**/
@@ -180,9 +183,12 @@ declare module '@polkadot/api/types/errors' {
* The bounty status is unexpected.
**/
UnexpectedStatus: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
contracts: {
[key: string]: AugmentedError<ApiType>;
/**
* Performing the requested transfer would have brought the contract below
* the subsistence threshold. No transfer is allowed to do this in order to allow
@@ -210,6 +216,10 @@ declare module '@polkadot/api/types/errors' {
* Contract trapped during execution.
**/
ContractTrapped: AugmentedError<ApiType>;
/**
* The debug message specified to `seal_debug_message` does contain invalid UTF-8.
**/
DebugMessageInvalidUTF8: AugmentedError<ApiType>;
/**
* Input passed to a contract API function failed to decode as expected type.
**/
@@ -308,6 +318,12 @@ declare module '@polkadot/api/types/errors' {
* when number of storage items is too large.
**/
StorageExhausted: AugmentedError<ApiType>;
/**
* A contract self destructed in its constructor.
*
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
**/
TerminatedInConstructor: AugmentedError<ApiType>;
/**
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
**/
@@ -322,9 +338,12 @@ declare module '@polkadot/api/types/errors' {
* The size defined in `T::MaxValueSize` was exceeded.
**/
ValueTooLarge: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
council: {
[key: string]: AugmentedError<ApiType>;
/**
* Members are already initialized!
**/
@@ -365,9 +384,12 @@ declare module '@polkadot/api/types/errors' {
* The given weight bound for the proposal was too low.
**/
WrongProposalWeight: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
democracy: {
[key: string]: AugmentedError<ApiType>;
/**
* Cannot cancel the same proposal twice
**/
@@ -460,10 +482,6 @@ declare module '@polkadot/api/types/errors' {
* The given account did not vote on the referendum.
**/
NotVoter: AugmentedError<ApiType>;
/**
* An unexpected integer overflow occurred.
**/
Overflow: AugmentedError<ApiType>;
/**
* Invalid preimage
**/
@@ -492,10 +510,6 @@ declare module '@polkadot/api/types/errors' {
* Maximum number of proposals reached.
**/
TooManyProposals: AugmentedError<ApiType>;
/**
* An unexpected integer underflow occurred.
**/
Underflow: AugmentedError<ApiType>;
/**
* Value too low
**/
@@ -509,9 +523,12 @@ declare module '@polkadot/api/types/errors' {
* Invalid upper bound.
**/
WrongUpperBound: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: AugmentedError<ApiType>;
/**
* OCW submitted solution for wrong round
**/
@@ -528,9 +545,12 @@ declare module '@polkadot/api/types/errors' {
* Wrong number of winners presented.
**/
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
elections: {
[key: string]: AugmentedError<ApiType>;
/**
* Duplicated candidate submission.
**/
@@ -599,9 +619,12 @@ declare module '@polkadot/api/types/errors' {
* Cannot vote when no candidates or members exist.
**/
UnableToVote: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
gilt: {
[key: string]: AugmentedError<ApiType>;
/**
* The amount of the bid is less than the minimum allowed.
**/
@@ -635,9 +658,12 @@ declare module '@polkadot/api/types/errors' {
* Gilt index is unknown.
**/
Unknown: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
grandpa: {
[key: string]: AugmentedError<ApiType>;
/**
* Attempt to signal GRANDPA change with one already pending.
**/
@@ -668,9 +694,12 @@ declare module '@polkadot/api/types/errors' {
* Cannot signal forced change so soon after last.
**/
TooSoon: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
identity: {
[key: string]: AugmentedError<ApiType>;
/**
* Account ID is already named.
**/
@@ -735,9 +764,12 @@ declare module '@polkadot/api/types/errors' {
* Too many subs-accounts.
**/
TooManySubAccounts: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
imOnline: {
[key: string]: AugmentedError<ApiType>;
/**
* Duplicated heartbeat.
**/
@@ -746,9 +778,12 @@ declare module '@polkadot/api/types/errors' {
* Non existent public key.
**/
InvalidKey: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
indices: {
[key: string]: AugmentedError<ApiType>;
/**
* The index was not available.
**/
@@ -769,9 +804,12 @@ declare module '@polkadot/api/types/errors' {
* The index is permanent and may not be freed/changed.
**/
Permanent: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
lottery: {
[key: string]: AugmentedError<ApiType>;
/**
* A lottery has already ended.
**/
@@ -796,17 +834,16 @@ declare module '@polkadot/api/types/errors' {
* A lottery has not been configured.
**/
NotConfigured: AugmentedError<ApiType>;
/**
* An overflow has occurred.
**/
Overflow: AugmentedError<ApiType>;
/**
* Too many calls for a single lottery.
**/
TooManyCalls: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
multisig: {
[key: string]: AugmentedError<ApiType>;
/**
* Call is already approved by this signatory.
**/
@@ -863,9 +900,12 @@ declare module '@polkadot/api/types/errors' {
* A different timepoint was given to the multisig operation that is underway.
**/
WrongTimepoint: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
proxy: {
[key: string]: AugmentedError<ApiType>;
/**
* Account is already a proxy.
**/
@@ -898,9 +938,12 @@ declare module '@polkadot/api/types/errors' {
* A call which is incompatible with the proxy type's filter was attempted.
**/
Unproxyable: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
recovery: {
[key: string]: AugmentedError<ApiType>;
/**
* This account is already set up for recovery
**/
@@ -953,10 +996,6 @@ declare module '@polkadot/api/types/errors' {
* A recovery process has not started for this rescuer
**/
NotStarted: AugmentedError<ApiType>;
/**
* There was an overflow in a calculation
**/
Overflow: AugmentedError<ApiType>;
/**
* There are still active recovery attempts that need to be closed
**/
@@ -969,9 +1008,12 @@ declare module '@polkadot/api/types/errors' {
* Threshold must be greater than zero
**/
ZeroThreshold: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
scheduler: {
[key: string]: AugmentedError<ApiType>;
/**
* Failed to schedule a call
**/
@@ -988,9 +1030,12 @@ declare module '@polkadot/api/types/errors' {
* Given target block number is in the past.
**/
TargetBlockNumberInPast: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
session: {
[key: string]: AugmentedError<ApiType>;
/**
* Registered duplicate key.
**/
@@ -1011,9 +1056,12 @@ declare module '@polkadot/api/types/errors' {
* No keys are associated with this account.
**/
NoKeys: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
society: {
[key: string]: AugmentedError<ApiType>;
/**
* User has already made a bid.
**/
@@ -1086,9 +1134,12 @@ declare module '@polkadot/api/types/errors' {
* User is suspended.
**/
Suspended: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
staking: {
[key: string]: AugmentedError<ApiType>;
/**
* Stash is already bonded.
**/
@@ -1169,16 +1220,22 @@ declare module '@polkadot/api/types/errors' {
* Too many nomination targets supplied.
**/
TooManyTargets: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
sudo: {
[key: string]: AugmentedError<ApiType>;
/**
* Sender must be the Sudo account
**/
RequireSudo: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
system: {
[key: string]: AugmentedError<ApiType>;
/**
* Failed to extract the runtime version from the new runtime.
*
@@ -1203,9 +1260,12 @@ declare module '@polkadot/api/types/errors' {
* and the new runtime.
**/
SpecVersionNeedsToIncrease: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
technicalCommittee: {
[key: string]: AugmentedError<ApiType>;
/**
* Members are already initialized!
**/
@@ -1246,9 +1306,12 @@ declare module '@polkadot/api/types/errors' {
* The given weight bound for the proposal was too low.
**/
WrongProposalWeight: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
technicalMembership: {
[key: string]: AugmentedError<ApiType>;
/**
* Already a member.
**/
@@ -1257,9 +1320,12 @@ declare module '@polkadot/api/types/errors' {
* Not a member.
**/
NotMember: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
tips: {
[key: string]: AugmentedError<ApiType>;
/**
* The tip was already found/started.
**/
@@ -1284,9 +1350,12 @@ declare module '@polkadot/api/types/errors' {
* The tip hash is unknown.
**/
UnknownTip: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
treasury: {
[key: string]: AugmentedError<ApiType>;
/**
* Proposer's balance is too low.
**/
@@ -1299,9 +1368,12 @@ declare module '@polkadot/api/types/errors' {
* Too many approvals in the queue.
**/
TooManyApprovals: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
vesting: {
[key: string]: AugmentedError<ApiType>;
/**
* Amount being transferred is too low to create a vesting schedule.
**/
@@ -1314,6 +1386,10 @@ declare module '@polkadot/api/types/errors' {
* The account given is not vesting.
**/
NotVesting: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
}
+120 -30
View File
@@ -27,7 +27,6 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/events' {
export interface AugmentedEvents<ApiType> {
assets: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An approval for account `delegate` was cancelled by `owner`.
* \[id, owner, delegate\]
@@ -105,9 +104,12 @@ declare module '@polkadot/api/types/events' {
* \[id, owner, delegate, destination\]
**/
TransferredApproved: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, AccountId, TAssetBalance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
balances: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A balance was set by root. \[who, free, reserved\]
**/
@@ -143,9 +145,12 @@ declare module '@polkadot/api/types/events' {
* Some balance was unreserved (moved from reserved to free). \[who, value\]
**/
Unreserved: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
bounties: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A bounty is awarded to a beneficiary. \[index, beneficiary\]
**/
@@ -174,9 +179,12 @@ declare module '@polkadot/api/types/events' {
* A bounty proposal was rejected; funds were slashed. \[index, bond\]
**/
BountyRejected: AugmentedEvent<ApiType, [BountyIndex, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
contracts: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A code with the specified hash was removed.
* \[code_hash\]
@@ -243,9 +251,12 @@ declare module '@polkadot/api/types/events' {
* this event is by calling `seal_terminate`.
**/
Terminated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
council: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A motion was approved by the required threshold.
* \[proposal_hash\]
@@ -283,9 +294,12 @@ declare module '@polkadot/api/types/events' {
* \[account, proposal_hash, voted, yes, no\]
**/
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
democracy: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A proposal \[hash\] has been blacklisted permanently.
**/
@@ -362,9 +376,12 @@ declare module '@polkadot/api/types/events' {
* An external proposal has been vetoed. \[who, proposal_hash, until\]
**/
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: AugmentedEvent<ApiType>;
/**
* The election has been finalized, with `Some` of the given computation, or else if the
* election failed, `None`.
@@ -393,9 +410,12 @@ declare module '@polkadot/api/types/events' {
* The unsigned phase of the given round has started.
**/
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
elections: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A \[candidate\] was slashed by \[amount\] due to failing to obtain a seat as member or
* runner-up.
@@ -433,9 +453,12 @@ declare module '@polkadot/api/types/events' {
* A \[seat holder\] was slashed by \[amount\] by being forcefully removed from the set.
**/
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
gilt: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A bid was successfully placed.
* \[ who, amount, duration \]
@@ -456,9 +479,12 @@ declare module '@polkadot/api/types/events' {
* \[ index, who, original_amount, additional_amount \]
**/
GiltThawed: AugmentedEvent<ApiType, [ActiveIndex, AccountId, BalanceOf, BalanceOf]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
grandpa: {
[key: string]: AugmentedEvent<ApiType>;
/**
* New authority set has been applied. \[authority_set\]
**/
@@ -471,9 +497,12 @@ declare module '@polkadot/api/types/events' {
* Current authority set has been resumed.
**/
Resumed: AugmentedEvent<ApiType, []>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
identity: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A name was cleared, and the given balance returned. \[who, deposit\]
**/
@@ -516,9 +545,12 @@ declare module '@polkadot/api/types/events' {
* main identity account to the sub-identity account. \[sub, main, deposit\]
**/
SubIdentityRevoked: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
imOnline: {
[key: string]: AugmentedEvent<ApiType>;
/**
* At the end of the session, no offence was committed.
**/
@@ -531,9 +563,12 @@ declare module '@polkadot/api/types/events' {
* At the end of the session, at least one validator was found to be \[offline\].
**/
SomeOffline: AugmentedEvent<ApiType, [Vec<IdentificationTuple>]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
indices: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A account index was assigned. \[index, who\]
**/
@@ -546,9 +581,12 @@ declare module '@polkadot/api/types/events' {
* A account index has been frozen to its current account ID. \[index, who\]
**/
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
lottery: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A new set of calls have been set!
**/
@@ -565,9 +603,12 @@ declare module '@polkadot/api/types/events' {
* A winner has been chosen!
**/
Winner: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
multisig: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A multisig operation has been approved by someone.
* \[approving, timepoint, multisig, call_hash\]
@@ -585,18 +626,24 @@ declare module '@polkadot/api/types/events' {
* A new multisig operation has begun. \[approving, multisig, call_hash\]
**/
NewMultisig: AugmentedEvent<ApiType, [AccountId, AccountId, CallHash]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
offences: {
[key: string]: AugmentedEvent<ApiType>;
/**
* There is an offence reported of the given `kind` happened at the `session_index` and
* (kind-specific) time slot. This event is not deposited for duplicate slashes.
* \[kind, timeslot\].
**/
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
proxy: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An announcement was placed to make a call in the future. \[real, proxy, call_hash\]
**/
@@ -610,9 +657,12 @@ declare module '@polkadot/api/types/events' {
* A proxy was executed correctly, with the given \[result\].
**/
ProxyExecuted: AugmentedEvent<ApiType, [DispatchResult]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
recovery: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Lost account has been successfully recovered by rescuer account.
* \[lost, rescuer\]
@@ -641,9 +691,12 @@ declare module '@polkadot/api/types/events' {
* \[lost, rescuer, sender\]
**/
RecoveryVouched: AugmentedEvent<ApiType, [AccountId, AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
scheduler: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Canceled some task. \[when, index\]
**/
@@ -656,17 +709,23 @@ declare module '@polkadot/api/types/events' {
* Scheduled some task. \[when, index\]
**/
Scheduled: AugmentedEvent<ApiType, [BlockNumber, u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
session: {
[key: string]: AugmentedEvent<ApiType>;
/**
* New session has happened. Note that the argument is the \[session_index\], not the block
* number as the type might suggest.
**/
NewSession: AugmentedEvent<ApiType, [SessionIndex]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
society: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A \[candidate\] was dropped (due to an excess of bids in the system).
**/
@@ -734,9 +793,12 @@ declare module '@polkadot/api/types/events' {
* their offer is the second. The vouching party is the third. \[candidate_id, offer, vouching\]
**/
Vouch: AugmentedEvent<ApiType, [AccountId, Balance, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
staking: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An account has bonded this amount. \[stash, amount\]
*
@@ -781,9 +843,12 @@ declare module '@polkadot/api/types/events' {
* from the unlocking queue. \[stash, amount\]
**/
Withdrawn: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
sudo: {
[key: string]: AugmentedEvent<ApiType>;
/**
* The \[sudoer\] just switched identity; the old key is supplied.
**/
@@ -796,9 +861,12 @@ declare module '@polkadot/api/types/events' {
* A sudo just took place. \[result\]
**/
SudoAsDone: AugmentedEvent<ApiType, [DispatchResult]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
system: {
[key: string]: AugmentedEvent<ApiType>;
/**
* `:code` was updated.
**/
@@ -823,9 +891,12 @@ declare module '@polkadot/api/types/events' {
* On on-chain remark happened. \[origin, remark_hash\]
**/
Remarked: AugmentedEvent<ApiType, [AccountId, Hash]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
technicalCommittee: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A motion was approved by the required threshold.
* \[proposal_hash\]
@@ -863,9 +934,12 @@ declare module '@polkadot/api/types/events' {
* \[account, proposal_hash, voted, yes, no\]
**/
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
technicalMembership: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Phantom member, never used.
**/
@@ -890,9 +964,12 @@ declare module '@polkadot/api/types/events' {
* Two members were swapped; see the transaction for who.
**/
MembersSwapped: AugmentedEvent<ApiType, []>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
tips: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A new tip suggestion has been opened. \[tip_hash\]
**/
@@ -913,9 +990,12 @@ declare module '@polkadot/api/types/events' {
* A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
**/
TipSlashed: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
treasury: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
**/
@@ -945,9 +1025,12 @@ declare module '@polkadot/api/types/events' {
* We have ended a spend period and will now allocate funds. \[budget_remaining\]
**/
Spending: AugmentedEvent<ApiType, [Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
utility: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Batch of dispatches completed fully with no error.
**/
@@ -957,9 +1040,12 @@ declare module '@polkadot/api/types/events' {
* well as the error. \[index, error\]
**/
BatchInterrupted: AugmentedEvent<ApiType, [u32, DispatchError]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
vesting: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An \[account\] has become fully vested. No further vesting can happen.
**/
@@ -970,6 +1056,10 @@ declare module '@polkadot/api/types/events' {
* \[account, unvested\]
**/
VestingUpdated: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
}
+156 -54
View File
@@ -3,13 +3,13 @@
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule } from '@polkadot/types/interfaces/contracts';
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
@@ -35,16 +35,16 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/storage' {
export interface AugmentedQueries<ApiType> {
assets: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The number of units of assets held by any given account.
**/
account: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
account: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
/**
* Approved balance transfers. First balance is the amount approved for transfer. Second
* is the amount of `T::Currency` reserved for storing this.
* First key is the asset ID, second key is the owner and third key is the delegate.
**/
approvals: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AssetApprovalKey | { owner?: any; delegate?: any } | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AssetApprovalKey]> & QueryableStorageEntry<ApiType, [AssetId, AssetApprovalKey]>;
approvals: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array, arg3: AccountId | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId, AccountId]>;
/**
* Details of an asset.
**/
@@ -53,9 +53,12 @@ declare module '@polkadot/api/types/storage' {
* Metadata of an asset.
**/
metadata: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<AssetMetadata>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
authorship: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Author of current block.
**/
@@ -68,9 +71,12 @@ declare module '@polkadot/api/types/storage' {
* Uncles
**/
uncles: AugmentedQuery<ApiType, () => Observable<Vec<UncleEntryItem>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
babe: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current epoch authorities.
**/
@@ -165,9 +171,12 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
**/
underConstruction: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Randomness>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
balances: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The balance of an account.
*
@@ -189,9 +198,12 @@ declare module '@polkadot/api/types/storage' {
* The total units issued in the system.
**/
totalIssuance: AugmentedQuery<ApiType, () => Observable<Balance>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
bounties: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Bounties that have been made.
**/
@@ -208,9 +220,12 @@ declare module '@polkadot/api/types/storage' {
* The description of each bounty.
**/
bountyDescriptions: AugmentedQuery<ApiType, (arg: BountyIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [BountyIndex]> & QueryableStorageEntry<ApiType, [BountyIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
contracts: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The subtrie counter.
**/
@@ -225,10 +240,6 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE since `AccountId` is a secure hash.
**/
contractInfoOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ContractInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Current cost schedule for contracts.
**/
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Evicted contracts that await child trie deletion.
*
@@ -240,9 +251,12 @@ declare module '@polkadot/api/types/storage' {
* A mapping from an original code hash to the original code, untouched by instrumentation.
**/
pristineCode: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<Bytes>>, [CodeHash]> & QueryableStorageEntry<ApiType, [CodeHash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
council: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current members of the collective. This is stored sorted (just by value).
**/
@@ -267,9 +281,12 @@ declare module '@polkadot/api/types/storage' {
* Votes on a given proposal, if it is ongoing.
**/
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
democracy: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* A record of who vetoed what. Maps proposal hash to a possible existent block number
* (until when it may not be resubmitted) and who vetoed it.
@@ -345,9 +362,12 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE as `AccountId`s are crypto hashes anyway.
**/
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current phase.
**/
@@ -383,9 +403,12 @@ declare module '@polkadot/api/types/storage' {
* Only exists when [`Snapshot`] is present.
**/
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
elections: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The present candidate list. A current member or runner-up can never enter this vector
* and is always implicitly assumed to be a candidate.
@@ -418,9 +441,12 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash.
**/
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voter>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
gilt: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The currently active gilts, indexed according to the order of creation.
**/
@@ -441,9 +467,12 @@ declare module '@polkadot/api/types/storage' {
* whose duration is one `Period` would be storage `0`.
**/
queueTotals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[u32, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
grandpa: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The number of changes (both in terms of keys and underlying economic responsibilities)
* in the "set" of Grandpa validators from genesis.
@@ -472,9 +501,12 @@ declare module '@polkadot/api/types/storage' {
* State of the current authority set.
**/
state: AugmentedQuery<ApiType, () => Observable<StoredState>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
identity: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Information that is pertinent to identify the entity behind an account.
*
@@ -501,14 +533,17 @@ declare module '@polkadot/api/types/storage' {
* context. If the account is not some other account's sub-identity, then just `None`.
**/
superOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[AccountId, Data]>>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
imOnline: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* For each session index, we keep a mapping of `ValidatorId<T>` to the
* number of blocks authored by the given authority.
**/
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
authoredBlocks: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
/**
* The block number after which it's ok to send heartbeats in the current
* session.
@@ -531,17 +566,23 @@ declare module '@polkadot/api/types/storage' {
* For each session index, we keep a mapping of `AuthIndex` to
* `offchain::OpaqueNetworkState`.
**/
receivedHeartbeats: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [SessionIndex, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
receivedHeartbeats: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [SessionIndex, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
indices: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The lookup from index to account.
**/
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
lottery: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The calls stored in this pallet to be used in an active lottery if configured
* by `Config::ValidateCall`.
@@ -567,9 +608,12 @@ declare module '@polkadot/api/types/storage' {
* Total number of tickets sold.
**/
ticketsCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
mmr: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Hashes of the nodes in the MMR.
*
@@ -585,21 +629,27 @@ declare module '@polkadot/api/types/storage' {
* Latest MMR Root hash.
**/
rootHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
multisig: {
[key: string]: QueryableStorageEntry<ApiType>;
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[OpaqueCall, AccountId, BalanceOf]>>>, [U8aFixed]> & QueryableStorageEntry<ApiType, [U8aFixed]>;
/**
* The set of open multisig operations.
**/
multisigs: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
multisigs: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
offences: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* A vector of reports of the same kind that happened at the same time slot.
**/
concurrentReportsIndex: AugmentedQueryDoubleMap<ApiType, (key1: Kind | string | Uint8Array, key2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, [Kind, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
concurrentReportsIndex: AugmentedQuery<ApiType, (arg1: Kind | string | Uint8Array, arg2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, [Kind, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
/**
* The primary structure that holds all offence records keyed by report identifiers.
**/
@@ -613,9 +663,12 @@ declare module '@polkadot/api/types/storage' {
* different types are not supported at the moment so we are doing the manual serialization.
**/
reportsByKindIndex: AugmentedQuery<ApiType, (arg: Kind | string | Uint8Array) => Observable<Bytes>, [Kind]> & QueryableStorageEntry<ApiType, [Kind]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
proxy: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The announcements made by the proxy (key).
**/
@@ -625,25 +678,31 @@ declare module '@polkadot/api/types/storage' {
* which are being delegated to, together with the amount held on deposit.
**/
proxies: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Vec<ProxyDefinition>, BalanceOf]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
randomnessCollectiveFlip: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Series of block headers from the last 81 blocks that acts as random seed material. This
* is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of
* the oldest hash.
**/
randomMaterial: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
recovery: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Active recovery attempts.
*
* First account is the account to be recovered, and the second account
* is the user trying to recover the account.
**/
activeRecoveries: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
activeRecoveries: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
/**
* The list of allowed proxy accounts.
*
@@ -654,9 +713,12 @@ declare module '@polkadot/api/types/storage' {
* The set of recoverable accounts and their recovery configuration.
**/
recoverable: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<RecoveryConfig>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
scheduler: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Items to be executed, indexed by the block number that they should be executed on.
**/
@@ -671,9 +733,12 @@ declare module '@polkadot/api/types/storage' {
* New networks start with last version.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
session: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current index of the session.
**/
@@ -706,9 +771,12 @@ declare module '@polkadot/api/types/storage' {
* The current set of validators.
**/
validators: AugmentedQuery<ApiType, () => Observable<Vec<ValidatorId>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
society: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current bids, stored ordered by the value of the bid.
**/
@@ -769,14 +837,17 @@ declare module '@polkadot/api/types/storage' {
/**
* Double map from Candidate -> Voter -> (Maybe) Vote.
**/
votes: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
votes: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
/**
* Members currently vouching or banned from vouching again
**/
vouching: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VouchingStatus>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
staking: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The active era information, it holds index and start.
*
@@ -830,7 +901,7 @@ declare module '@polkadot/api/types/storage' {
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
erasStakers: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasStakers: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Clipped Exposure of validator at era.
*
@@ -844,7 +915,7 @@ declare module '@polkadot/api/types/storage' {
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
erasStakersClipped: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasStakersClipped: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* The session index at which the era start for the last `HISTORY_DEPTH` eras.
*
@@ -864,7 +935,7 @@ declare module '@polkadot/api/types/storage' {
*
* Is it removed after `HISTORY_DEPTH` eras.
**/
erasValidatorPrefs: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasValidatorPrefs: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* The total validator era payout for the last `HISTORY_DEPTH` eras.
*
@@ -906,7 +977,7 @@ declare module '@polkadot/api/types/storage' {
/**
* All slashing events on nominators, mapped by era to the highest slash value of the era.
**/
nominatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
nominatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Where the reward payment should be made. Keyed by stash.
**/
@@ -949,17 +1020,23 @@ declare module '@polkadot/api/types/storage' {
* All slashing events on validators, mapped by era to the highest slash proportion
* and slash value of the era.
**/
validatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
validatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
sudo: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The `AccountId` of the sudo key.
**/
key: AugmentedQuery<ApiType, () => Observable<AccountId>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
system: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The full account information for a particular account ID.
**/
@@ -1034,9 +1111,12 @@ declare module '@polkadot/api/types/storage' {
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
**/
upgradedToU32RefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
technicalCommittee: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current members of the collective. This is stored sorted (just by value).
**/
@@ -1061,9 +1141,12 @@ declare module '@polkadot/api/types/storage' {
* Votes on a given proposal, if it is ongoing.
**/
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
technicalMembership: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current membership, stored as an ordered Vec.
**/
@@ -1072,9 +1155,12 @@ declare module '@polkadot/api/types/storage' {
* The current prime member, if one exists.
**/
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
timestamp: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Did the timestamp get updated in this block?
**/
@@ -1083,9 +1169,12 @@ declare module '@polkadot/api/types/storage' {
* Current time for the current block.
**/
now: AugmentedQuery<ApiType, () => Observable<Moment>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
tips: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Simple preimage lookup from the reason's hash to the original data. Again, has an
* insecure enumerable hash since the key is guaranteed to be the result of a secure hash.
@@ -1097,14 +1186,20 @@ declare module '@polkadot/api/types/storage' {
* guaranteed to be a secure hash.
**/
tips: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<OpenTip>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
transactionPayment: {
[key: string]: QueryableStorageEntry<ApiType>;
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>, []> & QueryableStorageEntry<ApiType, []>;
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
treasury: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Proposal indices that have been approved but not yet awarded.
**/
@@ -1117,13 +1212,20 @@ declare module '@polkadot/api/types/storage' {
* Proposals that have been made.
**/
proposals: AugmentedQuery<ApiType, (arg: ProposalIndex | AnyNumber | Uint8Array) => Observable<Option<TreasuryProposal>>, [ProposalIndex]> & QueryableStorageEntry<ApiType, [ProposalIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
vesting: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Information regarding the vesting of a given account.
**/
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
}
+4
View File
@@ -382,6 +382,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Retrieves the keys with prefix of a specific child storage
**/
getChildKeys: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns proof of storage for child key entries at a specific block state.
**/
getChildReadProof: AugmentedRpc<(childStorageKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: BlockHash | string | Uint8Array) => Observable<ReadProof>>;
/**
* Retrieves the child storage for a key
**/
+127 -40
View File
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple } from '@polkadot/types/types';
import type { AssetDestroyWitness, TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BabeEquivocationProof, NextConfigDescriptor } from '@polkadot/types/interfaces/babe';
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
import type { CodeHash, Schedule } from '@polkadot/types/interfaces/contracts';
import type { CodeHash } from '@polkadot/types/interfaces/contracts';
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
import type { Renouncing } from '@polkadot/types/interfaces/elections';
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
@@ -29,7 +29,6 @@ import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
declare module '@polkadot/api/types/submittable' {
export interface AugmentedSubmittables<ApiType> {
assets: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Approve an amount of asset for transfer by a delegated third-party account.
*
@@ -433,16 +432,22 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(1)`
**/
transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
authorship: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Provide a set of uncles.
**/
setUncles: AugmentedSubmittable<(newUncles: Vec<Header> | (Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Header>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
babe: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Plan an epoch config change. The epoch config change is recorded and will be enacted on
* the next call to `enact_epoch_change`. The config will be activated one epoch after.
@@ -468,9 +473,12 @@ declare module '@polkadot/api/types/submittable' {
* reporter.
**/
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: BabeEquivocationProof | { offender?: any; slotNumber?: any; firstHeader?: any; secondHeader?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [BabeEquivocationProof, KeyOwnerProof]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
balances: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Exactly as `transfer`, except the origin must be root and the source account may be
* specified.
@@ -545,9 +553,12 @@ declare module '@polkadot/api/types/submittable' {
* #</weight>
**/
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
bounties: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Accept the curator role for a bounty.
* A deposit will be reserved from curator and refund upon successful payout.
@@ -667,9 +678,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
unassignCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
contracts: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Makes a call to an account, optionally transferring some balance.
*
@@ -725,17 +739,11 @@ declare module '@polkadot/api/types/submittable' {
**/
instantiateWithCode: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, Bytes, Bytes, Bytes]>;
/**
* Updates the schedule for metering contracts.
*
* The schedule's version cannot be less than the version of the stored schedule.
* If a schedule does not change the instruction weights the version does not
* need to be increased. Therefore we allow storing a schedule that has the same
* version as the stored one.
* Generic tx
**/
updateSchedule: AugmentedSubmittable<(schedule: Schedule | { version?: any; enablePrintln?: any; limits?: any; instructionWeights?: any; hostFnWeights?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Schedule]>;
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
council: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Close a vote that is either approved, disapproved or whose voting period has ended.
*
@@ -872,9 +880,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact<ProposalIndex> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Hash, Compact<ProposalIndex>, bool]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
democracy: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Permanently place a proposal into the blacklist. This prevents it from ever being
* proposed again.
@@ -1205,9 +1216,12 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(R)` where R is the number of referendums the voter has voted on.
**/
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Submit a solution for the unsigned phase.
*
@@ -1225,9 +1239,12 @@ declare module '@polkadot/api/types/submittable' {
* No deposit or reward is associated with this submission.
**/
submitUnsigned: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
elections: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Clean all voters who are defunct (i.e. they do not serve any purpose at all). The
* deposit of the removed voters are returned.
@@ -1330,9 +1347,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
gilt: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Place a bid for a gilt to be issued.
*
@@ -1378,9 +1398,12 @@ declare module '@polkadot/api/types/submittable' {
* - `index`: The index of the gilt to be thawed.
**/
thaw: AugmentedSubmittable<(index: Compact<ActiveIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ActiveIndex>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
grandpa: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Note that the current authority set of the GRANDPA finality gadget has
* stalled. This will trigger a forced authority set change at the beginning
@@ -1410,9 +1433,12 @@ declare module '@polkadot/api/types/submittable' {
* reporter.
**/
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [GrandpaEquivocationProof, KeyOwnerProof]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
identity: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Add a registrar to the system.
*
@@ -1674,9 +1700,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
setSubs: AugmentedSubmittable<(subs: Vec<ITuple<[AccountId, Data]>> | ([AccountId | string | Uint8Array, Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>, [Vec<ITuple<[AccountId, Data]>>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
imOnline: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* # <weight>
* - Complexity: `O(K + E)` where K is length of `Keys` (heartbeat.validators_len)
@@ -1689,9 +1718,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
heartbeat: AugmentedSubmittable<(heartbeat: Heartbeat | { blockNumber?: any; networkState?: any; sessionIndex?: any; authorityIndex?: any; validatorsLen?: any } | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Heartbeat, Signature]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
indices: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Assign an previously unassigned index.
*
@@ -1801,9 +1833,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
lottery: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Buy a ticket to enter the lottery.
*
@@ -1847,9 +1882,12 @@ declare module '@polkadot/api/types/submittable' {
* This extrinsic must be called by the `ManagerOrigin`.
**/
stopRepeat: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
multisig: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Register approval for a dispatch to be made from a deterministic composite account if
* approved by a total of `threshold - 1` of `other_signatories`.
@@ -1986,9 +2024,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
cancelAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], timepoint: Timepoint | { height?: any; index?: any } | string | Uint8Array, callHash: U8aFixed | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16, Vec<AccountId>, Timepoint, U8aFixed]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
proxy: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Register a proxy account for the sender that is able to make calls on its behalf.
*
@@ -2181,9 +2222,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
removeProxy: AugmentedSubmittable<(delegate: AccountId | string | Uint8Array, proxyType: ProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, ProxyType, BlockNumber]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
recovery: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Send a call through a recovered account.
*
@@ -2383,9 +2427,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vouchRecovery: AugmentedSubmittable<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountId]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
scheduler: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Cancel an anonymously scheduled task.
*
@@ -2454,9 +2501,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, BlockNumber, Option<Period>, Priority, Call]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
session: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Removes any session key(s) of the function caller.
* This doesn't take effect until the next session.
@@ -2489,9 +2539,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
setKeys: AugmentedSubmittable<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
society: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* A user outside of the society can make a bid for entry.
*
@@ -2809,9 +2862,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vouch: AugmentedSubmittable<(who: AccountId | string | Uint8Array, value: BalanceOf | AnyNumber | Uint8Array, tip: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, BalanceOf, BalanceOf]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
staking: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Take the origin account as a stash and lock up `value` of its balance. `controller` will
* be the account that controls it.
@@ -3243,9 +3299,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
withdrawUnbonded: AugmentedSubmittable<(numSlashingSpans: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
sudo: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
*
@@ -3298,9 +3357,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
sudoUncheckedWeight: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array, weight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call, Weight]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
system: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* A dispatch that will fill the block weight up to the given ratio.
**/
@@ -3406,9 +3468,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
technicalCommittee: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Close a vote that is either approved, disapproved or whose voting period has ended.
*
@@ -3545,9 +3610,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact<ProposalIndex> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Hash, Compact<ProposalIndex>, bool]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
technicalMembership: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Add a member `who` to the set.
*
@@ -3595,9 +3663,12 @@ declare module '@polkadot/api/types/submittable' {
* Prime membership is *not* passed from `remove` to `add`, if extant.
**/
swapMember: AugmentedSubmittable<(remove: AccountId | string | Uint8Array, add: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountId]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
timestamp: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Set the current time.
*
@@ -3616,9 +3687,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
set: AugmentedSubmittable<(now: Compact<Moment> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<Moment>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
tips: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Close and payout a tip.
*
@@ -3751,9 +3825,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
tipNew: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, AccountId, Compact<BalanceOf>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
treasury: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
* and the original deposit will be returned.
@@ -3791,9 +3868,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
rejectProposal: AugmentedSubmittable<(proposalId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ProposalIndex>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
utility: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Send a call through an indexed pseudonym of the sender.
*
@@ -3847,9 +3927,12 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
batchAll: AugmentedSubmittable<(calls: Vec<Call> | (Call | { callIndex?: any; args?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Call>]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
vesting: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Force a vested transfer.
*
@@ -3923,6 +4006,10 @@ 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]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
}
+32 -30
View File
@@ -39,7 +39,7 @@ interface MetaDecoration {
}
// the max amount of keys/values that we will retrieve at once
const PAGE_SIZE = 384;
const PAGE_SIZE = 256;
const l = logger('api/init');
@@ -291,6 +291,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
(section as Record<string, { json: unknown }>)[methodName].json = decorateMethod(method.json, { methodName }) as unknown;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(section as Record<string, { raw: unknown }>)[methodName].raw = decorateMethod(method.raw, { methodName }) as unknown;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(section as Record<string, { meta: unknown }>)[methodName].meta = method.meta;
}
return section;
@@ -354,7 +356,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(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 */
@@ -363,11 +365,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
decorated.creator = creator;
decorated.at = decorateMethod((hash: Hash, arg1?: Arg, arg2?: Arg): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(arg1, arg2), hash));
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(args), hash));
decorated.hash = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(arg1, arg2)));
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(args)));
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
key.section === creator.section && key.method === creator.method;
@@ -383,40 +385,40 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
: args
))[1]);
decorated.keyPrefix = (key1?: Arg): string =>
u8aToHex(creator.keyPrefix(key1));
decorated.keyPrefix = (...keys: Arg[]): string =>
u8aToHex(creator.keyPrefix(...keys));
decorated.range = decorateMethod((range: [Hash, Hash?], arg1?: Arg, arg2?: Arg): Observable<[Hash, Codec][]> =>
this._decorateStorageRange(decorated, [arg1, arg2], range));
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
this._decorateStorageRange(decorated, args, range));
decorated.size = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2)));
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args)));
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, arg1?: Arg, arg2?: Arg): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2), hash));
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args), hash));
// FIXME NMap support
// .keys() & .entries() only available on map types
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
decorated.entries = decorateMethod(
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, null, doubleMapArg)));
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, null, args)));
decorated.entriesAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, hash, doubleMapArg)));
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, hash, args)));
decorated.entriesPaged = decorateMethod(
memo(this.#instanceId, (opts: PaginationOptions): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntriesPaged(creator, opts)));
decorated.keys = decorateMethod(
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, null, doubleMapArg)));
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, null, args)));
decorated.keysAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, hash, doubleMapArg)));
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, hash, args)));
decorated.keysPaged = decorateMethod(
memo(this.#instanceId, (opts: PaginationOptions): Observable<StorageKey[]> =>
@@ -450,7 +452,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
});
}
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: [Arg?, Arg?], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
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);
return this._rpcCore.state
@@ -481,10 +483,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
);
}
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
const headKey = iterKey(arg).toHex();
const headKey = iterKey(...args).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
const query = at
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
@@ -509,21 +511,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
}
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
const headKey = iterKey(opts.arg).toHex();
const headKey = iterKey(...opts.args).toHex();
return this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
);
}
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<[StorageKey, Codec][]> {
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
const query = at
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
return this._retrieveMapKeys(entry, at, arg).pipe(
return this._retrieveMapKeys(entry, at, args).pipe(
switchMap((keys) =>
keys.length
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
+16 -10
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { RpcInterfaceMethod } from '@polkadot/rpc-core/types';
import type { Text } from '@polkadot/types';
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
@@ -22,7 +23,6 @@ import { detectedCapabilities } from './capabilities';
import { Decorate } from './Decorate';
const KEEPALIVE_INTERVAL = 10000;
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
const l = logger('api/init');
@@ -116,17 +116,21 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// We have to assume that on the RPC layer the calls used here does not call back into
// the registry swap, so getHeader & getRuntimeVersion should not be historic
const header = this._genesisHash.eq(blockHash)
? { number: DEFAULT_BLOCKNUMBER, parentHash: this._genesisHash }
: await this._rpcCore.chain.getHeader(blockHash).toPromise();
const header = this.registry.createType('HeaderPartial',
this._genesisHash.eq(blockHash)
? { number: BN_ZERO, parentHash: this._genesisHash }
: await (this._rpcCore.chain.getHeader as RpcInterfaceMethod).json(blockHash).toPromise()
);
assert(header?.parentHash && !header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
// get the runtime version, either on-chain or via an known upgrade history
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number.unwrap());
const version = (firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
: await this._rpcCore.state.getRuntimeVersion(header.parentHash).toPromise();
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number);
const version = this.registry.createType('RuntimeVersionPartial',
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
: await (this._rpcCore.state.getRuntimeVersion as RpcInterfaceMethod).json(header.parentHash).toPromise()
);
// check for pre-existing registries
const existingViaVersion = this.#registries.find(({ specVersion }) => specVersion.eq(version.specVersion));
@@ -138,7 +142,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
// nothing has been found, construct new
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
const metadata = new Metadata(this.registry,
await (this._rpcCore.state.getMetadata as RpcInterfaceMethod).raw(header.parentHash).toPromise()
);
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
// add our new registry
+1 -1
View File
@@ -150,7 +150,7 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
]);
const raws = filterEntries([
api.query.session?.queuedKeys.key(),
api.query.system?.account.key(emptyAccountId)
api.query.system?.account?.key(emptyAccountId)
]);
return combineLatest([
+6
View File
@@ -129,6 +129,12 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
await api.query.system.account.entries(); // should not take a param
await api.query.staking.nominatorSlashInEra.entries(123); // should take a param
// nmap with keys
await api.query.assets.approvals.keys(123, 'blah');
await api.query.assets.account.keys(123);
await api.query.assets.account.entries(123);
await api.query.assets.blah.keys();
// check range
await api.query.balances.freeBalance.range<Balance>(['0x1234'], pairs.bob.address);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/api', version: '4.11.2' };
+2 -5
View File
@@ -50,13 +50,10 @@ describe('ApiPromise', (): void => {
describe('initialization', (): void => {
it('Create API instance with metadata map and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
const rpcData = await provider.send('state_getMetadata', []);
const rpcData = await provider.send<string>('state_getMetadata', []);
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
const specVersion = 0;
const metadata = { [`${genesisHash}-${specVersion}`]: rpcData as string };
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const api = await ApiPromise.create({ metadata, provider, registry });
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
expect(api.genesisHash).toBeDefined();
expect(api.runtimeMetadata).toBeDefined();
+4 -21
View File
@@ -1,30 +1,12 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
// Prepend an element V onto the beginning of a tuple T.
// Cons<1, [2,3,4]> is [1,2,3,4]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
? R
: never;
export type Push<T extends readonly unknown[], V> = [...T, V]
// Append an element V onto the end of a tuple T
// Push<[1,2,3],4> is [1,2,3,4]
// note that this DOES NOT PRESERVE optionality/readonly in tuples.
// So unfortunately Push<[1, 2?, 3?], 4> is [1,2|undefined,3|undefined,4]
export type Push<T extends any[], V> = (
(
Cons<any, Required<T>> extends infer R
? { [K in keyof R]: K extends keyof T ? T[K] : V }
: never
) extends infer P
? P extends any[] ? P : never
: never
);
export type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any?] ? U : [...T];
export type ApiTypes = 'promise' | 'rxjs';
@@ -75,8 +57,9 @@ export interface DecorateMethodOptions {
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
// FIXME We need a solution for NMap
export interface PaginationOptions<ArgType = CodecArg> {
arg?: ArgType;
args: ArgType[];
pageSize: number;
startKey?: string;
}
+3 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Json, Raw } from '@polkadot/types/codec';
import type { AnyFunction, Callback } from '@polkadot/types/types';
import type { AnyFunction, Callback, DefinitionRpc } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -11,6 +11,7 @@ import { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './b
export interface RpcRxResult<F extends AnyFunction> extends RxResult<F> {
json (...args: Parameters<F>): Observable<Json>;
raw (...args: Parameters<F>): Observable<Raw>;
meta: DefinitionRpc;
}
export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F> {
@@ -18,6 +19,7 @@ export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F
json (...args: Push<Parameters<F>, Callback<Json>>): UnsubscribePromise;
raw (...args: Parameters<F>): Promise<Raw>;
raw (...args: Push<Parameters<F>, Callback<Raw>>): UnsubscribePromise;
meta: DefinitionRpc;
}
export type RpcMethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
+12 -14
View File
@@ -6,7 +6,7 @@ import type { Hash } from '@polkadot/types/interfaces';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { ApiTypes, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
interface StorageEntryObservableMulti {
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
@@ -18,15 +18,16 @@ interface StorageEntryPromiseMulti {
}
export interface StorageEntryPromiseOverloads {
(arg1?: CodecArg, arg2?: CodecArg): Promise<Codec>;
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg): Promise<T>;
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
}
// This is the most generic typings we can have for a storage entry function
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
ApiType extends 'rxjs'
@@ -38,15 +39,15 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string;
keyPrefix: () => string;
keys: <K extends AnyTuple = A> (arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
@@ -80,10 +81,7 @@ export type QueryableStorageMulti<ApiType extends ApiTypes> =
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
export interface AugmentedQueries<ApiType extends ApiTypes> { }
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> extends StorageEntryBase<ApiType, F, A> {
keyPrefix: (key1?: Parameters<F>[0]) => string;
}
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F, A>;
// backwards compatibility-only
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
+9 -1
View File
@@ -14,7 +14,7 @@ function createApi (): Promise<ApiPromise> {
return new ApiPromise({ provider }).isReady;
}
describe.skip('misc quick tests', (): void => {
describe('misc quick tests', (): void => {
it.skip('retrieves balances correctly', async (): Promise<void> => {
const api = await createApi();
@@ -76,4 +76,12 @@ describe.skip('misc quick tests', (): void => {
.map(([block, value]) => [block, value.toRawType(), value.toHuman()])
));
});
it('expose rpc and rx definition', async (): Promise<void> => {
const api = await createApi();
console.error(api.rpc.payment.queryFeeDetails.meta);
console.error(api.rx.rpc.chain.getBlock.meta);
});
});
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
@@ -20,13 +20,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/types": "4.9.1",
"@polkadot/types-known": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/util-crypto": "^6.3.1",
"@polkadot/types": "4.11.2",
"@polkadot/types-known": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^6.3.1"
"@polkadot/keyring": "^6.5.1"
}
}
@@ -39,6 +39,21 @@ function createPrefixedKey ({ method, prefix }: CreateItemFn): Uint8Array {
return u8aConcat(xxhashAsU8a(prefix, 128), xxhashAsU8a(method, 128));
}
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
const { method, section } = itemFn;
return u8aConcat(
createPrefixedKey(itemFn),
...keys.map((type, index): Uint8Array => {
const arg = args[index];
assert(!isUndefined(arg) && !isNull(arg), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} has a null or undefined argument at position ${index}`);
return hashers[index](registry.createType(type.toString() as 'Raw', arg).toU8a());
})
);
}
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
const { method, section } = itemFn;
@@ -46,16 +61,7 @@ function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hash
// as per createKey, always add the length prefix (underlying it is Bytes)
return compactAddLength(
u8aConcat(
createPrefixedKey(itemFn),
...keys.map((type, index): Uint8Array => {
const arg = args[index];
assert(!isUndefined(arg) && !isNull(arg), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} has a null or undefined argument at position ${index}`);
return hashers[index](registry.createType(type.toString() as 'Raw', arg).toU8a());
})
)
createKeyRaw(registry, itemFn, keys, hashers, args)
);
}
@@ -80,49 +86,58 @@ function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _stora
}
/** @internal */
function extendHeadMeta (registry: Registry, { meta: { documentation, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (arg?: any) => Raw): (arg?: any) => StorageKey {
function extendHeadMeta (registry: Registry, { meta: { documentation, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (...args: unknown[]) => Raw): (...args: unknown[]) => StorageKey {
const outputType = type.isMap
? type.asMap.key.toString()
: type.asDoubleMap.key1.toString();
? type.asMap.key
: type.isDoubleMap
? type.asDoubleMap.key1
: type.asNMap.keyVec[0];
// 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,
fallback: registry.createType('Bytes', registry.createType(outputType as 'Raw').toHex()),
fallback: registry.createType('Bytes', registry.createType(outputType.toString() as 'Raw').toHex()),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
name,
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', type.isMap ? type.asMap.key : type.asDoubleMap.key1), 0)
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', outputType), 0)
});
const prefixKey = registry.createType('StorageKey', iterFn, { method, section });
return (arg?: any) =>
!isUndefined(arg) && !isNull(arg)
? registry.createType('StorageKey', iterFn(arg), { method, section })
: prefixKey;
return (...args: unknown[]) =>
registry.createType('StorageKey', iterFn(...args), { method, section });
}
// attach the full list hashing for prefixed maps
/** @internal */
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
const { meta: { type } } = itemFn;
const { meta: { type }, method, section } = itemFn;
// FIXME NMap support
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (arg?: any): Raw => {
assert(type.isDoubleMap || isUndefined(arg), 'Filtering arguments for keys/entries are only valid on double maps');
return new Raw(
registry,
type.isDoubleMap && !isUndefined(arg) && !isNull(arg)
? u8aConcat(
createPrefixedKey(itemFn),
getHasher(type.asDoubleMap.hasher)(
registry.createType(type.asDoubleMap.key1.toString() as 'Raw', arg).toU8a()
)
)
: createPrefixedKey(itemFn)
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (...args: unknown[]): Raw => {
assert(
(
(args.length === 0) ||
(type.isDoubleMap && args.length === 1) ||
(type.isNMap && args.length === (type.asNMap.hashers.length - 1))
),
() => `Iteration ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs arguments to be one less than the full arguments, found [${args.join(', ')}]`
);
if (args.length) {
if (type.isDoubleMap) {
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [getHasher(type.asDoubleMap.hasher)], args as CreateArgType[]));
} else if (type.isNMap) {
const keys = [...type.asNMap.keyVec];
const hashers = type.asNMap.hashers.map((h) => getHasher(h));
// remove the last entry
keys.pop();
hashers.pop();
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as CreateArgType[]));
}
}
return new Raw(registry, createKeyRaw(registry, itemFn, [], [], []));
});
return storageFn;
@@ -148,13 +163,12 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
);
// FIXME NMap support
if (type.isMap || type.isDoubleMap) {
if (type.isMap || type.isDoubleMap || type.isNMap) {
extendPrefixedMap(registry, itemFn, storageFn);
}
storageFn.keyPrefix = (arg?: any): Uint8Array =>
(storageFn.iterKey && storageFn.iterKey(arg)) ||
storageFn.keyPrefix = (...args: unknown[]): Uint8Array =>
(storageFn.iterKey && storageFn.iterKey(...args)) ||
compactStripLength(storageFn())[1];
return storageFn;
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/metadata', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/metadata', version: '4.11.2' };
+57 -103
View File
@@ -1736,12 +1736,6 @@
" Account liquidity restrictions prevent withdrawal"
]
},
{
"name": "Overflow",
"documentation": [
" Got an overflow after adding"
]
},
{
"name": "InsufficientBalance",
"documentation": [
@@ -4812,18 +4806,6 @@
" The account is already delegating."
]
},
{
"name": "Overflow",
"documentation": [
" An unexpected integer overflow occurred."
]
},
{
"name": "Underflow",
"documentation": [
" An unexpected integer underflow occurred."
]
},
{
"name": "InsufficientFunds",
"documentation": [
@@ -6949,17 +6931,6 @@
"storage": {
"prefix": "Contracts",
"items": [
{
"name": "CurrentSchedule",
"modifier": "Default",
"type": {
"plain": "Schedule"
},
"fallback": "0x000000000004000000000200000001000080000000100000000010000000010000200000001f060000d66a0200dd84030026180000bd1c0000430b000003170000ae2800009c000000dd69010063e00200300700000706000065070000b10500006e180000002800006905000072deae08f0070000dc070000710a00006a080000a507000096070000d1070000770900003e09000075090000d809000082090000bc090000120900003c09000072090000dc090000f7080000e108000062090000162000006b1d00002e2000002c1b0000fe080000000900000f090000a7090000f1090000ba090000bb09000065090000d8b82800000000009e9828000000000016902700000000004c705700000000004cc8270000000000e4bc270000000000e8d1270000000000a0685b0000000000484f2700000000009e7627000000000000f45100000000004cab120000000000184a700000000000140100000000000000cd460000000000fc02000000000000d0b570270000000013200000000000007821da3100000000e0200000000000009a120000000000000482b10900000000e03463000000000038d7900000000000de67d00700000000840900000000000006186e000000000016935d1200000000da02000000000000eaced408000000003a240e0200000000e705000000000000fc41d50a00000000d48e9309000000002d0f0000000000003a4225090000000047020000000000002303000000000000ba7c962300000000a5210000000000006d020000000000005403000000000000e50b00000000000026922400000000006110000000000000a4122600000000001d0d000000000000520e2200000000001a0600000000000020222200000000001a0600000000000044b13c0000000000",
"documentation": [
" Current cost schedule for contracts."
]
},
{
"name": "PristineCode",
"modifier": "Optional",
@@ -7038,23 +7009,6 @@
]
},
"calls": [
{
"name": "update_schedule",
"args": [
{
"name": "schedule",
"type": "Schedule"
}
],
"documentation": [
" Updates the schedule for metering contracts.",
"",
" The schedule's version cannot be less than the version of the stored schedule.",
" If a schedule does not change the instruction weights the version does not",
" need to be increased. Therefore we allow storing a schedule that has the same",
" version as the stored one."
]
},
{
"name": "call",
"args": [
@@ -7305,6 +7259,14 @@
}
],
"constants": [
{
"name": "Schedule",
"type": "Schedule",
"value": "0x040000000002000000010000800000001000000000100000000100002000000020000000004000000000020002000000bb060000c70c0200ea16030019160000571d0000940d0000c7190000f7290000520000000c59010050810200930b000027070000e7070000cd0500008c160000b819000022070000e757b50798060000490600008f090000ca0700009e050000de050000fa050000f9080000d3080000d2080000b1080000aa080000b2080000a1080000f60800001c0900009f0800006f080000af080000320800008d210000ff1d0000b2210000221e0000ca080000d6080000810800008c090000be090000b6090000a40a0000dc080000ae032600000000007a79250000000000bab224000000000056db500000000000469024000000000002ed2400000000008088240000000000d4c02400000000005e8224000000000004aa240000000000f6c1470000000000162d120000000000384b680000000000ef0000000000000060cf430000000000e20200000000000098ca9f20000000005b20000000000000202a872900000000f21c000000000000410d000000000000eafaac0900000000c6eb5c0000000000e4ba88000000000090bcc907000000007e09000000000000e08e1300000000002aea1800000000007e98cb0900000000b802000000000000bad9360800000000f2040c0200000000d505000000000000baa9960a00000000c021eb0f00000000ee0e00000000000000d47808000000005202000000000000080300000000000014c314230000000059200000000000005802000000000000290300000000000009090000000000005abf220000000000db12000000000000202a240000000000f50c00000000000024c61f00000000000c060000000000009a821f0000000000e30500000000000006eb360000000000",
"documentation": [
" Cost schedule and limits."
]
},
{
"name": "SignedClaimHandicap",
"type": "BlockNumber",
@@ -7383,26 +7345,10 @@
" to removal of a contract."
]
},
{
"name": "MaxDepth",
"type": "u32",
"value": "0x20000000",
"documentation": [
" The maximum nesting level of a call/instantiate stack."
]
},
{
"name": "MaxValueSize",
"type": "u32",
"value": "0x00400000",
"documentation": [
" The maximum size of a storage value and event payload in bytes."
]
},
{
"name": "DeletionQueueDepth",
"type": "u32",
"value": "0xf0000000",
"value": "0x71040000",
"documentation": [
" The maximum number of tries that can be queued for deletion."
]
@@ -7414,16 +7360,6 @@
"documentation": [
" The maximum amount of weight that can be consumed per block for lazy trie removal."
]
},
{
"name": "MaxCodeSize",
"type": "u32",
"value": "0x00000200",
"documentation": [
" The maximum length of a contract code in bytes. This limit applies to the instrumented",
" version of the code. Therefore `instantiate_with_code` can fail even when supplying",
" a wasm binary below this maximum size."
]
}
],
"errors": [
@@ -7623,6 +7559,20 @@
"documentation": [
" A contract with the same AccountId already exists."
]
},
{
"name": "TerminatedInConstructor",
"documentation": [
" A contract self destructed in its constructor.",
"",
" This can be triggered by a call to `seal_terminate` or `seal_restore_to`."
]
},
{
"name": "DebugMessageInvalidUTF8",
"documentation": [
" The debug message specified to `seal_debug_message` does contain invalid UTF-8."
]
}
],
"index": 18
@@ -10198,7 +10148,10 @@
"type": "BalanceOf",
"value": "0x00406352bfc601000000000000000000",
"documentation": [
" The base amount of currency needed to reserve for creating a recovery configuration."
" The base amount of currency needed to reserve for creating a recovery configuration.",
"",
" This is held for an additional storage item whose value size is",
" `2 + sizeof(BlockNumber, Balance)` bytes."
]
},
{
@@ -10206,7 +10159,9 @@
"type": "BalanceOf",
"value": "0x00203d88792d00000000000000000000",
"documentation": [
" The amount of currency needed per additional user when creating a recovery configuration."
" The amount of currency needed per additional user when creating a recovery configuration.",
"",
" This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value."
]
},
{
@@ -10222,7 +10177,13 @@
"type": "BalanceOf",
"value": "0x00406352bfc601000000000000000000",
"documentation": [
" The base amount of currency needed to reserve for starting a recovery."
" The base amount of currency needed to reserve for starting a recovery.",
"",
" This is primarily held for deterring malicious recovery attempts, and should",
" have a value large enough that a bad actor would choose not to place this",
" deposit. It also acts to fund additional storage item whose value size is",
" `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable",
" threshold."
]
}
],
@@ -10311,12 +10272,6 @@
" There are still active recovery attempts that need to be closed"
]
},
{
"name": "Overflow",
"documentation": [
" There was an overflow in a calculation"
]
},
{
"name": "AlreadyProxy",
"documentation": [
@@ -12647,18 +12602,25 @@
"name": "Approvals",
"modifier": "Optional",
"type": {
"doubleMap": {
"hasher": "Blake2_128Concat",
"key1": "AssetId",
"key2": "AssetApprovalKey",
"value": "AssetApproval",
"key2Hasher": "Blake2_128Concat"
"nMap": {
"keyVec": [
"AssetId",
"AccountId",
"AccountId"
],
"hashers": [
"Blake2_128Concat",
"Blake2_128Concat",
"Blake2_128Concat"
],
"value": "AssetApproval"
}
},
"fallback": "0x00",
"documentation": [
" Approved balance transfers. First balance is the amount approved for transfer. Second",
" is the amount of `T::Currency` reserved for storing this."
" is the amount of `T::Currency` reserved for storing this.",
" First key is the asset ID, second key is the owner and third key is the delegate."
]
},
{
@@ -13696,12 +13658,6 @@
" Minimum balance should be non-zero."
]
},
{
"name": "Overflow",
"documentation": [
" A mint operation lead to an overflow."
]
},
{
"name": "NoProvider",
"documentation": [
@@ -13993,22 +13949,20 @@
"name": "PalletId",
"type": "PalletId",
"value": "0x70792f6c6f74746f",
"documentation": []
"documentation": [
" The Lottery's pallet id"
]
},
{
"name": "MaxCalls",
"type": "u32",
"value": "0x0a000000",
"documentation": []
"documentation": [
" The max number of calls available in a single lottery."
]
}
],
"errors": [
{
"name": "Overflow",
"documentation": [
" An overflow has occurred."
]
},
{
"name": "NotConfigured",
"documentation": [
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,13 +20,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/metadata": "4.9.1",
"@polkadot/rpc-provider": "4.9.1",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/x-rxjs": "^6.3.1"
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.3.1"
"@polkadot/keyring": "^6.5.1"
}
}
+21 -27
View File
@@ -178,12 +178,6 @@ export class RpcCore {
this.mapping.set(jsonrpc, { ...def, isSubscription, jsonrpc, method, section });
// FIXME Remove any here
// To do so, remove `RpcInterfaceMethod` from './types.ts', and refactor
// every method inside this class to take:
// `<S extends keyof RpcInterface, M extends keyof RpcInterface[S]>`
// Not doing so, because it makes this class a little bit less readable,
// and leaving it as-is doesn't harm much
(exposed as Record<string, unknown>)[method] = isSubscription
? this._createMethodSubscribe(section, method, def as DefinitionRpcSub)
: this._createMethodSend(section, method, def);
@@ -192,13 +186,14 @@ export class RpcCore {
}, {} as RpcInterface[Section]);
}
private _memomize (creator: (outputAs: OutputType) => (...values: any[]) => Observable<any>): Memoized<RpcInterfaceMethod> {
private _memomize (creator: <T> (outputAs: OutputType) => (...values: unknown[]) => Observable<T>, def: DefinitionRpc): Memoized<RpcInterfaceMethod> {
const memoized = memoize(creator('scale') as RpcInterfaceMethod, {
getInstanceId: () => this.#instanceId
});
memoized.json = creator('json');
memoized.raw = creator('raw');
memoized.meta = def;
return memoized;
}
@@ -206,30 +201,29 @@ export class RpcCore {
private _createMethodSend (section: string, method: string, def: DefinitionRpc): RpcInterfaceMethod {
const rpcName = def.endpoint || `${section}_${method}`;
const hashIndex = def.params.findIndex(({ isHistoric }) => isHistoric);
const cacheIndex = def.params.findIndex(({ isCached }) => isCached);
let memoized: null | Memoized<RpcInterfaceMethod> = null;
// execute the RPC call, doing a registry swap for historic as applicable
const callWithRegistry = async (outputAs: OutputType, values: any[]): Promise<Codec | Codec[]> => {
const callWithRegistry = async <T> (outputAs: OutputType, values: unknown[]): Promise<T> => {
const blockHash = hashIndex === -1
? null
: values[hashIndex] as (Uint8Array | string | null | undefined);
const { registry } = blockHash && this.#getBlockRegistry
const { registry } = outputAs === 'scale' && blockHash && this.#getBlockRegistry
? await this.#getBlockRegistry(u8aToU8a(blockHash))
: { registry: this.#registryDefault };
const params = this._formatInputs(registry, null, def, values);
const data = await this.provider.send(rpcName, params.map((param): AnyJson => param.toJSON())) as AnyJson;
const data = await this.provider.send<AnyJson>(rpcName, params.map((param) => param.toJSON()));
return outputAs === 'scale'
? this._formatOutput(registry, blockHash, method, def, params, data)
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', data);
? this._formatOutput(registry, blockHash, method, def, params, data) as unknown as T
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', data) as unknown as T;
};
const creator = (outputAs: OutputType) => (...values: any[]): Observable<any> => {
const isDelayed = (hashIndex !== -1 && !!values[hashIndex]) || (cacheIndex !== -1 && !!values[cacheIndex]);
const creator = <T> (outputAs: OutputType) => (...values: unknown[]): Observable<T> => {
const isDelayed = outputAs === 'scale' && hashIndex !== -1 && !!values[hashIndex];
return new Observable((observer: Observer<any>): VoidCallback => {
callWithRegistry(outputAs, values)
return new Observable((observer: Observer<T>): VoidCallback => {
callWithRegistry<T>(outputAs, values)
.then((value): void => {
observer.next(value);
observer.complete();
@@ -253,7 +247,7 @@ export class RpcCore {
);
};
memoized = this._memomize(creator);
memoized = this._memomize(creator, def);
return memoized;
}
@@ -278,8 +272,8 @@ export class RpcCore {
const subType = `${section}_${updateType}`;
let memoized: null | Memoized<RpcInterfaceMethod> = null;
const creator = (outputAs: OutputType) => (...values: unknown[]): Observable<any> => {
return new Observable((observer: Observer<any>): VoidCallback => {
const creator = <T> (outputAs: OutputType) => (...values: unknown[]): Observable<T> => {
return new Observable((observer: Observer<T>): VoidCallback => {
// Have at least an empty promise, as used in the unsubscribe
let subscriptionPromise: Promise<number | string | null> = Promise.resolve(null);
const registry = this.#registryDefault;
@@ -294,7 +288,7 @@ export class RpcCore {
const params = this._formatInputs(registry, null, def, values);
const paramsJson = params.map((param): AnyJson => param.toJSON());
const update = (error?: Error | null, result?: any): void => {
const update = (error?: Error | null, result?: T): void => {
if (error) {
logErrorMessage(method, def, error);
@@ -304,8 +298,8 @@ export class RpcCore {
try {
observer.next(
outputAs === 'scale'
? this._formatOutput(registry, null, method, def, params, result)
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', result)
? this._formatOutput(registry, null, method, def, params, result) as unknown as T
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', result) as unknown as T
);
} catch (error) {
observer.error(error);
@@ -334,12 +328,12 @@ export class RpcCore {
}).pipe(drr());
};
memoized = this._memomize(creator);
memoized = this._memomize(creator, def);
return memoized;
}
private _formatInputs (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: any[]): Codec[] {
private _formatInputs (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: unknown[]): Codec[] {
const reqArgCount = def.params.filter(({ isOptional }) => !isOptional).length;
const optText = reqArgCount === def.params.length
? ''
@@ -352,11 +346,11 @@ export class RpcCore {
);
}
private _formatOutput (registry: Registry, blockHash: Uint8Array | string | null | undefined, method: string, rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
private _formatOutput (registry: Registry, blockHash: Uint8Array | string | null | undefined, method: string, rpc: DefinitionRpc, params: Codec[], result?: unknown): Codec | Codec[] {
if (rpc.type === 'StorageData') {
const key = params[0] as StorageKey;
return this._formatStorageData(registry, blockHash, key, result);
return this._formatStorageData(registry, blockHash, key, result as string);
} else if (rpc.type === 'StorageChangeSet') {
const keys = params[0] as Vec<StorageKey>;
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.11.2' };
+6 -3
View File
@@ -1,12 +1,15 @@
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Json, Raw } from '@polkadot/types';
import type { Codec, DefinitionRpc } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
export * from './types.jsonrpc';
export interface RpcInterfaceMethod {
(...params: any[]): Observable<any>;
json (...params: any[]): Observable<any>;
raw (...params: any[]): Observable<any>;
<T extends Codec> (...params: unknown[]): Observable<T>;
json (...params: unknown[]): Observable<Json>;
raw (...params: unknown[]): Observable<Raw>;
meta: DefinitionRpc;
}
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -20,18 +20,18 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/util-crypto": "^6.3.1",
"@polkadot/x-fetch": "^6.3.1",
"@polkadot/x-global": "^6.3.1",
"@polkadot/x-ws": "^6.3.1",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-fetch": "^6.5.1",
"@polkadot/x-global": "^6.5.1",
"@polkadot/x-ws": "^6.5.1",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^6.3.1",
"@polkadot/metadata": "4.9.1",
"@polkadot/keyring": "^6.5.1",
"@polkadot/metadata": "4.11.2",
"mock-socket": "^9.0.3",
"nock": "^13.0.11"
}
+3 -3
View File
@@ -103,7 +103,7 @@ export class HttpProvider implements ProviderInterface {
/**
* @summary Send HTTP POST Request with Body to configured HTTP Endpoint.
*/
public async send (method: string, params: any[]): Promise<any> {
public async send <T = any> (method: string, params: unknown[]): Promise<T> {
const body = this.#coder.encodeJson(method, params);
const response = await fetch(this.#endpoint, {
body,
@@ -121,14 +121,14 @@ export class HttpProvider implements ProviderInterface {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const result = await response.json();
return this.#coder.decodeResponse(result);
return this.#coder.decodeResponse(result) as T;
}
/**
* @summary Subscriptions are not supported with the HttpProvider, see [[WsProvider]].
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/require-await
public async subscribe (types: string, method: string, params: any[], cb: ProviderInterfaceCallback): Promise<number> {
public async subscribe (types: string, method: string, params: unknown[], cb: ProviderInterfaceCallback): Promise<number> {
l.error(ERROR_SUBSCRIBE);
throw new Error(ERROR_SUBSCRIBE);
+14 -14
View File
@@ -53,24 +53,24 @@ export class MockProvider implements ProviderInterface {
private requests: Record<string, (...params: any[]) => unknown> = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-unsafe-member-access
chain_getBlock: (hash: string): any => this.registry.createType('SignedBlock', rpcSignedBlock.result).toJSON(),
chain_getBlock: () => this.registry.createType('SignedBlock', rpcSignedBlock.result).toJSON(),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
chain_getBlockHash: (blockNumber: number): string => '0x1234',
chain_getBlockHash: () => '0x1234',
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
chain_getFinalizedHead: () => this.registry.createType('Header', rpcHeader.result).hash,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
chain_getHeader: () => this.registry.createType('Header', rpcHeader.result).toJSON(),
rpc_methods: () => this.registry.createType('RpcMethods').toJSON(),
state_getKeys: (): string[] => [],
state_getKeysPaged: (): string[] => [],
state_getMetadata: (): string => rpcMetadata,
state_getRuntimeVersion: (): string => this.registry.createType('RuntimeVersion').toHex(),
state_getStorage: (storage: MockStateDb, params: any[]): string => u8aToHex(storage[(params[0] as string)]),
system_chain: (): string => 'mockChain',
system_name: (): string => 'mockClient',
system_properties: (): Record<string, number | string> => ({ ss58Format: 42 }),
state_getKeys: () => [],
state_getKeysPaged: () => [],
state_getMetadata: () => rpcMetadata,
state_getRuntimeVersion: () => this.registry.createType('RuntimeVersion').toHex(),
state_getStorage: (storage: MockStateDb, [key]: string[]) => u8aToHex(storage[key]),
system_chain: () => 'mockChain',
system_name: () => 'mockClient',
system_properties: () => ({ ss58Format: 42 }),
system_upgradedToTripleRefCount: () => this.registry.createType('bool', true),
system_version: (): string => '9.8.7'
system_version: () => '9.8.7'
};
public subscriptions: MockStateSubscriptions = SUBSCRIPTIONS.reduce((subs, name): MockStateSubscriptions => {
@@ -121,12 +121,12 @@ export class MockProvider implements ProviderInterface {
}
// eslint-disable-next-line @typescript-eslint/require-await
public async send (method: string, params: any[]): Promise<unknown> {
public async send <T = any> (method: string, params: unknown[]): Promise<T> {
l.debug(() => ['send', method, params]);
assert(this.requests[method], () => `provider.send: Invalid method '${method}'`);
return this.requests[method](this.db, params);
return this.requests[method](this.db, params) as T;
}
// eslint-disable-next-line @typescript-eslint/require-await
@@ -152,7 +152,7 @@ export class MockProvider implements ProviderInterface {
public async unsubscribe (type: string, method: string, id: number): Promise<boolean> {
const sub = this.subscriptionMap[id];
l.debug((): any => ['unsubscribe', id, sub]);
l.debug(() => ['unsubscribe', id, sub]);
assert(sub, () => `Unable to find subscription for ${id}`);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.11.2' };
+2 -2
View File
@@ -49,7 +49,7 @@ export interface ProviderInterface {
connect (): Promise<void>;
disconnect (): Promise<void>;
on (type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
send (method: string, params: any[]): Promise<any>;
subscribe (type: string, method: string, params: any[], cb: ProviderInterfaceCallback): Promise<number | string>;
send <T = any> (method: string, params: unknown[]): Promise<T>;
subscribe (type: string, method: string, params: unknown[], cb: ProviderInterfaceCallback): Promise<number | string>;
unsubscribe (type: string, method: string, id: number | string): Promise<boolean>;
}
+11 -14
View File
@@ -23,13 +23,13 @@ interface SubscriptionHandler {
interface WsStateAwaiting {
callback: ProviderInterfaceCallback;
method: string;
params: any[];
params: unknown[];
subscription?: SubscriptionHandler;
}
interface WsStateSubscription extends SubscriptionHandler {
method: string;
params: any[];
params: unknown[];
}
const ALIASES: { [index: string]: string } = {
@@ -178,8 +178,10 @@ export class WsProvider implements ProviderInterface {
: new WebSocket(this.#endpoints[this.#endpointIndex], undefined, undefined, this.#headers, undefined, {
// default: true
fragmentOutgoingMessages: true,
// default: 16K
fragmentationThreshold: 256 * 1024
// default: 16K (bump, the Node has issues with too many fragments, e.g. on setCode)
fragmentationThreshold: 256 * 1024,
// default: 8MB (however Polkadot api.query.staking.erasStakers.entries(356) is over that)
maxReceivedMessageSize: 16 * 1024 * 1024
});
this.#websocket.onclose = this.#onSocketClose;
@@ -254,7 +256,7 @@ export class WsProvider implements ProviderInterface {
* @param params Encoded parameters as applicable for the method
* @param subscription Subscription details (internally used)
*/
public send <T = any> (method: string, params: any[], subscription?: SubscriptionHandler): Promise<T> {
public send <T = any> (method: string, params: unknown[], subscription?: SubscriptionHandler): Promise<T> {
return new Promise<T>((resolve, reject): void => {
try {
assert(this.isConnected && !isNull(this.#websocket), 'WebSocket is not connected');
@@ -262,10 +264,10 @@ export class WsProvider implements ProviderInterface {
const json = this.#coder.encodeJson(method, params);
const id = this.#coder.getId();
const callback = (error?: Error | null, result?: any): void => {
const callback = (error?: Error | null, result?: T): void => {
error
? reject(error)
: resolve(result);
: resolve(result as T);
};
l.debug(() => ['calling', method, json]);
@@ -287,11 +289,6 @@ export class WsProvider implements ProviderInterface {
/**
* @name subscribe
* @summary Allows subscribing to a specific event.
* @param {string} type Subscription type
* @param {string} method Subscription method
* @param {any[]} params Parameters
* @param {ProviderInterfaceCallback} callback Callback
* @return {Promise<number>} Promise resolving to the dd of the subscription you can use with [[unsubscribe]].
*
* @example
* <BR>
@@ -307,7 +304,7 @@ export class WsProvider implements ProviderInterface {
* })
* ```
*/
public subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
public subscribe (type: string, method: string, params: unknown[], callback: ProviderInterfaceCallback): Promise<number | string> {
return this.send<number | string>(method, params, { callback, type });
}
@@ -338,7 +335,7 @@ export class WsProvider implements ProviderInterface {
}
}
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
#emit = (type: ProviderInterfaceEmitted, ...args: unknown[]): void => {
this.#eventemitter.emit(type, ...args);
}
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -26,20 +26,20 @@
"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.0",
"@babel/core": "^7.14.3",
"@babel/register": "^7.13.16",
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.9.1",
"@polkadot/metadata": "4.9.1",
"@polkadot/rpc-provider": "4.9.1",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/api": "4.11.2",
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.0.1"
},
"devDependencies": {
"@types/websocket": "^1.0.2",
"@types/yargs": "^16.0.1"
"@types/yargs": "^17.0.0"
}
}
+3 -1
View File
@@ -25,6 +25,8 @@ async function run (ws: string): Promise<void> {
api.runtimeMetadata.getUniqTypes(false);
}
type ArgV = { ws: string };
export function main (): void {
// retrieve and parse arguments - we do this globally, since this is a single command
const { ws } = yargs
@@ -38,7 +40,7 @@ export function main (): void {
required: true,
type: 'string'
}
}).argv;
}).argv as ArgV;
run(ws)
.then((): void => {
+3 -1
View File
@@ -38,6 +38,8 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
process.exit(0);
}
type ArgV = { endpoint: string; output: string; package?: string; strict?: boolean };
export function main (): void {
const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({
endpoint: {
@@ -58,7 +60,7 @@ export function main (): void {
description: 'Turns on strict mode, no output of catch-all generic versions',
type: 'boolean'
}
}).argv;
}).argv as ArgV;
if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
try {
+3 -1
View File
@@ -9,6 +9,8 @@ import * as substrateDefs from '@polkadot/types/interfaces/definitions';
import { generateInterfaceTypes } from './generate/interfaceRegistry';
import { generateTsDef } from './generate/tsDef';
type ArgV = { input: string; package: string };
export function main (): void {
const { input, package: pkg } = yargs.strict().options({
input: {
@@ -21,7 +23,7 @@ export function main (): void {
required: true,
type: 'string'
}
}).argv;
}).argv as ArgV;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userDefs = require(path.join(process.cwd(), input, 'definitions.ts')) as Record<string, any>;
+3 -8
View File
@@ -58,7 +58,7 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
return [
[formatType(allDefs, dm.key1.toString(), imports), formatType(allDefs, dm.key2.toString(), imports)].join(', '),
`key1: ${key1Types}, key2: ${key2Types}`,
`arg1: ${key1Types}, arg2: ${key2Types}`,
formatType(allDefs, outputType, imports)
];
} else if (storageEntry.type.isNMap) {
@@ -76,7 +76,7 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
return [
nmap.keyVec.map((k) => formatType(allDefs, k.toString(), imports)).join(', '),
keyTypes.map((t, i) => `key${i + 1}: ${t}`).join(', '),
keyTypes.map((t, i) => `arg${i + 1}: ${t}`).join(', '),
formatType(allDefs, outputType, imports)
];
}
@@ -104,16 +104,11 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
.sort(compareName)
.map((storageEntry) => {
const [args, params, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
let entryType = 'AugmentedQuery';
if (storageEntry.type.isDoubleMap) {
entryType = `${entryType}DoubleMap`;
}
return {
args,
docs: storageEntry.documentation,
entryType,
entryType: 'AugmentedQuery',
name: stringCamelCase(storageEntry.name),
params,
returnType
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '4.11.2' };
+7 -4
View File
@@ -6,13 +6,16 @@ declare module '@polkadot/api/types/consts' {
export interface AugmentedConsts<ApiType> {
{{#each modules}}
{{{name}}}: {
{{#unless @root.isStrict}}
[key: string]: Codec;
{{/unless}}
{{~#each items}}
{{#each items}}
{{> docs}}
{{{name}}}: {{{type}}} & AugmentedConst<ApiType>;
{{/each}}
{{#unless @root.isStrict}}
/**
* Generic const
**/
[key: string]: Codec;
{{/unless}}
};
{{/each}}
}
+7 -4
View File
@@ -6,13 +6,16 @@ declare module '@polkadot/api/types/errors' {
export interface AugmentedErrors<ApiType> {
{{#each modules}}
{{{name}}}: {
{{#unless @root.isStrict}}
[key: string]: AugmentedError<ApiType>;
{{/unless}}
{{~#each items}}
{{#each items}}
{{> docs}}
{{{name}}}: AugmentedError<ApiType>;
{{/each}}
{{#unless @root.isStrict}}
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
{{/unless}}
};
{{/each}}
}
+7 -4
View File
@@ -6,13 +6,16 @@ declare module '@polkadot/api/types/events' {
export interface AugmentedEvents<ApiType> {
{{#each modules}}
{{{name}}}: {
{{#unless @root.isStrict}}
[key: string]: AugmentedEvent<ApiType>;
{{/unless}}
{{~#each items}}
{{#each items}}
{{> docs}}
{{{name}}}: AugmentedEvent<ApiType, [{{{type}}}]>;
{{/each}}
{{#unless @root.isStrict}}
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
{{/unless}}
};
{{/each}}
}
+7 -4
View File
@@ -6,13 +6,16 @@ declare module '@polkadot/api/types/storage' {
export interface AugmentedQueries<ApiType> {
{{#each modules}}
{{{name}}}: {
{{#unless @root.isStrict}}
[key: string]: QueryableStorageEntry<ApiType>;
{{/unless}}
{{~#each items}}
{{#each items}}
{{> docs}}
{{{name}}}: {{{entryType}}}<ApiType, ({{{params}}}) => Observable<{{{returnType}}}>, [{{{args}}}]>{{#unless @root.isStrict}} & QueryableStorageEntry<ApiType, [{{{args}}}]>{{/unless}};
{{/each}}
{{#unless @root.isStrict}}
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
{{/unless}}
};
{{/each}}
}
+7 -4
View File
@@ -6,13 +6,16 @@ declare module '@polkadot/api/types/submittable' {
export interface AugmentedSubmittables<ApiType> {
{{#each modules}}
{{{name}}}: {
{{#unless @root.isStrict}}
[key: string]: SubmittableExtrinsicFunction<ApiType>;
{{/unless}}
{{~#each items}}
{{#each items}}
{{> docs}}
{{{name}}}: AugmentedSubmittable<({{{params}}}) => SubmittableExtrinsic<ApiType>, [{{{args}}}]>;
{{/each}}
{{#unless @root.isStrict}}
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
{{/unless}}
};
{{/each}}
}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,9 +20,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/networks": "^6.3.1",
"@polkadot/types": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/networks": "^6.5.1",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '4.9.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '4.11.2' };
@@ -6,12 +6,6 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
// substrate
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
LookupSource: 'IndicesLookupSource',
Multiplier: 'Fixed64',
// Anchor
AnchorData: {
anchoredBlock: 'u64',
@@ -77,11 +71,21 @@ const sharedTypes = {
const versioned: OverrideVersionedType[] = [
{
minmax: [240, undefined],
minmax: [240, 999],
types: {
...sharedTypes,
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
LookupSource: 'IndicesLookupSource',
Multiplier: 'Fixed64',
RefCount: 'RefCountTo259'
}
},
{
minmax: [1000, undefined],
types: {
...sharedTypes
}
}
];
+3
View File
@@ -9,6 +9,7 @@ import node from './node';
import nodeTemplate from './node-template';
import polkadot from './polkadot';
import rococo from './rococo';
import shell from './shell';
import statemint from './statemint';
import westend from './westend';
@@ -20,6 +21,8 @@ const typesSpec: Record<string, OverrideVersionedType[]> = {
'node-template': nodeTemplate,
polkadot,
rococo,
shell,
statemine: statemint,
statemint,
westend
};
+16 -2
View File
@@ -15,16 +15,20 @@ const sharedTypes = {
const addrIndicesTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
CompactAssignments: 'CompactAssignmentsWith16',
Keys: 'SessionKeys5',
LookupSource: 'IndicesLookupSource',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsWith16',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
@@ -164,11 +168,21 @@ const versioned: OverrideVersionedType[] = [
minmax: [2028, 2029],
types: {
...sharedTypes,
AccountInfo: 'AccountInfoWithDualRefCount'
AccountInfo: 'AccountInfoWithDualRefCount',
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16'
}
},
{
minmax: [2030, undefined],
minmax: [2030, 9000],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16'
}
},
{
minmax: [9010, undefined],
types: {
...sharedTypes
}
@@ -9,8 +9,7 @@ const versioned: OverrideVersionedType[] = [
{
minmax: [0, undefined],
types: {
Address: 'MultiAddress',
LookupSource: 'MultiAddress'
// nothing, API tracks master
}
}
];
+2 -13
View File
@@ -5,22 +5,11 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
// these are override types for Polkadot
const versioned: OverrideVersionedType[] = [
{
minmax: [0, 260],
minmax: [0, undefined],
types: {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
LookupSource: 'IndicesLookupSource'
}
},
{
minmax: [261, undefined],
types: {
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
LookupSource: 'MultiAddress'
// nothing, API tracks master
}
}
];
+13 -1
View File
@@ -23,8 +23,10 @@ const sharedTypes = {
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsWith16',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
@@ -68,11 +70,21 @@ const versioned: OverrideVersionedType[] = [
minmax: [28, 29],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
AccountInfo: 'AccountInfoWithDualRefCount'
}
},
{
minmax: [30, undefined],
minmax: [30, 9000],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16'
}
},
{
minmax: [9010, undefined],
types: {
...sharedTypes
}
+17
View File
@@ -0,0 +1,17 @@
// Copyright 2017-2021 @polkadot/types-known authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable sort-keys */
import type { OverrideVersionedType } from '@polkadot/types/types';
const versioned: OverrideVersionedType[] = [
{
minmax: [0, undefined],
types: {
// nothing, limited runtime
}
}
];
export default versioned;
+6
View File
@@ -6,6 +6,10 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
// 16 validators
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
// general
Keys: 'SessionKeys6',
ProxyType: {
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy']
@@ -15,8 +19,10 @@ const sharedTypes = {
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsWith16',
LookupSource: 'AccountId',
Keys: 'SessionKeys5',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
+1 -1
View File
@@ -12,7 +12,7 @@ const upgrades: ChainUpgradesRaw = [
[2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011],
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
[3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027],
[6137912, 2028], [6561855, 2029], [7100891, 2030]
[6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010]
];
export default upgrades;
+1 -1
View File
@@ -9,7 +9,7 @@ const upgrades: ChainUpgradesRaw = [
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49],
[5124076, 50], [5478664, 900], [5482450, 9000]
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010]
];
export default upgrades;
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "4.9.1",
"version": "4.11.2",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -20,14 +20,14 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/metadata": "4.9.1",
"@polkadot/util": "^6.3.1",
"@polkadot/util-crypto": "^6.3.1",
"@polkadot/x-rxjs": "^6.3.1",
"@polkadot/metadata": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^6.3.1"
"@polkadot/keyring": "^6.5.1"
}
}
+132 -5
View File
@@ -10,6 +10,7 @@ import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import type { BeefyCommitment, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BridgedBlockHash, BridgedBlockNumber, BridgedHeader, InitializationData } from '@polkadot/types/interfaces/bridges';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import type { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
@@ -18,6 +19,7 @@ import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/conse
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractInstantiateResult, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpec, ContractEventSpec, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpec, ContractMessageSpec, ContractProject, ContractProjectContract, ContractProjectSource, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
import type { ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData } from '@polkadot/types/interfaces/cumulus';
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
@@ -26,7 +28,7 @@ import type { EvmAccount, EvmLog, EvmVicinity, ExitError, ExitFatal, ExitReason,
import type { AnySignature, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, AuthoritySetChanges, AuthorityWeight, DelayKind, DelayKindBest, EncodedFinalityProofs, ForkTreePendingChange, ForkTreePendingChangeNode, GrandpaCommit, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaJustification, GrandpaPrecommit, GrandpaPrevote, GrandpaSignedPrecommit, JustificationNotification, KeyOwnerProof, NextAuthority, PendingChange, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
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';
@@ -41,17 +43,18 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty
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, 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, 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, TransactionPriority, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, 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, TransactionPriority, 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 { 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';
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactAssignmentsTo265, CompactAssignmentsWith16, CompactAssignmentsWith24, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, RawSolutionTo265, RawSolutionWith16, RawSolutionWith24, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, RuntimeVersionPartial, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TokenError, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ArithmeticError, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TokenError, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalanceOf, DestroyWitness, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, BodyId, BodyPart, BodyPartAtLeastProportion, BodyPartFraction, BodyPartMoreThanProportion, DoubleEncodedCall, InboundStatus, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, OutboundStatus, Outcome, PluralityJunction, QueueConfigData, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, Xcm, XcmAssetEffects, XcmError, XcmHrmpChannelAccepted, XcmHrmpChannelClosing, XcmHrmpNewChannelOpenRequest, XcmOrder, XcmOrderBuyExecution, XcmOrderDepositAsset, XcmOrderDepositReserveAsset, XcmOrderExchangeAsset, XcmOrderInitiateReserveWithdraw, XcmOrderInitiateTeleport, XcmOrderQueryHolding, XcmOriginKind, XcmQueryResponse, XcmRelayedFrom, XcmReserveAssetDeposit, XcmResponse, XcmTeleportAsset, XcmTransact, XcmTransferAsset, XcmTransferReserveAsset, XcmWithdrawAsset, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
@@ -73,8 +76,12 @@ declare module '@polkadot/types/types/registry' {
'Compact<BalanceOf>': Compact<BalanceOf>;
'Compact<BlockNumber>': Compact<BlockNumber>;
'Compact<BountyIndex>': Compact<BountyIndex>;
'Compact<BridgedBlockNumber>': Compact<BridgedBlockNumber>;
'Compact<ClassId>': Compact<ClassId>;
'Compact<ContractDiscriminant>': Compact<ContractDiscriminant>;
'Compact<CoreIndex>': Compact<CoreIndex>;
'Compact<DepositBalance>': Compact<DepositBalance>;
'Compact<DepositBalanceOf>': Compact<DepositBalanceOf>;
'Compact<EraIndex>': Compact<EraIndex>;
'Compact<EventIndex>': Compact<EventIndex>;
'Compact<ExtendedBalance>': Compact<ExtendedBalance>;
@@ -84,6 +91,7 @@ declare module '@polkadot/types/types/registry' {
'Compact<Gas>': Compact<Gas>;
'Compact<GroupIndex>': Compact<GroupIndex>;
'Compact<Index>': Compact<Index>;
'Compact<InstanceId>': Compact<InstanceId>;
'Compact<KeyTypeId>': Compact<KeyTypeId>;
'Compact<LeasePeriod>': Compact<LeasePeriod>;
'Compact<LeasePeriodOf>': Compact<LeasePeriodOf>;
@@ -92,6 +100,8 @@ declare module '@polkadot/types/types/registry' {
'Compact<MomentOf>': Compact<MomentOf>;
'Compact<NominatorIndex>': Compact<NominatorIndex>;
'Compact<OffchainAccuracy>': Compact<OffchainAccuracy>;
'Compact<OverweightIndex>': Compact<OverweightIndex>;
'Compact<PageCounter>': Compact<PageCounter>;
'Compact<ParaId>': Compact<ParaId>;
'Compact<ParaValidatorIndex>': Compact<ParaValidatorIndex>;
'Compact<Perbill>': Compact<Perbill>;
@@ -178,6 +188,7 @@ declare module '@polkadot/types/types/registry' {
'Option<ApplyExtrinsicResult>': Option<ApplyExtrinsicResult>;
'Option<ApprovalFlag>': Option<ApprovalFlag>;
'Option<Approvals>': Option<Approvals>;
'Option<ArithmeticError>': Option<ArithmeticError>;
'Option<AssetApproval>': Option<AssetApproval>;
'Option<AssetApprovalKey>': Option<AssetApprovalKey>;
'Option<AssetBalance>': Option<AssetBalance>;
@@ -196,6 +207,9 @@ declare module '@polkadot/types/types/registry' {
'Option<AuthorityId>': Option<AuthorityId>;
'Option<AuthorityIndex>': Option<AuthorityIndex>;
'Option<AuthorityList>': Option<AuthorityList>;
'Option<AuthoritySet>': Option<AuthoritySet>;
'Option<AuthoritySetChange>': Option<AuthoritySetChange>;
'Option<AuthoritySetChanges>': Option<AuthoritySetChanges>;
'Option<AuthoritySignature>': Option<AuthoritySignature>;
'Option<AuthorityWeight>': Option<AuthorityWeight>;
'Option<AvailabilityBitfield>': Option<AvailabilityBitfield>;
@@ -243,6 +257,9 @@ declare module '@polkadot/types/types/registry' {
'Option<BountyStatusActive>': Option<BountyStatusActive>;
'Option<BountyStatusCuratorProposed>': Option<BountyStatusCuratorProposed>;
'Option<BountyStatusPendingPayout>': Option<BountyStatusPendingPayout>;
'Option<BridgedBlockHash>': Option<BridgedBlockHash>;
'Option<BridgedBlockNumber>': Option<BridgedBlockNumber>;
'Option<BridgedHeader>': Option<BridgedHeader>;
'Option<BufferedSessionChange>': Option<BufferedSessionChange>;
'Option<Bytes>': Option<Bytes>;
'Option<Call>': Option<Call>;
@@ -258,6 +275,9 @@ declare module '@polkadot/types/types/registry' {
'Option<ChainType>': Option<ChainType>;
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
'Option<ChangesTrieSignal>': Option<ChangesTrieSignal>;
'Option<ClassDetails>': Option<ClassDetails>;
'Option<ClassId>': Option<ClassId>;
'Option<ClassMetadata>': Option<ClassMetadata>;
'Option<CodecHash>': Option<CodecHash>;
'Option<CodeHash>': Option<CodeHash>;
'Option<CollatorId>': Option<CollatorId>;
@@ -266,8 +286,12 @@ declare module '@polkadot/types/types/registry' {
'Option<CommittedCandidateReceipt>': Option<CommittedCandidateReceipt>;
'Option<CompactAssignments>': Option<CompactAssignments>;
'Option<CompactAssignmentsTo257>': Option<CompactAssignmentsTo257>;
'Option<CompactAssignmentsTo265>': Option<CompactAssignmentsTo265>;
'Option<CompactAssignmentsWith16>': Option<CompactAssignmentsWith16>;
'Option<CompactAssignmentsWith24>': Option<CompactAssignmentsWith24>;
'Option<CompactScore>': Option<CompactScore>;
'Option<CompactScoreCompact>': Option<CompactScoreCompact>;
'Option<ConfigData>': Option<ConfigData>;
'Option<Consensus>': Option<Consensus>;
'Option<ConsensusEngineId>': Option<ConsensusEngineId>;
'Option<ConsumedWeight>': Option<ConsumedWeight>;
@@ -315,8 +339,13 @@ declare module '@polkadot/types/types/registry' {
'Option<Data>': Option<Data>;
'Option<DeferredOffenceOf>': Option<DeferredOffenceOf>;
'Option<DefunctVoter>': Option<DefunctVoter>;
'Option<DelayKind>': Option<DelayKind>;
'Option<DelayKindBest>': Option<DelayKindBest>;
'Option<Delegations>': Option<Delegations>;
'Option<DeletedContract>': Option<DeletedContract>;
'Option<DepositBalance>': Option<DepositBalance>;
'Option<DepositBalanceOf>': Option<DepositBalanceOf>;
'Option<DestroyWitness>': Option<DestroyWitness>;
'Option<Digest>': Option<Digest>;
'Option<DigestItem>': Option<DigestItem>;
'Option<DigestOf>': Option<DigestOf>;
@@ -442,6 +471,8 @@ declare module '@polkadot/types/types/registry' {
'Option<FixedU128>': Option<FixedU128>;
'Option<FixedU64>': Option<FixedU64>;
'Option<Forcing>': Option<Forcing>;
'Option<ForkTreePendingChange>': Option<ForkTreePendingChange>;
'Option<ForkTreePendingChangeNode>': Option<ForkTreePendingChangeNode>;
'Option<FullIdentification>': Option<FullIdentification>;
'Option<FunctionArgumentMetadataLatest>': Option<FunctionArgumentMetadataLatest>;
'Option<FunctionArgumentMetadataV10>': Option<FunctionArgumentMetadataV10>;
@@ -461,10 +492,14 @@ declare module '@polkadot/types/types/registry' {
'Option<GiltBid>': Option<GiltBid>;
'Option<GlobalValidationData>': Option<GlobalValidationData>;
'Option<GlobalValidationSchedule>': Option<GlobalValidationSchedule>;
'Option<GrandpaCommit>': Option<GrandpaCommit>;
'Option<GrandpaEquivocation>': Option<GrandpaEquivocation>;
'Option<GrandpaEquivocationProof>': Option<GrandpaEquivocationProof>;
'Option<GrandpaEquivocationValue>': Option<GrandpaEquivocationValue>;
'Option<GrandpaJustification>': Option<GrandpaJustification>;
'Option<GrandpaPrecommit>': Option<GrandpaPrecommit>;
'Option<GrandpaPrevote>': Option<GrandpaPrevote>;
'Option<GrandpaSignedPrecommit>': Option<GrandpaSignedPrecommit>;
'Option<GroupIndex>': Option<GroupIndex>;
'Option<H1024>': Option<H1024>;
'Option<H128>': Option<H128>;
@@ -477,6 +512,7 @@ declare module '@polkadot/types/types/registry' {
'Option<Hash>': Option<Hash>;
'Option<HeadData>': Option<HeadData>;
'Option<Header>': Option<Header>;
'Option<HeaderPartial>': Option<HeaderPartial>;
'Option<Health>': Option<Health>;
'Option<Heartbeat>': Option<Heartbeat>;
'Option<HeartbeatTo244>': Option<HeartbeatTo244>;
@@ -518,6 +554,10 @@ declare module '@polkadot/types/types/registry' {
'Option<Index>': Option<Index>;
'Option<IndicesLookupSource>': Option<IndicesLookupSource>;
'Option<IndividualExposure>': Option<IndividualExposure>;
'Option<InitializationData>': Option<InitializationData>;
'Option<InstanceDetails>': Option<InstanceDetails>;
'Option<InstanceId>': Option<InstanceId>;
'Option<InstanceMetadata>': Option<InstanceMetadata>;
'Option<InstantiateRequest>': Option<InstantiateRequest>;
'Option<InstantiateReturnValue>': Option<InstantiateReturnValue>;
'Option<InstructionWeights>': Option<InstructionWeights>;
@@ -557,6 +597,7 @@ declare module '@polkadot/types/types/registry' {
'Option<MaybeVrf>': Option<MaybeVrf>;
'Option<MemberCount>': Option<MemberCount>;
'Option<MembershipProof>': Option<MembershipProof>;
'Option<MessageId>': Option<MessageId>;
'Option<MessageIngestionType>': Option<MessageIngestionType>;
'Option<MessageQueueChain>': Option<MessageQueueChain>;
'Option<MessagingStateSnapshot>': Option<MessagingStateSnapshot>;
@@ -633,7 +674,10 @@ declare module '@polkadot/types/types/registry' {
'Option<OutboundHrmpMessage>': Option<OutboundHrmpMessage>;
'Option<OutboundStatus>': Option<OutboundStatus>;
'Option<Outcome>': Option<Outcome>;
'Option<OverweightIndex>': Option<OverweightIndex>;
'Option<Owner>': Option<Owner>;
'Option<PageCounter>': Option<PageCounter>;
'Option<PageIndexData>': Option<PageIndexData>;
'Option<PalletId>': Option<PalletId>;
'Option<PalletsOrigin>': Option<PalletsOrigin>;
'Option<PalletVersion>': Option<PalletVersion>;
@@ -657,6 +701,7 @@ declare module '@polkadot/types/types/registry' {
'Option<PeerEndpointAddr>': Option<PeerEndpointAddr>;
'Option<PeerInfo>': Option<PeerInfo>;
'Option<PeerPing>': Option<PeerPing>;
'Option<PendingChange>': Option<PendingChange>;
'Option<PendingPause>': Option<PendingPause>;
'Option<PendingResume>': Option<PendingResume>;
'Option<Perbill>': Option<Perbill>;
@@ -709,6 +754,9 @@ declare module '@polkadot/types/types/registry' {
'Option<RawBabePreDigestTo159>': Option<RawBabePreDigestTo159>;
'Option<RawOrigin>': Option<RawOrigin>;
'Option<RawSolution>': Option<RawSolution>;
'Option<RawSolutionTo265>': Option<RawSolutionTo265>;
'Option<RawSolutionWith16>': Option<RawSolutionWith16>;
'Option<RawSolutionWith24>': Option<RawSolutionWith24>;
'Option<RawVRFOutput>': Option<RawVRFOutput>;
'Option<ReadProof>': Option<ReadProof>;
'Option<ReadySolution>': Option<ReadySolution>;
@@ -747,6 +795,7 @@ declare module '@polkadot/types/types/registry' {
'Option<RuntimeDispatchInfo>': Option<RuntimeDispatchInfo>;
'Option<RuntimeVersion>': Option<RuntimeVersion>;
'Option<RuntimeVersionApi>': Option<RuntimeVersionApi>;
'Option<RuntimeVersionPartial>': Option<RuntimeVersionPartial>;
'Option<Schedule>': Option<Schedule>;
'Option<Scheduled>': Option<Scheduled>;
'Option<ScheduledTo254>': Option<ScheduledTo254>;
@@ -1007,6 +1056,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<ApplyExtrinsicResult>': Vec<ApplyExtrinsicResult>;
'Vec<ApprovalFlag>': Vec<ApprovalFlag>;
'Vec<Approvals>': Vec<Approvals>;
'Vec<ArithmeticError>': Vec<ArithmeticError>;
'Vec<AssetApproval>': Vec<AssetApproval>;
'Vec<AssetApprovalKey>': Vec<AssetApprovalKey>;
'Vec<AssetBalance>': Vec<AssetBalance>;
@@ -1025,6 +1075,9 @@ declare module '@polkadot/types/types/registry' {
'Vec<AuthorityId>': Vec<AuthorityId>;
'Vec<AuthorityIndex>': Vec<AuthorityIndex>;
'Vec<AuthorityList>': Vec<AuthorityList>;
'Vec<AuthoritySet>': Vec<AuthoritySet>;
'Vec<AuthoritySetChange>': Vec<AuthoritySetChange>;
'Vec<AuthoritySetChanges>': Vec<AuthoritySetChanges>;
'Vec<AuthoritySignature>': Vec<AuthoritySignature>;
'Vec<AuthorityWeight>': Vec<AuthorityWeight>;
'Vec<AvailabilityBitfield>': Vec<AvailabilityBitfield>;
@@ -1072,6 +1125,9 @@ declare module '@polkadot/types/types/registry' {
'Vec<BountyStatusActive>': Vec<BountyStatusActive>;
'Vec<BountyStatusCuratorProposed>': Vec<BountyStatusCuratorProposed>;
'Vec<BountyStatusPendingPayout>': Vec<BountyStatusPendingPayout>;
'Vec<BridgedBlockHash>': Vec<BridgedBlockHash>;
'Vec<BridgedBlockNumber>': Vec<BridgedBlockNumber>;
'Vec<BridgedHeader>': Vec<BridgedHeader>;
'Vec<BufferedSessionChange>': Vec<BufferedSessionChange>;
'Vec<Bytes>': Vec<Bytes>;
'Vec<Call>': Vec<Call>;
@@ -1087,6 +1143,9 @@ declare module '@polkadot/types/types/registry' {
'Vec<ChainType>': Vec<ChainType>;
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
'Vec<ChangesTrieSignal>': Vec<ChangesTrieSignal>;
'Vec<ClassDetails>': Vec<ClassDetails>;
'Vec<ClassId>': Vec<ClassId>;
'Vec<ClassMetadata>': Vec<ClassMetadata>;
'Vec<CodecHash>': Vec<CodecHash>;
'Vec<CodeHash>': Vec<CodeHash>;
'Vec<CollatorId>': Vec<CollatorId>;
@@ -1095,8 +1154,12 @@ declare module '@polkadot/types/types/registry' {
'Vec<CommittedCandidateReceipt>': Vec<CommittedCandidateReceipt>;
'Vec<CompactAssignments>': Vec<CompactAssignments>;
'Vec<CompactAssignmentsTo257>': Vec<CompactAssignmentsTo257>;
'Vec<CompactAssignmentsTo265>': Vec<CompactAssignmentsTo265>;
'Vec<CompactAssignmentsWith16>': Vec<CompactAssignmentsWith16>;
'Vec<CompactAssignmentsWith24>': Vec<CompactAssignmentsWith24>;
'Vec<CompactScore>': Vec<CompactScore>;
'Vec<CompactScoreCompact>': Vec<CompactScoreCompact>;
'Vec<ConfigData>': Vec<ConfigData>;
'Vec<Consensus>': Vec<Consensus>;
'Vec<ConsensusEngineId>': Vec<ConsensusEngineId>;
'Vec<ConsumedWeight>': Vec<ConsumedWeight>;
@@ -1144,8 +1207,13 @@ declare module '@polkadot/types/types/registry' {
'Vec<Data>': Vec<Data>;
'Vec<DeferredOffenceOf>': Vec<DeferredOffenceOf>;
'Vec<DefunctVoter>': Vec<DefunctVoter>;
'Vec<DelayKind>': Vec<DelayKind>;
'Vec<DelayKindBest>': Vec<DelayKindBest>;
'Vec<Delegations>': Vec<Delegations>;
'Vec<DeletedContract>': Vec<DeletedContract>;
'Vec<DepositBalance>': Vec<DepositBalance>;
'Vec<DepositBalanceOf>': Vec<DepositBalanceOf>;
'Vec<DestroyWitness>': Vec<DestroyWitness>;
'Vec<Digest>': Vec<Digest>;
'Vec<DigestItem>': Vec<DigestItem>;
'Vec<DigestOf>': Vec<DigestOf>;
@@ -1271,6 +1339,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<FixedU128>': Vec<FixedU128>;
'Vec<FixedU64>': Vec<FixedU64>;
'Vec<Forcing>': Vec<Forcing>;
'Vec<ForkTreePendingChange>': Vec<ForkTreePendingChange>;
'Vec<ForkTreePendingChangeNode>': Vec<ForkTreePendingChangeNode>;
'Vec<FullIdentification>': Vec<FullIdentification>;
'Vec<FunctionArgumentMetadataLatest>': Vec<FunctionArgumentMetadataLatest>;
'Vec<FunctionArgumentMetadataV10>': Vec<FunctionArgumentMetadataV10>;
@@ -1290,10 +1360,14 @@ declare module '@polkadot/types/types/registry' {
'Vec<GiltBid>': Vec<GiltBid>;
'Vec<GlobalValidationData>': Vec<GlobalValidationData>;
'Vec<GlobalValidationSchedule>': Vec<GlobalValidationSchedule>;
'Vec<GrandpaCommit>': Vec<GrandpaCommit>;
'Vec<GrandpaEquivocation>': Vec<GrandpaEquivocation>;
'Vec<GrandpaEquivocationProof>': Vec<GrandpaEquivocationProof>;
'Vec<GrandpaEquivocationValue>': Vec<GrandpaEquivocationValue>;
'Vec<GrandpaJustification>': Vec<GrandpaJustification>;
'Vec<GrandpaPrecommit>': Vec<GrandpaPrecommit>;
'Vec<GrandpaPrevote>': Vec<GrandpaPrevote>;
'Vec<GrandpaSignedPrecommit>': Vec<GrandpaSignedPrecommit>;
'Vec<GroupIndex>': Vec<GroupIndex>;
'Vec<H1024>': Vec<H1024>;
'Vec<H128>': Vec<H128>;
@@ -1306,6 +1380,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<Hash>': Vec<Hash>;
'Vec<HeadData>': Vec<HeadData>;
'Vec<Header>': Vec<Header>;
'Vec<HeaderPartial>': Vec<HeaderPartial>;
'Vec<Health>': Vec<Health>;
'Vec<Heartbeat>': Vec<Heartbeat>;
'Vec<HeartbeatTo244>': Vec<HeartbeatTo244>;
@@ -1347,6 +1422,10 @@ declare module '@polkadot/types/types/registry' {
'Vec<Index>': Vec<Index>;
'Vec<IndicesLookupSource>': Vec<IndicesLookupSource>;
'Vec<IndividualExposure>': Vec<IndividualExposure>;
'Vec<InitializationData>': Vec<InitializationData>;
'Vec<InstanceDetails>': Vec<InstanceDetails>;
'Vec<InstanceId>': Vec<InstanceId>;
'Vec<InstanceMetadata>': Vec<InstanceMetadata>;
'Vec<InstantiateRequest>': Vec<InstantiateRequest>;
'Vec<InstantiateReturnValue>': Vec<InstantiateReturnValue>;
'Vec<InstructionWeights>': Vec<InstructionWeights>;
@@ -1386,6 +1465,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<MaybeVrf>': Vec<MaybeVrf>;
'Vec<MemberCount>': Vec<MemberCount>;
'Vec<MembershipProof>': Vec<MembershipProof>;
'Vec<MessageId>': Vec<MessageId>;
'Vec<MessageIngestionType>': Vec<MessageIngestionType>;
'Vec<MessageQueueChain>': Vec<MessageQueueChain>;
'Vec<MessagingStateSnapshot>': Vec<MessagingStateSnapshot>;
@@ -1462,7 +1542,10 @@ declare module '@polkadot/types/types/registry' {
'Vec<OutboundHrmpMessage>': Vec<OutboundHrmpMessage>;
'Vec<OutboundStatus>': Vec<OutboundStatus>;
'Vec<Outcome>': Vec<Outcome>;
'Vec<OverweightIndex>': Vec<OverweightIndex>;
'Vec<Owner>': Vec<Owner>;
'Vec<PageCounter>': Vec<PageCounter>;
'Vec<PageIndexData>': Vec<PageIndexData>;
'Vec<PalletId>': Vec<PalletId>;
'Vec<PalletsOrigin>': Vec<PalletsOrigin>;
'Vec<PalletVersion>': Vec<PalletVersion>;
@@ -1486,6 +1569,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<PeerEndpointAddr>': Vec<PeerEndpointAddr>;
'Vec<PeerInfo>': Vec<PeerInfo>;
'Vec<PeerPing>': Vec<PeerPing>;
'Vec<PendingChange>': Vec<PendingChange>;
'Vec<PendingPause>': Vec<PendingPause>;
'Vec<PendingResume>': Vec<PendingResume>;
'Vec<Perbill>': Vec<Perbill>;
@@ -1538,6 +1622,9 @@ declare module '@polkadot/types/types/registry' {
'Vec<RawBabePreDigestTo159>': Vec<RawBabePreDigestTo159>;
'Vec<RawOrigin>': Vec<RawOrigin>;
'Vec<RawSolution>': Vec<RawSolution>;
'Vec<RawSolutionTo265>': Vec<RawSolutionTo265>;
'Vec<RawSolutionWith16>': Vec<RawSolutionWith16>;
'Vec<RawSolutionWith24>': Vec<RawSolutionWith24>;
'Vec<RawVRFOutput>': Vec<RawVRFOutput>;
'Vec<ReadProof>': Vec<ReadProof>;
'Vec<ReadySolution>': Vec<ReadySolution>;
@@ -1576,6 +1663,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<RuntimeDispatchInfo>': Vec<RuntimeDispatchInfo>;
'Vec<RuntimeVersion>': Vec<RuntimeVersion>;
'Vec<RuntimeVersionApi>': Vec<RuntimeVersionApi>;
'Vec<RuntimeVersionPartial>': Vec<RuntimeVersionPartial>;
'Vec<Schedule>': Vec<Schedule>;
'Vec<Scheduled>': Vec<Scheduled>;
'Vec<ScheduledTo254>': Vec<ScheduledTo254>;
@@ -1836,6 +1924,7 @@ declare module '@polkadot/types/types/registry' {
ApplyExtrinsicResult: ApplyExtrinsicResult;
ApprovalFlag: ApprovalFlag;
Approvals: Approvals;
ArithmeticError: ArithmeticError;
AssetApproval: AssetApproval;
AssetApprovalKey: AssetApprovalKey;
AssetBalance: AssetBalance;
@@ -1854,6 +1943,9 @@ declare module '@polkadot/types/types/registry' {
AuthorityId: AuthorityId;
AuthorityIndex: AuthorityIndex;
AuthorityList: AuthorityList;
AuthoritySet: AuthoritySet;
AuthoritySetChange: AuthoritySetChange;
AuthoritySetChanges: AuthoritySetChanges;
AuthoritySignature: AuthoritySignature;
AuthorityWeight: AuthorityWeight;
AvailabilityBitfield: AvailabilityBitfield;
@@ -1901,6 +1993,9 @@ declare module '@polkadot/types/types/registry' {
BountyStatusActive: BountyStatusActive;
BountyStatusCuratorProposed: BountyStatusCuratorProposed;
BountyStatusPendingPayout: BountyStatusPendingPayout;
BridgedBlockHash: BridgedBlockHash;
BridgedBlockNumber: BridgedBlockNumber;
BridgedHeader: BridgedHeader;
BufferedSessionChange: BufferedSessionChange;
Bytes: Bytes;
Call: Call;
@@ -1916,6 +2011,9 @@ declare module '@polkadot/types/types/registry' {
ChainType: ChainType;
ChangesTrieConfiguration: ChangesTrieConfiguration;
ChangesTrieSignal: ChangesTrieSignal;
ClassDetails: ClassDetails;
ClassId: ClassId;
ClassMetadata: ClassMetadata;
CodecHash: CodecHash;
CodeHash: CodeHash;
CollatorId: CollatorId;
@@ -1924,8 +2022,12 @@ declare module '@polkadot/types/types/registry' {
CommittedCandidateReceipt: CommittedCandidateReceipt;
CompactAssignments: CompactAssignments;
CompactAssignmentsTo257: CompactAssignmentsTo257;
CompactAssignmentsTo265: CompactAssignmentsTo265;
CompactAssignmentsWith16: CompactAssignmentsWith16;
CompactAssignmentsWith24: CompactAssignmentsWith24;
CompactScore: CompactScore;
CompactScoreCompact: CompactScoreCompact;
ConfigData: ConfigData;
Consensus: Consensus;
ConsensusEngineId: ConsensusEngineId;
ConsumedWeight: ConsumedWeight;
@@ -1973,8 +2075,13 @@ declare module '@polkadot/types/types/registry' {
Data: Data;
DeferredOffenceOf: DeferredOffenceOf;
DefunctVoter: DefunctVoter;
DelayKind: DelayKind;
DelayKindBest: DelayKindBest;
Delegations: Delegations;
DeletedContract: DeletedContract;
DepositBalance: DepositBalance;
DepositBalanceOf: DepositBalanceOf;
DestroyWitness: DestroyWitness;
Digest: Digest;
DigestItem: DigestItem;
DigestOf: DigestOf;
@@ -2100,6 +2207,8 @@ declare module '@polkadot/types/types/registry' {
FixedU128: FixedU128;
FixedU64: FixedU64;
Forcing: Forcing;
ForkTreePendingChange: ForkTreePendingChange;
ForkTreePendingChangeNode: ForkTreePendingChangeNode;
FullIdentification: FullIdentification;
FunctionArgumentMetadataLatest: FunctionArgumentMetadataLatest;
FunctionArgumentMetadataV10: FunctionArgumentMetadataV10;
@@ -2119,10 +2228,14 @@ declare module '@polkadot/types/types/registry' {
GiltBid: GiltBid;
GlobalValidationData: GlobalValidationData;
GlobalValidationSchedule: GlobalValidationSchedule;
GrandpaCommit: GrandpaCommit;
GrandpaEquivocation: GrandpaEquivocation;
GrandpaEquivocationProof: GrandpaEquivocationProof;
GrandpaEquivocationValue: GrandpaEquivocationValue;
GrandpaJustification: GrandpaJustification;
GrandpaPrecommit: GrandpaPrecommit;
GrandpaPrevote: GrandpaPrevote;
GrandpaSignedPrecommit: GrandpaSignedPrecommit;
GroupIndex: GroupIndex;
H1024: H1024;
H128: H128;
@@ -2135,6 +2248,7 @@ declare module '@polkadot/types/types/registry' {
Hash: Hash;
HeadData: HeadData;
Header: Header;
HeaderPartial: HeaderPartial;
Health: Health;
Heartbeat: Heartbeat;
HeartbeatTo244: HeartbeatTo244;
@@ -2176,6 +2290,10 @@ declare module '@polkadot/types/types/registry' {
Index: Index;
IndicesLookupSource: IndicesLookupSource;
IndividualExposure: IndividualExposure;
InitializationData: InitializationData;
InstanceDetails: InstanceDetails;
InstanceId: InstanceId;
InstanceMetadata: InstanceMetadata;
InstantiateRequest: InstantiateRequest;
InstantiateReturnValue: InstantiateReturnValue;
InstructionWeights: InstructionWeights;
@@ -2215,6 +2333,7 @@ declare module '@polkadot/types/types/registry' {
MaybeVrf: MaybeVrf;
MemberCount: MemberCount;
MembershipProof: MembershipProof;
MessageId: MessageId;
MessageIngestionType: MessageIngestionType;
MessageQueueChain: MessageQueueChain;
MessagingStateSnapshot: MessagingStateSnapshot;
@@ -2291,7 +2410,10 @@ declare module '@polkadot/types/types/registry' {
OutboundHrmpMessage: OutboundHrmpMessage;
OutboundStatus: OutboundStatus;
Outcome: Outcome;
OverweightIndex: OverweightIndex;
Owner: Owner;
PageCounter: PageCounter;
PageIndexData: PageIndexData;
PalletId: PalletId;
PalletsOrigin: PalletsOrigin;
PalletVersion: PalletVersion;
@@ -2315,6 +2437,7 @@ declare module '@polkadot/types/types/registry' {
PeerEndpointAddr: PeerEndpointAddr;
PeerInfo: PeerInfo;
PeerPing: PeerPing;
PendingChange: PendingChange;
PendingPause: PendingPause;
PendingResume: PendingResume;
Perbill: Perbill;
@@ -2367,6 +2490,9 @@ declare module '@polkadot/types/types/registry' {
RawBabePreDigestTo159: RawBabePreDigestTo159;
RawOrigin: RawOrigin;
RawSolution: RawSolution;
RawSolutionTo265: RawSolutionTo265;
RawSolutionWith16: RawSolutionWith16;
RawSolutionWith24: RawSolutionWith24;
RawVRFOutput: RawVRFOutput;
ReadProof: ReadProof;
ReadySolution: ReadySolution;
@@ -2405,6 +2531,7 @@ declare module '@polkadot/types/types/registry' {
RuntimeDispatchInfo: RuntimeDispatchInfo;
RuntimeVersion: RuntimeVersion;
RuntimeVersionApi: RuntimeVersionApi;
RuntimeVersionPartial: RuntimeVersionPartial;
Schedule: Schedule;
Scheduled: Scheduled;
ScheduledTo254: ScheduledTo254;
+1 -3
View File
@@ -62,8 +62,6 @@ function decodeAbstractInt (value: AnyNumber, bitLength: UIntBitLength, isNegati
* @ignore
* @noInheritDoc
*/
// TODO:
// - Apart from encoding/decoding we don't actually keep check on the sizes, is this good enough?
export abstract class AbstractInt extends BN implements Codec {
public readonly registry: Registry;
@@ -140,7 +138,7 @@ export abstract class AbstractInt extends BN implements Codec {
* @description True if this value is the max of the type
*/
public isMax (): boolean {
const u8a = this.toU8a().filter((byte): boolean => byte === 0xff);
const u8a = this.toU8a().filter((b) => b === 0xff);
return u8a.length === (this.#bitLength / 8);
}
+1 -1
View File
@@ -96,7 +96,7 @@ export class Compact<T extends CompactEncodable> implements ICompact<T> {
* @description Returns a BigInt representation of the number
*/
public toBigInt (): bigint {
return BigInt(this.toString());
return this.#raw.toBigInt();
}
/**
+16 -17
View File
@@ -11,6 +11,20 @@ import { bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/ut
const BITLENGTH: UIntBitLength = 64;
function decodeDate (value: CodecDate | Date | AnyNumber): Date {
if (value instanceof Date) {
return value;
} else if (isU8a(value)) {
value = u8aToBn(value.subarray(0, BITLENGTH / 8), true);
} else if (isString(value)) {
value = new BN(value.toString(), 10, 'le');
}
return new Date(
bnToBn(value as BN).toNumber() * 1000
);
}
/**
* @name Date
* @description
@@ -27,26 +41,11 @@ export class CodecDate extends Date implements Codec {
public createdAtHash?: Hash;
constructor (registry: Registry, value: CodecDate | Date | AnyNumber = 0) {
super(CodecDate.decodeDate(value));
super(decodeDate(value));
this.registry = registry;
}
/** @internal */
public static decodeDate (value: CodecDate | Date | AnyNumber | unknown): Date {
if (value instanceof Date) {
return value;
} else if (isU8a(value)) {
value = u8aToBn(value.subarray(0, BITLENGTH / 8), true);
} else if (isString(value)) {
value = new BN(value.toString(), 10, 'le');
}
return new Date(
bnToBn(value as BN).toNumber() * 1000
);
}
/**
* @description The length of the value when encoded as a Uint8Array
*/
@@ -72,7 +71,7 @@ export class CodecDate extends Date implements Codec {
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: unknown): boolean {
return CodecDate.decodeDate(other).getTime() === this.getTime();
return decodeDate(other as AnyNumber).getTime() === this.getTime();
}
/**
+2 -2
View File
@@ -81,7 +81,7 @@ export class Json extends Map<string, any> implements Codec {
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (): Record<string, AnyJson> {
return [...this.entries()].reduce((json: Record<string, AnyJson>, [key, value]): Record<string, AnyJson> => {
return [...this.entries()].reduce<Record<string, AnyJson>>((json, [key, value]): Record<string, AnyJson> => {
json[key] = isFunction((value as Codec).toHuman)
? (value as Codec).toHuman()
: value as AnyJson;
@@ -94,7 +94,7 @@ export class Json extends Map<string, any> implements Codec {
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): Record<string, AnyJson> {
return [...this.entries()].reduce((json: Record<string, AnyJson>, [key, value]): Record<string, AnyJson> => {
return [...this.entries()].reduce<Record<string, AnyJson>>((json, [key, value]): Record<string, AnyJson> => {
json[key] = value as AnyJson;
return json;
+4 -3
View File
@@ -99,12 +99,13 @@ function decodeStructFromObject <T> (registry: Registry, Types: ConstructorDef,
*/
function decodeStruct <T> (registry: Registry, Types: ConstructorDef, value: unknown, jsonMap: Map<any, string>): T {
if (isHex(value)) {
return decodeStruct(registry, Types, hexToU8a(value as string), jsonMap);
return decodeStruct(registry, Types, hexToU8a(value.toString()), jsonMap);
} else if (isU8a(value)) {
const values = decodeU8a(registry, value, Object.values(Types));
const keys = Object.keys(Types);
const values = decodeU8a(registry, value, Object.values(Types), keys);
// Transform array of values to {key: value} mapping
return Object.keys(Types).reduce((raw, key, index): T => {
return keys.reduce((raw, key, index): T => {
// TS2322: Type 'Codec' is not assignable to type 'T[keyof S]'.
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(raw as any)[key] = values[index];
+5 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '../create';
import { Text } from '../primitive';
import { Text, u16 } from '../primitive';
import { VecFixed } from '.';
describe('VecFixed', (): void => {
@@ -17,6 +17,10 @@ describe('VecFixed', (): void => {
expect(new VecFixed(registry, Text, 2, new Uint8Array([0x00, 0x04, 0x31])).toHex()).toEqual('0x000431');
});
it('constructs via hex', (): void => {
expect(new VecFixed(registry, u16, 2, '0x12345678').toHex()).toEqual('0x12345678');
});
it('decodes reusing instance inputs', (): void => {
const foo = new Text(registry, 'bar');
+21 -21
View File
@@ -3,12 +3,31 @@
import type { Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { assert, compactToU8a, isU8a, u8aConcat } from '@polkadot/util';
import { assert, compactToU8a, isHex, isU8a, u8aConcat } from '@polkadot/util';
import { AbstractArray } from './AbstractArray';
import { typeToConstructor } from './utils';
import { Vec } from './Vec';
/** @internal */
function decodeVecFixed<T extends Codec> (registry: Registry, Type: Constructor<T>, allocLength: number, value: VecFixed<any> | Uint8Array | string | any[]): T[] {
const values = Vec.decodeVec(
registry,
Type,
isU8a(value) || isHex(value)
? u8aConcat(compactToU8a(allocLength), value)
: value
);
while (values.length < allocLength) {
values.push(new Type(registry));
}
assert(values.length === allocLength, () => `Expected a length of exactly ${allocLength} entries`);
return values;
}
/**
* @name VecFixed
* @description
@@ -20,30 +39,11 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
constructor (registry: Registry, Type: Constructor<T> | keyof InterfaceTypes, length: number, value: VecFixed<any> | Uint8Array | string | any[] = [] as any[]) {
const Clazz = typeToConstructor<T>(registry, Type);
super(registry, ...VecFixed.decodeVecFixed(registry, Clazz, length, value));
super(registry, ...decodeVecFixed(registry, Clazz, length, value));
this._Type = Clazz;
}
/** @internal */
public static decodeVecFixed<T extends Codec> (registry: Registry, Type: Constructor<T>, allocLength: number, value: VecFixed<any> | Uint8Array | string | any[]): T[] {
const values = Vec.decodeVec(
registry,
Type,
isU8a(value)
? u8aConcat(compactToU8a(allocLength), value)
: value
);
while (values.length < allocLength) {
values.push(new Type(registry));
}
assert(values.length === allocLength, () => `Expected a length of exactly ${allocLength} entries`);
return values;
}
public static with<O extends Codec> (Type: Constructor<O> | keyof InterfaceTypes, length: number): Constructor<VecFixed<O>> {
return class extends VecFixed<O> {
constructor (registry: Registry, value?: any[]) {
+1
View File
@@ -6,6 +6,7 @@ import type { Codec } from '../types';
export interface CompactEncodable extends Codec {
bitLength (): number;
toBigInt (): bigint;
toBn (): BN;
toNumber (): number;
}
+23 -7
View File
@@ -3,6 +3,8 @@
import type { Codec, Constructor, Registry } from '../../types';
import { u8aToHex } from '@polkadot/util';
/**
* Given an u8a, and an array of Type constructors, decode the u8a against the
* types, and return an array of decoded values.
@@ -10,18 +12,32 @@ import type { Codec, Constructor, Registry } from '../../types';
* @param u8a - The u8a to decode.
* @param types - The array of Constructor to decode the U8a against.
*/
export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Constructor[] | { [index: string]: Constructor }): Codec[] {
const types = Array.isArray(_types)
? _types
: Object.values(_types);
export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Constructor[] | { [index: string]: Constructor }, _keys?: string[]): Codec[] {
const [types, keys]: [Constructor<Codec>[], string[]] = Array.isArray(_types)
? [_types, _keys || []]
: [Object.values(_types), Object.keys(_types)];
const result: Codec[] = [];
let offset = 0;
for (let i = 0; i < types.length; i++) {
const value = new types[i](registry, u8a.subarray(offset));
const Type = types[i];
result.push(value);
offset += value.encodedLength;
try {
const value = new Type(registry, u8a.subarray(offset));
result.push(value);
offset += value.encodedLength;
} catch (error) {
let rawType: string;
try {
rawType = new Type(registry).toRawType();
} catch {
rawType = '';
}
throw new Error(`decodeU8a: failed at ${u8aToHex(u8a.subarray(offset).slice(0, 8))}… on ${keys[i] ? `${keys[i]}` : ''}${rawType ? `: ${rawType}` : ''}:: ${(error as Error).message}`);
}
}
return result;
@@ -122,6 +122,38 @@ describe('createType', (): void => {
).toEqual(new Uint8Array([0x00, 0x12, 0x00, 0x23, 0x00, 0x45, 0x00, 0x67]));
});
describe('isPedantic', (): void => {
it('correctly decodes Bytes', (): void => {
expect(
createTypeUnsafe(registry, 'Bytes', ['0x12345678'], { isPedantic: true }).toHex()
).toEqual('0x12345678');
});
it('correctly decodes Bytes (prefixed)', (): void => {
expect(
createTypeUnsafe(registry, 'Bytes', [new Uint8Array([4 << 2, 0x12, 0x34, 0x56, 0x78])], { isPedantic: true }).toHex()
).toEqual('0x12345678');
});
it('correctly decodes Text', (): void => {
expect(
createTypeUnsafe(registry, 'Text', ['0x70726f7669646572'], { isPedantic: true }).toString()
).toEqual('provider');
});
it('correctly decodes Type', (): void => {
expect(
createTypeUnsafe(registry, 'Type', ['0x5665633c75383e'], { isPedantic: true }).toString()
).toEqual('Bytes'); // Vec<u8> -> Bytes
});
it('correctly decodes [u16; 4]', (): void => {
expect(
createTypeUnsafe(registry, '[u16; 4]', ['0x0012002300450067'], { isPedantic: true }).toHex()
).toEqual('0x0012002300450067');
});
});
describe('instanceof', (): void => {
it('instanceof should work (primitive type)', (): void => {
const value = registry.createType('Balance', 1234);
+11 -9
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Bytes } from '../primitive/Bytes';
import type { Codec, Constructor, InterfaceTypes, Registry } from '../types';
import type { FromReg } from './types';
@@ -15,15 +16,18 @@ interface CreateOptions {
// With isPedantic, actually check that the encoding matches that supplied. This
// is much slower, but verifies that we have the correct types defined
// eslint-disable-next-line @typescript-eslint/ban-types
function checkInstance<T extends Codec = Codec, K extends string = string> (value: Uint8Array, created: FromReg<T, K>): void {
const u8a = created.toU8a();
const rawType = created.toRawType();
const isEqual = rawType === 'Bytes'
? value.length === u8a.length
: u8aEq(value, u8a);
assert(isEqual, () => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(value, 512)} (${value.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
assert(
u8aEq(value, u8a) || (
// when length-prefixed from hex, just check the actual length
['Bytes', 'Text', 'Type'].includes(rawType) &&
value.length === (created as Bytes).length
),
() => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(value, 512)} (${value.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`
);
}
// Initializes a type with a value. This also checks for fallbacks and in the cases
@@ -50,10 +54,8 @@ function initType<T extends Codec = Codec, K extends string = string> (registry:
// An unsafe version of the `createType` below. It's unsafe because the `type`
// argument here can be any string, which, when it cannot parse, will yield a
// runtime error.
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: any[] = [], options: CreateOptions = {}): T {
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: unknown[] = [], options: CreateOptions = {}): T {
try {
// Circle back to isPedantic when it handles all cases 100% - as of now,
// it provides false warning which is more hinderance than help
return initType(registry, createClass<T, K>(registry, type), params, options);
} catch (error) {
throw new Error(`createType(${type}):: ${(error as Error).message}`);
@@ -66,6 +68,6 @@ export function createTypeUnsafe<T extends Codec = Codec, K extends string = str
* instance from
* @param params - The value to instantiate the type with
*/
export function createType<K extends keyof InterfaceTypes> (registry: Registry, type: K, ...params: any[]): InterfaceTypes[K] {
export function createType<K extends keyof InterfaceTypes> (registry: Registry, type: K, ...params: unknown[]): InterfaceTypes[K] {
return createTypeUnsafe<InterfaceTypes[K], K>(registry, type, params);
}
+25 -11
View File
@@ -1,32 +1,32 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { alias, removeColons } from './sanitize';
import { alias, removeBounded, removeColons } from './sanitize';
describe('sanitize', (): void => {
describe('alias', (): void => {
const exec = alias('String', 'Text');
const fn = alias('String', 'Text');
it('replaces all occurrences for types', (): void => {
expect(exec('(String,Address,MasterString,String)')).toEqual(
expect(fn('(String,Address,MasterString,String)')).toEqual(
'(Text,Address,MasterString,Text)'
);
});
it('replaces actual types, but leaves struct names', (): void => {
expect(exec('{"system":"String","versionString":"String"}')).toEqual(
expect(fn('{"system":"String","versionString":"String"}')).toEqual(
'{"system":"Text","versionString":"Text"}'
);
});
it('handles the preceding correctly', (): void => {
// NOTE This type doesn't make sense
expect(exec('String String (String,[String;32],String)"String<String>')).toEqual(
expect(fn('String String (String,[String;32],String)"String<String>')).toEqual(
'Text Text (Text,[Text;32],Text)"Text<Text>'
);
});
it('handles emdedded Vec/Tuples', (): void => {
it('handles embedded Vec/Tuples', (): void => {
const ann = alias('Announcement', 'ProxyAnnouncement');
expect(ann('(Vec<Announcement>,BalanceOf)')).toEqual(
@@ -36,24 +36,38 @@ describe('sanitize', (): void => {
});
describe('removeColons', (): void => {
const fn = removeColons();
it('removes preceding ::Text -> Text', (): void => {
expect(removeColons()('::Text')).toEqual('Text');
expect(fn('::Text')).toEqual('Text');
});
it('removes middle voting::TallyType -> TallyType', (): void => {
expect(removeColons()('voting::TallyType')).toEqual('TallyType');
expect(fn('voting::TallyType')).toEqual('TallyType');
});
it('removes on embedded values (one)', (): void => {
expect(removeColons()('(T::AccountId, SpanIndex)')).toEqual('(AccountId, SpanIndex)');
expect(fn('(T::AccountId, SpanIndex)')).toEqual('(AccountId, SpanIndex)');
});
it('removes on embedded values (all)', (): void => {
expect(removeColons()('(T::AccountId, slashing::SpanIndex)')).toEqual('(AccountId, SpanIndex)');
expect(fn('(T::AccountId, slashing::SpanIndex)')).toEqual('(AccountId, SpanIndex)');
});
it('keeps with allowNamespaces', (): void => {
expect(removeColons()('::slashing::SpanIndex', { allowNamespaces: true })).toEqual('slashing::SpanIndex');
expect(fn('::slashing::SpanIndex', { allowNamespaces: true })).toEqual('slashing::SpanIndex');
});
});
describe('bounded', (): void => {
const fn = removeBounded();
it('correctly cleans up bounded values', (): void => {
expect(fn('BoundedVec<u32, 256>')).toEqual('Vec<u32>');
});
it('correctly cleans up nested bounded values', (): void => {
expect(fn('BoundedBTreeMap<BoundedVec<BoundedVec<u32, 1>, 2>, BoundedBTreeSet<u32, BoundedVec<u64, 3>, 4>, 5>')).toEqual('BTreeMap<Vec<Vec<u32>>, BTreeSet<u32, Vec<u64>>>');
});
});
});
+29 -21
View File
@@ -7,7 +7,8 @@ interface SanitizeOptions {
type Mapper = (value: string, options?: SanitizeOptions) => string;
const ALLOWED_BOXES = ['BTreeMap', 'BTreeSet', 'Compact', 'DoNotConstruct', 'HashMap', 'Int', 'Linkage', 'Result', 'Option', 'UInt', 'Vec'];
const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Result', 'Option', 'UInt']);
const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
const mappings: Mapper[] = [
@@ -17,7 +18,7 @@ const mappings: Mapper[] = [
// <T::Balance as HasCompact>
cleanupCompact(),
// Change BoundedVec<Type, Size> to Vec<Type>
removeBoundedVec(),
removeBounded(),
// Remove all the trait prefixes
removeTraits(),
// remove PairOf<T> -> (T, T)
@@ -31,6 +32,7 @@ const mappings: Mapper[] = [
// alias Vec<u8> -> Bytes
alias('Vec<u8>', 'Bytes'),
alias('&\\[u8\\]', 'Bytes'),
alias("&'static\\[u8\\]", 'Bytes'),
// alias RawAddress -> Address
alias('RawAddress', 'Address'),
// lookups, mapped to Address/AccountId as appropriate in runtime
@@ -77,14 +79,12 @@ export function alias (src: string, dest: string, withChecks = true): Mapper {
export function cleanupCompact (): Mapper {
return (value: string): string => {
for (let index = 0; index < value.length; index++) {
if (value[index] !== '<') {
continue;
}
if (value[index] === '<') {
const end = findClosing(value, index + 1) - 14;
const end = findClosing(value, index + 1) - 14;
if (value.substr(end, 14) === ' as HasCompact') {
value = `Compact<${value.substr(index + 1, end - index - 1)}>`;
if (value.substr(end, 14) === ' as HasCompact') {
value = `Compact<${value.substr(index + 1, end - index - 1)}>`;
}
}
}
@@ -98,24 +98,32 @@ export function flattenSingleTuple (): Mapper {
}
function replaceTagWith (value: string, matcher: string, replacer: (inner: string) => string): string {
for (let index = 0; index < value.length; index++) {
if (value.substr(index, matcher.length) === matcher) {
const start = index + matcher.length;
const end = findClosing(value, start);
let index = -1;
value = `${value.substr(0, index)}${replacer(value.substr(start, end - start))}${value.substr(end + 1)}`;
while (true) {
index = value.indexOf(matcher, index + 1);
if (index === -1) {
return value;
}
}
return value;
const start = index + matcher.length;
const end = findClosing(value, start);
value = `${value.substr(0, index)}${replacer(value.substr(start, end - start))}${value.substr(end + 1)}`;
}
}
// remove the BoundedVec wrappers
export function removeBoundedVec (): Mapper {
const replacer = (inner: string) => `Vec<${inner.split(',')[0]}>`;
// remove the Bounded* wrappers
export function removeBounded (): Mapper {
return (value: string) =>
replaceTagWith(value, 'BoundedVec<', replacer);
BOUNDED.reduce((value, tag) =>
replaceTagWith(value, `Bounded${tag}<`, (inner: string): string => {
const parts = inner.split(',');
return `${tag}<${parts.filter((_, i) => i !== parts.length - 1).join(',')}>`;
}), value
);
}
export function removeColons (): Mapper {
@@ -4,13 +4,18 @@
import type { ExtDef, ExtInfo, ExtTypes } from './types';
import { polkadot } from './polkadot';
import { shell } from './shell';
import { substrate } from './substrate';
// A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions,
// we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded
// into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are
// deemed fixed and non-changeable)
const allExtensions: ExtDef = { ...substrate, ...polkadot };
const allExtensions: ExtDef = {
...substrate,
...shell,
...polkadot
};
// the v4 signed extensions (the order is important here, as applied by default)
const defaultExtensions: Array<keyof typeof allExtensions> = [
@@ -0,0 +1,10 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ExtDef } from './types';
import { emptyCheck } from './emptyCheck';
export const shell: ExtDef = {
DisallowSigned: emptyCheck
};
@@ -0,0 +1,22 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types';
export default {
rpc: {},
types: {
BridgedBlockHash: 'H256',
BridgedBlockNumber: 'BlockNumber',
BridgedHeader: 'Header',
InitializationData: {
header: 'Header',
authorityList: 'AuthorityList',
setId: 'SetId',
isHalted: 'bool'
}
}
} as Definitions;
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export * from './types';
@@ -0,0 +1,25 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Struct, bool } from '@polkadot/types';
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
import type { BlockNumber, H256, Header } from '@polkadot/types/interfaces/runtime';
/** @name BridgedBlockHash */
export interface BridgedBlockHash extends H256 {}
/** @name BridgedBlockNumber */
export interface BridgedBlockNumber extends BlockNumber {}
/** @name BridgedHeader */
export interface BridgedHeader extends Header {}
/** @name InitializationData */
export interface InitializationData extends Struct {
readonly header: Header;
readonly authorityList: AuthorityList;
readonly setId: SetId;
readonly isHalted: bool;
}
export type PHANTOM_BRIDGES = 'bridges';
@@ -15,7 +15,7 @@ export default {
{
name: 'hash',
type: 'BlockHash',
isCached: true,
isHistoric: true,
isOptional: true
}
],
@@ -0,0 +1,28 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types';
const dmpQueue = {
ConfigData: {
maxIndividual: 'Weight'
},
MessageId: '[u8; 32]',
OverweightIndex: 'u64',
PageCounter: 'u32',
PageIndexData: {
beginUsed: 'PageCounter',
endUsed: 'PageCounter',
overweightCount: 'OverweightIndex'
}
};
export default {
rpc: {},
types: {
...dmpQueue
}
} as Definitions;

Some files were not shown because too many files have changed in this diff Show More