Compare commits

...
11 Commits
Author SHA1 Message Date
Github Actions 8475130a22 [CI Skip] release/stable 6.2.1
skip-checks: true
2021-10-04 08:33:37 +00:00
Jaco a7e824ff09 6.2.1 (#4016)
* 6.2.1

* CHANGELOG

* Bump static metadata

* CHANGELOG
2021-10-04 11:17:55 +03:00
Alexander Popiak 9d5fb2bf72 Add asset id in signing (#4009)
* add assetId to SignerOptions

* pull assetId into extrinsic signing

* set assetId to optional AnyNumber throughout

* add logging of extrinsic options

* add assetId to _injectSignature & add getters

* re-add import

* longer doc comments
2021-10-04 10:02:28 +03:00
Github Actions 2cf0e306dd [CI Skip] release/beta 6.1.3-3
skip-checks: true
2021-10-01 10:17:38 +00:00
Jaco 72d5330727 Use lookup types in derives (#4012)
* Use lookup types in derives

* additional

* society
2021-10-01 13:02:24 +03:00
Github Actions 1c3bdda08f [CI Skip] release/beta 6.1.3-2
skip-checks: true
2021-10-01 08:51:17 +00:00
Jaco 668ad3dfe5 Handle plain multi queries diguised as map-form (#4011) 2021-10-01 11:29:12 +03:00
Github Actions 651afaeb9a [CI Skip] release/beta 6.1.3-1
skip-checks: true
2021-09-30 06:54:52 +00:00
Jaco 5036aa9ef4 Better error messages for misformed queries (#4007)
* Better error messages for misformed queries

* Cater for raw function (no meta)
2021-09-30 09:39:13 +03:00
Github Actions 3598cc25f4 [CI Skip] release/beta 6.1.3-0
skip-checks: true
2021-09-29 12:28:47 +00:00
Jaco 987a2ec2df Adjust multi to infer return types (#4002)
* Adjust multi to infer return types

* some linting

* Additional

* Dedupe
2021-09-29 14:07:29 +02:00
86 changed files with 682 additions and 757 deletions
+18
View File
@@ -1,5 +1,23 @@
# CHANGELOG
## 6.2.1 Oct 4, 2021
Upgrade priority: Low. Maintenance updates.
Contributed:
- Cater for new asset fee payment extension (Thanks to https://github.com/apopiak)
Changes:
- Extend error messages for malformed `queryMulti` inputs
- Correctly handle non-map queries passed to `queryMulti` in map form
- Use new metadata v14 lookup type in derive results
- Adjust definitions to infer TS types in `.multi` queries
- Fix TS lookup enum generation with nested Option & Tuple
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 6.1.2 Sep 29, 2021
Upgrade priority: Low. Recommended for 6.x users using historic queries.
+1 -1
View File
@@ -35,6 +35,6 @@
"@types/jest": "^27.0.2",
"copyfiles": "^2.4.1"
},
"version": "6.1.2",
"version": "6.2.1",
"packageManager": "yarn@3.0.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.1.2",
"@polkadot/types": "6.1.2",
"@polkadot/api": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.2.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -20,15 +20,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.1.2",
"@polkadot/rpc-core": "6.1.2",
"@polkadot/types": "6.1.2",
"@polkadot/api": "6.2.1",
"@polkadot/rpc-core": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-provider": "6.1.2"
"@polkadot/rpc-provider": "6.2.1"
}
}
+11 -8
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Data, Option } from '@polkadot/types';
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletIdentityIdentityInfo, PalletIdentityRegistration } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
@@ -14,6 +15,8 @@ import { isHex, u8aToString } from '@polkadot/util';
import { memo } from '../util';
type IdentityInfoAdditional = PalletIdentityIdentityInfo['additional'][0];
const UNDEF_HEX = { toHex: () => undefined };
function dataAsString (data: Data): string | undefined {
@@ -37,7 +40,7 @@ function extractOther (additional: IdentityInfoAdditional[]): Record<string, str
}, {});
}
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
function extractIdentity (identityOfOpt?: Option<PalletIdentityRegistration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
if (!identityOfOpt?.isSome) {
return { judgements: [] };
}
@@ -61,7 +64,7 @@ function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [Accou
};
}
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> {
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<PalletIdentityRegistration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<PalletIdentityRegistration> | undefined, [AccountId, Data] | undefined]> {
if (identityOfOpt?.isSome) {
// this identity has something set
return of([identityOfOpt, undefined]);
@@ -70,7 +73,7 @@ function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | u
// we have a super
return combineLatest([
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
api.query.identity.identityOf(superOf[0]),
of(superOf)
]);
}
@@ -79,9 +82,9 @@ function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | u
return of([undefined, undefined]);
}
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<PalletIdentityRegistration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
return accountId && api.query.identity?.identityOf
? api.queryMulti<[Option<Registration>, Option<ITuple<[AccountId, Data]>>]>([
? api.queryMulti<[Option<PalletIdentityRegistration>, Option<ITuple<[AccountId, Data]>>]>([
[api.query.identity.identityOf, accountId],
[api.query.identity.superOf, accountId]
])
@@ -113,8 +116,8 @@ export function hasIdentityMulti (instanceId: string, api: ApiInterfaceRx): (acc
return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable<DeriveHasIdentity[]> =>
api.query.identity?.identityOf
? combineLatest([
api.query.identity.identityOf.multi<Option<Registration>>(accountIds),
api.query.identity.superOf.multi<Option<ITuple<[AccountId, Data]>>>(accountIds)
api.query.identity.identityOf.multi(accountIds),
api.query.identity.superOf.multi(accountIds)
]).pipe(
map(([identities, supers]) =>
identities.map((identityOfOpt, index): DeriveHasIdentity => {
+16 -15
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import type { AccountId, AccountIndex, Address, Balance, BalanceLockTo212, BlockNumber, VestingSchedule } from '@polkadot/types/interfaces';
import type { PalletBalancesBalanceLock, PalletVestingVestingInfo } from '@polkadot/types/lookup';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,15 +14,15 @@ import { BN, bnMax, isFunction } from '@polkadot/util';
import { memo } from '../util';
type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
type BalanceLocksEntry = Vec<PalletBalancesBalanceLock | BalanceLockTo212>;
type BalanceLocks = BalanceLocksEntry[];
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
type ResultBalance = [PalletVestingVestingInfo | null, ((PalletBalancesBalanceLock | BalanceLockTo212)[])[]];
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
interface AllLocked {
allLocked: boolean,
lockedBalance: Balance,
lockedBreakdown: (BalanceLock | BalanceLockTo212)[],
lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[],
vestingLocked: Balance
}
@@ -33,9 +34,9 @@ type DeriveCustomLocks = ApiInterfaceRx['derive'] & {
const VESTING_ID = '0x76657374696e6720';
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (BalanceLock | BalanceLockTo212)[]): AllLocked {
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): AllLocked {
let lockedBalance = api.registry.createType('Balance');
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
let lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[] = [];
let vestingLocked = api.registry.createType('Balance');
let allLocked = false;
@@ -56,7 +57,7 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
}
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
return {
@@ -73,7 +74,7 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
// Calculate the vesting balances,
// - offset = balance locked at startingBlock
// - perBlock is the unlock amount
const emptyVest = api.registry.createType('VestingInfo');
const emptyVest = api.registry.createType<PalletVestingVestingInfo>('VestingInfo');
const { locked: vestingTotal, perBlock, startingBlock } = vesting || emptyVest;
const isStarted = bestNumber.gt(startingBlock);
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
@@ -96,7 +97,7 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
// old
function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
return api.queryMulti<[Vec<BalanceLock>, Option<VestingSchedule>]>([
return api.queryMulti<[Vec<PalletBalancesBalanceLock>, Option<VestingSchedule>]>([
[api.query.balances.locks, accountId],
[api.query.balances.vesting, accountId]
]).pipe(
@@ -106,7 +107,7 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
if (optVesting.isSome) {
const { offset: locked, perBlock, startingBlock } = optVesting.unwrap();
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
vestingNew = api.registry.createType<PalletVestingVestingInfo>('VestingInfo', { locked, perBlock, startingBlock });
}
return [vestingNew, [locks]];
@@ -126,20 +127,20 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstanc
return (
api.query.vesting?.vesting
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
? api.queryMulti<[Option<PalletVestingVestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
// TODO We need to check module instances here as well, not only the balances module
: queries.length
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(queries).pipe(
map((r): [Option<VestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
? api.queryMulti<[...(Vec<PalletBalancesBalanceLock>)[]]>(queries).pipe(
map((r): [Option<PalletVestingVestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
)
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
: of([api.registry.createType('Option<VestingInfo>')] as [Option<PalletVestingVestingInfo>])
).pipe(
map(([opt, ...locks]): ResultBalance => {
let offset = -1;
return [
opt.unwrapOr(null),
lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])
lockEmpty.map((e) => e ? api.registry.createType<Vec<PalletBalancesBalanceLock>>('Vec<BalanceLock>') : locks[++offset])
];
})
);
+38
View File
@@ -0,0 +1,38 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Balance, BalanceLockTo212, BlockNumber, Index } from '@polkadot/types/interfaces';
import type { PalletBalancesBalanceLock } from '@polkadot/types/lookup';
export interface DeriveBalancesAccountData {
freeBalance: Balance;
frozenFee: Balance;
frozenMisc: Balance;
reservedBalance: Balance;
votingBalance: Balance;
}
export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
accountId: AccountId;
accountNonce: Index;
additional: DeriveBalancesAccountData[];
}
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
availableBalance: Balance;
lockedBalance: Balance;
lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[];
vestingLocked: Balance;
}
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
additional: DeriveBalancesAllAccountData[];
isVesting: boolean;
vestedBalance: Balance;
vestedClaimable: Balance;
vestingEndBlock: BlockNumber;
vestingPerBlock: Balance;
vestingTotal: Balance;
}
export type DeriveBalancesMap = Record<string, DeriveBalancesAll>;
+5 -4
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import type { DeriveBounties, DeriveCollectiveProposal } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -12,7 +13,7 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
import { filterBountiesProposals } from './helpers/filterBountyProposals';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
type Result = [Option<PalletBountiesBounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
const bounties: DeriveBounties = [];
@@ -53,8 +54,8 @@ export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observ
const ids = keys.map(({ args: [id] }) => id);
return combineLatest([
bountyBase.bounties.multi<Option<Bounty>>(ids),
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
bountyBase.bounties.multi(ids),
bountyBase.bountyDescriptions.multi(ids),
of(ids),
of(filterBountiesProposals(api, proposals))
]);
@@ -40,9 +40,6 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: strin
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(hashes.map((hash) =>
// this should simply be api.query[section].proposalOf.multi<Option<Proposal>>(hashes),
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
api.query[section].proposalOf<Option<Proposal>>(hash).pipe(
catchError(() => of(null))
)
+4 -3
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableModuleStorage } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
import type { AccountId, Balance } from '@polkadot/types/interfaces';
import type { PalletElectionsPhragmenVoter } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
@@ -13,9 +14,9 @@ import { combineLatest, map, of } from 'rxjs';
import { memo } from '../util';
// Voter is current tuple is 2.x-era
type VoteEntry = Voter | ITuple<[Balance, Vec<AccountId>]>;
type VoteEntry = PalletElectionsPhragmenVoter | ITuple<[Balance, Vec<AccountId>]>;
function isVoter (value: VoteEntry): value is Voter {
function isVoter (value: VoteEntry): value is PalletElectionsPhragmenVoter {
return !Array.isArray(value);
}
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u64, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import type { Option, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex } from '@polkadot/types/interfaces';
import type { PalletSchedulerScheduledV2 } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveDispatch, DeriveProposalImage } from '../types';
@@ -42,7 +43,7 @@ function queryQueue (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
);
}
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Option<Scheduled>[] | null)[]]> {
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Option<PalletSchedulerScheduledV2>[] | null)[]]> {
// We don't get entries, but rather we get the keys (triggered via finished referendums) and
// the subscribe to those keys - this means we pickup when the schedulers actually executes
// at a block, the entry for that block will become empty
@@ -56,11 +57,11 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Opt
return blockNumbers.length
? combineLatest([
of(blockNumbers),
// this should simply be api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>>,
// this should simply be api.query.scheduler.agenda.multi,
// however we have had cases on Darwinia where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(blockNumbers.map((blockNumber) =>
api.query.scheduler.agenda<Vec<Option<Scheduled>>>(blockNumber).pipe(
api.query.scheduler.agenda(blockNumber).pipe(
// this does create an issue since it discards all at that block
catchError(() => of(null))
)
@@ -86,7 +87,7 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
const id = scheduled.maybeId.unwrap().toHex();
if (id.startsWith(DEMOCRACY_ID)) {
const [, index] = api.registry.createType<ITuple<[u64, ReferendumIndex]>>('(u64, ReferendumIndex)', id);
const [, index] = api.registry.createType('(u64, ReferendumIndex)', id);
const imageHash = scheduled.call.args[0] as Hash;
result.push({ at, imageHash, index });
+11 -6
View File
@@ -3,8 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import type { AccountId, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyVoteVoting } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveDemocracyLock } from '../types';
@@ -14,6 +14,11 @@ import { BN_ZERO, isUndefined } from '@polkadot/util';
import { memo } from '../util';
type ReferendumInfoFinished = PalletDemocracyReferendumInfo['asFinished'];
type VotingDelegating = PalletDemocracyVoteVoting['asDelegating'];
type VotingDirect = PalletDemocracyVoteVoting['asDirect'];
type VotingDirectVote = VotingDirect['votes'][0];
const LOCKUPS = [0, 1, 2, 4, 8, 16, 32];
function parseEnd (api: ApiInterfaceRx, vote: Vote, { approved, end }: ReferendumInfoFinished): [BN, BN] {
@@ -25,7 +30,7 @@ function parseEnd (api: ApiInterfaceRx, vote: Vote, { approved, end }: Referendu
];
}
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: ReferendumInfo): DeriveDemocracyLock {
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: PalletDemocracyReferendumInfo): DeriveDemocracyLock {
const { balance, vote } = accountVote.asStandard;
const [referendumEnd, unlockAt] = referendum.isFinished
? parseEnd(api, vote, referendum.asFinished)
@@ -57,13 +62,13 @@ function directLocks (api: ApiInterfaceRx, { votes }: VotingDirect): Observable<
return of([]);
}
return api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo | ReferendumInfoTo239>>(votes.map(([referendumId]) => referendumId)).pipe(
return api.query.democracy.referendumInfoOf.multi(votes.map(([referendumId]) => referendumId)).pipe(
map((referendums) =>
votes
.map((vote, index): [VotingDirectVote, ReferendumInfo | ReferendumInfoTo239 | null] =>
.map((vote, index): [VotingDirectVote, PalletDemocracyReferendumInfo | ReferendumInfoTo239 | null] =>
[vote, referendums[index].unwrapOr(null)]
)
.filter((item): item is [VotingDirectVote, ReferendumInfo] =>
.filter((item): item is [VotingDirectVote, PalletDemocracyReferendumInfo] =>
!!item[1] && isUndefined((item[1] as ReferendumInfoTo239).end) && item[0][1].isStandard
)
.map(([directVote, referendum]) =>
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import type { H256 } from '@polkadot/types/interfaces';
import type { PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalExternal } from '../types';
@@ -12,7 +13,7 @@ import { map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[Hash, VoteThreshold]>>): Observable<DeriveProposalExternal | null> {
function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[H256, PalletDemocracyVoteThreshold]>>): Observable<DeriveProposalExternal | null> {
if (nextOpt.isNone) {
return of(null);
}
@@ -31,7 +32,7 @@ function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[Hash, VoteThres
export function nextExternal (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposalExternal | null> {
return memo(instanceId, (): Observable<DeriveProposalExternal | null> =>
api.query.democracy?.nextExternal
? api.query.democracy.nextExternal<Option<ITuple<[Hash, VoteThreshold]>>>().pipe(
? api.query.democracy.nextExternal().pipe(
switchMap((nextOpt) => withImage(api, nextOpt))
)
: of(null)
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { DeriveProposalImage } from '../types';
import { map } from 'rxjs';
@@ -13,11 +11,9 @@ import { map } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimage (instanceId: string, api: ApiInterfaceRx): (hash: Hash) => Observable<DeriveProposalImage | undefined> {
return memo(instanceId, (hash: Hash): Observable<DeriveProposalImage | undefined> =>
api.query.democracy.preimages<PreImage>(hash).pipe(
api.query.democracy.preimages(hash).pipe(
map((imageOpt) => parseImage(api, imageOpt))
)
);
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { DeriveProposalImage } from '../types';
import { map, of } from 'rxjs';
@@ -13,12 +11,10 @@ import { map, of } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimages (instanceId: string, api: ApiInterfaceRx): (hashes: Hash[]) => Observable<(DeriveProposalImage | undefined)[]> {
return memo(instanceId, (hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
hashes.length
? api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
? api.query.democracy.preimages.multi(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) => parseImage(api, imageOpt))
)
@@ -58,9 +58,9 @@ export function proposals (instanceId: string, api: ApiInterfaceRx): () => Obser
? combineLatest([
of(proposals),
api.derive.democracy.preimages(
proposals.map(([, hash]): Hash => hash)),
api.query.democracy.depositOf.multi<Depositors>(
proposals.map(([index]): PropIndex => index))
proposals.map(([, hash]) => hash)),
api.query.democracy.depositOf.multi(
proposals.map(([index]) => index))
])
: of<Result>([[], [], []])
),
@@ -3,23 +3,24 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo } from '@polkadot/types/lookup';
import { map, switchMap } from 'rxjs';
import { memo } from '../util';
type ReferendumInfoFinished = PalletDemocracyReferendumInfo['asFinished'];
export function referendumsFinished (instanceId: string, api: ApiInterfaceRx): () => Observable<ReferendumInfoFinished[]> {
return memo(instanceId, (): Observable<ReferendumInfoFinished[]> =>
api.derive.democracy.referendumIds().pipe(
switchMap((ids) =>
api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids)
api.query.democracy.referendumInfoOf.multi(ids)
),
map((infos): ReferendumInfoFinished[] =>
infos
.map((optInfo) => optInfo.unwrapOr(null))
.filter((info): info is ReferendumInfo => !!info && info.isFinished)
.filter((info): info is PalletDemocracyReferendumInfo => !!info && info.isFinished)
.map((info) => info.asFinished)
)
)
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDelegating, VotingDirectVote } from '@polkadot/types/interfaces';
import type { AccountId, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyVoteVoting } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
@@ -15,6 +16,10 @@ import { isFunction } from '@polkadot/util';
import { memo } from '../util';
import { calcVotes, getStatus, parseImage } from './util';
type VotingDelegating = PalletDemocracyVoteVoting['asDelegating'];
type VotingDirect = PalletDemocracyVoteVoting['asDirect'];
type VotingDirectVote = VotingDirect['votes'][0];
function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DeriveBalancesAccount[]]> =>
@@ -41,7 +46,7 @@ function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveRef
);
}
function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveReferendumVote[] {
function extractVotes (mapped: [AccountId, PalletDemocracyVoteVoting][], referendumId: BN): DeriveReferendumVote[] {
return mapped
.filter(([, voting]) => voting.isDirect)
.map(([accountId, voting]): [AccountId, VotingDirectVote[]] => [
@@ -66,9 +71,9 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
}
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting, [AccountId]>().pipe(
return api.query.democracy.votingOf.entries().pipe(
map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, Voting] => [accountId, voting]);
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, PalletDemocracyVoteVoting] => [accountId, voting]);
const votes = extractVotes(mapped, referendumId);
const delegations = mapped
.filter(([, voting]) => voting.isDelegating)
@@ -123,8 +128,8 @@ export function _referendumsVotes (instanceId: string, api: ApiInterfaceRx): (re
);
}
export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo(instanceId, (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (index: BN, info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo(instanceId, (index: BN, info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
const status = getStatus(info);
return status
@@ -143,7 +148,7 @@ export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (inde
export function referendumsInfo (instanceId: string, api: ApiInterfaceRx): (ids: BN[]) => Observable<DeriveReferendum[]> {
return memo(instanceId, (ids: BN[]): Observable<DeriveReferendum[]> =>
ids.length
? api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids).pipe(
? api.query.democracy.referendumInfoOf.multi(ids).pipe(
switchMap((infos): Observable<(DeriveReferendum | null)[]> =>
combineLatest(
ids.map((id, index): Observable<DeriveReferendum | null> =>
+4 -3
View File
@@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, ReferendumStatus, Vote, VoteThreshold } from '@polkadot/types/interfaces';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumStatus, PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
export interface DeriveDemocracyLock {
@@ -41,14 +42,14 @@ export interface DeriveProposal {
export interface DeriveProposalExternal {
image?: DeriveProposalImage;
imageHash: Hash;
threshold: VoteThreshold;
threshold: PalletDemocracyVoteThreshold;
}
export interface DeriveReferendum {
index: ReferendumIndex;
image?: DeriveProposalImage;
imageHash: Hash;
status: ReferendumStatus | ReferendumInfoTo239;
status: PalletDemocracyReferendumStatus | ReferendumInfoTo239;
}
export interface DeriveReferendumVote {
+10 -9
View File
@@ -3,7 +3,8 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
import type { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfoTo239, Tally } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyReferendumStatus, PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
@@ -18,12 +19,12 @@ interface ApproxState {
votedTotal: BN;
}
function isOldInfo (info: ReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
function isOldInfo (info: PalletDemocracyReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
return !!(info as ReferendumInfoTo239).proposalHash;
}
function isCurrentStatus (status: ReferendumStatus | ReferendumInfoTo239): status is ReferendumStatus {
return !!(status as ReferendumStatus).tally;
function isCurrentStatus (status: PalletDemocracyReferendumStatus | ReferendumInfoTo239): status is PalletDemocracyReferendumStatus {
return !!(status as PalletDemocracyReferendumStatus).tally;
}
function isCurrentPreimage (api: ApiInterfaceRx, imageOpt: Option<OldPreimage> | Option<PreimageStatus>): imageOpt is Option<PreimageStatus> {
@@ -57,18 +58,18 @@ export function compareRationals (n1: BN, d1: BN, n2: BN, d2: BN): boolean {
}
}
function calcPassingOther (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState): boolean {
function calcPassingOther (threshold: PalletDemocracyVoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState): boolean {
const sqrtVoters = bnSqrt(votedTotal);
return sqrtVoters.isZero()
? false
: threshold.isSupermajorityapproval
: threshold.isSuperMajorityApprove
? compareRationals(votedNay, sqrtVoters, votedAye, sqrtElectorate)
: compareRationals(votedNay, sqrtElectorate, votedAye, sqrtVoters);
}
export function calcPassing (threshold: VoteThreshold, sqrtElectorate: BN, state: ApproxState): boolean {
return threshold.isSimplemajority
export function calcPassing (threshold: PalletDemocracyVoteThreshold, sqrtElectorate: BN, state: ApproxState): boolean {
return threshold.isSimpleMajority
? state.votedAye.gt(state.votedNay)
: calcPassingOther(threshold, sqrtElectorate, state);
}
@@ -134,7 +135,7 @@ export function calcVotes (sqrtElectorate: BN, referendum: DeriveReferendum, vot
};
}
export function getStatus (info: Option<ReferendumInfo | ReferendumInfoTo239>): ReferendumStatus | ReferendumInfoTo239 | null {
export function getStatus (info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): PalletDemocracyReferendumStatus | ReferendumInfoTo239 | null {
if (info.isNone) {
return null;
}
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option, u32 } from '@polkadot/types';
import type { Option, u32, WrapperOpaque } from '@polkadot/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletImOnlineBoundedOpaqueNetworkState } from '@polkadot/types/lookup';
import type { DeriveHeartbeats } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,7 +14,9 @@ import { BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
function mapResult ([result, validators, heartbeats, numBlocks]: [DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]): DeriveHeartbeats {
type HeartbeatsOpt = Option<WrapperOpaque<PalletImOnlineBoundedOpaqueNetworkState>>;
function mapResult ([result, validators, heartbeats, numBlocks]: [DeriveHeartbeats, AccountId[], HeartbeatsOpt[], u32[]]): DeriveHeartbeats {
validators.forEach((validator, index): void => {
const validatorId = validator.toString();
const blockCount = numBlocks[index];
@@ -39,13 +42,13 @@ export function receivedHeartbeats (instanceId: string, api: ApiInterfaceRx): ()
return memo(instanceId, (): Observable<DeriveHeartbeats> =>
api.query.imOnline?.receivedHeartbeats
? api.derive.staking.overview().pipe(
switchMap(({ currentIndex, validators }): Observable<[DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]> =>
switchMap(({ currentIndex, validators }): Observable<[DeriveHeartbeats, AccountId[], HeartbeatsOpt[], u32[]]> =>
combineLatest([
of({}),
of(validators),
api.query.imOnline.receivedHeartbeats.multi<Option<Bytes>>(
api.query.imOnline.receivedHeartbeats.multi(
validators.map((_address, index) => [currentIndex, index])),
api.query.imOnline.authoredBlocks.multi<u32>(
api.query.imOnline.authoredBlocks.multi(
validators.map((address) => [currentIndex, address]))
])
),
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.2.1' };
+10 -8
View File
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, BalanceOf, Bid, BidKind } from '@polkadot/types/interfaces';
import type { Option } from '@polkadot/types';
import type { BalanceOf } from '@polkadot/types/interfaces';
import type { PalletSocietyBid, PalletSocietyBidKind } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveSocietyCandidate } from '../types';
@@ -12,20 +13,21 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
type ResultSuspend = Option<ITuple<[BalanceOf, BidKind]>>;
type Result = [Bid[], ResultSuspend[]]
type ResultSuspend = Option<ITuple<[BalanceOf, PalletSocietyBidKind]>>;
type Result = [PalletSocietyBid[], ResultSuspend[]]
/**
* @description Get the candidate info for a society
*/
export function candidates (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSocietyCandidate[]> {
return memo(instanceId, (): Observable<DeriveSocietyCandidate[]> =>
api.query.society.candidates<Vec<Bid>>().pipe(
switchMap((candidates: Vec<Bid>): Observable<Result> =>
api.query.society.candidates().pipe(
switchMap((candidates): Observable<Result> =>
combineLatest([
of(candidates),
api.query.society.suspendedCandidates.multi<ResultSuspend>(
candidates.map(({ who }): AccountId => who))
api.query.society.suspendedCandidates.multi(
candidates.map(({ who }) => who)
)
])
),
map(([candidates, suspended]: Result): DeriveSocietyCandidate[] =>
+3 -2
View File
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u32, Vec } from '@polkadot/types';
import type { AccountId, BalanceOf, Bid } from '@polkadot/types/interfaces';
import type { AccountId, BalanceOf } from '@polkadot/types/interfaces';
import type { PalletSocietyBid } from '@polkadot/types/lookup';
import type { DeriveSociety } from '../types';
import { map } from 'rxjs';
import { memo } from '../util';
type Result = [Vec<Bid>, Option<AccountId>, Option<AccountId>, Option<AccountId>, u32, BalanceOf]
type Result = [Vec<PalletSocietyBid>, Option<AccountId>, Option<AccountId>, Option<AccountId>, u32, BalanceOf]
/**
* @description Get the overall info for a society
+6 -8
View File
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { bool, Option, Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { DeriveSocietyMember } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -16,11 +14,11 @@ export function _members (instanceId: string, api: ApiInterfaceRx): (accountIds:
return memo(instanceId, (accountIds: AccountId[]): Observable<DeriveSocietyMember[]> =>
combineLatest([
of(accountIds),
api.query.society.payouts.multi<Vec<ITuple<[BlockNumber, Balance]>>>(accountIds),
api.query.society.strikes.multi<StrikeCount>(accountIds),
api.query.society.defenderVotes.multi<Option<SocietyVote>>(accountIds),
api.query.society.suspendedMembers.multi<bool>(accountIds),
api.query.society.vouching.multi<Option<VouchingStatus>>(accountIds)
api.query.society.payouts.multi(accountIds),
api.query.society.strikes.multi(accountIds),
api.query.society.defenderVotes.multi(accountIds),
api.query.society.suspendedMembers.multi(accountIds),
api.query.society.vouching.multi(accountIds)
]).pipe(
map(([accountIds, payouts, strikes, defenderVotes, suspended, vouching]) =>
accountIds.map((accountId, index) => ({
+33
View File
@@ -0,0 +1,33 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceOf, BlockNumber, StrikeCount } from '@polkadot/types/interfaces';
import type { PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus } from '@polkadot/types/lookup';
export interface DeriveSociety {
bids: PalletSocietyBid[];
defender?: AccountId;
hasDefender: boolean;
head?: AccountId;
founder?: AccountId;
maxMembers: u32;
pot: BalanceOf;
}
export interface DeriveSocietyCandidate {
accountId: AccountId;
kind: PalletSocietyBidKind;
value: Balance;
isSuspended: boolean;
}
export interface DeriveSocietyMember {
accountId: AccountId;
isDefenderVoter: boolean;
isSuspended: boolean;
payouts: [BlockNumber, Balance][];
strikes: StrikeCount;
vote?: PalletSocietyVote;
vouching?: PalletSocietyVouchingStatus;
}
+6 -5
View File
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces';
import type { Balance } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger, PalletStakingUnlockChunk } from '@polkadot/types/lookup';
import type { DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types';
import { combineLatest, map, switchMap } from 'rxjs';
@@ -19,7 +20,7 @@ const QUERY_OPTS = {
withPrefs: true
};
function groupByEra (list: UnlockChunk[]): Record<string, BN> {
function groupByEra (list: PalletStakingUnlockChunk[]): Record<string, BN> {
return list.reduce((map: Record<string, BN>, { era, value }): Record<string, BN> => {
const key = era.toString();
@@ -29,7 +30,7 @@ function groupByEra (list: UnlockChunk[]): Record<string, BN> {
}, {});
}
function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DeriveSessionInfo): DeriveUnlocking[] | undefined {
function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: PalletStakingStakingLedger | undefined, sessionInfo: DeriveSessionInfo): DeriveUnlocking[] | undefined {
const results = Object
.entries(groupByEra(
(stakingLedger?.unlocking || []).filter(({ era }) => era.unwrap().gt(sessionInfo.activeEra))
@@ -44,8 +45,8 @@ function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger |
: undefined;
}
function redeemableSum (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DeriveSessionInfo): Balance {
return api.registry.createType('Balance', (stakingLedger?.unlocking || [] as UnlockChunk[]).reduce((total, { era, value }): BN => {
function redeemableSum (api: ApiInterfaceRx, stakingLedger: PalletStakingStakingLedger | undefined, sessionInfo: DeriveSessionInfo): Balance {
return api.registry.createType('Balance', (stakingLedger?.unlocking || [] as PalletStakingUnlockChunk[]).reduce((total, { era, value }): BN => {
return sessionInfo.activeEra.gte(era.unwrap())
? total.iadd(value.unwrap())
: total;
@@ -3,7 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraRewardPoints } from '@polkadot/types/interfaces';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import { switchMap } from 'rxjs';
@@ -12,11 +12,11 @@ import { memo } from '../util';
/**
* @description Retrieve the staking overview, including elected and points earned
*/
export function currentPoints (instanceId: string, api: ApiInterfaceRx): () => Observable<EraRewardPoints> {
return memo(instanceId, (): Observable<EraRewardPoints> =>
export function currentPoints (instanceId: string, api: ApiInterfaceRx): () => Observable<PalletStakingEraRewardPoints> {
return memo(instanceId, (): Observable<PalletStakingEraRewardPoints> =>
api.derive.session.indexes().pipe(
switchMap(({ activeEra }) =>
api.query.staking.erasRewardPoints<EraRewardPoints>(activeEra)
api.query.staking.erasRewardPoints<PalletStakingEraRewardPoints>(activeEra)
)
));
}
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { StorageKey } from '@polkadot/types';
import type { AccountId, EraIndex, Exposure } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure } from '@polkadot/types/lookup';
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { deriveCache, memo } from '../util';
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, Exposure][];
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, PalletStakingExposure][];
const CACHE_KEY = 'eraExposure';
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraIndex, EraRewardPoints } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import type { DeriveEraPoints, DeriveEraValPoints } from '../types';
import { map, of, switchMap } from 'rxjs';
@@ -15,7 +16,7 @@ import { filterEras } from './util';
const CACHE_KEY = 'eraPoints';
function mapValidators ({ individual }: EraRewardPoints): DeriveEraValPoints {
function mapValidators ({ individual }: PalletStakingEraRewardPoints): DeriveEraValPoints {
return [...individual.entries()]
.filter(([, points]) => points.gt(BN_ZERO))
.reduce((result: DeriveEraValPoints, [validatorId, points]): DeriveEraValPoints => {
@@ -25,7 +26,7 @@ function mapValidators ({ individual }: EraRewardPoints): DeriveEraValPoints {
}, {});
}
function mapPoints (eras: EraIndex[], points: EraRewardPoints[]): DeriveEraPoints[] {
function mapPoints (eras: EraIndex[], points: PalletStakingEraRewardPoints[]): DeriveEraPoints[] {
return eras.map((era, index): DeriveEraPoints => ({
era,
eraPoints: points[index].total,
@@ -48,7 +49,7 @@ export function _erasPoints (instanceId: string, api: ApiInterfaceRx): (eras: Er
return !remaining.length
? of(cached)
: api.query.staking.erasRewardPoints.multi<EraRewardPoints>(remaining).pipe(
: api.query.staking.erasRewardPoints.multi(remaining).pipe(
map((points): DeriveEraPoints[] => {
const query = mapPoints(remaining, points);
+3 -2
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { StorageKey } from '@polkadot/types';
import type { EraIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveEraPrefs, DeriveEraValPrefs } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,7 +14,7 @@ import { deriveCache, memo } from '../util';
const CACHE_KEY = 'eraPrefs';
function mapPrefs (era: EraIndex, all: [StorageKey, ValidatorPrefs][]): DeriveEraPrefs {
function mapPrefs (era: EraIndex, all: [StorageKey, PalletStakingValidatorPrefs][]): DeriveEraPrefs {
const validators: DeriveEraValPrefs = {};
all.forEach(([key, prefs]): void => {
@@ -38,7 +38,7 @@ export function _erasRewards (instanceId: string, api: ApiInterfaceRx): (eras: E
return of(cached);
}
return api.query.staking.erasValidatorReward.multi<Option<Balance>>(remaining).pipe(
return api.query.staking.erasValidatorReward.multi(remaining).pipe(
map((optRewards) => {
const query = mapRewards(remaining, optRewards);
+13 -8
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, Keys } from '@polkadot/types/interfaces';
import type { AccountId } from '@polkadot/types/interfaces';
import type { NodeRuntimeSessionKeys } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveStakingKeys } from './types';
@@ -12,13 +13,17 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): DeriveStakingKeys {
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, NodeRuntimeSessionKeys | AccountId[]][], nextKeys: Option<NodeRuntimeSessionKeys>): DeriveStakingKeys {
const sessionIds = (queuedKeys.find(([currentId]) => currentId.eq(stashId)) || [undefined, [] as AccountId[]])[1];
const nextSessionIds = nextKeys.unwrapOr([] as AccountId[]);
return {
nextSessionIds,
sessionIds
nextSessionIds: Array.isArray(nextSessionIds)
? nextSessionIds
: [...nextSessionIds.values()] as AccountId[],
sessionIds: Array.isArray(sessionIds)
? sessionIds
: [...sessionIds.values()] as AccountId[]
};
}
@@ -33,13 +38,13 @@ export function keys (instanceId: string, api: ApiInterfaceRx): (stashId: Uint8A
export function keysMulti (instanceId: string, api: ApiInterfaceRx): (stashIds: (Uint8Array | string)[]) => Observable<DeriveStakingKeys[]> {
return memo(instanceId, (stashIds: (Uint8Array | string)[]): Observable<DeriveStakingKeys[]> =>
stashIds.length
? api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>().pipe(
switchMap((queuedKeys): Observable<[Vec<ITuple<[AccountId, Keys]>>, Option<Keys>[]]> =>
? api.query.session.queuedKeys().pipe(
switchMap((queuedKeys): Observable<[Vec<ITuple<[AccountId, NodeRuntimeSessionKeys]>>, Option<NodeRuntimeSessionKeys>[]]> =>
combineLatest([
of(queuedKeys),
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.session.nextKeys.multi(stashIds.map((stashId) => [api.consts.session.dedupKeyPrefix, stashId]))
: api.query.session.nextKeys.multi(stashIds)
])
),
map(([queuedKeys, nextKeys]) =>
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure } from '@polkadot/types/lookup';
import type { DeriveOwnExposure } from '../types';
import { map, of, switchMap } from 'rxjs';
@@ -14,7 +15,7 @@ export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accoun
// 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[]>([
? api.queryMulti<PalletStakingExposure[]>([
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakersClipped, [era, accountId]]),
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakers, [era, accountId]])
]).pipe(
+18 -17
View File
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, EraIndex, Exposure, Nominations, RewardDestination, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingNominations, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveStakingQuery, StakingQueryFlags } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<Nominations>, rewardDestination: RewardDestination, validatorPrefs: ValidatorPrefs, exposure: Exposure, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestination: PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
return {
accountId: stashId,
controllerId: controllerIdOpt && controllerIdOpt.unwrapOr(null),
@@ -26,21 +27,21 @@ function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> |
};
}
function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[], { withLedger = false }: StakingQueryFlags): Observable<Option<StakingLedger>[]> {
function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[], { withLedger = false }: StakingQueryFlags): Observable<Option<PalletStakingStakingLedger>[]> {
const ids = optIds
.filter((opt): opt is Option<AccountId> => withLedger && !!opt && opt.isSome)
.map((opt) => opt.unwrap());
const emptyLed = api.registry.createType('Option<StakingLedger>');
const emptyLed = api.registry.createType<Option<PalletStakingStakingLedger>>('Option<StakingLedger>');
return (
ids.length
? api.query.staking.ledger.multi<Option<StakingLedger>>(ids)
? api.query.staking.ledger.multi(ids)
: of([])
).pipe(
map((optLedgers): Option<StakingLedger>[] => {
map((optLedgers): Option<PalletStakingStakingLedger>[] => {
let offset = -1;
return optIds.map((opt): Option<StakingLedger> =>
return optIds.map((opt): Option<PalletStakingStakingLedger> =>
opt && opt.isSome
? optLedgers[++offset] || emptyLed
: emptyLed
@@ -49,27 +50,27 @@ function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[],
);
}
function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<Nominations>[], RewardDestination[], ValidatorPrefs[], Exposure[]]> {
const emptyNoms = api.registry.createType('Option<Nominations>');
const emptyRewa = api.registry.createType('RewardDestination');
const emptyExpo = api.registry.createType('Exposure');
const emptyPrefs = api.registry.createType('ValidatorPrefs');
function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], PalletStakingRewardDestination[], PalletStakingValidatorPrefs[], PalletStakingExposure[]]> {
const emptyNoms = api.registry.createType<Option<PalletStakingNominations>>('Option<Nominations>');
const emptyRewa = api.registry.createType<PalletStakingRewardDestination>('RewardDestination');
const emptyExpo = api.registry.createType<PalletStakingExposure>('Exposure');
const emptyPrefs = api.registry.createType<PalletStakingValidatorPrefs>('ValidatorPrefs');
return combineLatest([
withController || withLedger
? api.query.staking.bonded.multi<Option<AccountId>>(stashIds)
? api.query.staking.bonded.multi(stashIds)
: of(stashIds.map(() => null)),
withNominations
? api.query.staking.nominators.multi<Option<Nominations>>(stashIds)
? api.query.staking.nominators.multi(stashIds)
: of(stashIds.map(() => emptyNoms)),
withDestination
? api.query.staking.payee.multi<RewardDestination>(stashIds)
? api.query.staking.payee.multi(stashIds)
: of(stashIds.map(() => emptyRewa)),
withPrefs
? api.query.staking.validators.multi<ValidatorPrefs>(stashIds)
? api.query.staking.validators.multi(stashIds)
: of(stashIds.map(() => emptyPrefs)),
withExposure
? api.query.staking.erasStakers.multi<Exposure>(stashIds.map((stashId) => [activeEra, stashId]))
? api.query.staking.erasStakers.multi(stashIds.map((stashId) => [activeEra, stashId]))
: of(stashIds.map(() => emptyExpo))
]);
}
@@ -3,7 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveStakerPrefs } from '../types';
import { map, switchMap } from 'rxjs';
@@ -13,7 +13,7 @@ import { memo } from '../util';
export function _stakerPrefs (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerPrefs[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveStakerPrefs[]> =>
api.query.staking.erasValidatorPrefs.multi<ValidatorPrefs>(eras.map((era) => [era, accountId])).pipe(
api.query.staking.erasValidatorPrefs.multi(eras.map((era) => [era, accountId])).pipe(
map((all): DeriveStakerPrefs[] =>
all.map((validatorPrefs, index): DeriveStakerPrefs => ({
era: eras[index],
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
import type { DeriveStakingQuery } from './types';
@@ -108,7 +109,7 @@ function removeClaimed (validators: string[], queryValidators: DeriveStakingQuer
});
}
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): DeriveStakerReward[] {
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: PalletStakingStakingLedger }): 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);
+11 -10
View File
@@ -1,13 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types';
export type DeriveEraValPoints = Record<string, RewardPoint>;
export type DeriveEraValPrefs = Record<string, ValidatorPrefs>;
export type DeriveEraValPrefs = Record<string, PalletStakingValidatorPrefs>;
export type DeriveEraValSlash = Record<string, Balance>;
@@ -40,9 +41,9 @@ export interface DeriveStakerPoints {
}
export interface DeriveOwnExposure {
clipped: Exposure;
clipped: PalletStakingExposure;
era: EraIndex;
exposure: Exposure;
exposure: PalletStakingExposure;
}
export interface DeriveEraExposureNominating {
@@ -52,7 +53,7 @@ export interface DeriveEraExposureNominating {
export type DeriveEraNominatorExposure = Record<string, DeriveEraExposureNominating[]>;
export type DeriveEraValidatorExposure = Record<string, Exposure>;
export type DeriveEraValidatorExposure = Record<string, PalletStakingExposure>;
export interface DeriveEraExposure {
era: EraIndex;
@@ -70,7 +71,7 @@ export interface DeriveStakerExposure {
export interface DeriveStakerPrefs {
era: EraIndex;
validatorPrefs: ValidatorPrefs;
validatorPrefs: PalletStakingValidatorPrefs;
}
export interface DeriveStakerRewardValidator {
@@ -106,16 +107,16 @@ export interface DeriveStakingValidators {
export interface DeriveStakingStash {
controllerId: AccountId | null;
exposure: Exposure;
exposure: PalletStakingExposure;
nominators: AccountId[];
rewardDestination: RewardDestination;
rewardDestination: PalletStakingRewardDestination;
stashId: AccountId;
validatorPrefs: ValidatorPrefs;
validatorPrefs: PalletStakingValidatorPrefs;
}
export interface DeriveStakingQuery extends DeriveStakingStash {
accountId: AccountId;
stakingLedger: StakingLedger;
stakingLedger: PalletStakingStakingLedger;
}
export interface DeriveStakingElected {
@@ -59,7 +59,7 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
const allIds = [...proposalIds, ...approvalIds];
return combineLatest([
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
api.query.treasury.proposals.multi(allIds),
api.derive.council
? api.derive.council.proposals()
: of([] as DeriveCollectiveProposal[])
+5 -62
View File
@@ -2,52 +2,22 @@
// SPDX-License-Identifier: Apache-2.0
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
import type { Balance, BlockNumber, BountyIndex, Hash, Proposal, ProposalIndex, SetIndex, TreasuryProposal, Votes } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
export * from './accounts/types';
export * from './balances/types';
export * from './council/types';
export * from './crowdloan/types';
export * from './democracy/types';
export * from './elections/types';
export * from './parachains/types';
export * from './session/types';
export * from './society/types';
export * from './staking/types';
export * from './type/types';
export interface DeriveBalancesAccountData {
freeBalance: Balance;
frozenFee: Balance;
frozenMisc: Balance;
reservedBalance: Balance;
votingBalance: Balance;
}
export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
accountId: AccountId;
accountNonce: Index;
additional: DeriveBalancesAccountData[];
}
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
availableBalance: Balance;
lockedBalance: Balance;
lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
vestingLocked: Balance;
}
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
additional: DeriveBalancesAllAccountData[];
isVesting: boolean;
vestedBalance: Balance;
vestedClaimable: Balance;
vestingEndBlock: BlockNumber;
vestingPerBlock: Balance;
vestingTotal: Balance;
}
export type DeriveBalancesMap = Record<string, DeriveBalancesAll>;
export interface DeriveContractFees {
callBaseFee: BN;
contractFee: BN;
@@ -90,33 +60,6 @@ export interface RecentlyOffline {
export type DeriveRecentlyOffline = Record<string, RecentlyOffline[]>;
export interface DeriveSociety {
bids: Bid[];
defender?: AccountId;
hasDefender: boolean;
head?: AccountId;
founder?: AccountId;
maxMembers: u32;
pot: BalanceOf;
}
export interface DeriveSocietyCandidate {
accountId: AccountId;
kind: BidKind;
value: Balance;
isSuspended: boolean;
}
export interface DeriveSocietyMember {
accountId: AccountId;
isDefenderVoter: boolean;
isSuspended: boolean;
payouts: [BlockNumber, Balance][];
strikes: StrikeCount;
vote?: SocietyVote;
vouching?: VouchingStatus;
}
export interface DeriveTreasuryProposal {
council: DeriveCollectiveProposal[];
id: ProposalIndex;
@@ -138,7 +81,7 @@ export interface VoterPosition {
export type DeriveVoterPositions = Record<string, VoterPosition>;
export interface DeriveBounty {
bounty: Bounty;
bounty: PalletBountiesBounty;
description: string;
index: BountyIndex;
proposals: DeriveCollectiveProposal[];
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -20,12 +20,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.1.2",
"@polkadot/api-derive": "6.2.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-core": "6.1.2",
"@polkadot/rpc-provider": "6.1.2",
"@polkadot/types": "6.1.2",
"@polkadot/types-known": "6.1.2",
"@polkadot/rpc-core": "6.2.1",
"@polkadot/rpc-provider": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/types-known": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"eventemitter3": "^4.0.7",
+2 -21
View File
@@ -180,47 +180,28 @@ declare module '@polkadot/api/types/events' {
contracts: {
/**
* A code with the specified hash was removed.
* \[code_hash\]
*
* This happens when the last contract that uses this code hash was removed.
**/
CodeRemoved: AugmentedEvent<ApiType, [H256]>;
/**
* Code with the specified hash has been stored. \[code_hash\]
* Code with the specified hash has been stored.
**/
CodeStored: AugmentedEvent<ApiType, [H256]>;
/**
* A custom event emitted by the contract.
* \[contract, data\]
*
* # Params
*
* - `contract`: The contract that emitted the event.
* - `data`: Data supplied by the contract. Metadata generated during contract compilation
* is needed to decode it.
**/
ContractEmitted: AugmentedEvent<ApiType, [AccountId32, Bytes]>;
/**
* Contract deployed by address at the specified address. \[deployer, contract\]
* Contract deployed by address at the specified address.
**/
Instantiated: AugmentedEvent<ApiType, [AccountId32, AccountId32]>;
/**
* Triggered when the current schedule is updated.
* \[version\]
*
* # Params
*
* - `version`: The version of the newly set schedule.
**/
ScheduleUpdated: AugmentedEvent<ApiType, [u32]>;
/**
* Contract has been removed.
* \[contract, beneficiary\]
*
* # Params
*
* - `contract`: The contract that was terminated.
* - `beneficiary`: The account that received the contracts remaining balance.
*
* # Note
*
+4 -4
View File
@@ -2572,8 +2572,8 @@ declare module '@polkadot/api/types/submittable' {
* The dispatch origin of this function must be signed.
*
* # <weight>
* - Complexity: `O(1)` in number of key types.
* Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.
* - Complexity: `O(1)` in number of key types. Actual cost depends on the number of length
* of `T::Keys::key_ids()` which is fixed.
* - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`
* - DbWrites: `NextKeys`, `origin account`
* - DbWrites per key id: `KeyOwner`
@@ -2588,8 +2588,8 @@ declare module '@polkadot/api/types/submittable' {
* The dispatch origin of this function must be signed.
*
* # <weight>
* - Complexity: `O(1)`
* Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.
* - Complexity: `O(1)`. Actual cost depends on the number of length of
* `T::Keys::key_ids()` which is fixed.
* - DbReads: `origin account`, `T::ValidatorIdOf`, `NextKeys`
* - DbWrites: `origin account`, `NextKeys`
* - DbReads per key id: `KeyOwner`
+5 -3
View File
@@ -373,9 +373,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
: this._rpcCore.state.queryStorageAt)(
calls.map((args: QueryableStorageMultiArg<ApiType>) =>
Array.isArray(args)
? args[0].creator.meta.type.asMap.hashers.length === 1
? [args[0].creator, args.slice(1)]
: [args[0].creator, ...args.slice(1)]
? args[0].creator.meta.type.isPlain
? [args[0].creator]
: args[0].creator.meta.type.asMap.hashers.length === 1
? [args[0].creator, args.slice(1)]
: [args[0].creator, ...args.slice(1)]
: [args.creator])));
}
+1 -1
View File
@@ -82,7 +82,7 @@ async function query (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
const oldBal = await api.query.balances.totalIssuance.at('abcd');
// It's hard to correctly type .multi. Expected: `Balance[]`, actual: Codec[].
// In the meantime, we can case with `<Balance>` (this is not available on recent chains)
const multi = await api.query.balances.freeBalance.multi<Balance>([pairs.alice.address, pairs.bob.address]);
const multi = await api.query.balances.freeBalance.multi([pairs.alice.address, pairs.bob.address]);
console.log('query types:', bar, bal, bal2, override, oldBal, multi);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/api', version: '6.2.1' };
+1
View File
@@ -45,6 +45,7 @@ export interface SignerOptions {
nonce: AnyNumber | Codec;
signer?: Signer;
tip?: AnyNumber;
assetId?: AnyNumber;
}
export type AddressOrPair = IKeyringPair | string | AccountId | Address;
+20 -19
View File
@@ -8,13 +8,19 @@ import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@polkadot/types/types';
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
interface StorageEntryObservableMulti {
<T extends Codec>(args: (unknown[] | unknown)[]): Observable<T[]>;
type AsCodec<R extends Codec | any> = R extends Codec
? R
: Codec;
type ReturnCodec<F extends AnyFunction> = AsCodec<ObsInnerType<ReturnType<F>>>;
interface StorageEntryObservableMulti<R extends Codec = Codec> {
<T extends Codec = R>(args: (unknown[] | unknown)[]): Observable<T[]>;
}
interface StorageEntryPromiseMulti {
<T extends Codec>(args: (unknown[] | unknown)[]): Promise<T[]>;
<T extends Codec>(args: (unknown[] | unknown)[], callback: Callback<T[]>): UnsubscribePromise;
interface StorageEntryPromiseMulti<R extends Codec = Codec> {
<T extends Codec = R>(args: (unknown[] | unknown)[]): Promise<T[]>;
<T extends Codec = R>(args: (unknown[] | unknown)[], callback: Callback<T[]>): UnsubscribePromise;
}
export interface StorageEntryPromiseOverloads {
@@ -52,28 +58,23 @@ export interface QueryableStorageAt<ApiType extends ApiTypes> extends AugmentedQ
[key: string]: QueryableModuleStorageAt<ApiType>;
}
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> extends StorageEntryBaseAt<ApiType, F, A> {
at: <T extends Codec | any = ReturnCodec<F>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string;
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
entriesAt: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesPaged: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
range: <T extends Codec | any = ReturnCodec<F>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
sizeAt: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
multi: ApiType extends 'rxjs'
? StorageEntryObservableMulti<ReturnCodec<F>>
: StorageEntryPromiseMulti<ReturnCodec<F>>;
}
export interface StorageEntryBaseAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entries: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string;
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.1.2",
"@polkadot/types": "6.1.2",
"@polkadot/rpc-provider": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.2.1' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -20,7 +20,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.1.2",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"@polkadot/x-fetch": "^7.4.1",
@@ -30,7 +30,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types": "6.1.2",
"@polkadot/types": "6.2.1",
"mock-socket": "^9.0.3",
"nock": "^13.1.3"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.2.1' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -29,10 +29,10 @@
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.1.2",
"@polkadot/rpc-provider": "6.1.2",
"@polkadot/types": "6.1.2",
"@polkadot/types-support": "6.1.2",
"@polkadot/api": "6.2.1",
"@polkadot/rpc-provider": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/types-support": "6.2.1",
"@polkadot/util": "^7.4.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
-4
View File
@@ -41,10 +41,6 @@ function entrySignature (lookup: PortableRegistry, allDefs: Record<string, Modul
const keyTypes = similarTypes.map((t) => t.join(' | '));
const defValue = lookup.getTypeDef(value);
if (value.toNumber() === 416) {
console.log(JSON.stringify(defValue));
}
setImports(allDefs, imports, [
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
storageEntry.modifier.isOptional
+1 -1
View File
@@ -55,7 +55,7 @@ function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, {
const keys = (sub as TypeDef[]).map((def, index): string => {
const { info, lookupName, name = `unknown${index}`, type } = def;
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
const isComplex = [TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const isComplex = [TypeDefInfo.Option, TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
? ''
: createGetter(definitions, `as${getter}`, lookupName || (isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports, false) : type), imports);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/typegen', version: '6.2.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Known type definitions",
"main": "index.js",
@@ -21,7 +21,7 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/networks": "^7.4.1",
"@polkadot/types": "6.1.2",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/types-known', version: '6.2.1' };
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-support",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Supporting files for types, mostly for testing",
"main": "index.js",
File diff suppressed because one or more lines are too long
@@ -265,7 +265,7 @@
{
"name": "Version",
"type": 159,
"value": "0x186b7573616d61347061726974792d6b7573616d61020000008c2300000000000038df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1503000000f78b278be53f454c02000000af2c0297a23e6d3d0100000049eaaf1b548a0cb00100000091d5df18b0d2cf5801000000ed99c5acb25eedf503000000cbca25e39f14238702000000687ad44ad37f03c201000000ab3c0572291feb8b01000000bc9d89904f5b923f0100000037c8bb1350a9a2a80100000005000000",
"value": "0x186b7573616d61347061726974792d6b7573616d6102000000962300000000000038df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1503000000f78b278be53f454c02000000af2c0297a23e6d3d0100000049eaaf1b548a0cb00100000091d5df18b0d2cf5801000000ed99c5acb25eedf503000000cbca25e39f14238702000000687ad44ad37f03c201000000ab3c0572291feb8b01000000bc9d89904f5b923f0100000037c8bb1350a9a2a80100000007000000",
"docs": [
" Get the chain's current version."
]
@@ -6229,7 +6229,7 @@
},
"fallback": "0x00",
"docs": [
" Latest versions that we know various locations support."
" The Latest versions that we know various locations support."
]
},
{
@@ -2163,6 +2163,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Event"
],
"params": [],
@@ -2189,8 +2190,7 @@
}
},
"docs": [
"Events for this module.",
""
"\n\t\t\tThe [event](https://substrate.dev/docs/en/knowledgebase/runtime/events) emitted\n\t\t\tby this pallet.\n\t\t\t"
]
}
},
@@ -6868,116 +6868,109 @@
"variant": {
"variants": [
{
"name": "Undefined",
"name": "Overflow",
"fields": [],
"index": 0,
"docs": []
},
{
"name": "Overflow",
"name": "Unimplemented",
"fields": [],
"index": 1,
"docs": []
},
{
"name": "Unimplemented",
"name": "UntrustedReserveLocation",
"fields": [],
"index": 2,
"docs": []
},
{
"name": "UnhandledXcmVersion",
"name": "UntrustedTeleportLocation",
"fields": [],
"index": 3,
"docs": []
},
{
"name": "UnhandledXcmMessage",
"name": "MultiLocationFull",
"fields": [],
"index": 4,
"docs": []
},
{
"name": "UnhandledEffect",
"name": "MultiLocationNotInvertible",
"fields": [],
"index": 5,
"docs": []
},
{
"name": "EscalationOfPrivilege",
"name": "BadOrigin",
"fields": [],
"index": 6,
"docs": []
},
{
"name": "UntrustedReserveLocation",
"name": "InvalidLocation",
"fields": [],
"index": 7,
"docs": []
},
{
"name": "UntrustedTeleportLocation",
"name": "AssetNotFound",
"fields": [],
"index": 8,
"docs": []
},
{
"name": "DestinationBufferOverflow",
"name": "FailedToTransactAsset",
"fields": [],
"index": 9,
"docs": []
},
{
"name": "MultiLocationFull",
"name": "NotWithdrawable",
"fields": [],
"index": 10,
"docs": []
},
{
"name": "MultiLocationNotInvertible",
"name": "LocationCannotHold",
"fields": [],
"index": 11,
"docs": []
},
{
"name": "FailedToDecode",
"name": "ExceedsMaxMessageSize",
"fields": [],
"index": 12,
"docs": []
},
{
"name": "BadOrigin",
"name": "DestinationUnsupported",
"fields": [],
"index": 13,
"docs": []
},
{
"name": "ExceedsMaxMessageSize",
"name": "Transport",
"fields": [],
"index": 14,
"docs": []
},
{
"name": "FailedToTransactAsset",
"name": "Unroutable",
"fields": [],
"index": 15,
"docs": []
},
{
"name": "WeightLimitReached",
"fields": [
{
"name": null,
"type": 8,
"typeName": "Weight",
"docs": []
}
],
"name": "UnknownClaim",
"fields": [],
"index": 16,
"docs": []
},
{
"name": "Wildcard",
"name": "FailedToDecode",
"fields": [],
"index": 17,
"docs": []
@@ -6994,70 +6987,10 @@
"index": 19,
"docs": []
},
{
"name": "WeightNotComputable",
"fields": [],
"index": 20,
"docs": []
},
{
"name": "Barrier",
"fields": [],
"index": 21,
"docs": []
},
{
"name": "NotWithdrawable",
"fields": [],
"index": 22,
"docs": []
},
{
"name": "LocationCannotHold",
"fields": [],
"index": 23,
"docs": []
},
{
"name": "TooExpensive",
"fields": [],
"index": 24,
"docs": []
},
{
"name": "AssetNotFound",
"fields": [],
"index": 25,
"docs": []
},
{
"name": "DestinationUnsupported",
"fields": [],
"index": 26,
"docs": []
},
{
"name": "RecursionLimitReached",
"fields": [],
"index": 27,
"docs": []
},
{
"name": "Transport",
"fields": [],
"index": 28,
"docs": []
},
{
"name": "Unroutable",
"fields": [],
"index": 29,
"docs": []
},
{
"name": "UnknownWeightRequired",
"fields": [],
"index": 30,
"index": 20,
"docs": []
},
{
@@ -7070,19 +7003,38 @@
"docs": []
}
],
"index": 31,
"index": 21,
"docs": []
},
{
"name": "UnknownClaim",
"name": "UnhandledXcmVersion",
"fields": [],
"index": 32,
"index": 22,
"docs": []
},
{
"name": "InvalidLocation",
"name": "WeightLimitReached",
"fields": [
{
"name": null,
"type": 8,
"typeName": "Weight",
"docs": []
}
],
"index": 23,
"docs": []
},
{
"name": "Barrier",
"fields": [],
"index": 33,
"index": 24,
"docs": []
},
{
"name": "WeightNotComputable",
"fields": [],
"index": 25,
"docs": []
}
]
@@ -9916,7 +9868,7 @@
{
"name": null,
"type": 127,
"typeName": "result::Result<(), (u32, Error)>",
"typeName": "Option<(u32, Error)>",
"docs": []
}
],
@@ -9946,15 +9898,11 @@
"id": 127,
"type": {
"path": [
"Result"
"Option"
],
"params": [
{
"name": "T",
"type": 53
},
{
"name": "E",
"type": 128
}
],
@@ -9962,20 +9910,13 @@
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"name": null,
"type": 53,
"typeName": null,
"docs": []
}
],
"name": "None",
"fields": [],
"index": 0,
"docs": []
},
{
"name": "Err",
"name": "Some",
"fields": [
{
"name": null,
@@ -15843,6 +15784,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Call"
],
"params": [
@@ -15879,8 +15821,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)`",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)`. Actual cost depends on the number of length of",
" `T::Keys::key_ids()` which is fixed.",
"- DbReads: `origin account`, `T::ValidatorIdOf`, `NextKeys`",
"- DbWrites: `origin account`, `NextKeys`",
"- DbReads per key id: `KeyOwner`",
@@ -15899,8 +15841,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)` in number of key types.",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)` in number of key types. Actual cost depends on the number of length",
" of `T::Keys::key_ids()` which is fixed.",
"- DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`",
"- DbWrites: `NextKeys`, `origin account`",
"- DbWrites per key id: `KeyOwner`",
@@ -15911,9 +15853,7 @@
}
},
"docs": [
"Dispatchable calls.",
"",
"Each variant of this enum maps to a dispatchable function from the associated module."
"Contains one variant per dispatchable that can be called by an extrinsic."
]
}
},
@@ -15922,6 +15862,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Error"
],
"params": [
@@ -15977,7 +15918,7 @@
}
},
"docs": [
"Error for the session module."
"Error for the session pallet."
]
}
},
@@ -16740,6 +16681,12 @@
"def": {
"composite": {
"fields": [
{
"name": null,
"type": 111,
"typeName": null,
"docs": []
},
{
"name": null,
"type": 265,
@@ -28989,7 +28936,7 @@
"parameters.",
"",
"- `proposed_max_capacity` - specifies how many messages can be in the channel at once.",
"- `proposed_max_message_size` - specifies the maximum size of any of the messages.",
"- `proposed_max_message_size` - specifies the maximum size of the messages.",
"",
"These numbers are a subject to the relay-chain configuration limits.",
"",
@@ -38072,18 +38019,10 @@
"Candidate not in parent context."
]
},
{
"name": "UnoccupiedBitInBitfield",
"fields": [],
"index": 12,
"docs": [
"The bitfield contains a bit relating to an unassigned availability core."
]
},
{
"name": "InvalidGroupIndex",
"fields": [],
"index": 13,
"index": 12,
"docs": [
"Invalid group index in core assignment."
]
@@ -38091,7 +38030,7 @@
{
"name": "InsufficientBacking",
"fields": [],
"index": 14,
"index": 13,
"docs": [
"Insufficient (non-majority) backing."
]
@@ -38099,7 +38038,7 @@
{
"name": "InvalidBacking",
"fields": [],
"index": 15,
"index": 14,
"docs": [
"Invalid (bad signature, unknown validator, etc.) backing."
]
@@ -38107,7 +38046,7 @@
{
"name": "NotCollatorSigned",
"fields": [],
"index": 16,
"index": 15,
"docs": [
"Collator did not sign PoV."
]
@@ -38115,7 +38054,7 @@
{
"name": "ValidationDataHashMismatch",
"fields": [],
"index": 17,
"index": 16,
"docs": [
"The validation data hash does not match expected."
]
@@ -38123,7 +38062,7 @@
{
"name": "InternalError",
"fields": [],
"index": 18,
"index": 17,
"docs": [
"Internal error only returned when compiled with debug assertions."
]
@@ -38131,7 +38070,7 @@
{
"name": "IncorrectDownwardMessageHandling",
"fields": [],
"index": 19,
"index": 18,
"docs": [
"The downward message queue is not processed correctly."
]
@@ -38139,7 +38078,7 @@
{
"name": "InvalidUpwardMessages",
"fields": [],
"index": 20,
"index": 19,
"docs": [
"At least one upward message sent does not pass the acceptance criteria."
]
@@ -38147,7 +38086,7 @@
{
"name": "HrmpWatermarkMishandling",
"fields": [],
"index": 21,
"index": 20,
"docs": [
"The candidate didn't follow the rules of HRMP watermark advancement."
]
@@ -38155,7 +38094,7 @@
{
"name": "InvalidOutboundHrmp",
"fields": [],
"index": 22,
"index": 21,
"docs": [
"The HRMP messages sent by the candidate is not valid."
]
@@ -38163,7 +38102,7 @@
{
"name": "InvalidValidationCodeHash",
"fields": [],
"index": 23,
"index": 22,
"docs": [
"The validation code hash of the candidate is not valid."
]
@@ -38171,7 +38110,7 @@
{
"name": "ParaHeadMismatch",
"fields": [],
"index": 24,
"index": 23,
"docs": [
"The `para_head` hash in the candidate descriptor doesn't match the hash of the actual para head in the",
"commitments."
@@ -38221,11 +38160,11 @@
]
},
{
"name": "CandidateCouldBeInvalid",
"name": "CandidateConcludedInvalid",
"fields": [],
"index": 2,
"docs": [
"Potentially invalid candidate."
"Disputed candidate that was concluded invalid."
]
}
]
@@ -40206,7 +40145,7 @@
"fields": [],
"index": 3,
"docs": [
"The last lease period cannot be more then 3 periods after the first period."
"The last lease period cannot be more than 3 periods after the first period."
]
},
{
File diff suppressed because one or more lines are too long
@@ -265,7 +265,7 @@
{
"name": "Version",
"type": 121,
"value": "0x20706f6c6b61646f743c7061726974792d706f6c6b61646f74000000008c2300000000000038df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1503000000f78b278be53f454c02000000af2c0297a23e6d3d0100000049eaaf1b548a0cb00100000091d5df18b0d2cf5801000000ed99c5acb25eedf503000000cbca25e39f14238702000000687ad44ad37f03c201000000ab3c0572291feb8b01000000bc9d89904f5b923f0100000037c8bb1350a9a2a80100000007000000",
"value": "0x20706f6c6b61646f743c7061726974792d706f6c6b61646f7400000000962300000000000038df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1503000000f78b278be53f454c02000000af2c0297a23e6d3d0100000049eaaf1b548a0cb00100000091d5df18b0d2cf5801000000ed99c5acb25eedf503000000cbca25e39f14238702000000687ad44ad37f03c201000000ab3c0572291feb8b01000000bc9d89904f5b923f0100000037c8bb1350a9a2a80100000008000000",
"docs": [
" Get the chain's current version."
]
@@ -2308,6 +2308,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Event"
],
"params": [],
@@ -2334,8 +2335,7 @@
}
},
"docs": [
"Events for this module.",
""
"\n\t\t\tThe [event](https://substrate.dev/docs/en/knowledgebase/runtime/events) emitted\n\t\t\tby this pallet.\n\t\t\t"
]
}
},
@@ -6132,116 +6132,109 @@
"variant": {
"variants": [
{
"name": "Undefined",
"name": "Overflow",
"fields": [],
"index": 0,
"docs": []
},
{
"name": "Overflow",
"name": "Unimplemented",
"fields": [],
"index": 1,
"docs": []
},
{
"name": "Unimplemented",
"name": "UntrustedReserveLocation",
"fields": [],
"index": 2,
"docs": []
},
{
"name": "UnhandledXcmVersion",
"name": "UntrustedTeleportLocation",
"fields": [],
"index": 3,
"docs": []
},
{
"name": "UnhandledXcmMessage",
"name": "MultiLocationFull",
"fields": [],
"index": 4,
"docs": []
},
{
"name": "UnhandledEffect",
"name": "MultiLocationNotInvertible",
"fields": [],
"index": 5,
"docs": []
},
{
"name": "EscalationOfPrivilege",
"name": "BadOrigin",
"fields": [],
"index": 6,
"docs": []
},
{
"name": "UntrustedReserveLocation",
"name": "InvalidLocation",
"fields": [],
"index": 7,
"docs": []
},
{
"name": "UntrustedTeleportLocation",
"name": "AssetNotFound",
"fields": [],
"index": 8,
"docs": []
},
{
"name": "DestinationBufferOverflow",
"name": "FailedToTransactAsset",
"fields": [],
"index": 9,
"docs": []
},
{
"name": "MultiLocationFull",
"name": "NotWithdrawable",
"fields": [],
"index": 10,
"docs": []
},
{
"name": "MultiLocationNotInvertible",
"name": "LocationCannotHold",
"fields": [],
"index": 11,
"docs": []
},
{
"name": "FailedToDecode",
"name": "ExceedsMaxMessageSize",
"fields": [],
"index": 12,
"docs": []
},
{
"name": "BadOrigin",
"name": "DestinationUnsupported",
"fields": [],
"index": 13,
"docs": []
},
{
"name": "ExceedsMaxMessageSize",
"name": "Transport",
"fields": [],
"index": 14,
"docs": []
},
{
"name": "FailedToTransactAsset",
"name": "Unroutable",
"fields": [],
"index": 15,
"docs": []
},
{
"name": "WeightLimitReached",
"fields": [
{
"name": null,
"type": 8,
"typeName": "Weight",
"docs": []
}
],
"name": "UnknownClaim",
"fields": [],
"index": 16,
"docs": []
},
{
"name": "Wildcard",
"name": "FailedToDecode",
"fields": [],
"index": 17,
"docs": []
@@ -6258,70 +6251,10 @@
"index": 19,
"docs": []
},
{
"name": "WeightNotComputable",
"fields": [],
"index": 20,
"docs": []
},
{
"name": "Barrier",
"fields": [],
"index": 21,
"docs": []
},
{
"name": "NotWithdrawable",
"fields": [],
"index": 22,
"docs": []
},
{
"name": "LocationCannotHold",
"fields": [],
"index": 23,
"docs": []
},
{
"name": "TooExpensive",
"fields": [],
"index": 24,
"docs": []
},
{
"name": "AssetNotFound",
"fields": [],
"index": 25,
"docs": []
},
{
"name": "DestinationUnsupported",
"fields": [],
"index": 26,
"docs": []
},
{
"name": "RecursionLimitReached",
"fields": [],
"index": 27,
"docs": []
},
{
"name": "Transport",
"fields": [],
"index": 28,
"docs": []
},
{
"name": "Unroutable",
"fields": [],
"index": 29,
"docs": []
},
{
"name": "UnknownWeightRequired",
"fields": [],
"index": 30,
"index": 20,
"docs": []
},
{
@@ -6334,19 +6267,38 @@
"docs": []
}
],
"index": 31,
"index": 21,
"docs": []
},
{
"name": "UnknownClaim",
"name": "UnhandledXcmVersion",
"fields": [],
"index": 32,
"index": 22,
"docs": []
},
{
"name": "InvalidLocation",
"name": "WeightLimitReached",
"fields": [
{
"name": null,
"type": 8,
"typeName": "Weight",
"docs": []
}
],
"index": 23,
"docs": []
},
{
"name": "Barrier",
"fields": [],
"index": 33,
"index": 24,
"docs": []
},
{
"name": "WeightNotComputable",
"fields": [],
"index": 25,
"docs": []
}
]
@@ -10971,6 +10923,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Call"
],
"params": [
@@ -11007,8 +10960,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)`",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)`. Actual cost depends on the number of length of",
" `T::Keys::key_ids()` which is fixed.",
"- DbReads: `origin account`, `T::ValidatorIdOf`, `NextKeys`",
"- DbWrites: `origin account`, `NextKeys`",
"- DbReads per key id: `KeyOwner`",
@@ -11027,8 +10980,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)` in number of key types.",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)` in number of key types. Actual cost depends on the number of length",
" of `T::Keys::key_ids()` which is fixed.",
"- DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`",
"- DbWrites: `NextKeys`, `origin account`",
"- DbWrites per key id: `KeyOwner`",
@@ -11039,9 +10992,7 @@
}
},
"docs": [
"Dispatchable calls.",
"",
"Each variant of this enum maps to a dispatchable function from the associated module."
"Contains one variant per dispatchable that can be called by an extrinsic."
]
}
},
@@ -20562,7 +20513,7 @@
"parameters.",
"",
"- `proposed_max_capacity` - specifies how many messages can be in the channel at once.",
"- `proposed_max_message_size` - specifies the maximum size of any of the messages.",
"- `proposed_max_message_size` - specifies the maximum size of the messages.",
"",
"These numbers are a subject to the relay-chain configuration limits.",
"",
@@ -23792,6 +23743,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Error"
],
"params": [
@@ -23847,7 +23799,7 @@
}
},
"docs": [
"Error for the session module."
"Error for the session pallet."
]
}
},
@@ -24155,6 +24107,12 @@
"def": {
"composite": {
"fields": [
{
"name": null,
"type": 107,
"typeName": null,
"docs": []
},
{
"name": null,
"type": 423,
@@ -28560,18 +28518,10 @@
"Candidate not in parent context."
]
},
{
"name": "UnoccupiedBitInBitfield",
"fields": [],
"index": 12,
"docs": [
"The bitfield contains a bit relating to an unassigned availability core."
]
},
{
"name": "InvalidGroupIndex",
"fields": [],
"index": 13,
"index": 12,
"docs": [
"Invalid group index in core assignment."
]
@@ -28579,7 +28529,7 @@
{
"name": "InsufficientBacking",
"fields": [],
"index": 14,
"index": 13,
"docs": [
"Insufficient (non-majority) backing."
]
@@ -28587,7 +28537,7 @@
{
"name": "InvalidBacking",
"fields": [],
"index": 15,
"index": 14,
"docs": [
"Invalid (bad signature, unknown validator, etc.) backing."
]
@@ -28595,7 +28545,7 @@
{
"name": "NotCollatorSigned",
"fields": [],
"index": 16,
"index": 15,
"docs": [
"Collator did not sign PoV."
]
@@ -28603,7 +28553,7 @@
{
"name": "ValidationDataHashMismatch",
"fields": [],
"index": 17,
"index": 16,
"docs": [
"The validation data hash does not match expected."
]
@@ -28611,7 +28561,7 @@
{
"name": "InternalError",
"fields": [],
"index": 18,
"index": 17,
"docs": [
"Internal error only returned when compiled with debug assertions."
]
@@ -28619,7 +28569,7 @@
{
"name": "IncorrectDownwardMessageHandling",
"fields": [],
"index": 19,
"index": 18,
"docs": [
"The downward message queue is not processed correctly."
]
@@ -28627,7 +28577,7 @@
{
"name": "InvalidUpwardMessages",
"fields": [],
"index": 20,
"index": 19,
"docs": [
"At least one upward message sent does not pass the acceptance criteria."
]
@@ -28635,7 +28585,7 @@
{
"name": "HrmpWatermarkMishandling",
"fields": [],
"index": 21,
"index": 20,
"docs": [
"The candidate didn't follow the rules of HRMP watermark advancement."
]
@@ -28643,7 +28593,7 @@
{
"name": "InvalidOutboundHrmp",
"fields": [],
"index": 22,
"index": 21,
"docs": [
"The HRMP messages sent by the candidate is not valid."
]
@@ -28651,7 +28601,7 @@
{
"name": "InvalidValidationCodeHash",
"fields": [],
"index": 23,
"index": 22,
"docs": [
"The validation code hash of the candidate is not valid."
]
@@ -28659,7 +28609,7 @@
{
"name": "ParaHeadMismatch",
"fields": [],
"index": 24,
"index": 23,
"docs": [
"The `para_head` hash in the candidate descriptor doesn't match the hash of the actual para head in the",
"commitments."
@@ -28709,11 +28659,11 @@
]
},
{
"name": "CandidateCouldBeInvalid",
"name": "CandidateConcludedInvalid",
"fields": [],
"index": 2,
"docs": [
"Potentially invalid candidate."
"Disputed candidate that was concluded invalid."
]
}
]
@@ -30694,7 +30644,7 @@
"fields": [],
"index": 3,
"docs": [
"The last lease period cannot be more then 3 periods after the first period."
"The last lease period cannot be more than 3 periods after the first period."
]
},
{
File diff suppressed because one or more lines are too long
@@ -301,7 +301,7 @@
{
"name": "batched_calls_limit",
"type": 4,
"value": "0x73ed0000",
"value": "0x8ee30000",
"docs": [
" The limit on the number of batched calls."
]
@@ -2349,6 +2349,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Event"
],
"params": [],
@@ -2375,8 +2376,7 @@
}
},
"docs": [
"Events for this module.",
""
"\n\t\t\tThe [event](https://substrate.dev/docs/en/knowledgebase/runtime/events) emitted\n\t\t\tby this pallet.\n\t\t\t"
]
}
},
@@ -3830,13 +3830,13 @@
"name": "Instantiated",
"fields": [
{
"name": null,
"name": "deployer",
"type": 0,
"typeName": "T::AccountId",
"docs": []
},
{
"name": null,
"name": "contract",
"type": 0,
"typeName": "T::AccountId",
"docs": []
@@ -3844,34 +3844,32 @@
],
"index": 0,
"docs": [
"Contract deployed by address at the specified address. \\[deployer, contract\\]"
"Contract deployed by address at the specified address."
]
},
{
"name": "Terminated",
"fields": [
{
"name": null,
"name": "contract",
"type": 0,
"typeName": "T::AccountId",
"docs": []
"docs": [
"The contract that was terminated."
]
},
{
"name": null,
"name": "beneficiary",
"type": 0,
"typeName": "T::AccountId",
"docs": []
"docs": [
"The account that received the contracts remaining balance"
]
}
],
"index": 1,
"docs": [
"Contract has been removed.",
"\\[contract, beneficiary\\]",
"",
"# Params",
"",
"- `contract`: The contract that was terminated.",
"- `beneficiary`: The account that received the contracts remaining balance.",
"",
"# Note",
"",
@@ -3883,7 +3881,7 @@
"name": "CodeStored",
"fields": [
{
"name": null,
"name": "code_hash",
"type": 9,
"typeName": "T::Hash",
"docs": []
@@ -3891,62 +3889,57 @@
],
"index": 2,
"docs": [
"Code with the specified hash has been stored. \\[code_hash\\]"
"Code with the specified hash has been stored."
]
},
{
"name": "ScheduleUpdated",
"fields": [
{
"name": null,
"name": "version",
"type": 4,
"typeName": "u32",
"docs": []
"docs": [
"The version of the newly set schedule."
]
}
],
"index": 3,
"docs": [
"Triggered when the current schedule is updated.",
"\\[version\\]",
"",
"# Params",
"",
"- `version`: The version of the newly set schedule."
"Triggered when the current schedule is updated."
]
},
{
"name": "ContractEmitted",
"fields": [
{
"name": null,
"name": "contract",
"type": 0,
"typeName": "T::AccountId",
"docs": []
"docs": [
"The contract that emitted the event."
]
},
{
"name": null,
"name": "data",
"type": 10,
"typeName": "Vec<u8>",
"docs": []
"docs": [
"Data supplied by the contract. Metadata generated during contract compilation",
"is needed to decode it."
]
}
],
"index": 4,
"docs": [
"A custom event emitted by the contract.",
"\\[contract, data\\]",
"",
"# Params",
"",
"- `contract`: The contract that emitted the event.",
"- `data`: Data supplied by the contract. Metadata generated during contract compilation",
" is needed to decode it."
"A custom event emitted by the contract."
]
},
{
"name": "CodeRemoved",
"fields": [
{
"name": null,
"name": "code_hash",
"type": 9,
"typeName": "T::Hash",
"docs": []
@@ -3955,7 +3948,6 @@
"index": 5,
"docs": [
"A code with the specified hash was removed.",
"\\[code_hash\\]",
"",
"This happens when the last contract that uses this code hash was removed."
]
@@ -12114,6 +12106,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Call"
],
"params": [
@@ -12150,8 +12143,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)`",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)`. Actual cost depends on the number of length of",
" `T::Keys::key_ids()` which is fixed.",
"- DbReads: `origin account`, `T::ValidatorIdOf`, `NextKeys`",
"- DbWrites: `origin account`, `NextKeys`",
"- DbReads per key id: `KeyOwner`",
@@ -12170,8 +12163,8 @@
"The dispatch origin of this function must be signed.",
"",
"# <weight>",
"- Complexity: `O(1)` in number of key types.",
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
"- Complexity: `O(1)` in number of key types. Actual cost depends on the number of length",
" of `T::Keys::key_ids()` which is fixed.",
"- DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`",
"- DbWrites: `NextKeys`, `origin account`",
"- DbWrites per key id: `KeyOwner`",
@@ -12182,9 +12175,7 @@
}
},
"docs": [
"Dispatchable calls.",
"",
"Each variant of this enum maps to a dispatchable function from the associated module."
"Contains one variant per dispatchable that can be called by an extrinsic."
]
}
},
@@ -24300,6 +24291,7 @@
"type": {
"path": [
"pallet_session",
"pallet",
"Error"
],
"params": [
@@ -24355,7 +24347,7 @@
}
},
"docs": [
"Error for the session module."
"Error for the session pallet."
]
}
},
@@ -27493,6 +27485,12 @@
"def": {
"composite": {
"fields": [
{
"name": null,
"type": 98,
"typeName": null,
"docs": []
},
{
"name": null,
"type": 417,
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-support', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/types-support', version: '6.2.1' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "6.1.2",
"version": "6.2.1",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -26,7 +26,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.4.1",
"@polkadot/types-support": "6.1.2",
"@polkadot/types-support": "6.2.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.12.0"
}
+4 -13
View File
@@ -138,12 +138,9 @@ export default {
xcm: 'XcmV2Xcm',
},
Transact: {
_alias: {
call_: 'call',
},
originType: 'XcmV0OriginKind',
requireWeightAtMost: 'Compact<u64>',
call_: 'XcmDoubleEncoded',
call: 'XcmDoubleEncoded',
},
HrmpNewChannelOpenRequest: {
sender: 'Compact<u32>',
@@ -266,7 +263,7 @@ export default {
_enum: {
Null: 'Null',
Assets: 'XcmV1MultiassetMultiAssets',
ExecutionResult: 'Result<Null, (u32,XcmV2TraitsError)>',
ExecutionResult: 'Option<(u32,XcmV2TraitsError)>',
Version: 'u32'
}
},
@@ -501,12 +498,9 @@ export default {
effects: 'Vec<XcmV0Order>',
},
Transact: {
_alias: {
call_: 'call',
},
originType: 'XcmV0OriginKind',
requireWeightAtMost: 'u64',
call_: 'XcmDoubleEncoded',
call: 'XcmDoubleEncoded',
},
HrmpNewChannelOpenRequest: {
sender: 'Compact<u32>',
@@ -609,12 +603,9 @@ export default {
effects: 'Vec<XcmV1Order>',
},
Transact: {
_alias: {
call_: 'call',
},
originType: 'XcmV0OriginKind',
requireWeightAtMost: 'u64',
call_: 'XcmDoubleEncoded',
call: 'XcmDoubleEncoded',
},
HrmpNewChannelOpenRequest: {
sender: 'Compact<u32>',
+12 -20
View File
@@ -60,40 +60,32 @@ export default {
**/
XcmV2TraitsError: {
_enum: {
Undefined: 'Null',
Overflow: 'Null',
Unimplemented: 'Null',
UnhandledXcmVersion: 'Null',
UnhandledXcmMessage: 'Null',
UnhandledEffect: 'Null',
EscalationOfPrivilege: 'Null',
UntrustedReserveLocation: 'Null',
UntrustedTeleportLocation: 'Null',
DestinationBufferOverflow: 'Null',
MultiLocationFull: 'Null',
MultiLocationNotInvertible: 'Null',
FailedToDecode: 'Null',
BadOrigin: 'Null',
ExceedsMaxMessageSize: 'Null',
InvalidLocation: 'Null',
AssetNotFound: 'Null',
FailedToTransactAsset: 'Null',
WeightLimitReached: 'u64',
Wildcard: 'Null',
TooMuchWeightRequired: 'Null',
NotHoldingFees: 'Null',
WeightNotComputable: 'Null',
Barrier: 'Null',
NotWithdrawable: 'Null',
LocationCannotHold: 'Null',
TooExpensive: 'Null',
AssetNotFound: 'Null',
ExceedsMaxMessageSize: 'Null',
DestinationUnsupported: 'Null',
RecursionLimitReached: 'Null',
Transport: 'Null',
Unroutable: 'Null',
UnknownWeightRequired: 'Null',
Trap: 'u64',
UnknownClaim: 'Null',
InvalidLocation: 'Null'
FailedToDecode: 'Null',
TooMuchWeightRequired: 'Null',
NotHoldingFees: 'Null',
TooExpensive: 'Null',
Trap: 'u64',
UnhandledXcmVersion: 'Null',
WeightLimitReached: 'u64',
Barrier: 'Null',
WeightNotComputable: 'Null'
}
},
/**
+5 -10
View File
@@ -965,8 +965,7 @@ export default {
**/
PalletContractsScheduleInstructionWeights: {
_alias: {
r_if: 'r#if',
call_: 'call'
r_if: 'r#if'
},
version: 'u32',
i64Const: 'u32',
@@ -978,7 +977,7 @@ export default {
brIf: 'u32',
brTable: 'u32',
brTablePerEntry: 'u32',
call_: 'u32',
call: 'u32',
callIndirect: 'u32',
callIndirectPerParam: 'u32',
localGet: 'u32',
@@ -1026,8 +1025,7 @@ export default {
**/
PalletContractsScheduleHostFnWeights: {
_alias: {
r_return: 'r#return',
call_: 'call'
r_return: 'r#return'
},
caller: 'u64',
address: 'u64',
@@ -1056,7 +1054,7 @@ export default {
getStorage: 'u64',
getStoragePerByte: 'u64',
transfer: 'u64',
call_: 'u64',
call: 'u64',
callTransferSurcharge: 'u64',
callPerInputByte: 'u64',
callPerOutputByte: 'u64',
@@ -1160,12 +1158,9 @@ export default {
* Lookup454: pallet_scheduler::ScheduledV2<node_runtime::Call, BlockNumber, node_runtime::OriginCaller, sp_core::crypto::AccountId32>
**/
PalletSchedulerScheduledV2: {
_alias: {
call_: 'call'
},
maybeId: 'Option<Bytes>',
priority: 'u8',
call_: 'Call',
call: 'Call',
maybePeriodic: 'Option<(u32,u32)>',
origin: 'NodeRuntimeOriginCaller'
},
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Bytes, Compact, Enum, Null, Option, Result, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types';
import type { Bytes, Compact, Enum, Null, Option, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types';
import type { PerU16 } from '@polkadot/types/interfaces/runtime';
import type { ITuple } from '@polkadot/types/types';
@@ -156,7 +156,7 @@ declare module '@polkadot/types/lookup' {
readonly asTransact: {
readonly originType: XcmV0OriginKind;
readonly requireWeightAtMost: Compact<u64>;
readonly call_: XcmDoubleEncoded;
readonly call: XcmDoubleEncoded;
} & Struct;
readonly isHrmpNewChannelOpenRequest: boolean;
readonly asHrmpNewChannelOpenRequest: {
@@ -290,7 +290,7 @@ declare module '@polkadot/types/lookup' {
readonly isAssets: boolean;
readonly asAssets: XcmV1MultiassetMultiAssets;
readonly isExecutionResult: boolean;
readonly asExecutionResult: Result<Null, ITuple<[u32, XcmV2TraitsError]>>;
readonly asExecutionResult: Option<ITuple<[u32, XcmV2TraitsError]>>;
readonly isVersion: boolean;
readonly asVersion: u32;
}
@@ -539,7 +539,7 @@ declare module '@polkadot/types/lookup' {
readonly asTransact: {
readonly originType: XcmV0OriginKind;
readonly requireWeightAtMost: u64;
readonly call_: XcmDoubleEncoded;
readonly call: XcmDoubleEncoded;
} & Struct;
readonly isHrmpNewChannelOpenRequest: boolean;
readonly asHrmpNewChannelOpenRequest: {
@@ -654,7 +654,7 @@ declare module '@polkadot/types/lookup' {
readonly asTransact: {
readonly originType: XcmV0OriginKind;
readonly requireWeightAtMost: u64;
readonly call_: XcmDoubleEncoded;
readonly call: XcmDoubleEncoded;
} & Struct;
readonly isHrmpNewChannelOpenRequest: boolean;
readonly asHrmpNewChannelOpenRequest: {
@@ -59,42 +59,34 @@ declare module '@polkadot/types/lookup' {
/** @name XcmV2TraitsError (96) */
export interface XcmV2TraitsError extends Enum {
readonly isUndefined: boolean;
readonly isOverflow: boolean;
readonly isUnimplemented: boolean;
readonly isUnhandledXcmVersion: boolean;
readonly isUnhandledXcmMessage: boolean;
readonly isUnhandledEffect: boolean;
readonly isEscalationOfPrivilege: boolean;
readonly isUntrustedReserveLocation: boolean;
readonly isUntrustedTeleportLocation: boolean;
readonly isDestinationBufferOverflow: boolean;
readonly isMultiLocationFull: boolean;
readonly isMultiLocationNotInvertible: boolean;
readonly isFailedToDecode: boolean;
readonly isBadOrigin: boolean;
readonly isExceedsMaxMessageSize: boolean;
readonly isInvalidLocation: boolean;
readonly isAssetNotFound: boolean;
readonly isFailedToTransactAsset: boolean;
readonly isWeightLimitReached: boolean;
readonly asWeightLimitReached: u64;
readonly isWildcard: boolean;
readonly isTooMuchWeightRequired: boolean;
readonly isNotHoldingFees: boolean;
readonly isWeightNotComputable: boolean;
readonly isBarrier: boolean;
readonly isNotWithdrawable: boolean;
readonly isLocationCannotHold: boolean;
readonly isTooExpensive: boolean;
readonly isAssetNotFound: boolean;
readonly isExceedsMaxMessageSize: boolean;
readonly isDestinationUnsupported: boolean;
readonly isRecursionLimitReached: boolean;
readonly isTransport: boolean;
readonly isUnroutable: boolean;
readonly isUnknownWeightRequired: boolean;
readonly isUnknownClaim: boolean;
readonly isFailedToDecode: boolean;
readonly isTooMuchWeightRequired: boolean;
readonly isNotHoldingFees: boolean;
readonly isTooExpensive: boolean;
readonly isTrap: boolean;
readonly asTrap: u64;
readonly isUnknownClaim: boolean;
readonly isInvalidLocation: boolean;
readonly isUnhandledXcmVersion: boolean;
readonly isWeightLimitReached: boolean;
readonly asWeightLimitReached: u64;
readonly isBarrier: boolean;
readonly isWeightNotComputable: boolean;
}
/** @name PolkadotParachainPrimitivesHrmpChannelId (98) */
@@ -1029,7 +1029,7 @@ declare module '@polkadot/types/lookup' {
readonly brIf: u32;
readonly brTable: u32;
readonly brTablePerEntry: u32;
readonly call_: u32;
readonly call: u32;
readonly callIndirect: u32;
readonly callIndirectPerParam: u32;
readonly localGet: u32;
@@ -1102,7 +1102,7 @@ declare module '@polkadot/types/lookup' {
readonly getStorage: u64;
readonly getStoragePerByte: u64;
readonly transfer: u64;
readonly call_: u64;
readonly call: u64;
readonly callTransferSurcharge: u64;
readonly callPerInputByte: u64;
readonly callPerOutputByte: u64;
@@ -1200,7 +1200,7 @@ declare module '@polkadot/types/lookup' {
export interface PalletSchedulerScheduledV2 extends Struct {
readonly maybeId: Option<Bytes>;
readonly priority: u8;
readonly call_: Call;
readonly call: Call;
readonly maybePeriodic: Option<ITuple<[u32, u32]>>;
readonly origin: NodeRuntimeOriginCaller;
}
@@ -3,11 +3,12 @@
import type { SignOptions } from '@polkadot/keyring/types';
import type { ExtrinsicEra } from '../../interfaces/extrinsics';
import type { Balance, Hash, Index } from '../../interfaces/runtime';
import type { AssetId, Balance, Hash, Index } from '../../interfaces/runtime';
import type { ExtrinsicPayloadValue, IKeyringPair, Registry } from '../../types';
import { Compact } from '../../codec/Compact';
import { Enum } from '../../codec/Enum';
import { Option } from '../../codec/Option';
import { Struct } from '../../codec/Struct';
import { Bytes } from '../../primitive/Bytes';
import { u32 } from '../../primitive/U32';
@@ -92,6 +93,14 @@ export class GenericExtrinsicPayloadV4 extends Struct {
return this.get('transactionVersion') as u32;
}
/**
* @description
* The (optional) asset id for this signature for chains that support transaction fees in assets
*/
public get assetId (): Option<AssetId> {
return this.get('assetId') as Option<AssetId>;
}
/**
* @description Sign the payload with the keypair
*/
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics';
import type { Address, Balance, Call, Index } from '../../interfaces/runtime';
import type { Address, AssetId, Balance, Call, Index } from '../../interfaces/runtime';
import type { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
import type { ExtrinsicSignatureOptions } from '../types';
@@ -10,6 +10,7 @@ import { assert, isU8a, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
import { Compact } from '../../codec/Compact';
import { Enum } from '../../codec/Enum';
import { Option } from '../../codec/Option';
import { Struct } from '../../codec/Struct';
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
import { GenericExtrinsicPayloadV4 } from './ExtrinsicPayload';
@@ -114,12 +115,21 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
return this.get('tip') as Compact<Balance>;
}
protected _injectSignature (signer: Address, signature: ExtrinsicSignature, { era, nonce, tip }: GenericExtrinsicPayloadV4): IExtrinsicSignature {
/**
* @description
* The (optional) asset id for this signature for chains that support transaction fees in assets
*/
public get assetId (): Option<AssetId> {
return this.get('assetId') as Option<AssetId>;
}
protected _injectSignature (signer: Address, signature: ExtrinsicSignature, { assetId, era, nonce, tip }: GenericExtrinsicPayloadV4): IExtrinsicSignature {
this.set('era', era);
this.set('nonce', nonce);
this.set('signer', signer);
this.set('signature', signature);
this.set('tip', tip);
this.set('assetId', assetId);
return this;
}
@@ -138,8 +148,9 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
/**
* @description Creates a payload from the supplied options
*/
public createPayload (method: Call, { blockHash, era, genesisHash, nonce, runtimeVersion: { specVersion, transactionVersion }, tip }: SignatureOptions): GenericExtrinsicPayloadV4 {
public createPayload (method: Call, { assetId, blockHash, era, genesisHash, nonce, runtimeVersion: { specVersion, transactionVersion }, tip }: SignatureOptions): GenericExtrinsicPayloadV4 {
return new GenericExtrinsicPayloadV4(this.registry, {
assetId,
blockHash,
era: era || IMMORTAL_ERA,
genesisHash,
@@ -50,8 +50,8 @@ const SETS = [
// These we never use these as top-level names, they are wrappers
const WRAPPERS = ['BoundedBTreeMap', 'BoundedVec', 'Box', 'BTreeMap', 'Cow', 'Result', 'Option', 'WeakBoundedVec', 'WrapperOpaque'];
// These are reserved and/or conflicts with built-in Codec definitions
const RESERVED = ['call', 'entries', 'hash', 'keys', 'new', 'size'];
// These are reserved and/or conflicts with built-in Codec or JS definitions
const RESERVED = ['entries', 'hash', 'keys', 'new', 'size'];
function matchParts (first: string[], second: (string | Text)[]): boolean {
return first.length === second.length && first.every((a, index) => {
@@ -33,9 +33,9 @@ export default {
},
VoteThreshold: {
_enum: [
'Super majority approval',
'Super majority rejection',
'Simple majority'
'Super Majority Approve',
'Super Majority Against',
'Simple Majority'
]
}
}
@@ -41,9 +41,9 @@ export interface VoterInfo extends Struct {
/** @name VoteThreshold */
export interface VoteThreshold extends Enum {
readonly isSupermajorityapproval: boolean;
readonly isSupermajorityrejection: boolean;
readonly isSimplemajority: boolean;
readonly isSuperMajorityApprove: boolean;
readonly isSuperMajorityAgainst: boolean;
readonly isSimpleMajority: boolean;
}
export type PHANTOM_ELECTIONS = 'elections';
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '6.1.2' };
export const packageInfo = { name: '@polkadot/types', version: '6.2.1' };
@@ -73,6 +73,12 @@ function decodeStorageKey (value?: string | Uint8Array | StorageKey | StorageEnt
assert(isFunction(fn), 'Expected function input for key construction');
if (fn.meta && fn.meta.type.isMap) {
const map = fn.meta.type.asMap;
assert(Array.isArray(args) && args.length === map.hashers.length, () => `Expected an array of ${map.hashers.length} values as params to a Map query`);
}
return {
key: fn(...args),
method: fn.method,
+2
View File
@@ -159,6 +159,7 @@ export interface SignatureOptions {
signedExtensions?: string[];
signer?: Signer;
tip?: AnyNumber;
assetId?: AnyNumber;
}
interface ExtrinsicSignatureBase {
@@ -179,6 +180,7 @@ export interface ExtrinsicPayloadValue {
specVersion: AnyNumber;
tip: AnyNumber;
transactionVersion: AnyNumber;
assetId?: AnyNumber;
}
export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {
+27 -27
View File
@@ -1842,40 +1842,40 @@ __metadata:
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.1.2
"@polkadot/types": 6.1.2
"@polkadot/api": 6.2.1
"@polkadot/types": 6.2.1
"@polkadot/util": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/api-derive@6.1.2, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@6.2.1, @polkadot/api-derive@workspace:packages/api-derive":
version: 0.0.0-use.local
resolution: "@polkadot/api-derive@workspace:packages/api-derive"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.1.2
"@polkadot/api": 6.2.1
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-core": 6.1.2
"@polkadot/rpc-provider": 6.1.2
"@polkadot/types": 6.1.2
"@polkadot/rpc-core": 6.2.1
"@polkadot/rpc-provider": 6.2.1
"@polkadot/types": 6.2.1
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/api@6.1.2, @polkadot/api@workspace:packages/api":
"@polkadot/api@6.2.1, @polkadot/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@polkadot/api@workspace:packages/api"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api-derive": 6.1.2
"@polkadot/api-derive": 6.2.1
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-core": 6.1.2
"@polkadot/rpc-provider": 6.1.2
"@polkadot/types": 6.1.2
"@polkadot/types-known": 6.1.2
"@polkadot/rpc-core": 6.2.1
"@polkadot/rpc-provider": 6.2.1
"@polkadot/types": 6.2.1
"@polkadot/types-known": 6.2.1
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
eventemitter3: ^4.0.7
@@ -2000,26 +2000,26 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/rpc-core@6.1.2, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@6.2.1, @polkadot/rpc-core@workspace:packages/rpc-core":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-core@workspace:packages/rpc-core"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/rpc-provider": 6.1.2
"@polkadot/types": 6.1.2
"@polkadot/rpc-provider": 6.2.1
"@polkadot/types": 6.2.1
"@polkadot/util": ^7.4.1
rxjs: ^7.3.0
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@6.1.2, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@6.2.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/types": 6.1.2
"@polkadot/types": 6.2.1
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
"@polkadot/x-fetch": ^7.4.1
@@ -2047,10 +2047,10 @@ __metadata:
"@babel/core": ^7.15.5
"@babel/register": ^7.15.3
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.1.2
"@polkadot/rpc-provider": 6.1.2
"@polkadot/types": 6.1.2
"@polkadot/types-support": 6.1.2
"@polkadot/api": 6.2.1
"@polkadot/rpc-provider": 6.2.1
"@polkadot/types": 6.2.1
"@polkadot/types-support": 6.2.1
"@polkadot/util": ^7.4.1
"@types/websocket": ^1.0.4
"@types/yargs": ^17.0.3
@@ -2066,18 +2066,18 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-known@6.1.2, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@6.2.1, @polkadot/types-known@workspace:packages/types-known":
version: 0.0.0-use.local
resolution: "@polkadot/types-known@workspace:packages/types-known"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/networks": ^7.4.1
"@polkadot/types": 6.1.2
"@polkadot/types": 6.2.1
"@polkadot/util": ^7.4.1
languageName: unknown
linkType: soft
"@polkadot/types-support@6.1.2, @polkadot/types-support@workspace:packages/types-support":
"@polkadot/types-support@6.2.1, @polkadot/types-support@workspace:packages/types-support":
version: 0.0.0-use.local
resolution: "@polkadot/types-support@workspace:packages/types-support"
dependencies:
@@ -2086,13 +2086,13 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types@6.1.2, @polkadot/types@workspace:packages/types":
"@polkadot/types@6.2.1, @polkadot/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@polkadot/types@workspace:packages/types"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.4.1
"@polkadot/types-support": 6.1.2
"@polkadot/types-support": 6.2.1
"@polkadot/util": ^7.4.1
"@polkadot/util-crypto": ^7.4.1
"@types/bn.js": ^4.11.6