Adjust derive.staking.query (no opt) (#2588)

* Adjust derive.staking.query (no opt)

* Rewrite
This commit is contained in:
Jaco Greeff
2020-09-06 18:06:37 +02:00
committed by GitHub
parent a968fe05b5
commit 395dc79ef7
4 changed files with 49 additions and 54 deletions
+2 -2
View File
@@ -28,8 +28,8 @@
"@babel/core": "^7.11.6",
"@babel/register": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@polkadot/dev": "^0.55.46",
"@polkadot/ts": "^0.3.42",
"@polkadot/dev": "^0.55.47",
"@polkadot/ts": "^0.3.43",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.13",
"@vuepress/plugin-search": "^1.5.4",
+16 -19
View File
@@ -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> {
+8 -10
View File
@@ -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 {
+23 -23
View File
@@ -2826,9 +2826,9 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/dev@npm:^0.55.46":
version: 0.55.46
resolution: "@polkadot/dev@npm:0.55.46"
"@polkadot/dev@npm:^0.55.47":
version: 0.55.47
resolution: "@polkadot/dev@npm:0.55.47"
dependencies:
"@babel/cli": ^7.11.6
"@babel/core": ^7.11.6
@@ -2858,7 +2858,7 @@ __metadata:
babel-jest: ^26.3.0
babel-plugin-module-resolver: ^4.0.0
babel-plugin-styled-components: ^1.11.1
browserslist: ^4.14.0
browserslist: ^4.14.1
chalk: ^4.1.0
coveralls: ^3.1.0
cpx: ^1.5.0
@@ -2886,7 +2886,7 @@ __metadata:
mkdirp: ^1.0.4
prettier: ^2.1.1
rimraf: ^3.0.2
typedoc: ^0.19.0
typedoc: ^0.19.1
typedoc-plugin-markdown: ^2.4.2
typedoc-plugin-no-inherit: ^1.1.10
typescript: ^4.0.2
@@ -2916,7 +2916,7 @@ __metadata:
polkadot-exec-typedoc: scripts/polkadot-exec-typedoc.js
polkadot-exec-vuepress: scripts/polkadot-exec-vuepress.js
polkadot-exec-webpack: scripts/polkadot-exec-webpack.js
checksum: 6710f1b534f7ad1a7e0d7faa015bf078db7c901ee6082be0d29fb213884fe9ffe7709b873b2c6bebec9f0f1a1c14a571e8e86915efab8466eda152d548d4cf64
checksum: 4d0d5f9cc41aaf43d2f541a45313111bd7fce8203dfb648305e71b5b1d7d8c8e02eaa08aedd91692b7e3e78cba3eaaca3f1270086132ac01a86c004ac7d7e752
languageName: node
linkType: hard
@@ -2979,12 +2979,12 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/ts@npm:^0.3.42":
version: 0.3.42
resolution: "@polkadot/ts@npm:0.3.42"
"@polkadot/ts@npm:^0.3.43":
version: 0.3.43
resolution: "@polkadot/ts@npm:0.3.43"
dependencies:
"@types/chrome": ^0.0.122
checksum: ac08d6783ddbc54594e179c2056ebf6539ed97181650ec95b83da0aaeb019362930794aa4728a2a6aca0ba09470848d2bc0024977b696479e76881e4f88dcd0c
checksum: 5f286d9e290833abbe791da560d6dc9afbf43deb2042e93507a52aa4dcea7985a0fc132462a9194cfc1ebce026c5a0a561155a969655cd89a6dc2fbf21327373
languageName: node
linkType: hard
@@ -5210,7 +5210,7 @@ __metadata:
languageName: node
linkType: hard
"browserslist@npm:^4.0.0, browserslist@npm:^4.12.0, browserslist@npm:^4.14.0, browserslist@npm:^4.8.5":
"browserslist@npm:^4.0.0, browserslist@npm:^4.12.0, browserslist@npm:^4.14.1, browserslist@npm:^4.8.5":
version: 4.14.1
resolution: "browserslist@npm:4.14.1"
dependencies:
@@ -7536,11 +7536,11 @@ __metadata:
linkType: hard
"dot-prop@npm:^5.1.0, dot-prop@npm:^5.2.0":
version: 5.2.0
resolution: "dot-prop@npm:5.2.0"
version: 5.3.0
resolution: "dot-prop@npm:5.3.0"
dependencies:
is-obj: ^2.0.0
checksum: d2f62e0b5ec467edb8e278ab6070955f0a4aec973ec1fa837ff6152f3cdd96cd2a04c7e2626cb3eac4f639b8f6786b5b87d3c01df7ba729693c636cb78b7ae93
checksum: 76e6693d8803eeff9cb920988446bf223cf1f6e5b1c0c2fe07a66906392134931a481b11e3c0bd852c5cfc97fad65258bcb4359169ad1d8d624cb3f56932be98
languageName: node
linkType: hard
@@ -13402,9 +13402,9 @@ __metadata:
linkType: hard
"node-fetch@npm:^2.3.0, node-fetch@npm:^2.5.0":
version: 2.6.0
resolution: "node-fetch@npm:2.6.0"
checksum: dd9f586a9f7ddb7dd94d2aba9cb693d32f5001e9850098512fbc8a4cbdd56838afa08ed0a6725b9fce9b01ec12b713e622cbfc16d92762d8b937b238330a632a
version: 2.6.1
resolution: "node-fetch@npm:2.6.1"
checksum: cbb171635e538162b977eac5dfe7a1e07a9a02e991924377a6435502291e2f823d306b95aabc455caebf4a118ccf836868462bc70ccc3095af02bb9da61fda37
languageName: node
linkType: hard
@@ -16379,8 +16379,8 @@ __metadata:
"@babel/core": ^7.11.6
"@babel/register": ^7.11.5
"@babel/runtime": ^7.11.2
"@polkadot/dev": ^0.55.46
"@polkadot/ts": ^0.3.42
"@polkadot/dev": ^0.55.47
"@polkadot/ts": ^0.3.43
"@polkadot/typegen": "workspace:packages/typegen"
"@types/jest": ^26.0.13
"@vuepress/plugin-search": ^1.5.4
@@ -16422,11 +16422,11 @@ __metadata:
linkType: hard
"rxjs@npm:^6.4.0, rxjs@npm:^6.6.2":
version: 6.6.2
resolution: "rxjs@npm:6.6.2"
version: 6.6.3
resolution: "rxjs@npm:6.6.3"
dependencies:
tslib: ^1.9.0
checksum: 9b16cd36093b87ce454726f14783e204b80431e6657d36191877e4d9d4b0713c73e5ee8b45be336b081d47b10cd016b3812ea3bd4b27bf87942b1410aa18ee04
checksum: 61a3da6db947f69b7d805df3a619d8f60678b7372c4d571dd63e45ef3532be984a88307ea0aa2cd8d2578b62c3c022186e8da9dca47c9c1b8c9ecba6f5581deb
languageName: node
linkType: hard
@@ -18365,7 +18365,7 @@ __metadata:
languageName: node
linkType: hard
"typedoc@npm:^0.19.0, typedoc@npm:^0.19.1":
"typedoc@npm:^0.19.1":
version: 0.19.1
resolution: "typedoc@npm:0.19.1"
dependencies: