Compare commits

..
22 Commits
Author SHA1 Message Date
Github Actions 84eb806f07 [CI Skip] release/stable 1.20.1
skip-checks: true
2020-06-22 14:20:44 +00:00
Jaco Greeff 2493442a2e 1.20 (#2377)
* 1.20

* Indicate @polkadot/util bump
2020-06-22 16:08:22 +02:00
Github Actions 77df7907c7 [CI Skip] release/beta 1.20.0-beta.9
skip-checks: true
2020-06-22 13:42:01 +00:00
Jaco Greeff f1b6268784 Bump metadata (#2376) 2020-06-22 15:31:27 +02:00
Github Actions 9aa9380251 [CI Skip] release/beta 1.20.0-beta.8
skip-checks: true
2020-06-22 08:22:33 +00:00
Jaco Greeff b4306cb60a Bump metadata (#2373) 2020-06-22 10:12:01 +02:00
Github Actions 1e83daf797 [CI Skip] release/beta 1.20.0-beta.7
skip-checks: true
2020-06-21 11:26:27 +00:00
Jaco Greeff d46d32d9bc Optimize query/queryMulti retrievals (#2371)
* Optimize query/queryMulti retrievals

* Current retrieval on a batch basis

* Dedup staking.account/accounts internally
2020-06-21 13:13:38 +02:00
Github Actions 032a0a595c [CI Skip] release/beta 1.20.0-beta.6
skip-checks: true
2020-06-21 08:09:28 +00:00
Jaco Greeff 34101ec12b Adjust with queryMulti as applicable (#2370) 2020-06-21 09:56:02 +02:00
Github Actions 4e02b982d3 [CI Skip] release/beta 1.20.0-beta.5
skip-checks: true
2020-06-20 18:12:10 +00:00
Jaco Greeff 5b96d52fa6 Adjust for zero-length combines (#2369) 2020-06-20 20:00:01 +02:00
Github Actions 735f2b835e [CI Skip] release/beta 1.20.0-beta.4
skip-checks: true
2020-06-20 13:42:40 +00:00
Jaco Greeff 646e64c286 Add derive.staking.waitingInfo (#2367)
* Add derive.staking.waitingInfo

* Small optimizations

* Updated
2020-06-20 15:30:48 +02:00
Github Actions fc9060caa8 [CI Skip] release/beta 1.20.0-beta.3
skip-checks: true
2020-06-19 12:04:34 +00:00
Jaco Greeff 503c2b3c63 Add transactionPayment release type (#2366) 2020-06-19 13:51:40 +02:00
Github Actions 168abc130f [CI Skip] release/beta 1.20.0-beta.2
skip-checks: true
2020-06-18 08:28:13 +00:00
Jaco Greeff 5c5db2709b Add system_dryRun RPCs (#2363)
* Add system_dryRun RPCs

* CHANGELOG
2020-06-18 10:15:41 +02:00
Github Actions 5a4ff5420f [CI Skip] release/beta 1.20.0-beta.1
skip-checks: true
2020-06-18 08:04:22 +00:00
Jaco Greeff a1655508ba Cleanups in API typing (& overrides) (#2362)
* Cleanups in API typing (& overrides)

* Less magic "as" overrides
2020-06-18 09:52:39 +02:00
Github Actions 64827a6114 [CI Skip] release/beta 1.20.0-beta.0
skip-checks: true
2020-06-17 22:18:49 +00:00
Jaco Greeff 2eb09374bc Map entries/keys cleanups (#2360) 2020-06-18 00:06:19 +02:00
47 changed files with 1467 additions and 1021 deletions
+11
View File
@@ -1,11 +1,22 @@
# CHANGELOG
## 1.20.1 Jun 22, 2020
- **Important** RPC for `account_nextIndex` has been moved to `system_accountNextIndex` (Aligning with Substrate as a primary alias)
- Cleanup map entries support with only Substrate 2.0-era RPCs (when introduced)
- Add `system_dryRun` RPC
- Optimize `derive.staking.queryMulti` retrievals with additional per-type batching
- Add `derive.staking.waitingInfo` (same as `electedInfo` for waiting validators)
- Adjust types & metadata for latest Substrate
- `@polkadot/util` 2.15
## 1.19.1 Jun 16, 2020
- Improve typing on `.entries()` queries (Thanks to https://github.com/monitz87)
- Align metadata and types with latest Substrate
- Update Polkadot types for current evolution of parachains
- Allow for type aliasing on events (aligning with calls & queries)
- `@polkadot/util` 2.14
## 1.18.1 Jun 8, 2020
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.19.1"
"version": "1.20.1"
}
+5 -5
View File
@@ -24,15 +24,15 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/register": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@polkadot/dev": "^0.55.10",
"@babel/core": "^7.10.3",
"@babel/register": "^7.10.3",
"@babel/runtime": "^7.10.3",
"@polkadot/dev": "^0.55.11",
"@polkadot/ts": "^0.3.26",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.0",
"@vuepress/plugin-search": "^1.5.2",
"copyfiles": "^2.3.0"
},
"version": "1.19.1"
"version": "1.20.1"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.19.1",
"version": "1.20.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
@@ -26,11 +26,11 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api": "1.19.1",
"@polkadot/rpc-core": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/api": "1.20.1",
"@polkadot/rpc-core": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"bn.js": "^5.1.2",
"rxjs": "^6.5.5"
}
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.19.1",
"version": "1.20.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -27,18 +27,18 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api": "1.19.1",
"@polkadot/rpc-core": "1.19.1",
"@polkadot/rpc-provider": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/api": "1.20.1",
"@polkadot/rpc-core": "1.20.1",
"@polkadot/rpc-provider": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"@polkadot/util-crypto": "^2.15.1",
"bn.js": "^5.1.2",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1"
"@polkadot/keyring": "^2.15.1"
}
}
+12 -13
View File
@@ -7,7 +7,7 @@ import { Balance, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces'
import { DeriveSessionInfo, DeriveStakingAccount, DeriveStakingQuery, DeriveUnlocking } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest } from 'rxjs';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { isUndefined } from '@polkadot/util';
@@ -70,21 +70,15 @@ function parseResult (api: ApiInterfaceRx, sessionInfo: DeriveSessionInfo, query
};
}
export function _account (api: ApiInterfaceRx): (sessionInfo: DeriveSessionInfo, accountId: Uint8Array | string) => Observable<DeriveStakingAccount> {
return memo((sessionInfo: DeriveSessionInfo, accountId: Uint8Array | string): Observable<DeriveStakingAccount> =>
api.derive.staking.query(accountId).pipe(
map((query) => parseResult(api, sessionInfo, query))
));
}
/**
* @description From a stash, retrieve the controllerId and fill in all the relevant staking details
*/
export function account (api: ApiInterfaceRx): (accountId: Uint8Array | string) => Observable<DeriveStakingAccount> {
return memo((accountId: Uint8Array | string): Observable<DeriveStakingAccount> =>
api.derive.session.info().pipe(
switchMap((sessionInfo) => api.derive.staking._account(sessionInfo, accountId))
));
api.derive.staking.accounts([accountId]).pipe(
map(([first]) => first)
)
);
}
/**
@@ -94,7 +88,12 @@ export function accounts (api: ApiInterfaceRx): (accountIds: (Uint8Array | strin
return memo((accountIds: (Uint8Array | string)[]): Observable<DeriveStakingAccount[]> =>
api.derive.session.info().pipe(
switchMap((sessionInfo) =>
combineLatest(accountIds.map((accountId) => api.derive.staking._account(sessionInfo, accountId)))
api.derive.staking.queryMulti(accountIds).pipe(
map((queries) =>
queries.map((query) => parseResult(api, sessionInfo, query))
)
)
)
));
)
);
}
+10 -15
View File
@@ -3,10 +3,9 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId } from '@polkadot/types/interfaces';
import { DeriveStakingQuery, DeriveStakingElected } from '../types';
import { DeriveStakingElected } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
@@ -14,18 +13,14 @@ import { memo } from '../util';
export function electedInfo (api: ApiInterfaceRx): () => Observable<DeriveStakingElected> {
return memo((): Observable<DeriveStakingElected> =>
api.derive.staking.validators().pipe(
switchMap(({ nextElected }): Observable<[AccountId[], DeriveStakingQuery[]]> =>
combineLatest([
of(nextElected),
combineLatest(
nextElected.map((accountId) => api.derive.staking.query(accountId))
)
])
),
map(([nextElected, info]): DeriveStakingElected => ({
info,
nextElected
}))
switchMap(({ nextElected }): Observable<DeriveStakingElected> =>
api.derive.staking.queryMulti(nextElected).pipe(
map((info): DeriveStakingElected => ({
info,
nextElected
}))
)
)
)
);
}
+1
View File
@@ -21,3 +21,4 @@ export * from './stakerRewards';
export * from './stakerSlashes';
export * from './stashes';
export * from './validators';
export * from './waitingInfo';
+80 -59
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Exposure, Keys, Nominations, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces';
import { AccountId, EraIndex, Exposure, Keys, Nominations, RewardDestination, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveStakingQuery } from '../types';
@@ -16,7 +16,7 @@ import { memo } from '../util';
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Option<Keys>, Exposure];
function unwrapSessionIds (stashId: AccountId, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): { nextSessionIds: AccountId[]; sessionIds: AccountId[] } {
function parseSessionIds (stashId: AccountId, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): { nextSessionIds: AccountId[]; sessionIds: AccountId[] } {
const sessionIds = (queuedKeys.find(([currentId]): boolean =>
currentId.eq(stashId)
) || [undefined, [] as AccountId[]])[1];
@@ -28,6 +28,31 @@ function unwrapSessionIds (stashId: AccountId, queuedKeys: [AccountId, Keys][],
};
}
function parseController (stashId: AccountId, queuedKeys: Vec<ITuple<[AccountId, Keys]>>, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, nextKeys, exposure]: MultiResult, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
const controllerId = controllerIdOpt.unwrapOr(null);
const nominators = nominatorsOpt.unwrapOr(null);
return controllerId && stakingLedgerOpt.isSome
? {
accountId: stashId,
controllerId,
exposure,
nominators: nominators
? Array.isArray(nominators)
? nominators[0].targets
: nominators.targets
: [],
rewardDestination,
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
stashId,
validatorPrefs: Array.isArray(validatorPrefs)
? validatorPrefs[0]
: validatorPrefs,
...parseSessionIds(stashId, queuedKeys, nextKeys)
}
: { accountId: stashId, nextSessionIds: [], sessionIds: [] };
}
function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable<MultiResult> {
return api.queryMulti<MultiResult>([
[api.query.staking.bonded, stashId],
@@ -39,64 +64,43 @@ function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable<Mult
]);
}
function retrieveCurr (api: ApiInterfaceRx, stashId: AccountId): Observable<MultiResult> {
return api.derive.session.indexes().pipe(
switchMap(({ activeEra }) =>
api.queryMulti<MultiResult>([
[api.query.staking.bonded, stashId],
[api.query.staking.nominators, stashId],
[api.query.staking.payee, stashId],
[api.query.staking.validators, stashId],
api.consts.session?.dedupKeyPrefix
? [api.query.session.nextKeys, [api.consts.session.dedupKeyPrefix, stashId]]
: [api.query.session.nextKeys, stashId],
[api.query.staking.erasStakers, [activeEra, stashId]]
])
function retrieveCurr (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex): Observable<MultiResult[]> {
return combineLatest([
api.query.staking.bonded.multi<Option<AccountId>>(stashIds),
api.query.staking.nominators.multi<Option<Nominations>>(stashIds),
api.query.staking.payee.multi<RewardDestination>(stashIds),
api.query.staking.validators.multi<ValidatorPrefs>(stashIds),
api.consts.session?.dedupKeyPrefix
? api.query.session.nextKeys.multi<Option<Keys>>(stashIds.map((stashId) => [api.consts.session.dedupKeyPrefix, stashId]))
: api.query.session.nextKeys.multi<Option<Keys>>(stashIds),
api.query.staking.erasStakers.multi<Exposure>(stashIds.map((stashId) => [activeEra, stashId]))
]).pipe(
map(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, nextKeys, exposure]): MultiResult[] =>
controllerIdOpt.map((controllerIdOpt, index): MultiResult =>
[controllerIdOpt, nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], nextKeys[index], exposure[index]]
)
)
);
}
function retrieveController (api: ApiInterfaceRx, stashId: AccountId, queuedKeys: Vec<ITuple<[AccountId, Keys]>>, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, nextKeys, exposure]: MultiResult): Observable<DeriveStakingQuery> {
const controllerId = controllerIdOpt.unwrapOr(null);
const nominators = nominatorsOpt.unwrapOr(null);
function retrieveControllers (api: ApiInterfaceRx, optControllerIds: Option<AccountId>[]): Observable<Option<StakingLedger>[]> {
const ids = optControllerIds.filter((opt) => opt.isSome).map((opt) => opt.unwrap());
return controllerId
? api.query.staking.ledger(controllerId).pipe(
map((stakingLedgerOpt): DeriveStakingQuery => ({
accountId: stashId,
controllerId,
exposure,
nominators: nominators
? Array.isArray(nominators)
? nominators[0].targets
: nominators.targets
: [],
rewardDestination,
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
stashId,
validatorPrefs: Array.isArray(validatorPrefs)
? validatorPrefs[0]
: validatorPrefs,
...unwrapSessionIds(stashId, queuedKeys, nextKeys)
}))
)
: of({ accountId: stashId, nextSessionIds: [], sessionIds: [] });
}
if (!ids.length) {
return of(optControllerIds.map(() => api.registry.createType('Option<StakingLedger>')));
}
export function queryWithQueued (api: ApiInterfaceRx): (accountId: Uint8Array | string, queuedKeys: Vec<ITuple<[AccountId, Keys]>>) => Observable<DeriveStakingQuery> {
return memo((accountId: Uint8Array | string, queuedKeys: Vec<ITuple<[AccountId, Keys]>>): Observable<DeriveStakingQuery> => {
const stashId = api.registry.createType('AccountId', accountId);
return api.query.staking.ledger.multi<Option<StakingLedger>>(ids).pipe(
map((optLedgers): Option<StakingLedger>[] => {
let offset = -1;
return (
isFunction(api.query.staking.erasStakers)
? retrieveCurr(api, stashId)
: retrievePrev(api, stashId)
).pipe(
switchMap((result): Observable<DeriveStakingQuery> =>
retrieveController(api, stashId, queuedKeys, result)
)
);
});
return optControllerIds.map((opt): Option<StakingLedger> =>
opt.isSome
? optLedgers[++offset]
: api.registry.createType('Option<StakingLedger>')
);
})
);
}
/**
@@ -104,8 +108,8 @@ export function queryWithQueued (api: ApiInterfaceRx): (accountId: Uint8Array |
*/
export function query (api: ApiInterfaceRx): (accountId: Uint8Array | string) => Observable<DeriveStakingQuery> {
return memo((accountId: Uint8Array | string): Observable<DeriveStakingQuery> =>
api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>().pipe(
switchMap((queuedKeys) => api.derive.staking.queryWithQueued(accountId, queuedKeys))
api.derive.staking.queryMulti([accountId]).pipe(
map(([first]) => first)
)
);
}
@@ -113,10 +117,27 @@ export function query (api: ApiInterfaceRx): (accountId: Uint8Array | string) =>
export function queryMulti (api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[]) => Observable<DeriveStakingQuery[]> {
return memo((accountIds: (Uint8Array | string)[]): Observable<DeriveStakingQuery[]> =>
accountIds.length
? api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>().pipe(
switchMap((queuedKeys) => combineLatest(
accountIds.map((acc) => api.derive.staking.queryWithQueued(acc, queuedKeys))
))
? combineLatest([
api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>(),
api.derive.session.indexes()
]).pipe(
switchMap(([queuedKeys, { activeEra }]): Observable<DeriveStakingQuery[]> => {
const stashIds = accountIds.map((accountId) => api.registry.createType('AccountId', accountId));
return (
isFunction(api.query.staking.erasStakers)
? retrieveCurr(api, stashIds, activeEra)
: combineLatest(stashIds.map((stashId) => retrievePrev(api, stashId)))
).pipe(
switchMap((results): Observable<DeriveStakingQuery[]> =>
retrieveControllers(api, results.map(([optController]) => optController)).pipe(
map((stakingLedgerOpts) =>
stashIds.map((stashId, index) => parseController(stashId, queuedKeys, results[index], stakingLedgerOpts[index]))
)
)
)
);
})
)
: of([])
);
+5
View File
@@ -96,6 +96,11 @@ export interface DeriveStakingElected {
info: DeriveStakingQuery[];
}
export interface DeriveStakingWaiting {
info: DeriveStakingQuery[];
waiting: AccountId[];
}
export interface DeriveStakingValidators {
nextElected: AccountId[];
validators: AccountId[];
@@ -18,9 +18,7 @@ export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]>
// only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
map((keys): AccountId[] =>
keys.map((key): AccountId => key.args[1] as AccountId)
)
map((keys) => keys.map((key): AccountId => key.args[1] as AccountId))
)
: api.query.staking.currentElected<AccountId[]>()
);
@@ -0,0 +1,32 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveStakingWaiting } from '../types';
import { Observable, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function waitingInfo (api: ApiInterfaceRx): () => Observable<DeriveStakingWaiting> {
return memo((): Observable<DeriveStakingWaiting> =>
combineLatest([
api.derive.staking.validators(),
api.derive.staking.stashes()
]).pipe(
switchMap(([{ nextElected }, stashes]): Observable<DeriveStakingWaiting> => {
const elected = nextElected.map((a) => a.toString());
const waiting = stashes.filter((v) => !elected.includes(v.toString()));
return api.derive.staking.queryMulti(waiting).pipe(
map((info): DeriveStakingWaiting => ({
info,
waiting
}))
);
})
)
);
}
+12 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "1.19.1",
"version": "1.20.1",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
@@ -26,21 +26,21 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api-derive": "1.19.1",
"@polkadot/keyring": "^2.14.1",
"@polkadot/metadata": "1.19.1",
"@polkadot/rpc-core": "1.19.1",
"@polkadot/rpc-provider": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/types-known": "1.19.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/api-derive": "1.20.1",
"@polkadot/keyring": "^2.15.1",
"@polkadot/metadata": "1.20.1",
"@polkadot/rpc-core": "1.20.1",
"@polkadot/rpc-provider": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/types-known": "1.20.1",
"@polkadot/util": "^2.15.1",
"@polkadot/util-crypto": "^2.15.1",
"bn.js": "^5.1.2",
"eventemitter3": "^4.0.4",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1"
"@polkadot/keyring": "^2.15.1"
}
}
+71 -2
View File
@@ -3,8 +3,8 @@
import { Codec } from '@polkadot/types/types';
import { Vec } from '@polkadot/types/codec';
import { u32, u64 } from '@polkadot/types/primitive';
import { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import { u16, u32, u64 } from '@polkadot/types/primitive';
import { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import { SessionIndex } from '@polkadot/types/interfaces/session';
import { EraIndex } from '@polkadot/types/interfaces/staking';
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
@@ -176,6 +176,40 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
**/
subAccountDeposit: AugmentedConst<BalanceOf>;
};
proxy: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The maximum amount of proxies allowed for a single account.
**/
maxProxies: AugmentedConst<u16>;
/**
* The base amount of currency needed to reserve for creating a proxy.
**/
proxyDepositBase: AugmentedConst<BalanceOf>;
/**
* The amount of currency needed per proxy added.
**/
proxyDepositFactor: AugmentedConst<BalanceOf>;
};
recovery: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The base amount of currency needed to reserve for creating a recovery configuration.
**/
configDepositBase: AugmentedConst<BalanceOf>;
/**
* The amount of currency needed per additional user when creating a recovery configuration.
**/
friendDepositFactor: AugmentedConst<BalanceOf>;
/**
* The maximum amount of friends allowed in a recovery configuration.
**/
maxFriends: AugmentedConst<u16>;
/**
* The base amount of currency needed to reserve for starting a recovery.
**/
recoveryDeposit: AugmentedConst<BalanceOf>;
};
society: {
[index: string]: AugmentedConst<object & Codec>;
/**
@@ -215,10 +249,45 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: AugmentedConst<EraIndex>;
/**
* The number of blocks before the end of the era from which election submissions are allowed.
*
* Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will
* be used.
*
* This is bounded by being within the last session. Hence, setting it to a value more than the
* length of a session will be pointless.
**/
electionLookahead: AugmentedConst<BlockNumber>;
/**
* Maximum number of balancing iterations to run in the offchain submission.
*
* If set to 0, balance_solution will not be executed at all.
**/
maxIterations: AugmentedConst<u32>;
/**
* The maximum number of nominators rewarded for each validator.
*
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim
* their reward. This used to limit the i/o cost for the nominator payout.
**/
maxNominatorRewardedPerValidator: AugmentedConst<u32>;
/**
* The threshold of improvement that should be provided for a new solution to be accepted.
**/
minSolutionScoreBump: AugmentedConst<Perbill>;
/**
* Number of sessions per era.
**/
sessionsPerEra: AugmentedConst<SessionIndex>;
/**
* Number of eras that slashes are deferred by, after computation.
*
* This should be less than the bonding duration.
* Set to 0 if slashes should be applied immediately, without opportunity for
* intervention.
**/
slashDeferDuration: AugmentedConst<EraIndex>;
};
system: {
[index: string]: AugmentedConst<object & Codec>;
+3 -1
View File
@@ -24,7 +24,7 @@ import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkado
import { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReleasesStaking, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import { AccountInfo, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
import { Multiplier, PaymentReleases } from '@polkadot/types/interfaces/txpayment';
import { Multisig } from '@polkadot/types/interfaces/utility';
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
import { ApiTypes } from '@polkadot/api/types';
@@ -392,6 +392,7 @@ declare module '@polkadot/api/types/storage' {
};
multisig: {
[index: string]: QueryableStorageEntry<ApiType>;
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
/**
* The set of open multisig operations.
**/
@@ -902,6 +903,7 @@ declare module '@polkadot/api/types/storage' {
transactionPayment: {
[index: string]: QueryableStorageEntry<ApiType>;
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>> & QueryableStorageEntry<ApiType>;
storageVersion: AugmentedQuery<ApiType, () => Observable<PaymentReleases>> & QueryableStorageEntry<ApiType>;
};
treasury: {
[index: string]: QueryableStorageEntry<ApiType>;
+9 -7
View File
@@ -19,16 +19,10 @@ import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
import { AccountId, BlockNumber, H256, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
import { ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo } from '@polkadot/types/interfaces/system';
import { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo } from '@polkadot/types/interfaces/system';
declare module '@polkadot/rpc-core/types.jsonrpc' {
export interface RpcInterface {
account: {
/**
* Retrieves the next accountIndex as available on the node
**/
nextIndex: AugmentedRpc<(accountId: AccountId | string | Uint8Array) => Observable<Index>>;
};
author: {
/**
* Returns true if the keystore has private keys for the given public key and key type.
@@ -244,6 +238,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
};
system: {
/**
* Retrieves the next accountIndex as available on the node
**/
accountNextIndex: AugmentedRpc<(accountId: AccountId | string | Uint8Array) => Observable<Index>>;
/**
* Adds a reserved peer
**/
@@ -256,6 +254,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Retrieves the chain type
**/
chainType: AugmentedRpc<() => Observable<ChainType>>;
/**
* Dry run an extrinsic at a given block
**/
dryRun: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ApplyExtrinsicResult>>;
/**
* Return health status of the node
**/
+76 -11
View File
@@ -12,7 +12,7 @@ import { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
import { EquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
import { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
import { Heartbeat } from '@polkadot/types/interfaces/imOnline';
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill, ProxyType, Weight } from '@polkadot/types/interfaces/runtime';
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill, Percent, ProxyType, Weight } from '@polkadot/types/interfaces/runtime';
import { Period, Priority } from '@polkadot/types/interfaces/scheduler';
import { Keys } from '@polkadot/types/interfaces/session';
import { SocietyJudgement } from '@polkadot/types/interfaces/society';
@@ -1280,7 +1280,7 @@ declare module '@polkadot/api/types/submittable' {
* - Write: Multisig Storage, [Caller Account]
* # </weight>
**/
approveAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, callHash: U8aFixed | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
approveAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, callHash: U8aFixed | string | Uint8Array, maxWeight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Register approval for a dispatch to be made from a deterministic composite account if
* approved by a total of `threshold - 1` of `other_signatories`.
@@ -1324,16 +1324,37 @@ declare module '@polkadot/api/types/submittable' {
* `DepositBase + threshold * DepositFactor`.
* -------------------------------
* - Base Weight:
* - Create: 46.55 + 0.089 * S µs
* - Approve: 34.03 + .112 * S µs
* - Complete: 40.36 + .225 * S µs
* - Create: 41.89 + 0.118 * S + .002 * Z µs
* - Create w/ Store: 53.57 + 0.119 * S + .003 * Z µs
* - Approve: 31.39 + 0.136 * S + .002 * Z µs
* - Complete: 39.94 + 0.26 * S + .002 * Z µs
* - DB Weight:
* - Reads: Multisig Storage, [Caller Account]
* - Writes: Multisig Storage, [Caller Account]
* - Reads: Multisig Storage, [Caller Account], Calls (if `store_call`)
* - Writes: Multisig Storage, [Caller Account], Calls (if `store_call`)
* - Plus Call Weight
* # </weight>
**/
asMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
asMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, call: Bytes | string | Uint8Array, storeCall: bool | boolean | Uint8Array, maxWeight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Immediately dispatch a multi-signature call using a single approval from the caller.
*
* The dispatch origin for this call must be _Signed_.
*
* - `other_signatories`: The accounts (other than the sender) who are part of the
* multi-signature, but do not participate in the approval process.
* - `call`: The call to be executed.
*
* Result is equivalent to the dispatched result.
*
* # <weight>
* O(Z + C) where Z is the length of the call and C its execution weight.
* -------------------------------
* - Base Weight: 33.72 + 0.002 * Z µs
* - DB Weight: None
* - Plus Call Weight
* # </weight>
**/
asMultiThreshold1: AugmentedSubmittable<(otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Cancel a pre-existing, on-going multisig transaction. Any deposit reserved previously
* for this operation will be unreserved on success.
@@ -1357,10 +1378,10 @@ declare module '@polkadot/api/types/submittable' {
* - I/O: 1 read `O(S)`, one remove.
* - Storage: removes one item.
* ----------------------------------
* - Base Weight: 37.6 + 0.084 * S
* - Base Weight: 36.07 + 0.124 * S
* - DB Weight:
* - Read: Multisig Storage, [Caller Account]
* - Write: Multisig Storage, [Caller Account]
* - Read: Multisig Storage, [Caller Account], Refund Account, Calls
* - Write: Multisig Storage, [Caller Account], Refund Account, Calls
* # </weight>
**/
cancelAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], timepoint: Timepoint | { height?: any; index?: any } | string | Uint8Array, callHash: U8aFixed | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
@@ -2235,6 +2256,17 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
forceUnstake: AugmentedSubmittable<(stash: AccountId | string | Uint8Array, numSlashingSpans: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Increments the ideal number of validators.
*
* The dispatch origin must be Root.
*
* # <weight>
* Base Weight: 1.717 µs
* Read/Write: Validator Count
* # </weight>
**/
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Declare the desire to nominate `targets` for the origin controller.
*
@@ -2320,6 +2352,17 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
rebond: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Scale up the ideal number of validators by a factor.
*
* The dispatch origin must be Root.
*
* # <weight>
* Base Weight: 1.717 µs
* Read/Write: Validator Count
* # </weight>
**/
scaleValidatorCount: AugmentedSubmittable<(factor: Percent | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* (Re-)set the controller of a stash.
*
@@ -3144,6 +3187,28 @@ declare module '@polkadot/api/types/submittable' {
};
vesting: {
[index: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Force a vested transfer.
*
* The dispatch origin for this call must be _Root_.
*
* - `source`: The account whose funds should be transferred.
* - `target`: The account that should be transferred the vested funds.
* - `amount`: The amount of funds to transfer and will be vested.
* - `schedule`: The vesting schedule attached to the transfer.
*
* Emits `VestingCreated`.
*
* # <weight>
* - `O(1)`.
* - DbWeight: 4 Reads, 4 Writes
* - Reads: Vesting Storage, Balances Locks, Target Account, Source Account
* - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
* - Benchmark: 100.3 + .365 * l µs (min square analysis)
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
* # </weight>
**/
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
/**
* Unlock any vested funds of the sender account.
*
+22 -33
View File
@@ -11,7 +11,7 @@ import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, Dec
import BN from 'bn.js';
import { BehaviorSubject, Observable, combineLatest, of } from 'rxjs';
import { map, switchMap, take, tap, toArray } from 'rxjs/operators';
import { map, switchMap, tap, toArray } from 'rxjs/operators';
import decorateDerive, { ExactDerive } from '@polkadot/api-derive';
import { memo } from '@polkadot/api-derive/util';
import DecoratedMeta from '@polkadot/metadata/Decorated';
@@ -495,35 +495,28 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
const headKey = iterKey(arg).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
return this._rpcCore.state.getKeysPaged
? startSubject.pipe(
switchMap((startKey) =>
this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_KEYS, startKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta)))
)
),
tap((keys): void => {
keys.length === PAGE_SIZE_KEYS
? startSubject.next(keys[PAGE_SIZE_KEYS - 1].toHex())
: startSubject.complete();
}),
toArray(), // toArray since we want to startSubject to be completed
map((keysArr: StorageKey[][]) => keysArr.reduce((result: StorageKey[], keys) => result.concat(keys), []))
)
: this._rpcCore.state.getKeys(headKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta)))
);
return startSubject.pipe(
switchMap((startKey) =>
this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_KEYS, startKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta)))
)
),
tap((keys): void => {
keys.length === PAGE_SIZE_KEYS
? startSubject.next(keys[PAGE_SIZE_KEYS - 1].toHex())
: startSubject.complete();
}),
toArray(), // toArray since we want to startSubject to be completed
map((keysArr: StorageKey[][]) => keysArr.reduce((result: StorageKey[], keys) => result.concat(keys), []))
);
}
private _retrieveMapKeysPaged ({ iterKey, meta }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
const headKey = iterKey(opts.arg).toHex();
const getKeysPaged = this._rpcCore.state.getKeysPaged;
assert(getKeysPaged, 'Pagination not supported by the chain');
return getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey).pipe(
return this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta)))
);
}
@@ -535,13 +528,11 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
of(keys),
...Array(Math.ceil(keys.length / PAGE_SIZE_VALS))
.fill(0)
.map((_, index): Observable<Codec[]> => {
const keyset = keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS);
return this._rpcCore.state.queryStorageAt
? this._rpcCore.state.queryStorageAt<Codec[]>(keyset)
: this._rpcCore.state.subscribeStorage<Codec[]>(keyset).pipe(take(1));
})
.map((_, index): Observable<Codec[]> =>
this._rpcCore.state.queryStorageAt<Codec[]>(
keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS)
)
)
])
),
map(([keys, ...valsArr]): [StorageKey, Codec][] =>
@@ -557,9 +548,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
switchMap((keys) =>
combineLatest<[StorageKey[], ...Codec[][]]>([
of(keys),
this._rpcCore.state.queryStorageAt
? this._rpcCore.state.queryStorageAt<Codec[]>(keys)
: this._rpcCore.state.subscribeStorage<Codec[]>(keys).pipe(take(1))
this._rpcCore.state.queryStorageAt<Codec[]>(keys)
])
),
map(([keys, ...valsArr]): [StorageKey, Codec][] =>
+15 -23
View File
@@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AnyFunction, Callback, Codec } from '@polkadot/types/types';
import { ApiOptions, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads, UnsubscribePromise } from '../types';
import { Callback, Codec } from '@polkadot/types/types';
import { ApiOptions, DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads, UnsubscribePromise, VoidFn } from '../types';
import { Observable, EMPTY } from 'rxjs';
import { EMPTY, Observable, Subscription } from 'rxjs';
import { catchError, first, tap } from 'rxjs/operators';
import { isFunction, assert } from '@polkadot/util';
@@ -36,7 +36,7 @@ function extractArgs (args: any[], needsCallback: boolean): [any[], Callback<Cod
}
// a Promise completion tracker, wrapping an isComplete variable that ensures the promise only resolves once
function promiseTracker (resolve: (value: () => void) => void, reject: (value: Error) => void): Tracker {
function promiseTracker (resolve: (value: VoidFn) => void, reject: (value: Error) => void): Tracker {
let isCompleted = false;
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -63,37 +63,29 @@ function promiseTracker (resolve: (value: () => void) => void, reject: (value: E
/**
* @description Decorate method for ApiPromise, where the results are converted to the Promise equivalent
*/
export function decorateMethod<Method extends AnyFunction> (method: Method, options?: DecorateMethodOptions): StorageEntryPromiseOverloads {
export function decorateMethod<Method extends DecorateFn<ObsInnerType<ReturnType<Method>>>> (method: Method, options?: DecorateMethodOptions): StorageEntryPromiseOverloads {
const needsCallback = options && options.methodName && options.methodName.includes('subscribe');
return function (...args: any[]): Promise<ObsInnerType<ReturnType<Method>>> | UnsubscribePromise {
const [actualArgs, callback] = extractArgs(args, !!needsCallback);
const [actualArgs, resultCb] = extractArgs(args, !!needsCallback);
if (!callback) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
return method(...actualArgs).pipe(first()).toPromise() as Promise<ObsInnerType<ReturnType<Method>>>;
if (!resultCb) {
return method(...actualArgs).pipe(first()).toPromise();
}
return new Promise((resolve, reject): void => {
return new Promise<VoidFn>((resolve, reject): void => {
const tracker = promiseTracker(resolve, reject);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
const subscription: { unsubscribe: () => void } = method(...actualArgs).pipe(
const subscription: Subscription = method(...actualArgs).pipe(
// if we find an error (invalid params, etc), reject the promise
catchError((error): Observable<never> => tracker.reject(error)),
// upon the first result, resolve with the unsub function
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
tap(() => tracker.resolve(() => subscription.unsubscribe()))
).subscribe((result: any): void => {
if (setImmediate) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
setImmediate(() => callback(result) as void);
} else {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
callback(result);
}
).subscribe((result): void => {
// We use setImmediate here to ensure that the Promise above (tracker) has resolved, before returning
// the first result. By putting is back in the queue, the promise above is guarder for first execution
setImmediate(() => resultCb(result) as void);
});
}) as UnsubscribePromise;
});
} as StorageEntryPromiseOverloads;
}
+3 -3
View File
@@ -2,14 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AnyFunction } from '@polkadot/types/types';
import { ApiOptions } from '../types';
import { Codec } from '@polkadot/types/types';
import { ApiOptions, DecorateFn } from '../types';
import { from, Observable } from 'rxjs';
import ApiBase from '../base';
export function decorateMethod <Method extends AnyFunction> (method: Method): Method {
export function decorateMethod <Method extends DecorateFn<Codec>> (method: Method): Method {
return method;
}
+6 -2
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
// Prepend an element V onto the beginning of a tuple T.
@@ -30,7 +30,9 @@ export type ApiTypes = 'promise' | 'rxjs';
// Returns the inner type of an Observable
export type ObsInnerType<O extends Observable<any>> = O extends Observable<infer U> ? U : never;
export type UnsubscribePromise = Promise<() => void>;
export type VoidFn = () => void;
export type UnsubscribePromise = Promise<VoidFn>;
// FIXME The day TS has higher-kinded types, we can remove this hardcoded stuff
export type PromiseOrObs<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
@@ -68,6 +70,8 @@ export interface DecorateMethodOptions {
methodName?: string;
}
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
export interface PaginationOptions<ArgType = CodecArg> {
arg?: ArgType;
pageSize: number;
+2 -2
View File
@@ -5,10 +5,11 @@
// Augment the modules
import '@polkadot/api/augment';
import BN from 'bn.js';
import type BN from 'bn.js';
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import { Constants } from '@polkadot/metadata/Decorated/types';
import { RpcInterface } from '@polkadot/rpc-core/types';
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
import { Metadata } from '@polkadot/types';
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import { DefinitionRpc, DefinitionRpcSub, Signer, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
@@ -18,7 +19,6 @@ import ApiBase from '../base';
import { DecoratedRpc } from './rpc';
import { QueryableStorage, QueryableStorageMulti } from './storage';
import { SubmittableExtrinsics } from './submittable';
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
export { Signer, SignerResult } from '@polkadot/types/types';
export { default as ApiBase } from '../base';
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "1.19.1",
"version": "1.20.1",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"publishConfig": {
@@ -26,14 +26,14 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/types": "1.19.1",
"@polkadot/types-known": "1.19.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/types": "1.20.1",
"@polkadot/types-known": "1.20.1",
"@polkadot/util": "^2.15.1",
"@polkadot/util-crypto": "^2.15.1",
"bn.js": "^5.1.2"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1"
"@polkadot/keyring": "^2.15.1"
}
}
@@ -1588,7 +1588,16 @@
"type": {
"Plain": "Multiplier"
},
"fallback": "0x00000000000000000000000000000000",
"fallback": "0x000064a7b3b6e00d0000000000000000",
"documentation": []
},
{
"name": "StorageVersion",
"modifier": "Default",
"type": {
"Plain": "PaymentReleases"
},
"fallback": "0x00",
"documentation": []
}
]
@@ -2464,6 +2473,44 @@
" # </weight>"
]
},
{
"name": "increase_validator_count",
"args": [
{
"name": "additional",
"type": "Compact<u32>"
}
],
"documentation": [
" Increments the ideal number of validators.",
"",
" The dispatch origin must be Root.",
"",
" # <weight>",
" Base Weight: 1.717 µs",
" Read/Write: Validator Count",
" # </weight>"
]
},
{
"name": "scale_validator_count",
"args": [
{
"name": "factor",
"type": "Percent"
}
],
"documentation": [
" Scale up the ideal number of validators by a factor.",
"",
" The dispatch origin must be Root.",
"",
" # <weight>",
" Base Weight: 1.717 µs",
" Read/Write: Validator Count",
" # </weight>"
]
},
{
"name": "force_no_eras",
"args": [],
@@ -2938,6 +2985,61 @@
"documentation": [
" Number of eras that staked funds must remain bonded for."
]
},
{
"name": "SlashDeferDuration",
"type": "EraIndex",
"value": "0xa8000000",
"documentation": [
" Number of eras that slashes are deferred by, after computation. ",
"",
" This should be less than the bonding duration. ",
" Set to 0 if slashes should be applied immediately, without opportunity for",
" intervention."
]
},
{
"name": "ElectionLookahead",
"type": "BlockNumber",
"value": "0x32000000",
"documentation": [
" The number of blocks before the end of the era from which election submissions are allowed.",
"",
" Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will",
" be used.",
"",
" This is bounded by being within the last session. Hence, setting it to a value more than the",
" length of a session will be pointless."
]
},
{
"name": "MaxIterations",
"type": "u32",
"value": "0x0a000000",
"documentation": [
" Maximum number of balancing iterations to run in the offchain submission. ",
"",
" If set to 0, balance_solution will not be executed at all."
]
},
{
"name": "MinSolutionScoreBump",
"type": "Perbill",
"value": "0x20a10700",
"documentation": [
" The threshold of improvement that should be provided for a new solution to be accepted."
]
},
{
"name": "MaxNominatorRewardedPerValidator",
"type": "u32",
"value": "0x40000000",
"documentation": [
" The maximum number of nominators rewarded for each validator.",
"",
" For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim",
" their reward. This used to limit the i/o cost for the nominator payout."
]
}
],
"errors": [
@@ -4955,7 +5057,7 @@
"DispatchResult"
],
"documentation": [
" A motion was executed; `bool` is true if returned without error."
" A motion was executed; result will be `Ok` if it returned without error."
]
},
{
@@ -4965,7 +5067,7 @@
"DispatchResult"
],
"documentation": [
" A single member did some action; `bool` is true if returned without error."
" A single member did some action; result will be `Ok` if it returned without error."
]
},
{
@@ -4976,7 +5078,7 @@
"MemberCount"
],
"documentation": [
" A proposal was closed after its duration was up."
" A proposal was closed because its threshold was reached or after its duration was up."
]
}
],
@@ -5021,7 +5123,7 @@
{
"name": "TooEarly",
"documentation": [
" The close call is made too early, before the end of the voting."
" The close call was made too early, before the end of the voting."
]
},
{
@@ -5403,7 +5505,7 @@
"DispatchResult"
],
"documentation": [
" A motion was executed; `bool` is true if returned without error."
" A motion was executed; result will be `Ok` if it returned without error."
]
},
{
@@ -5413,7 +5515,7 @@
"DispatchResult"
],
"documentation": [
" A single member did some action; `bool` is true if returned without error."
" A single member did some action; result will be `Ok` if it returned without error."
]
},
{
@@ -5424,7 +5526,7 @@
"MemberCount"
],
"documentation": [
" A proposal was closed after its duration was up."
" A proposal was closed because its threshold was reached or after its duration was up."
]
}
],
@@ -5469,7 +5571,7 @@
{
"name": "TooEarly",
"documentation": [
" The close call is made too early, before the end of the voting."
" The close call was made too early, before the end of the voting."
]
},
{
@@ -9750,7 +9852,40 @@
]
}
],
"constants": [],
"constants": [
{
"name": "ConfigDepositBase",
"type": "BalanceOf",
"value": "0x00406352bfc601000000000000000000",
"documentation": [
" The base amount of currency needed to reserve for creating a recovery configuration."
]
},
{
"name": "FriendDepositFactor",
"type": "BalanceOf",
"value": "0x00203d88792d00000000000000000000",
"documentation": [
" The amount of currency needed per additional user when creating a recovery configuration."
]
},
{
"name": "MaxFriends",
"type": "u16",
"value": "0x0900",
"documentation": [
" The maximum amount of friends allowed in a recovery configuration."
]
},
{
"name": "RecoveryDeposit",
"type": "BalanceOf",
"value": "0x00406352bfc601000000000000000000",
"documentation": [
" The base amount of currency needed to reserve for starting a recovery."
]
}
],
"errors": [
{
"name": "NotAllowed",
@@ -9959,6 +10094,44 @@
" - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.",
" # </weight>"
]
},
{
"name": "force_vested_transfer",
"args": [
{
"name": "source",
"type": "LookupSource"
},
{
"name": "target",
"type": "LookupSource"
},
{
"name": "schedule",
"type": "VestingInfo"
}
],
"documentation": [
" Force a vested transfer.",
"",
" The dispatch origin for this call must be _Root_.",
"",
" - `source`: The account whose funds should be transferred.",
" - `target`: The account that should be transferred the vested funds.",
" - `amount`: The amount of funds to transfer and will be vested.",
" - `schedule`: The vesting schedule attached to the transfer.",
"",
" Emits `VestingCreated`.",
"",
" # <weight>",
" - `O(1)`.",
" - DbWeight: 4 Reads, 4 Writes",
" - Reads: Vesting Storage, Balances Locks, Target Account, Source Account",
" - Writes: Vesting Storage, Balances Locks, Target Account, Source Account",
" - Benchmark: 100.3 + .365 * l µs (min square analysis)",
" - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.",
" # </weight>"
]
}
],
"events": [
@@ -10446,7 +10619,32 @@
]
}
],
"constants": [],
"constants": [
{
"name": "ProxyDepositBase",
"type": "BalanceOf",
"value": "0x00f09e544c3900000000000000000000",
"documentation": [
" The base amount of currency needed to reserve for creating a proxy."
]
},
{
"name": "ProxyDepositFactor",
"type": "BalanceOf",
"value": "0x0060aa7714b400000000000000000000",
"documentation": [
" The amount of currency needed per proxy added."
]
},
{
"name": "MaxProxies",
"type": "u16",
"value": "0x2000",
"documentation": [
" The maximum amount of proxies allowed for a single account."
]
}
],
"errors": [
{
"name": "TooMany",
@@ -10507,10 +10705,56 @@
"documentation": [
" The set of open multisig operations."
]
},
{
"name": "Calls",
"modifier": "Optional",
"type": {
"Map": {
"hasher": "Identity",
"key": "[u8;32]",
"value": "(Bytes,AccountId,BalanceOf)",
"linked": false
}
},
"fallback": "0x00",
"documentation": []
}
]
},
"calls": [
{
"name": "as_multi_threshold_1",
"args": [
{
"name": "other_signatories",
"type": "Vec<AccountId>"
},
{
"name": "call",
"type": "Call"
}
],
"documentation": [
" Immediately dispatch a multi-signature call using a single approval from the caller.",
"",
" The dispatch origin for this call must be _Signed_.",
"",
" - `other_signatories`: The accounts (other than the sender) who are part of the",
" multi-signature, but do not participate in the approval process.",
" - `call`: The call to be executed.",
"",
" Result is equivalent to the dispatched result.",
"",
" # <weight>",
" O(Z + C) where Z is the length of the call and C its execution weight.",
" -------------------------------",
" - Base Weight: 33.72 + 0.002 * Z µs",
" - DB Weight: None",
" - Plus Call Weight",
" # </weight>"
]
},
{
"name": "as_multi",
"args": [
@@ -10528,7 +10772,15 @@
},
{
"name": "call",
"type": "Call"
"type": "Bytes"
},
{
"name": "store_call",
"type": "bool"
},
{
"name": "max_weight",
"type": "Weight"
}
],
"documentation": [
@@ -10574,12 +10826,13 @@
" `DepositBase + threshold * DepositFactor`.",
" -------------------------------",
" - Base Weight:",
" - Create: 46.55 + 0.089 * S µs",
" - Approve: 34.03 + .112 * S µs",
" - Complete: 40.36 + .225 * S µs",
" - Create: 41.89 + 0.118 * S + .002 * Z µs",
" - Create w/ Store: 53.57 + 0.119 * S + .003 * Z µs",
" - Approve: 31.39 + 0.136 * S + .002 * Z µs",
" - Complete: 39.94 + 0.26 * S + .002 * Z µs",
" - DB Weight:",
" - Reads: Multisig Storage, [Caller Account]",
" - Writes: Multisig Storage, [Caller Account]",
" - Reads: Multisig Storage, [Caller Account], Calls (if `store_call`)",
" - Writes: Multisig Storage, [Caller Account], Calls (if `store_call`)",
" - Plus Call Weight",
" # </weight>"
]
@@ -10602,6 +10855,10 @@
{
"name": "call_hash",
"type": "[u8;32]"
},
{
"name": "max_weight",
"type": "Weight"
}
],
"documentation": [
@@ -10689,10 +10946,10 @@
" - I/O: 1 read `O(S)`, one remove.",
" - Storage: removes one item.",
" ----------------------------------",
" - Base Weight: 37.6 + 0.084 * S",
" - Base Weight: 36.07 + 0.124 * S",
" - DB Weight:",
" - Read: Multisig Storage, [Caller Account]",
" - Write: Multisig Storage, [Caller Account]",
" - Read: Multisig Storage, [Caller Account], Refund Account, Calls",
" - Write: Multisig Storage, [Caller Account], Refund Account, Calls",
" # </weight>"
]
}
@@ -10754,9 +11011,9 @@
"constants": [],
"errors": [
{
"name": "ZeroThreshold",
"name": "MinimumThreshold",
"documentation": [
" Threshold is too low (zero)."
" Threshold must be 2 or greater."
]
},
{
@@ -10824,6 +11081,18 @@
"documentation": [
" A timepoint was given, yet no multisig operation is underway."
]
},
{
"name": "WeightTooLow",
"documentation": [
" The maximum weight information provided was too low."
]
},
{
"name": "AlreadyStored",
"documentation": [
" The data to be stored is already stored."
]
}
]
}
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "1.19.1",
"version": "1.20.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -26,15 +26,15 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/metadata": "1.19.1",
"@polkadot/rpc-provider": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/metadata": "1.20.1",
"@polkadot/rpc-provider": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1"
"@polkadot/keyring": "^2.15.1"
}
}
+7 -4
View File
@@ -16,6 +16,11 @@ import { assert, hexToU8a, isFunction, isNull, isNumber, isUndefined, logger, u8
import { drr } from './rxjs';
interface StorageChangeSetJSON {
block: string;
changes: [string, string | null][];
}
const l = logger('rpc-core');
const EMPTY_META = {
@@ -75,8 +80,6 @@ export default class Rpc implements RpcInterface {
// these via the createInterfaces inside the constructor. However... this is not quite visible. The reason
// why we don't do for individual assignments is to allow user-defined RPCs to also be defined
public readonly account!: RpcInterface['account'];
public readonly author!: RpcInterface['author'];
public readonly babe!: RpcInterface['babe'];
@@ -341,10 +344,10 @@ export default class Rpc implements RpcInterface {
const keys = params[0] as Vec<StorageKey>;
return keys
? this._formatStorageSet(keys, (result as { changes: [string, string | null][] }).changes)
? this._formatStorageSet(keys, (result as StorageChangeSetJSON).changes)
: this.registry.createType('StorageChangeSet', result);
} else if (rpc.type === 'Vec<StorageChangeSet>') {
const mapped = (result as { block: string; changes: [string, string | null][] }[]).map(({ block, changes }): [Hash, Codec[]] => [
const mapped = (result as StorageChangeSetJSON[]).map(({ block, changes }): [Hash, Codec[]] => [
this.registry.createType('Hash', block),
this._formatStorageSet(params[0] as Vec<StorageKey>, changes)
]);
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "1.19.1",
"version": "1.20.1",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -26,18 +26,18 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/metadata": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/metadata": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"@polkadot/util-crypto": "^2.15.1",
"bn.js": "^5.1.2",
"eventemitter3": "^4.0.4",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.31"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1",
"@polkadot/keyring": "^2.15.1",
"mock-socket": "^9.0.3",
"nock": "^12.0.3"
}
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "1.19.1",
"version": "1.20.1",
"description": "Type generation scripts",
"main": "index.js",
"bin": {
@@ -33,14 +33,14 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.10.2",
"@babel/register": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@polkadot/api": "1.19.1",
"@polkadot/metadata": "1.19.1",
"@polkadot/rpc-provider": "1.19.1",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@babel/core": "^7.10.3",
"@babel/register": "^7.10.3",
"@babel/runtime": "^7.10.3",
"@polkadot/api": "1.20.1",
"@polkadot/metadata": "1.20.1",
"@polkadot/rpc-provider": "1.20.1",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"handlebars": "^4.7.6",
"websocket": "^1.0.31",
"yargs": "^15.3.1"
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "1.19.1",
"version": "1.20.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -26,9 +26,9 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/types": "1.19.1",
"@polkadot/util": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/types": "1.20.1",
"@polkadot/util": "^2.15.1",
"bn.js": "^5.1.2"
},
"devDependencies": {
+3
View File
@@ -34,6 +34,9 @@ const typesModules: Record<string, OverrideModuleType> = {
Compact: 'CompactAssignments',
Releases: 'ReleasesStaking'
},
transactionPayment: {
Releases: 'PaymentReleases'
},
treasury: {
Proposal: 'TreasuryProposal'
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "1.19.1",
"version": "1.20.1",
"description": "Implementation of the Parity codec",
"main": "index.js",
"keywords": [
@@ -26,17 +26,17 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/metadata": "1.19.1",
"@polkadot/util": "^2.14.1",
"@polkadot/util-crypto": "^2.14.1",
"@babel/runtime": "^7.10.3",
"@polkadot/metadata": "1.20.1",
"@polkadot/util": "^2.15.1",
"@polkadot/util-crypto": "^2.15.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^5.1.2",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^2.14.1",
"@polkadot/keyring": "^2.15.1",
"@types/memoizee": "^0.4.4"
}
}
+33 -15
View File
@@ -31,16 +31,16 @@ import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, Cand
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, DispatchClass, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import { AccountInfo, ChainProperties, ChainType, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount } from '@polkadot/types/interfaces/system';
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
import { Multiplier, PaymentReleases } from '@polkadot/types/interfaces/txpayment';
import { CallHash, Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
@@ -171,18 +171,6 @@ declare module '@polkadot/types/types/registry' {
DigestItem: DigestItem;
'Option<DigestItem>': Option<DigestItem>;
'Vec<DigestItem>': Vec<DigestItem>;
DispatchClass: DispatchClass;
'Option<DispatchClass>': Option<DispatchClass>;
'Vec<DispatchClass>': Vec<DispatchClass>;
DispatchInfo: DispatchInfo;
'Option<DispatchInfo>': Option<DispatchInfo>;
'Vec<DispatchInfo>': Vec<DispatchInfo>;
DispatchInfoTo190: DispatchInfoTo190;
'Option<DispatchInfoTo190>': Option<DispatchInfoTo190>;
'Vec<DispatchInfoTo190>': Vec<DispatchInfoTo190>;
DispatchInfoTo244: DispatchInfoTo244;
'Option<DispatchInfoTo244>': Option<DispatchInfoTo244>;
'Vec<DispatchInfoTo244>': Vec<DispatchInfoTo244>;
ExtrinsicsWeight: ExtrinsicsWeight;
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
@@ -1008,6 +996,9 @@ declare module '@polkadot/types/types/registry' {
AccountInfo: AccountInfo;
'Option<AccountInfo>': Option<AccountInfo>;
'Vec<AccountInfo>': Vec<AccountInfo>;
ApplyExtrinsicResult: ApplyExtrinsicResult;
'Option<ApplyExtrinsicResult>': Option<ApplyExtrinsicResult>;
'Vec<ApplyExtrinsicResult>': Vec<ApplyExtrinsicResult>;
ChainProperties: ChainProperties;
'Option<ChainProperties>': Option<ChainProperties>;
'Vec<ChainProperties>': Vec<ChainProperties>;
@@ -1017,6 +1008,9 @@ declare module '@polkadot/types/types/registry' {
DigestOf: DigestOf;
'Option<DigestOf>': Option<DigestOf>;
'Vec<DigestOf>': Vec<DigestOf>;
DispatchClass: DispatchClass;
'Option<DispatchClass>': Option<DispatchClass>;
'Vec<DispatchClass>': Vec<DispatchClass>;
DispatchError: DispatchError;
'Option<DispatchError>': Option<DispatchError>;
'Vec<DispatchError>': Vec<DispatchError>;
@@ -1026,6 +1020,18 @@ declare module '@polkadot/types/types/registry' {
DispatchErrorTo198: DispatchErrorTo198;
'Option<DispatchErrorTo198>': Option<DispatchErrorTo198>;
'Vec<DispatchErrorTo198>': Vec<DispatchErrorTo198>;
DispatchInfo: DispatchInfo;
'Option<DispatchInfo>': Option<DispatchInfo>;
'Vec<DispatchInfo>': Vec<DispatchInfo>;
DispatchInfoTo190: DispatchInfoTo190;
'Option<DispatchInfoTo190>': Option<DispatchInfoTo190>;
'Vec<DispatchInfoTo190>': Vec<DispatchInfoTo190>;
DispatchInfoTo244: DispatchInfoTo244;
'Option<DispatchInfoTo244>': Option<DispatchInfoTo244>;
'Vec<DispatchInfoTo244>': Vec<DispatchInfoTo244>;
DispatchOutcome: DispatchOutcome;
'Option<DispatchOutcome>': Option<DispatchOutcome>;
'Vec<DispatchOutcome>': Vec<DispatchOutcome>;
DispatchResult: DispatchResult;
'Option<DispatchResult>': Option<DispatchResult>;
'Vec<DispatchResult>': Vec<DispatchResult>;
@@ -1054,6 +1060,9 @@ declare module '@polkadot/types/types/registry' {
Health: Health;
'Option<Health>': Option<Health>;
'Vec<Health>': Vec<Health>;
InvalidTransaction: InvalidTransaction;
'Option<InvalidTransaction>': Option<InvalidTransaction>;
'Vec<InvalidTransaction>': Vec<InvalidTransaction>;
Key: Key;
'Option<Key>': Option<Key>;
'Vec<Key>': Vec<Key>;
@@ -1097,6 +1106,12 @@ declare module '@polkadot/types/types/registry' {
'Compact<RefCount>': Compact<RefCount>;
'Option<RefCount>': Option<RefCount>;
'Vec<RefCount>': Vec<RefCount>;
TransactionValidityError: TransactionValidityError;
'Option<TransactionValidityError>': Option<TransactionValidityError>;
'Vec<TransactionValidityError>': Vec<TransactionValidityError>;
UnknownTransaction: UnknownTransaction;
'Option<UnknownTransaction>': Option<UnknownTransaction>;
'Vec<UnknownTransaction>': Vec<UnknownTransaction>;
OpenTip: OpenTip;
'Option<OpenTip>': Option<OpenTip>;
'Vec<OpenTip>': Vec<OpenTip>;
@@ -1112,6 +1127,9 @@ declare module '@polkadot/types/types/registry' {
Multiplier: Multiplier;
'Option<Multiplier>': Option<Multiplier>;
'Vec<Multiplier>': Vec<Multiplier>;
PaymentReleases: PaymentReleases;
'Option<PaymentReleases>': Option<PaymentReleases>;
'Vec<PaymentReleases>': Vec<PaymentReleases>;
CallHash: CallHash;
'Option<CallHash>': Option<CallHash>;
'Vec<CallHash>': Vec<CallHash>;
@@ -1,25 +0,0 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// order important in structs... :)
/* eslint-disable sort-keys */
import { Definitions } from '../../types';
export default {
rpc: {
nextIndex: {
alias: ['system_accountNextIndex'],
description: 'Retrieves the next accountIndex as available on the node',
params: [
{
name: 'accountId',
type: 'AccountId'
}
],
type: 'Index'
}
},
types: {}
} as Definitions;
@@ -1,4 +0,0 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export * from './types';
@@ -1,4 +0,0 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export type PHANTOM_ACCOUNT = 'account';
@@ -45,7 +45,6 @@ export { default as metadata } from './metadata/definitions';
export { default as rpc } from './rpc/definitions';
// rpc-only definitions
export { default as account } from './account/definitions';
export { default as author } from './author/definitions';
export { default as chain } from './chain/definitions';
export { default as childstate } from './childstate/definitions';
@@ -2,7 +2,8 @@
/* eslint-disable */
import { Struct } from '@polkadot/types/codec';
import { Balance, DispatchClass, Weight } from '@polkadot/types/interfaces/runtime';
import { Balance, Weight } from '@polkadot/types/interfaces/runtime';
import { DispatchClass } from '@polkadot/types/interfaces/system';
/** @name RuntimeDispatchInfo */
export interface RuntimeDispatchInfo extends Struct {
@@ -39,23 +39,6 @@ export default {
PreRuntime: 'PreRuntime' // 6
}
},
DispatchClass: {
_enum: ['Normal', 'Operational', 'Mandatory']
},
DispatchInfo: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'Pays'
},
DispatchInfoTo190: {
weight: 'Weight',
class: 'DispatchClass'
},
DispatchInfoTo244: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'bool'
},
ExtrinsicsWeight: {
normal: 'Weight',
operational: 'Weight'
+1 -28
View File
@@ -4,7 +4,7 @@
import { ITuple } from '@polkadot/types/types';
import { Compact, Enum, Int, Struct, U8aFixed, Vec } from '@polkadot/types/codec';
import { GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId } from '@polkadot/types/generic';
import { Bytes, DoNotConstruct, Null, StorageKey, bool, u128, u32, u64, u8 } from '@polkadot/types/primitive';
import { Bytes, DoNotConstruct, Null, StorageKey, u128, u32, u64, u8 } from '@polkadot/types/primitive';
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
import { Signature } from '@polkadot/types/interfaces/extrinsics';
@@ -73,33 +73,6 @@ export interface DigestItem extends Enum {
readonly asPreRuntime: PreRuntime;
}
/** @name DispatchClass */
export interface DispatchClass extends Enum {
readonly isNormal: boolean;
readonly isOperational: boolean;
readonly isMandatory: boolean;
}
/** @name DispatchInfo */
export interface DispatchInfo extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: Pays;
}
/** @name DispatchInfoTo190 */
export interface DispatchInfoTo190 extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
}
/** @name DispatchInfoTo244 */
export interface DispatchInfoTo244 extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: bool;
}
/** @name ExtrinsicsWeight */
export interface ExtrinsicsWeight extends Struct {
readonly normal: Weight;
@@ -9,6 +9,33 @@ import { Definitions } from '../../types';
export default {
rpc: {
accountNextIndex: {
alias: ['account_nextIndex'],
description: 'Retrieves the next accountIndex as available on the node',
params: [
{
name: 'accountId',
type: 'AccountId'
}
],
type: 'Index'
},
dryRun: {
alias: ['system_dryRunAt'],
description: 'Dry run an extrinsic at a given block',
params: [
{
name: 'extrinsic',
type: 'Bytes'
},
{
name: 'at',
type: 'BlockHash',
isOptional: true
}
],
type: 'ApplyExtrinsicResult'
},
name: {
description: 'Retrieves the node name',
params: [],
@@ -91,6 +118,7 @@ export default {
refcount: 'RefCount',
data: 'AccountData'
},
ApplyExtrinsicResult: 'Result<DispatchOutcome, TransactionValidityError>',
ChainProperties: {
ss58Format: 'Option<u8>',
tokenDecimals: 'Option<u32>',
@@ -105,6 +133,9 @@ export default {
}
},
DigestOf: 'Digest',
DispatchClass: {
_enum: ['Normal', 'Operational', 'Mandatory']
},
DispatchError: {
_enum: {
Other: 'Null',
@@ -121,6 +152,21 @@ export default {
module: 'Option<u8>',
error: 'u8'
},
DispatchInfo: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'Pays'
},
DispatchInfoTo190: {
weight: 'Weight',
class: 'DispatchClass'
},
DispatchInfoTo244: {
weight: 'Weight',
class: 'DispatchClass',
paysFee: 'bool'
},
DispatchOutcome: 'Result<(), DispatchError>',
DispatchResult: 'Result<(), DispatchError>',
DispatchResultOf: 'DispatchResult',
DispatchResultTo198: 'Result<(), Text>',
@@ -141,6 +187,20 @@ export default {
isSyncing: 'bool',
shouldHavePeers: 'bool'
},
InvalidTransaction: {
_enum: {
Call: 'Null',
Payment: 'Null',
Future: 'Null',
Stale: 'Null',
BadProof: 'Null',
AncientBirthBlock: 'Null',
ExhaustsResources: 'Null',
Custom: 'u8',
BadMandatory: 'Null',
MandatoryDispatch: 'Null'
}
},
Key: 'Bytes',
LastRuntimeUpgradeInfo: {
specVersion: 'Compact<u32>',
@@ -214,6 +274,19 @@ export default {
Initialization: 'Null'
}
},
RefCount: 'u8'
RefCount: 'u8',
TransactionValidityError: {
_enum: {
Invalid: 'InvalidTransaction',
Unknown: 'UnknownTransaction'
}
},
UnknownTransaction: {
_enum: {
CannotLookup: 'Null',
NoUnsignedValidator: 'Null',
Custom: 'u8'
}
}
}
} as Definitions;
+75 -1
View File
@@ -6,7 +6,7 @@ import { Compact, Enum, HashMap, Option, Result, Struct, U8aFixed, Vec } from '@
import { GenericEvent } from '@polkadot/types/generic';
import { Bytes, Text, bool, u32, u64, u8 } from '@polkadot/types/primitive';
import { AccountData } from '@polkadot/types/interfaces/balances';
import { BlockNumber, Digest, Hash, Index } from '@polkadot/types/interfaces/runtime';
import { BlockNumber, Digest, Hash, Index, Pays, Weight } from '@polkadot/types/interfaces/runtime';
/** @name AccountInfo */
export interface AccountInfo extends Struct {
@@ -15,6 +15,14 @@ export interface AccountInfo extends Struct {
readonly data: AccountData;
}
/** @name ApplyExtrinsicResult */
export interface ApplyExtrinsicResult extends Result<DispatchOutcome, TransactionValidityError> {
readonly isError: boolean;
readonly asError: TransactionValidityError;
readonly isOk: boolean;
readonly asOk: DispatchOutcome;
}
/** @name ChainProperties */
export interface ChainProperties extends Struct {
readonly ss58Format: Option<u8>;
@@ -34,6 +42,13 @@ export interface ChainType extends Enum {
/** @name DigestOf */
export interface DigestOf extends Digest {}
/** @name DispatchClass */
export interface DispatchClass extends Enum {
readonly isNormal: boolean;
readonly isOperational: boolean;
readonly isMandatory: boolean;
}
/** @name DispatchError */
export interface DispatchError extends Enum {
readonly isOther: boolean;
@@ -55,6 +70,34 @@ export interface DispatchErrorTo198 extends Struct {
readonly error: u8;
}
/** @name DispatchInfo */
export interface DispatchInfo extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: Pays;
}
/** @name DispatchInfoTo190 */
export interface DispatchInfoTo190 extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
}
/** @name DispatchInfoTo244 */
export interface DispatchInfoTo244 extends Struct {
readonly weight: Weight;
readonly class: DispatchClass;
readonly paysFee: bool;
}
/** @name DispatchOutcome */
export interface DispatchOutcome extends Result<ITuple<[]>, DispatchError> {
readonly isError: boolean;
readonly asError: DispatchError;
readonly isOk: boolean;
readonly asOk: ITuple<[]>;
}
/** @name DispatchResult */
export interface DispatchResult extends Result<ITuple<[]>, DispatchError> {
readonly isError: boolean;
@@ -103,6 +146,21 @@ export interface Health extends Struct {
readonly shouldHavePeers: bool;
}
/** @name InvalidTransaction */
export interface InvalidTransaction extends Enum {
readonly isCall: boolean;
readonly isPayment: boolean;
readonly isFuture: boolean;
readonly isStale: boolean;
readonly isBadProof: boolean;
readonly isAncientBirthBlock: boolean;
readonly isExhaustsResources: boolean;
readonly isCustom: boolean;
readonly asCustom: u8;
readonly isBadMandatory: boolean;
readonly isMandatoryDispatch: boolean;
}
/** @name Key */
export interface Key extends Bytes {}
@@ -199,4 +257,20 @@ export interface Phase extends Enum {
/** @name RefCount */
export interface RefCount extends u8 {}
/** @name TransactionValidityError */
export interface TransactionValidityError extends Enum {
readonly isInvalid: boolean;
readonly asInvalid: InvalidTransaction;
readonly isUnknown: boolean;
readonly asUnknown: UnknownTransaction;
}
/** @name UnknownTransaction */
export interface UnknownTransaction extends Enum {
readonly isCannotLookup: boolean;
readonly isNoUnsignedValidator: boolean;
readonly isCustom: boolean;
readonly asCustom: u8;
}
export type PHANTOM_SYSTEM = 'system';
@@ -7,6 +7,9 @@ import { Definitions } from '../../types';
export default {
rpc: {},
types: {
Multiplier: 'Fixed128'
Multiplier: 'Fixed128',
PaymentReleases: {
_enum: ['V1Ancient', 'V2']
}
}
} as Definitions;
@@ -1,9 +1,16 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import { Enum } from '@polkadot/types/codec';
import { Fixed128 } from '@polkadot/types/interfaces/runtime';
/** @name Multiplier */
export interface Multiplier extends Fixed128 {}
/** @name PaymentReleases */
export interface PaymentReleases extends Enum {
readonly isV1Ancient: boolean;
readonly isV2: boolean;
}
export type PHANTOM_TXPAYMENT = 'txpayment';
-1
View File
@@ -35,7 +35,6 @@ export * from './claims/types';
export * from './parachains/types';
export * from './metadata/types';
export * from './rpc/types';
export * from './account/types';
export * from './author/types';
export * from './chain/types';
export * from './childstate/types';
+5 -1
View File
@@ -2,6 +2,8 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec } from './codec';
import BN from 'bn.js';
// We cannot inline this into CodecArg, TS thrws up when building docs
@@ -26,4 +28,6 @@ export type ArrayElementType<T extends ReadonlyArray<unknown>> = T extends Reado
export type BareOpts = boolean | Record<string, boolean>;
export type Callback<T> = (result: T) => void | Promise<void>;
export type Callback<T, E = undefined> = E extends Codec
? (result: T, extra: E) => void | Promise<void>
: (result: T) => void | Promise<void>;
+532 -647
View File
File diff suppressed because it is too large Load Diff