Compare commits

..
18 Commits
Author SHA1 Message Date
Github Actions ff23ead797 [CI Skip] release/stable 3.10.1
skip-checks: true
2021-02-22 08:45:21 +00:00
Jaco Greeff ae55e4fbf7 3.10 (#3198) 2021-02-22 09:36:29 +01:00
Github Actions b17412163d [CI Skip] release/beta 3.9.4-4
skip-checks: true
2021-02-21 12:18:23 +00:00
Jaco Greeff 46dcbf9a42 Bump common (#3196) 2021-02-21 13:09:51 +01:00
Github Actions 193dfcc32f [CI Skip] release/beta 3.9.4-3
skip-checks: true
2021-02-21 09:42:58 +00:00
Jaco Greeff a81011cf94 Adjust ConsumedWeight (#3195) 2021-02-21 10:34:07 +01:00
Github Actions d43a8b2e11 [CI Skip] release/beta 3.9.4-2
skip-checks: true
2021-02-20 11:47:18 +00:00
Jaco Greeff dff859ba68 Don't send unsubscribe when already disconnected (#3192)
* Don't send unsubscribe when already disconnected

* Small cleanups
2021-02-20 12:37:05 +01:00
Github Actions 5169b6ee69 [CI Skip] release/beta 3.9.4-1
skip-checks: true
2021-02-20 10:59:13 +00:00
Jaco Greeff f4405667fe Adjust use of staking derive multi (#3173)
* Adjust use of staking derive multi

* Remove migrateEra

* Flatten rewards
2021-02-20 11:51:48 +01:00
Github Actions 49ff636305 [CI Skip] release/beta 3.9.4-0
skip-checks: true
2021-02-16 12:00:27 +00:00
Jaco Greeff d77d686c76 Update detectPackage to use packgeInfo.ts (#3182) 2021-02-16 12:50:45 +01:00
Github Actions 502c6a3451 [CI Skip] release/stable 3.9.3
skip-checks: true
2021-02-16 06:47:07 +00:00
Jaco Greeff b58c77683d 3.9.3 PersistedValidationData (#3180) 2021-02-16 07:39:29 +01:00
Github Actions b9f82fc549 [CI Skip] release/stable 3.9.2
skip-checks: true
2021-02-15 09:05:52 +00:00
Jaco Greeff 25b8dba607 3.9.2 (#3176)
* 3.9.2

* Update CHANGELOG.md
2021-02-15 09:56:14 +01:00
Github Actions 1bc4f2c334 [CI Skip] release/beta 3.9.2-0
skip-checks: true
2021-02-15 06:47:13 +00:00
Nikos Kontakis aee8ac6b0a Update README.md (#3175)
Minor url link fixes (documentation portal and JSON-RPC methods link)
2021-02-15 07:37:11 +01:00
37 changed files with 763 additions and 657 deletions
+3 -1
View File
@@ -14,4 +14,6 @@
3.6.3
3.6.4
3.7.2
3.7.3
3.7.3
3.9.2
3.9.3
+35
View File
@@ -1,5 +1,40 @@
# CHANGELOG
## 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.
Contributed:
- Update README links (Thanks to https://github.com/wirednkod)
Changes:
- Added missing Culmulus `ParachainInherentData` & `MessageQueueChain` types
- Add alias for `system_unstable_networkState` RPC
## 3.9.1 Feb 14, 2021
Upgrade priority: Low.
+2 -2
View File
@@ -7,7 +7,7 @@
# @polkadot/api
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/docs/api/).
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
@@ -22,7 +22,7 @@ The API is split up into a number of internal packages -
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
- [@polkadot/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/docs/substrate/rpc) exposed by a Polkadot network client
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
+5 -5
View File
@@ -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/core": "^7.12.17",
"@babel/register": "^7.12.13",
"@babel/runtime": "^7.12.13",
"@polkadot/dev": "^0.61.25",
"@babel/runtime": "^7.12.18",
"@polkadot/dev": "^0.61.26",
"@polkadot/ts": "^0.3.59",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.20",
"copyfiles": "^2.4.1"
},
"version": "3.9.1"
"version": "3.10.1"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "3.9.1",
"version": "3.10.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"sideEffects": false,
@@ -12,11 +12,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.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/api": "3.10.1",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/x-rxjs": "^5.7.1",
"bn.js": "^4.11.9"
}
}
+6
View File
@@ -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.10.1' };
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "3.9.1",
"version": "3.10.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"sideEffects": false,
@@ -12,17 +12,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.1",
"@polkadot/rpc-core": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/util-crypto": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/api": "3.10.1",
"@polkadot/rpc-core": "3.10.1",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/util-crypto": "^5.7.1",
"@polkadot/x-rxjs": "^5.7.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.6.2",
"@polkadot/rpc-provider": "3.9.1"
"@polkadot/keyring": "^5.7.1",
"@polkadot/rpc-provider": "3.10.1"
}
}
+6
View File
@@ -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.10.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';
+19 -37
View File
@@ -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)
)
);
}
+23 -41
View File
@@ -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([])
);
}
+12 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "3.9.1",
"version": "3.10.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.1",
"@polkadot/keyring": "^5.6.2",
"@polkadot/metadata": "3.9.1",
"@polkadot/rpc-core": "3.9.1",
"@polkadot/rpc-provider": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/types-known": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/util-crypto": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/api-derive": "3.10.1",
"@polkadot/keyring": "^5.7.1",
"@polkadot/metadata": "3.10.1",
"@polkadot/rpc-core": "3.10.1",
"@polkadot/rpc-provider": "3.10.1",
"@polkadot/types": "3.10.1",
"@polkadot/types-known": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/util-crypto": "^5.7.1",
"@polkadot/x-rxjs": "^5.7.1",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
}
+1 -1
View File
@@ -18,7 +18,7 @@
import { detectPackage } from '@polkadot/util';
import packageInfo from './package-info.json';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
+6
View File
@@ -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.10.1' };
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "3.9.1",
"version": "3.10.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.1",
"@polkadot/types-known": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/util-crypto": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/types": "3.10.1",
"@polkadot/types-known": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/util-crypto": "^5.7.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.6.2"
"@polkadot/keyring": "^5.7.1"
}
}
+1 -1
View File
@@ -18,7 +18,7 @@
import { detectPackage } from '@polkadot/util';
import packageInfo from './package-info.json';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
+6
View File
@@ -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.10.1' };
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "3.9.1",
"version": "3.10.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": false,
@@ -12,14 +12,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.1",
"@polkadot/rpc-provider": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2"
"@babel/runtime": "^7.12.18",
"@polkadot/metadata": "3.10.1",
"@polkadot/rpc-provider": "3.10.1",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/x-rxjs": "^5.7.1"
},
"devDependencies": {
"@polkadot/keyring": "^5.6.2"
"@polkadot/keyring": "^5.7.1"
}
}
+6
View File
@@ -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.10.1' };
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "3.9.1",
"version": "3.10.1",
"description": "Transport providers for the API",
"main": "index.js",
"sideEffects": false,
@@ -12,19 +12,19 @@
"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.1",
"@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.12.18",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/util-crypto": "^5.7.1",
"@polkadot/x-fetch": "^5.7.1",
"@polkadot/x-global": "^5.7.1",
"@polkadot/x-ws": "^5.7.1",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^5.6.2",
"@polkadot/metadata": "3.9.1",
"@polkadot/keyring": "^5.7.1",
"@polkadot/metadata": "3.10.1",
"mock-socket": "^9.0.3",
"nock": "^13.0.7"
}
+6
View File
@@ -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.10.1' };
+11 -9
View File
@@ -245,8 +245,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 +298,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 +320,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 => {
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "3.9.1",
"version": "3.10.1",
"description": "Type generation scripts",
"main": "index.js",
"sideEffects": false,
@@ -19,15 +19,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/core": "^7.12.17",
"@babel/register": "^7.12.13",
"@babel/runtime": "^7.12.13",
"@polkadot/api": "3.9.1",
"@polkadot/metadata": "3.9.1",
"@polkadot/rpc-provider": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"handlebars": "^4.7.6",
"@babel/runtime": "^7.12.18",
"@polkadot/api": "3.10.1",
"@polkadot/metadata": "3.10.1",
"@polkadot/rpc-provider": "3.10.1",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.33",
"yargs": "^16.2.0"
},
+6
View File
@@ -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.10.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "3.9.1",
"version": "3.10.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": false,
@@ -12,10 +12,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.1",
"@polkadot/util": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/networks": "^5.7.1",
"@polkadot/types": "3.10.1",
"@polkadot/util": "^5.7.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
+6
View File
@@ -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.10.1' };
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "3.9.1",
"version": "3.10.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.1",
"@polkadot/util": "^5.6.2",
"@polkadot/util-crypto": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"@babel/runtime": "^7.12.18",
"@polkadot/metadata": "3.10.1",
"@polkadot/util": "^5.7.1",
"@polkadot/util-crypto": "^5.7.1",
"@polkadot/x-rxjs": "^5.7.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.6.2"
"@polkadot/keyring": "^5.7.1"
}
}
+17 -5
View File
@@ -31,7 +31,7 @@ import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lotter
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AbstractFungible, AbstractNonFungible, AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Balances, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, ConcreteFungible, ConcreteNonFungible, CoreAssignment, CoreIndex, CoreOccupied, DepositAsset, DepositReserveAsset, DoubleVoteReport, DownwardMessage, ExchangeAsset, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InitiateReserveWithdraw, InitiateTeleport, Junction, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiAsset, MultiLocation, NetworkId, NewBidder, NewBidderOption, Order, OriginKind, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainProposal, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueryHolding, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayTo, RelayedFrom, Remark, ReserveAssetDeposit, Retriable, Scheduling, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TeleportAsset, Transact, TransientValidationData, UpwardMessage, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry, WithdrawAsset, Xcm, XcmError, XcmResult } from '@polkadot/types/interfaces/parachains';
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AbstractFungible, AbstractNonFungible, AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Balances, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, ConcreteFungible, ConcreteNonFungible, CoreAssignment, CoreIndex, CoreOccupied, DepositAsset, DepositReserveAsset, DoubleVoteReport, DownwardMessage, ExchangeAsset, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InitiateReserveWithdraw, InitiateTeleport, Junction, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiAsset, MultiLocation, NetworkId, NewBidder, NewBidderOption, Order, OriginKind, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueryHolding, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayChainHash, RelayTo, RelayedFrom, Remark, ReserveAssetDeposit, Retriable, Scheduling, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TeleportAsset, Transact, TransientValidationData, UpwardMessage, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry, WithdrawAsset, Xcm, XcmError, XcmResult } from '@polkadot/types/interfaces/parachains';
import type { FeeDetails, InclusionFee, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { Approvals } from '@polkadot/types/interfaces/poll';
import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
@@ -46,7 +46,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
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 { 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';
@@ -508,6 +508,7 @@ declare module '@polkadot/types/types/registry' {
'Option<MemberCount>': Option<MemberCount>;
'Option<MembershipProof>': Option<MembershipProof>;
'Option<MessageIngestionType>': Option<MessageIngestionType>;
'Option<MessageQueueChain>': Option<MessageQueueChain>;
'Option<MessagingStateSnapshot>': Option<MessagingStateSnapshot>;
'Option<MessagingStateSnapshotEgressEntry>': Option<MessagingStateSnapshotEgressEntry>;
'Option<MetadataAll>': Option<MetadataAll>;
@@ -574,6 +575,7 @@ declare module '@polkadot/types/types/registry' {
'Option<PalletsOrigin>': Option<PalletsOrigin>;
'Option<PalletVersion>': Option<PalletVersion>;
'Option<ParachainDispatchOrigin>': Option<ParachainDispatchOrigin>;
'Option<ParachainInherentData>': Option<ParachainInherentData>;
'Option<ParachainProposal>': Option<ParachainProposal>;
'Option<ParaGenesisArgs>': Option<ParaGenesisArgs>;
'Option<ParaId>': Option<ParaId>;
@@ -595,8 +597,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>;
@@ -658,6 +661,7 @@ declare module '@polkadot/types/types/registry' {
'Option<Registration>': Option<Registration>;
'Option<RegistrationJudgement>': Option<RegistrationJudgement>;
'Option<RelayChainBlockNumber>': Option<RelayChainBlockNumber>;
'Option<RelayChainHash>': Option<RelayChainHash>;
'Option<RelayedFrom>': Option<RelayedFrom>;
'Option<RelayTo>': Option<RelayTo>;
'Option<Releases>': Option<Releases>;
@@ -1232,6 +1236,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<MemberCount>': Vec<MemberCount>;
'Vec<MembershipProof>': Vec<MembershipProof>;
'Vec<MessageIngestionType>': Vec<MessageIngestionType>;
'Vec<MessageQueueChain>': Vec<MessageQueueChain>;
'Vec<MessagingStateSnapshot>': Vec<MessagingStateSnapshot>;
'Vec<MessagingStateSnapshotEgressEntry>': Vec<MessagingStateSnapshotEgressEntry>;
'Vec<MetadataAll>': Vec<MetadataAll>;
@@ -1298,6 +1303,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<PalletsOrigin>': Vec<PalletsOrigin>;
'Vec<PalletVersion>': Vec<PalletVersion>;
'Vec<ParachainDispatchOrigin>': Vec<ParachainDispatchOrigin>;
'Vec<ParachainInherentData>': Vec<ParachainInherentData>;
'Vec<ParachainProposal>': Vec<ParachainProposal>;
'Vec<ParaGenesisArgs>': Vec<ParaGenesisArgs>;
'Vec<ParaId>': Vec<ParaId>;
@@ -1319,8 +1325,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>;
@@ -1382,6 +1389,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<Registration>': Vec<Registration>;
'Vec<RegistrationJudgement>': Vec<RegistrationJudgement>;
'Vec<RelayChainBlockNumber>': Vec<RelayChainBlockNumber>;
'Vec<RelayChainHash>': Vec<RelayChainHash>;
'Vec<RelayedFrom>': Vec<RelayedFrom>;
'Vec<RelayTo>': Vec<RelayTo>;
'Vec<Releases>': Vec<Releases>;
@@ -1956,6 +1964,7 @@ declare module '@polkadot/types/types/registry' {
MemberCount: MemberCount;
MembershipProof: MembershipProof;
MessageIngestionType: MessageIngestionType;
MessageQueueChain: MessageQueueChain;
MessagingStateSnapshot: MessagingStateSnapshot;
MessagingStateSnapshotEgressEntry: MessagingStateSnapshotEgressEntry;
MetadataAll: MetadataAll;
@@ -2022,6 +2031,7 @@ declare module '@polkadot/types/types/registry' {
PalletsOrigin: PalletsOrigin;
PalletVersion: PalletVersion;
ParachainDispatchOrigin: ParachainDispatchOrigin;
ParachainInherentData: ParachainInherentData;
ParachainProposal: ParachainProposal;
ParaGenesisArgs: ParaGenesisArgs;
ParaId: ParaId;
@@ -2043,8 +2053,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;
@@ -2106,6 +2117,7 @@ declare module '@polkadot/types/types/registry' {
Registration: Registration;
RegistrationJudgement: RegistrationJudgement;
RelayChainBlockNumber: RelayChainBlockNumber;
RelayChainHash: RelayChainHash;
RelayedFrom: RelayedFrom;
RelayTo: RelayTo;
Releases: Releases;
+1 -1
View File
@@ -18,7 +18,7 @@
import { detectPackage } from '@polkadot/util';
import packageInfo from './package-info.json';
import { packageInfo } from './packageInfo';
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
@@ -209,6 +209,7 @@ export default {
downwardMessages: 'Vec<InboundDownwardMessage>',
horizontalMessages: 'BTreeMap<ParaId, InboundHrmpMessages>'
},
MessageQueueChain: 'RelayChainHash',
OutboundHrmpMessage: {
recipient: 'u32',
data: 'Bytes'
@@ -216,6 +217,12 @@ export default {
ParachainDispatchOrigin: {
_enum: ['Signed', 'Parachain', 'Root']
},
ParachainInherentData: {
validationData: 'PersistedValidationData',
relayChainState: 'StorageProof',
downwardMessages: 'Vec<InboundDownwardMessage>',
horizontalMessages: 'BTreeMap<ParaId, VecInboundHrmpMessage>'
},
ParaGenesisArgs: {
genesisHead: 'Bytes',
validationCode: 'Bytes',
@@ -247,13 +254,12 @@ export default {
ParaValidatorIndex: 'u32',
PersistedValidationData: {
parentHead: 'HeadData',
blockNumber: 'RelayChainBlockNumber',
relayStorageRoot: 'Hash',
hrmpMqcHeads: 'Vec<(u32, Hash)>',
dmqMqcHead: 'Hash',
relayParentNumber: 'RelayChainBlockNumber',
relayParentStorageRoot: 'Hash',
maxPovSize: 'u32'
},
RelayChainBlockNumber: 'u32',
RelayChainHash: 'Hash',
QueuedParathread: {
claim: 'ParathreadEntry',
coreOffset: 'u32'
@@ -528,12 +534,7 @@ export default {
egressChannels: 'Vec<MessagingStateSnapshotEgressEntry>'
},
MessagingStateSnapshotEgressEntry: '(ParaId, AbridgedHrmpChannel)',
SystemInherentData: {
validationData: 'PersistedValidationData',
relayChainState: 'StorageProof',
downwardMessages: 'Vec<InboundDownwardMessage>',
horizontalMessages: 'BTreeMap<ParaId, VecInboundHrmpMessage>'
},
SystemInherentData: 'ParachainInherentData',
VecInboundHrmpMessage: 'Vec<InboundHrmpMessage>'
}
} as Definitions;
@@ -444,6 +444,9 @@ export interface MessageIngestionType extends Struct {
readonly horizontalMessages: BTreeMap<ParaId, InboundHrmpMessages>;
}
/** @name MessageQueueChain */
export interface MessageQueueChain extends RelayChainHash {}
/** @name MessagingStateSnapshot */
export interface MessagingStateSnapshot extends Struct {
readonly relayDispatchQueueSize: ITuple<[u32, u32]>;
@@ -545,6 +548,14 @@ export interface ParachainDispatchOrigin extends Enum {
readonly isRoot: boolean;
}
/** @name ParachainInherentData */
export interface ParachainInherentData extends Struct {
readonly validationData: PersistedValidationData;
readonly relayChainState: StorageProof;
readonly downwardMessages: Vec<InboundDownwardMessage>;
readonly horizontalMessages: BTreeMap<ParaId, VecInboundHrmpMessage>;
}
/** @name ParachainProposal */
export interface ParachainProposal extends Struct {
readonly proposer: AccountId;
@@ -613,10 +624,8 @@ export interface ParaValidatorIndex extends u32 {}
/** @name PersistedValidationData */
export interface PersistedValidationData extends Struct {
readonly parentHead: HeadData;
readonly blockNumber: RelayChainBlockNumber;
readonly relayStorageRoot: Hash;
readonly hrmpMqcHeads: Vec<ITuple<[u32, Hash]>>;
readonly dmqMqcHead: Hash;
readonly relayParentNumber: RelayChainBlockNumber;
readonly relayParentStorageRoot: Hash;
readonly maxPovSize: u32;
}
@@ -642,6 +651,9 @@ export interface RegisteredParachainInfo extends Struct {
/** @name RelayChainBlockNumber */
export interface RelayChainBlockNumber extends u32 {}
/** @name RelayChainHash */
export interface RelayChainHash extends Hash {}
/** @name RelayedFrom */
export interface RelayedFrom extends Struct {
readonly superorigin: MultiLocation;
@@ -738,12 +750,7 @@ export interface Statement extends Enum {
export interface SubId extends u32 {}
/** @name SystemInherentData */
export interface SystemInherentData extends Struct {
readonly validationData: PersistedValidationData;
readonly relayChainState: StorageProof;
readonly downwardMessages: Vec<InboundDownwardMessage>;
readonly horizontalMessages: BTreeMap<ParaId, VecInboundHrmpMessage>;
}
export interface SystemInherentData extends ParachainInherentData {}
/** @name TeleportAsset */
export interface TeleportAsset extends Struct {
@@ -82,6 +82,7 @@ export default {
type: 'Vec<PeerInfo>'
},
networkState: {
alias: ['system_unstable_networkState'],
description: 'Returns current state of the network',
params: [],
type: 'NetworkState'
@@ -152,7 +153,7 @@ export default {
BlockWeights: {
baseBlock: 'Weight',
maxBlock: 'Weight',
perClass: 'PerDispatchClass'
perClass: 'PerDispatchClassWeightsPerClass'
},
ChainProperties: 'GenericChainProperties',
ChainType: {
@@ -163,7 +164,7 @@ export default {
Custom: 'Text'
}
},
ConsumedWeight: 'PerDispatchClass',
ConsumedWeight: 'PerDispatchClassWeight',
DigestOf: 'Digest',
DispatchClass: {
_enum: ['Normal', 'Operational', 'Mandatory']
@@ -295,16 +296,21 @@ export default {
bestHash: 'Hash',
bestNumber: 'BlockNumber'
},
PerDispatchClass: {
normal: 'WeightPerClass',
operational: 'WeightPerClass',
mandatory: 'WeightPerClass'
},
PerDispatchClassU32: {
normal: 'u32',
operational: 'u32',
mandatory: 'u32'
},
PerDispatchClassWeight: {
normal: 'Weight',
operational: 'Weight',
mandatory: 'Weight'
},
PerDispatchClassWeightsPerClass: {
normal: 'WeightPerClass',
operational: 'WeightPerClass',
mandatory: 'WeightPerClass'
},
Phase: {
_enum: {
ApplyExtrinsic: 'u32',
+16 -9
View File
@@ -45,7 +45,7 @@ export interface BlockLength extends Struct {
export interface BlockWeights extends Struct {
readonly baseBlock: Weight;
readonly maxBlock: Weight;
readonly perClass: PerDispatchClass;
readonly perClass: PerDispatchClassWeightsPerClass;
}
/** @name ChainProperties */
@@ -61,7 +61,7 @@ export interface ChainType extends Enum {
}
/** @name ConsumedWeight */
export interface ConsumedWeight extends PerDispatchClass {}
export interface ConsumedWeight extends PerDispatchClassWeight {}
/** @name DigestOf */
export interface DigestOf extends Digest {}
@@ -276,13 +276,6 @@ export interface PeerPing extends Struct {
readonly secs: u64;
}
/** @name PerDispatchClass */
export interface PerDispatchClass extends Struct {
readonly normal: WeightPerClass;
readonly operational: WeightPerClass;
readonly mandatory: WeightPerClass;
}
/** @name PerDispatchClassU32 */
export interface PerDispatchClassU32 extends Struct {
readonly normal: u32;
@@ -290,6 +283,20 @@ export interface PerDispatchClassU32 extends Struct {
readonly mandatory: u32;
}
/** @name PerDispatchClassWeight */
export interface PerDispatchClassWeight extends Struct {
readonly normal: Weight;
readonly operational: Weight;
readonly mandatory: Weight;
}
/** @name PerDispatchClassWeightsPerClass */
export interface PerDispatchClassWeightsPerClass extends Struct {
readonly normal: WeightPerClass;
readonly operational: WeightPerClass;
readonly mandatory: WeightPerClass;
}
/** @name Phase */
export interface Phase extends Enum {
readonly isApplyExtrinsic: boolean;
+6
View File
@@ -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', version: '3.10.1' };
+359 -351
View File
File diff suppressed because it is too large Load Diff