add injective

This commit is contained in:
liangping 2021-11-16 11:26:27 +08:00
parent a3ad4a56bc
commit 6d37cf4df5
4 changed files with 23 additions and 1 deletions

View File

@ -25,6 +25,7 @@
"omniflix": "OmniFlix", "omniflix": "OmniFlix",
"likecoin": "LikeCoin", "likecoin": "LikeCoin",
"stargaze": "Stargaze", "stargaze": "Stargaze",
"injective": "Injective Protocal",
"staking": "Staking", "staking": "Staking",
"governance": "Governance", "governance": "Governance",

View File

@ -300,7 +300,11 @@ export function getUnitAmount(amount, denom) {
export function formatTokenAmount(tokenAmount, fraction = 2, denom = 'uatom') { export function formatTokenAmount(tokenAmount, fraction = 2, denom = 'uatom') {
let amount let amount
if (denom.startsWith('rowan')) { if (denom.startsWith('inj')) {
// eslint-disable-next-line no-undef
amount = Number(BigInt(Number(tokenAmount)) / 1000000000000000000n)
// }
} else if (denom.startsWith('rowan')) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
amount = Number(BigInt(Number(tokenAmount)) / 1000000000000000000n) amount = Number(BigInt(Number(tokenAmount)) / 1000000000000000000n)
// } // }

View File

@ -49,10 +49,19 @@ export default class ChainFetch {
} }
async getLatestBlock(config = null) { async getLatestBlock(config = null) {
const conf = config || this.getSelectedConfig()
console.log('config: ', conf)
if (conf.chain_name === 'injective') {
return ChainFetch.fetch('https://tm.injective.network', '/block').then(data => Block.create(commonProcess(data)))
}
return this.get('/blocks/latest', config).then(data => Block.create(data)) return this.get('/blocks/latest', config).then(data => Block.create(data))
} }
async getBlockByHeight(height, config = null) { async getBlockByHeight(height, config = null) {
const conf = config || this.getSelectedConfig()
if (conf.chain_name === 'injective') {
return ChainFetch.fetch('https://tm.injective.network', `/block?height=${height}`).then(data => Block.create(commonProcess(data)))
}
return this.get(`/blocks/${height}`, config).then(data => Block.create(data)) return this.get(`/blocks/${height}`, config).then(data => Block.create(data))
} }

View File

@ -0,0 +1,8 @@
{
"chain_name": "injective",
"api": "https://lcd.injective.network",
"sdk_version": "0.42.4",
"addr_prefix": "inj",
"excludes": "",
"logo": "https://dl.airtable.com/.attachments/e024faae112ae873d301f9e1e17a921c/3f3671f7/9pOKAlQ5_400x400.jpg"
}