Prototype static init Enum/Set/Struct (#5087)
* Prototype static init Enum/Set/Struct * Adjust (similar, logic extracted - further local testing) * Adjust with latest util (no prototype atm) * Introduce prototype assignment * Old Enum tests * Fix toCallsOnly spread * Adjust * Use objectSpread in derives (decorated objects only) * Adjust * Remove extra map from bag get * Additional spreads * Signer spread * Formatting * typo * Adjust spreads for session * Additional spread * Adjust spread * Formatting * CHANGELOG * Adjust * slice * CHANGELOG
This commit is contained in:
@@ -10,7 +10,7 @@ import type { Bag } from './types';
|
||||
|
||||
import { map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN_ZERO, bnToBn } from '@polkadot/util';
|
||||
import { BN_ZERO, bnToBn, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -21,20 +21,17 @@ function orderBags (ids: BN[], bags: Option<PalletBagsListListBag>[]): Bag[] {
|
||||
id,
|
||||
key: id.toString()
|
||||
}))
|
||||
.sort((a, b) => b.id.cmp(a.id))
|
||||
.map((base, index): Bag => ({
|
||||
...base,
|
||||
bagLower: BN_ZERO,
|
||||
bagUpper: base.id,
|
||||
index
|
||||
}));
|
||||
.sort((a, b) => b.id.cmp(a.id));
|
||||
const max = sorted.length - 1;
|
||||
|
||||
return sorted.map((entry, index) =>
|
||||
index === max
|
||||
? entry
|
||||
// We could probably use a .add(BN_ONE) here
|
||||
: { ...entry, bagLower: sorted[index + 1].bagUpper }
|
||||
return sorted.map((entry, index): Bag =>
|
||||
objectSpread(entry, {
|
||||
bagLower: index === max
|
||||
? BN_ZERO
|
||||
: sorted[index + 1].id,
|
||||
bagUpper: entry.id,
|
||||
index
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ import type { Bag, BagExpanded } from './types';
|
||||
|
||||
import { map, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Observable<BagExpanded> {
|
||||
return memo(instanceId, (bag: Bag): Observable<BagExpanded> =>
|
||||
api.derive.bagsList.listNodes(bag.bag).pipe(
|
||||
map((nodes) => ({ ...bag, nodes }))
|
||||
map((nodes) => objectSpread({ nodes }, bag))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveBalancesAccountData } from
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -40,12 +40,11 @@ function getBalance (api: DeriveApi, [freeBalance, reservedBalance, frozenFee, f
|
||||
}
|
||||
|
||||
function calcBalances (api: DeriveApi, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
return {
|
||||
return objectSpread({
|
||||
accountId,
|
||||
accountNonce,
|
||||
additional: additional.map((b) => getBalance(api, b)),
|
||||
...getBalance(api, primary)
|
||||
};
|
||||
additional: additional.map((b) => getBalance(api, b))
|
||||
}, getBalance(api, primary));
|
||||
}
|
||||
|
||||
// old
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveBalancesAccountData, Deriv
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN, BN_ZERO, bnMax, bnMin, isFunction } from '@polkadot/util';
|
||||
import { BN, BN_ZERO, bnMax, bnMin, isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -57,13 +57,12 @@ function calcLocked (api: DeriveApi, bestNumber: BlockNumber, locks: (PalletBala
|
||||
function calcShared (api: DeriveApi, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||
|
||||
return {
|
||||
...data,
|
||||
return objectSpread({}, data, {
|
||||
availableBalance: api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance))),
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
vestingLocked
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function calcVesting (bestNumber: BlockNumber, shared: DeriveBalancesAllAccountData, _vesting: PalletVestingVestingInfo[] | null): DeriveBalancesAllVesting {
|
||||
@@ -102,16 +101,14 @@ function calcVesting (bestNumber: BlockNumber, shared: DeriveBalancesAllAccountD
|
||||
function calcBalances (api: DeriveApi, [data, [vesting, allLocks, namedReserves], bestNumber]: Result): DeriveBalancesAll {
|
||||
const shared = calcShared(api, bestNumber, data, allLocks[0]);
|
||||
|
||||
return {
|
||||
...shared,
|
||||
...calcVesting(bestNumber, shared, vesting),
|
||||
return objectSpread(shared, calcVesting(bestNumber, shared, vesting), {
|
||||
accountId: data.accountId,
|
||||
accountNonce: data.accountNonce,
|
||||
additional: allLocks
|
||||
.filter((_, index) => index !== 0)
|
||||
.slice(1)
|
||||
.map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||
namedReserves
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// old
|
||||
|
||||
@@ -7,6 +7,8 @@ import type { DeriveApi, DeriveOwnContributions } from '../types';
|
||||
|
||||
import { combineLatest, EMPTY, map, of, startWith, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { extractContributed } from './util';
|
||||
|
||||
@@ -21,10 +23,8 @@ function _getValues (api: DeriveApi, childKey: string, keys: string[]): Observab
|
||||
? api.registry.createType('Balance', o.unwrap())
|
||||
: api.registry.createType('Balance')
|
||||
)
|
||||
.reduce((all: DeriveOwnContributions, b, index): DeriveOwnContributions => ({
|
||||
...all,
|
||||
[keys[index]]: b
|
||||
}), {})
|
||||
.reduce((all: DeriveOwnContributions, b, index): DeriveOwnContributions =>
|
||||
objectSpread(all, { [keys[index]]: b }), {})
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -51,10 +51,9 @@ function _contributions (api: DeriveApi, paraId: string | number | BN, childKey:
|
||||
_getValues(api, childKey, keys),
|
||||
_watchOwnChanges(api, paraId, childKey, keys)
|
||||
]).pipe(
|
||||
map(([all, latest]) => ({
|
||||
...all,
|
||||
...latest
|
||||
}))
|
||||
map(([all, latest]) =>
|
||||
objectSpread({}, all, latest)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { DeriveApi, DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { Enum } from '@polkadot/types';
|
||||
import { isFunction, stringToHex } from '@polkadot/util';
|
||||
import { isFunction, objectSpread, stringToHex } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -107,7 +107,7 @@ function queryScheduler (api: DeriveApi): Observable<DeriveDispatch[]> {
|
||||
]);
|
||||
}),
|
||||
map(([infos, images]): DeriveDispatch[] =>
|
||||
infos.map((info, index) => ({ ...info, image: images[index] }))
|
||||
infos.map((info, index) => objectSpread({ image: images[index] }, info))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveProposal, DeriveProposalImage } from '../types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -33,17 +33,17 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
|
||||
.map(([index, imageHash, proposer], proposalIndex): DeriveProposal => {
|
||||
const depositors = optDepositors[proposalIndex].unwrap();
|
||||
|
||||
return {
|
||||
...(
|
||||
isNewDepositors(depositors)
|
||||
? { balance: depositors[1], seconds: depositors[0] }
|
||||
: { balance: depositors[0], seconds: depositors[1] }
|
||||
),
|
||||
image: images[proposalIndex],
|
||||
imageHash,
|
||||
index,
|
||||
proposer
|
||||
};
|
||||
return objectSpread(
|
||||
{
|
||||
image: images[proposalIndex],
|
||||
imageHash,
|
||||
index,
|
||||
proposer
|
||||
},
|
||||
isNewDepositors(depositors)
|
||||
? { balance: depositors[1], seconds: depositors[0] }
|
||||
: { balance: depositors[0], seconds: depositors[1] }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,9 +56,11 @@ export function proposals (instanceId: string, api: DeriveApi): () => Observable
|
||||
? combineLatest([
|
||||
of(proposals),
|
||||
api.derive.democracy.preimages(
|
||||
proposals.map(([, hash]) => hash)),
|
||||
proposals.map(([, hash]) => hash)
|
||||
),
|
||||
api.query.democracy.depositOf.multi(
|
||||
proposals.map(([index]) => index))
|
||||
proposals.map(([index]) => index)
|
||||
)
|
||||
])
|
||||
: of<Result>([[], [], []])
|
||||
),
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveReferendumExt } from '../types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function referendums (instanceId: string, api: DeriveApi): () => Observable<DeriveReferendumExt[]> {
|
||||
@@ -20,10 +22,9 @@ export function referendums (instanceId: string, api: DeriveApi): () => Observab
|
||||
: of([[], []])
|
||||
),
|
||||
map(([referendums, votes]) =>
|
||||
referendums.map((referendum, index): DeriveReferendumExt => ({
|
||||
...referendum,
|
||||
...votes[index]
|
||||
}))
|
||||
referendums.map((referendum, index): DeriveReferendumExt =>
|
||||
objectSpread({}, referendum, votes[index])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveReferendum, DeriveReferend
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { calcVotes, getStatus } from './util';
|
||||
@@ -57,11 +57,12 @@ function extractVotes (mapped: [AccountId, PalletDemocracyVoteVoting][], referen
|
||||
// FIXME We are ignoring split votes
|
||||
votes.reduce((result: DeriveReferendumVote[], [, vote]): DeriveReferendumVote[] => {
|
||||
if (vote.isStandard) {
|
||||
result.push({
|
||||
accountId,
|
||||
isDelegating: false,
|
||||
...vote.asStandard
|
||||
});
|
||||
result.push(
|
||||
objectSpread({
|
||||
accountId,
|
||||
isDelegating: false
|
||||
}, vote.asStandard)
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PalletDemocracyReferendumInfo, PalletDemocracyReferendumStatus, Pa
|
||||
import type { Option } from '@polkadot/types-codec';
|
||||
import type { DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
|
||||
|
||||
import { BN, bnSqrt } from '@polkadot/util';
|
||||
import { BN, bnSqrt, objectSpread } from '@polkadot/util';
|
||||
|
||||
interface ApproxState {
|
||||
votedAye: BN;
|
||||
@@ -119,11 +119,10 @@ export function calcVotes (sqrtElectorate: BN, referendum: DeriveReferendum, vot
|
||||
? calcVotesCurrent(referendum.status.tally, votes)
|
||||
: calcVotesPrev(votes);
|
||||
|
||||
return {
|
||||
...state,
|
||||
return objectSpread({}, state, {
|
||||
isPassing: calcPassing(referendum.status.threshold, sqrtElectorate, state),
|
||||
votes
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function getStatus (info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): PalletDemocracyReferendumStatus | ReferendumInfoTo239 | null {
|
||||
|
||||
@@ -11,6 +11,8 @@ import type { DeriveElectionsInfo } from './types';
|
||||
|
||||
import { combineLatest, map, of } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
// SeatHolder is current tuple is 2.x-era Substrate
|
||||
@@ -107,15 +109,16 @@ export function info (instanceId: string, api: DeriveApi): () => Observable<Deri
|
||||
? queryAll(api, council, elections)
|
||||
: queryCouncil(api, council)
|
||||
).pipe(
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||
...getConstants(api, elections),
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates: candidates.map(getCandidate),
|
||||
members: members.length
|
||||
? members.map(getAccountTuple).sort(sortAccounts)
|
||||
: councilMembers.map((a): [AccountId32, Balance] => [a, api.registry.createType('Balance')]),
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts)
|
||||
}))
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo =>
|
||||
objectSpread({}, getConstants(api, elections), {
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates: candidates.map(getCandidate),
|
||||
members: members.length
|
||||
? members.map(getAccountTuple).sort(sortAccounts)
|
||||
: councilMembers.map((a): [AccountId32, Balance] => [a, api.registry.createType('Balance')]),
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts)
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { Active, DidUpdate, Heads, ParaInfoResult, PendingSwap, RelayDispat
|
||||
|
||||
import { map, of } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { didUpdateToBool } from './util';
|
||||
|
||||
@@ -28,20 +30,18 @@ function parseActive (id: ParaId, active: Active): DeriveParachainActive | null
|
||||
if (found && found[1].isSome) {
|
||||
const [collatorId, retriable] = found[1].unwrap();
|
||||
|
||||
return {
|
||||
collatorId,
|
||||
...(
|
||||
retriable.isWithRetries
|
||||
? {
|
||||
isRetriable: true,
|
||||
retries: retriable.asWithRetries.toNumber()
|
||||
}
|
||||
: {
|
||||
isRetriable: false,
|
||||
retries: 0
|
||||
}
|
||||
)
|
||||
};
|
||||
return objectSpread<DeriveParachainActive>(
|
||||
{ collatorId },
|
||||
retriable.isWithRetries
|
||||
? {
|
||||
isRetriable: true,
|
||||
retries: retriable.asWithRetries.toNumber()
|
||||
}
|
||||
: {
|
||||
isRetriable: false,
|
||||
retries: 0
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -65,7 +65,7 @@ function parse (id: ParaId, [active, retryQueue, selectedThreads, didUpdate, inf
|
||||
didUpdate: didUpdateToBool(didUpdate, id),
|
||||
heads,
|
||||
id,
|
||||
info: { id, ...info.unwrap() } as DeriveParachainInfo,
|
||||
info: objectSpread<DeriveParachainInfo>({ id }, info.unwrap()),
|
||||
pendingSwapId: pendingSwap.unwrapOr(null),
|
||||
relayDispatchQueue,
|
||||
retryCollators: parseCollators(id, retryQueue),
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { DidUpdate, ParaInfoResult, PendingSwap, RelayDispatchQueueSize } f
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { didUpdateToBool } from './util';
|
||||
|
||||
@@ -23,7 +25,7 @@ function parse ([ids, didUpdate, infos, pendingSwaps, relayDispatchQueueSizes]:
|
||||
return ids.map((id, index): DeriveParachain => ({
|
||||
didUpdate: didUpdateToBool(didUpdate, id),
|
||||
id,
|
||||
info: { id, ...infos[index].unwrapOr(null) } as DeriveParachainInfo,
|
||||
info: objectSpread<DeriveParachainInfo>({ id }, infos[index].unwrapOr(null)),
|
||||
pendingSwapId: pendingSwaps[index].unwrapOr(null),
|
||||
relayDispatchQueueSize: relayDispatchQueueSizes[index][0].toNumber()
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveSessionInfo } from '../types';
|
||||
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -18,13 +20,12 @@ export function info (instanceId: string, api: DeriveApi): () => Observable<Deri
|
||||
const sessionLength = api.consts?.babe?.epochDuration || api.registry.createType('u64', 1);
|
||||
const sessionsPerEra = api.consts?.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1);
|
||||
|
||||
return {
|
||||
...indexes,
|
||||
return objectSpread({
|
||||
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(sessionLength)),
|
||||
isEpoch: !!api.query.babe,
|
||||
sessionLength,
|
||||
sessionsPerEra
|
||||
};
|
||||
}, indexes);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { DeriveApi, DeriveSessionInfo, DeriveSessionProgress } from '../typ
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultSlotsNoSession = [u64, u64, u64];
|
||||
@@ -28,20 +30,20 @@ function createDerive (api: DeriveApi, info: DeriveSessionInfo, [currentSlot, ep
|
||||
const sessionProgress = currentSlot.sub(epochStartSlot);
|
||||
const eraProgress = info.currentIndex.sub(activeEraStartSessionIndex).imul(info.sessionLength).iadd(sessionProgress);
|
||||
|
||||
return {
|
||||
...info,
|
||||
return objectSpread({
|
||||
eraProgress: api.registry.createType('BlockNumber', eraProgress),
|
||||
sessionProgress: api.registry.createType('BlockNumber', sessionProgress)
|
||||
};
|
||||
}, info);
|
||||
}
|
||||
|
||||
function queryAura (api: DeriveApi): Observable<DeriveSessionProgress> {
|
||||
return api.derive.session.info().pipe(
|
||||
map((info): DeriveSessionProgress => ({
|
||||
...info,
|
||||
eraProgress: api.registry.createType('BlockNumber'),
|
||||
sessionProgress: api.registry.createType('BlockNumber')
|
||||
}))
|
||||
map((info): DeriveSessionProgress =>
|
||||
objectSpread({
|
||||
eraProgress: api.registry.createType('BlockNumber'),
|
||||
sessionProgress: api.registry.createType('BlockNumber')
|
||||
}, info)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { StakingQueryFlags } from './types';
|
||||
|
||||
import { combineLatest, map, switchMap } from 'rxjs';
|
||||
|
||||
import { BN, BN_ZERO } from '@polkadot/util';
|
||||
import { BN, BN_ZERO, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { firstMemo, memo } from '../util';
|
||||
|
||||
@@ -54,12 +54,10 @@ function redeemableSum (api: DeriveApi, stakingLedger: PalletStakingStakingLedge
|
||||
}
|
||||
|
||||
function parseResult (api: DeriveApi, sessionInfo: DeriveSessionInfo, keys: DeriveStakingKeys, query: DeriveStakingQuery): DeriveStakingAccount {
|
||||
return {
|
||||
...keys,
|
||||
...query,
|
||||
return objectSpread({}, keys, query, {
|
||||
redeemable: redeemableSum(api, query.stakingLedger, sessionInfo),
|
||||
unlocking: calculateUnlocking(api, query.stakingLedger, sessionInfo)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveStakingOverview } from '../types';
|
||||
|
||||
import { combineLatest, map } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -17,10 +19,11 @@ export function overview (instanceId: string, api: DeriveApi): () => Observable<
|
||||
api.derive.session.indexes(),
|
||||
api.derive.staking.validators()
|
||||
]).pipe(
|
||||
map(([indexes, { nextElected, validators }]): DeriveStakingOverview => ({
|
||||
...indexes,
|
||||
nextElected,
|
||||
validators
|
||||
}))
|
||||
map(([indexes, { nextElected, validators }]): DeriveStakingOverview =>
|
||||
objectSpread({}, indexes, {
|
||||
nextElected,
|
||||
validators
|
||||
})
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { DeriveStakingQuery } from './types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||
import { BN_BILLION, BN_ZERO, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { firstMemo, memo } from '../util';
|
||||
|
||||
@@ -125,10 +125,11 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}));
|
||||
.map((reward) =>
|
||||
objectSpread({}, reward, {
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function _stakerRewardsEras (instanceId: string, api: DeriveApi): (eras: EraIndex[], withActive?: boolean) => Observable<ErasResult> {
|
||||
|
||||
Reference in New Issue
Block a user