Skip to content

Commit

Permalink
Don't return delegations with dust amounts (#171)
Browse files Browse the repository at this point in the history
* Add filter to delegations

* Fix filter

* Simplify
  • Loading branch information
mariopino authored and faboweb committed Dec 6, 2019
1 parent 2733b2f commit c140cf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/cosmosV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class CosmosV0API extends PerBlockCacheDataSource {
const involvedAddresses = transaction.tags.reduce((addresses, tag) => {
// temporary in here to identify why this fails
if (!tag.value) {
console.log(JSON.stringify(transaction))
return addresses
}
if (tag.value.startsWith(`cosmos`)) {
Expand Down Expand Up @@ -278,12 +277,21 @@ class CosmosV0API extends PerBlockCacheDataSource {
let delegations =
(await this.query(`staking/delegators/${address}/delegations`)) || []

return delegations.map(delegation =>
this.reducers.delegationReducer(
delegation,
validatorsDictionary[delegation.validator_address]
return delegations
.filter(delegation =>
BigNumber(
this.reducers.calculateTokens(
validatorsDictionary[delegation.validator_address],
delegation.shares
)
).isGreaterThanOrEqualTo(1e-6)
)
.map(delegation =>
this.reducers.delegationReducer(
delegation,
validatorsDictionary[delegation.validator_address]
)
)
)
}

async getUndelegationsForDelegatorAddress(address, validatorsDictionary) {
Expand Down
1 change: 1 addition & 0 deletions lib/reducers/cosmosV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ module.exports = {
rewardReducer,
overviewReducer,
accountInfoReducer,
calculateTokens,
undelegationEndTimeReducer,

atoms,
Expand Down

0 comments on commit c140cf0

Please sign in to comment.