Skip to content

Commit

Permalink
Refactor native mainnet, testnet chain config
Browse files Browse the repository at this point in the history
  • Loading branch information
delivan committed Aug 29, 2023
1 parent f200c34 commit 0f5c7c7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 54 deletions.
52 changes: 52 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -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",
];
62 changes: 8 additions & 54 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
})();
Expand Down

0 comments on commit 0f5c7c7

Please sign in to comment.