Made search include chainName and simplified the url fix
This commit is contained in:
parent
b01588c94d
commit
2982f8e727
@ -11,7 +11,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const dashboardStore = useDashboard();
|
const dashboardStore = useDashboard();
|
||||||
const conf = computed(() => dashboardStore.getChainConfig(props.name) || {});
|
const conf = computed(() => dashboardStore.chains[props.name] || {});
|
||||||
|
|
||||||
const addFavor = (e: Event) => {
|
const addFavor = (e: Event) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -35,7 +35,7 @@ function changeEndpoint(item: Endpoint) {
|
|||||||
{{
|
{{
|
||||||
baseStore.latest?.block?.header?.height
|
baseStore.latest?.block?.header?.height
|
||||||
? `#${baseStore.latest.block.header.height}`
|
? `#${baseStore.latest.block.header.height}`
|
||||||
: chainStore.current?.prettyName || ''
|
: chainStore.chainName || ''
|
||||||
}} <span class="text-error">{{ baseStore.connected ? '' : 'disconnected' }}</span>
|
}} <span class="text-error">{{ baseStore.connected ? '' : 'disconnected' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
@ -30,7 +30,7 @@ const validators = ref(stakingStore.validators)
|
|||||||
const keyword = ref("")
|
const keyword = ref("")
|
||||||
|
|
||||||
function loadSigningInfo(chainName: string) {
|
function loadSigningInfo(chainName: string) {
|
||||||
const chain = dashboard.getChainConfig(chainName)
|
const chain = dashboard.chains[chainName]
|
||||||
if(chain && chain.endpoints.rest) {
|
if(chain && chain.endpoints.rest) {
|
||||||
const client = CosmosRestClient.newDefault(chain.endpoints.rest[0].address)
|
const client = CosmosRestClient.newDefault(chain.endpoints.rest[0].address)
|
||||||
client.getSlashingSigningInfos().then( resp => {
|
client.getSlashingSigningInfos().then( resp => {
|
||||||
@ -95,7 +95,7 @@ function add() {
|
|||||||
|
|
||||||
function changeChain() {
|
function changeChain() {
|
||||||
validators.value = []
|
validators.value = []
|
||||||
const endpoint = dashboard.getChainConfig(selectChain.value).endpoints.rest?.at(0)?.address
|
const endpoint = dashboard.chains[selectChain.value].endpoints.rest?.at(0)?.address
|
||||||
if(!endpoint) return
|
if(!endpoint) return
|
||||||
|
|
||||||
const client = CosmosRestClient.newDefault(endpoint)
|
const client = CosmosRestClient.newDefault(endpoint)
|
||||||
@ -193,7 +193,7 @@ function color(v: string) {
|
|||||||
<div class="input-group input-group-md">
|
<div class="input-group input-group-md">
|
||||||
<select v-model="selectChain" class="select select-bordered capitalize" @change="changeChain">
|
<select v-model="selectChain" class="select select-bordered capitalize" @change="changeChain">
|
||||||
<option v-for="v in dashboard.chains" :value="v.chainName">
|
<option v-for="v in dashboard.chains" :value="v.chainName">
|
||||||
{{ v.prettyName }}
|
{{ v.chainName }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<input v-model="keyword" type="text" class="input w-full" placeholder="keywords to filter validator">
|
<input v-model="keyword" type="text" class="input w-full" placeholder="keywords to filter validator">
|
||||||
|
@ -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
|
const coinDecimals = chain.assets[0].denom_units.find(x => x.denom === chain.assets[0].symbol.toLowerCase())?.exponent || 6
|
||||||
conf.value = JSON.stringify({
|
conf.value = JSON.stringify({
|
||||||
chainId: chainid,
|
chainId: chainid,
|
||||||
chainName: chain.prettyName,
|
chainName: chain.chainName,
|
||||||
rpc: chain.endpoints?.rpc?.at(0)?.address,
|
rpc: chain.endpoints?.rpc?.at(0)?.address,
|
||||||
rest: chain.endpoints?.rest?.at(0)?.address,
|
rest: chain.endpoints?.rest?.at(0)?.address,
|
||||||
bip44: {
|
bip44: {
|
||||||
|
@ -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
|
const coinDecimals = chain.assets[0].denom_units.find(x => x.denom === chain.assets[0].symbol.toLowerCase())?.exponent || 6
|
||||||
conf.value = JSON.stringify({
|
conf.value = JSON.stringify({
|
||||||
chainId: chainid,
|
chainId: chainid,
|
||||||
chainName: chain.prettyName,
|
chainName: chain.chainName,
|
||||||
rpc: chain.endpoints?.rpc?.at(0)?.address,
|
rpc: chain.endpoints?.rpc?.at(0)?.address,
|
||||||
rest: chain.endpoints?.rest?.at(0)?.address,
|
rest: chain.endpoints?.rest?.at(0)?.address,
|
||||||
bip44: {
|
bip44: {
|
||||||
@ -103,7 +103,7 @@ async function initSnap() {
|
|||||||
|
|
||||||
conf.value = JSON.stringify({
|
conf.value = JSON.stringify({
|
||||||
chainId,
|
chainId,
|
||||||
chainName: chain.prettyName,
|
chainName: chain.chainName,
|
||||||
bech32Config: {
|
bech32Config: {
|
||||||
bech32PrefixAccAddr: chain.bech32Prefix,
|
bech32PrefixAccAddr: chain.bech32Prefix,
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,8 @@ const chains = computed(() => {
|
|||||||
const lowercaseKeywords = keywords.value.toLowerCase();
|
const lowercaseKeywords = keywords.value.toLowerCase();
|
||||||
|
|
||||||
return Object.values(dashboard.chains).filter(
|
return Object.values(dashboard.chains).filter(
|
||||||
(x: ChainConfig) => x.prettyName.toLowerCase().indexOf(lowercaseKeywords) > -1
|
(x: ChainConfig) => x.chainName.toLowerCase().indexOf(lowercaseKeywords) > -1
|
||||||
|
|| x.prettyName.toLowerCase().indexOf(lowercaseKeywords) > -1
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Object.values(dashboard.chains);
|
return Object.values(dashboard.chains);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useBlockchain } from "@/stores";
|
import { useBlockchain, useDashboard } from "@/stores";
|
||||||
import { createRouter, createWebHistory } from "vue-router";
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { setupLayouts } from "virtual:generated-layouts";
|
import { setupLayouts } from "virtual:generated-layouts";
|
||||||
@ -15,10 +15,10 @@ router.beforeEach((to) => {
|
|||||||
const { chain } = to.params
|
const { chain } = to.params
|
||||||
if(chain){
|
if(chain){
|
||||||
const blockchain = useBlockchain()
|
const blockchain = useBlockchain()
|
||||||
const lowercaseChain = chain.toString().toLowerCase();
|
if(chain !== blockchain.chainName) {
|
||||||
if(lowercaseChain !== blockchain.chainName)
|
blockchain.setCurrent(chain.toString())
|
||||||
blockchain.setCurrent(lowercaseChain)
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Docs: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards
|
// Docs: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards
|
||||||
|
@ -41,7 +41,7 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
current(): ChainConfig | undefined {
|
current(): ChainConfig | undefined {
|
||||||
return this.dashboard.getChainConfig(this.chainName);
|
return this.dashboard.chains[this.chainName];
|
||||||
},
|
},
|
||||||
logo(): string {
|
logo(): string {
|
||||||
return this.current?.logo || '';
|
return this.current?.logo || '';
|
||||||
@ -99,7 +99,7 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
// compute favorite menu
|
// compute favorite menu
|
||||||
const favNavItems: VerticalNavItems = [];
|
const favNavItems: VerticalNavItems = [];
|
||||||
Object.keys(this.dashboard.favoriteMap).forEach((name) => {
|
Object.keys(this.dashboard.favoriteMap).forEach((name) => {
|
||||||
const ch = this.dashboard.getChainConfig(name);
|
const ch = this.dashboard.chains[name];
|
||||||
if (ch && this.dashboard.favoriteMap?.[name]) {
|
if (ch && this.dashboard.favoriteMap?.[name]) {
|
||||||
favNavItems.push({
|
favNavItems.push({
|
||||||
title: ch.prettyName || ch.chainName || name,
|
title: ch.prettyName || ch.chainName || name,
|
||||||
@ -175,9 +175,20 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
JSON.stringify(endpoint)
|
JSON.stringify(endpoint)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
setCurrent(name: string) {
|
async setCurrent(name: string) {
|
||||||
if (name !== this.chainName) {
|
// Ensure chains are loaded due to asynchronous calls.
|
||||||
this.chainName = name;
|
if(this.dashboard.length === 0) {
|
||||||
|
await this.dashboard.initial();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the case-sensitive name for the chainName, else simply use the parameter-value.
|
||||||
|
const caseSensitiveName =
|
||||||
|
Object.keys(this.dashboard.chains).find((x) => x.toLowerCase() === name.toLowerCase())
|
||||||
|
|| name;
|
||||||
|
|
||||||
|
// Update chainName if needed
|
||||||
|
if (caseSensitiveName !== this.chainName) {
|
||||||
|
this.chainName = caseSensitiveName;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
supportModule(mod: string) {
|
supportModule(mod: string) {
|
||||||
|
@ -153,7 +153,7 @@ export function fromLocal(lc: LocalConfig): ChainConfig {
|
|||||||
cosmosSdk: lc.sdk_version
|
cosmosSdk: lc.sdk_version
|
||||||
}
|
}
|
||||||
conf.bech32Prefix = lc.addr_prefix;
|
conf.bech32Prefix = lc.addr_prefix;
|
||||||
conf.chainName = lc.chain_name.toLowerCase();
|
conf.chainName = lc.chain_name;
|
||||||
conf.coinType = lc.coin_type;
|
conf.coinType = lc.coin_type;
|
||||||
conf.prettyName = lc.registry_name || lc.chain_name;
|
conf.prettyName = lc.registry_name || lc.chain_name;
|
||||||
conf.endpoints = {
|
conf.endpoints = {
|
||||||
@ -178,7 +178,7 @@ export function fromDirectory(source: DirectoryChain): ChainConfig {
|
|||||||
(conf.assets = source.assets),
|
(conf.assets = source.assets),
|
||||||
(conf.bech32Prefix = source.bech32_prefix),
|
(conf.bech32Prefix = source.bech32_prefix),
|
||||||
(conf.chainId = source.chain_id),
|
(conf.chainId = source.chain_id),
|
||||||
(conf.chainName = source.chain_name.toLowerCase()),
|
(conf.chainName = source.chain_name),
|
||||||
(conf.prettyName = source.pretty_name),
|
(conf.prettyName = source.pretty_name),
|
||||||
(conf.versions = {
|
(conf.versions = {
|
||||||
application: source.versions?.application_version || '',
|
application: source.versions?.application_version || '',
|
||||||
@ -275,9 +275,9 @@ export const useDashboard = defineStore('dashboard', {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
initial() {
|
async initial() {
|
||||||
this.loadingFromLocal();
|
await this.loadingFromLocal();
|
||||||
// this.loadingFromRegistry()
|
// await this.loadingFromRegistry()
|
||||||
},
|
},
|
||||||
loadingPrices() {
|
loadingPrices() {
|
||||||
const coinIds = [] as string[]
|
const coinIds = [] as string[]
|
||||||
@ -308,7 +308,7 @@ export const useDashboard = defineStore('dashboard', {
|
|||||||
this.status = LoadingStatus.Loading;
|
this.status = LoadingStatus.Loading;
|
||||||
get(this.source).then((res) => {
|
get(this.source).then((res) => {
|
||||||
res.chains.forEach((x: DirectoryChain) => {
|
res.chains.forEach((x: DirectoryChain) => {
|
||||||
this.chains[x.chain_name.toLowerCase()] = fromDirectory(x);
|
this.chains[x.chain_name] = fromDirectory(x);
|
||||||
});
|
});
|
||||||
this.status = LoadingStatus.Loaded;
|
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/mainnet/*.json', { eager: true })
|
||||||
: import.meta.glob('../../chains/testnet/*.json', { eager: true });
|
: import.meta.glob('../../chains/testnet/*.json', { eager: true });
|
||||||
Object.values<LocalConfig>(source).forEach((x: LocalConfig) => {
|
Object.values<LocalConfig>(source).forEach((x: LocalConfig) => {
|
||||||
this.chains[x.chain_name.toLowerCase()] = fromLocal(x);
|
this.chains[x.chain_name] = fromLocal(x);
|
||||||
});
|
});
|
||||||
this.setupDefault();
|
this.setupDefault();
|
||||||
this.status = LoadingStatus.Loaded;
|
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/mainnet/*.json', { eager: true })
|
||||||
: import.meta.glob('../../chains/testnet/*.json', { eager: true });
|
: import.meta.glob('../../chains/testnet/*.json', { eager: true });
|
||||||
Object.values<LocalConfig>(source).forEach((x: LocalConfig) => {
|
Object.values<LocalConfig>(source).forEach((x: LocalConfig) => {
|
||||||
config[x.chain_name.toLowerCase()] = fromLocal(x);
|
config[x.chain_name] = fromLocal(x);
|
||||||
});
|
});
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
@ -360,8 +360,5 @@ export const useDashboard = defineStore('dashboard', {
|
|||||||
this.source = newSource;
|
this.source = newSource;
|
||||||
this.initial();
|
this.initial();
|
||||||
},
|
},
|
||||||
getChainConfig(chainId: string): ChainConfig {
|
|
||||||
return this.chains[chainId.toLowerCase()];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user