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:
@@ -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