From be82fd5a1b730e2c6f3f1e055e104359483a236c Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 10 Aug 2021 08:59:45 +0800 Subject: [PATCH] hardcode sdk_version in config --- src/libs/data/data.js | 7 ++++++ src/libs/fetch.js | 20 ---------------- src/store/chains/akash.json | 1 + src/store/chains/band.json | 3 ++- src/store/chains/cosmos.json | 1 + src/store/chains/crypto.json | 1 + src/store/chains/index.js | 41 ++++++++++++++++++--------------- src/store/chains/iris.json | 1 + src/store/chains/kava.json | 2 +- src/store/chains/okexchain.json | 1 + src/store/chains/osmosis.json | 1 + 11 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/libs/data/data.js b/src/libs/data/data.js index b07a9c4e..9f5361ca 100644 --- a/src/libs/data/data.js +++ b/src/libs/data/data.js @@ -87,6 +87,13 @@ export function formatToken(token) { } return `${parseFloat(amount)} ${denom}` } + if (denom === 'BASECRO') { + const amount = token.amount / 1000000 + if (amount > 10) { + return `${parseFloat(amount.toFixed())} CRO` + } + return `${parseFloat(amount)} CRO` + } return `${parseFloat(token.amount)} ${denom}` } return token diff --git a/src/libs/fetch.js b/src/libs/fetch.js index f6b5386e..6a9db0ce 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -19,23 +19,6 @@ export function keybase(identity) { .then(res => res.json()) } -async function refetchVersion(chain) { - await fetch(`${chain.api}/node_info`) - .then(res => res.json()) - .then(json => { - const { build_deps } = json.application_version - // eslint-disable-next-line camelcase - if (build_deps) { - const sdk = build_deps.find(e => e.startsWith('github.com/cosmos/cosmos-sdk')) - const re = /(\d+(\.\d+)*)/i - const version = sdk.match(re) - // eslint-disable-next-line prefer-destructuring - return version[0] - } - return json.node_info.version - }).catch(() => null) -} - const chainAPI = class ChainFetch { getSelectedConfig() { let chain = store.state.chains.selected @@ -43,9 +26,6 @@ const chainAPI = class ChainFetch { if (lschains) { chain = JSON.parse(lschains)[chain.chain_name] } - if (!chain.sdk_version) { - chain.sdk_version = refetchVersion(chain) - } if (!chain.sdk_version) { chain.sdk_version = '0.33' } diff --git a/src/store/chains/akash.json b/src/store/chains/akash.json index 028b7078..32bc3487 100644 --- a/src/store/chains/akash.json +++ b/src/store/chains/akash.json @@ -1,5 +1,6 @@ { "chain_name": "akash", "api": "https://akash.api.ping.pub", + "sdk_version": "0.41.3", "logo": "https://dl.airtable.com/.attachments/52586702dd8352d97834fce5c2d83614/969b4d53/akash-network.png" } \ No newline at end of file diff --git a/src/store/chains/band.json b/src/store/chains/band.json index 537bfa81..fc3b4e66 100644 --- a/src/store/chains/band.json +++ b/src/store/chains/band.json @@ -1,5 +1,6 @@ { "chain_name": "band", "api": "https://api-gm-lb.bandchain.org", - "logo": "https://dl.airtable.com/.attachments/472ae99a508e32b4439b416beddd4eb9/c5166f62/band-symbol-blue-bg.75a3ad91.svg" + "logo": "https://dl.airtable.com/.attachments/472ae99a508e32b4439b416beddd4eb9/c5166f62/band-symbol-blue-bg.75a3ad91.svg", + "sdk_version": "0.33.8" } \ No newline at end of file diff --git a/src/store/chains/cosmos.json b/src/store/chains/cosmos.json index c39e76fa..7a5bdf55 100644 --- a/src/store/chains/cosmos.json +++ b/src/store/chains/cosmos.json @@ -1,5 +1,6 @@ { "chain_name": "cosmos", "api":"https://lcd-cosmoshub.keplr.app", + "sdk_version": "0.42.6", "logo": "https://dl.airtable.com/.attachments/e54f814bba8c0f9af8a3056020210de0/2d1155fb/cosmos-hub.svg" } \ No newline at end of file diff --git a/src/store/chains/crypto.json b/src/store/chains/crypto.json index 03ac15b3..7efaca9c 100644 --- a/src/store/chains/crypto.json +++ b/src/store/chains/crypto.json @@ -2,5 +2,6 @@ { "chain_name": "crypto", "api": "https://mainnet.crypto.org:1317", + "sdk_version": "0.39.2", "logo": "https://dl.airtable.com/.attachments/b2e638424ea09dccd4f11b04dc53872a/844d11dc/LOGO.png" } \ No newline at end of file diff --git a/src/store/chains/index.js b/src/store/chains/index.js index de696148..5dd7fc25 100644 --- a/src/store/chains/index.js +++ b/src/store/chains/index.js @@ -13,27 +13,30 @@ if (localChains) { chains = JSON.parse(localChains) } else { chains = update + localStorage.setItem('chains', JSON.stringify(update)) } -Object.keys(update).forEach(key => { - const chain = update[key] - fetch(`${chain.api}/node_info`) - .then(res => res.json()) - .then(json => { - const { build_deps } = json.application_version - // eslint-disable-next-line camelcase - if (build_deps) { - const sdk = build_deps.find(e => e.startsWith('github.com/cosmos/cosmos-sdk')) - const re = /(\d+(\.\d+)*)/i - const version = sdk.match(re) - // eslint-disable-next-line prefer-destructuring - chain.sdk_version = version[0] - } else { - chain.sdk_version = json.node_info.version - } - localStorage.setItem('chains', JSON.stringify(update)) - }) -}) +// Object.keys(update).forEach(key => { +// const chain = update[key] +// if (!chain.sdk_version) { +// fetch(`${chain.api}/node_info`) +// .then(res => res.json()) +// .then(json => { +// const { build_deps } = json.application_version +// // eslint-disable-next-line camelcase +// if (build_deps) { +// const sdk = build_deps.find(e => e.startsWith('github.com/cosmos/cosmos-sdk')) +// const re = /(\d+(\.\d+)*)/i +// const version = sdk.match(re) +// // eslint-disable-next-line prefer-destructuring +// chain.sdk_version = version[0] +// } else { +// chain.sdk_version = json.node_info.version +// } +// localStorage.setItem('chains', JSON.stringify(update)) +// }) +// } +// }) export default { namespaced: true, diff --git a/src/store/chains/iris.json b/src/store/chains/iris.json index d5e280dc..c38b6055 100644 --- a/src/store/chains/iris.json +++ b/src/store/chains/iris.json @@ -1,5 +1,6 @@ { "chain_name": "iris", "api": "https://iris.api.ping.pub", + "sdk_version": "0.42.4", "logo": "https://dl.airtable.com/.attachments/2d6d51b1b262db00ecc51616ffc3bdf5/90ff00d0/IRISnet.svg" } \ No newline at end of file diff --git a/src/store/chains/kava.json b/src/store/chains/kava.json index 65a849c2..dc253a21 100644 --- a/src/store/chains/kava.json +++ b/src/store/chains/kava.json @@ -1,6 +1,6 @@ { "chain_name": "kava", - "chain_id": "kava-7", "api": "https://kava4.data.kava.io", + "sdk_version": "0.39.2", "logo": "https://dl.airtable.com/.attachments/f25737491bd0034240093a7b4e039b15/afec77ff/logo.png" } \ No newline at end of file diff --git a/src/store/chains/okexchain.json b/src/store/chains/okexchain.json index c203de97..696087e6 100644 --- a/src/store/chains/okexchain.json +++ b/src/store/chains/okexchain.json @@ -1,6 +1,7 @@ { "chain_name": "okexchain", "api": "https://exchainrpc.okex.org/okexchain/v1", + "sdk_version": "0.39.2", "logo": "https://dl.airtable.com/.attachments/4620a173477efece7f459a3d6fc770c0/9f6618ad/OKexchain.svg", "unload_module": ["minting", "slashing"] } \ No newline at end of file diff --git a/src/store/chains/osmosis.json b/src/store/chains/osmosis.json index c39e3a0e..8e0d693b 100644 --- a/src/store/chains/osmosis.json +++ b/src/store/chains/osmosis.json @@ -1,5 +1,6 @@ { "chain_name": "osmosis", "api": "https://lcd-osmosis.keplr.app", + "sdk_version": "0.42.5", "logo": "https://dl.airtable.com/.attachments/4ef30ec4008bc86cc3c0f74a6bb84050/0eeb4d64/aQ5W3zaT_400x400.jpg" }