-
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.
* first steps * Integrate validators feature for akashv0 * Simplify extending Cosmos logic * Remove unused imports * Uncomment networks * Enable portfolio for Akash * Commnet livepeer mainnet network * Commnet livepeer mainnet network * fix validators expected returns * apply code review * use proper reducers * add gas prices * fix totalstake and delegation in general * fix api_url * correct staking denom to cosmossdk default for now * add also default stake gas price Co-authored-by: Bitcoinera <[email protected]>
- Loading branch information
1 parent
f0c7924
commit 79070b5
Showing
5 changed files
with
122 additions
and
2 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,29 @@ | ||
const terraV3Reducers = require('./terraV3-reducers') | ||
|
||
function blockReducer(networkId, block, transactions) { | ||
return { | ||
networkId, | ||
height: block.block.header.height, | ||
chainId: block.block.header.chain_id, | ||
hash: block.block_id.hash, | ||
time: block.block.header.time, | ||
transactions, | ||
proposer_address: block.block.header.proposer_address | ||
} | ||
} | ||
|
||
function delegationReducer(delegation, validator) { | ||
const delegationCoin = terraV3Reducers.coinReducer(delegation.balance) | ||
return { | ||
validatorAddress: delegation.validator_address, | ||
delegatorAddress: delegation.delegator_address, | ||
validator, | ||
amount: delegationCoin.amount | ||
} | ||
} | ||
|
||
module.exports = { | ||
...terraV3Reducers, | ||
blockReducer, | ||
delegationReducer | ||
} |
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,48 @@ | ||
const TerraV3API = require('./terraV3-source') | ||
const CosmosV0API = require('./cosmosV0-source') | ||
|
||
const gasPrices = [ | ||
{ | ||
denom: 'stake', | ||
price: '0.01' | ||
}, | ||
{ | ||
denom: 'akash', | ||
price: '0.01' | ||
} | ||
] | ||
|
||
class AkashV0API extends TerraV3API { | ||
setReducers() { | ||
this.reducers = require('../reducers/akashV0-reducers') | ||
this.gasPrices = gasPrices | ||
} | ||
|
||
async getBlockByHeightV2(blockHeight) { | ||
let block, transactions | ||
if (blockHeight) { | ||
const response = await Promise.all([ | ||
this.getRetry(`blocks/${blockHeight}`), | ||
this.getTransactionsByHeight(blockHeight) | ||
]) | ||
block = response[0] | ||
transactions = response[1] | ||
} else { | ||
block = await this.getRetry(`blocks/latest`) | ||
transactions = await this.getTransactionsV2ByHeight( | ||
block.block.header.height | ||
) | ||
} | ||
return this.reducers.blockReducer(this.networkId, block, transactions) | ||
} | ||
|
||
async getAllValidators(height) { | ||
return CosmosV0API.prototype.getAllValidators.call(this, height) | ||
} | ||
|
||
async getExpectedReturns(validator) { | ||
return CosmosV0API.prototype.getExpectedReturns.call(this, validator) | ||
} | ||
} | ||
|
||
module.exports = AkashV0API |