Skip to content

Commit

Permalink
Add self stake to validators query (#433)
Browse files Browse the repository at this point in the history
* add self stake

* Update lib/reducers/polkadotV0-reducers.js

Co-Authored-By: Ana G. <40721795+Bitcoinera@users.noreply.github.com>

* lint

Co-authored-by: Ana G. <40721795+Bitcoinera@users.noreply.github.com>
Co-authored-by: Bitcoinera <anagjordano@gmail.com>
  • Loading branch information
3 people authored Mar 10, 2020
1 parent f7dae99 commit cd06c1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/reducers/polkadotV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function validatorReducer(network, validator) {
maxChangeCommission: undefined,
status: `ACTIVE`, // We are fetching current session active validators only (not intentions)
statusDetailed: ``, // TODO: Include validator heartbeat messages
delegatorShares: undefined
delegatorShares: undefined,
selfStake:
(
BigNumber(validator.exposure.own).toNumber() / POLKADOT_CONVERSION
).toFixed(9) || 0
}
}

Expand Down
6 changes: 4 additions & 2 deletions lib/source/polkadotV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class polkadotAPI {
)
validatorIdentity = JSON.parse(JSON.stringify(validatorIdentity))

// Add identity, voting power and tokens
// TODO: also include self stake
validators.forEach(validator => {
const identity = validatorIdentity.find(
validatorIdentity => validatorIdentity.accountId === validator.accountId
Expand All @@ -166,6 +164,10 @@ class polkadotAPI {
return 0
}

async getSelfStake(validator) {
return validator.selfStake
}

async getBalancesFromAddress(address) {
const api = await this.getAPI()
// the documentation points at api.query.system.account as the preferred query. Looking into it
Expand Down

0 comments on commit cd06c1c

Please sign in to comment.