Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83650b8f28 | ||
|
|
50a3501dd2 | ||
|
|
526a3fd139 | ||
|
|
3b996b3444 | ||
|
|
c72c9e4a5e | ||
|
|
60a71a5ac9 | ||
|
|
26c3ccccc3 | ||
|
|
963e25934d | ||
|
|
55d9f8a062 | ||
|
|
700c8ba21f | ||
|
|
cbc255b4e7 | ||
|
|
2fe1e5031e | ||
|
|
f2cdac7875 | ||
|
|
165405bdc3 | ||
|
|
f86d71524d | ||
|
|
4d6d59f1c5 | ||
|
|
7a709898e5 | ||
|
|
121bfc7913 | ||
|
|
a04ccec445 | ||
|
|
2611fc5e1a | ||
|
|
cd5c306b22 | ||
|
|
ca6a7819f6 | ||
|
|
29c0ea9856 | ||
|
|
c82ed58d68 | ||
|
|
59a3867c50 | ||
|
|
0fca4e6866 | ||
|
|
3f9e65a179 | ||
|
|
92bde9de6f | ||
|
|
9b3158599c | ||
|
|
206fb49df5 | ||
|
|
cc0ad9b04b | ||
|
|
39902dd8ac | ||
|
|
324e4ab89b | ||
|
|
68bf0a487f | ||
|
|
3acf7e0fd7 | ||
|
|
edaf13abe1 | ||
|
|
b3649a70ce | ||
|
|
80ab628643 | ||
|
|
76363c0142 | ||
|
|
80c18c2201 | ||
|
|
fcf9b86b87 | ||
|
|
1113a3d2f8 | ||
|
|
c899dbf893 | ||
|
|
be137b2a03 | ||
|
|
122d780fe8 | ||
|
|
12be027b18 | ||
|
|
dfeef40037 | ||
|
|
a7b4fe4dd0 | ||
|
|
f4ec64d6f5 | ||
|
|
9a0d39199e | ||
|
|
77d82d9511 | ||
|
|
5464b91cc6 | ||
|
|
64ff87952a | ||
|
|
0de39e4c52 | ||
|
|
60bc384d22 | ||
|
|
ca7ea0e143 | ||
|
|
23d50248de | ||
|
|
ad4e54a2f6 | ||
|
|
e659df27ae | ||
|
|
6dc3c06fe8 | ||
|
|
776956f166 | ||
|
|
4c5203acba | ||
|
|
d80070a041 | ||
|
|
1c00cb4c4e | ||
|
|
736505603e | ||
|
|
c243da79e1 | ||
|
|
2677f38090 | ||
|
|
41d05d2402 | ||
|
|
0f38584566 | ||
|
|
2b7fb8667e | ||
|
|
ca18846bfb | ||
|
|
4ba372d29b | ||
|
|
bdc2d24366 | ||
|
|
3de06c1d4c | ||
|
|
b51149d895 | ||
|
|
e0fef55366 | ||
|
|
e2aac5f94a | ||
|
|
8f44f84c7f | ||
|
|
d53a61ec86 | ||
|
|
cf18f79c14 | ||
|
|
beb8011b4c | ||
|
|
38a601b665 | ||
|
|
11a3483ce5 | ||
|
|
1db133b741 | ||
|
|
716dce0093 | ||
|
|
3b53442172 | ||
|
|
253d94a47d | ||
|
|
fb1129a49b | ||
|
|
1cc56d6e44 | ||
|
|
9e2983a735 | ||
|
|
a6fcba95de | ||
|
|
c8c535834e | ||
|
|
b8d7c2e3e3 | ||
|
|
0283d4727b | ||
|
|
a4ab732478 |
+2
-1
@@ -21,4 +21,5 @@
|
||||
4.0.3
|
||||
|
||||
4.6.2
|
||||
4.7.2
|
||||
4.7.2
|
||||
4.9.2
|
||||
@@ -1,5 +1,63 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 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.
|
||||
|
||||
- **Breaking change** The previously deprecated contracts interfaces, has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces as per the previous code usage hints.
|
||||
- **Important** By default the `isPedantic` mode is now switched on for storage queries. This means that the API will fail on any types where the input/output decoding doesn't match 100%
|
||||
|
||||
Changes:
|
||||
|
||||
- Re-add isPedantic check on storage decoding
|
||||
- `ConsensusEngineId` now implements `[u8;4]` (mapping closer to Rust source)
|
||||
- Additional Xcm types
|
||||
- Adjust parachain types
|
||||
- Remove error logging on createType (details passed in error)
|
||||
- Adjust `ContractInfo` type as per latest Substrate
|
||||
- Adjust `DigestItem` type as per latest Substrate
|
||||
- Adjust re-encoding of `BitVec` based on decoded length
|
||||
- Added `contracts_instantiate`, `state_traceBlock` & `system_reservedPeers` RPCs
|
||||
- Prepare for auto-capability detection with historic `.at` queries
|
||||
- Add known upgrade block for Westend 900 & 9000
|
||||
- Remove all deprecated interfaces inside `@polkadot/api-contracts`
|
||||
- Initial support for NMap storage keys
|
||||
- Support metadata v13 from Substrate (upcoming upgrade)
|
||||
- Optimize historic metadata retrieval from rpc core
|
||||
|
||||
|
||||
## 4.8.1 May 2, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when using or developing for parachains.
|
||||
|
||||
+4
-4
@@ -25,14 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.0",
|
||||
"@babel/core": "^7.14.2",
|
||||
"@babel/register": "^7.13.16",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/dev": "^0.62.11",
|
||||
"@polkadot/ts": "^0.3.64",
|
||||
"@polkadot/dev": "^0.62.14",
|
||||
"@polkadot/ts": "^0.3.66",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.23",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "4.8.1"
|
||||
"version": "4.10.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/types": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/x-rxjs": "^6.3.1",
|
||||
"@polkadot/api": "4.10.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/x-rxjs": "^6.4.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { ContractGeneric, MapConstructorExec } from './types';
|
||||
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, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
@@ -34,19 +34,12 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
*/
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<constructorName>`. Creates a contract in a non-deterministic way.
|
||||
*/
|
||||
public readonly createContract: ContractGeneric<BlueprintOptions, SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>>;
|
||||
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, codeHash: string | Hash | Uint8Array, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = this.registry.createType('Hash', codeHash);
|
||||
this.createContract = createBluePrintWithId(this.#deploy);
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
if (isUndefined(this.#tx[c.method])) {
|
||||
@@ -59,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)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,17 +10,14 @@ import type { MapConstructorExec } from './types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, compactAddLength, isFunction, isUndefined, isWasm, logger, 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';
|
||||
|
||||
const l = logger('Code');
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
@@ -59,55 +56,25 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deploy the code bundle and the contract, creating a Blueprint.
|
||||
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
|
||||
*/
|
||||
public createContract (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
l.warn('.createContract is deprecated, use code.tx.<constructorName>(...) instead (where code refers to this instance)');
|
||||
|
||||
return this.#instantiate(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
#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],
|
||||
[])
|
||||
) || []))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,25 @@
|
||||
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, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
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');
|
||||
@@ -40,16 +41,6 @@ function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, par
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T, warn?: string): ContractGeneric<ContractOptions, T> {
|
||||
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T => {
|
||||
warn && l.warn(warn);
|
||||
|
||||
return isOptions(options)
|
||||
? fn(messageOrId, options, params)
|
||||
: fn(messageOrId, ...extractOptions(options, params));
|
||||
};
|
||||
}
|
||||
|
||||
export class ContractSubmittableResult extends SubmittableResult {
|
||||
public readonly contractEvents?: DecodedEvent[];
|
||||
|
||||
@@ -60,51 +51,12 @@ 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
|
||||
*/
|
||||
public readonly address: AccountId;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly exec: ContractGeneric<ContractOptions, SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly read: ContractGeneric<ContractOptions, ContractCallSend<ApiType>>;
|
||||
|
||||
readonly #query: MapMessageQuery<ApiType> = {};
|
||||
|
||||
readonly #tx: MapMessageTx<ApiType> = {};
|
||||
@@ -113,8 +65,6 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = this.registry.createType('AccountId', address);
|
||||
this.exec = createWithId(this.#exec, '.exec is deprecated, use contract.tx.<messageName>(...) instead (where contract refers to this instance)');
|
||||
this.read = createWithId(this.#read, '.read is deprecated, use contract.query.<messageName>(...) instead (where contract refers to this instance)');
|
||||
|
||||
this.abi.messages.forEach((m): void => {
|
||||
if (isUndefined(this.#tx[m.method])) {
|
||||
@@ -144,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[]) =>
|
||||
@@ -175,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);
|
||||
@@ -183,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
|
||||
}))
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ export const mockApi = {
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiate: (): never => {
|
||||
throw new Error('mock');
|
||||
},
|
||||
putCode: (): never => {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -30,10 +30,6 @@ async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<v
|
||||
// execute
|
||||
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
|
||||
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
|
||||
|
||||
// deprecated
|
||||
await contract.read('get', {}).send(pairs.eve.address);
|
||||
await contract.exec('inc', {}, 123).signAndSend(pairs.dave);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.10.1' };
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/rpc-core": "4.8.1",
|
||||
"@polkadot/types": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/util-crypto": "^6.3.1",
|
||||
"@polkadot/x-rxjs": "^6.3.1",
|
||||
"@polkadot/api": "4.10.1",
|
||||
"@polkadot/rpc-core": "4.10.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/util-crypto": "^6.4.1",
|
||||
"@polkadot/x-rxjs": "^6.4.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.3.1",
|
||||
"@polkadot/rpc-provider": "4.8.1"
|
||||
"@polkadot/keyring": "^6.4.1",
|
||||
"@polkadot/rpc-provider": "4.10.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.10.1' };
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/keyring": "^6.3.1",
|
||||
"@polkadot/metadata": "4.8.1",
|
||||
"@polkadot/rpc-core": "4.8.1",
|
||||
"@polkadot/rpc-provider": "4.8.1",
|
||||
"@polkadot/types": "4.8.1",
|
||||
"@polkadot/types-known": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/util-crypto": "^6.3.1",
|
||||
"@polkadot/x-rxjs": "^6.3.1",
|
||||
"@polkadot/api-derive": "4.10.1",
|
||||
"@polkadot/keyring": "^6.4.1",
|
||||
"@polkadot/metadata": "4.10.1",
|
||||
"@polkadot/rpc-core": "4.10.1",
|
||||
"@polkadot/rpc-provider": "4.10.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/types-known": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/util-crypto": "^6.4.1",
|
||||
"@polkadot/x-rxjs": "^6.4.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
@@ -104,20 +105,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 +113,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.
|
||||
*
|
||||
@@ -184,6 +175,13 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The repeat threshold of the offchain worker.
|
||||
*
|
||||
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
|
||||
* to submit the worker's solution.
|
||||
**/
|
||||
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Duration of the signed phase.
|
||||
**/
|
||||
@@ -283,7 +281,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
identity: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The amount held on deposit for a registered identity.
|
||||
* The amount held on deposit for a registered identity
|
||||
**/
|
||||
basicDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -320,7 +318,13 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
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>;
|
||||
};
|
||||
multisig: {
|
||||
@@ -382,10 +386,15 @@ declare module '@polkadot/api/types/consts' {
|
||||
[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>;
|
||||
/**
|
||||
@@ -394,6 +403,12 @@ 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>;
|
||||
};
|
||||
|
||||
@@ -43,10 +43,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.
|
||||
**/
|
||||
@@ -132,10 +128,6 @@ 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
|
||||
**/
|
||||
@@ -210,6 +202,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 +304,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.
|
||||
**/
|
||||
@@ -460,10 +462,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 +490,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
|
||||
**/
|
||||
@@ -512,6 +506,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* OCW submitted solution for wrong round
|
||||
**/
|
||||
OcwCallWrongEra: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too early.
|
||||
**/
|
||||
@@ -792,10 +790,6 @@ 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.
|
||||
**/
|
||||
@@ -949,10 +943,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
|
||||
**/
|
||||
|
||||
@@ -590,11 +590,10 @@ declare module '@polkadot/api/types/events' {
|
||||
[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. last
|
||||
* element indicates of the offence was applied (true) or queued (false)
|
||||
* \[kind, timeslot, applied\].
|
||||
* (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
* \[kind, timeslot\].
|
||||
**/
|
||||
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot, bool]>;
|
||||
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot]>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, Next
|
||||
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';
|
||||
@@ -17,7 +17,7 @@ import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/in
|
||||
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
@@ -225,10 +225,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.
|
||||
*
|
||||
@@ -600,11 +596,6 @@ declare module '@polkadot/api/types/storage' {
|
||||
* 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]>;
|
||||
/**
|
||||
* Deferred reports that have been rejected by the offence handler and need to be submitted
|
||||
* at a later time.
|
||||
**/
|
||||
deferredOffences: AugmentedQuery<ApiType, () => Observable<Vec<DeferredOffenceOf>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The primary structure that holds all offence records keyed by report identifiers.
|
||||
**/
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import type { ContractCallRequest, ContractExecResult, ContractInstantiateResult, InstantiateRequest } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import type { EthAccount, EthCallRequest, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
|
||||
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
@@ -20,7 +20,7 @@ import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import type { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
|
||||
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
|
||||
|
||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
@@ -128,6 +128,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns the value under a specified storage key in a contract
|
||||
**/
|
||||
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Instantiate a new contract
|
||||
**/
|
||||
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; endowment?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
|
||||
/**
|
||||
* Returns the projected time a given contract will be able to sustain paying its rent
|
||||
**/
|
||||
@@ -442,6 +446,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Subscribes to storage changes for the provided keys
|
||||
**/
|
||||
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
|
||||
/**
|
||||
* Provides a way to trace the re-execution of a single block
|
||||
**/
|
||||
traceBlock: AugmentedRpc<(block: Hash | string | Uint8Array, targets: Option<Text> | null | object | string | Uint8Array, storageKeys: Option<Text> | null | object | string | Uint8Array) => Observable<TraceBlockResponse>>;
|
||||
};
|
||||
syncstate: {
|
||||
/**
|
||||
@@ -510,6 +518,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Remove a reserved peer
|
||||
**/
|
||||
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
|
||||
/**
|
||||
* Returns the list of reserved peers
|
||||
**/
|
||||
reservedPeers: AugmentedRpc<() => Observable<Vec<Text>>>;
|
||||
/**
|
||||
* Resets the log filter to Substrate defaults
|
||||
**/
|
||||
|
||||
@@ -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';
|
||||
@@ -724,15 +724,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - The `deploy` function is executed in the context of the newly-created account.
|
||||
**/
|
||||
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.
|
||||
**/
|
||||
updateSchedule: AugmentedSubmittable<(schedule: Schedule | { version?: any; enablePrintln?: any; limits?: any; instructionWeights?: any; hostFnWeights?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Schedule]>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
|
||||
@@ -262,7 +262,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
return allKeys;
|
||||
}, []);
|
||||
const unknown = exposed.filter((key) => !allKeys.includes(key));
|
||||
const unknown = exposed.filter((k) => !allKeys.includes(k));
|
||||
const deletion = allKnown.filter(([k]) => hasResults && !exposed.includes(k) && k !== 'rpc_methods');
|
||||
|
||||
if (unknown.length) {
|
||||
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
|
||||
@@ -270,17 +271,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
// loop through all entries we have (populated in decorate) and filter as required
|
||||
// only remove when we have results and method missing, or with no results if optional
|
||||
allKnown
|
||||
.filter(([key]): boolean => hasResults
|
||||
? !exposed.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
|
||||
: key === 'rpc_methods' // we didn't find this one, remove
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.forEach(([_, { method, section }]): void => {
|
||||
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rpcCore as unknown as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
});
|
||||
deletion.forEach(([, { method, section }]): void => {
|
||||
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
});
|
||||
}
|
||||
|
||||
protected _decorateRpc<ApiType extends ApiTypes> (rpc: RpcCore & RpcInterface, decorateMethod: DecorateMethod<ApiType>, input: Partial<DecoratedRpc<ApiType, RpcInterface>> = {}): DecoratedRpc<ApiType, RpcInterface> {
|
||||
@@ -297,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;
|
||||
@@ -378,8 +374,16 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section && key.method === creator.method;
|
||||
|
||||
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
|
||||
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
creator.meta.type.isPlain
|
||||
? undefined
|
||||
: creator.meta.type.isMap
|
||||
? args[0]
|
||||
: creator.meta.type.isDoubleMap
|
||||
? [args[0], args[1]]
|
||||
: args
|
||||
))[1]);
|
||||
|
||||
decorated.keyPrefix = (key1?: Arg): string =>
|
||||
u8aToHex(creator.keyPrefix(key1));
|
||||
@@ -393,6 +397,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, arg1?: Arg, arg2?: Arg): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2), 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(
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -58,7 +58,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
this._rx.signer = options.signer;
|
||||
|
||||
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
|
||||
this._rpcCore.setRegistrySwap((blockHash: Uint8Array) => this.getBlockRegistry(blockHash));
|
||||
|
||||
if (this.hasSubscriptions) {
|
||||
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
|
||||
@@ -102,10 +102,10 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
/**
|
||||
* @description Sets up a registry based on the block hash defined
|
||||
*/
|
||||
public async getBlockRegistry (blockHash: string | Uint8Array): Promise<VersionedRegistry> {
|
||||
// shortcut in the case where we have an immediate-same request
|
||||
const lastBlockHash = u8aToU8a(blockHash);
|
||||
const existingViaHash = this.#registries.find((r) => r.lastBlockHash && u8aEq(lastBlockHash, r.lastBlockHash));
|
||||
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry> {
|
||||
const existingViaHash = this.#registries.find(({ lastBlockHash }) =>
|
||||
lastBlockHash && u8aEq(lastBlockHash, blockHash)
|
||||
);
|
||||
|
||||
if (existingViaHash) {
|
||||
return existingViaHash;
|
||||
@@ -116,39 +116,45 @@ 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((r) => r.specVersion.eq(version.specVersion));
|
||||
const existingViaVersion = this.#registries.find(({ specVersion }) => specVersion.eq(version.specVersion));
|
||||
|
||||
if (existingViaVersion) {
|
||||
existingViaVersion.lastBlockHash = lastBlockHash;
|
||||
existingViaVersion.lastBlockHash = blockHash;
|
||||
|
||||
return existingViaVersion;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// For now, since this is new we ignore the capability lookups (this could be useful once proven)
|
||||
// this._detectCapabilities(registry, blockHash);
|
||||
|
||||
// add our new registry
|
||||
const result = { isDefault: false, lastBlockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||
const result = { isDefault: false, lastBlockHash: blockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||
|
||||
this.#registries.push(result);
|
||||
|
||||
// TODO This could be useful for historic, disabled due to cross-looping, i.e. .at queries
|
||||
// this._detectCapabilities(registry, blockHash);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -190,17 +196,19 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
return [source.genesisHash, source.runtimeMetadata];
|
||||
}
|
||||
|
||||
private _detectCapabilities (registry?: Registry, blockHash?: string | Uint8Array): void {
|
||||
private _detectCapabilities (registry: Registry, blockHash?: string | Uint8Array): boolean {
|
||||
detectedCapabilities(this._rx, blockHash)
|
||||
.toPromise()
|
||||
.then((types): void => {
|
||||
if (Object.keys(types).length) {
|
||||
(registry || this.registry).register(types as Record<string, string>);
|
||||
registry.register(types as Record<string, string>);
|
||||
|
||||
l.debug(() => `Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${stringify(types)}`);
|
||||
}
|
||||
})
|
||||
.catch(l.error);
|
||||
.catch(undefined);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// subscribe to metadata updates, inject the types on changes
|
||||
@@ -235,9 +243,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
// clear the registry types to ensure that we override correctly
|
||||
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
|
||||
this.injectMetadata(metadata, false, thisRegistry.registry);
|
||||
this._detectCapabilities(thisRegistry.registry);
|
||||
|
||||
return true;
|
||||
return this._detectCapabilities(thisRegistry.registry);
|
||||
})
|
||||
)
|
||||
)
|
||||
@@ -293,12 +300,14 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// inject metadata and adjust the types as detected
|
||||
this.injectMetadata(metadata, true);
|
||||
this._detectCapabilities();
|
||||
|
||||
// derive is last, since it uses the decorated rx
|
||||
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
|
||||
this._derive = this._decorateDerive(this._decorateMethod);
|
||||
|
||||
// detect the on-chain capabilities
|
||||
this._detectCapabilities(this.registry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { bool, Raw, u32 } from '@polkadot/types';
|
||||
import type { Raw, u32 } from '@polkadot/types';
|
||||
import type { Releases } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
import { assert, compactFromU8a } from '@polkadot/util';
|
||||
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, take } from '@polkadot/x-rxjs/operators';
|
||||
import { catchError, map, take } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
// the order and types needs to map with the all array setup below
|
||||
type ExtractedQ = [bool | null, bool | null, bool | null, Releases | null];
|
||||
type ExtractedQ = [Releases | null];
|
||||
|
||||
type ExtractedR = [Raw | null];
|
||||
type ExtractedR = [Raw | null, Raw | null];
|
||||
|
||||
type ExtractedC = [u32 | null, u32 | null];
|
||||
|
||||
@@ -38,23 +38,26 @@ interface AvailableMap<T> {
|
||||
|
||||
interface Constants {
|
||||
accountIdLength: number;
|
||||
refcount1Length: number;
|
||||
refcount2Length: number;
|
||||
refcount3Length: number;
|
||||
}
|
||||
|
||||
const NumberMap = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
|
||||
|
||||
function mapCapabilities ({ accountIdLength }: Constants, [leasePeriodsPerSlot, slotRangeCount]: ExtractedC, [systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: ExtractedQ, [keys]: ExtractedR): Partial<DetectedTypes> {
|
||||
function mapCapabilities ({ accountIdLength, refcount1Length, refcount2Length, refcount3Length }: Constants, [leasePeriodsPerSlot, slotRangeCount]: ExtractedC, [stakingVersion]: ExtractedQ, [keys, accountInfo]: ExtractedR): Partial<DetectedTypes> {
|
||||
const types: Partial<DetectedTypes> = {};
|
||||
|
||||
// AccountInfo
|
||||
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
if (accountInfo) {
|
||||
const length = accountInfo.length;
|
||||
|
||||
if (!systemRefcount32 || systemRefcount32.isFalse) {
|
||||
types.RefCount = 'u8';
|
||||
if (length === refcount1Length) {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
} else if (length === refcount2Length) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else if (length === refcount3Length) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +94,8 @@ function mapCapabilities ({ accountIdLength }: Constants, [leasePeriodsPerSlot,
|
||||
// @ts-ignore
|
||||
types.Keys = `SessionKeys${numIds - 1}`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +118,12 @@ function mapCapabilities ({ accountIdLength }: Constants, [leasePeriodsPerSlot,
|
||||
|
||||
function filterEntries <T> (original: T[]): AvailableMap<T> {
|
||||
const included = original.map((c) => !!c);
|
||||
const filtered = original.filter((_, index) => included[index]);
|
||||
|
||||
return { filtered, included, original };
|
||||
return {
|
||||
filtered: original.filter((_, index) => included[index]),
|
||||
included,
|
||||
original
|
||||
};
|
||||
}
|
||||
|
||||
function extractResults <R, T = unknown> (results: unknown[], map: AvailableMap<T>): R {
|
||||
@@ -134,18 +140,17 @@ function extractResults <R, T = unknown> (results: unknown[], map: AvailableMap<
|
||||
* @description Query the chain for the specific capabilities
|
||||
*/
|
||||
export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Array | string | undefined): Observable<Partial<DetectedTypes>> {
|
||||
const emptyAccountId = api.registry.createType('AccountId');
|
||||
const consts = filterEntries([
|
||||
api.consts.auctions?.leasePeriodsPerSlot,
|
||||
api.consts.auctions?.slotRangeCount
|
||||
]);
|
||||
const queries = filterEntries([
|
||||
api.query.system?.upgradedToU32RefCount,
|
||||
api.query.system?.upgradedToDualRefCount,
|
||||
api.query.system?.upgradedToTripleRefCount,
|
||||
api.query.staking?.storageVersion
|
||||
]);
|
||||
const raws = filterEntries([
|
||||
api.query.session?.queuedKeys
|
||||
api.query.session?.queuedKeys.key(),
|
||||
api.query.system?.account?.key(emptyAccountId)
|
||||
]);
|
||||
|
||||
return combineLatest([
|
||||
@@ -162,20 +167,24 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
|
||||
: of([]),
|
||||
raws.filtered.length
|
||||
? blockHash
|
||||
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key(), blockHash)))
|
||||
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key())))
|
||||
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k, blockHash)))
|
||||
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k)))
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([cResults, qResults, rResults]): Partial<DetectedTypes> =>
|
||||
mapCapabilities(
|
||||
{
|
||||
accountIdLength: api.registry.createType('AccountId').encodedLength
|
||||
accountIdLength: emptyAccountId.encodedLength,
|
||||
refcount1Length: api.registry.createType('AccountInfoWithRefCount').encodedLength,
|
||||
refcount2Length: api.registry.createType('AccountInfoWithDualRefCount').encodedLength,
|
||||
refcount3Length: api.registry.createType('AccountInfoWithTripleRefCount').encodedLength
|
||||
},
|
||||
extractResults<ExtractedC>(cResults, consts),
|
||||
extractResults<ExtractedQ>(qResults, queries),
|
||||
extractResults<ExtractedR>(rResults, raws)
|
||||
)
|
||||
),
|
||||
take(1)
|
||||
take(1),
|
||||
catchError(() => of({}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.10.1' };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiOptions, SubmittableExtrinsic } from '../types';
|
||||
import type { SubmittableExtrinsic } from '../types';
|
||||
|
||||
import { createPair } from '@polkadot/keyring/pair';
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
@@ -44,23 +44,16 @@ describe('ApiPromise', (): void => {
|
||||
}
|
||||
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(3000000);
|
||||
jest.setTimeout(10000);
|
||||
provider = new MockProvider(registry);
|
||||
});
|
||||
|
||||
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: any = {};
|
||||
const key = `${genesisHash}-${specVersion}`;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
metadata[key] = rpcData;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const api = await ApiPromise.create({ metadata, provider, registry } as ApiOptions);
|
||||
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
|
||||
|
||||
expect(api.genesisHash).toBeDefined();
|
||||
expect(api.runtimeMetadata).toBeDefined();
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -66,14 +66,14 @@ describe('extractStorageArgs', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 0 found');
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
|
||||
});
|
||||
|
||||
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [123])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 1 found');
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
|
||||
});
|
||||
|
||||
// Linked maps have been removed
|
||||
|
||||
@@ -6,14 +6,14 @@ import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
|
||||
function sig ({ method, section }: StorageEntry, args: Type[]): string {
|
||||
return `${section}.${method}(${args.join(', ')})`;
|
||||
}
|
||||
|
||||
function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
|
||||
const { key1, key2 } = creator.meta.type.asDoubleMap;
|
||||
|
||||
assert(args.length === 2, () => `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`);
|
||||
assert(args.length === 2, () => `${sig(creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args as [any, any]];
|
||||
@@ -22,7 +22,7 @@ function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [a
|
||||
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
||||
const { key } = creator.meta.type.asMap;
|
||||
|
||||
assert(args.length === 1, () => `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
|
||||
assert(args.length === 1, () => `${sig(creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
|
||||
|
||||
// expand
|
||||
return args.length
|
||||
@@ -30,18 +30,29 @@ function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [Stora
|
||||
: [creator];
|
||||
}
|
||||
|
||||
function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
|
||||
const { keyVec } = creator.meta.type.asNMap;
|
||||
|
||||
assert(args.length === keyVec.length, () => `${sig(creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args];
|
||||
}
|
||||
|
||||
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
||||
// call. Additionally, it verifies that the correct number of arguments have been passed
|
||||
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, [any, any]] | [StorageEntry] | [StorageEntry, any] {
|
||||
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
|
||||
const args = _args.filter((arg) => !isUndefined(arg));
|
||||
|
||||
if (creator.meta.type.isDoubleMap) {
|
||||
return doDoubleMap(creator, args);
|
||||
} else if (creator.meta.type.isMap) {
|
||||
return doMap(creator, args);
|
||||
} else if (creator.meta.type.isNMap) {
|
||||
return doNMap(creator, args);
|
||||
}
|
||||
|
||||
assert(args.length === 0, () => `${sig(creator)} does not take any arguments, ${args.length} found`);
|
||||
assert(args.length === 0, () => `${sig(creator, [])} does not take any arguments, ${args.length} found`);
|
||||
|
||||
// no args
|
||||
return [creator];
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/types-known": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/util-crypto": "^6.3.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/types-known": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/util-crypto": "^6.4.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.3.1"
|
||||
"@polkadot/keyring": "^6.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,20 @@ describe('MagicNumber', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('succeeds when the magic number matches', (): void => {
|
||||
expect((): MagicNumber => new MagicNumber(registry, MAGIC_NUMBER)).not.toThrow();
|
||||
expect(
|
||||
() => new MagicNumber(registry, MAGIC_NUMBER)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('succeeds when the magic number is empty', (): void => {
|
||||
expect(
|
||||
() => new MagicNumber(registry)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('fails when the magic number mismatches', (): void => {
|
||||
expect((): MagicNumber => new MagicNumber(registry, 0x12345)).toThrow(/MagicNumber/);
|
||||
expect(
|
||||
() => new MagicNumber(registry, 0x12345678)
|
||||
).toThrow(/MagicNumber mismatch/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,9 +13,7 @@ export class MagicNumber extends U32 {
|
||||
super(registry, value);
|
||||
|
||||
if (!this.isEmpty) {
|
||||
const magic = registry.createType('u32', MAGIC_NUMBER);
|
||||
|
||||
assert(this.eq(magic), () => `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`);
|
||||
assert(this.eq(MAGIC_NUMBER), () => `MagicNumber mismatch: expected ${registry.createType('u32', MAGIC_NUMBER).toHex()}, found ${this.toHex()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12, MetadataV13 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
@@ -10,13 +10,16 @@ import { assert } from '@polkadot/util';
|
||||
import { toV10 } from './v9/toV10';
|
||||
import { toV11 } from './v10/toV11';
|
||||
import { toV12 } from './v11/toV12';
|
||||
import { toLatest } from './v12/toLatest';
|
||||
import { toV13 } from './v12/toV13';
|
||||
import { toLatest } from './v13/toLatest';
|
||||
import { MagicNumber } from './MagicNumber';
|
||||
import { getUniqTypes, toCallsOnly } from './util';
|
||||
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12;
|
||||
type MetaVersions = 9 | 10 | 11 | 12 | 13;
|
||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12 | MetadataV13;
|
||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12' | 'asV13';
|
||||
type MetaVersions = 'latest' | 9 | 10 | 11 | 12 | 13;
|
||||
|
||||
const LATEST_VERSION = 13;
|
||||
|
||||
/**
|
||||
* @name MetadataVersioned
|
||||
@@ -24,7 +27,7 @@ type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
* The versioned runtime metadata as a decoded structure
|
||||
*/
|
||||
export class MetadataVersioned extends Struct {
|
||||
readonly #converted = new Map<number, MetaMapped>();
|
||||
readonly #converted = new Map<MetaVersions, MetaMapped>();
|
||||
|
||||
constructor (registry: Registry, value?: unknown) {
|
||||
super(registry, {
|
||||
@@ -34,16 +37,18 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
#assertVersion = (version: number): boolean => {
|
||||
assert(this.version <= version, () => `Cannot convert metadata from v${this.version} to v${version}`);
|
||||
assert(this.version <= version, () => `Cannot convert metadata from version ${this.version} to ${version}`);
|
||||
|
||||
return this.version === version;
|
||||
};
|
||||
|
||||
#getVersion = <T extends MetaMapped, F extends MetaMapped>(version: MetaVersions, fromPrev: (registry: Registry, input: F, metaVersion: number) => T): T => {
|
||||
const asCurr = `asV${version}` as MetaAsX;
|
||||
const asPrev = `asV${version - 1}` as MetaAsX;
|
||||
const asPrev = version === 'latest'
|
||||
? `asV${LATEST_VERSION}` as MetaAsX
|
||||
: `asV${version - 1}` as MetaAsX;
|
||||
|
||||
if (this.#assertVersion(version)) {
|
||||
if (version !== 'latest' && this.#assertVersion(version)) {
|
||||
return this.#metadata()[asCurr] as T;
|
||||
}
|
||||
|
||||
@@ -101,16 +106,23 @@ export class MetadataVersioned extends Struct {
|
||||
return this.#getVersion(12, toV12);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V13 object
|
||||
*/
|
||||
public get asV13 (): MetadataV13 {
|
||||
return this.#getVersion(13, toV13);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a latest version object
|
||||
*/
|
||||
public get asLatest (): MetadataLatest {
|
||||
// This is non-existent & latest - applied here to do the module-specific type conversions
|
||||
return this.#getVersion(13, toLatest);
|
||||
return this.#getVersion('latest', toLatest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @description The magicNumber for the Metadata (known constant)
|
||||
*/
|
||||
public get magicNumber (): MagicNumber {
|
||||
return this.get('magicNumber') as MagicNumber;
|
||||
@@ -131,8 +143,8 @@ export class MetadataVersioned extends Struct {
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): Record<string, AnyJson> {
|
||||
// HACK(y): ensure that we apply the aliasses if we have not done so already, this is
|
||||
// needed to ensure we have the overrides as intended (only applied in toLatest)
|
||||
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
|
||||
// needed to ensure we have the correct overrides (which is only applied in toLatest)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
this.asLatest;
|
||||
|
||||
|
||||
@@ -49,4 +49,52 @@ describe('createFunction', (): void => {
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
|
||||
);
|
||||
});
|
||||
|
||||
it('allows creating of NMap keys (with Bytes)', (): void => {
|
||||
const storageFn = createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: {
|
||||
type: {
|
||||
asNMap: {
|
||||
hashers: [
|
||||
registry.createType('StorageHasher', 'Twox64Concat'),
|
||||
registry.createType('StorageHasher', 'Blake2_256'),
|
||||
registry.createType('StorageHasher', 'Blake2_256')
|
||||
],
|
||||
keyVec: [
|
||||
new Text(registry, 'Bytes'),
|
||||
new Text(registry, 'AccountId'),
|
||||
new Text(registry, 'AccountId')
|
||||
],
|
||||
value: new Text(registry, 'SessionKeys5')
|
||||
},
|
||||
isNMap: true
|
||||
}
|
||||
} as any,
|
||||
method: 'NextKeys',
|
||||
prefix: 'Session',
|
||||
section: 'session'
|
||||
}, {});
|
||||
|
||||
expect(
|
||||
u8aToHex(
|
||||
storageFn([
|
||||
// hex, without length prefix
|
||||
'0x3a73657373696f6e3a6b657973',
|
||||
// addresses
|
||||
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4',
|
||||
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4'
|
||||
])
|
||||
)
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'd901' + // length
|
||||
'cec5070d609dd3497f72bde07fc96ba0' + // twox 128
|
||||
'4c014e6bf8b8c2c011e7290b85696bb3' + // twox 128
|
||||
'9fe6329cc0b39e09' + // twox 64
|
||||
'343a73657373696f6e3a6b657973' + // twox 64 (concat, with length)
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' + // blake2
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -108,6 +108,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
|
||||
const { meta: { type } } = 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');
|
||||
|
||||
@@ -136,15 +137,18 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
|
||||
// - storage.timestamp.blockPeriod()
|
||||
// For higher-map queries the params are passed in as an tuple, [key1, key2]
|
||||
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | CreateArgType[]) =>
|
||||
type.isDoubleMap
|
||||
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
|
||||
type.isPlain
|
||||
? options.skipHashing
|
||||
? compactAddLength(u8aToU8a(options.key))
|
||||
: createKey(registry, itemFn, [], [], [])
|
||||
: type.isMap
|
||||
? createKey(registry, itemFn, [type.asMap.key], [getHasher(type.asMap.hasher)], [arg as CreateArgType])
|
||||
: options.skipHashing
|
||||
? compactAddLength(u8aToU8a(options.key))
|
||||
: createKey(registry, itemFn, [], [], [])
|
||||
: type.isDoubleMap
|
||||
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
|
||||
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
|
||||
);
|
||||
|
||||
// FIXME NMap support
|
||||
if (type.isMap || type.isDoubleMap) {
|
||||
extendPrefixedMap(registry, itemFn, storageFn);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.10.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import metadata from './v12/static';
|
||||
import metadata from './v13/static';
|
||||
|
||||
export default metadata;
|
||||
|
||||
@@ -12,10 +12,11 @@ type Arg = { type: Type } & Codec;
|
||||
|
||||
type Item = {
|
||||
type: {
|
||||
isDoubleMap?: boolean;
|
||||
isDoubleMap: boolean;
|
||||
isMap: boolean;
|
||||
isNMap: boolean;
|
||||
isPlain: boolean;
|
||||
asDoubleMap?: {
|
||||
asDoubleMap: {
|
||||
key1: Text;
|
||||
key2: Text;
|
||||
value: Text;
|
||||
@@ -24,6 +25,10 @@ type Item = {
|
||||
key: Text;
|
||||
value: Text;
|
||||
};
|
||||
asNMap: {
|
||||
keyVec: Text[];
|
||||
value: Text;
|
||||
},
|
||||
asPlain: Text;
|
||||
};
|
||||
} & Codec;
|
||||
@@ -106,20 +111,25 @@ function unwrapStorage (storage?: Storage): Item[] {
|
||||
function getStorageNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
return modules.map(({ storage }): string[][] =>
|
||||
unwrapStorage(storage).map(({ type }) =>
|
||||
type.isDoubleMap && type.asDoubleMap
|
||||
type.isPlain
|
||||
? [
|
||||
type.asDoubleMap.key1.toString(),
|
||||
type.asDoubleMap.key2.toString(),
|
||||
type.asDoubleMap.value.toString()
|
||||
type.asPlain.toString()
|
||||
]
|
||||
: type.isMap
|
||||
? [
|
||||
type.asMap.key.toString(),
|
||||
type.asMap.value.toString()
|
||||
]
|
||||
: [
|
||||
type.asPlain.toString()
|
||||
type.asMap.value.toString(),
|
||||
type.asMap.key.toString()
|
||||
]
|
||||
: type.isDoubleMap
|
||||
? [
|
||||
type.asDoubleMap.value.toString(),
|
||||
type.asDoubleMap.key1.toString(),
|
||||
type.asDoubleMap.key2.toString()
|
||||
]
|
||||
: [
|
||||
type.asNMap.value.toString(),
|
||||
...type.asNMap.keyVec.map((k) => k.toString())
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataV12, MetadataV13 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
**/
|
||||
export function toV13 (registry: Registry, metadata: MetadataV12): MetadataV13 {
|
||||
return registry.createType('MetadataV13', metadata);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
import substrateData from './static';
|
||||
import substrateJson from './static-substrate.json';
|
||||
|
||||
describe('MetadataV13 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 13, substrateData, substrateJson);
|
||||
|
||||
toLatest(registry, 13, substrateData);
|
||||
|
||||
defaultValues(registry, substrateData, true, true);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { EventMetadataLatest, EventMetadataV12, FunctionMetadataLatest, FunctionMetadataV12, MetadataLatest, MetadataV12, ModuleConstantMetadataLatest, ModuleConstantMetadataV12, ModuleMetadataLatest, ModuleMetadataV12, StorageEntryMetadataLatest, StorageMetadataLatest, StorageMetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { EventMetadataLatest, EventMetadataV13, FunctionMetadataLatest, FunctionMetadataV13, MetadataLatest, MetadataV13, ModuleConstantMetadataLatest, ModuleConstantMetadataV13, ModuleMetadataLatest, ModuleMetadataV13, StorageEntryMetadataLatest, StorageMetadataLatest, StorageMetadataV13 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { OverrideModuleType, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Type } from '@polkadot/types/primitive';
|
||||
@@ -16,11 +16,13 @@ const KNOWN_ORIGINS: Record<string, string> = {
|
||||
TechnicalCommittee: 'CollectiveOrigin'
|
||||
};
|
||||
|
||||
const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']];
|
||||
|
||||
/**
|
||||
* Find and apply the correct type override
|
||||
* @internal
|
||||
**/
|
||||
function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): void {
|
||||
function setTypeOverride (sectionTypes: OverrideModuleType, types: Type[]): void {
|
||||
types.forEach((type): void => {
|
||||
const override = Object.keys(sectionTypes).find((aliased) => type.eq(aliased));
|
||||
|
||||
@@ -29,9 +31,11 @@ function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): v
|
||||
} else {
|
||||
// FIXME: NOT happy with this approach, but gets over the initial hump cased by (Vec<Announcement>,BalanceOf)
|
||||
const orig = type.toString();
|
||||
const alias = Object.entries(sectionTypes).reduce((result: string, [from, to]): string =>
|
||||
[['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']].reduce((result, [one, two]): string =>
|
||||
result.replace(`${one}${from}${two}`, `${one}${to}${two}`), result), orig);
|
||||
const alias = Object
|
||||
.entries(sectionTypes)
|
||||
.reduce((result: string, [from, to]) =>
|
||||
BOXES.reduce((result, [one, two]) =>
|
||||
result.replace(`${one}${from}${two}`, `${one}${to}${two}`), result), orig);
|
||||
|
||||
if (orig !== alias) {
|
||||
type.setOverride(alias);
|
||||
@@ -44,9 +48,9 @@ function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): v
|
||||
* Apply module-specific type overrides (always be done as part of toLatest)
|
||||
* @internal
|
||||
**/
|
||||
function convertCalls (registry: Registry, calls: FunctionMetadataV12[], sectionTypes: OverrideModuleType): FunctionMetadataLatest[] {
|
||||
function convertCalls (registry: Registry, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): FunctionMetadataLatest[] {
|
||||
return calls.map((c): FunctionMetadataLatest => {
|
||||
c.args.forEach(({ type }) => setTypeOverride(sectionTypes, type));
|
||||
setTypeOverride(sectionTypes, c.args.map(({ type }) => type));
|
||||
|
||||
return registry.createType('FunctionMetadataLatest', c);
|
||||
});
|
||||
@@ -56,9 +60,9 @@ function convertCalls (registry: Registry, calls: FunctionMetadataV12[], section
|
||||
* Apply module-specific type overrides (always be done as part of toLatest)
|
||||
* @internal
|
||||
*/
|
||||
function convertConstants (registry: Registry, constants: ModuleConstantMetadataV12[], sectionTypes: OverrideModuleType): ModuleConstantMetadataLatest[] {
|
||||
function convertConstants (registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): ModuleConstantMetadataLatest[] {
|
||||
return constants.map((c): ModuleConstantMetadataLatest => {
|
||||
setTypeOverride(sectionTypes, c.type);
|
||||
setTypeOverride(sectionTypes, [c.type]);
|
||||
|
||||
return registry.createType('ModuleConstantMetadataLatest', c);
|
||||
});
|
||||
@@ -68,9 +72,9 @@ function convertConstants (registry: Registry, constants: ModuleConstantMetadata
|
||||
* Apply module-specific type overrides (always be done as part of toLatest)
|
||||
* @internal
|
||||
**/
|
||||
function convertEvents (registry: Registry, events: EventMetadataV12[], sectionTypes: OverrideModuleType): EventMetadataLatest[] {
|
||||
function convertEvents (registry: Registry, events: EventMetadataV13[], sectionTypes: OverrideModuleType): EventMetadataLatest[] {
|
||||
return events.map((e): EventMetadataLatest => {
|
||||
e.args.forEach((type) => setTypeOverride(sectionTypes, type));
|
||||
setTypeOverride(sectionTypes, e.args.map((type) => type));
|
||||
|
||||
return registry.createType('EventMetadataLatest', e);
|
||||
});
|
||||
@@ -80,16 +84,18 @@ function convertEvents (registry: Registry, events: EventMetadataV12[], sectionT
|
||||
* Apply module-specific storage type overrides (always part of toLatest)
|
||||
* @internal
|
||||
**/
|
||||
function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV12, sectionTypes: OverrideModuleType): StorageMetadataLatest {
|
||||
function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): StorageMetadataLatest {
|
||||
return registry.createType('StorageMetadataLatest', {
|
||||
items: items.map((s): StorageEntryMetadataLatest => {
|
||||
if (s.type.isDoubleMap) {
|
||||
setTypeOverride(sectionTypes, s.type.asDoubleMap.value, s.type.asDoubleMap.key1, s.type.asDoubleMap.key2);
|
||||
} else if (s.type.isMap) {
|
||||
setTypeOverride(sectionTypes, s.type.asMap.value, s.type.asMap.key);
|
||||
} else {
|
||||
setTypeOverride(sectionTypes, s.type.asPlain);
|
||||
}
|
||||
setTypeOverride(sectionTypes,
|
||||
s.type.isPlain
|
||||
? [s.type.asPlain]
|
||||
: s.type.isMap
|
||||
? [s.type.asMap.value, s.type.asMap.key]
|
||||
: s.type.isDoubleMap
|
||||
? [s.type.asDoubleMap.value, s.type.asDoubleMap.key1, s.type.asDoubleMap.key2]
|
||||
: [s.type.asNMap.value, ...s.type.asNMap.keyVec]
|
||||
);
|
||||
|
||||
return registry.createType('StorageEntryMetadataLatest', s);
|
||||
}),
|
||||
@@ -98,13 +104,15 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV
|
||||
}
|
||||
|
||||
// generate & register the OriginCaller type
|
||||
function registerOriginCaller (registry: Registry, modules: ModuleMetadataV12[], metaVersion: number): void {
|
||||
function registerOriginCaller (registry: Registry, modules: ModuleMetadataV13[], metaVersion: number): void {
|
||||
registry.register({
|
||||
OriginCaller: {
|
||||
_enum: modules
|
||||
.map((mod, index): [string, number] => [
|
||||
mod.name.toString(),
|
||||
metaVersion >= 12 ? mod.index.toNumber() : index
|
||||
metaVersion >= 12
|
||||
? mod.index.toNumber()
|
||||
: index
|
||||
])
|
||||
.sort((a, b) => a[1] - b[1])
|
||||
.reduce((result: Record<string, string>, [name, index]): Record<string, string> => {
|
||||
@@ -121,7 +129,7 @@ function registerOriginCaller (registry: Registry, modules: ModuleMetadataV12[],
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function createModule (registry: Registry, mod: ModuleMetadataV12, { calls, constants, events, storage }: { calls: FunctionMetadataV12[] | null, constants: ModuleConstantMetadataV12[], events: EventMetadataV12[] | null, storage: StorageMetadataV12 | null }): ModuleMetadataLatest {
|
||||
function createModule (registry: Registry, mod: ModuleMetadataV13, { calls, constants, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): ModuleMetadataLatest {
|
||||
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name));
|
||||
|
||||
return registry.createType('ModuleMetadataLatest', {
|
||||
@@ -138,7 +146,7 @@ function createModule (registry: Registry, mod: ModuleMetadataV12, { calls, cons
|
||||
* most-recent metadata, since it allows us a chance to actually apply call and storage specific type aliasses
|
||||
* @internal
|
||||
**/
|
||||
export function toLatest (registry: Registry, { extrinsic, modules }: MetadataV12, metaVersion: number): MetadataLatest {
|
||||
export function toLatest (registry: Registry, { extrinsic, modules }: MetadataV13, metaVersion: number): MetadataLatest {
|
||||
registerOriginCaller(registry, modules, metaVersion);
|
||||
|
||||
return registry.createType('MetadataLatest', {
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/rpc-provider": "4.8.1",
|
||||
"@polkadot/types": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/x-rxjs": "^6.3.1"
|
||||
"@polkadot/metadata": "4.10.1",
|
||||
"@polkadot/rpc-provider": "4.10.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/x-rxjs": "^6.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.3.1"
|
||||
"@polkadot/keyring": "^6.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class RpcCore {
|
||||
|
||||
#registryDefault: Registry;
|
||||
|
||||
#getBlockRegistry?: (blockHash: string | Uint8Array) => Promise<{ registry: Registry }>;
|
||||
#getBlockRegistry?: (blockHash: Uint8Array) => Promise<{ registry: Registry }>;
|
||||
|
||||
readonly #storageCache = new Map<string, string | null>();
|
||||
|
||||
@@ -140,8 +140,10 @@ export class RpcCore {
|
||||
/**
|
||||
* @description Sets a registry swap (typically from Api)
|
||||
*/
|
||||
public setRegistrySwap (registrySwap: (blockHash: string | Uint8Array) => Promise<{ registry: Registry }>): void {
|
||||
this.#getBlockRegistry = registrySwap;
|
||||
public setRegistrySwap (registrySwap: (blockHash: Uint8Array) => Promise<{ registry: Registry }>): void {
|
||||
this.#getBlockRegistry = memoize(registrySwap, {
|
||||
getInstanceId: () => this.#instanceId
|
||||
});
|
||||
}
|
||||
|
||||
public addUserInterfaces<Section extends keyof RpcInterface> (userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
@@ -176,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);
|
||||
@@ -190,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;
|
||||
}
|
||||
@@ -204,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;
|
||||
const { registry } = blockHash && this.#getBlockRegistry
|
||||
? await this.#getBlockRegistry(blockHash)
|
||||
: values[hashIndex] as (Uint8Array | string | null | undefined);
|
||||
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();
|
||||
@@ -251,7 +247,7 @@ export class RpcCore {
|
||||
);
|
||||
};
|
||||
|
||||
memoized = this._memomize(creator);
|
||||
memoized = this._memomize(creator, def);
|
||||
|
||||
return memoized;
|
||||
}
|
||||
@@ -276,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;
|
||||
@@ -292,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);
|
||||
|
||||
@@ -302,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);
|
||||
@@ -332,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
|
||||
? ''
|
||||
@@ -350,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>;
|
||||
|
||||
@@ -438,27 +434,23 @@ export class RpcCore {
|
||||
? ''
|
||||
: ` entry ${entryIndex}:`;
|
||||
|
||||
if (meta.modifier.isOptional) {
|
||||
let inner = null;
|
||||
|
||||
if (!isEmpty) {
|
||||
try {
|
||||
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
const option = new Option(registry, createClass(registry, type), inner);
|
||||
|
||||
if (blockHash) {
|
||||
option.createdAtHash = registry.createType('Hash', blockHash);
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
try {
|
||||
if (meta.modifier.isOptional) {
|
||||
let inner = null;
|
||||
|
||||
if (!isEmpty) {
|
||||
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
|
||||
}
|
||||
|
||||
const option = new Option(registry, createClass(registry, type), inner);
|
||||
|
||||
if (blockHash) {
|
||||
option.createdAtHash = registry.createType('Hash', blockHash);
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
return createTypeUnsafe(registry, type, [
|
||||
isEmpty
|
||||
? meta.fallback
|
||||
@@ -467,9 +459,7 @@ export class RpcCore {
|
||||
: input
|
||||
], { blockHash, isPedantic: true });
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
|
||||
|
||||
return createTypeUnsafe(registry, 'Raw', [input], { blockHash });
|
||||
throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.10.1' };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const CMP = (a: unknown, b: unknown): boolean =>
|
||||
stringify({ t: a }) === stringify({ t: b });
|
||||
|
||||
const ERR = (error: Error): Observable<never> => {
|
||||
l.error(error);
|
||||
l.error(error.message);
|
||||
|
||||
throw error;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.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.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/util-crypto": "^6.4.1",
|
||||
"@polkadot/x-fetch": "^6.4.1",
|
||||
"@polkadot/x-global": "^6.4.1",
|
||||
"@polkadot/x-ws": "^6.4.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.3.1",
|
||||
"@polkadot/metadata": "4.8.1",
|
||||
"@polkadot/keyring": "^6.4.1",
|
||||
"@polkadot/metadata": "4.10.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.11"
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -53,23 +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 }),
|
||||
system_version: (): string => '9.8.7'
|
||||
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: () => '9.8.7'
|
||||
};
|
||||
|
||||
public subscriptions: MockStateSubscriptions = SUBSCRIPTIONS.reduce((subs, name): MockStateSubscriptions => {
|
||||
@@ -120,15 +121,17 @@ 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
|
||||
public async subscribe (type: string, method: string, ...params: unknown[]): Promise<number> {
|
||||
l.debug((): any => ['subscribe', method, params]);
|
||||
l.debug(() => ['subscribe', method, params]);
|
||||
|
||||
assert(this.subscriptions[method], () => `provider.subscribe: Invalid method '${method}'`);
|
||||
|
||||
@@ -149,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}`);
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.10.1' };
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -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 } = {
|
||||
@@ -254,7 +254,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 +262,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 +287,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 +302,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 +333,7 @@ export class WsProvider implements ProviderInterface {
|
||||
}
|
||||
}
|
||||
|
||||
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
|
||||
#emit = (type: ProviderInterfaceEmitted, ...args: unknown[]): void => {
|
||||
this.#eventemitter.emit(type, ...args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
@@ -26,17 +26,17 @@
|
||||
"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.2",
|
||||
"@babel/register": "^7.13.16",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.8.1",
|
||||
"@polkadot/metadata": "4.8.1",
|
||||
"@polkadot/rpc-provider": "4.8.1",
|
||||
"@polkadot/types": "4.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/api": "4.10.1",
|
||||
"@polkadot/metadata": "4.10.1",
|
||||
"@polkadot/rpc-provider": "4.10.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^16.2.0"
|
||||
"yargs": "^17.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.2",
|
||||
|
||||
@@ -25,38 +25,60 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
|
||||
return ['', '', formatType(allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
const map = storageEntry.type.asMap;
|
||||
|
||||
// Find similar types of the `key` type
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, storageEntry.type.asMap.key.toString(), imports);
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, map.key.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes,
|
||||
storageEntry.type.asMap.value.toString()
|
||||
map.value.toString()
|
||||
]);
|
||||
|
||||
return [
|
||||
formatType(allDefs, storageEntry.type.asMap.key.toString(), imports),
|
||||
formatType(allDefs, map.key.toString(), imports),
|
||||
`arg: ${similarTypes.join(' | ')}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
];
|
||||
} else if (storageEntry.type.isDoubleMap) {
|
||||
const dm = storageEntry.type.asDoubleMap;
|
||||
|
||||
// Find similar types of `key1` and `key2` types
|
||||
const similarTypes1 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports);
|
||||
const similarTypes2 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports);
|
||||
const similarTypes1 = getSimilarTypes(registry, allDefs, dm.key1.toString(), imports);
|
||||
const similarTypes2 = getSimilarTypes(registry, allDefs, dm.key2.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes1,
|
||||
...similarTypes2,
|
||||
storageEntry.type.asDoubleMap.value.toString()
|
||||
dm.value.toString()
|
||||
]);
|
||||
|
||||
const key1Types = similarTypes1.join(' | ');
|
||||
const key2Types = similarTypes2.join(' | ');
|
||||
|
||||
return [
|
||||
[formatType(allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports), formatType(allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports)].join(', '),
|
||||
[formatType(allDefs, dm.key1.toString(), imports), formatType(allDefs, dm.key2.toString(), imports)].join(', '),
|
||||
`key1: ${key1Types}, key2: ${key2Types}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
];
|
||||
} else if (storageEntry.type.isNMap) {
|
||||
const nmap = storageEntry.type.asNMap;
|
||||
|
||||
// Find similar types for all keys
|
||||
const similarTypes = nmap.keyVec.map((k) => getSimilarTypes(registry, allDefs, k.toString(), imports));
|
||||
|
||||
setImports(allDefs, imports, [
|
||||
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
|
||||
nmap.value.toString()
|
||||
]);
|
||||
|
||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||
|
||||
return [
|
||||
nmap.keyVec.map((k) => formatType(allDefs, k.toString(), imports)).join(', '),
|
||||
keyTypes.map((t, i) => `key${i + 1}: ${t}`).join(', '),
|
||||
formatType(allDefs, outputType, imports)
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(`entryArgs: Cannot parse args of entry ${storageEntry.name.toString()}`);
|
||||
|
||||
@@ -210,7 +210,9 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
? ('`' + func.type.asMap.key.toString() + '`')
|
||||
: func.type.isDoubleMap
|
||||
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
|
||||
: '';
|
||||
: func.type.isNMap
|
||||
? ('`' + func.type.asNMap.keyVec.map((k) => k.toString()).join(', ') + '`')
|
||||
: '';
|
||||
const methodName = stringLowerFirst(func.name);
|
||||
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.10.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/networks": "^6.4.1",
|
||||
"@polkadot/types": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -48,9 +48,15 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
parachains: {
|
||||
Id: 'ParaId'
|
||||
},
|
||||
parasInclusion: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
parasScheduler: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
parasShared: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
proposeParachain: {
|
||||
Proposal: 'ParachainProposal'
|
||||
},
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.8.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.10.1' };
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -20,25 +20,39 @@ const versioned: OverrideVersionedType[] = [
|
||||
...sharedTypes,
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
Address: 'AccountId',
|
||||
LookupSource: 'AccountId'
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
LookupSource: 'AccountId',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [201, 214],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
AccountInfo: 'AccountInfoWithDualRefCount'
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [215, 228],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
Keys: 'SessionKeys6'
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
Keys: 'SessionKeys6',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [229, undefined],
|
||||
minmax: [229, 9000],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [9010, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ const sharedTypes = {
|
||||
const addrAccountIdTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
LookupSource: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithCommission'
|
||||
};
|
||||
|
||||
@@ -71,11 +73,21 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [48, 49],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
AccountInfo: 'AccountInfoWithDualRefCount'
|
||||
AccountInfo: 'AccountInfoWithDualRefCount',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [50, undefined],
|
||||
minmax: [50, 9000],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [9010, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "4.8.1",
|
||||
"version": "4.10.1",
|
||||
"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.8.1",
|
||||
"@polkadot/util": "^6.3.1",
|
||||
"@polkadot/util-crypto": "^6.3.1",
|
||||
"@polkadot/x-rxjs": "^6.3.1",
|
||||
"@polkadot/metadata": "4.10.1",
|
||||
"@polkadot/util": "^6.4.1",
|
||||
"@polkadot/util-crypto": "^6.4.1",
|
||||
"@polkadot/x-rxjs": "^6.4.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.3.1"
|
||||
"@polkadot/keyring": "^6.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
|
||||
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractStorageKey, DeletedContract, Gas, HostFnWeights, HostFnWeightsTo264, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
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';
|
||||
@@ -30,31 +31,31 @@ import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityPro
|
||||
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV13, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV13, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, NMapTypeLatest, NMapTypeV13, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
|
||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayChainHash, Remark, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import type { FeeDetails, InclusionFee, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { Approvals } from '@polkadot/types/interfaces/poll';
|
||||
import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, 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, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } 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 { 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, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, Outcome, PluralityJunction, 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 } from '@polkadot/types/interfaces/xcm';
|
||||
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';
|
||||
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
export interface InterfaceTypes {
|
||||
@@ -73,7 +74,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<BalanceOf>': Compact<BalanceOf>;
|
||||
'Compact<BlockNumber>': Compact<BlockNumber>;
|
||||
'Compact<BountyIndex>': Compact<BountyIndex>;
|
||||
'Compact<ConsensusEngineId>': Compact<ConsensusEngineId>;
|
||||
'Compact<ContractDiscriminant>': Compact<ContractDiscriminant>;
|
||||
'Compact<CoreIndex>': Compact<CoreIndex>;
|
||||
'Compact<EraIndex>': Compact<EraIndex>;
|
||||
@@ -93,6 +93,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>;
|
||||
@@ -108,6 +110,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<RefCountTo259>': Compact<RefCountTo259>;
|
||||
'Compact<ReferendumIndex>': Compact<ReferendumIndex>;
|
||||
'Compact<RegistrarIndex>': Compact<RegistrarIndex>;
|
||||
'Compact<RelayBlockNumber>': Compact<RelayBlockNumber>;
|
||||
'Compact<RelayChainBlockNumber>': Compact<RelayChainBlockNumber>;
|
||||
'Compact<RewardPoint>': Compact<RewardPoint>;
|
||||
'Compact<SchedulePriority>': Compact<SchedulePriority>;
|
||||
@@ -178,6 +181,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>;
|
||||
@@ -225,6 +229,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<BlockHash>': Option<BlockHash>;
|
||||
'Option<BlockLength>': Option<BlockLength>;
|
||||
'Option<BlockNumber>': Option<BlockNumber>;
|
||||
'Option<BlockTrace>': Option<BlockTrace>;
|
||||
'Option<BlockTraceEvent>': Option<BlockTraceEvent>;
|
||||
'Option<BlockTraceEventData>': Option<BlockTraceEventData>;
|
||||
'Option<BlockTraceSpan>': Option<BlockTraceSpan>;
|
||||
'Option<BlockWeights>': Option<BlockWeights>;
|
||||
'Option<BodyId>': Option<BodyId>;
|
||||
'Option<BodyPart>': Option<BodyPart>;
|
||||
@@ -253,6 +261,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
'Option<ChainType>': Option<ChainType>;
|
||||
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
|
||||
'Option<ChangesTrieSignal>': Option<ChangesTrieSignal>;
|
||||
'Option<CodecHash>': Option<CodecHash>;
|
||||
'Option<CodeHash>': Option<CodeHash>;
|
||||
'Option<CollatorId>': Option<CollatorId>;
|
||||
@@ -261,8 +270,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>;
|
||||
@@ -284,6 +297,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ContractExecResultTo255>': Option<ContractExecResultTo255>;
|
||||
'Option<ContractExecResultTo260>': Option<ContractExecResultTo260>;
|
||||
'Option<ContractInfo>': Option<ContractInfo>;
|
||||
'Option<ContractInstantiateResult>': Option<ContractInstantiateResult>;
|
||||
'Option<ContractLayoutArray>': Option<ContractLayoutArray>;
|
||||
'Option<ContractLayoutCell>': Option<ContractLayoutCell>;
|
||||
'Option<ContractLayoutEnum>': Option<ContractLayoutEnum>;
|
||||
@@ -333,6 +347,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<DoubleMapTypeV10>': Option<DoubleMapTypeV10>;
|
||||
'Option<DoubleMapTypeV11>': Option<DoubleMapTypeV11>;
|
||||
'Option<DoubleMapTypeV12>': Option<DoubleMapTypeV12>;
|
||||
'Option<DoubleMapTypeV13>': Option<DoubleMapTypeV13>;
|
||||
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
|
||||
'Option<DoubleVoteReport>': Option<DoubleVoteReport>;
|
||||
'Option<DownwardMessage>': Option<DownwardMessage>;
|
||||
@@ -355,6 +370,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ErrorMetadataV10>': Option<ErrorMetadataV10>;
|
||||
'Option<ErrorMetadataV11>': Option<ErrorMetadataV11>;
|
||||
'Option<ErrorMetadataV12>': Option<ErrorMetadataV12>;
|
||||
'Option<ErrorMetadataV13>': Option<ErrorMetadataV13>;
|
||||
'Option<ErrorMetadataV9>': Option<ErrorMetadataV9>;
|
||||
'Option<EthAccount>': Option<EthAccount>;
|
||||
'Option<EthBlock>': Option<EthBlock>;
|
||||
@@ -395,11 +411,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<EventMetadataV10>': Option<EventMetadataV10>;
|
||||
'Option<EventMetadataV11>': Option<EventMetadataV11>;
|
||||
'Option<EventMetadataV12>': Option<EventMetadataV12>;
|
||||
'Option<EventMetadataV13>': Option<EventMetadataV13>;
|
||||
'Option<EventMetadataV9>': Option<EventMetadataV9>;
|
||||
'Option<EventRecord>': Option<EventRecord>;
|
||||
'Option<EvmAccount>': Option<EvmAccount>;
|
||||
'Option<EvmLog>': Option<EvmLog>;
|
||||
'Option<EvmVicinity>': Option<EvmVicinity>;
|
||||
'Option<ExecReturnValue>': Option<ExecReturnValue>;
|
||||
'Option<ExitError>': Option<ExitError>;
|
||||
'Option<ExitFatal>': Option<ExitFatal>;
|
||||
'Option<ExitReason>': Option<ExitReason>;
|
||||
@@ -413,6 +431,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ExtrinsicMetadataLatest>': Option<ExtrinsicMetadataLatest>;
|
||||
'Option<ExtrinsicMetadataV11>': Option<ExtrinsicMetadataV11>;
|
||||
'Option<ExtrinsicMetadataV12>': Option<ExtrinsicMetadataV12>;
|
||||
'Option<ExtrinsicMetadataV13>': Option<ExtrinsicMetadataV13>;
|
||||
'Option<ExtrinsicOrHash>': Option<ExtrinsicOrHash>;
|
||||
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
|
||||
'Option<ExtrinsicPayloadUnknown>': Option<ExtrinsicPayloadUnknown>;
|
||||
@@ -436,11 +455,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<FunctionArgumentMetadataV10>': Option<FunctionArgumentMetadataV10>;
|
||||
'Option<FunctionArgumentMetadataV11>': Option<FunctionArgumentMetadataV11>;
|
||||
'Option<FunctionArgumentMetadataV12>': Option<FunctionArgumentMetadataV12>;
|
||||
'Option<FunctionArgumentMetadataV13>': Option<FunctionArgumentMetadataV13>;
|
||||
'Option<FunctionArgumentMetadataV9>': Option<FunctionArgumentMetadataV9>;
|
||||
'Option<FunctionMetadataLatest>': Option<FunctionMetadataLatest>;
|
||||
'Option<FunctionMetadataV10>': Option<FunctionMetadataV10>;
|
||||
'Option<FunctionMetadataV11>': Option<FunctionMetadataV11>;
|
||||
'Option<FunctionMetadataV12>': Option<FunctionMetadataV12>;
|
||||
'Option<FunctionMetadataV13>': Option<FunctionMetadataV13>;
|
||||
'Option<FunctionMetadataV9>': Option<FunctionMetadataV9>;
|
||||
'Option<FundIndex>': Option<FundIndex>;
|
||||
'Option<FundInfo>': Option<FundInfo>;
|
||||
@@ -464,6 +485,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>;
|
||||
@@ -496,6 +518,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<InboundDownwardMessage>': Option<InboundDownwardMessage>;
|
||||
'Option<InboundHrmpMessage>': Option<InboundHrmpMessage>;
|
||||
'Option<InboundHrmpMessages>': Option<InboundHrmpMessages>;
|
||||
'Option<InboundStatus>': Option<InboundStatus>;
|
||||
'Option<IncludedBlocks>': Option<IncludedBlocks>;
|
||||
'Option<InclusionFee>': Option<InclusionFee>;
|
||||
'Option<IncomingParachain>': Option<IncomingParachain>;
|
||||
@@ -504,6 +527,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Index>': Option<Index>;
|
||||
'Option<IndicesLookupSource>': Option<IndicesLookupSource>;
|
||||
'Option<IndividualExposure>': Option<IndividualExposure>;
|
||||
'Option<InstantiateRequest>': Option<InstantiateRequest>;
|
||||
'Option<InstantiateReturnValue>': Option<InstantiateReturnValue>;
|
||||
'Option<InstructionWeights>': Option<InstructionWeights>;
|
||||
'Option<InvalidDisputeStatementKind>': Option<InvalidDisputeStatementKind>;
|
||||
'Option<InvalidTransaction>': Option<InvalidTransaction>;
|
||||
@@ -535,11 +560,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<MapTypeV10>': Option<MapTypeV10>;
|
||||
'Option<MapTypeV11>': Option<MapTypeV11>;
|
||||
'Option<MapTypeV12>': Option<MapTypeV12>;
|
||||
'Option<MapTypeV13>': Option<MapTypeV13>;
|
||||
'Option<MapTypeV9>': Option<MapTypeV9>;
|
||||
'Option<MaybeRandomness>': Option<MaybeRandomness>;
|
||||
'Option<MaybeVrf>': Option<MaybeVrf>;
|
||||
'Option<MemberCount>': Option<MemberCount>;
|
||||
'Option<MembershipProof>': Option<MembershipProof>;
|
||||
'Option<MessageId>': Option<MessageId>;
|
||||
'Option<MessageIngestionType>': Option<MessageIngestionType>;
|
||||
'Option<MessageQueueChain>': Option<MessageQueueChain>;
|
||||
'Option<MessagingStateSnapshot>': Option<MessagingStateSnapshot>;
|
||||
@@ -549,6 +576,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<MetadataV10>': Option<MetadataV10>;
|
||||
'Option<MetadataV11>': Option<MetadataV11>;
|
||||
'Option<MetadataV12>': Option<MetadataV12>;
|
||||
'Option<MetadataV13>': Option<MetadataV13>;
|
||||
'Option<MetadataV9>': Option<MetadataV9>;
|
||||
'Option<MmrLeafProof>': Option<MmrLeafProof>;
|
||||
'Option<MmrRootHash>': Option<MmrRootHash>;
|
||||
@@ -556,12 +584,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ModuleConstantMetadataV10>': Option<ModuleConstantMetadataV10>;
|
||||
'Option<ModuleConstantMetadataV11>': Option<ModuleConstantMetadataV11>;
|
||||
'Option<ModuleConstantMetadataV12>': Option<ModuleConstantMetadataV12>;
|
||||
'Option<ModuleConstantMetadataV13>': Option<ModuleConstantMetadataV13>;
|
||||
'Option<ModuleConstantMetadataV9>': Option<ModuleConstantMetadataV9>;
|
||||
'Option<ModuleId>': Option<ModuleId>;
|
||||
'Option<ModuleMetadataLatest>': Option<ModuleMetadataLatest>;
|
||||
'Option<ModuleMetadataV10>': Option<ModuleMetadataV10>;
|
||||
'Option<ModuleMetadataV11>': Option<ModuleMetadataV11>;
|
||||
'Option<ModuleMetadataV12>': Option<ModuleMetadataV12>;
|
||||
'Option<ModuleMetadataV13>': Option<ModuleMetadataV13>;
|
||||
'Option<ModuleMetadataV9>': Option<ModuleMetadataV9>;
|
||||
'Option<Moment>': Option<Moment>;
|
||||
'Option<MomentOf>': Option<MomentOf>;
|
||||
@@ -587,6 +617,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<NextAuthority>': Option<NextAuthority>;
|
||||
'Option<NextConfigDescriptor>': Option<NextConfigDescriptor>;
|
||||
'Option<NextConfigDescriptorV1>': Option<NextConfigDescriptorV1>;
|
||||
'Option<NMapTypeLatest>': Option<NMapTypeLatest>;
|
||||
'Option<NMapTypeV13>': Option<NMapTypeV13>;
|
||||
'Option<NodeRole>': Option<NodeRole>;
|
||||
'Option<Nominations>': Option<Nominations>;
|
||||
'Option<NominatorIndex>': Option<NominatorIndex>;
|
||||
@@ -609,8 +641,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Origin>': Option<Origin>;
|
||||
'Option<OriginCaller>': Option<OriginCaller>;
|
||||
'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>;
|
||||
@@ -671,6 +707,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ProxyDefinition>': Option<ProxyDefinition>;
|
||||
'Option<ProxyState>': Option<ProxyState>;
|
||||
'Option<ProxyType>': Option<ProxyType>;
|
||||
'Option<QueueConfigData>': Option<QueueConfigData>;
|
||||
'Option<QueuedParathread>': Option<QueuedParathread>;
|
||||
'Option<Randomness>': Option<Randomness>;
|
||||
'Option<Raw>': Option<Raw>;
|
||||
@@ -685,6 +722,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>;
|
||||
@@ -702,11 +742,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<RegistrarInfo>': Option<RegistrarInfo>;
|
||||
'Option<Registration>': Option<Registration>;
|
||||
'Option<RegistrationJudgement>': Option<RegistrationJudgement>;
|
||||
'Option<RelayBlockNumber>': Option<RelayBlockNumber>;
|
||||
'Option<RelayChainBlockNumber>': Option<RelayChainBlockNumber>;
|
||||
'Option<RelayChainHash>': Option<RelayChainHash>;
|
||||
'Option<RelayHash>': Option<RelayHash>;
|
||||
'Option<Releases>': Option<Releases>;
|
||||
'Option<Remark>': Option<Remark>;
|
||||
'Option<Renouncing>': Option<Renouncing>;
|
||||
'Option<RentProjection>': Option<RentProjection>;
|
||||
'Option<ReportedRoundStates>': Option<ReportedRoundStates>;
|
||||
'Option<Reporter>': Option<Reporter>;
|
||||
'Option<ReportIdOf>': Option<ReportIdOf>;
|
||||
@@ -720,6 +763,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>;
|
||||
@@ -799,21 +843,25 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<StorageEntryMetadataV10>': Option<StorageEntryMetadataV10>;
|
||||
'Option<StorageEntryMetadataV11>': Option<StorageEntryMetadataV11>;
|
||||
'Option<StorageEntryMetadataV12>': Option<StorageEntryMetadataV12>;
|
||||
'Option<StorageEntryMetadataV13>': Option<StorageEntryMetadataV13>;
|
||||
'Option<StorageEntryMetadataV9>': Option<StorageEntryMetadataV9>;
|
||||
'Option<StorageEntryModifierLatest>': Option<StorageEntryModifierLatest>;
|
||||
'Option<StorageEntryModifierV10>': Option<StorageEntryModifierV10>;
|
||||
'Option<StorageEntryModifierV11>': Option<StorageEntryModifierV11>;
|
||||
'Option<StorageEntryModifierV12>': Option<StorageEntryModifierV12>;
|
||||
'Option<StorageEntryModifierV13>': Option<StorageEntryModifierV13>;
|
||||
'Option<StorageEntryModifierV9>': Option<StorageEntryModifierV9>;
|
||||
'Option<StorageEntryTypeLatest>': Option<StorageEntryTypeLatest>;
|
||||
'Option<StorageEntryTypeV10>': Option<StorageEntryTypeV10>;
|
||||
'Option<StorageEntryTypeV11>': Option<StorageEntryTypeV11>;
|
||||
'Option<StorageEntryTypeV12>': Option<StorageEntryTypeV12>;
|
||||
'Option<StorageEntryTypeV13>': Option<StorageEntryTypeV13>;
|
||||
'Option<StorageEntryTypeV9>': Option<StorageEntryTypeV9>;
|
||||
'Option<StorageHasher>': Option<StorageHasher>;
|
||||
'Option<StorageHasherV10>': Option<StorageHasherV10>;
|
||||
'Option<StorageHasherV11>': Option<StorageHasherV11>;
|
||||
'Option<StorageHasherV12>': Option<StorageHasherV12>;
|
||||
'Option<StorageHasherV13>': Option<StorageHasherV13>;
|
||||
'Option<StorageHasherV9>': Option<StorageHasherV9>;
|
||||
'Option<StorageKey>': Option<StorageKey>;
|
||||
'Option<StorageKind>': Option<StorageKind>;
|
||||
@@ -821,6 +869,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<StorageMetadataV10>': Option<StorageMetadataV10>;
|
||||
'Option<StorageMetadataV11>': Option<StorageMetadataV11>;
|
||||
'Option<StorageMetadataV12>': Option<StorageMetadataV12>;
|
||||
'Option<StorageMetadataV13>': Option<StorageMetadataV13>;
|
||||
'Option<StorageMetadataV9>': Option<StorageMetadataV9>;
|
||||
'Option<StorageProof>': Option<StorageProof>;
|
||||
'Option<StoredPendingChange>': Option<StoredPendingChange>;
|
||||
@@ -838,6 +887,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Timepoint>': Option<Timepoint>;
|
||||
'Option<TokenError>': Option<TokenError>;
|
||||
'Option<TombstoneContractInfo>': Option<TombstoneContractInfo>;
|
||||
'Option<TraceBlockResponse>': Option<TraceBlockResponse>;
|
||||
'Option<TraceError>': Option<TraceError>;
|
||||
'Option<TransactionPriority>': Option<TransactionPriority>;
|
||||
'Option<TransactionValidityError>': Option<TransactionValidityError>;
|
||||
'Option<TransientValidationData>': Option<TransientValidationData>;
|
||||
@@ -930,6 +981,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<XcmOrderInitiateTeleport>': Option<XcmOrderInitiateTeleport>;
|
||||
'Option<XcmOrderQueryHolding>': Option<XcmOrderQueryHolding>;
|
||||
'Option<XcmOriginKind>': Option<XcmOriginKind>;
|
||||
'Option<XcmpMessageFormat>': Option<XcmpMessageFormat>;
|
||||
'Option<XcmQueryResponse>': Option<XcmQueryResponse>;
|
||||
'Option<XcmRelayedFrom>': Option<XcmRelayedFrom>;
|
||||
'Option<XcmReserveAssetDeposit>': Option<XcmReserveAssetDeposit>;
|
||||
@@ -972,6 +1024,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>;
|
||||
@@ -1019,6 +1072,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<BlockHash>': Vec<BlockHash>;
|
||||
'Vec<BlockLength>': Vec<BlockLength>;
|
||||
'Vec<BlockNumber>': Vec<BlockNumber>;
|
||||
'Vec<BlockTrace>': Vec<BlockTrace>;
|
||||
'Vec<BlockTraceEvent>': Vec<BlockTraceEvent>;
|
||||
'Vec<BlockTraceEventData>': Vec<BlockTraceEventData>;
|
||||
'Vec<BlockTraceSpan>': Vec<BlockTraceSpan>;
|
||||
'Vec<BlockWeights>': Vec<BlockWeights>;
|
||||
'Vec<BodyId>': Vec<BodyId>;
|
||||
'Vec<BodyPart>': Vec<BodyPart>;
|
||||
@@ -1047,6 +1104,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
'Vec<ChainType>': Vec<ChainType>;
|
||||
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
|
||||
'Vec<ChangesTrieSignal>': Vec<ChangesTrieSignal>;
|
||||
'Vec<CodecHash>': Vec<CodecHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
'Vec<CollatorId>': Vec<CollatorId>;
|
||||
@@ -1055,8 +1113,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>;
|
||||
@@ -1078,6 +1140,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ContractExecResultTo255>': Vec<ContractExecResultTo255>;
|
||||
'Vec<ContractExecResultTo260>': Vec<ContractExecResultTo260>;
|
||||
'Vec<ContractInfo>': Vec<ContractInfo>;
|
||||
'Vec<ContractInstantiateResult>': Vec<ContractInstantiateResult>;
|
||||
'Vec<ContractLayoutArray>': Vec<ContractLayoutArray>;
|
||||
'Vec<ContractLayoutCell>': Vec<ContractLayoutCell>;
|
||||
'Vec<ContractLayoutEnum>': Vec<ContractLayoutEnum>;
|
||||
@@ -1127,6 +1190,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<DoubleMapTypeV10>': Vec<DoubleMapTypeV10>;
|
||||
'Vec<DoubleMapTypeV11>': Vec<DoubleMapTypeV11>;
|
||||
'Vec<DoubleMapTypeV12>': Vec<DoubleMapTypeV12>;
|
||||
'Vec<DoubleMapTypeV13>': Vec<DoubleMapTypeV13>;
|
||||
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
|
||||
'Vec<DoubleVoteReport>': Vec<DoubleVoteReport>;
|
||||
'Vec<DownwardMessage>': Vec<DownwardMessage>;
|
||||
@@ -1149,6 +1213,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ErrorMetadataV10>': Vec<ErrorMetadataV10>;
|
||||
'Vec<ErrorMetadataV11>': Vec<ErrorMetadataV11>;
|
||||
'Vec<ErrorMetadataV12>': Vec<ErrorMetadataV12>;
|
||||
'Vec<ErrorMetadataV13>': Vec<ErrorMetadataV13>;
|
||||
'Vec<ErrorMetadataV9>': Vec<ErrorMetadataV9>;
|
||||
'Vec<EthAccount>': Vec<EthAccount>;
|
||||
'Vec<EthBlock>': Vec<EthBlock>;
|
||||
@@ -1189,11 +1254,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<EventMetadataV10>': Vec<EventMetadataV10>;
|
||||
'Vec<EventMetadataV11>': Vec<EventMetadataV11>;
|
||||
'Vec<EventMetadataV12>': Vec<EventMetadataV12>;
|
||||
'Vec<EventMetadataV13>': Vec<EventMetadataV13>;
|
||||
'Vec<EventMetadataV9>': Vec<EventMetadataV9>;
|
||||
'Vec<EventRecord>': Vec<EventRecord>;
|
||||
'Vec<EvmAccount>': Vec<EvmAccount>;
|
||||
'Vec<EvmLog>': Vec<EvmLog>;
|
||||
'Vec<EvmVicinity>': Vec<EvmVicinity>;
|
||||
'Vec<ExecReturnValue>': Vec<ExecReturnValue>;
|
||||
'Vec<ExitError>': Vec<ExitError>;
|
||||
'Vec<ExitFatal>': Vec<ExitFatal>;
|
||||
'Vec<ExitReason>': Vec<ExitReason>;
|
||||
@@ -1207,6 +1274,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ExtrinsicMetadataLatest>': Vec<ExtrinsicMetadataLatest>;
|
||||
'Vec<ExtrinsicMetadataV11>': Vec<ExtrinsicMetadataV11>;
|
||||
'Vec<ExtrinsicMetadataV12>': Vec<ExtrinsicMetadataV12>;
|
||||
'Vec<ExtrinsicMetadataV13>': Vec<ExtrinsicMetadataV13>;
|
||||
'Vec<ExtrinsicOrHash>': Vec<ExtrinsicOrHash>;
|
||||
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
|
||||
'Vec<ExtrinsicPayloadUnknown>': Vec<ExtrinsicPayloadUnknown>;
|
||||
@@ -1230,11 +1298,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<FunctionArgumentMetadataV10>': Vec<FunctionArgumentMetadataV10>;
|
||||
'Vec<FunctionArgumentMetadataV11>': Vec<FunctionArgumentMetadataV11>;
|
||||
'Vec<FunctionArgumentMetadataV12>': Vec<FunctionArgumentMetadataV12>;
|
||||
'Vec<FunctionArgumentMetadataV13>': Vec<FunctionArgumentMetadataV13>;
|
||||
'Vec<FunctionArgumentMetadataV9>': Vec<FunctionArgumentMetadataV9>;
|
||||
'Vec<FunctionMetadataLatest>': Vec<FunctionMetadataLatest>;
|
||||
'Vec<FunctionMetadataV10>': Vec<FunctionMetadataV10>;
|
||||
'Vec<FunctionMetadataV11>': Vec<FunctionMetadataV11>;
|
||||
'Vec<FunctionMetadataV12>': Vec<FunctionMetadataV12>;
|
||||
'Vec<FunctionMetadataV13>': Vec<FunctionMetadataV13>;
|
||||
'Vec<FunctionMetadataV9>': Vec<FunctionMetadataV9>;
|
||||
'Vec<FundIndex>': Vec<FundIndex>;
|
||||
'Vec<FundInfo>': Vec<FundInfo>;
|
||||
@@ -1258,6 +1328,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>;
|
||||
@@ -1290,6 +1361,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<InboundDownwardMessage>': Vec<InboundDownwardMessage>;
|
||||
'Vec<InboundHrmpMessage>': Vec<InboundHrmpMessage>;
|
||||
'Vec<InboundHrmpMessages>': Vec<InboundHrmpMessages>;
|
||||
'Vec<InboundStatus>': Vec<InboundStatus>;
|
||||
'Vec<IncludedBlocks>': Vec<IncludedBlocks>;
|
||||
'Vec<InclusionFee>': Vec<InclusionFee>;
|
||||
'Vec<IncomingParachain>': Vec<IncomingParachain>;
|
||||
@@ -1298,6 +1370,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<Index>': Vec<Index>;
|
||||
'Vec<IndicesLookupSource>': Vec<IndicesLookupSource>;
|
||||
'Vec<IndividualExposure>': Vec<IndividualExposure>;
|
||||
'Vec<InstantiateRequest>': Vec<InstantiateRequest>;
|
||||
'Vec<InstantiateReturnValue>': Vec<InstantiateReturnValue>;
|
||||
'Vec<InstructionWeights>': Vec<InstructionWeights>;
|
||||
'Vec<InvalidDisputeStatementKind>': Vec<InvalidDisputeStatementKind>;
|
||||
'Vec<InvalidTransaction>': Vec<InvalidTransaction>;
|
||||
@@ -1329,11 +1403,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<MapTypeV10>': Vec<MapTypeV10>;
|
||||
'Vec<MapTypeV11>': Vec<MapTypeV11>;
|
||||
'Vec<MapTypeV12>': Vec<MapTypeV12>;
|
||||
'Vec<MapTypeV13>': Vec<MapTypeV13>;
|
||||
'Vec<MapTypeV9>': Vec<MapTypeV9>;
|
||||
'Vec<MaybeRandomness>': Vec<MaybeRandomness>;
|
||||
'Vec<MaybeVrf>': Vec<MaybeVrf>;
|
||||
'Vec<MemberCount>': Vec<MemberCount>;
|
||||
'Vec<MembershipProof>': Vec<MembershipProof>;
|
||||
'Vec<MessageId>': Vec<MessageId>;
|
||||
'Vec<MessageIngestionType>': Vec<MessageIngestionType>;
|
||||
'Vec<MessageQueueChain>': Vec<MessageQueueChain>;
|
||||
'Vec<MessagingStateSnapshot>': Vec<MessagingStateSnapshot>;
|
||||
@@ -1343,6 +1419,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<MetadataV10>': Vec<MetadataV10>;
|
||||
'Vec<MetadataV11>': Vec<MetadataV11>;
|
||||
'Vec<MetadataV12>': Vec<MetadataV12>;
|
||||
'Vec<MetadataV13>': Vec<MetadataV13>;
|
||||
'Vec<MetadataV9>': Vec<MetadataV9>;
|
||||
'Vec<MmrLeafProof>': Vec<MmrLeafProof>;
|
||||
'Vec<MmrRootHash>': Vec<MmrRootHash>;
|
||||
@@ -1350,12 +1427,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ModuleConstantMetadataV10>': Vec<ModuleConstantMetadataV10>;
|
||||
'Vec<ModuleConstantMetadataV11>': Vec<ModuleConstantMetadataV11>;
|
||||
'Vec<ModuleConstantMetadataV12>': Vec<ModuleConstantMetadataV12>;
|
||||
'Vec<ModuleConstantMetadataV13>': Vec<ModuleConstantMetadataV13>;
|
||||
'Vec<ModuleConstantMetadataV9>': Vec<ModuleConstantMetadataV9>;
|
||||
'Vec<ModuleId>': Vec<ModuleId>;
|
||||
'Vec<ModuleMetadataLatest>': Vec<ModuleMetadataLatest>;
|
||||
'Vec<ModuleMetadataV10>': Vec<ModuleMetadataV10>;
|
||||
'Vec<ModuleMetadataV11>': Vec<ModuleMetadataV11>;
|
||||
'Vec<ModuleMetadataV12>': Vec<ModuleMetadataV12>;
|
||||
'Vec<ModuleMetadataV13>': Vec<ModuleMetadataV13>;
|
||||
'Vec<ModuleMetadataV9>': Vec<ModuleMetadataV9>;
|
||||
'Vec<Moment>': Vec<Moment>;
|
||||
'Vec<MomentOf>': Vec<MomentOf>;
|
||||
@@ -1381,6 +1460,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<NextAuthority>': Vec<NextAuthority>;
|
||||
'Vec<NextConfigDescriptor>': Vec<NextConfigDescriptor>;
|
||||
'Vec<NextConfigDescriptorV1>': Vec<NextConfigDescriptorV1>;
|
||||
'Vec<NMapTypeLatest>': Vec<NMapTypeLatest>;
|
||||
'Vec<NMapTypeV13>': Vec<NMapTypeV13>;
|
||||
'Vec<NodeRole>': Vec<NodeRole>;
|
||||
'Vec<Nominations>': Vec<Nominations>;
|
||||
'Vec<NominatorIndex>': Vec<NominatorIndex>;
|
||||
@@ -1403,8 +1484,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<Origin>': Vec<Origin>;
|
||||
'Vec<OriginCaller>': Vec<OriginCaller>;
|
||||
'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>;
|
||||
@@ -1465,6 +1550,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ProxyDefinition>': Vec<ProxyDefinition>;
|
||||
'Vec<ProxyState>': Vec<ProxyState>;
|
||||
'Vec<ProxyType>': Vec<ProxyType>;
|
||||
'Vec<QueueConfigData>': Vec<QueueConfigData>;
|
||||
'Vec<QueuedParathread>': Vec<QueuedParathread>;
|
||||
'Vec<Randomness>': Vec<Randomness>;
|
||||
'Vec<Raw>': Vec<Raw>;
|
||||
@@ -1479,6 +1565,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>;
|
||||
@@ -1496,11 +1585,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<RegistrarInfo>': Vec<RegistrarInfo>;
|
||||
'Vec<Registration>': Vec<Registration>;
|
||||
'Vec<RegistrationJudgement>': Vec<RegistrationJudgement>;
|
||||
'Vec<RelayBlockNumber>': Vec<RelayBlockNumber>;
|
||||
'Vec<RelayChainBlockNumber>': Vec<RelayChainBlockNumber>;
|
||||
'Vec<RelayChainHash>': Vec<RelayChainHash>;
|
||||
'Vec<RelayHash>': Vec<RelayHash>;
|
||||
'Vec<Releases>': Vec<Releases>;
|
||||
'Vec<Remark>': Vec<Remark>;
|
||||
'Vec<Renouncing>': Vec<Renouncing>;
|
||||
'Vec<RentProjection>': Vec<RentProjection>;
|
||||
'Vec<ReportedRoundStates>': Vec<ReportedRoundStates>;
|
||||
'Vec<Reporter>': Vec<Reporter>;
|
||||
'Vec<ReportIdOf>': Vec<ReportIdOf>;
|
||||
@@ -1514,6 +1606,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>;
|
||||
@@ -1593,21 +1686,25 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<StorageEntryMetadataV10>': Vec<StorageEntryMetadataV10>;
|
||||
'Vec<StorageEntryMetadataV11>': Vec<StorageEntryMetadataV11>;
|
||||
'Vec<StorageEntryMetadataV12>': Vec<StorageEntryMetadataV12>;
|
||||
'Vec<StorageEntryMetadataV13>': Vec<StorageEntryMetadataV13>;
|
||||
'Vec<StorageEntryMetadataV9>': Vec<StorageEntryMetadataV9>;
|
||||
'Vec<StorageEntryModifierLatest>': Vec<StorageEntryModifierLatest>;
|
||||
'Vec<StorageEntryModifierV10>': Vec<StorageEntryModifierV10>;
|
||||
'Vec<StorageEntryModifierV11>': Vec<StorageEntryModifierV11>;
|
||||
'Vec<StorageEntryModifierV12>': Vec<StorageEntryModifierV12>;
|
||||
'Vec<StorageEntryModifierV13>': Vec<StorageEntryModifierV13>;
|
||||
'Vec<StorageEntryModifierV9>': Vec<StorageEntryModifierV9>;
|
||||
'Vec<StorageEntryTypeLatest>': Vec<StorageEntryTypeLatest>;
|
||||
'Vec<StorageEntryTypeV10>': Vec<StorageEntryTypeV10>;
|
||||
'Vec<StorageEntryTypeV11>': Vec<StorageEntryTypeV11>;
|
||||
'Vec<StorageEntryTypeV12>': Vec<StorageEntryTypeV12>;
|
||||
'Vec<StorageEntryTypeV13>': Vec<StorageEntryTypeV13>;
|
||||
'Vec<StorageEntryTypeV9>': Vec<StorageEntryTypeV9>;
|
||||
'Vec<StorageHasher>': Vec<StorageHasher>;
|
||||
'Vec<StorageHasherV10>': Vec<StorageHasherV10>;
|
||||
'Vec<StorageHasherV11>': Vec<StorageHasherV11>;
|
||||
'Vec<StorageHasherV12>': Vec<StorageHasherV12>;
|
||||
'Vec<StorageHasherV13>': Vec<StorageHasherV13>;
|
||||
'Vec<StorageHasherV9>': Vec<StorageHasherV9>;
|
||||
'Vec<StorageKey>': Vec<StorageKey>;
|
||||
'Vec<StorageKind>': Vec<StorageKind>;
|
||||
@@ -1615,6 +1712,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<StorageMetadataV10>': Vec<StorageMetadataV10>;
|
||||
'Vec<StorageMetadataV11>': Vec<StorageMetadataV11>;
|
||||
'Vec<StorageMetadataV12>': Vec<StorageMetadataV12>;
|
||||
'Vec<StorageMetadataV13>': Vec<StorageMetadataV13>;
|
||||
'Vec<StorageMetadataV9>': Vec<StorageMetadataV9>;
|
||||
'Vec<StorageProof>': Vec<StorageProof>;
|
||||
'Vec<StoredPendingChange>': Vec<StoredPendingChange>;
|
||||
@@ -1632,6 +1730,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<Timepoint>': Vec<Timepoint>;
|
||||
'Vec<TokenError>': Vec<TokenError>;
|
||||
'Vec<TombstoneContractInfo>': Vec<TombstoneContractInfo>;
|
||||
'Vec<TraceBlockResponse>': Vec<TraceBlockResponse>;
|
||||
'Vec<TraceError>': Vec<TraceError>;
|
||||
'Vec<TransactionPriority>': Vec<TransactionPriority>;
|
||||
'Vec<TransactionValidityError>': Vec<TransactionValidityError>;
|
||||
'Vec<TransientValidationData>': Vec<TransientValidationData>;
|
||||
@@ -1724,6 +1824,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<XcmOrderInitiateTeleport>': Vec<XcmOrderInitiateTeleport>;
|
||||
'Vec<XcmOrderQueryHolding>': Vec<XcmOrderQueryHolding>;
|
||||
'Vec<XcmOriginKind>': Vec<XcmOriginKind>;
|
||||
'Vec<XcmpMessageFormat>': Vec<XcmpMessageFormat>;
|
||||
'Vec<XcmQueryResponse>': Vec<XcmQueryResponse>;
|
||||
'Vec<XcmRelayedFrom>': Vec<XcmRelayedFrom>;
|
||||
'Vec<XcmReserveAssetDeposit>': Vec<XcmReserveAssetDeposit>;
|
||||
@@ -1766,6 +1867,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ApplyExtrinsicResult: ApplyExtrinsicResult;
|
||||
ApprovalFlag: ApprovalFlag;
|
||||
Approvals: Approvals;
|
||||
ArithmeticError: ArithmeticError;
|
||||
AssetApproval: AssetApproval;
|
||||
AssetApprovalKey: AssetApprovalKey;
|
||||
AssetBalance: AssetBalance;
|
||||
@@ -1813,6 +1915,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
BlockHash: BlockHash;
|
||||
BlockLength: BlockLength;
|
||||
BlockNumber: BlockNumber;
|
||||
BlockTrace: BlockTrace;
|
||||
BlockTraceEvent: BlockTraceEvent;
|
||||
BlockTraceEventData: BlockTraceEventData;
|
||||
BlockTraceSpan: BlockTraceSpan;
|
||||
BlockWeights: BlockWeights;
|
||||
BodyId: BodyId;
|
||||
BodyPart: BodyPart;
|
||||
@@ -1841,6 +1947,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ChainProperties: ChainProperties;
|
||||
ChainType: ChainType;
|
||||
ChangesTrieConfiguration: ChangesTrieConfiguration;
|
||||
ChangesTrieSignal: ChangesTrieSignal;
|
||||
CodecHash: CodecHash;
|
||||
CodeHash: CodeHash;
|
||||
CollatorId: CollatorId;
|
||||
@@ -1849,8 +1956,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;
|
||||
@@ -1872,6 +1983,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ContractExecResultTo255: ContractExecResultTo255;
|
||||
ContractExecResultTo260: ContractExecResultTo260;
|
||||
ContractInfo: ContractInfo;
|
||||
ContractInstantiateResult: ContractInstantiateResult;
|
||||
ContractLayoutArray: ContractLayoutArray;
|
||||
ContractLayoutCell: ContractLayoutCell;
|
||||
ContractLayoutEnum: ContractLayoutEnum;
|
||||
@@ -1921,6 +2033,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
DoubleMapTypeV10: DoubleMapTypeV10;
|
||||
DoubleMapTypeV11: DoubleMapTypeV11;
|
||||
DoubleMapTypeV12: DoubleMapTypeV12;
|
||||
DoubleMapTypeV13: DoubleMapTypeV13;
|
||||
DoubleMapTypeV9: DoubleMapTypeV9;
|
||||
DoubleVoteReport: DoubleVoteReport;
|
||||
DownwardMessage: DownwardMessage;
|
||||
@@ -1943,6 +2056,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ErrorMetadataV10: ErrorMetadataV10;
|
||||
ErrorMetadataV11: ErrorMetadataV11;
|
||||
ErrorMetadataV12: ErrorMetadataV12;
|
||||
ErrorMetadataV13: ErrorMetadataV13;
|
||||
ErrorMetadataV9: ErrorMetadataV9;
|
||||
EthAccount: EthAccount;
|
||||
EthBlock: EthBlock;
|
||||
@@ -1983,11 +2097,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
EventMetadataV10: EventMetadataV10;
|
||||
EventMetadataV11: EventMetadataV11;
|
||||
EventMetadataV12: EventMetadataV12;
|
||||
EventMetadataV13: EventMetadataV13;
|
||||
EventMetadataV9: EventMetadataV9;
|
||||
EventRecord: EventRecord;
|
||||
EvmAccount: EvmAccount;
|
||||
EvmLog: EvmLog;
|
||||
EvmVicinity: EvmVicinity;
|
||||
ExecReturnValue: ExecReturnValue;
|
||||
ExitError: ExitError;
|
||||
ExitFatal: ExitFatal;
|
||||
ExitReason: ExitReason;
|
||||
@@ -2001,6 +2117,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicMetadataLatest: ExtrinsicMetadataLatest;
|
||||
ExtrinsicMetadataV11: ExtrinsicMetadataV11;
|
||||
ExtrinsicMetadataV12: ExtrinsicMetadataV12;
|
||||
ExtrinsicMetadataV13: ExtrinsicMetadataV13;
|
||||
ExtrinsicOrHash: ExtrinsicOrHash;
|
||||
ExtrinsicPayload: ExtrinsicPayload;
|
||||
ExtrinsicPayloadUnknown: ExtrinsicPayloadUnknown;
|
||||
@@ -2024,11 +2141,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
FunctionArgumentMetadataV10: FunctionArgumentMetadataV10;
|
||||
FunctionArgumentMetadataV11: FunctionArgumentMetadataV11;
|
||||
FunctionArgumentMetadataV12: FunctionArgumentMetadataV12;
|
||||
FunctionArgumentMetadataV13: FunctionArgumentMetadataV13;
|
||||
FunctionArgumentMetadataV9: FunctionArgumentMetadataV9;
|
||||
FunctionMetadataLatest: FunctionMetadataLatest;
|
||||
FunctionMetadataV10: FunctionMetadataV10;
|
||||
FunctionMetadataV11: FunctionMetadataV11;
|
||||
FunctionMetadataV12: FunctionMetadataV12;
|
||||
FunctionMetadataV13: FunctionMetadataV13;
|
||||
FunctionMetadataV9: FunctionMetadataV9;
|
||||
FundIndex: FundIndex;
|
||||
FundInfo: FundInfo;
|
||||
@@ -2052,6 +2171,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
Hash: Hash;
|
||||
HeadData: HeadData;
|
||||
Header: Header;
|
||||
HeaderPartial: HeaderPartial;
|
||||
Health: Health;
|
||||
Heartbeat: Heartbeat;
|
||||
HeartbeatTo244: HeartbeatTo244;
|
||||
@@ -2084,6 +2204,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
InboundDownwardMessage: InboundDownwardMessage;
|
||||
InboundHrmpMessage: InboundHrmpMessage;
|
||||
InboundHrmpMessages: InboundHrmpMessages;
|
||||
InboundStatus: InboundStatus;
|
||||
IncludedBlocks: IncludedBlocks;
|
||||
InclusionFee: InclusionFee;
|
||||
IncomingParachain: IncomingParachain;
|
||||
@@ -2092,6 +2213,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
Index: Index;
|
||||
IndicesLookupSource: IndicesLookupSource;
|
||||
IndividualExposure: IndividualExposure;
|
||||
InstantiateRequest: InstantiateRequest;
|
||||
InstantiateReturnValue: InstantiateReturnValue;
|
||||
InstructionWeights: InstructionWeights;
|
||||
InvalidDisputeStatementKind: InvalidDisputeStatementKind;
|
||||
InvalidTransaction: InvalidTransaction;
|
||||
@@ -2123,11 +2246,13 @@ declare module '@polkadot/types/types/registry' {
|
||||
MapTypeV10: MapTypeV10;
|
||||
MapTypeV11: MapTypeV11;
|
||||
MapTypeV12: MapTypeV12;
|
||||
MapTypeV13: MapTypeV13;
|
||||
MapTypeV9: MapTypeV9;
|
||||
MaybeRandomness: MaybeRandomness;
|
||||
MaybeVrf: MaybeVrf;
|
||||
MemberCount: MemberCount;
|
||||
MembershipProof: MembershipProof;
|
||||
MessageId: MessageId;
|
||||
MessageIngestionType: MessageIngestionType;
|
||||
MessageQueueChain: MessageQueueChain;
|
||||
MessagingStateSnapshot: MessagingStateSnapshot;
|
||||
@@ -2137,6 +2262,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
MetadataV10: MetadataV10;
|
||||
MetadataV11: MetadataV11;
|
||||
MetadataV12: MetadataV12;
|
||||
MetadataV13: MetadataV13;
|
||||
MetadataV9: MetadataV9;
|
||||
MmrLeafProof: MmrLeafProof;
|
||||
MmrRootHash: MmrRootHash;
|
||||
@@ -2144,12 +2270,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
ModuleConstantMetadataV10: ModuleConstantMetadataV10;
|
||||
ModuleConstantMetadataV11: ModuleConstantMetadataV11;
|
||||
ModuleConstantMetadataV12: ModuleConstantMetadataV12;
|
||||
ModuleConstantMetadataV13: ModuleConstantMetadataV13;
|
||||
ModuleConstantMetadataV9: ModuleConstantMetadataV9;
|
||||
ModuleId: ModuleId;
|
||||
ModuleMetadataLatest: ModuleMetadataLatest;
|
||||
ModuleMetadataV10: ModuleMetadataV10;
|
||||
ModuleMetadataV11: ModuleMetadataV11;
|
||||
ModuleMetadataV12: ModuleMetadataV12;
|
||||
ModuleMetadataV13: ModuleMetadataV13;
|
||||
ModuleMetadataV9: ModuleMetadataV9;
|
||||
Moment: Moment;
|
||||
MomentOf: MomentOf;
|
||||
@@ -2175,6 +2303,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
NextAuthority: NextAuthority;
|
||||
NextConfigDescriptor: NextConfigDescriptor;
|
||||
NextConfigDescriptorV1: NextConfigDescriptorV1;
|
||||
NMapTypeLatest: NMapTypeLatest;
|
||||
NMapTypeV13: NMapTypeV13;
|
||||
NodeRole: NodeRole;
|
||||
Nominations: Nominations;
|
||||
NominatorIndex: NominatorIndex;
|
||||
@@ -2197,8 +2327,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
Origin: Origin;
|
||||
OriginCaller: OriginCaller;
|
||||
OutboundHrmpMessage: OutboundHrmpMessage;
|
||||
OutboundStatus: OutboundStatus;
|
||||
Outcome: Outcome;
|
||||
OverweightIndex: OverweightIndex;
|
||||
Owner: Owner;
|
||||
PageCounter: PageCounter;
|
||||
PageIndexData: PageIndexData;
|
||||
PalletId: PalletId;
|
||||
PalletsOrigin: PalletsOrigin;
|
||||
PalletVersion: PalletVersion;
|
||||
@@ -2259,6 +2393,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ProxyDefinition: ProxyDefinition;
|
||||
ProxyState: ProxyState;
|
||||
ProxyType: ProxyType;
|
||||
QueueConfigData: QueueConfigData;
|
||||
QueuedParathread: QueuedParathread;
|
||||
Randomness: Randomness;
|
||||
Raw: Raw;
|
||||
@@ -2273,6 +2408,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;
|
||||
@@ -2290,11 +2428,14 @@ declare module '@polkadot/types/types/registry' {
|
||||
RegistrarInfo: RegistrarInfo;
|
||||
Registration: Registration;
|
||||
RegistrationJudgement: RegistrationJudgement;
|
||||
RelayBlockNumber: RelayBlockNumber;
|
||||
RelayChainBlockNumber: RelayChainBlockNumber;
|
||||
RelayChainHash: RelayChainHash;
|
||||
RelayHash: RelayHash;
|
||||
Releases: Releases;
|
||||
Remark: Remark;
|
||||
Renouncing: Renouncing;
|
||||
RentProjection: RentProjection;
|
||||
ReportedRoundStates: ReportedRoundStates;
|
||||
Reporter: Reporter;
|
||||
ReportIdOf: ReportIdOf;
|
||||
@@ -2308,6 +2449,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
RuntimeDispatchInfo: RuntimeDispatchInfo;
|
||||
RuntimeVersion: RuntimeVersion;
|
||||
RuntimeVersionApi: RuntimeVersionApi;
|
||||
RuntimeVersionPartial: RuntimeVersionPartial;
|
||||
Schedule: Schedule;
|
||||
Scheduled: Scheduled;
|
||||
ScheduledTo254: ScheduledTo254;
|
||||
@@ -2387,21 +2529,25 @@ declare module '@polkadot/types/types/registry' {
|
||||
StorageEntryMetadataV10: StorageEntryMetadataV10;
|
||||
StorageEntryMetadataV11: StorageEntryMetadataV11;
|
||||
StorageEntryMetadataV12: StorageEntryMetadataV12;
|
||||
StorageEntryMetadataV13: StorageEntryMetadataV13;
|
||||
StorageEntryMetadataV9: StorageEntryMetadataV9;
|
||||
StorageEntryModifierLatest: StorageEntryModifierLatest;
|
||||
StorageEntryModifierV10: StorageEntryModifierV10;
|
||||
StorageEntryModifierV11: StorageEntryModifierV11;
|
||||
StorageEntryModifierV12: StorageEntryModifierV12;
|
||||
StorageEntryModifierV13: StorageEntryModifierV13;
|
||||
StorageEntryModifierV9: StorageEntryModifierV9;
|
||||
StorageEntryTypeLatest: StorageEntryTypeLatest;
|
||||
StorageEntryTypeV10: StorageEntryTypeV10;
|
||||
StorageEntryTypeV11: StorageEntryTypeV11;
|
||||
StorageEntryTypeV12: StorageEntryTypeV12;
|
||||
StorageEntryTypeV13: StorageEntryTypeV13;
|
||||
StorageEntryTypeV9: StorageEntryTypeV9;
|
||||
StorageHasher: StorageHasher;
|
||||
StorageHasherV10: StorageHasherV10;
|
||||
StorageHasherV11: StorageHasherV11;
|
||||
StorageHasherV12: StorageHasherV12;
|
||||
StorageHasherV13: StorageHasherV13;
|
||||
StorageHasherV9: StorageHasherV9;
|
||||
StorageKey: StorageKey;
|
||||
StorageKind: StorageKind;
|
||||
@@ -2409,6 +2555,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
StorageMetadataV10: StorageMetadataV10;
|
||||
StorageMetadataV11: StorageMetadataV11;
|
||||
StorageMetadataV12: StorageMetadataV12;
|
||||
StorageMetadataV13: StorageMetadataV13;
|
||||
StorageMetadataV9: StorageMetadataV9;
|
||||
StorageProof: StorageProof;
|
||||
StoredPendingChange: StoredPendingChange;
|
||||
@@ -2426,6 +2573,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
Timepoint: Timepoint;
|
||||
TokenError: TokenError;
|
||||
TombstoneContractInfo: TombstoneContractInfo;
|
||||
TraceBlockResponse: TraceBlockResponse;
|
||||
TraceError: TraceError;
|
||||
TransactionPriority: TransactionPriority;
|
||||
TransactionValidityError: TransactionValidityError;
|
||||
TransientValidationData: TransientValidationData;
|
||||
@@ -2518,6 +2667,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
XcmOrderInitiateTeleport: XcmOrderInitiateTeleport;
|
||||
XcmOrderQueryHolding: XcmOrderQueryHolding;
|
||||
XcmOriginKind: XcmOriginKind;
|
||||
XcmpMessageFormat: XcmpMessageFormat;
|
||||
XcmQueryResponse: XcmQueryResponse;
|
||||
XcmRelayedFrom: XcmRelayedFrom;
|
||||
XcmReserveAssetDeposit: XcmReserveAssetDeposit;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { Codec } from '../types';
|
||||
|
||||
export interface CompactEncodable extends Codec {
|
||||
bitLength (): number;
|
||||
toBigInt (): bigint;
|
||||
toBn (): BN;
|
||||
toNumber (): number;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ function getSubType (value: TypeDef): keyof InterfaceTypes {
|
||||
function getTypeClassMap (value: TypeDef): Record<string, keyof InterfaceTypes> {
|
||||
const result: Record<string, keyof InterfaceTypes> = {};
|
||||
|
||||
return getSubDefArray(value).reduce((result, sub): Record<string, keyof InterfaceTypes> => {
|
||||
return getSubDefArray(value).reduce<Record<string, keyof InterfaceTypes>>((result, sub) => {
|
||||
result[sub.name as string] = sub.type as keyof InterfaceTypes;
|
||||
|
||||
return result;
|
||||
@@ -61,9 +61,7 @@ function getTypeClassMap (value: TypeDef): Record<string, keyof InterfaceTypes>
|
||||
|
||||
// create an array of type string constructors from the input
|
||||
function getTypeClassArray (value: TypeDef): (keyof InterfaceTypes)[] {
|
||||
return getSubDefArray(value).map(({ type }): keyof InterfaceTypes =>
|
||||
type as keyof InterfaceTypes
|
||||
);
|
||||
return getSubDefArray(value).map(({ type }) => type as keyof InterfaceTypes);
|
||||
}
|
||||
|
||||
function createInt ({ displayName, length }: TypeDef, Clazz: typeof Int | typeof UInt): Constructor {
|
||||
@@ -92,7 +90,7 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
|
||||
return Enum.with(
|
||||
subs.every(({ type }) => type === 'Null')
|
||||
? subs.reduce((out: Record<string, number>, { index, name }, count): Record<string, number> => {
|
||||
? subs.reduce<Record<string, number>>((out, { index, name }, count) => {
|
||||
out[name as string] = index || count;
|
||||
|
||||
return out;
|
||||
@@ -139,7 +137,7 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
const result: Record<string, number> = {};
|
||||
|
||||
return CodecSet.with(
|
||||
getSubDefArray(value).reduce((result, { index, name }): Record<string, number> => {
|
||||
getSubDefArray(value).reduce<Record<string, number>>((result, { index, name }) => {
|
||||
result[name as string] = index as number;
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,76 +1,63 @@
|
||||
// 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';
|
||||
|
||||
import { logger } from '@polkadot/util';
|
||||
import { assert, isHex, isU8a, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { createClass } from './createClass';
|
||||
|
||||
interface CreateOptions {
|
||||
blockHash?: Uint8Array | string | null;
|
||||
isPedantic?: boolean;
|
||||
withoutLog?: boolean;
|
||||
}
|
||||
|
||||
const l = logger('registry');
|
||||
|
||||
// TODO: Fix and re-enable
|
||||
// With isPedantic, actually check that the encoding matches that supplied. This
|
||||
// is much slower, but verifies that we have the correct types defined
|
||||
// function checkInstance<T extends Codec = Codec, K extends string = string> (value: Uint8Array, created: FromReg<T, K>): void {
|
||||
// // the underlying type created.toRawType()
|
||||
// const rawType = created.toRawType();
|
||||
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();
|
||||
|
||||
// // ignore bytes completely - this is probably a FIXME, since these are somewhat
|
||||
// // breaking for at least online queries - not quite sure wtf is going wrong here
|
||||
// if (rawType === 'Bytes') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // the hex values for what we have
|
||||
// const inHex = u8aToHex(value);
|
||||
// const crHex = created.toHex();
|
||||
|
||||
// // Check equality, based on some different approaches (as decoded)
|
||||
// const isEqual = inHex === crHex || // raw hex values, quick path
|
||||
// inHex === created.toHex(true) || // wrapped options
|
||||
// u8aToHex(value.reverse()) === crHex; // reverse (for numbers, which are BE)
|
||||
|
||||
// // if the hex doesn't match and the value for both is non-empty, complain... bitterly
|
||||
// if (!isEqual && (u8aHasValue(value) || u8aHasValue(created.toU8a(true)))) {
|
||||
// l.warn(`${rawType}:: Input doesn't match output, received ${u8aToHex(value)}, created ${crHex}`);
|
||||
// }
|
||||
// }
|
||||
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
|
||||
// where isPedantic is specified (storage decoding), also check the format/structure
|
||||
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: any[] = [], { blockHash }: CreateOptions = {}): FromReg<T, K> {
|
||||
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: unknown[] = [], { blockHash, isPedantic }: CreateOptions = {}): FromReg<T, K> {
|
||||
const created = new Type(registry, ...params);
|
||||
const value = params[0];
|
||||
|
||||
if (isPedantic) {
|
||||
if (isU8a(value)) {
|
||||
checkInstance(value, created);
|
||||
} else if (isHex(value)) {
|
||||
checkInstance(u8aToU8a(value.toString()), created);
|
||||
}
|
||||
}
|
||||
|
||||
if (blockHash) {
|
||||
created.createdAtHash = createType(registry, 'Hash', blockHash);
|
||||
}
|
||||
|
||||
// if (isPedantic && isU8a(value)) {
|
||||
// checkInstance(value, created);
|
||||
// }
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
!options.withoutLog && l.error(error);
|
||||
|
||||
throw new Error(`createType(${type}):: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
@@ -81,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);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ function encodeSubTypes (sub: TypeDef[], asEnum?: boolean): string {
|
||||
|
||||
assert(names.every((n) => !!n), () => `Subtypes does not have consistent names, ${names.join(', ')}`);
|
||||
|
||||
const inner = sub.reduce((result: Record<string, string>, type): Record<string, string> => ({
|
||||
const inner = sub.reduce< Record<string, string>>((result, type) => ({
|
||||
...result,
|
||||
[type.name as string]: encodeTypeDef(type)
|
||||
}), {});
|
||||
|
||||
@@ -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>>>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
@@ -77,14 +78,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 +97,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 {
|
||||
@@ -209,7 +216,7 @@ export function removeWrap (check: string): Mapper {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function sanitize (value: String | string, options?: SanitizeOptions): string {
|
||||
return mappings.reduce((result, fn): string =>
|
||||
return mappings.reduce<string>((result, fn) =>
|
||||
fn(result, options), value.toString()
|
||||
).trim();
|
||||
}
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { hexToBn } from '@polkadot/util';
|
||||
|
||||
import { CID_AURA, CID_BABE, CID_GRPA, GenericConsensusEngineId as ConsensusEngineId } from './ConsensusEngineId';
|
||||
import { TypeRegistry } from '../create';
|
||||
import { CID_AURA, GenericConsensusEngineId as ConsensusEngineId } from './ConsensusEngineId';
|
||||
|
||||
describe('ConsensusEngineId', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('creates a valid id for aura', (): void => {
|
||||
expect(ConsensusEngineId.stringToId('FRNK')).toEqual(CID_GRPA);
|
||||
expect(ConsensusEngineId.stringToId('aura')).toEqual(CID_AURA);
|
||||
expect(new ConsensusEngineId(registry, 'aura').toU8a()).toEqual(CID_AURA);
|
||||
});
|
||||
|
||||
it('reverses an id to string for babe', (): void => {
|
||||
expect(ConsensusEngineId.idToString(CID_BABE)).toEqual('BABE');
|
||||
});
|
||||
|
||||
it('reverses a non-ASCII id to a hex string', (): void => {
|
||||
expect(ConsensusEngineId.idToString(hexToBn('0x01020304', { isLe: true }))).toEqual('0x01020304');
|
||||
expect(ConsensusEngineId.idToString(0x04030201)).toEqual('0x01020304');
|
||||
expect(new ConsensusEngineId(registry, 'BABE').toString()).toEqual('BABE');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,40 +2,35 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId } from '../interfaces/runtime';
|
||||
import type { AnyU8a, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { bnToU8a, isAscii, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
import { bnToU8a, isNumber, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
|
||||
import { U8aFixed } from '../codec/U8aFixed';
|
||||
import { Bytes } from '../primitive/Bytes';
|
||||
import { u32 } from '../primitive/U32';
|
||||
|
||||
// there are all reversed since it is actually encoded as u32, LE,
|
||||
// this means that FRNK has the bytes as KNRF
|
||||
export const CID_AURA = 0x61727561; // 'aura'
|
||||
export const CID_BABE = 0x45424142; // 'BABE'
|
||||
export const CID_GRPA = 0x4b4e5246; // 'FRNK' (don't ask, used to be afg1)
|
||||
export const CID_POW = 0x5f776f70; // 'pow_'
|
||||
export const CID_AURA = stringToU8a('aura');
|
||||
export const CID_BABE = stringToU8a('BABE');
|
||||
export const CID_GRPA = stringToU8a('FRNK');
|
||||
export const CID_POW = stringToU8a('pow_');
|
||||
|
||||
/**
|
||||
* @name GenericConsensusEngineId
|
||||
* @description
|
||||
* A 4-byte identifier (actually a [u8; 4]) identifying the engine, e.g. for Aura it would be [b'a', b'u', b'r', b'a']
|
||||
* A 4-byte identifier identifying the engine
|
||||
*/
|
||||
export class GenericConsensusEngineId extends u32 {
|
||||
public static idToString (input: number | BN): string {
|
||||
const u8a = bnToU8a(input);
|
||||
|
||||
return isAscii(u8a)
|
||||
? u8aToString(u8a)
|
||||
: u8aToHex(u8a);
|
||||
}
|
||||
|
||||
public static stringToId (input: string): number {
|
||||
return input
|
||||
.split('')
|
||||
.reverse()
|
||||
.reduce((result, char): number => (result * 256) + char.charCodeAt(0), 0);
|
||||
export class GenericConsensusEngineId extends U8aFixed {
|
||||
constructor (registry: Registry, value?: AnyU8a) {
|
||||
super(
|
||||
registry,
|
||||
isNumber(value)
|
||||
? bnToU8a(value, { isLe: false })
|
||||
: value,
|
||||
32
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,11 +78,7 @@ export class GenericConsensusEngineId extends u32 {
|
||||
];
|
||||
}
|
||||
|
||||
private _getPowAuthor (bytes: Bytes): AccountId {
|
||||
return this.registry.createType('AccountId', bytes);
|
||||
}
|
||||
|
||||
private _getH160Author (bytes: Bytes): AccountId {
|
||||
private _getBytesAsAuthor (bytes: Bytes): AccountId {
|
||||
return this.registry.createType('AccountId', bytes);
|
||||
}
|
||||
|
||||
@@ -103,22 +94,34 @@ export class GenericConsensusEngineId extends u32 {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isPow) {
|
||||
return this._getPowAuthor(bytes);
|
||||
}
|
||||
|
||||
// Moonbeam is neither Aura nor Babe nor Pow and uses h160 addresses
|
||||
if (bytes.length === 20) {
|
||||
return this._getH160Author(bytes);
|
||||
// For pow & Moonbeam, the bytes are the actual author
|
||||
if (this.isPow || bytes.length === 20) {
|
||||
return this._getBytesAsAuthor(bytes);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): string {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'ConsensusEngineId';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Override the default toString to return a 4-byte string
|
||||
*/
|
||||
public toString (): string {
|
||||
return GenericConsensusEngineId.idToString(this as BN);
|
||||
return this.isAscii
|
||||
? u8aToString(this)
|
||||
: u8aToHex(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export default {
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'BlockHash',
|
||||
isCached: true,
|
||||
isHistoric: true,
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
|
||||
@@ -24,6 +24,22 @@ export default {
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
},
|
||||
instantiate: {
|
||||
description: 'Instantiate a new contract',
|
||||
params: [
|
||||
{
|
||||
name: 'request',
|
||||
type: 'InstantiateRequest'
|
||||
},
|
||||
{
|
||||
name: 'at',
|
||||
type: 'BlockHash',
|
||||
isHstoric: true,
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'ContractInstantiateResult'
|
||||
},
|
||||
getStorage: {
|
||||
description: 'Returns the value under a specified storage key in a contract',
|
||||
params: [
|
||||
@@ -65,10 +81,10 @@ export default {
|
||||
AliveContractInfo: {
|
||||
trieId: 'TrieId',
|
||||
storageSize: 'u32',
|
||||
emptyPairCount: 'u32',
|
||||
totalPairCount: 'u32',
|
||||
pairCount: 'u32',
|
||||
codeHash: 'CodeHash',
|
||||
rentAllowance: 'Balance',
|
||||
rentPaid: 'Balance',
|
||||
deductBlock: 'BlockNumber',
|
||||
lastWrite: 'Option<BlockNumber>',
|
||||
_reserved: 'Option<Null>'
|
||||
@@ -141,6 +157,10 @@ export default {
|
||||
pairCount: 'u32',
|
||||
trieId: 'TrieId'
|
||||
},
|
||||
ExecReturnValue: {
|
||||
flags: 'u32',
|
||||
data: 'Bytes'
|
||||
},
|
||||
Gas: 'u64',
|
||||
HostFnWeightsTo264: {
|
||||
caller: 'Weight',
|
||||
@@ -243,6 +263,25 @@ export default {
|
||||
hashBlake2128PerByte: 'Weight',
|
||||
rentParams: 'Weight'
|
||||
},
|
||||
InstantiateRequest: {
|
||||
origin: 'AccountId',
|
||||
endowment: 'Balance',
|
||||
gasLimit: 'Gas',
|
||||
code: 'Bytes',
|
||||
data: 'Bytes',
|
||||
salt: 'Bytes'
|
||||
},
|
||||
ContractInstantiateResult: {
|
||||
_enum: {
|
||||
Ok: 'InstantiateReturnValue',
|
||||
Err: 'Null'
|
||||
}
|
||||
},
|
||||
InstantiateReturnValue: {
|
||||
result: 'ExecReturnValue',
|
||||
accountId: 'AccountId',
|
||||
rentProjection: 'Option<RentProjection>'
|
||||
},
|
||||
InstructionWeights: {
|
||||
i64const: 'u32',
|
||||
i64load: 'u32',
|
||||
@@ -326,6 +365,12 @@ export default {
|
||||
code: 'Bytes',
|
||||
originalCodeLen: 'u32'
|
||||
},
|
||||
RentProjection: {
|
||||
_enum: {
|
||||
EvictionAt: 'BlockNumber',
|
||||
NoEviction: 'Null'
|
||||
}
|
||||
},
|
||||
ScheduleTo212: {
|
||||
version: 'u32',
|
||||
putCodePerByteCost: 'Gas',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user