chainName is now considered lowercased, fixing address bar capitalization

This commit is contained in:
zenodeapp 2023-12-03 20:43:31 +01:00
parent fe79a2ab11
commit b01588c94d
8 changed files with 24 additions and 21 deletions

View File

@ -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();

View File

@ -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 || ''
}} <span class="text-error">{{ baseStore.connected ? '' : 'disconnected' }}</span>
</div>
<div

View File

@ -30,7 +30,7 @@ const validators = ref(stakingStore.validators)
const keyword = ref("")
function loadSigningInfo(chainName: string) {
const chain = dashboard.chains[chainName]
const chain = dashboard.getChainConfig(chainName)
if(chain && chain.endpoints.rest) {
const client = CosmosRestClient.newDefault(chain.endpoints.rest[0].address)
client.getSlashingSigningInfos().then( resp => {
@ -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) {
<div class="input-group input-group-md">
<select v-model="selectChain" class="select select-bordered capitalize" @change="changeChain">
<option v-for="v in dashboard.chains" :value="v.chainName">
{{ v.chainName }}
{{ v.prettyName }}
</option>
</select>
<input v-model="keyword" type="text" class="input w-full" placeholder="keywords to filter validator">

View File

@ -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: {

View File

@ -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,
},

View File

@ -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)
}
})

View File

@ -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,

View File

@ -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<LocalConfig>(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<LocalConfig>(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()];
}
},
});