Adjust derive.staking.query (no opt) (#2588)
* Adjust derive.staking.query (no opt) * Rewrite
This commit is contained in:
@@ -17,27 +17,24 @@ import { memo } from '../util';
|
||||
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure];
|
||||
|
||||
function parseController (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]: MultiResult, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
|
||||
const controllerId = controllerIdOpt.unwrapOr(null);
|
||||
const nominators = nominatorsOpt.unwrapOr(null);
|
||||
|
||||
return controllerId && stakingLedgerOpt.isSome
|
||||
? {
|
||||
accountId: stashId,
|
||||
controllerId,
|
||||
exposure,
|
||||
nominators: nominators
|
||||
? Array.isArray(nominators)
|
||||
? nominators[0].targets
|
||||
: nominators.targets
|
||||
: [],
|
||||
rewardDestination,
|
||||
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
|
||||
stashId,
|
||||
validatorPrefs: Array.isArray(validatorPrefs)
|
||||
? validatorPrefs[0]
|
||||
: validatorPrefs
|
||||
}
|
||||
: { accountId: stashId };
|
||||
return {
|
||||
accountId: stashId,
|
||||
controllerId: controllerIdOpt.unwrapOr(null),
|
||||
exposure,
|
||||
nominators: nominators
|
||||
? Array.isArray(nominators)
|
||||
? nominators[0].targets
|
||||
: nominators.targets
|
||||
: [],
|
||||
rewardDestination,
|
||||
stakingLedger: stakingLedgerOpt.unwrapOrDefault(),
|
||||
stashId,
|
||||
validatorPrefs: Array.isArray(validatorPrefs)
|
||||
? validatorPrefs[0]
|
||||
: validatorPrefs
|
||||
};
|
||||
}
|
||||
|
||||
function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable<MultiResult> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import { AccountId, Balance, EraIndex, Exposure, Keys, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { DeriveSessionIndexes } from '../session/types';
|
||||
|
||||
export type DeriveEraValPoints = Record<string, RewardPoint>;
|
||||
@@ -102,19 +102,17 @@ export interface DeriveStakingValidators {
|
||||
}
|
||||
|
||||
export interface DeriveStakingStash {
|
||||
controllerId?: AccountId;
|
||||
exposure?: Exposure;
|
||||
nominators?: AccountId[];
|
||||
nominateAt?: EraIndex;
|
||||
rewardDestination?: RewardDestination;
|
||||
nextKeys?: Keys;
|
||||
stashId?: AccountId;
|
||||
validatorPrefs?: ValidatorPrefs;
|
||||
controllerId: AccountId | null;
|
||||
exposure: Exposure;
|
||||
nominators: AccountId[];
|
||||
rewardDestination: RewardDestination;
|
||||
stashId: AccountId;
|
||||
validatorPrefs: ValidatorPrefs;
|
||||
}
|
||||
|
||||
export interface DeriveStakingQuery extends DeriveStakingStash {
|
||||
accountId: AccountId;
|
||||
stakingLedger?: StakingLedger;
|
||||
stakingLedger: StakingLedger;
|
||||
}
|
||||
|
||||
export interface DeriveStakingElected {
|
||||
|
||||
Reference in New Issue
Block a user