From 0f5c7c7aa4ffa5cd9c2f5549b688e2edbadf5831 Mon Sep 17 00:00:00 2001 From: delivan Date: Tue, 29 Aug 2023 13:22:26 +0900 Subject: [PATCH] Refactor native mainnet, testnet chain config --- src/constants.ts | 52 ++++++++++++++++++++++++++++++++++++++++ src/index.ts | 62 +++++++----------------------------------------- 2 files changed, 60 insertions(+), 54 deletions(-) create mode 100644 src/constants.ts diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 000000000..a9c46d08f --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,52 @@ +export const nativeMainnetChainIdentifiers: string[] = [ + "cosmoshub", + "osmosis", + "juno", + "agoric", + "akashnet", + "axelar-dojo", + "bostrom", + "core", + "emoney", + "evmos_9001", + "gravity-bridge", + "ixo", + "iov-mainnet-ibc", + "irishub", + "kava_2222", + "regen", + "secret", + "sentinelhub", + "shentu-2.2", + "sifchain", + "sommelier", + "stargaze", + "stride", + "tgrade-mainnet", + "umee", + "crypto-org-chain-mainnet", + "quicksilver", + "columbus", + "phoenix", + "mars", + "quasar", + "noble", + "injective", + "omniflixhub", + "kyve", + "neutron", + "gitopia", + "likecoin-mainnet", +]; + +export const nativeTestnetChainIdentifiers: string[] = [ + "ares", + "axelar-testnet-lisbon", + "atlantic", + "blockspacerace", + "mocha", + "elfagar", + "osmo-test", + "pion", + "theta-testnet", +]; diff --git a/src/index.ts b/src/index.ts index d5b9961b1..85f0e104b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,10 @@ import { checkImageSize, validateChainInfoFromPath } from "./validate"; import libPath from "path"; import { ChainIdHelper } from "@keplr-wallet/cosmos"; +import { + nativeMainnetChainIdentifiers, + nativeTestnetChainIdentifiers, +} from "./constants"; const main = async () => { // get file name @@ -16,67 +20,17 @@ const main = async () => { const chainInfo = await validateChainInfoFromPath(path); const isNativeSupported = (() => { - const nativeChains: string[] = [ - "cosmoshub", - "osmosis", - "juno", - "agoric", - "akashnet", - "axelar-dojo", - "bostrom", - "core", - "emoney", - "evmos_9001", - "gravity-bridge", - "ixo", - "iov-mainnet-ibc", - "irishub", - "kava_2222", - "regen", - "secret", - "sentinelhub", - "shentu-2.2", - "sifchain", - "sommelier", - "stargaze", - "stride", - "tgrade-mainnet", - "umee", - "crypto-org-chain-mainnet", - "quicksilver", - "columbus", - "phoenix", - "mars", - "quasar", - "noble", - "injective", - "omniflixhub", - "kyve", - "neutron", - "gitopia", - "likecoin-mainnet", - ]; const chainIdentifier = ChainIdHelper.parse(chainInfo.chainId).identifier; - return nativeChains.map((s) => s.trim()).includes(chainIdentifier); + return nativeMainnetChainIdentifiers + .map((s) => s.trim()) + .includes(chainIdentifier); })(); const isTestnetChain = (() => { - const testNetChains: string[] = [ - "ares", - "axelar-testnet-lisbon", - "atlantic", - "blockspacerace", - "mocha", - "elfagar", - "osmo-test", - "pion", - "theta-testnet", - ]; - const chainIdentifier = ChainIdHelper.parse(chainInfo.chainId).identifier; - return testNetChains + return nativeTestnetChainIdentifiers .map((s) => s.trim()) .some((s) => s === chainIdentifier); })();