-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ana/111 regen testnet production (#118)
* regen is home * fix websocket link * eslint fix * delete console logs * fixed regen source (using cosmosV0) * add feature flags for regen * fix txs in regen * fix transactions per address * fix eslint errors
- Loading branch information
1 parent
30bb928
commit 5e0dcf3
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const cosmosV0Reducers = require('./cosmosV0-reducers') | ||
|
||
module.exports = { | ||
...cosmosV0Reducers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const CosmosV0API = require('./cosmosV0-source') | ||
const { transactionReducer } = require('./reducers/cosmosV0-reducers') | ||
const { uniqWith, sortBy, reverse } = require('lodash') | ||
|
||
class RegenV0API extends CosmosV0API { | ||
constructor(network) { | ||
super(network) | ||
|
||
this.delegatorBech32Prefix = `xrn:` | ||
this.validatorConsensusBech32Prefix = `xrn:valcons` | ||
} | ||
setReducers() { | ||
this.reducers = require('./reducers/regenV0-reducers') | ||
} | ||
|
||
async getTransactionsByHeight(height) { | ||
const { txs } = await this.get(`txs?tx.height=${height}`) | ||
return Array.isArray(txs) | ||
? txs.map(transaction => this.reducers.transactionReducer(transaction)) | ||
: [] | ||
} | ||
|
||
async getTransactions(address) { | ||
const pagination = `&limit=${1000000000}` | ||
|
||
const txs = await Promise.all([ | ||
this.get(`/txs?sender=${address}${pagination}`).then(({ txs }) => txs), | ||
this.get(`/txs?recipient=${address}${pagination}`).then(({ txs }) => txs) | ||
]).then(([senderTxs, recipientTxs]) => [].concat(senderTxs, recipientTxs)) | ||
|
||
const dupFreeTxs = uniqWith(txs, (a, b) => a.txhash === b.txhash) | ||
const sortedTxs = sortBy(dupFreeTxs, ['timestamp']) | ||
const reversedTxs = reverse(sortedTxs) | ||
return reversedTxs.map(transactionReducer) | ||
} | ||
} | ||
|
||
module.exports = RegenV0API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters