Adjust object index typings (#5671)
* Adjust object index typings * CHANGELOG * Remove dot-notation overrides * Align overrides * Ordering * Revert lint formatting changes * Bump common
This commit is contained in:
@@ -27,8 +27,8 @@
|
||||
"@polkadot/rpc-core": "10.8.1",
|
||||
"@polkadot/types": "10.8.1",
|
||||
"@polkadot/types-codec": "10.8.1",
|
||||
"@polkadot/util": "^12.2.2",
|
||||
"@polkadot/util-crypto": "^12.2.2",
|
||||
"@polkadot/util": "^12.3.1",
|
||||
"@polkadot/util-crypto": "^12.3.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"tslib": "^2.5.3"
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ export function _flags (instanceId: string, api: DeriveApi): () => Observable<Fl
|
||||
return memo(instanceId, (): Observable<FlagsIntermediate> => {
|
||||
const results: unknown[] = [undefined, [], [], [], undefined];
|
||||
const calls = [
|
||||
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections)?.members,
|
||||
(api.query.elections || api.query['phragmenElection'] || api.query['electionsPhragmen'])?.members,
|
||||
api.query.council?.members,
|
||||
api.query.technicalCommittee?.members,
|
||||
api.query.society?.members,
|
||||
|
||||
@@ -15,13 +15,13 @@ import { memo } from '../util/index.js';
|
||||
|
||||
function retrieveNick (api: DeriveApi, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
? api.query.nicks.nameOf(accountId)
|
||||
accountId && api.query['nicks']?.['nameOf']
|
||||
? api.query['nicks']['nameOf'](accountId)
|
||||
: of(undefined)
|
||||
) as Observable<Option<ITuple<[Bytes, Balance]>> | undefined>).pipe(
|
||||
map((nameOf): string | undefined =>
|
||||
nameOf?.isSome
|
||||
? u8aToString(nameOf.unwrap()[0]).substring(0, (api.consts.nicks.maxLength as u32).toNumber())
|
||||
? u8aToString(nameOf.unwrap()[0]).substring(0, (api.consts['nicks']['maxLength'] as u32).toNumber())
|
||||
: undefined
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { QueryableStorage } from '@polkadot/api-base/types';
|
||||
import type { DeriveApi } from '../types.js';
|
||||
|
||||
export function getQueryInterface (api: DeriveApi): QueryableStorage<'rxjs'>['voterBagsList'] {
|
||||
export function getQueryInterface (api: DeriveApi): DeriveApi['query']['voterList'] {
|
||||
return (
|
||||
// latest substrate (latest always first)
|
||||
api.query.voterBagsList ||
|
||||
// latest substrate & polkadot
|
||||
api.query.voterList ||
|
||||
// previous substrate
|
||||
api.query.bagsList ||
|
||||
// latest polkadot
|
||||
api.query.voterList
|
||||
api.query['voterBagsList'] ||
|
||||
api.query['bagsList']
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ function calcBalances (api: DeriveApi, [accountId, [accountNonce, [primary, ...a
|
||||
// old
|
||||
function queryBalancesFree (api: DeriveApi, accountId: AccountId): Observable<Result> {
|
||||
return combineLatest([
|
||||
api.query.balances.freeBalance<Balance>(accountId),
|
||||
api.query.balances.reservedBalance<Balance>(accountId),
|
||||
api.query.system.accountNonce<Index>(accountId)
|
||||
api.query.balances['freeBalance']<Balance>(accountId),
|
||||
api.query.balances['reservedBalance']<Balance>(accountId),
|
||||
api.query.system['accountNonce']<Index>(accountId)
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result => [
|
||||
accountNonce,
|
||||
@@ -71,8 +71,8 @@ function queryNonceOnly (api: DeriveApi, accountId: AccountId): Observable<Resul
|
||||
? api.query.system.account(accountId).pipe(
|
||||
map(({ nonce }) => fill(nonce))
|
||||
)
|
||||
: isFunction(api.query.system.accountNonce)
|
||||
? api.query.system.accountNonce<Index>(accountId).pipe(
|
||||
: isFunction(api.query.system['accountNonce'])
|
||||
? api.query.system['accountNonce']<Index>(accountId).pipe(
|
||||
map((nonce) => fill(nonce))
|
||||
)
|
||||
: of(fill(api.registry.createType('Index')));
|
||||
@@ -80,7 +80,7 @@ function queryNonceOnly (api: DeriveApi, accountId: AccountId): Observable<Resul
|
||||
|
||||
function queryBalancesAccount (api: DeriveApi, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||
const balances = modules
|
||||
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m]?.account)
|
||||
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m as 'balances']?.account)
|
||||
.filter((q) => isFunction(q));
|
||||
|
||||
const extract = (nonce: Index, data: AccountData[]): Result => [
|
||||
@@ -98,7 +98,7 @@ function queryBalancesAccount (api: DeriveApi, accountId: AccountId, modules: st
|
||||
map(([{ nonce }, ...balances]) => extract(nonce, balances as unknown as AccountData[]))
|
||||
)
|
||||
: combineLatest([
|
||||
api.query.system.accountNonce<Index>(accountId),
|
||||
api.query.system['accountNonce']<Index>(accountId),
|
||||
...balances.map((c) => c(accountId))
|
||||
]).pipe(
|
||||
map(([nonce, ...balances]) => extract(nonce, balances as unknown as AccountData[]))
|
||||
@@ -164,7 +164,7 @@ export function account (instanceId: string, api: DeriveApi): (address: AccountI
|
||||
? querySystemAccount(api, accountId)
|
||||
: isFunction(api.query.balances?.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: isFunction(api.query.balances?.freeBalance)
|
||||
: isFunction(api.query.balances?.['freeBalance'])
|
||||
? queryBalancesFree(api, accountId)
|
||||
: queryNonceOnly(api, accountId)
|
||||
])
|
||||
|
||||
@@ -116,7 +116,7 @@ function calcBalances (api: DeriveApi, result: Result): DeriveBalancesAll {
|
||||
function queryOld (api: DeriveApi, accountId: AccountId | string): Observable<ResultBalance> {
|
||||
return combineLatest([
|
||||
api.query.balances.locks(accountId),
|
||||
api.query.balances.vesting<Option<VestingSchedule>>(accountId)
|
||||
api.query.balances['vesting']<Option<VestingSchedule>>(accountId)
|
||||
]).pipe(
|
||||
map(([locks, optVesting]): ResultBalance => {
|
||||
let vestingNew = null;
|
||||
|
||||
@@ -42,11 +42,11 @@ function getAuthorDetailsWithAt (header: Header, queryAt: QueryableStorage<'rxjs
|
||||
|
||||
if (loggedAuthor) {
|
||||
// use the author mapping pallet, if available (ie: moonbeam, moonriver), to map session (nimbus) key to author (collator/validator) key
|
||||
if (queryAt.authorMapping?.mappingWithDeposit) {
|
||||
if (queryAt['authorMapping']?.['mappingWithDeposit']) {
|
||||
return combineLatest([
|
||||
of(header),
|
||||
validators,
|
||||
queryAt.authorMapping.mappingWithDeposit<OptionMapping>(loggedAuthor).pipe(
|
||||
queryAt['authorMapping']['mappingWithDeposit']<OptionMapping>(loggedAuthor).pipe(
|
||||
map((o) =>
|
||||
o.unwrapOr({ account: null }).account
|
||||
)
|
||||
@@ -55,13 +55,13 @@ function getAuthorDetailsWithAt (header: Header, queryAt: QueryableStorage<'rxjs
|
||||
}
|
||||
|
||||
// fall back to session and parachain staking pallets, if available (ie: manta, calamari), to map session (nimbus) key to author (collator) key
|
||||
if (queryAt.parachainStaking?.selectedCandidates && queryAt.session?.nextKeys) {
|
||||
if (queryAt['parachainStaking']?.['selectedCandidates'] && queryAt.session?.nextKeys) {
|
||||
const loggedHex = loggedAuthor.toHex();
|
||||
|
||||
return combineLatest([
|
||||
of(header),
|
||||
validators,
|
||||
queryAt.parachainStaking.selectedCandidates<Vec<AccountId>>().pipe(
|
||||
queryAt['parachainStaking']['selectedCandidates']<Vec<AccountId>>().pipe(
|
||||
mergeMap((selectedCandidates) =>
|
||||
combineLatest([
|
||||
of(selectedCandidates),
|
||||
|
||||
@@ -15,18 +15,18 @@ type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN, BN];
|
||||
function queryConstants (api: DeriveApi): Observable<ResultV2> {
|
||||
return of([
|
||||
// deprecated
|
||||
api.consts.contracts.callBaseFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts.contractFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts.creationFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts.transactionBaseFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts.transactionByteFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts.transferFee || api.registry.createType('Balance'),
|
||||
api.consts.contracts['callBaseFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['contractFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['creationFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['transactionBaseFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['transactionByteFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['transferFee'] || api.registry.createType('Balance'),
|
||||
|
||||
// current
|
||||
api.consts.contracts.rentByteFee,
|
||||
api.consts.contracts.rentDepositOffset,
|
||||
api.consts.contracts.surchargeReward,
|
||||
api.consts.contracts.tombstoneDeposit
|
||||
api.consts.contracts['rentByteFee'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['rentDepositOffset'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['surchargeReward'] || api.registry.createType('Balance'),
|
||||
api.consts.contracts['tombstoneDeposit'] || api.registry.createType('Balance')
|
||||
]) as unknown as Observable<ResultV2>;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,22 +21,22 @@ function isVoter (value: VoteEntry): value is PalletElectionsPhragmenVoter {
|
||||
}
|
||||
|
||||
function retrieveStakeOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, Balance][]> {
|
||||
return elections.stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
return elections['stakeOf'].entries<Balance, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveVoteOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, AccountId[]][]> {
|
||||
return elections.votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
function retrieveVoteOf (elections: DeriveApi['query']['elections']): Observable<[AccountId, AccountId[]][]> {
|
||||
return elections['votesOf'].entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrievePrev (api: DeriveApi, elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
|
||||
function retrievePrev (api: DeriveApi, elections: DeriveApi['query']['elections']): Observable<DeriveCouncilVotes> {
|
||||
return combineLatest([
|
||||
retrieveStakeOf(elections),
|
||||
retrieveVoteOf(elections)
|
||||
@@ -63,7 +63,7 @@ function retrievePrev (api: DeriveApi, elections: QueryableModuleStorage<'rxjs'>
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveCurrent (elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
|
||||
function retrieveCurrent (elections: DeriveApi['query']['elections']): Observable<DeriveCouncilVotes> {
|
||||
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
|
||||
map((entries): DeriveCouncilVotes =>
|
||||
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
|
||||
@@ -77,11 +77,11 @@ function retrieveCurrent (elections: QueryableModuleStorage<'rxjs'>): Observable
|
||||
}
|
||||
|
||||
export function votes (instanceId: string, api: DeriveApi): () => Observable<DeriveCouncilVotes> {
|
||||
const elections = api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections;
|
||||
const elections = api.query.elections || api.query['phragmenElection'] || api.query['electionsPhragmen'];
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
|
||||
elections
|
||||
? elections.stakeOf
|
||||
? elections['stakeOf']
|
||||
? retrievePrev(api, elections)
|
||||
: retrieveCurrent(elections)
|
||||
: of([])
|
||||
|
||||
@@ -35,7 +35,7 @@ function createChildKey (info: AllInfo): string {
|
||||
|
||||
export function childKey (instanceId: string, api: DeriveApi): (paraId: string | number | BN) => Observable<string | null> {
|
||||
return memo(instanceId, (paraId: string | number | BN): Observable<string | null> =>
|
||||
api.query.crowdloan.funds<Option<PolkadotRuntimeCommonCrowdloanFundInfo>>(paraId).pipe(
|
||||
api.query['crowdloan']['funds']<Option<PolkadotRuntimeCommonCrowdloanFundInfo>>(paraId).pipe(
|
||||
map((optInfo) =>
|
||||
optInfo.isSome
|
||||
? createChildKey(optInfo.unwrap())
|
||||
|
||||
@@ -53,7 +53,7 @@ function isBounded (call: FrameSupportPreimagesBounded | FrameSupportScheduleMay
|
||||
}
|
||||
|
||||
function queryQueue (api: DeriveApi): Observable<DeriveDispatch[]> {
|
||||
return api.query.democracy.dispatchQueue<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>().pipe(
|
||||
return api.query.democracy['dispatchQueue']<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>().pipe(
|
||||
switchMap((dispatches) =>
|
||||
combineLatest([
|
||||
of(dispatches),
|
||||
@@ -142,7 +142,7 @@ export function dispatchQueue (instanceId: string, api: DeriveApi): () => Observ
|
||||
return memo(instanceId, (): Observable<DeriveDispatch[]> =>
|
||||
isFunction(api.query.scheduler?.agenda)
|
||||
? queryScheduler(api)
|
||||
: api.query.democracy.dispatchQueue
|
||||
: api.query.democracy['dispatchQueue']
|
||||
? queryQueue(api)
|
||||
: of([])
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ type PreimageInfo = [Bytes, AccountId, Balance, BlockNumber];
|
||||
type OldPreimage = ITuple<PreimageInfo>;
|
||||
|
||||
function isDemocracyPreimage (api: DeriveApi, imageOpt: Option<OldPreimage> | Option<PreimageStatus>): imageOpt is Option<PreimageStatus> {
|
||||
return !!imageOpt && !api.query.democracy.dispatchQueue;
|
||||
return !!imageOpt && !api.query.democracy['dispatchQueue'];
|
||||
}
|
||||
|
||||
function constructProposal (api: DeriveApi, [bytes, proposer, balance, at]: PreimageInfo): DeriveProposalImage {
|
||||
@@ -79,7 +79,7 @@ function parseImage (api: DeriveApi, [proposalHash, status, bytes]: [HexString,
|
||||
function getDemocracyImages (api: DeriveApi, bounded: (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[]): Observable<(DeriveProposalImage | undefined)[]> {
|
||||
const hashes = bounded.map((b) => getImageHashBounded(b));
|
||||
|
||||
return api.query.democracy.preimages.multi<Option<PreimageStatus>>(hashes).pipe(
|
||||
return api.query.democracy['preimages'].multi<Option<PreimageStatus>>(hashes).pipe(
|
||||
map((images): (DeriveProposalImage | undefined)[] =>
|
||||
images.map((imageOpt) => parseDemocracy(api, imageOpt))
|
||||
)
|
||||
@@ -127,7 +127,7 @@ function getImages (api: DeriveApi, bounded: (FrameSupportPreimagesBounded | Uin
|
||||
export function preimages (instanceId: string, api: DeriveApi): (hashes: (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[]) => Observable<(DeriveProposalImage | undefined)[]> {
|
||||
return memo(instanceId, (hashes: (Hash | Uint8Array | string | FrameSupportPreimagesBounded)[]): Observable<(DeriveProposalImage | undefined)[]> =>
|
||||
hashes.length
|
||||
? isFunction(api.query.democracy.preimages)
|
||||
? isFunction(api.query.democracy['preimages'])
|
||||
? getDemocracyImages(api, hashes)
|
||||
: isFunction(api.query.preimage.preimageFor)
|
||||
? getImages(api, hashes)
|
||||
|
||||
@@ -23,7 +23,6 @@ type Result = [Proposals, (DeriveProposalImage | undefined)[], Depositors[]];
|
||||
|
||||
function isNewDepositors (depositors: ITuple<[Vec<AccountId>, Balance]> | ITuple<[Balance, Vec<AccountId>]>): depositors is ITuple<[Vec<AccountId>, Balance]> {
|
||||
// Detect balance...
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
return isFunction((depositors[1] as Balance).mul);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ type VotingDirect = PalletDemocracyVoteVoting['asDirect'];
|
||||
type VotingDirectVote = VotingDirect['votes'][0];
|
||||
|
||||
function votesPrev (api: DeriveApi, referendumId: BN): Observable<DeriveReferendumVote[]> {
|
||||
return api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
|
||||
return api.query.democracy['votersFor']<Vec<AccountId>>(referendumId).pipe(
|
||||
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DeriveBalancesAccount[]]> =>
|
||||
combineLatest([
|
||||
of(votersFor),
|
||||
votersFor.length
|
||||
? api.query.democracy.voteOf.multi<Vote>(
|
||||
? api.query.democracy['voteOf'].multi<Vote>(
|
||||
votersFor.map((accountId): [BN | number, AccountId] =>
|
||||
[referendumId, accountId]
|
||||
)
|
||||
|
||||
@@ -47,20 +47,22 @@ function sortAccounts ([, balanceA]: [AccountId32, Balance], [, balanceB]: [Acco
|
||||
function getConstants (api: DeriveApi, elections: string | null): Partial<DeriveElectionsInfo> {
|
||||
return elections
|
||||
? {
|
||||
candidacyBond: api.consts[elections].candidacyBond as Balance,
|
||||
desiredRunnersUp: api.consts[elections].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[elections].desiredMembers as u32,
|
||||
termDuration: api.consts[elections].termDuration as BlockNumber,
|
||||
votingBond: api.consts[elections].votingBond as Balance
|
||||
candidacyBond: api.consts[elections as 'elections'].candidacyBond as Balance,
|
||||
desiredRunnersUp: api.consts[elections as 'elections'].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[elections as 'elections'].desiredMembers as u32,
|
||||
termDuration: api.consts[elections as 'elections'].termDuration as BlockNumber,
|
||||
votingBond: api.consts[elections as 'elections']['votingBond'] as Balance,
|
||||
votingBondBase: api.consts[elections as 'elections'].votingBondBase as Balance,
|
||||
votingBondFactor: api.consts[elections as 'elections'].votingBondFactor as Balance
|
||||
}
|
||||
: {};
|
||||
}
|
||||
|
||||
function getModules (api: DeriveApi): [string, string | null] {
|
||||
const [council] = api.registry.getModuleInstances(api.runtimeVersion.specName, 'council') || ['council'];
|
||||
const elections = api.query.phragmenElection
|
||||
const elections = api.query['phragmenElection']
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
: api.query['electionsPhragmen']
|
||||
? 'electionsPhragmen'
|
||||
: api.query.elections
|
||||
? 'elections'
|
||||
@@ -72,9 +74,9 @@ function getModules (api: DeriveApi): [string, string | null] {
|
||||
function queryAll (api: DeriveApi, council: string, elections: string): Observable<[AccountId32[], Candidate[], Member[], Member[]]> {
|
||||
return api.queryMulti<[Vec<AccountId32>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query[council as 'council'].members,
|
||||
api.query[elections as 'phragmenElection'].candidates,
|
||||
api.query[elections as 'phragmenElection'].members,
|
||||
api.query[elections as 'phragmenElection'].runnersUp
|
||||
api.query[elections as 'elections'].candidates,
|
||||
api.query[elections as 'elections'].members,
|
||||
api.query[elections as 'elections'].runnersUp
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,6 @@ export interface DeriveElectionsInfo {
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
votingBondBase?: Balance;
|
||||
votingBondFactor?: Balance;
|
||||
}
|
||||
|
||||
@@ -75,16 +75,16 @@ function parse (id: ParaId, [active, retryQueue, selectedThreads, didUpdate, inf
|
||||
|
||||
export function info (instanceId: string, api: DeriveApi): (id: ParaId | number) => Observable<DeriveParachainFull | null> {
|
||||
return memo(instanceId, (id: ParaId | number): Observable<DeriveParachainFull | null> =>
|
||||
api.query.registrar && api.query.parachains
|
||||
api.query['registrar'] && api.query['parachains']
|
||||
? api.queryMulti<Result>([
|
||||
api.query.registrar.active,
|
||||
api.query.registrar.retryQueue,
|
||||
api.query.registrar.selectedThreads,
|
||||
api.query.parachains.didUpdate,
|
||||
[api.query.registrar.paras, id],
|
||||
[api.query.registrar.pendingSwap, id],
|
||||
[api.query.parachains.heads, id],
|
||||
[api.query.parachains.relayDispatchQueue, id]
|
||||
api.query['registrar']['active'],
|
||||
api.query['registrar']['retryQueue'],
|
||||
api.query['registrar']['selectedThreads'],
|
||||
api.query['parachains']['didUpdate'],
|
||||
[api.query['registrar']['paras'], id],
|
||||
[api.query['registrar']['pendingSwap'], id],
|
||||
[api.query['parachains']['heads'], id],
|
||||
[api.query['parachains']['relayDispatchQueue'], id]
|
||||
])
|
||||
.pipe(
|
||||
map((result: Result): DeriveParachainFull | null =>
|
||||
|
||||
@@ -16,12 +16,12 @@ import { didUpdateToBool } from './util.js';
|
||||
type Result = [
|
||||
ParaId[],
|
||||
DidUpdate,
|
||||
RelayDispatchQueueSize[],
|
||||
ParaInfoResult[],
|
||||
PendingSwap[],
|
||||
RelayDispatchQueueSize[]
|
||||
PendingSwap[]
|
||||
];
|
||||
|
||||
function parse ([ids, didUpdate, infos, pendingSwaps, relayDispatchQueueSizes]: Result): DeriveParachain[] {
|
||||
function parse ([ids, didUpdate, relayDispatchQueueSizes, infos, pendingSwaps]: Result): DeriveParachain[] {
|
||||
return ids.map((id, index): DeriveParachain => ({
|
||||
didUpdate: didUpdateToBool(didUpdate, id),
|
||||
id,
|
||||
@@ -33,15 +33,15 @@ function parse ([ids, didUpdate, infos, pendingSwaps, relayDispatchQueueSizes]:
|
||||
|
||||
export function overview (instanceId: string, api: DeriveApi): () => Observable<DeriveParachain[]> {
|
||||
return memo(instanceId, (): Observable<DeriveParachain[]> =>
|
||||
api.query.registrar?.parachains && api.query.parachains
|
||||
? api.query.registrar.parachains<ParaId[]>().pipe(
|
||||
api.query['registrar']?.['parachains'] && api.query['parachains']
|
||||
? api.query['registrar']['parachains']<ParaId[]>().pipe(
|
||||
switchMap((paraIds) =>
|
||||
combineLatest([
|
||||
of(paraIds),
|
||||
api.query.parachains.didUpdate<DidUpdate>(),
|
||||
api.query.registrar.paras.multi<ParaInfoResult>(paraIds),
|
||||
api.query.registrar.pendingSwap.multi<PendingSwap>(paraIds),
|
||||
api.query.parachains.relayDispatchQueueSize.multi<RelayDispatchQueueSize>(paraIds)
|
||||
api.query['parachains']['didUpdate']<DidUpdate>(),
|
||||
api.query['parachains']['relayDispatchQueueSize'].multi<RelayDispatchQueueSize>(paraIds),
|
||||
api.query['registrar']['paras'].multi<ParaInfoResult>(paraIds),
|
||||
api.query['registrar']['pendingSwap'].multi<PendingSwap>(paraIds)
|
||||
])
|
||||
),
|
||||
map(parse)
|
||||
|
||||
@@ -19,7 +19,7 @@ export function erasHistoric (instanceId: string, api: DeriveApi): (withActive?:
|
||||
api.query.staking.activeEra(),
|
||||
api.consts.staking.historyDepth
|
||||
? of(api.consts.staking.historyDepth)
|
||||
: api.query.staking.historyDepth<u32>()
|
||||
: api.query.staking['historyDepth']<u32>()
|
||||
]).pipe(
|
||||
map(([activeEraOpt, historyDepth]): EraIndex[] => {
|
||||
const result: EraIndex[] = [];
|
||||
|
||||
@@ -38,8 +38,8 @@ export function keysMulti (instanceId: string, api: DeriveApi): (stashIds: (Uint
|
||||
switchMap((queuedKeys) =>
|
||||
combineLatest([
|
||||
of(queuedKeys),
|
||||
api.consts.session?.dedupKeyPrefix
|
||||
? api.query.session.nextKeys.multi(stashIds.map((s) => [api.consts.session.dedupKeyPrefix, s]))
|
||||
api.consts['session']?.['dedupKeyPrefix']
|
||||
? api.query.session.nextKeys.multi(stashIds.map((s) => [api.consts['session']['dedupKeyPrefix'], s]))
|
||||
: combineLatest(stashIds.map((s) => api.query.session.nextKeys(s)))
|
||||
])
|
||||
),
|
||||
|
||||
@@ -18,7 +18,7 @@ export function nextElected (instanceId: string, api: DeriveApi): () => Observab
|
||||
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
|
||||
map((keys) => keys.map(({ args: [, accountId] }) => accountId))
|
||||
)
|
||||
: api.query.staking.currentElected<AccountId[]>()
|
||||
: api.query.staking['currentElected']<AccountId[]>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces';
|
||||
import type { Codec, Constructor, InterfaceTypes, Registry } from '@polkadot/types/types';
|
||||
import type { Codec, CodecClass, InterfaceTypes, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Option, StorageKey } from '@polkadot/types';
|
||||
|
||||
@@ -29,7 +29,7 @@ export class BountyFactory {
|
||||
this.#registry.createType('Bounty');
|
||||
|
||||
public optionOf = <T extends Codec>(value: T): Option<T> => {
|
||||
const typeName = this.#registry.getClassName(value.constructor as Constructor<T>);
|
||||
const typeName = this.#registry.getClassName(value.constructor as CodecClass<T>);
|
||||
|
||||
return new Option<T>(this.#registry, typeName as keyof InterfaceTypes, value);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user