diff --git a/src/components/ChainSummary.vue b/src/components/ChainSummary.vue index 53edb036..dd86afe2 100644 --- a/src/components/ChainSummary.vue +++ b/src/components/ChainSummary.vue @@ -11,7 +11,7 @@ const props = defineProps({ }); const dashboardStore = useDashboard(); -const conf = computed(() => dashboardStore.chains[props.name] || {}); +const conf = computed(() => dashboardStore.getChainConfig(props.name) || {}); const addFavor = (e: Event) => { e.stopPropagation(); diff --git a/src/layouts/components/ChainProfile.vue b/src/layouts/components/ChainProfile.vue index 029aa594..1674ca3e 100644 --- a/src/layouts/components/ChainProfile.vue +++ b/src/layouts/components/ChainProfile.vue @@ -32,10 +32,10 @@ function changeEndpoint(item: Endpoint) { " class="capitalize whitespace-nowrap text-base font-semibold text-gray-600 dark:text-gray-200 hidden md:!block" > - #{{ - baseStore.latest?.block?.header?.height || - chainStore.chainName || - '' + {{ + baseStore.latest?.block?.header?.height + ? `#${baseStore.latest.block.header.height}` + : chainStore.current?.prettyName || '' }} {{ baseStore.connected ? '' : 'disconnected' }}
{ @@ -95,7 +95,7 @@ function add() { function changeChain() { validators.value = [] - const endpoint = dashboard.chains[selectChain.value].endpoints.rest?.at(0)?.address + const endpoint = dashboard.getChainConfig(selectChain.value).endpoints.rest?.at(0)?.address if(!endpoint) return const client = CosmosRestClient.newDefault(endpoint) @@ -193,7 +193,7 @@ function color(v: string) {
diff --git a/src/modules/wallet/keplr.vue b/src/modules/wallet/keplr.vue index 1f5b2749..e30d8388 100644 --- a/src/modules/wallet/keplr.vue +++ b/src/modules/wallet/keplr.vue @@ -29,7 +29,7 @@ async function initParamsForKeplr() { const coinDecimals = chain.assets[0].denom_units.find(x => x.denom === chain.assets[0].symbol.toLowerCase())?.exponent || 6 conf.value = JSON.stringify({ chainId: chainid, - chainName: chain.chainName, + chainName: chain.prettyName, rpc: chain.endpoints?.rpc?.at(0)?.address, rest: chain.endpoints?.rest?.at(0)?.address, bip44: { diff --git a/src/modules/wallet/suggest.vue b/src/modules/wallet/suggest.vue index 818262d5..70dd66bc 100644 --- a/src/modules/wallet/suggest.vue +++ b/src/modules/wallet/suggest.vue @@ -49,7 +49,7 @@ async function initParamsForKeplr() { const coinDecimals = chain.assets[0].denom_units.find(x => x.denom === chain.assets[0].symbol.toLowerCase())?.exponent || 6 conf.value = JSON.stringify({ chainId: chainid, - chainName: chain.chainName, + chainName: chain.prettyName, rpc: chain.endpoints?.rpc?.at(0)?.address, rest: chain.endpoints?.rest?.at(0)?.address, bip44: { @@ -103,7 +103,7 @@ async function initSnap() { conf.value = JSON.stringify({ chainId, - chainName: chain.chainName, + chainName: chain.prettyName, bech32Config: { bech32PrefixAccAddr: chain.bech32Prefix, }, diff --git a/src/router/index.ts b/src/router/index.ts index 7dc4a6d0..32ed023f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -15,9 +15,9 @@ router.beforeEach((to) => { const { chain } = to.params if(chain){ const blockchain = useBlockchain() - if(chain !== blockchain.chainName) { - blockchain.setCurrent(chain.toString()) - } + const lowercaseChain = chain.toString().toLowerCase(); + if(lowercaseChain !== blockchain.chainName) + blockchain.setCurrent(lowercaseChain) } }) diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 76f392db..ba85e1d2 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -41,7 +41,7 @@ export const useBlockchain = defineStore('blockchain', { }, getters: { current(): ChainConfig | undefined { - return this.dashboard.chains[this.chainName]; + return this.dashboard.getChainConfig(this.chainName); }, logo(): string { return this.current?.logo || ''; @@ -99,7 +99,7 @@ export const useBlockchain = defineStore('blockchain', { // compute favorite menu const favNavItems: VerticalNavItems = []; Object.keys(this.dashboard.favoriteMap).forEach((name) => { - const ch = this.dashboard.chains[name]; + const ch = this.dashboard.getChainConfig(name); if (ch && this.dashboard.favoriteMap?.[name]) { favNavItems.push({ title: ch.prettyName || ch.chainName || name, diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index 2753c1c2..7820bbd3 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -153,7 +153,7 @@ export function fromLocal(lc: LocalConfig): ChainConfig { cosmosSdk: lc.sdk_version } conf.bech32Prefix = lc.addr_prefix; - conf.chainName = lc.chain_name; + conf.chainName = lc.chain_name.toLowerCase(); conf.coinType = lc.coin_type; conf.prettyName = lc.registry_name || lc.chain_name; conf.endpoints = { @@ -178,7 +178,7 @@ export function fromDirectory(source: DirectoryChain): ChainConfig { (conf.assets = source.assets), (conf.bech32Prefix = source.bech32_prefix), (conf.chainId = source.chain_id), - (conf.chainName = source.chain_name), + (conf.chainName = source.chain_name.toLowerCase()), (conf.prettyName = source.pretty_name), (conf.versions = { application: source.versions?.application_version || '', @@ -308,7 +308,7 @@ export const useDashboard = defineStore('dashboard', { this.status = LoadingStatus.Loading; get(this.source).then((res) => { res.chains.forEach((x: DirectoryChain) => { - this.chains[x.chain_name] = fromDirectory(x); + this.chains[x.chain_name.toLowerCase()] = fromDirectory(x); }); this.status = LoadingStatus.Loaded; }); @@ -323,7 +323,7 @@ export const useDashboard = defineStore('dashboard', { ? import.meta.glob('../../chains/mainnet/*.json', { eager: true }) : import.meta.glob('../../chains/testnet/*.json', { eager: true }); Object.values(source).forEach((x: LocalConfig) => { - this.chains[x.chain_name] = fromLocal(x); + this.chains[x.chain_name.toLowerCase()] = fromLocal(x); }); this.setupDefault(); this.status = LoadingStatus.Loaded; @@ -335,7 +335,7 @@ export const useDashboard = defineStore('dashboard', { ? import.meta.glob('../../chains/mainnet/*.json', { eager: true }) : import.meta.glob('../../chains/testnet/*.json', { eager: true }); Object.values(source).forEach((x: LocalConfig) => { - config[x.chain_name] = fromLocal(x); + config[x.chain_name.toLowerCase()] = fromLocal(x); }); return config }, @@ -360,5 +360,8 @@ export const useDashboard = defineStore('dashboard', { this.source = newSource; this.initial(); }, + getChainConfig(chainId: string): ChainConfig { + return this.chains[chainId.toLowerCase()]; + } }, });