Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1a1be49c5 | ||
|
|
4b6ad647a2 | ||
|
|
04f656cafa | ||
|
|
09bbd5f6c9 | ||
|
|
dbc3df6d09 | ||
|
|
26865f92e3 | ||
|
|
73045de73d | ||
|
|
6d3491b9f1 | ||
|
|
886f3a3c08 | ||
|
|
c72f976895 | ||
|
|
ab8b381d8b | ||
|
|
443e29a3be | ||
|
|
117bb5717a | ||
|
|
5fb76baa16 | ||
|
|
274b3498d4 | ||
|
|
fa9e1c53e1 | ||
|
|
3ebf7eb424 | ||
|
|
7d11e6f9a5 | ||
|
|
a0d6384b01 | ||
|
|
47afe2cfc6 | ||
|
|
c37a2fc756 | ||
|
|
e2545276bb | ||
|
|
4219409ef8 | ||
|
|
c9e64d2a32 | ||
|
|
41db3b2e35 | ||
|
|
ebe15dada6 | ||
|
|
c2cb5dc574 | ||
|
|
ba451348c0 | ||
|
|
ec76b11666 | ||
|
|
7603f9e6c1 | ||
|
|
b50eab11c0 | ||
|
|
66d05c1771 | ||
|
|
fd7c3d7e10 | ||
|
|
28d4c7d808 | ||
|
|
43d36fbcf6 | ||
|
|
e54eef2369 | ||
|
|
296842858f | ||
|
|
ba8849a3e9 | ||
|
|
e333c3d8d9 | ||
|
|
0fe6a21624 | ||
|
|
0abedb81c6 | ||
|
|
08eda72d4b | ||
|
|
70d4126c84 | ||
|
|
dcccab705c | ||
|
|
e45ff6d026 | ||
|
|
b49c2314e7 | ||
|
|
0ac085756a | ||
|
|
542a690c89 | ||
|
|
ff23ead797 | ||
|
|
ae55e4fbf7 | ||
|
|
b17412163d | ||
|
|
46dcbf9a42 | ||
|
|
193dfcc32f | ||
|
|
a81011cf94 | ||
|
|
d43a8b2e11 | ||
|
|
dff859ba68 | ||
|
|
5169b6ee69 | ||
|
|
f4405667fe | ||
|
|
49ff636305 | ||
|
|
d77d686c76 | ||
|
|
502c6a3451 | ||
|
|
b58c77683d |
+4
-3
@@ -1,4 +1,4 @@
|
||||
25
|
||||
26
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
@@ -8,11 +8,12 @@
|
||||
2.8.2
|
||||
3.2.2
|
||||
3.2.3
|
||||
|
||||
3.3.2
|
||||
3.6.2
|
||||
3.6.3
|
||||
3.6.4
|
||||
3.7.2
|
||||
3.7.3
|
||||
3.9.2
|
||||
3.9.2
|
||||
3.9.3
|
||||
3.10.2
|
||||
|
||||
@@ -24,8 +24,6 @@ module.exports = {
|
||||
...base.rules,
|
||||
// add override for any (a metric ton of them, initial conversion)
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
// these should be removed, there are 8 of them as errors
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
// this seems very broken atm, false positives
|
||||
'@typescript-eslint/unbound-method': 'off'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,59 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 3.11.1 Feb 28, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Clean Websocket states on disconnects (Thanks to https://github.com/ianhe8x)
|
||||
- Support for C-like indexed enums (Thanks to https://github.com/xlc)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust council derives to cater for current-generation candidate mapping
|
||||
- Allow for override of codec hasher (& output type)
|
||||
- Adjust submittables to submit hex-encoded addresses to queries
|
||||
- Adjust initialization to always retrieve tx version from Metadata only
|
||||
- Update election types as per latest Substrate
|
||||
- Add types for the new gilt module
|
||||
- Upgrade to the latest Substrate metadata
|
||||
- Adjust package detection to check for local monorepo dependencies
|
||||
- Ensure that metadata `.toJSON()` does apply type aliasses
|
||||
|
||||
|
||||
## 3.10.2 Feb 23, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for users of chains where `MultiAddress` is in-use and blocks are decoded.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix decoding for `MultiAddress` enum where non-`AccountId` variable-lengths are provided as part of a stream
|
||||
- Added known Polkadot 28 upgrade block
|
||||
- Update for latest Substrate contracts `Schedule` types
|
||||
|
||||
|
||||
## 3.10.1 Feb 22, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust ConsumedWeight types to align with Rust module code
|
||||
- Check for connection status in subscription unsubscribe
|
||||
- Adjust staking reward derives ordering for better performance
|
||||
- Adapt detection imports to remove `.json` dependencies (Better behavior using Node.js with ESM)
|
||||
|
||||
|
||||
## 3.9.3 Feb 16, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the updated parachain types.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjusted parachain `PersistedValidationData` structure
|
||||
|
||||
|
||||
## 3.9.2 Feb 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain builders since it contains the latest parachain types.
|
||||
|
||||
+6
-6
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -25,14 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.13",
|
||||
"@babel/register": "^7.12.13",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/dev": "^0.61.25",
|
||||
"@babel/core": "^7.13.8",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/dev": "^0.61.30",
|
||||
"@polkadot/ts": "^0.3.59",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.20",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "3.9.2"
|
||||
"version": "3.11.1"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,11 +15,11 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/api": "3.11.1",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/x-rxjs": "^5.9.2",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, typesInfo]);
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { Abi } from './Abi';
|
||||
import './detectPackage';
|
||||
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
export { Abi } from './Abi';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '3.11.1' };
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,17 +15,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/rpc-core": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/api": "3.11.1",
|
||||
"@polkadot/rpc-core": "3.11.1",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/util-crypto": "^5.9.2",
|
||||
"@polkadot/x-rxjs": "^5.9.2",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/rpc-provider": "3.9.2"
|
||||
"@polkadot/keyring": "^5.9.2",
|
||||
"@polkadot/rpc-provider": "3.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('bounties derive', () => {
|
||||
let storageKey: (index: number) => StorageKey;
|
||||
let defaultBounty: () => Bounty;
|
||||
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T)=> Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T) => Option<T>;
|
||||
let bountyIndex: (index: number) => BountyIndex;
|
||||
let proposalIndex: (index: number) => ProposalIndex;
|
||||
let bytes: (value: string) => Bytes;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, coreInfo, typesInfo]);
|
||||
@@ -15,16 +15,28 @@ import { memo } from '../util';
|
||||
// SeatHolder is current tuple is 2.x-era Substrate
|
||||
type Member = SeatHolder | ITuple<[AccountId, Balance]>;
|
||||
|
||||
type Candidate = AccountId | ITuple<[AccountId, Balance]>;
|
||||
|
||||
function isSeatHolder (value: Member): value is SeatHolder {
|
||||
return !Array.isArray(value);
|
||||
}
|
||||
|
||||
function isCandidateTuple (value: Candidate): value is ITuple<[AccountId, Balance]> {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
||||
function getAccountTuple (value: Member): [AccountId, Balance] {
|
||||
return isSeatHolder(value)
|
||||
? [value.who, value.stake]
|
||||
: value;
|
||||
}
|
||||
|
||||
function getCandidate (value: Candidate): AccountId {
|
||||
return isCandidateTuple(value)
|
||||
? value[0]
|
||||
: value;
|
||||
}
|
||||
|
||||
function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [AccountId, Balance]): number {
|
||||
return balanceB.cmp(balanceA);
|
||||
}
|
||||
@@ -32,7 +44,7 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<Member>, Vec<Member>]>([
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query.council.members,
|
||||
api.query[section].candidates,
|
||||
api.query[section].members,
|
||||
@@ -41,7 +53,7 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates,
|
||||
candidates: candidates.map(getCandidate),
|
||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AnyFunction } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
@@ -22,6 +24,7 @@ import * as technicalCommittee from './technicalCommittee';
|
||||
import * as treasury from './treasury';
|
||||
import * as tx from './tx';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export * from './type';
|
||||
|
||||
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '3.11.1' };
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { StorageKey } from '@polkadot/types';
|
||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
|
||||
type KeysAndExposures = [StorageKey, Exposure][];
|
||||
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, Exposure][];
|
||||
|
||||
const CACHE_KEY = 'eraExposure';
|
||||
|
||||
|
||||
@@ -1,55 +1,37 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveOwnExposure } from '../types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
const CACHE_KEY = 'ownExposure';
|
||||
|
||||
export function _ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveOwnExposure> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveOwnExposure> => {
|
||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
||||
const cached = withActive
|
||||
? undefined
|
||||
: deriveCache.get<DeriveOwnExposure>(cacheKey);
|
||||
|
||||
return cached
|
||||
? of(cached)
|
||||
: api.queryMulti<[Exposure, Exposure]>([
|
||||
[api.query.staking.erasStakersClipped, [era, accountId]],
|
||||
[api.query.staking.erasStakers, [era, accountId]]
|
||||
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
||||
eras.length
|
||||
? api.queryMulti<Exposure[]>([
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakersClipped, [era, accountId]]),
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakers, [era, accountId]])
|
||||
]).pipe(
|
||||
map(([clipped, exposure]): DeriveOwnExposure => {
|
||||
const value = { clipped, era, exposure };
|
||||
|
||||
!withActive && deriveCache.set(cacheKey, value);
|
||||
|
||||
return value;
|
||||
})
|
||||
);
|
||||
});
|
||||
map((all): DeriveOwnExposure[] =>
|
||||
eras.map((era, index) => ({ clipped: all[index], era, exposure: all[eras.length + index] }))
|
||||
)
|
||||
)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
export function ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveOwnExposure> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveOwnExposure> =>
|
||||
api.derive.staking._ownExposure(accountId, era, true)
|
||||
);
|
||||
}
|
||||
|
||||
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
||||
eras.length
|
||||
? combineLatest(
|
||||
eras.map((era) => api.derive.staking._ownExposure(accountId, era, withActive))
|
||||
)
|
||||
: of([])
|
||||
api.derive.staking._ownExposures(accountId, [era], true).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +1,44 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveStakerSlashes } from '../types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { deriveCache, memo } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
const CACHE_KEY = 'ownSlash';
|
||||
|
||||
export function _ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveStakerSlashes> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveStakerSlashes> => {
|
||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
||||
const cached = withActive
|
||||
? undefined
|
||||
: deriveCache.get<DeriveStakerSlashes>(cacheKey);
|
||||
|
||||
return cached
|
||||
? of(cached)
|
||||
: api.queryMulti<[Option<BalanceOf>, Option<ITuple<[Perbill, BalanceOf]>>]>([
|
||||
[api.query.staking.nominatorSlashInEra, [era, accountId]],
|
||||
[api.query.staking.validatorSlashInEra, [era, accountId]]
|
||||
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
||||
eras.length
|
||||
? api.queryMulti<(Option<ITuple<[Perbill, BalanceOf]>> | Option<BalanceOf>)[]>([
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.validatorSlashInEra, [era, accountId]]),
|
||||
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.nominatorSlashInEra, [era, accountId]])
|
||||
]).pipe(
|
||||
map(([optNom, optVal]): DeriveStakerSlashes => {
|
||||
const value = {
|
||||
map((values): DeriveStakerSlashes[] =>
|
||||
eras.map((era, index) => ({
|
||||
era,
|
||||
total: optVal.isSome
|
||||
? optVal.unwrap()[1]
|
||||
: optNom.unwrapOrDefault()
|
||||
};
|
||||
|
||||
!withActive && deriveCache.set(cacheKey, value);
|
||||
|
||||
return value;
|
||||
})
|
||||
);
|
||||
});
|
||||
total: values[index].isSome
|
||||
? (values[index].unwrap() as ITuple<[Perbill, BalanceOf]>)[1]
|
||||
: (values[index + eras.length].unwrapOrDefault() as BalanceOf)
|
||||
}))
|
||||
)
|
||||
)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
export function ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveStakerSlashes> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveStakerSlashes> =>
|
||||
api.derive.staking._ownSlash(accountId, era, true)
|
||||
);
|
||||
}
|
||||
|
||||
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
||||
eras.length
|
||||
? combineLatest(
|
||||
eras.map((era) => api.derive.staking._ownSlash(accountId, era, withActive))
|
||||
)
|
||||
: of([])
|
||||
api.derive.staking._ownSlashes(accountId, [era], true).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,36 +10,46 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function _stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[]> => {
|
||||
const stakerId = api.registry.createType('AccountId', accountId).toString();
|
||||
export function _stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[][]> => {
|
||||
const stakerIds = accountIds.map((a) => api.registry.createType('AccountId', a).toString());
|
||||
|
||||
return api.derive.staking._erasExposure(eras, withActive).pipe(
|
||||
map((exposures): DeriveStakerExposure[] =>
|
||||
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
||||
const isValidator = !!allValidators[stakerId];
|
||||
const validators: DeriveEraValidatorExposure = {};
|
||||
const nominating = allNominators[stakerId] || [];
|
||||
map((exposures): DeriveStakerExposure[][] =>
|
||||
stakerIds.map((stakerId) =>
|
||||
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
||||
const isValidator = !!allValidators[stakerId];
|
||||
const validators: DeriveEraValidatorExposure = {};
|
||||
const nominating = allNominators[stakerId] || [];
|
||||
|
||||
if (isValidator) {
|
||||
validators[stakerId] = allValidators[stakerId];
|
||||
} else if (nominating) {
|
||||
nominating.forEach(({ validatorId }): void => {
|
||||
validators[validatorId] = allValidators[validatorId];
|
||||
});
|
||||
}
|
||||
if (isValidator) {
|
||||
validators[stakerId] = allValidators[stakerId];
|
||||
} else if (nominating) {
|
||||
nominating.forEach(({ validatorId }): void => {
|
||||
validators[validatorId] = allValidators[validatorId];
|
||||
});
|
||||
}
|
||||
|
||||
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
||||
})
|
||||
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
||||
export function stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], withActive?: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], withActive = false): Observable<DeriveStakerExposure[][]> =>
|
||||
api.derive.staking.erasHistoric(withActive).pipe(
|
||||
switchMap((eras) => api.derive.staking._stakerExposure(accountId, eras, withActive))
|
||||
switchMap((eras) => api.derive.staking._stakerExposures(accountIds, eras, withActive))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
||||
api.derive.staking.stakerExposures([accountId, withActive]).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, EraIndex, StakingLedger, StakingLedgerTo240 } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
|
||||
import type { DeriveStakingQuery } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { BN_BILLION, BN_ZERO, isFunction } from '@polkadot/util';
|
||||
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
||||
type ErasResult = [DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
||||
|
||||
const MIN_ONE = new BN(-1);
|
||||
|
||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
|
||||
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: BN_ZERO, validators: {} };
|
||||
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
|
||||
@@ -71,32 +68,25 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, e
|
||||
});
|
||||
}
|
||||
|
||||
function uniqValidators (rewards: DeriveStakerReward[]): string[] {
|
||||
const uniq: string[] = [];
|
||||
function allUniqValidators (rewards: DeriveStakerReward[][]): [string[], string[][]] {
|
||||
return rewards.reduce(([all, perStash]: [string[], string[][]], rewards) => {
|
||||
const uniq: string[] = [];
|
||||
|
||||
rewards.forEach(({ validators }): void => {
|
||||
Object.keys(validators).forEach((validatorId): void => {
|
||||
if (!uniq.includes(validatorId)) {
|
||||
uniq.push(validatorId);
|
||||
}
|
||||
});
|
||||
});
|
||||
perStash.push(uniq);
|
||||
rewards.forEach(({ validators }) =>
|
||||
Object.keys(validators).forEach((validatorId): void => {
|
||||
if (!uniq.includes(validatorId)) {
|
||||
uniq.push(validatorId);
|
||||
|
||||
return uniq;
|
||||
}
|
||||
if (!all.includes(validatorId)) {
|
||||
all.push(validatorId);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
function isOldLedger (ledger?: StakingLedger | StakingLedgerTo240): ledger is StakingLedgerTo240 {
|
||||
return !!(ledger as StakingLedgerTo240)?.lastReward;
|
||||
}
|
||||
|
||||
function filterEra (era: EraIndex, stakingLedger: StakingLedger): boolean {
|
||||
return isOldLedger(stakingLedger)
|
||||
? era.gt(stakingLedger.lastReward.unwrapOr(MIN_ONE))
|
||||
: !stakingLedger.claimedRewards.some((e) => e.eq(era));
|
||||
}
|
||||
|
||||
function filterEras (eras: EraIndex[], stakingLedger: StakingLedger): EraIndex[] {
|
||||
return eras.filter((era) => filterEra(era, stakingLedger));
|
||||
return [all, perStash];
|
||||
}, [[], []]);
|
||||
}
|
||||
|
||||
function removeClaimed (validators: string[], queryValidators: DeriveStakingQuery[], reward: DeriveStakerReward): void {
|
||||
@@ -119,43 +109,34 @@ function removeClaimed (validators: string[], queryValidators: DeriveStakingQuer
|
||||
});
|
||||
}
|
||||
|
||||
function filterRewards (api: ApiInterfaceRx, eras: EraIndex[], { migrateEra, rewards, stakingLedger }: { migrateEra: BN, rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): Observable<DeriveStakerReward[]> {
|
||||
const validators = uniqValidators(rewards);
|
||||
const filter = filterEras(eras, stakingLedger);
|
||||
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): DeriveStakerReward[] {
|
||||
const filter = eras.filter((era) => !stakingLedger.claimedRewards.some((e) => e.eq(era)));
|
||||
const validators = valInfo.map(([v]) => v);
|
||||
const queryValidators = valInfo.map(([, q]) => q);
|
||||
|
||||
return api.derive.staking.queryMulti(validators, { withLedger: true }).pipe(
|
||||
map((queryValidators): DeriveStakerReward[] =>
|
||||
rewards
|
||||
.filter(({ isEmpty }) => !isEmpty)
|
||||
.filter((reward): boolean => {
|
||||
if (!filter.some((filter) => reward.era.eq(filter))) {
|
||||
return false;
|
||||
} else if (reward.era.lt(migrateEra)) {
|
||||
// we filter again here, the actual ledger may have changed, e.g. something has been claimed
|
||||
return filterEra(reward.era, stakingLedger);
|
||||
}
|
||||
return rewards
|
||||
.filter(({ isEmpty }) => !isEmpty)
|
||||
.filter((reward): boolean => {
|
||||
if (!filter.some((filter) => reward.era.eq(filter))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reward.isStakerPayout = true;
|
||||
reward.isStakerPayout = true;
|
||||
|
||||
removeClaimed(validators, queryValidators, reward);
|
||||
removeClaimed(validators, queryValidators, reward);
|
||||
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}))
|
||||
)
|
||||
);
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}));
|
||||
}
|
||||
|
||||
export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (eras: EraIndex[], withActive: boolean) => Observable<ErasResult> {
|
||||
return memo(instanceId, (eras: EraIndex[], withActive: boolean): Observable<ErasResult> =>
|
||||
combineLatest([
|
||||
isFunction(api.query.staking.migrateEra)
|
||||
? api.query.staking.migrateEra<Option<EraIndex>>()
|
||||
: of(api.registry.createType('Option<EraIndex>')),
|
||||
api.derive.staking._erasPoints(eras, withActive),
|
||||
api.derive.staking._erasPrefs(eras, withActive),
|
||||
api.derive.staking._erasRewards(eras, withActive)
|
||||
@@ -163,23 +144,39 @@ export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (e
|
||||
);
|
||||
}
|
||||
|
||||
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[]> =>
|
||||
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[][]> =>
|
||||
combineLatest([
|
||||
api.derive.staking.query(accountId, { withLedger: true }),
|
||||
api.derive.staking._stakerExposure(accountId, eras, withActive),
|
||||
api.derive.staking.queryMulti(accountIds, { withLedger: true }),
|
||||
api.derive.staking._stakerExposures(accountIds, eras, withActive),
|
||||
api.derive.staking._stakerRewardsEras(eras, withActive)
|
||||
]).pipe(
|
||||
switchMap(([{ stakingLedger, stashId }, exposures, erasResult]): Observable<DeriveStakerReward[]> => {
|
||||
if (!stashId || !stakingLedger) {
|
||||
return of([]);
|
||||
switchMap(([queries, exposures, erasResult]): Observable<DeriveStakerReward[][]> => {
|
||||
const allRewards = queries.map(({ stakingLedger, stashId }, index): DeriveStakerReward[] =>
|
||||
(!stashId || !stakingLedger)
|
||||
? []
|
||||
: parseRewards(api, stashId, erasResult, exposures[index])
|
||||
);
|
||||
|
||||
if (withActive) {
|
||||
return of(allRewards);
|
||||
}
|
||||
|
||||
const rewards = parseRewards(api, stashId, erasResult, exposures);
|
||||
const [allValidators, stashValidators] = allUniqValidators(allRewards);
|
||||
|
||||
return withActive
|
||||
? of(rewards)
|
||||
: filterRewards(api, eras, { migrateEra: erasResult[0].unwrapOr(BN_ZERO), rewards, stakingLedger });
|
||||
return api.derive.staking.queryMulti(allValidators, { withLedger: true }).pipe(
|
||||
map((queriedVals): DeriveStakerReward[][] => {
|
||||
return queries.map(({ stakingLedger }, index): DeriveStakerReward[] => {
|
||||
const rewards = allRewards[index];
|
||||
const ownValidators = stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
|
||||
validatorId,
|
||||
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
|
||||
]);
|
||||
|
||||
return filterRewards(eras, ownValidators, { rewards, stakingLedger });
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
)
|
||||
);
|
||||
@@ -188,7 +185,8 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
|
||||
export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerReward[]> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerReward[]> =>
|
||||
api.derive.staking.erasHistoric(withActive).pipe(
|
||||
switchMap((eras) => api.derive.staking._stakerRewards(accountId, eras, withActive))
|
||||
switchMap((eras) => api.derive.staking._stakerRewards([accountId], eras, withActive)),
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -196,7 +194,7 @@ export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accoun
|
||||
export function stakerRewardsMultiEras (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[]) => Observable<DeriveStakerReward[][]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[]): Observable<DeriveStakerReward[][]> =>
|
||||
accountIds.length && eras.length
|
||||
? combineLatest(accountIds.map((acc) => api.derive.staking._stakerRewards(acc, eras, false)))
|
||||
? api.derive.staking._stakerRewards(accountIds, eras, false)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { DeriveCache } from './types';
|
||||
|
||||
const mapCache = new Map<string, any>();
|
||||
|
||||
const deriveMapCache: DeriveCache = {
|
||||
export const deriveMapCache: DeriveCache = {
|
||||
del: (key: string): void => {
|
||||
mapCache.delete(key);
|
||||
},
|
||||
@@ -24,11 +24,9 @@ const deriveMapCache: DeriveCache = {
|
||||
}
|
||||
};
|
||||
|
||||
const deriveNoopCache: DeriveCache = {
|
||||
export const deriveNoopCache: DeriveCache = {
|
||||
del: (): void => undefined,
|
||||
forEach: () => undefined,
|
||||
get: (): undefined => undefined,
|
||||
set: (_: string, value: unknown): unknown => value
|
||||
};
|
||||
|
||||
export { deriveMapCache, deriveNoopCache };
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
@@ -15,17 +15,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api-derive": "3.9.2",
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-core": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/types-known": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/api-derive": "3.11.1",
|
||||
"@polkadot/keyring": "^5.9.2",
|
||||
"@polkadot/metadata": "3.11.1",
|
||||
"@polkadot/rpc-core": "3.11.1",
|
||||
"@polkadot/rpc-provider": "3.11.1",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/types-known": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/util-crypto": "^5.9.2",
|
||||
"@polkadot/x-rxjs": "^5.9.2",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -107,12 +107,17 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum nesting level of a call/instantiate stack. A reasonable default
|
||||
* value is 100.
|
||||
* 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 in bytes. A reasonable default is 16 KiB.
|
||||
* The maximum size of a storage value and event payload in bytes.
|
||||
**/
|
||||
maxValueSize: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -179,6 +184,22 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Duration of the signed phase.
|
||||
**/
|
||||
signedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum amount of improvement to the solution score that defines a solution as
|
||||
* "better" (in any phase).
|
||||
**/
|
||||
solutionImprovementThreshold: Perbill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Duration of the unsigned phase.
|
||||
**/
|
||||
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: Codec;
|
||||
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
||||
|
||||
@@ -191,7 +191,7 @@ declare module '@polkadot/api/types/errors' {
|
||||
/**
|
||||
* A contract could not be evicted because it has enough balance to pay rent.
|
||||
*
|
||||
* This can be returned from [`Module::claim_surcharge`] because the target
|
||||
* This can be returned from [`Pallet::claim_surcharge`] because the target
|
||||
* contract has enough balance to pay for its rent.
|
||||
**/
|
||||
ContractNotEvictable: AugmentedError<ApiType>;
|
||||
@@ -206,7 +206,7 @@ declare module '@polkadot/api/types/errors' {
|
||||
/**
|
||||
* Removal of a contract failed because the deletion queue is full.
|
||||
*
|
||||
* This can happen when either calling [`Module::claim_surcharge`] or `seal_terminate`.
|
||||
* This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.
|
||||
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
|
||||
* Trying again during another block is the only way to resolve this issue.
|
||||
**/
|
||||
@@ -499,6 +499,21 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
WrongUpperBound: AugmentedError<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too early.
|
||||
**/
|
||||
PreDispatchEarlySubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too weak, score-wise.
|
||||
**/
|
||||
PreDispatchWeakSubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Wrong number of winners presented.
|
||||
**/
|
||||
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -691,6 +706,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The data to be stored is already stored.
|
||||
**/
|
||||
AlreadyStored: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The maximum weight information provided was too low.
|
||||
**/
|
||||
MaxWeightTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Threshold must be 2 or greater.
|
||||
**/
|
||||
@@ -731,10 +750,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A timepoint was given, yet no multisig operation is underway.
|
||||
**/
|
||||
UnexpectedTimepoint: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The maximum weight information provided was too low.
|
||||
**/
|
||||
WeightTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A different timepoint was given to the multisig operation that is underway.
|
||||
**/
|
||||
|
||||
@@ -345,6 +345,37 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* The election has been finalized, with `Some` of the given computation, or else if the
|
||||
* election failed, `None`.
|
||||
**/
|
||||
ElectionFinalized: AugmentedEvent<ApiType, [Option<ElectionCompute>]>;
|
||||
/**
|
||||
* An account has been rewarded for their signed submission being finalized.
|
||||
**/
|
||||
Rewarded: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The signed phase of the given round has started.
|
||||
**/
|
||||
SignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* An account has been slashed for submitting an invalid signed submission.
|
||||
**/
|
||||
Slashed: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A solution was stored with the given compute.
|
||||
*
|
||||
* If the solution is signed, this means that it hasn't yet been processed. If the
|
||||
* solution is unsigned, this means that it has also been processed.
|
||||
**/
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
/**
|
||||
* The unsigned phase of the given round has started.
|
||||
**/
|
||||
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
|
||||
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SeatHolder, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
@@ -323,6 +323,44 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current phase.
|
||||
**/
|
||||
currentPhase: AugmentedQuery<ApiType, () => Observable<Phase>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Desired number of targets to elect for this round.
|
||||
*
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
|
||||
**/
|
||||
queuedSolution: AugmentedQuery<ApiType, () => Observable<Option<ReadySolution>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Internal counter for the number of rounds.
|
||||
*
|
||||
* This is useful for de-duplication of transactions submitted to the pool, and general
|
||||
* diagnostics of the pallet.
|
||||
*
|
||||
* This is merely incremented once per every time that an upstream `elect` is called.
|
||||
**/
|
||||
round: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot data of the round.
|
||||
*
|
||||
* This is created at the beginning of the signed phase and cleared upon calling `elect`.
|
||||
**/
|
||||
snapshot: AugmentedQuery<ApiType, () => Observable<Option<RoundSnapshot>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The metadata of the [`RoundSnapshot`]
|
||||
*
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
@@ -723,6 +761,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* set, it might be active or not.
|
||||
**/
|
||||
currentEra: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The last planned session scheduled by the session pallet.
|
||||
*
|
||||
* This is basically in sync with the call to [`SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<SessionIndex>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
@@ -730,6 +774,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
|
||||
* solutions to be submitted.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -809,6 +855,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* True if the current **planned** session is final. Note that this does not take era
|
||||
* forcing into account.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -835,10 +883,14 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The next validator set. At the end of an era, if this is available (potentially from the
|
||||
* result of an offchain worker), it is immediately used. Otherwise, the on-chain election
|
||||
* is executed.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The score of the current [`QueuedElected`].
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -854,11 +906,15 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Snapshot of nominators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotNominators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot of validators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotValidators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
|
||||
@@ -333,11 +333,11 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
/**
|
||||
* Get offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageGet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
localStorageGet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Set offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageSet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||
localStorageSet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||
};
|
||||
payment: {
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
||||
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||
import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CodeHash, Schedule } 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';
|
||||
@@ -18,7 +18,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
|
||||
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys } from '@polkadot/types/interfaces/session';
|
||||
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RewardDestination, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { Key } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -538,7 +538,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* * If no account exists and the call value is not less than `existential_deposit`,
|
||||
* a regular account will be created and any value will be transferred.
|
||||
**/
|
||||
call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Gas>, Bytes]>;
|
||||
call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Weight>, Bytes]>;
|
||||
/**
|
||||
* Allows block producers to claim a small reward for evicting a contract. If a block
|
||||
* producer fails to do so, a regular users will be allowed to claim the reward.
|
||||
@@ -558,7 +558,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary
|
||||
* must be supplied.
|
||||
**/
|
||||
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Gas>, CodeHash, Bytes, Bytes]>;
|
||||
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, CodeHash, Bytes, Bytes]>;
|
||||
/**
|
||||
* Instantiates a new contract from the supplied `code` optionally transferring
|
||||
* some balance.
|
||||
@@ -582,7 +582,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - The `endowment` is transferred to the new account.
|
||||
* - The `deploy` function is executed in the context of the newly-created account.
|
||||
**/
|
||||
instantiateWithCode: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Gas>, Bytes, Bytes, Bytes]>;
|
||||
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.
|
||||
*
|
||||
@@ -1062,6 +1062,26 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
* The dispatch origin fo this call must be __none__.
|
||||
*
|
||||
* This submission is checked on the fly. Moreover, this unsigned solution is only
|
||||
* validated when submitted to the pool from the **local** node. Effectively, this means
|
||||
* that only active validators can submit this transaction when authoring a block (similar
|
||||
* to an inherent).
|
||||
*
|
||||
* To prevent any incorrect solution (and thus wasted time/weight), this transaction will
|
||||
* panic if the solution submitted by the validator is invalid in any way, effectively
|
||||
* putting their authoring reward at risk.
|
||||
*
|
||||
* No deposit or reward is associated with this submission.
|
||||
**/
|
||||
submitUnsigned: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, Decora
|
||||
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from '../detectPackage';
|
||||
import { packageInfo } from '../packageInfo';
|
||||
import { Init } from './Init';
|
||||
|
||||
interface PkgJson {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ChainProperties, Hash, RuntimeVersion, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
||||
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
@@ -12,8 +12,7 @@ import BN from 'bn.js';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
@@ -85,6 +84,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
registry.setChainProperties(chainProps || this.registry.getChainProperties());
|
||||
registry.setKnownTypes(this._options);
|
||||
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
|
||||
registry.setHasher(getSpecHasher(registry, chain, version.specName));
|
||||
|
||||
// for bundled types, pull through the aliases defined
|
||||
if (registry.knownTypes.typesBundle) {
|
||||
@@ -285,20 +285,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
return [genesisHash, metadata];
|
||||
}
|
||||
|
||||
private async _initFromMeta (metadata: Metadata): Promise<boolean> {
|
||||
const metaExtrinsic = metadata.asLatest.extrinsic;
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
if (metaExtrinsic.version.gt(BN_ZERO)) {
|
||||
this._extrinsicType = metaExtrinsic.version.toNumber();
|
||||
} else if (!this._options.source) {
|
||||
// detect the extrinsic version in-use based on the last block
|
||||
const { block: { extrinsics: [firstTx] } }: SignedBlock = await this._rpcCore.chain.getBlock().toPromise();
|
||||
|
||||
// If we haven't sync-ed to 1 yes, this won't have any values
|
||||
this._extrinsicType = firstTx ? firstTx.type : LATEST_EXTRINSIC_VERSION;
|
||||
}
|
||||
|
||||
private _initFromMeta (metadata: Metadata): boolean {
|
||||
this._extrinsicType = metadata.asLatest.extrinsic.version.toNumber();
|
||||
this._rx.extrinsicType = this._extrinsicType;
|
||||
this._rx.genesisHash = this._genesisHash;
|
||||
this._rx.runtimeVersion = this._runtimeVersion as RuntimeVersion; // must be set here
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { packageInfo as deriveInfo } from '@polkadot/api-derive/packageInfo';
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [deriveInfo, metaInfo, coreInfo, providerInfo, typesInfo, knownInfo]);
|
||||
|
||||
@@ -6,7 +6,7 @@ import './detectPackage';
|
||||
export { Keyring } from '@polkadot/keyring';
|
||||
export { WsProvider } from '@polkadot/rpc-provider/ws';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { ApiPromise } from './promise';
|
||||
export { ApiRx } from './rx';
|
||||
|
||||
export { SubmittableResult } from './submittable';
|
||||
export { ApiRx } from './rx';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '3.11.1' };
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
@@ -15,14 +15,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/types-known": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/types-known": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/util-crypto": "^5.9.2",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^5.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
import { assert } from '@polkadot/util';
|
||||
@@ -126,4 +126,16 @@ export class MetadataVersioned extends Struct {
|
||||
public getUniqTypes (throwError: boolean): string[] {
|
||||
return getUniqTypes(this.registry, this.asLatest, throwError);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
this.asLatest;
|
||||
|
||||
return super.toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,4 @@ export function expandMetadata (registry: Registry, metadata: Metadata): Decorat
|
||||
};
|
||||
}
|
||||
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage };
|
||||
export { decorateConstants, decorateErrors, decorateEvents, decorateExtrinsics, decorateStorage };
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo, knownInfo]);
|
||||
|
||||
@@ -5,3 +5,4 @@ import './detectPackage';
|
||||
|
||||
export { Metadata } from './Metadata';
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '3.11.1' };
|
||||
@@ -474,7 +474,7 @@
|
||||
{
|
||||
"name": "Version",
|
||||
"type": "RuntimeVersion",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a000000080100000000000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a04000000d2bc9897eed08f1502000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a000000090100000000000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a04000000d2bc9897eed08f1502000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"documentation": [
|
||||
" Get the chain's current version."
|
||||
]
|
||||
@@ -1697,6 +1697,230 @@
|
||||
"errors": [],
|
||||
"index": 7
|
||||
},
|
||||
{
|
||||
"name": "ElectionProviderMultiPhase",
|
||||
"storage": {
|
||||
"prefix": "ElectionProviderMultiPhase",
|
||||
"items": [
|
||||
{
|
||||
"name": "Round",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
"fallback": "0x01000000",
|
||||
"documentation": [
|
||||
" Internal counter for the number of rounds.",
|
||||
"",
|
||||
" This is useful for de-duplication of transactions submitted to the pool, and general",
|
||||
" diagnostics of the pallet.",
|
||||
"",
|
||||
" This is merely incremented once per every time that an upstream `elect` is called."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CurrentPhase",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Phase"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Current phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "QueuedSolution",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "ReadySolution"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Current best solution, signed or unsigned, queued to be returned upon `elect`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Snapshot",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "RoundSnapshot"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Snapshot data of the round.",
|
||||
"",
|
||||
" This is created at the beginning of the signed phase and cleared upon calling `elect`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DesiredTargets",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Desired number of targets to elect for this round.",
|
||||
"",
|
||||
" Only exists when [`Snapshot`] is present."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SnapshotMetadata",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "SolutionOrSnapshotSize"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The metadata of the [`RoundSnapshot`]",
|
||||
"",
|
||||
" Only exists when [`Snapshot`] is present."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"calls": [
|
||||
{
|
||||
"name": "submit_unsigned",
|
||||
"args": [
|
||||
{
|
||||
"name": "solution",
|
||||
"type": "RawSolution"
|
||||
},
|
||||
{
|
||||
"name": "witness",
|
||||
"type": "SolutionOrSnapshotSize"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Submit a solution for the unsigned phase.",
|
||||
"",
|
||||
" The dispatch origin fo this call must be __none__.",
|
||||
"",
|
||||
" This submission is checked on the fly. Moreover, this unsigned solution is only",
|
||||
" validated when submitted to the pool from the **local** node. Effectively, this means",
|
||||
" that only active validators can submit this transaction when authoring a block (similar",
|
||||
" to an inherent).",
|
||||
"",
|
||||
" To prevent any incorrect solution (and thus wasted time/weight), this transaction will",
|
||||
" panic if the solution submitted by the validator is invalid in any way, effectively",
|
||||
" putting their authoring reward at risk.",
|
||||
"",
|
||||
" No deposit or reward is associated with this submission."
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "SolutionStored",
|
||||
"args": [
|
||||
"ElectionCompute"
|
||||
],
|
||||
"documentation": [
|
||||
" A solution was stored with the given compute.",
|
||||
"",
|
||||
" If the solution is signed, this means that it hasn't yet been processed. If the",
|
||||
" solution is unsigned, this means that it has also been processed."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ElectionFinalized",
|
||||
"args": [
|
||||
"Option<ElectionCompute>"
|
||||
],
|
||||
"documentation": [
|
||||
" The election has been finalized, with `Some` of the given computation, or else if the",
|
||||
" election failed, `None`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Rewarded",
|
||||
"args": [
|
||||
"AccountId"
|
||||
],
|
||||
"documentation": [
|
||||
" An account has been rewarded for their signed submission being finalized."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Slashed",
|
||||
"args": [
|
||||
"AccountId"
|
||||
],
|
||||
"documentation": [
|
||||
" An account has been slashed for submitting an invalid signed submission."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedPhaseStarted",
|
||||
"args": [
|
||||
"u32"
|
||||
],
|
||||
"documentation": [
|
||||
" The signed phase of the given round has started."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "UnsignedPhaseStarted",
|
||||
"args": [
|
||||
"u32"
|
||||
],
|
||||
"documentation": [
|
||||
" The unsigned phase of the given round has started."
|
||||
]
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"name": "UnsignedPhase",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x32000000",
|
||||
"documentation": [
|
||||
" Duration of the unsigned phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedPhase",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x32000000",
|
||||
"documentation": [
|
||||
" Duration of the signed phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SolutionImprovementThreshold",
|
||||
"type": "Perbill",
|
||||
"value": "0x20a10700",
|
||||
"documentation": [
|
||||
" The minimum amount of improvement to the solution score that defines a solution as",
|
||||
" \"better\" (in any phase)."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
{
|
||||
"name": "PreDispatchEarlySubmission",
|
||||
"documentation": [
|
||||
" Submission was too early."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PreDispatchWrongWinnerCount",
|
||||
"documentation": [
|
||||
" Wrong number of winners presented."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PreDispatchWeakSubmission",
|
||||
"documentation": [
|
||||
" Submission was too weak, score-wise."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 8
|
||||
},
|
||||
{
|
||||
"name": "Staking",
|
||||
"storage": {
|
||||
@@ -2148,6 +2372,19 @@
|
||||
" The earliest era for which we have a pending, unapplied slash."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CurrentPlannedSession",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "SessionIndex"
|
||||
},
|
||||
"fallback": "0x00000000",
|
||||
"documentation": [
|
||||
" The last planned session scheduled by the session pallet.",
|
||||
"",
|
||||
" This is basically in sync with the call to [`SessionManager::new_session`]."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SnapshotValidators",
|
||||
"modifier": "Optional",
|
||||
@@ -2157,7 +2394,9 @@
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Snapshot of validators at the beginning of the current election window. This should only",
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`."
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2169,7 +2408,9 @@
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Snapshot of nominators at the beginning of the current election window. This should only",
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`."
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2182,7 +2423,9 @@
|
||||
"documentation": [
|
||||
" The next validator set. At the end of an era, if this is available (potentially from the",
|
||||
" result of an offchain worker), it is immediately used. Otherwise, the on-chain election",
|
||||
" is executed."
|
||||
" is executed.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2193,7 +2436,9 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The score of the current [`QueuedElected`]."
|
||||
" The score of the current [`QueuedElected`].",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2205,7 +2450,9 @@
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Flag to control the execution of the offchain election. When `Open(_)`, we accept",
|
||||
" solutions to be submitted."
|
||||
" solutions to be submitted.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2217,7 +2464,9 @@
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" True if the current **planned** session is final. Note that this does not take era",
|
||||
" forcing into account."
|
||||
" forcing into account.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3363,7 +3612,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 8
|
||||
"index": 9
|
||||
},
|
||||
{
|
||||
"name": "Session",
|
||||
@@ -3557,7 +3806,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 9
|
||||
"index": 10
|
||||
},
|
||||
{
|
||||
"name": "Democracy",
|
||||
@@ -4806,7 +5055,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 10
|
||||
"index": 11
|
||||
},
|
||||
{
|
||||
"name": "Council",
|
||||
@@ -5265,7 +5514,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 11
|
||||
"index": 12
|
||||
},
|
||||
{
|
||||
"name": "TechnicalCommittee",
|
||||
@@ -5724,7 +5973,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 12
|
||||
"index": 13
|
||||
},
|
||||
{
|
||||
"name": "Elections",
|
||||
@@ -6183,7 +6432,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 13
|
||||
"index": 14
|
||||
},
|
||||
{
|
||||
"name": "TechnicalMembership",
|
||||
@@ -6366,7 +6615,7 @@
|
||||
],
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 14
|
||||
"index": 15
|
||||
},
|
||||
{
|
||||
"name": "Grandpa",
|
||||
@@ -6589,7 +6838,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 15
|
||||
"index": 16
|
||||
},
|
||||
{
|
||||
"name": "Treasury",
|
||||
@@ -6829,7 +7078,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 16
|
||||
"index": 17
|
||||
},
|
||||
{
|
||||
"name": "Contracts",
|
||||
@@ -6842,7 +7091,7 @@
|
||||
"type": {
|
||||
"Plain": "Schedule"
|
||||
},
|
||||
"fallback": "0x0000000000040000000002000000010000800000001000000000100000000100002000000000000800150600004c6b02004c8103009e1800000b1d0000160d0000651800006d2b00008a000000f5700100fdf602008e070000440600006e070000030600004f180000b528000091070000b60da70827080000590800006a0a0000ef070000560800004a0800008e080000f509000061090000dd090000a10a00009c090000e409000091090000650900001e0a0000120a0000ae09000099090000060a00006b2000000b1d000051200000221d000094090000ad090000b6090000160a0000660a0000fd090000260a0000440a0000d41a2a0000000000a0c729000000000092122900000000001ab5580000000000ba1c290000000000e000290000000000b0ef280000000000ee325c0000000000dec1280000000000ca07290000000000c07d4e00000000009c77140000000000303a7200000000000b01000000000000f0ab450000000000ff0200000000000060a21c270000000030078d31000000002635af09000000000ae164000000000038b18e0000000000b6b1cc0700000000890900000000000040036c00000000008ad6e21100000000de020000000000006e67cc080000000078f6110200000000e605000000000000acb1b50a00000000b24419090000000092579f08000000004702000000000000240300000000000016eaeb220000000055020000000000003503000000000000db0a000000000000f4802600000000006a100000000000006a9a280000000000220d0000000000004e9c2400000000001c0600000000000026832400000000001b06000000000000",
|
||||
"fallback": "0x0000000000040000000002000000010000800000001000000000100000000100002000000078060000a5600200a1740300271600000d1c0000e20c00006e160000ff280000a00000008b780100e4f80200b70600002c06000027070000a705000074170000ca2700002807000002ea8f08ef070000fd0700003c0a0000630800007f070000c7070000fe0700008909000022090000ea080000c30900002709000059070000d508000082080000b60900007a090000c90800009b080000bb080000a51f0000b51c00009a1f0000c21c00008c0800006b080000ea0800004009000092090000fc080000ae090000c2090000ae37290000000000e636290000000000be5a280000000000d479570000000000bc25280000000000a285280000000000008c28000000000052385c00000000003a07280000000000942a280000000000541d4d00000000002603130000000000b08a6f00000000000b01000000000000a053480000000000fd020000000000009862332700000000a32000000000000000e3bd3100000000902200000000000056120000000000006872ad0900000000de326200000000007cfe8e00000000008211ce07000000009309000000000000ac096d0000000000e43f161100000000da020000000000005e74cf0800000000e07b0b0200000000f005000000000000deb1c40a00000000f24a370900000000ff0e000000000000228bf9080000000049020000000000002a030000000000004c971c2300000000892100000000000067020000000000005703000000000000e60b000000000000aac22400000000006210000000000000f434270000000000200d00000000000094672200000000001806000000000000f86c2200000000001806000000000000",
|
||||
"documentation": [
|
||||
" Current cost schedule for contracts."
|
||||
]
|
||||
@@ -6952,7 +7201,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gas_limit",
|
||||
"type": "Compact<Gas>"
|
||||
"type": "Compact<Weight>"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
@@ -6978,7 +7227,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gas_limit",
|
||||
"type": "Compact<Gas>"
|
||||
"type": "Compact<Weight>"
|
||||
},
|
||||
{
|
||||
"name": "code",
|
||||
@@ -7026,7 +7275,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gas_limit",
|
||||
"type": "Compact<Gas>"
|
||||
"type": "Compact<Weight>"
|
||||
},
|
||||
{
|
||||
"name": "code_hash",
|
||||
@@ -7272,8 +7521,7 @@
|
||||
"type": "u32",
|
||||
"value": "0x20000000",
|
||||
"documentation": [
|
||||
" The maximum nesting level of a call/instantiate stack. A reasonable default",
|
||||
" value is 100."
|
||||
" The maximum nesting level of a call/instantiate stack."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -7281,13 +7529,13 @@
|
||||
"type": "u32",
|
||||
"value": "0x00400000",
|
||||
"documentation": [
|
||||
" The maximum size of a storage value in bytes. A reasonable default is 16 KiB."
|
||||
" The maximum size of a storage value and event payload in bytes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DeletionQueueDepth",
|
||||
"type": "u32",
|
||||
"value": "0xf2000000",
|
||||
"value": "0x1b010000",
|
||||
"documentation": [
|
||||
" The maximum number of tries that can be queued for deletion."
|
||||
]
|
||||
@@ -7299,6 +7547,16 @@
|
||||
"documentation": [
|
||||
" The maximum amount of weight that can be consumed per block for lazy trie removal."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxCodeSize",
|
||||
"type": "u32",
|
||||
"value": "0x00000200",
|
||||
"documentation": [
|
||||
" The maximum length of a contract code in bytes. This limit applies to the instrumented",
|
||||
" version of the code. Therefore `instantiate_with_code` can fail even when supplying",
|
||||
" a wasm binary below this maximum size."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -7470,7 +7728,7 @@
|
||||
"documentation": [
|
||||
" Removal of a contract failed because the deletion queue is full.",
|
||||
"",
|
||||
" This can happen when either calling [`Module::claim_surcharge`] or `seal_terminate`.",
|
||||
" This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.",
|
||||
" The queue is filled by deleting contracts and emptied by a fixed amount each block.",
|
||||
" Trying again during another block is the only way to resolve this issue."
|
||||
]
|
||||
@@ -7480,7 +7738,7 @@
|
||||
"documentation": [
|
||||
" A contract could not be evicted because it has enough balance to pay rent.",
|
||||
"",
|
||||
" This can be returned from [`Module::claim_surcharge`] because the target",
|
||||
" This can be returned from [`Pallet::claim_surcharge`] because the target",
|
||||
" contract has enough balance to pay for its rent."
|
||||
]
|
||||
},
|
||||
@@ -7500,7 +7758,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 17
|
||||
"index": 18
|
||||
},
|
||||
{
|
||||
"name": "Sudo",
|
||||
@@ -7652,7 +7910,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 18
|
||||
"index": 19
|
||||
},
|
||||
{
|
||||
"name": "ImOnline",
|
||||
@@ -7792,7 +8050,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 19
|
||||
"index": 20
|
||||
},
|
||||
{
|
||||
"name": "AuthorityDiscovery",
|
||||
@@ -7801,7 +8059,7 @@
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 20
|
||||
"index": 21
|
||||
},
|
||||
{
|
||||
"name": "Offences",
|
||||
@@ -7895,7 +8153,7 @@
|
||||
],
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 21
|
||||
"index": 22
|
||||
},
|
||||
{
|
||||
"name": "Historical",
|
||||
@@ -7904,7 +8162,7 @@
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 22
|
||||
"index": 23
|
||||
},
|
||||
{
|
||||
"name": "RandomnessCollectiveFlip",
|
||||
@@ -7930,7 +8188,7 @@
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 23
|
||||
"index": 24
|
||||
},
|
||||
{
|
||||
"name": "Identity",
|
||||
@@ -8670,7 +8928,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 24
|
||||
"index": 25
|
||||
},
|
||||
{
|
||||
"name": "Society",
|
||||
@@ -9652,7 +9910,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 25
|
||||
"index": 26
|
||||
},
|
||||
{
|
||||
"name": "Recovery",
|
||||
@@ -10206,7 +10464,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 26
|
||||
"index": 27
|
||||
},
|
||||
{
|
||||
"name": "Vesting",
|
||||
@@ -10398,7 +10656,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 27
|
||||
"index": 28
|
||||
},
|
||||
{
|
||||
"name": "Scheduler",
|
||||
@@ -10690,7 +10948,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 28
|
||||
"index": 29
|
||||
},
|
||||
{
|
||||
"name": "Proxy",
|
||||
@@ -11208,7 +11466,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 29
|
||||
"index": 30
|
||||
},
|
||||
{
|
||||
"name": "Multisig",
|
||||
@@ -11622,7 +11880,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "WeightTooLow",
|
||||
"name": "MaxWeightTooLow",
|
||||
"documentation": [
|
||||
" The maximum weight information provided was too low."
|
||||
]
|
||||
@@ -11634,7 +11892,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 30
|
||||
"index": 31
|
||||
},
|
||||
{
|
||||
"name": "Bounties",
|
||||
@@ -12094,7 +12352,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 31
|
||||
"index": 32
|
||||
},
|
||||
{
|
||||
"name": "Tips",
|
||||
@@ -12467,7 +12725,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 32
|
||||
"index": 33
|
||||
},
|
||||
{
|
||||
"name": "Assets",
|
||||
@@ -13280,7 +13538,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 33
|
||||
"index": 34
|
||||
},
|
||||
{
|
||||
"name": "Mmr",
|
||||
@@ -13334,7 +13592,7 @@
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"index": 34
|
||||
"index": 35
|
||||
},
|
||||
{
|
||||
"name": "Lottery",
|
||||
@@ -13556,7 +13814,7 @@
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
"index": 35
|
||||
"index": 36
|
||||
}
|
||||
],
|
||||
"extrinsic": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,14 +15,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2"
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/metadata": "3.11.1",
|
||||
"@polkadot/rpc-provider": "3.11.1",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/x-rxjs": "^5.9.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^5.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [metaInfo, providerInfo, typesInfo]);
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
||||
import type { StorageKey, Vec } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
@@ -18,6 +20,8 @@ import { publishReplay, refCount } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { drr, refCountDelay } from './util';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
interface StorageChangeSetJSON {
|
||||
block: string;
|
||||
changes: [string, string | null][];
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '3.11.1' };
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,20 +15,20 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-fetch": "^5.6.2",
|
||||
"@polkadot/x-global": "^5.6.2",
|
||||
"@polkadot/x-ws": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/util-crypto": "^5.9.2",
|
||||
"@polkadot/x-fetch": "^5.9.2",
|
||||
"@polkadot/x-global": "^5.9.2",
|
||||
"@polkadot/x-ws": "^5.9.2",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/keyring": "^5.9.2",
|
||||
"@polkadot/metadata": "3.11.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.7"
|
||||
"nock": "^13.0.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||
@@ -1,5 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
export { HttpProvider } from './http';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { WsProvider } from './ws';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '3.11.1' };
|
||||
@@ -42,6 +42,16 @@ const RETRY_DELAY = 1000;
|
||||
|
||||
const l = logger('api-ws');
|
||||
|
||||
function eraseRecord<T> (record: Record<string, T>, cb?: (item: T) => void): void {
|
||||
Object.keys(record).forEach((key): void => {
|
||||
if (cb) {
|
||||
cb(record[key]);
|
||||
}
|
||||
|
||||
delete record[key];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* # @polkadot/rpc-provider/ws
|
||||
*
|
||||
@@ -245,8 +255,8 @@ export class WsProvider implements ProviderInterface {
|
||||
* @param params Encoded parameters as applicable for the method
|
||||
* @param subscription Subscription details (internally used)
|
||||
*/
|
||||
public send (method: string, params: any[], subscription?: SubscriptionHandler): Promise<any> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
public send <T = any> (method: string, params: any[], subscription?: SubscriptionHandler): Promise<T> {
|
||||
return new Promise<T>((resolve, reject): void => {
|
||||
try {
|
||||
assert(this.isConnected && !isNull(this.#websocket), 'WebSocket is not connected');
|
||||
|
||||
@@ -298,10 +308,8 @@ export class WsProvider implements ProviderInterface {
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
public async subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||
const id = await this.send(method, params, { callback, type }) as Promise<number | string>;
|
||||
|
||||
return id;
|
||||
public subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||
return this.send<number | string>(method, params, { callback, type });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,9 +330,13 @@ export class WsProvider implements ProviderInterface {
|
||||
|
||||
delete this.#subscriptions[subscription];
|
||||
|
||||
const result = await this.send(method, [id]) as Promise<boolean>;
|
||||
|
||||
return result;
|
||||
try {
|
||||
return this.isConnected && !isNull(this.#websocket)
|
||||
? this.send<boolean>(method, [id])
|
||||
: true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
|
||||
@@ -332,12 +344,17 @@ export class WsProvider implements ProviderInterface {
|
||||
}
|
||||
|
||||
#onSocketClose = (event: CloseEvent): void => {
|
||||
const error = new Error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||
|
||||
if (this.#autoConnectMs > 0) {
|
||||
l.error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||
l.error(error.message);
|
||||
}
|
||||
|
||||
this.#isConnected = false;
|
||||
this.#emit('disconnected');
|
||||
// reject all hanging requests
|
||||
eraseRecord(this.#handlers, (handler) => handler.callback(error, undefined));
|
||||
eraseRecord(this.#waitingForId);
|
||||
|
||||
if (this.#autoConnectMs > 0) {
|
||||
setTimeout((): void => {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
const TEST_HTTP_URL = 'http://localhost:9944';
|
||||
export const TEST_HTTP_URL = 'http://localhost:9944';
|
||||
|
||||
function mockHttp (requests: any[]): any {
|
||||
export function mockHttp (requests: any[]): any {
|
||||
nock.cleanAll();
|
||||
|
||||
return requests.reduce((scope, request: any): nock.Scope => {
|
||||
@@ -21,8 +21,3 @@ function mockHttp (requests: any[]): any {
|
||||
});
|
||||
}, nock(TEST_HTTP_URL));
|
||||
}
|
||||
|
||||
export {
|
||||
TEST_HTTP_URL,
|
||||
mockHttp
|
||||
};
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
import { Server, WebSocket } from 'mock-socket';
|
||||
|
||||
const TEST_WS_URL = 'ws://localhost:9955';
|
||||
|
||||
interface Scope {
|
||||
body: { [index: string]: Record<string, any> };
|
||||
requests: number;
|
||||
@@ -29,6 +27,8 @@ interface ReplyDef {
|
||||
|
||||
global.WebSocket = WebSocket;
|
||||
|
||||
export const TEST_WS_URL = 'ws://localhost:9955';
|
||||
|
||||
// should be JSONRPC def return
|
||||
function createError ({ error: { code, message }, id }: ErrorDef): any {
|
||||
return {
|
||||
@@ -51,7 +51,7 @@ function createReply ({ id, reply: { result } }: ReplyDef): any {
|
||||
}
|
||||
|
||||
// scope definition returned
|
||||
function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
||||
export function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
||||
const server = new Server(wsUrl);
|
||||
|
||||
let requestCount = 0;
|
||||
@@ -85,8 +85,3 @@ function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TE
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
export {
|
||||
TEST_WS_URL,
|
||||
mockWs
|
||||
};
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
|
||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
||||
@@ -19,15 +22,15 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.12.13",
|
||||
"@babel/register": "^7.12.13",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/api": "3.9.2",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/rpc-provider": "3.9.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"handlebars": "^4.7.6",
|
||||
"@babel/core": "^7.13.8",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/api": "3.11.1",
|
||||
"@polkadot/metadata": "3.11.1",
|
||||
"@polkadot/rpc-provider": "3.11.1",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.33",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, metaInfo, providerInfo, typesInfo]);
|
||||
@@ -1,4 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { formatType } from './util/formatting';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '3.11.1' };
|
||||
@@ -70,8 +70,8 @@ export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeI
|
||||
setImports(allDefs, imports, [typeDef.sub.type]);
|
||||
}
|
||||
} else if (type.includes('[') && type.includes('|')) {
|
||||
// We split the types
|
||||
const splitTypes = /\[\s?(.+?)\s?\]/.exec(type)![1].split(/\s?\|\s?/);
|
||||
// We split the types (we already dod the check above, so safe-path should not be caught)
|
||||
const splitTypes = (/\[\s?(.+?)\s?\]/.exec(type) || ['', ''])[1].split(/\s?\|\s?/);
|
||||
|
||||
setImports(allDefs, imports, splitTypes);
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.mjs"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -12,10 +15,10 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/networks": "^5.6.2",
|
||||
"@polkadot/types": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/networks": "^5.9.2",
|
||||
"@polkadot/types": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { ChainUpgradeVersion, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
|
||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||
|
||||
@@ -14,6 +16,8 @@ import typesModules from './modules';
|
||||
import typesSpec from './spec';
|
||||
import upgrades from './upgrades';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
// flatten a VersionedType[] into a Record<string, string>
|
||||
/** @internal */
|
||||
function filterVersions (versions: OverrideVersionedType[] = [], specVersion: number): RegistryTypes {
|
||||
@@ -74,6 +78,13 @@ export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string
|
||||
};
|
||||
}
|
||||
|
||||
export function getSpecHasher ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
|
||||
return knownTypes.hasher || knownTypes.typesBundle?.chain?.[_chainName]?.hasher || knownTypes.typesBundle?.spec?.[_specName]?.hasher || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '3.11.1' };
|
||||
@@ -11,7 +11,15 @@ const sharedTypes = {
|
||||
Keys: 'SessionKeys6',
|
||||
LookupSource: 'MultiAddress',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'DeprecatedSudoBalances', 'IdentityJudgement', 'CancelProxy']
|
||||
_enum: {
|
||||
Any: 0,
|
||||
NonTransfer: 1,
|
||||
Governance: 2,
|
||||
Staking: 3,
|
||||
// SudoBalances: 4,
|
||||
IdentityJudgement: 5,
|
||||
CancelProxy: 6
|
||||
}
|
||||
},
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
|
||||
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
|
||||
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
|
||||
[3613564, 27]
|
||||
[3613564, 27], [3899547, 28]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "3.9.2",
|
||||
"version": "3.11.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
@@ -15,15 +15,15 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"@polkadot/metadata": "3.9.2",
|
||||
"@polkadot/util": "^5.6.2",
|
||||
"@polkadot/util-crypto": "^5.6.2",
|
||||
"@polkadot/x-rxjs": "^5.6.2",
|
||||
"@babel/runtime": "^7.13.8",
|
||||
"@polkadot/metadata": "3.11.1",
|
||||
"@polkadot/util": "^5.9.2",
|
||||
"@polkadot/util-crypto": "^5.9.2",
|
||||
"@polkadot/x-rxjs": "^5.9.2",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.6.2"
|
||||
"@polkadot/keyring": "^5.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ 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, InstructionWeights, Limits, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, ScheduleTo258, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractStorageKey, DeletedContract, Gas, HostFnWeights, HostFnWeightsTo264, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, PrefabWasmModuleReserved, 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 { DeployData, FundIndex, FundInfo, LastContribution } from '@polkadot/types/interfaces/crowdloan';
|
||||
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';
|
||||
@@ -24,6 +24,7 @@ import type { EthAccount, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilt
|
||||
import type { EvmAccount, EvmLog, EvmVicinity, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed } from '@polkadot/types/interfaces/evm';
|
||||
import type { AnySignature, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
|
||||
import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { 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';
|
||||
@@ -38,15 +39,15 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty
|
||||
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, 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, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, 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 { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9, 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, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardDestinationTo257, 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 { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, 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, PerDispatchClass, PerDispatchClassU32, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, 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, 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';
|
||||
@@ -55,6 +56,7 @@ import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
export interface InterfaceTypes {
|
||||
'Compact<AccountIndex>': Compact<AccountIndex>;
|
||||
'Compact<ActiveIndex>': Compact<ActiveIndex>;
|
||||
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
|
||||
'Compact<AssetId>': Compact<AssetId>;
|
||||
'Compact<AuctionIndex>': Compact<AuctionIndex>;
|
||||
@@ -73,6 +75,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<CoreIndex>': Compact<CoreIndex>;
|
||||
'Compact<EraIndex>': Compact<EraIndex>;
|
||||
'Compact<EventIndex>': Compact<EventIndex>;
|
||||
'Compact<ExtendedBalance>': Compact<ExtendedBalance>;
|
||||
'Compact<FixedU128>': Compact<FixedU128>;
|
||||
'Compact<FixedU64>': Compact<FixedU64>;
|
||||
'Compact<FundIndex>': Compact<FundIndex>;
|
||||
@@ -135,6 +138,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<ValidatorCount>': Compact<ValidatorCount>;
|
||||
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
|
||||
'Compact<VoteIndex>': Compact<VoteIndex>;
|
||||
'Compact<VoteWeight>': Compact<VoteWeight>;
|
||||
'Compact<Weight>': Compact<Weight>;
|
||||
'Option<AbridgedCandidateReceipt>': Option<AbridgedCandidateReceipt>;
|
||||
'Option<AbridgedHostConfiguration>': Option<AbridgedHostConfiguration>;
|
||||
@@ -157,6 +161,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountVoteSplit>': Option<AccountVoteSplit>;
|
||||
'Option<AccountVoteStandard>': Option<AccountVoteStandard>;
|
||||
'Option<ActiveEraInfo>': Option<ActiveEraInfo>;
|
||||
'Option<ActiveGilt>': Option<ActiveGilt>;
|
||||
'Option<ActiveGiltsTotal>': Option<ActiveGiltsTotal>;
|
||||
'Option<ActiveIndex>': Option<ActiveIndex>;
|
||||
'Option<ActiveRecovery>': Option<ActiveRecovery>;
|
||||
'Option<Address>': Option<Address>;
|
||||
'Option<AliveContractInfo>': Option<AliveContractInfo>;
|
||||
@@ -228,6 +235,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
'Option<ChainType>': Option<ChainType>;
|
||||
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
|
||||
'Option<CodecHash>': Option<CodecHash>;
|
||||
'Option<CodeHash>': Option<CodeHash>;
|
||||
'Option<CollatorId>': Option<CollatorId>;
|
||||
'Option<CollatorSignature>': Option<CollatorSignature>;
|
||||
@@ -380,6 +388,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ExitRevert>': Option<ExitRevert>;
|
||||
'Option<ExitSucceed>': Option<ExitSucceed>;
|
||||
'Option<Exposure>': Option<Exposure>;
|
||||
'Option<ExtendedBalance>': Option<ExtendedBalance>;
|
||||
'Option<Extrinsic>': Option<Extrinsic>;
|
||||
'Option<ExtrinsicEra>': Option<ExtrinsicEra>;
|
||||
'Option<ExtrinsicMetadataLatest>': Option<ExtrinsicMetadataLatest>;
|
||||
@@ -417,6 +426,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<FundIndex>': Option<FundIndex>;
|
||||
'Option<FundInfo>': Option<FundInfo>;
|
||||
'Option<Gas>': Option<Gas>;
|
||||
'Option<GiltBid>': Option<GiltBid>;
|
||||
'Option<GlobalValidationSchedule>': Option<GlobalValidationSchedule>;
|
||||
'Option<GrandpaEquivocation>': Option<GrandpaEquivocation>;
|
||||
'Option<GrandpaEquivocationProof>': Option<GrandpaEquivocationProof>;
|
||||
@@ -438,6 +448,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<HeartbeatTo244>': Option<HeartbeatTo244>;
|
||||
'Option<HostConfiguration>': Option<HostConfiguration>;
|
||||
'Option<HostFnWeights>': Option<HostFnWeights>;
|
||||
'Option<HostFnWeightsTo264>': Option<HostFnWeightsTo264>;
|
||||
'Option<HrmpChannel>': Option<HrmpChannel>;
|
||||
'Option<HrmpChannelId>': Option<HrmpChannelId>;
|
||||
'Option<HrmpOpenChannelRequest>': Option<HrmpOpenChannelRequest>;
|
||||
@@ -493,6 +504,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<LeasePeriod>': Option<LeasePeriod>;
|
||||
'Option<LeasePeriodOf>': Option<LeasePeriodOf>;
|
||||
'Option<Limits>': Option<Limits>;
|
||||
'Option<LimitsTo264>': Option<LimitsTo264>;
|
||||
'Option<LocalValidationData>': Option<LocalValidationData>;
|
||||
'Option<LockIdentifier>': Option<LockIdentifier>;
|
||||
'Option<LookupSource>': Option<LookupSource>;
|
||||
@@ -597,8 +609,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<PendingResume>': Option<PendingResume>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Option<PerDispatchClass>': Option<PerDispatchClass>;
|
||||
'Option<PerDispatchClassU32>': Option<PerDispatchClassU32>;
|
||||
'Option<PerDispatchClassWeight>': Option<PerDispatchClassWeight>;
|
||||
'Option<PerDispatchClassWeightsPerClass>': Option<PerDispatchClassWeightsPerClass>;
|
||||
'Option<Period>': Option<Period>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Option<PermissionLatest>': Option<PermissionLatest>;
|
||||
@@ -643,8 +656,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<RawBabePreDigestSecondaryVRF>': Option<RawBabePreDigestSecondaryVRF>;
|
||||
'Option<RawBabePreDigestTo159>': Option<RawBabePreDigestTo159>;
|
||||
'Option<RawOrigin>': Option<RawOrigin>;
|
||||
'Option<RawSolution>': Option<RawSolution>;
|
||||
'Option<RawVRFOutput>': Option<RawVRFOutput>;
|
||||
'Option<ReadProof>': Option<ReadProof>;
|
||||
'Option<ReadySolution>': Option<ReadySolution>;
|
||||
'Option<Reasons>': Option<Reasons>;
|
||||
'Option<RecoveryConfig>': Option<RecoveryConfig>;
|
||||
'Option<RefCount>': Option<RefCount>;
|
||||
@@ -674,6 +689,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<RewardDestination>': Option<RewardDestination>;
|
||||
'Option<RewardDestinationTo257>': Option<RewardDestinationTo257>;
|
||||
'Option<RewardPoint>': Option<RewardPoint>;
|
||||
'Option<RoundSnapshot>': Option<RoundSnapshot>;
|
||||
'Option<RoundState>': Option<RoundState>;
|
||||
'Option<RpcMethods>': Option<RpcMethods>;
|
||||
'Option<RuntimeDbWeight>': Option<RuntimeDbWeight>;
|
||||
@@ -687,6 +703,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SchedulePriority>': Option<SchedulePriority>;
|
||||
'Option<ScheduleTo212>': Option<ScheduleTo212>;
|
||||
'Option<ScheduleTo258>': Option<ScheduleTo258>;
|
||||
'Option<ScheduleTo264>': Option<ScheduleTo264>;
|
||||
'Option<Scheduling>': Option<Scheduling>;
|
||||
'Option<Seal>': Option<Seal>;
|
||||
'Option<SealV0>': Option<SealV0>;
|
||||
@@ -732,6 +749,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SlotRange>': Option<SlotRange>;
|
||||
'Option<SocietyJudgement>': Option<SocietyJudgement>;
|
||||
'Option<SocietyVote>': Option<SocietyVote>;
|
||||
'Option<SolutionOrSnapshotSize>': Option<SolutionOrSnapshotSize>;
|
||||
'Option<SolutionSupport>': Option<SolutionSupport>;
|
||||
'Option<SolutionSupports>': Option<SolutionSupports>;
|
||||
'Option<SpanIndex>': Option<SpanIndex>;
|
||||
'Option<SpanRecord>': Option<SpanRecord>;
|
||||
'Option<Sr25519Signature>': Option<Sr25519Signature>;
|
||||
@@ -842,6 +862,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<Votes>': Option<Votes>;
|
||||
'Option<VotesTo230>': Option<VotesTo230>;
|
||||
'Option<VoteThreshold>': Option<VoteThreshold>;
|
||||
'Option<VoteWeight>': Option<VoteWeight>;
|
||||
'Option<Voting>': Option<Voting>;
|
||||
'Option<VotingDelegating>': Option<VotingDelegating>;
|
||||
'Option<VotingDirect>': Option<VotingDirect>;
|
||||
@@ -884,6 +905,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<AccountVoteSplit>': Vec<AccountVoteSplit>;
|
||||
'Vec<AccountVoteStandard>': Vec<AccountVoteStandard>;
|
||||
'Vec<ActiveEraInfo>': Vec<ActiveEraInfo>;
|
||||
'Vec<ActiveGilt>': Vec<ActiveGilt>;
|
||||
'Vec<ActiveGiltsTotal>': Vec<ActiveGiltsTotal>;
|
||||
'Vec<ActiveIndex>': Vec<ActiveIndex>;
|
||||
'Vec<ActiveRecovery>': Vec<ActiveRecovery>;
|
||||
'Vec<Address>': Vec<Address>;
|
||||
'Vec<AliveContractInfo>': Vec<AliveContractInfo>;
|
||||
@@ -955,6 +979,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
'Vec<ChainType>': Vec<ChainType>;
|
||||
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
|
||||
'Vec<CodecHash>': Vec<CodecHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
'Vec<CollatorId>': Vec<CollatorId>;
|
||||
'Vec<CollatorSignature>': Vec<CollatorSignature>;
|
||||
@@ -1107,6 +1132,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ExitRevert>': Vec<ExitRevert>;
|
||||
'Vec<ExitSucceed>': Vec<ExitSucceed>;
|
||||
'Vec<Exposure>': Vec<Exposure>;
|
||||
'Vec<ExtendedBalance>': Vec<ExtendedBalance>;
|
||||
'Vec<Extrinsic>': Vec<Extrinsic>;
|
||||
'Vec<ExtrinsicEra>': Vec<ExtrinsicEra>;
|
||||
'Vec<ExtrinsicMetadataLatest>': Vec<ExtrinsicMetadataLatest>;
|
||||
@@ -1144,6 +1170,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<FundIndex>': Vec<FundIndex>;
|
||||
'Vec<FundInfo>': Vec<FundInfo>;
|
||||
'Vec<Gas>': Vec<Gas>;
|
||||
'Vec<GiltBid>': Vec<GiltBid>;
|
||||
'Vec<GlobalValidationSchedule>': Vec<GlobalValidationSchedule>;
|
||||
'Vec<GrandpaEquivocation>': Vec<GrandpaEquivocation>;
|
||||
'Vec<GrandpaEquivocationProof>': Vec<GrandpaEquivocationProof>;
|
||||
@@ -1165,6 +1192,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<HeartbeatTo244>': Vec<HeartbeatTo244>;
|
||||
'Vec<HostConfiguration>': Vec<HostConfiguration>;
|
||||
'Vec<HostFnWeights>': Vec<HostFnWeights>;
|
||||
'Vec<HostFnWeightsTo264>': Vec<HostFnWeightsTo264>;
|
||||
'Vec<HrmpChannel>': Vec<HrmpChannel>;
|
||||
'Vec<HrmpChannelId>': Vec<HrmpChannelId>;
|
||||
'Vec<HrmpOpenChannelRequest>': Vec<HrmpOpenChannelRequest>;
|
||||
@@ -1220,6 +1248,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<LeasePeriod>': Vec<LeasePeriod>;
|
||||
'Vec<LeasePeriodOf>': Vec<LeasePeriodOf>;
|
||||
'Vec<Limits>': Vec<Limits>;
|
||||
'Vec<LimitsTo264>': Vec<LimitsTo264>;
|
||||
'Vec<LocalValidationData>': Vec<LocalValidationData>;
|
||||
'Vec<LockIdentifier>': Vec<LockIdentifier>;
|
||||
'Vec<LookupSource>': Vec<LookupSource>;
|
||||
@@ -1324,8 +1353,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<PendingResume>': Vec<PendingResume>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
'Vec<PerDispatchClass>': Vec<PerDispatchClass>;
|
||||
'Vec<PerDispatchClassU32>': Vec<PerDispatchClassU32>;
|
||||
'Vec<PerDispatchClassWeight>': Vec<PerDispatchClassWeight>;
|
||||
'Vec<PerDispatchClassWeightsPerClass>': Vec<PerDispatchClassWeightsPerClass>;
|
||||
'Vec<Period>': Vec<Period>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
'Vec<PermissionLatest>': Vec<PermissionLatest>;
|
||||
@@ -1370,8 +1400,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<RawBabePreDigestSecondaryVRF>': Vec<RawBabePreDigestSecondaryVRF>;
|
||||
'Vec<RawBabePreDigestTo159>': Vec<RawBabePreDigestTo159>;
|
||||
'Vec<RawOrigin>': Vec<RawOrigin>;
|
||||
'Vec<RawSolution>': Vec<RawSolution>;
|
||||
'Vec<RawVRFOutput>': Vec<RawVRFOutput>;
|
||||
'Vec<ReadProof>': Vec<ReadProof>;
|
||||
'Vec<ReadySolution>': Vec<ReadySolution>;
|
||||
'Vec<Reasons>': Vec<Reasons>;
|
||||
'Vec<RecoveryConfig>': Vec<RecoveryConfig>;
|
||||
'Vec<RefCount>': Vec<RefCount>;
|
||||
@@ -1401,6 +1433,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<RewardDestination>': Vec<RewardDestination>;
|
||||
'Vec<RewardDestinationTo257>': Vec<RewardDestinationTo257>;
|
||||
'Vec<RewardPoint>': Vec<RewardPoint>;
|
||||
'Vec<RoundSnapshot>': Vec<RoundSnapshot>;
|
||||
'Vec<RoundState>': Vec<RoundState>;
|
||||
'Vec<RpcMethods>': Vec<RpcMethods>;
|
||||
'Vec<RuntimeDbWeight>': Vec<RuntimeDbWeight>;
|
||||
@@ -1414,6 +1447,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<SchedulePriority>': Vec<SchedulePriority>;
|
||||
'Vec<ScheduleTo212>': Vec<ScheduleTo212>;
|
||||
'Vec<ScheduleTo258>': Vec<ScheduleTo258>;
|
||||
'Vec<ScheduleTo264>': Vec<ScheduleTo264>;
|
||||
'Vec<Scheduling>': Vec<Scheduling>;
|
||||
'Vec<Seal>': Vec<Seal>;
|
||||
'Vec<SealV0>': Vec<SealV0>;
|
||||
@@ -1459,6 +1493,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<SlotRange>': Vec<SlotRange>;
|
||||
'Vec<SocietyJudgement>': Vec<SocietyJudgement>;
|
||||
'Vec<SocietyVote>': Vec<SocietyVote>;
|
||||
'Vec<SolutionOrSnapshotSize>': Vec<SolutionOrSnapshotSize>;
|
||||
'Vec<SolutionSupport>': Vec<SolutionSupport>;
|
||||
'Vec<SolutionSupports>': Vec<SolutionSupports>;
|
||||
'Vec<SpanIndex>': Vec<SpanIndex>;
|
||||
'Vec<SpanRecord>': Vec<SpanRecord>;
|
||||
'Vec<Sr25519Signature>': Vec<Sr25519Signature>;
|
||||
@@ -1569,6 +1606,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<Votes>': Vec<Votes>;
|
||||
'Vec<VotesTo230>': Vec<VotesTo230>;
|
||||
'Vec<VoteThreshold>': Vec<VoteThreshold>;
|
||||
'Vec<VoteWeight>': Vec<VoteWeight>;
|
||||
'Vec<Voting>': Vec<Voting>;
|
||||
'Vec<VotingDelegating>': Vec<VotingDelegating>;
|
||||
'Vec<VotingDirect>': Vec<VotingDirect>;
|
||||
@@ -1611,6 +1649,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountVoteSplit: AccountVoteSplit;
|
||||
AccountVoteStandard: AccountVoteStandard;
|
||||
ActiveEraInfo: ActiveEraInfo;
|
||||
ActiveGilt: ActiveGilt;
|
||||
ActiveGiltsTotal: ActiveGiltsTotal;
|
||||
ActiveIndex: ActiveIndex;
|
||||
ActiveRecovery: ActiveRecovery;
|
||||
Address: Address;
|
||||
AliveContractInfo: AliveContractInfo;
|
||||
@@ -1682,6 +1723,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ChainProperties: ChainProperties;
|
||||
ChainType: ChainType;
|
||||
ChangesTrieConfiguration: ChangesTrieConfiguration;
|
||||
CodecHash: CodecHash;
|
||||
CodeHash: CodeHash;
|
||||
CollatorId: CollatorId;
|
||||
CollatorSignature: CollatorSignature;
|
||||
@@ -1834,6 +1876,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExitRevert: ExitRevert;
|
||||
ExitSucceed: ExitSucceed;
|
||||
Exposure: Exposure;
|
||||
ExtendedBalance: ExtendedBalance;
|
||||
Extrinsic: Extrinsic;
|
||||
ExtrinsicEra: ExtrinsicEra;
|
||||
ExtrinsicMetadataLatest: ExtrinsicMetadataLatest;
|
||||
@@ -1871,6 +1914,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
FundIndex: FundIndex;
|
||||
FundInfo: FundInfo;
|
||||
Gas: Gas;
|
||||
GiltBid: GiltBid;
|
||||
GlobalValidationSchedule: GlobalValidationSchedule;
|
||||
GrandpaEquivocation: GrandpaEquivocation;
|
||||
GrandpaEquivocationProof: GrandpaEquivocationProof;
|
||||
@@ -1892,6 +1936,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
HeartbeatTo244: HeartbeatTo244;
|
||||
HostConfiguration: HostConfiguration;
|
||||
HostFnWeights: HostFnWeights;
|
||||
HostFnWeightsTo264: HostFnWeightsTo264;
|
||||
HrmpChannel: HrmpChannel;
|
||||
HrmpChannelId: HrmpChannelId;
|
||||
HrmpOpenChannelRequest: HrmpOpenChannelRequest;
|
||||
@@ -1947,6 +1992,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
LeasePeriod: LeasePeriod;
|
||||
LeasePeriodOf: LeasePeriodOf;
|
||||
Limits: Limits;
|
||||
LimitsTo264: LimitsTo264;
|
||||
LocalValidationData: LocalValidationData;
|
||||
LockIdentifier: LockIdentifier;
|
||||
LookupSource: LookupSource;
|
||||
@@ -2051,8 +2097,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
PendingResume: PendingResume;
|
||||
Perbill: Perbill;
|
||||
Percent: Percent;
|
||||
PerDispatchClass: PerDispatchClass;
|
||||
PerDispatchClassU32: PerDispatchClassU32;
|
||||
PerDispatchClassWeight: PerDispatchClassWeight;
|
||||
PerDispatchClassWeightsPerClass: PerDispatchClassWeightsPerClass;
|
||||
Period: Period;
|
||||
Permill: Permill;
|
||||
PermissionLatest: PermissionLatest;
|
||||
@@ -2097,8 +2144,10 @@ declare module '@polkadot/types/types/registry' {
|
||||
RawBabePreDigestSecondaryVRF: RawBabePreDigestSecondaryVRF;
|
||||
RawBabePreDigestTo159: RawBabePreDigestTo159;
|
||||
RawOrigin: RawOrigin;
|
||||
RawSolution: RawSolution;
|
||||
RawVRFOutput: RawVRFOutput;
|
||||
ReadProof: ReadProof;
|
||||
ReadySolution: ReadySolution;
|
||||
Reasons: Reasons;
|
||||
RecoveryConfig: RecoveryConfig;
|
||||
RefCount: RefCount;
|
||||
@@ -2128,6 +2177,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
RewardDestination: RewardDestination;
|
||||
RewardDestinationTo257: RewardDestinationTo257;
|
||||
RewardPoint: RewardPoint;
|
||||
RoundSnapshot: RoundSnapshot;
|
||||
RoundState: RoundState;
|
||||
RpcMethods: RpcMethods;
|
||||
RuntimeDbWeight: RuntimeDbWeight;
|
||||
@@ -2141,6 +2191,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
SchedulePriority: SchedulePriority;
|
||||
ScheduleTo212: ScheduleTo212;
|
||||
ScheduleTo258: ScheduleTo258;
|
||||
ScheduleTo264: ScheduleTo264;
|
||||
Scheduling: Scheduling;
|
||||
Seal: Seal;
|
||||
SealV0: SealV0;
|
||||
@@ -2186,6 +2237,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
SlotRange: SlotRange;
|
||||
SocietyJudgement: SocietyJudgement;
|
||||
SocietyVote: SocietyVote;
|
||||
SolutionOrSnapshotSize: SolutionOrSnapshotSize;
|
||||
SolutionSupport: SolutionSupport;
|
||||
SolutionSupports: SolutionSupports;
|
||||
SpanIndex: SpanIndex;
|
||||
SpanRecord: SpanRecord;
|
||||
Sr25519Signature: Sr25519Signature;
|
||||
@@ -2296,6 +2350,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
Votes: Votes;
|
||||
VotesTo230: VotesTo230;
|
||||
VoteThreshold: VoteThreshold;
|
||||
VoteWeight: VoteWeight;
|
||||
Voting: Voting;
|
||||
VotingDelegating: VotingDelegating;
|
||||
VotingDirect: VotingDirect;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { compactToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
@@ -36,7 +36,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyNumber, Codec, Registry } from '../types';
|
||||
import type { UIntBitLength } from './types';
|
||||
|
||||
@@ -95,7 +95,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
@@ -112,7 +112,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
/**
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, BareOpts, Codec, Registry } from '../types';
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ export abstract class Base<T extends Codec> implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces';
|
||||
import type { CodecHash } from '../interfaces';
|
||||
import type { AnyJson, AnyNumber, Constructor, ICompact, InterfaceTypes, Registry } from '../types';
|
||||
import type { CompactEncodable, UIntBitLength } from './types';
|
||||
|
||||
@@ -63,7 +63,7 @@ export class Compact<T extends CompactEncodable> implements ICompact<T> {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyNumber, Codec, Registry } from '../types';
|
||||
import type { UIntBitLength } from './types';
|
||||
|
||||
@@ -55,7 +55,7 @@ export class CodecDate extends Date implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -359,6 +359,46 @@ describe('Enum', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('indexed enum', (): void => {
|
||||
const Test = Enum.with({
|
||||
A: 5,
|
||||
B: 42,
|
||||
C: 69,
|
||||
D: 255
|
||||
});
|
||||
|
||||
it('handles an indexed C-like enum', (): void => {
|
||||
expect(new Test(registry, 'A').toNumber()).toEqual(5);
|
||||
expect(new Test(registry, 'B').toNumber()).toEqual(42);
|
||||
expect(new Test(registry, 'C').toNumber()).toEqual(69);
|
||||
expect(new Test(registry, 69).toNumber()).toEqual(69);
|
||||
expect(new Test(registry, 'D').toNumber()).toEqual(255);
|
||||
});
|
||||
|
||||
it('creates proper raw structure', (): void => {
|
||||
expect(new Test(registry).toRawType()).toEqual(JSON.stringify({
|
||||
_enum: {
|
||||
A: 5,
|
||||
B: 42,
|
||||
C: 69,
|
||||
D: 255
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it('has the indexes for the enum', (): void => {
|
||||
expect(new Test(registry).defIndexes).toEqual([5, 42, 69, 255]);
|
||||
});
|
||||
|
||||
it('has the correct outputs', (): void => {
|
||||
const test = new Test(registry, 5);
|
||||
|
||||
expect(test.toU8a()).toEqual(new Uint8Array([5]));
|
||||
expect(test.toHex()).toEqual('0x05');
|
||||
expect(test.toJSON()).toEqual('A');
|
||||
});
|
||||
});
|
||||
|
||||
describe('toHex', (): void => {
|
||||
it('has a proper hex representation & length', (): void => {
|
||||
const Test = Enum.with({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces';
|
||||
import type { CodecHash } from '../interfaces';
|
||||
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
@@ -15,56 +15,100 @@ export interface EnumConstructor<T = Codec> {
|
||||
new(registry: Registry, value?: any, index?: number): T;
|
||||
}
|
||||
|
||||
type TypesDef = Record<string, Constructor>;
|
||||
interface EntryDef {
|
||||
Type: Constructor;
|
||||
index: number;
|
||||
}
|
||||
|
||||
type TypesDef = Record<string, EntryDef>;
|
||||
|
||||
interface Decoded {
|
||||
index: number;
|
||||
value: Codec;
|
||||
}
|
||||
|
||||
function extractDef (registry: Registry, _def: Record<string, keyof InterfaceTypes | Constructor> | string[]): { def: TypesDef; isBasic: boolean } {
|
||||
if (!Array.isArray(_def)) {
|
||||
const def = mapToTypeMap(registry, _def);
|
||||
const isBasic = !Object.values(def).some((type): boolean => type !== Null);
|
||||
function isRustEnum (def: Record<string, keyof InterfaceTypes | Constructor> | Record<string, number>): def is Record<string, keyof InterfaceTypes | Constructor> {
|
||||
const defValues = Object.values(def);
|
||||
|
||||
if (defValues.some((v) => isNumber(v))) {
|
||||
assert(defValues.every((v) => isNumber(v) && v >= 0 && v <= 255), 'Invalid number-indexed enum definition');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function extractDef (registry: Registry, _def: Record<string, keyof InterfaceTypes | Constructor> | Record<string, number> | string[]): { def: TypesDef; isBasic: boolean; isIndexed: boolean } {
|
||||
if (Array.isArray(_def)) {
|
||||
return {
|
||||
def,
|
||||
isBasic
|
||||
def: _def.reduce((def: TypesDef, key, index): TypesDef => {
|
||||
def[key] = { Type: Null, index };
|
||||
|
||||
return def;
|
||||
}, {}),
|
||||
isBasic: true,
|
||||
isIndexed: false
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
def: _def.reduce((def, key): TypesDef => {
|
||||
def[key] = Null;
|
||||
let isBasic: boolean;
|
||||
let isIndexed: boolean;
|
||||
let def: TypesDef;
|
||||
|
||||
return def;
|
||||
}, {} as TypesDef),
|
||||
isBasic: true
|
||||
if (isRustEnum(_def)) {
|
||||
def = Object
|
||||
.entries(mapToTypeMap(registry, _def))
|
||||
.reduce((def: TypesDef, [key, Type], index): TypesDef => {
|
||||
def[key] = { Type, index };
|
||||
|
||||
return def;
|
||||
}, {});
|
||||
isBasic = !Object.values(def).some(({ Type }) => Type !== Null);
|
||||
isIndexed = false;
|
||||
} else {
|
||||
def = Object
|
||||
.entries(_def)
|
||||
.reduce((def: TypesDef, [key, index]): TypesDef => {
|
||||
def[key] = { Type: Null, index };
|
||||
|
||||
return def;
|
||||
}, {});
|
||||
isBasic = true;
|
||||
isIndexed = true;
|
||||
}
|
||||
|
||||
return {
|
||||
def,
|
||||
isBasic,
|
||||
isIndexed
|
||||
};
|
||||
}
|
||||
|
||||
function createFromValue (registry: Registry, def: TypesDef, index = 0, value?: any): Decoded {
|
||||
const Clazz = Object.values(def)[index];
|
||||
const entry = Object.values(def).find((e) => e.index === index);
|
||||
|
||||
assert(!isUndefined(Clazz), `Unable to create Enum via index ${index}, in ${Object.keys(def).join(', ')}`);
|
||||
assert(!isUndefined(entry), `Unable to create Enum via index ${index}, in ${Object.keys(def).join(', ')}`);
|
||||
|
||||
return {
|
||||
index,
|
||||
value: value instanceof Clazz ? value : new Clazz(registry, value)
|
||||
value: value instanceof entry.Type
|
||||
? value
|
||||
: new entry.Type(registry, value)
|
||||
};
|
||||
}
|
||||
|
||||
function decodeFromJSON (registry: Registry, def: TypesDef, key: string, value?: any): Decoded {
|
||||
// JSON comes in the form of { "<type (lowercased)>": "<value for type>" }, here we
|
||||
// additionally force to lower to ensure forward compat
|
||||
const keys = Object.keys(def).map((k): string => k.toLowerCase());
|
||||
const keys = Object.keys(def).map((k) => k.toLowerCase());
|
||||
const keyLower = key.toLowerCase();
|
||||
const index = keys.indexOf(keyLower);
|
||||
|
||||
assert(index !== -1, `Cannot map Enum JSON, unable to find '${key}' in ${keys.join(', ')}`);
|
||||
|
||||
try {
|
||||
return createFromValue(registry, def, index, value);
|
||||
return createFromValue(registry, def, Object.values(def)[index].index, value);
|
||||
} catch (error) {
|
||||
throw new Error(`Enum(${key}):: ${(error as Error).message}`);
|
||||
}
|
||||
@@ -79,7 +123,10 @@ function decodeFromString (registry: Registry, def: TypesDef, value: string): De
|
||||
|
||||
function decodeFromValue (registry: Registry, def: TypesDef, value?: any): Decoded {
|
||||
if (isU8a(value)) {
|
||||
return createFromValue(registry, def, value[0], value.subarray(1));
|
||||
// nested, we don't want to match isObject below
|
||||
if (value.length) {
|
||||
return createFromValue(registry, def, value[0], value.subarray(1));
|
||||
}
|
||||
} else if (isNumber(value)) {
|
||||
return createFromValue(registry, def, value);
|
||||
} else if (isString(value)) {
|
||||
@@ -91,7 +138,7 @@ function decodeFromValue (registry: Registry, def: TypesDef, value?: any): Decod
|
||||
}
|
||||
|
||||
// Worst-case scenario, return the first with default
|
||||
return createFromValue(registry, def, 0);
|
||||
return createFromValue(registry, def, Object.values(def)[0].index);
|
||||
}
|
||||
|
||||
function decodeEnum (registry: Registry, def: TypesDef, value?: any, index?: number): Decoded {
|
||||
@@ -104,7 +151,6 @@ function decodeEnum (registry: Registry, def: TypesDef, value?: any, index?: num
|
||||
return createFromValue(registry, def, value.index, value.value);
|
||||
}
|
||||
|
||||
// Or else, we just look at `value`
|
||||
return decodeFromValue(registry, def, value);
|
||||
}
|
||||
|
||||
@@ -122,27 +168,30 @@ export class Enum implements Codec {
|
||||
|
||||
readonly #def: TypesDef;
|
||||
|
||||
readonly #index: number;
|
||||
readonly #entryIndex: number;
|
||||
|
||||
readonly #indexes: number[];
|
||||
|
||||
readonly #isBasic: boolean;
|
||||
|
||||
readonly #isIndexed: boolean;
|
||||
|
||||
readonly #raw: Codec;
|
||||
|
||||
constructor (registry: Registry, def: Record<string, keyof InterfaceTypes | Constructor> | string[], value?: unknown, index?: number) {
|
||||
constructor (registry: Registry, def: Record<string, keyof InterfaceTypes | Constructor> | Record<string, number> | string[], value?: unknown, index?: number) {
|
||||
const defInfo = extractDef(registry, def);
|
||||
const decoded = decodeEnum(registry, defInfo.def, value, index);
|
||||
|
||||
this.registry = registry;
|
||||
this.#def = defInfo.def;
|
||||
this.#isBasic = defInfo.isBasic;
|
||||
this.#indexes = Object.keys(defInfo.def).map((_, index): number => index);
|
||||
this.#index = this.#indexes.indexOf(decoded.index) || 0;
|
||||
this.#isIndexed = defInfo.isIndexed;
|
||||
this.#indexes = Object.values(defInfo.def).map(({ index }) => index);
|
||||
this.#entryIndex = this.#indexes.indexOf(decoded.index) || 0;
|
||||
this.#raw = decoded.value;
|
||||
}
|
||||
|
||||
public static with (Types: Record<string, keyof InterfaceTypes | Constructor> | string[]): EnumConstructor<Enum> {
|
||||
public static with (Types: Record<string, keyof InterfaceTypes | Constructor> | Record<string, number> | string[]): EnumConstructor<Enum> {
|
||||
return class extends Enum {
|
||||
constructor (registry: Registry, value?: unknown, index?: number) {
|
||||
super(registry, Types, value, index);
|
||||
@@ -182,15 +231,15 @@ export class Enum implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The index of the metadata value
|
||||
* @description The index of the enum value
|
||||
*/
|
||||
public get index (): number {
|
||||
return this.#index;
|
||||
return this.#indexes[this.#entryIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,8 +273,8 @@ export class Enum implements Codec {
|
||||
/**
|
||||
* @description The available keys for this enum
|
||||
*/
|
||||
public get defEntries (): string[] {
|
||||
return Object.keys(this.#def);
|
||||
public get defIndexes (): number[] {
|
||||
return this.#indexes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +288,7 @@ export class Enum implements Codec {
|
||||
* @description The name of the type this enum value represents
|
||||
*/
|
||||
public get type (): string {
|
||||
return this.defKeys[this.#index];
|
||||
return this.defKeys[this.#entryIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,16 +350,32 @@ export class Enum implements Codec {
|
||||
* @description Returns the number representation for the value
|
||||
*/
|
||||
public toNumber (): number {
|
||||
return this.#index;
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a raw struct representation of the enum types
|
||||
*/
|
||||
protected _toRawStruct (): string[] | Record<string, string> {
|
||||
return this.#isBasic
|
||||
? this.defKeys
|
||||
: Struct.typesToMap(this.registry, this.#def);
|
||||
protected _toRawStruct (): string[] | Record<string, string | number> {
|
||||
if (this.#isBasic) {
|
||||
return this.#isIndexed
|
||||
? this.defKeys.reduce((out: Record<string, number>, key, index): Record<string, number> => {
|
||||
out[key] = this.#indexes[index];
|
||||
|
||||
return out;
|
||||
}, {})
|
||||
: this.defKeys;
|
||||
}
|
||||
|
||||
const typeMap = Object
|
||||
.entries(this.#def)
|
||||
.reduce((out: Record<string, Constructor>, [key, { Type }]) => {
|
||||
out[key] = Type;
|
||||
|
||||
return out;
|
||||
}, {});
|
||||
|
||||
return Struct.typesToMap(this.registry, typeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,7 +400,7 @@ export class Enum implements Codec {
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
return u8aConcat(
|
||||
new Uint8Array(isBare ? [] : [this.#indexes[this.#index]]),
|
||||
new Uint8Array(isBare ? [] : [this.index]),
|
||||
this.#raw.toU8a(isBare)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { isFunction, isUndefined } from '@polkadot/util';
|
||||
@@ -50,7 +50,7 @@ export class Json extends Map<string, any> implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
@@ -119,7 +119,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
||||
/**
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces';
|
||||
import type { CodecHash } from '../interfaces';
|
||||
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { assert, isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
|
||||
@@ -79,7 +79,7 @@ export class Option<T extends Codec> implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, AnyU8a, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
|
||||
@@ -34,7 +34,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { Codec, Constructor, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@@ -121,7 +121,7 @@ export class CodecSet extends Set<string> implements Codec {
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { CodecHash } from '../interfaces/runtime';
|
||||
import type { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
@@ -224,7 +224,7 @@ export class Struct<
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,19 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
|
||||
[TypeDefInfo.DoNotConstruct]: (registry: Registry, value: TypeDef): Constructor => DoNotConstruct.with(value.displayName),
|
||||
|
||||
[TypeDefInfo.Enum]: (registry: Registry, value: TypeDef): Constructor => Enum.with(getTypeClassMap(value)),
|
||||
[TypeDefInfo.Enum]: (registry: Registry, value: TypeDef): Constructor => {
|
||||
const subs = getSubDefArray(value);
|
||||
|
||||
return Enum.with(
|
||||
subs.every(({ type }) => type === 'Null')
|
||||
? subs.reduce((out: Record<string, number>, { index, name }, count): Record<string, number> => {
|
||||
out[name as string] = index || count;
|
||||
|
||||
return out;
|
||||
}, {})
|
||||
: getTypeClassMap(value)
|
||||
);
|
||||
},
|
||||
|
||||
[TypeDefInfo.HashMap]: (registry: Registry, value: TypeDef): Constructor => createHashMap(value, HashMap),
|
||||
|
||||
|
||||
@@ -57,12 +57,18 @@ describe('createType', (): void => {
|
||||
).toEqual('B');
|
||||
});
|
||||
|
||||
it('allows creation of a Enum (parametrised)', (): void => {
|
||||
it('allows creation of a Enum (with types)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '{"_enum": {"A": null, "B": "u32", "C": null} }', [1]).toJSON()
|
||||
).toEqual({ B: 0 });
|
||||
});
|
||||
|
||||
it('allows creation of a Enum (with indexes)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '{"_enum": {"A": 42, "B": 69, "C": 255} }', [69]).toJSON()
|
||||
).toEqual('B');
|
||||
});
|
||||
|
||||
it('allows creation of a Result', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Result<u32,Text>', ['0x011064656667']).toJSON()
|
||||
|
||||
@@ -118,7 +118,7 @@ const encoders: Record<TypeDefInfo, (typeDef: TypeDef) => string> = {
|
||||
[TypeDefInfo.VecFixed]: (typeDef: TypeDef): string => encodeVecFixed(typeDef)
|
||||
};
|
||||
|
||||
function encodeType (typeDef:TypeDef): string {
|
||||
function encodeType (typeDef: TypeDef): string {
|
||||
const encoder = encoders[typeDef.info];
|
||||
|
||||
assert(encoder, `Cannot encode type: ${JSON.stringify(typeDef)}`);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { TypeDef } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
import { assert, isNumber } from '@polkadot/util';
|
||||
|
||||
import { sanitize } from './sanitize';
|
||||
import { TypeDefInfo } from './types';
|
||||
@@ -16,23 +16,47 @@ interface TypeDefOptions {
|
||||
|
||||
const MAX_NESTED = 64;
|
||||
|
||||
function isRustEnum (details: Record<string, string> | Record<string, number>): details is Record<string, string> {
|
||||
const values = Object.values(details);
|
||||
|
||||
if (values.some((v) => isNumber(v))) {
|
||||
assert(values.every((v) => isNumber(v) && v >= 0 && v <= 255), 'Invalid number-indexed enum definition');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// decode an enum of either of the following forms
|
||||
// { _enum: ['A', 'B', 'C'] }
|
||||
// { _enum: { A: AccountId, B: Balance, C: u32 } }
|
||||
function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>, count: number): TypeDef {
|
||||
// { _enum: { A: 1, B: 2 } }
|
||||
function _decodeEnum (value: TypeDef, details: string[] | Record<string, string> | Record<string, number>, count: number): TypeDef {
|
||||
value.info = TypeDefInfo.Enum;
|
||||
|
||||
// not as pretty, but remain compatible with oo7 for both struct and Array types
|
||||
value.sub = Array.isArray(details)
|
||||
? details.map((name): TypeDef => ({
|
||||
if (Array.isArray(details)) {
|
||||
value.sub = details.map((name, index): TypeDef => ({
|
||||
index,
|
||||
info: TypeDefInfo.Plain,
|
||||
name,
|
||||
type: 'Null'
|
||||
}))
|
||||
: Object.entries(details).map(([name, type]): TypeDef =>
|
||||
}));
|
||||
} else if (isRustEnum(details)) {
|
||||
value.sub = Object.entries(details).map(([name, type], index): TypeDef => ({
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
getTypeDef(type || 'Null', { name }, count)
|
||||
);
|
||||
...getTypeDef(type || 'Null', { name }, count),
|
||||
index
|
||||
}));
|
||||
} else {
|
||||
value.sub = Object.entries(details).map(([name, index]): TypeDef => ({
|
||||
index,
|
||||
info: TypeDefInfo.Plain,
|
||||
name,
|
||||
type: 'Null'
|
||||
}));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
||||
import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
|
||||
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
|
||||
import type { ChainProperties, CodecHash, DispatchErrorModule } from '../interfaces/types';
|
||||
import type { CallFunction, Codec, CodecHasher, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
|
||||
|
||||
// we are attempting to avoid circular refs, hence the Metadata path import
|
||||
import { decorateConstants, decorateExtrinsics } from '@polkadot/metadata/decorate';
|
||||
@@ -315,8 +315,8 @@ export class TypeRegistry implements Registry {
|
||||
return !this.#unknownTypes.get(name) && (this.hasClass(name) || this.hasDef(name));
|
||||
}
|
||||
|
||||
public hash (data: Uint8Array): H256 {
|
||||
return this.createType('H256', this.#hasher(data));
|
||||
public hash (data: Uint8Array): CodecHash {
|
||||
return this.createType('CodecHash', this.#hasher(data));
|
||||
}
|
||||
|
||||
public register (type: Constructor | RegistryTypes): void;
|
||||
@@ -368,8 +368,8 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
}
|
||||
|
||||
setHasher (hasher: (data: Uint8Array) => Uint8Array = blake2AsU8a): void {
|
||||
this.#hasher = hasher;
|
||||
setHasher (hasher?: CodecHasher | null): void {
|
||||
this.#hasher = hasher || blake2AsU8a;
|
||||
}
|
||||
|
||||
setKnownTypes (knownTypes: RegisteredTypes): void {
|
||||
|
||||
@@ -1,25 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
||||
//
|
||||
// new URL(import.meta.url).pathname)
|
||||
//
|
||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
||||
// there is a complete dead end with usage thereof
|
||||
//
|
||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
||||
//
|
||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
||||
//
|
||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
||||
|
||||
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import packageInfo from './package-info.json';
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
||||
|
||||
export { packageInfo };
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [metaInfo]);
|
||||
|
||||
@@ -168,7 +168,7 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends Base<ExtrinsicVx | Extr
|
||||
* - left as is, to create an inherent
|
||||
*/
|
||||
export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBase<A> implements IExtrinsic<A> {
|
||||
constructor (registry: Registry, value: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call | undefined, { version }: CreateOptions = {}) {
|
||||
constructor (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, { version }: CreateOptions = {}) {
|
||||
super(registry, GenericExtrinsic._decodeExtrinsic(registry, value, version));
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeExtrinsic (registry: Registry, value: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call | undefined, version: number = DEFAULT_VERSION): ExtrinsicVx | ExtrinsicUnknown {
|
||||
private static _decodeExtrinsic (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, version: number = DEFAULT_VERSION): ExtrinsicVx | ExtrinsicUnknown {
|
||||
if (isU8a(value) || Array.isArray(value) || isHex(value)) {
|
||||
return GenericExtrinsic._decodeU8a(registry, u8aToU8a(value), version);
|
||||
} else if (value instanceof registry.createClass('Call')) {
|
||||
|
||||
@@ -36,12 +36,12 @@ const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
* on the contents included
|
||||
*/
|
||||
export class GenericExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
constructor (registry: Registry, value: Partial<ExtrinsicPayloadValue> | Uint8Array | string | undefined, { version }: ExtrinsicPayloadOptions = {}) {
|
||||
constructor (registry: Registry, value?: Partial<ExtrinsicPayloadValue> | Uint8Array | string, { version }: ExtrinsicPayloadOptions = {}) {
|
||||
super(registry, GenericExtrinsicPayload.decodeExtrinsicPayload(registry, value as ExtrinsicPayloadValue, version));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicPayload (registry: Registry, value: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string | undefined, version: number = DEFAULT_VERSION): ExtrinsicPayloadVx {
|
||||
public static decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string, version: number = DEFAULT_VERSION): ExtrinsicPayloadVx {
|
||||
if (value instanceof GenericExtrinsicPayload) {
|
||||
return value._raw;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ registry.setMetadata(metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('ExtrinsicV4', (): void => {
|
||||
it.only('constructs a sane Uint8Array (default)', (): void => {
|
||||
it('constructs a sane Uint8Array (default)', (): void => {
|
||||
expect(
|
||||
new Extrinsic(registry).toU8a()
|
||||
).toEqual(new Uint8Array([
|
||||
@@ -37,7 +37,7 @@ describe('ExtrinsicV4', (): void => {
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'0600' + // balance.transfer
|
||||
'ff' +
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
@@ -65,14 +65,14 @@ describe('ExtrinsicV4', (): void => {
|
||||
}).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'ff' +
|
||||
'00' +
|
||||
'd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' +
|
||||
'00' + // ed25519
|
||||
'b8065808da3d11ddb4167afb156eafb51e8104ba792589bb443653a7fab82b90' +
|
||||
'c6530e838df06bfc8befcbbcfca7e219350cff865439b815b10b8e64ae1e9b01' +
|
||||
'ab31e8dbdbf37398f9a42cfe473e17f6e2e05d8d7a1612513fa73f5f6ad3bfdb' +
|
||||
'adbabd920d033ad48999d9dc6a07e3e7ffb9a503128c94bf4fd97aeb4523f90e' +
|
||||
'000408' + // era. nonce, tip
|
||||
'0600' +
|
||||
'ff' +
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
|
||||
@@ -58,9 +58,9 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry, undefined).signFake(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
pairs.alice.publicKey,
|
||||
signOptions
|
||||
).toHex()
|
||||
).toEqual(
|
||||
@@ -74,7 +74,7 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
);
|
||||
});
|
||||
|
||||
it('fake signs default', (): void => {
|
||||
it('fake signs default (AccountId address)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
});
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry, undefined).signFake(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
signOptions
|
||||
@@ -102,4 +102,27 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
'00a50100'
|
||||
);
|
||||
});
|
||||
|
||||
it('injects a signature', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).addSignature(
|
||||
pairs.alice.publicKey,
|
||||
new Uint8Array(65).fill(1),
|
||||
new Uint8Array(0)
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'00' + // MultiAddress
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
'01' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'000000'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import type { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import type { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
import { isU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Compact } from '../../codec/Compact';
|
||||
import { Enum } from '../../codec/Enum';
|
||||
@@ -17,6 +17,10 @@ import { GenericExtrinsicPayloadV4 } from './ExtrinsicPayload';
|
||||
const FAKE_NONE = new Uint8Array();
|
||||
const FAKE_SOME = new Uint8Array([1]);
|
||||
|
||||
function toAddress (registry: Registry, address: Address | Uint8Array | string): Address {
|
||||
return registry.createType('Address', isU8a(address) ? u8aToHex(address) : address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicSignatureV4
|
||||
* @description
|
||||
@@ -25,7 +29,7 @@ const FAKE_SOME = new Uint8Array([1]);
|
||||
export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSignature {
|
||||
#fakePrefix: Uint8Array;
|
||||
|
||||
constructor (registry: Registry, value: GenericExtrinsicSignatureV4 | Uint8Array | undefined, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
constructor (registry: Registry, value?: GenericExtrinsicSignatureV4 | Uint8Array, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
super(registry, {
|
||||
signer: 'Address',
|
||||
// eslint-disable-next-line sort-keys
|
||||
@@ -39,7 +43,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicSignature (value: GenericExtrinsicSignatureV4 | Uint8Array | undefined, isSigned = false): GenericExtrinsicSignatureV4 | Uint8Array {
|
||||
public static decodeExtrinsicSignature (value?: GenericExtrinsicSignatureV4 | Uint8Array, isSigned = false): GenericExtrinsicSignatureV4 | Uint8Array {
|
||||
if (!value) {
|
||||
return EMPTY_U8A;
|
||||
} else if (value instanceof GenericExtrinsicSignatureV4) {
|
||||
@@ -125,7 +129,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): IExtrinsicSignature {
|
||||
return this._injectSignature(
|
||||
this.registry.createType('Address', signer),
|
||||
toAddress(this.registry, signer),
|
||||
this.registry.createType('ExtrinsicSignature', signature),
|
||||
new GenericExtrinsicPayloadV4(this.registry, payload)
|
||||
);
|
||||
@@ -151,7 +155,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const signer = toAddress(this.registry, account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('ExtrinsicSignature', payload.sign(account));
|
||||
|
||||
@@ -162,7 +166,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
* @description Generate a payload and applies a fake signature
|
||||
*/
|
||||
public signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = toAddress(this.registry, address);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('ExtrinsicSignature', u8aConcat(this.#fakePrefix, new Uint8Array(64).fill(0x42)));
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Vec } from '../codec/Vec';
|
||||
import type { GenericExtrinsic } from '../extrinsic/Extrinsic';
|
||||
import type { Digest, DigestItem, H256, Header } from '../interfaces/runtime';
|
||||
import type { CodecHash, Digest, DigestItem, Header } from '../interfaces/runtime';
|
||||
import type { AnyNumber, AnyU8a, Registry } from '../types';
|
||||
|
||||
import { Struct } from '../codec/Struct';
|
||||
@@ -38,7 +38,7 @@ export class GenericBlock extends Struct {
|
||||
/**
|
||||
* @description Encodes a content [[Hash]] for the block
|
||||
*/
|
||||
public get contentHash (): H256 {
|
||||
public get contentHash (): CodecHash {
|
||||
return this.registry.hash(this.toU8a());
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class GenericBlock extends Struct {
|
||||
/**
|
||||
* @description Block/header [[Hash]]
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
public get hash (): CodecHash {
|
||||
return this.header.hash;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ describe('Call', (): void => {
|
||||
|
||||
it('handles creation from a hex value properly', (): void => {
|
||||
expect(
|
||||
new Call(registry, '0x0601').toU8a()
|
||||
new Call(registry, '0x06010000000000000000000000000000000000000000000000000000000000000000').toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([6, 1, 1, 110, 7, 17, 0, 0, 0])
|
||||
new Uint8Array([6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||
); // balances.setBalance
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,12 +12,10 @@ 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
|
||||
const CID_AURA = 0x61727561; // 'aura'
|
||||
const CID_BABE = 0x45424142; // 'BABE'
|
||||
const CID_GRPA = 0x4b4e5246; // 'FRNK' (don't ask, used to be afg1)
|
||||
const CID_POW = 0x5f776f70; // 'pow_'
|
||||
|
||||
export { CID_AURA, CID_BABE, CID_GRPA, CID_POW };
|
||||
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_'
|
||||
|
||||
/**
|
||||
* @name GenericConsensusEngineId
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
|
||||
describe('MultiAddress', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('decodes from an empty value', (): void => {
|
||||
const a = registry.createType('MultiAddress');
|
||||
|
||||
expect(a.index).toEqual(0);
|
||||
expect(a.toHex()).toEqual('0x000000000000000000000000000000000000000000000000000000000000000000');
|
||||
});
|
||||
|
||||
it('correctly decodes a stream with Address20', (): void => {
|
||||
const a = registry.createType('MultiAddress', '0x0467f89207abe6e1b093befd84a48f03313765929207009e292608');
|
||||
|
||||
expect(a.index).toEqual(4);
|
||||
expect(a.toString()).toEqual('0x67f89207abe6e1b093befd84a48f033137659292');
|
||||
});
|
||||
|
||||
it('correctly decodes an AccountId', (): void => {
|
||||
const a = registry.createType('MultiAddress', '0x0102030405060708010203040506070801020304050607080102030405060708');
|
||||
|
||||
expect(a.index).toEqual(0);
|
||||
expect(a.toString()).toEqual('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
});
|
||||
|
||||
it('correctly decodes an AccountIndex', (): void => {
|
||||
const a = registry.createType('MultiAddress', '25GUyv');
|
||||
|
||||
expect(a.index).toEqual(1);
|
||||
expect(a.toString()).toEqual('25GUyv');
|
||||
});
|
||||
|
||||
it('correctly decodes an AccountIndex (AccountIndex input)', (): void => {
|
||||
const a = registry.createType('MultiAddress', registry.createType('AccountIndex', '25GUyv'));
|
||||
|
||||
expect(a.index).toEqual(1);
|
||||
expect(a.toString()).toEqual('25GUyv');
|
||||
});
|
||||
|
||||
it('correctly decodes an Address20', (): void => {
|
||||
const a = registry.createType('MultiAddress', '0x67f89207abe6e1b093befd84a48f033137659292');
|
||||
|
||||
expect(a.index).toEqual(4);
|
||||
expect(a.toString()).toEqual('0x67f89207abe6e1b093befd84a48f033137659292');
|
||||
});
|
||||
});
|
||||
@@ -10,18 +10,16 @@ import { Enum } from '../codec/Enum';
|
||||
import { GenericAccountId } from './AccountId';
|
||||
import { GenericAccountIndex } from './AccountIndex';
|
||||
|
||||
function decodeMultiU8a (registry: Registry, value?: unknown): unknown {
|
||||
if (isU8a(value) && value.length <= 32) {
|
||||
if (value.length === 32) {
|
||||
return { id: value };
|
||||
} else if (value.length === 20) {
|
||||
return { Address20: value };
|
||||
} else {
|
||||
return decodeMultiAny(registry, registry.createType('AccountIndex', value));
|
||||
}
|
||||
function decodeU8a (registry: Registry, u8a: Uint8Array): unknown {
|
||||
if ([0, 32].includes(u8a.length)) {
|
||||
return { Id: u8a };
|
||||
} else if (u8a.length === 20) {
|
||||
return { Address20: u8a };
|
||||
} else if (u8a.length <= 8) {
|
||||
return { Index: registry.createType('AccountIndex', u8a).toNumber() };
|
||||
}
|
||||
|
||||
return value;
|
||||
return u8a;
|
||||
}
|
||||
|
||||
function decodeMultiAny (registry: Registry, value?: unknown): unknown {
|
||||
@@ -29,13 +27,15 @@ function decodeMultiAny (registry: Registry, value?: unknown): unknown {
|
||||
return value;
|
||||
} else if (value instanceof GenericAccountId) {
|
||||
return { Id: value };
|
||||
} else if (value instanceof GenericAccountIndex || isNumber(value) || isBn(value)) {
|
||||
return { Index: registry.createType('Compact<AccountIndex>', value) };
|
||||
} else if (value instanceof GenericAccountIndex || isBn(value) || isNumber(value)) {
|
||||
return { Index: isNumber(value) ? value : value.toNumber() };
|
||||
} else if (isString(value)) {
|
||||
return decodeMultiU8a(registry, decodeAddress(value.toString()));
|
||||
return decodeU8a(registry, decodeAddress(value.toString()));
|
||||
} else if (isU8a(value)) {
|
||||
return decodeU8a(registry, value);
|
||||
}
|
||||
|
||||
return decodeMultiU8a(registry, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
export class GenericMultiAddress extends Enum {
|
||||
|
||||
@@ -6,3 +6,4 @@ import './detectPackage';
|
||||
export * from './codec';
|
||||
export * from './create';
|
||||
export * from './index.types';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
trieId: 'TrieId'
|
||||
},
|
||||
Gas: 'u64',
|
||||
HostFnWeights: {
|
||||
HostFnWeightsTo264: {
|
||||
caller: 'Weight',
|
||||
address: 'Weight',
|
||||
gasLeft: 'Weight',
|
||||
@@ -188,6 +188,58 @@ export default {
|
||||
hashBlake2128: 'Weight',
|
||||
hashBlake2128PerByte: 'Weight'
|
||||
},
|
||||
HostFnWeights: {
|
||||
caller: 'Weight',
|
||||
address: 'Weight',
|
||||
gasLeft: 'Weight',
|
||||
balance: 'Weight',
|
||||
valueTransferred: 'Weight',
|
||||
minimumBalance: 'Weight',
|
||||
tombstoneDeposit: 'Weight',
|
||||
rentAllowance: 'Weight',
|
||||
blockNumber: 'Weight',
|
||||
now: 'Weight',
|
||||
weightToFee: 'Weight',
|
||||
gas: 'Weight',
|
||||
input: 'Weight',
|
||||
inputPerByte: 'Weight',
|
||||
return: 'Weight',
|
||||
returnPerByte: 'Weight',
|
||||
terminate: 'Weight',
|
||||
terminatePerCodeByte: 'Weight',
|
||||
restoreTo: 'Weight',
|
||||
restoreToPerCallerCodeByte: 'Weight',
|
||||
restoreToPerTombstoneCodeByte: 'Weight',
|
||||
restoreToPerDelta: 'Weight',
|
||||
random: 'Weight',
|
||||
depositEvent: 'Weight',
|
||||
depositEventPerTopic: 'Weight',
|
||||
depositEventPerByte: 'Weight',
|
||||
setRentAllowance: 'Weight',
|
||||
setStorage: 'Weight',
|
||||
setStoragePerByte: 'Weight',
|
||||
clearStorage: 'Weight',
|
||||
getStorage: 'Weight',
|
||||
getStoragePerByte: 'Weight',
|
||||
transfer: 'Weight',
|
||||
call: 'Weight',
|
||||
callPerCodeByte: 'Weight',
|
||||
callTransferSurcharge: 'Weight',
|
||||
callPerInputByte: 'Weight',
|
||||
callPerOutputByte: 'Weight',
|
||||
instantiate: 'Weight',
|
||||
instantiatePerCodeByte: 'Weight',
|
||||
instantiatePerInputByte: 'Weight',
|
||||
instantiatePerOutputByte: 'Weight',
|
||||
hashSha2256: 'Weight',
|
||||
hashSha2256PerByte: 'Weight',
|
||||
hashKeccak256: 'Weight',
|
||||
hashKeccak256PerByte: 'Weight',
|
||||
hashBlake2256: 'Weight',
|
||||
hashBlake2256PerByte: 'Weight',
|
||||
hashBlake2128: 'Weight',
|
||||
hashBlake2128PerByte: 'Weight'
|
||||
},
|
||||
InstructionWeights: {
|
||||
i64const: 'u32',
|
||||
i64load: 'u32',
|
||||
@@ -241,7 +293,7 @@ export default {
|
||||
i64rotl: 'u32',
|
||||
i64rotr: 'u32'
|
||||
},
|
||||
Limits: {
|
||||
LimitsTo264: {
|
||||
eventTopics: 'u32',
|
||||
stackHeight: 'u32',
|
||||
globals: 'u32',
|
||||
@@ -252,6 +304,16 @@ export default {
|
||||
subjectLen: 'u32',
|
||||
codeSize: 'u32'
|
||||
},
|
||||
Limits: {
|
||||
eventTopics: 'u32',
|
||||
stackHeight: 'u32',
|
||||
globals: 'u32',
|
||||
parameters: 'u32',
|
||||
memoryPages: 'u32',
|
||||
tableSize: 'u32',
|
||||
brTableSize: 'u32',
|
||||
subjectLen: 'u32'
|
||||
},
|
||||
PrefabWasmModule: {
|
||||
scheduleVersion: 'Compact<u32>',
|
||||
initial: 'Compact<u32>',
|
||||
@@ -295,6 +357,13 @@ export default {
|
||||
enablePrintln: 'bool',
|
||||
maxSubjectLen: 'u32'
|
||||
},
|
||||
ScheduleTo264: {
|
||||
version: 'u32',
|
||||
enablePrintln: 'bool',
|
||||
limits: 'LimitsTo264',
|
||||
instructionWeights: 'InstructionWeights',
|
||||
hostFnWeights: 'HostFnWeightsTo264'
|
||||
},
|
||||
Schedule: {
|
||||
version: 'u32',
|
||||
enablePrintln: 'bool',
|
||||
|
||||
@@ -115,6 +115,60 @@ export interface Gas extends u64 {}
|
||||
|
||||
/** @name HostFnWeights */
|
||||
export interface HostFnWeights extends Struct {
|
||||
readonly caller: Weight;
|
||||
readonly address: Weight;
|
||||
readonly gasLeft: Weight;
|
||||
readonly balance: Weight;
|
||||
readonly valueTransferred: Weight;
|
||||
readonly minimumBalance: Weight;
|
||||
readonly tombstoneDeposit: Weight;
|
||||
readonly rentAllowance: Weight;
|
||||
readonly blockNumber: Weight;
|
||||
readonly now: Weight;
|
||||
readonly weightToFee: Weight;
|
||||
readonly gas: Weight;
|
||||
readonly input: Weight;
|
||||
readonly inputPerByte: Weight;
|
||||
readonly return: Weight;
|
||||
readonly returnPerByte: Weight;
|
||||
readonly terminate: Weight;
|
||||
readonly terminatePerCodeByte: Weight;
|
||||
readonly restoreTo: Weight;
|
||||
readonly restoreToPerCallerCodeByte: Weight;
|
||||
readonly restoreToPerTombstoneCodeByte: Weight;
|
||||
readonly restoreToPerDelta: Weight;
|
||||
readonly random: Weight;
|
||||
readonly depositEvent: Weight;
|
||||
readonly depositEventPerTopic: Weight;
|
||||
readonly depositEventPerByte: Weight;
|
||||
readonly setRentAllowance: Weight;
|
||||
readonly setStorage: Weight;
|
||||
readonly setStoragePerByte: Weight;
|
||||
readonly clearStorage: Weight;
|
||||
readonly getStorage: Weight;
|
||||
readonly getStoragePerByte: Weight;
|
||||
readonly transfer: Weight;
|
||||
readonly call: Weight;
|
||||
readonly callPerCodeByte: Weight;
|
||||
readonly callTransferSurcharge: Weight;
|
||||
readonly callPerInputByte: Weight;
|
||||
readonly callPerOutputByte: Weight;
|
||||
readonly instantiate: Weight;
|
||||
readonly instantiatePerCodeByte: Weight;
|
||||
readonly instantiatePerInputByte: Weight;
|
||||
readonly instantiatePerOutputByte: Weight;
|
||||
readonly hashSha2256: Weight;
|
||||
readonly hashSha2256PerByte: Weight;
|
||||
readonly hashKeccak256: Weight;
|
||||
readonly hashKeccak256PerByte: Weight;
|
||||
readonly hashBlake2256: Weight;
|
||||
readonly hashBlake2256PerByte: Weight;
|
||||
readonly hashBlake2128: Weight;
|
||||
readonly hashBlake2128PerByte: Weight;
|
||||
}
|
||||
|
||||
/** @name HostFnWeightsTo264 */
|
||||
export interface HostFnWeightsTo264 extends Struct {
|
||||
readonly caller: Weight;
|
||||
readonly address: Weight;
|
||||
readonly gasLeft: Weight;
|
||||
@@ -227,6 +281,18 @@ export interface Limits extends Struct {
|
||||
readonly tableSize: u32;
|
||||
readonly brTableSize: u32;
|
||||
readonly subjectLen: u32;
|
||||
}
|
||||
|
||||
/** @name LimitsTo264 */
|
||||
export interface LimitsTo264 extends Struct {
|
||||
readonly eventTopics: u32;
|
||||
readonly stackHeight: u32;
|
||||
readonly globals: u32;
|
||||
readonly parameters: u32;
|
||||
readonly memoryPages: u32;
|
||||
readonly tableSize: u32;
|
||||
readonly brTableSize: u32;
|
||||
readonly subjectLen: u32;
|
||||
readonly codeSize: u32;
|
||||
}
|
||||
|
||||
@@ -290,6 +356,15 @@ export interface ScheduleTo258 extends Struct {
|
||||
readonly maxSubjectLen: u32;
|
||||
}
|
||||
|
||||
/** @name ScheduleTo264 */
|
||||
export interface ScheduleTo264 extends Struct {
|
||||
readonly version: u32;
|
||||
readonly enablePrintln: bool;
|
||||
readonly limits: LimitsTo264;
|
||||
readonly instructionWeights: InstructionWeights;
|
||||
readonly hostFnWeights: HostFnWeightsTo264;
|
||||
}
|
||||
|
||||
/** @name SeedOf */
|
||||
export interface SeedOf extends Hash {}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ export { default as engine } from './engine/definitions';
|
||||
export { default as evm } from './evm/definitions';
|
||||
export { default as extrinsics } from './extrinsics/definitions';
|
||||
export { default as genericAsset } from './genericAsset/definitions';
|
||||
export { default as gilt } from './gilt/definitions';
|
||||
export { default as grandpa } from './grandpa/definitions';
|
||||
export { default as identity } from './identity/definitions';
|
||||
export { default as imOnline } from './imOnline/definitions';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
const AllConvictions = [
|
||||
export const AllConvictions = [
|
||||
// 0.1x votes, unlocked.
|
||||
'None',
|
||||
// 1x votes, locked for an enactment period following a successful vote.
|
||||
@@ -23,8 +23,6 @@ const AllConvictions = [
|
||||
'Locked6x'
|
||||
];
|
||||
|
||||
export { AllConvictions };
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
ActiveGilt: {
|
||||
proportion: 'Perquintill',
|
||||
amount: 'Balance',
|
||||
who: 'AccountId',
|
||||
expiry: 'BlockNumber'
|
||||
},
|
||||
ActiveGiltsTotal: {
|
||||
frozen: 'Balance',
|
||||
proportion: 'Perquintill',
|
||||
index: 'ActiveIndex',
|
||||
target: 'Perquintill'
|
||||
},
|
||||
ActiveIndex: 'u32',
|
||||
GiltBid: {
|
||||
amount: 'Balance',
|
||||
who: 'AccountId'
|
||||
}
|
||||
}
|
||||
} as Definitions;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user