Skip to content

Commit 395dc79

Browse files
authored
Adjust derive.staking.query (no opt) (#2588)
* Adjust derive.staking.query (no opt) * Rewrite
1 parent a968fe0 commit 395dc79

File tree

4 files changed

+49
-54
lines changed

4 files changed

+49
-54
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"@babel/core": "^7.11.6",
2929
"@babel/register": "^7.11.5",
3030
"@babel/runtime": "^7.11.2",
31-
"@polkadot/dev": "^0.55.46",
32-
"@polkadot/ts": "^0.3.42",
31+
"@polkadot/dev": "^0.55.47",
32+
"@polkadot/ts": "^0.3.43",
3333
"@polkadot/typegen": "workspace:packages/typegen",
3434
"@types/jest": "^26.0.13",
3535
"@vuepress/plugin-search": "^1.5.4",

packages/api-derive/src/staking/query.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,24 @@ import { memo } from '../util';
1717
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure];
1818

1919
function parseController (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]: MultiResult, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
20-
const controllerId = controllerIdOpt.unwrapOr(null);
2120
const nominators = nominatorsOpt.unwrapOr(null);
2221

23-
return controllerId && stakingLedgerOpt.isSome
24-
? {
25-
accountId: stashId,
26-
controllerId,
27-
exposure,
28-
nominators: nominators
29-
? Array.isArray(nominators)
30-
? nominators[0].targets
31-
: nominators.targets
32-
: [],
33-
rewardDestination,
34-
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
35-
stashId,
36-
validatorPrefs: Array.isArray(validatorPrefs)
37-
? validatorPrefs[0]
38-
: validatorPrefs
39-
}
40-
: { accountId: stashId };
22+
return {
23+
accountId: stashId,
24+
controllerId: controllerIdOpt.unwrapOr(null),
25+
exposure,
26+
nominators: nominators
27+
? Array.isArray(nominators)
28+
? nominators[0].targets
29+
: nominators.targets
30+
: [],
31+
rewardDestination,
32+
stakingLedger: stakingLedgerOpt.unwrapOrDefault(),
33+
stashId,
34+
validatorPrefs: Array.isArray(validatorPrefs)
35+
? validatorPrefs[0]
36+
: validatorPrefs
37+
};
4138
}
4239

4340
function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable<MultiResult> {

packages/api-derive/src/staking/types.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// of the Apache-2.0 license. See the LICENSE file for details.
44

55
import type BN from 'bn.js';
6-
import { AccountId, Balance, EraIndex, Exposure, Keys, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
6+
import { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
77
import { DeriveSessionIndexes } from '../session/types';
88

99
export type DeriveEraValPoints = Record<string, RewardPoint>;
@@ -102,19 +102,17 @@ export interface DeriveStakingValidators {
102102
}
103103

104104
export interface DeriveStakingStash {
105-
controllerId?: AccountId;
106-
exposure?: Exposure;
107-
nominators?: AccountId[];
108-
nominateAt?: EraIndex;
109-
rewardDestination?: RewardDestination;
110-
nextKeys?: Keys;
111-
stashId?: AccountId;
112-
validatorPrefs?: ValidatorPrefs;
105+
controllerId: AccountId | null;
106+
exposure: Exposure;
107+
nominators: AccountId[];
108+
rewardDestination: RewardDestination;
109+
stashId: AccountId;
110+
validatorPrefs: ValidatorPrefs;
113111
}
114112

115113
export interface DeriveStakingQuery extends DeriveStakingStash {
116114
accountId: AccountId;
117-
stakingLedger?: StakingLedger;
115+
stakingLedger: StakingLedger;
118116
}
119117

120118
export interface DeriveStakingElected {

yarn.lock

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,9 +2826,9 @@ __metadata:
28262826
languageName: unknown
28272827
linkType: soft
28282828

2829-
"@polkadot/dev@npm:^0.55.46":
2830-
version: 0.55.46
2831-
resolution: "@polkadot/dev@npm:0.55.46"
2829+
"@polkadot/dev@npm:^0.55.47":
2830+
version: 0.55.47
2831+
resolution: "@polkadot/dev@npm:0.55.47"
28322832
dependencies:
28332833
"@babel/cli": ^7.11.6
28342834
"@babel/core": ^7.11.6
@@ -2858,7 +2858,7 @@ __metadata:
28582858
babel-jest: ^26.3.0
28592859
babel-plugin-module-resolver: ^4.0.0
28602860
babel-plugin-styled-components: ^1.11.1
2861-
browserslist: ^4.14.0
2861+
browserslist: ^4.14.1
28622862
chalk: ^4.1.0
28632863
coveralls: ^3.1.0
28642864
cpx: ^1.5.0
@@ -2886,7 +2886,7 @@ __metadata:
28862886
mkdirp: ^1.0.4
28872887
prettier: ^2.1.1
28882888
rimraf: ^3.0.2
2889-
typedoc: ^0.19.0
2889+
typedoc: ^0.19.1
28902890
typedoc-plugin-markdown: ^2.4.2
28912891
typedoc-plugin-no-inherit: ^1.1.10
28922892
typescript: ^4.0.2
@@ -2916,7 +2916,7 @@ __metadata:
29162916
polkadot-exec-typedoc: scripts/polkadot-exec-typedoc.js
29172917
polkadot-exec-vuepress: scripts/polkadot-exec-vuepress.js
29182918
polkadot-exec-webpack: scripts/polkadot-exec-webpack.js
2919-
checksum: 6710f1b534f7ad1a7e0d7faa015bf078db7c901ee6082be0d29fb213884fe9ffe7709b873b2c6bebec9f0f1a1c14a571e8e86915efab8466eda152d548d4cf64
2919+
checksum: 4d0d5f9cc41aaf43d2f541a45313111bd7fce8203dfb648305e71b5b1d7d8c8e02eaa08aedd91692b7e3e78cba3eaaca3f1270086132ac01a86c004ac7d7e752
29202920
languageName: node
29212921
linkType: hard
29222922

@@ -2979,12 +2979,12 @@ __metadata:
29792979
languageName: unknown
29802980
linkType: soft
29812981

2982-
"@polkadot/ts@npm:^0.3.42":
2983-
version: 0.3.42
2984-
resolution: "@polkadot/ts@npm:0.3.42"
2982+
"@polkadot/ts@npm:^0.3.43":
2983+
version: 0.3.43
2984+
resolution: "@polkadot/ts@npm:0.3.43"
29852985
dependencies:
29862986
"@types/chrome": ^0.0.122
2987-
checksum: ac08d6783ddbc54594e179c2056ebf6539ed97181650ec95b83da0aaeb019362930794aa4728a2a6aca0ba09470848d2bc0024977b696479e76881e4f88dcd0c
2987+
checksum: 5f286d9e290833abbe791da560d6dc9afbf43deb2042e93507a52aa4dcea7985a0fc132462a9194cfc1ebce026c5a0a561155a969655cd89a6dc2fbf21327373
29882988
languageName: node
29892989
linkType: hard
29902990

@@ -5210,7 +5210,7 @@ __metadata:
52105210
languageName: node
52115211
linkType: hard
52125212

5213-
"browserslist@npm:^4.0.0, browserslist@npm:^4.12.0, browserslist@npm:^4.14.0, browserslist@npm:^4.8.5":
5213+
"browserslist@npm:^4.0.0, browserslist@npm:^4.12.0, browserslist@npm:^4.14.1, browserslist@npm:^4.8.5":
52145214
version: 4.14.1
52155215
resolution: "browserslist@npm:4.14.1"
52165216
dependencies:
@@ -7536,11 +7536,11 @@ __metadata:
75367536
linkType: hard
75377537

75387538
"dot-prop@npm:^5.1.0, dot-prop@npm:^5.2.0":
7539-
version: 5.2.0
7540-
resolution: "dot-prop@npm:5.2.0"
7539+
version: 5.3.0
7540+
resolution: "dot-prop@npm:5.3.0"
75417541
dependencies:
75427542
is-obj: ^2.0.0
7543-
checksum: d2f62e0b5ec467edb8e278ab6070955f0a4aec973ec1fa837ff6152f3cdd96cd2a04c7e2626cb3eac4f639b8f6786b5b87d3c01df7ba729693c636cb78b7ae93
7543+
checksum: 76e6693d8803eeff9cb920988446bf223cf1f6e5b1c0c2fe07a66906392134931a481b11e3c0bd852c5cfc97fad65258bcb4359169ad1d8d624cb3f56932be98
75447544
languageName: node
75457545
linkType: hard
75467546

@@ -13402,9 +13402,9 @@ __metadata:
1340213402
linkType: hard
1340313403

1340413404
"node-fetch@npm:^2.3.0, node-fetch@npm:^2.5.0":
13405-
version: 2.6.0
13406-
resolution: "node-fetch@npm:2.6.0"
13407-
checksum: dd9f586a9f7ddb7dd94d2aba9cb693d32f5001e9850098512fbc8a4cbdd56838afa08ed0a6725b9fce9b01ec12b713e622cbfc16d92762d8b937b238330a632a
13405+
version: 2.6.1
13406+
resolution: "node-fetch@npm:2.6.1"
13407+
checksum: cbb171635e538162b977eac5dfe7a1e07a9a02e991924377a6435502291e2f823d306b95aabc455caebf4a118ccf836868462bc70ccc3095af02bb9da61fda37
1340813408
languageName: node
1340913409
linkType: hard
1341013410

@@ -16379,8 +16379,8 @@ __metadata:
1637916379
"@babel/core": ^7.11.6
1638016380
"@babel/register": ^7.11.5
1638116381
"@babel/runtime": ^7.11.2
16382-
"@polkadot/dev": ^0.55.46
16383-
"@polkadot/ts": ^0.3.42
16382+
"@polkadot/dev": ^0.55.47
16383+
"@polkadot/ts": ^0.3.43
1638416384
"@polkadot/typegen": "workspace:packages/typegen"
1638516385
"@types/jest": ^26.0.13
1638616386
"@vuepress/plugin-search": ^1.5.4
@@ -16422,11 +16422,11 @@ __metadata:
1642216422
linkType: hard
1642316423

1642416424
"rxjs@npm:^6.4.0, rxjs@npm:^6.6.2":
16425-
version: 6.6.2
16426-
resolution: "rxjs@npm:6.6.2"
16425+
version: 6.6.3
16426+
resolution: "rxjs@npm:6.6.3"
1642716427
dependencies:
1642816428
tslib: ^1.9.0
16429-
checksum: 9b16cd36093b87ce454726f14783e204b80431e6657d36191877e4d9d4b0713c73e5ee8b45be336b081d47b10cd016b3812ea3bd4b27bf87942b1410aa18ee04
16429+
checksum: 61a3da6db947f69b7d805df3a619d8f60678b7372c4d571dd63e45ef3532be984a88307ea0aa2cd8d2578b62c3c022186e8da9dca47c9c1b8c9ecba6f5581deb
1643016430
languageName: node
1643116431
linkType: hard
1643216432

@@ -18365,7 +18365,7 @@ __metadata:
1836518365
languageName: node
1836618366
linkType: hard
1836718367

18368-
"typedoc@npm:^0.19.0, typedoc@npm:^0.19.1":
18368+
"typedoc@npm:^0.19.1":
1836918369
version: 0.19.1
1837018370
resolution: "typedoc@npm:0.19.1"
1837118371
dependencies:

0 commit comments

Comments
 (0)