Skip to content

Commit

Permalink
Merge pull request #47 from eco-stake/fix-delegation-data-without-price
Browse files Browse the repository at this point in the history
Ensure full delegations data is returned
  • Loading branch information
tombeynon authored Oct 7, 2022
2 parents 198c796 + d76eefd commit bbe7a27
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions validators/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ export class Validator {

const asset = this.chain.baseAsset
const price = asset?.prices?.coingecko
if(!price) return delegations

const total_tokens = delegations.total_tokens
if(!total_tokens) return delegations

const total_tokens_display = divide(total_tokens, pow(10, this.chain.decimals))
const total_usd = price.usd && multiply(total_tokens_display, price.usd)
const total_usd = price?.usd && multiply(total_tokens_display, price.usd)
return {
...this.data.delegations,
...delegations,
total_tokens_display,
total_usd
}
Expand Down

0 comments on commit bbe7a27

Please sign in to comment.