From 0ccfd3b79f0e9449a45cc6e63384d1939ece661f Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 17 Nov 2021 15:28:09 +0800 Subject: [PATCH] refactor --- .../chains => chains/mainnet}/akash.json | 0 .../chains => chains/mainnet}/band.json | 0 .../chains => chains/mainnet}/bitsong.json | 0 .../chains => chains/mainnet}/certik.json | 0 .../chains => chains/mainnet}/cosmos.json | 0 .../chains => chains/mainnet}/crypto.json | 0 .../chains => chains/mainnet}/desmos.json | 0 .../chains => chains/mainnet}/emoney.json | 0 .../chains => chains/mainnet}/injective.json | 0 .../chains => chains/mainnet}/iris.json | 0 .../chains => chains/mainnet}/juno.json | 0 .../chains => chains/mainnet}/kava.json | 0 .../chains => chains/mainnet}/likecoin.json | 0 .../chains => chains/mainnet}/neuron.json.bak | 0 .../chains => chains/mainnet}/okexchain.json | 0 .../chains => chains/mainnet}/omniflix.json | 0 .../chains => chains/mainnet}/osmosis.json | 0 .../mainnet}/persistence.json | 0 .../chains => chains/mainnet}/regen.json | 0 .../chains => chains/mainnet}/secret.json | 0 .../chains => chains/mainnet}/sentinel.json | 0 .../chains => chains/mainnet}/sifchain.json | 0 .../chains => chains/mainnet}/stargaze.json | 0 .../chains => chains/mainnet}/starname.json | 0 .../chains => chains/mainnet}/terra.json | 0 .../chains => chains/mainnet}/vidulum.json | 0 .../testnet/cosmos.json} | 0 src/chains/testnet/iris.json | 8 +++++ src/store/chains/index.js | 33 +++---------------- 29 files changed, 12 insertions(+), 29 deletions(-) rename src/{store/chains => chains/mainnet}/akash.json (100%) rename src/{store/chains => chains/mainnet}/band.json (100%) rename src/{store/chains => chains/mainnet}/bitsong.json (100%) rename src/{store/chains => chains/mainnet}/certik.json (100%) rename src/{store/chains => chains/mainnet}/cosmos.json (100%) rename src/{store/chains => chains/mainnet}/crypto.json (100%) rename src/{store/chains => chains/mainnet}/desmos.json (100%) rename src/{store/chains => chains/mainnet}/emoney.json (100%) rename src/{store/chains => chains/mainnet}/injective.json (100%) rename src/{store/chains => chains/mainnet}/iris.json (100%) rename src/{store/chains => chains/mainnet}/juno.json (100%) rename src/{store/chains => chains/mainnet}/kava.json (100%) rename src/{store/chains => chains/mainnet}/likecoin.json (100%) rename src/{store/chains => chains/mainnet}/neuron.json.bak (100%) rename src/{store/chains => chains/mainnet}/okexchain.json (100%) rename src/{store/chains => chains/mainnet}/omniflix.json (100%) rename src/{store/chains => chains/mainnet}/osmosis.json (100%) rename src/{store/chains => chains/mainnet}/persistence.json (100%) rename src/{store/chains => chains/mainnet}/regen.json (100%) rename src/{store/chains => chains/mainnet}/secret.json (100%) rename src/{store/chains => chains/mainnet}/sentinel.json (100%) rename src/{store/chains => chains/mainnet}/sifchain.json (100%) rename src/{store/chains => chains/mainnet}/stargaze.json (100%) rename src/{store/chains => chains/mainnet}/starname.json (100%) rename src/{store/chains => chains/mainnet}/terra.json (100%) rename src/{store/chains => chains/mainnet}/vidulum.json (100%) rename src/{store/chains/cosmostest.json => chains/testnet/cosmos.json} (100%) create mode 100644 src/chains/testnet/iris.json diff --git a/src/store/chains/akash.json b/src/chains/mainnet/akash.json similarity index 100% rename from src/store/chains/akash.json rename to src/chains/mainnet/akash.json diff --git a/src/store/chains/band.json b/src/chains/mainnet/band.json similarity index 100% rename from src/store/chains/band.json rename to src/chains/mainnet/band.json diff --git a/src/store/chains/bitsong.json b/src/chains/mainnet/bitsong.json similarity index 100% rename from src/store/chains/bitsong.json rename to src/chains/mainnet/bitsong.json diff --git a/src/store/chains/certik.json b/src/chains/mainnet/certik.json similarity index 100% rename from src/store/chains/certik.json rename to src/chains/mainnet/certik.json diff --git a/src/store/chains/cosmos.json b/src/chains/mainnet/cosmos.json similarity index 100% rename from src/store/chains/cosmos.json rename to src/chains/mainnet/cosmos.json diff --git a/src/store/chains/crypto.json b/src/chains/mainnet/crypto.json similarity index 100% rename from src/store/chains/crypto.json rename to src/chains/mainnet/crypto.json diff --git a/src/store/chains/desmos.json b/src/chains/mainnet/desmos.json similarity index 100% rename from src/store/chains/desmos.json rename to src/chains/mainnet/desmos.json diff --git a/src/store/chains/emoney.json b/src/chains/mainnet/emoney.json similarity index 100% rename from src/store/chains/emoney.json rename to src/chains/mainnet/emoney.json diff --git a/src/store/chains/injective.json b/src/chains/mainnet/injective.json similarity index 100% rename from src/store/chains/injective.json rename to src/chains/mainnet/injective.json diff --git a/src/store/chains/iris.json b/src/chains/mainnet/iris.json similarity index 100% rename from src/store/chains/iris.json rename to src/chains/mainnet/iris.json diff --git a/src/store/chains/juno.json b/src/chains/mainnet/juno.json similarity index 100% rename from src/store/chains/juno.json rename to src/chains/mainnet/juno.json diff --git a/src/store/chains/kava.json b/src/chains/mainnet/kava.json similarity index 100% rename from src/store/chains/kava.json rename to src/chains/mainnet/kava.json diff --git a/src/store/chains/likecoin.json b/src/chains/mainnet/likecoin.json similarity index 100% rename from src/store/chains/likecoin.json rename to src/chains/mainnet/likecoin.json diff --git a/src/store/chains/neuron.json.bak b/src/chains/mainnet/neuron.json.bak similarity index 100% rename from src/store/chains/neuron.json.bak rename to src/chains/mainnet/neuron.json.bak diff --git a/src/store/chains/okexchain.json b/src/chains/mainnet/okexchain.json similarity index 100% rename from src/store/chains/okexchain.json rename to src/chains/mainnet/okexchain.json diff --git a/src/store/chains/omniflix.json b/src/chains/mainnet/omniflix.json similarity index 100% rename from src/store/chains/omniflix.json rename to src/chains/mainnet/omniflix.json diff --git a/src/store/chains/osmosis.json b/src/chains/mainnet/osmosis.json similarity index 100% rename from src/store/chains/osmosis.json rename to src/chains/mainnet/osmosis.json diff --git a/src/store/chains/persistence.json b/src/chains/mainnet/persistence.json similarity index 100% rename from src/store/chains/persistence.json rename to src/chains/mainnet/persistence.json diff --git a/src/store/chains/regen.json b/src/chains/mainnet/regen.json similarity index 100% rename from src/store/chains/regen.json rename to src/chains/mainnet/regen.json diff --git a/src/store/chains/secret.json b/src/chains/mainnet/secret.json similarity index 100% rename from src/store/chains/secret.json rename to src/chains/mainnet/secret.json diff --git a/src/store/chains/sentinel.json b/src/chains/mainnet/sentinel.json similarity index 100% rename from src/store/chains/sentinel.json rename to src/chains/mainnet/sentinel.json diff --git a/src/store/chains/sifchain.json b/src/chains/mainnet/sifchain.json similarity index 100% rename from src/store/chains/sifchain.json rename to src/chains/mainnet/sifchain.json diff --git a/src/store/chains/stargaze.json b/src/chains/mainnet/stargaze.json similarity index 100% rename from src/store/chains/stargaze.json rename to src/chains/mainnet/stargaze.json diff --git a/src/store/chains/starname.json b/src/chains/mainnet/starname.json similarity index 100% rename from src/store/chains/starname.json rename to src/chains/mainnet/starname.json diff --git a/src/store/chains/terra.json b/src/chains/mainnet/terra.json similarity index 100% rename from src/store/chains/terra.json rename to src/chains/mainnet/terra.json diff --git a/src/store/chains/vidulum.json b/src/chains/mainnet/vidulum.json similarity index 100% rename from src/store/chains/vidulum.json rename to src/chains/mainnet/vidulum.json diff --git a/src/store/chains/cosmostest.json b/src/chains/testnet/cosmos.json similarity index 100% rename from src/store/chains/cosmostest.json rename to src/chains/testnet/cosmos.json diff --git a/src/chains/testnet/iris.json b/src/chains/testnet/iris.json new file mode 100644 index 00000000..6db2f8f9 --- /dev/null +++ b/src/chains/testnet/iris.json @@ -0,0 +1,8 @@ +{ + "chain_name": "iris-network", + "api": "http://35.234.10.84:1317", + "sdk_version": "0.42.4", + "addr_prefix": "iaa", + "excludes": "mint", + "logo": "https://dl.airtable.com/.attachments/2d6d51b1b262db00ecc51616ffc3bdf5/90ff00d0/IRISnet.svg" +} \ No newline at end of file diff --git a/src/store/chains/index.js b/src/store/chains/index.js index 66556fd0..aba18098 100644 --- a/src/store/chains/index.js +++ b/src/store/chains/index.js @@ -1,6 +1,9 @@ let chains = {} -const configs = require.context('.', false, /\.json$/) +let configs = require.context('../../chains/mainnet', false, /\.json$/) +if (window.location.hostname.startsWith('testnet') || window.location.search.indexOf('testnet')) { + configs = require.context('../../chains/testnet', false, /\.json$/) +} const update = {} configs.keys().forEach(k => { @@ -8,38 +11,10 @@ configs.keys().forEach(k => { update[c.chain_name] = c }) -// const localChains = localStorage.getItem('chains') -// if (localChains) { -// chains = JSON.parse(localChains) -// } else { chains = update localStorage.setItem('chains', JSON.stringify(update)) const selected = chains.cosmos -// } - -// 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, state: {