Skip to content

Commit

Permalink
filter out validator specific txs (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitcoinera authored and jbibla committed Jan 24, 2020
1 parent f9b96a2 commit 5ce9a91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/source/cosmosV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,12 @@ class CosmosV0API extends RESTDataSource {
this.loadPaginatedTxs(`/txs?action=submit_proposal&proposer=${address}`),
this.loadPaginatedTxs(`/txs?action=deposit&depositor=${address}`),
this.loadPaginatedTxs(`/txs?action=vote&voter=${address}`),
// this.get(`/txs?action=create_validator&destination-validator=${valAddress}`), // TODO
// this.get(`/txs?action=edit_validator&destination-validator=${valAddress}`), // TODO
this.loadPaginatedTxs(`/txs?action=delegate&delegator=${address}`),
this.loadPaginatedTxs(
`/txs?action=begin_redelegate&delegator=${address}`
),
this.loadPaginatedTxs(`/txs?action=begin_unbonding&delegator=${address}`),
// this.get(`/txs?action=unjail&source-validator=${address}`), // TODO
// this.get(`/txs?action=set_withdraw_address&delegator=${address}`), // other

this.loadPaginatedTxs(
`/txs?action=withdraw_delegator_reward&delegator=${address}`
),
Expand Down
11 changes: 10 additions & 1 deletion lib/source/cosmosV2-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ class CosmosV2API extends CosmosV0API {
const dupFreeTxs = uniqWith(txs, (a, b) => a.txhash === b.txhash)
const sortedTxs = sortBy(dupFreeTxs, ['timestamp'])
const reversedTxs = reverse(sortedTxs)
return reversedTxs.map(tx =>
// here we filter out all transactions related to validators
const filteredTxs = reversedTxs.filter(
tx =>
tx.tx.value.msg[0].type !==
`cosmos-sdk/MsgWithdrawValidatorCommission` &&
tx.tx.value.msg[0].type !== `cosmos-sdk/MsgSetWithdrawAddress` &&
tx.tx.value.msg[0].type !== `cosmos-sdk/MsgEditValidator` &&
tx.tx.value.msg[0].type !== `cosmos-sdk/MsgUnjail`
)
return filteredTxs.map(tx =>
this.reducers.transactionReducer(tx, this.reducers)
)
}
Expand Down

0 comments on commit 5ce9a91

Please sign in to comment.