diff --git a/src/modules/[chain]/ibc/connStore.ts b/src/modules/[chain]/ibc/connStore.ts index 4c4bd91f..8cec9a0f 100644 --- a/src/modules/[chain]/ibc/connStore.ts +++ b/src/modules/[chain]/ibc/connStore.ts @@ -1,7 +1,6 @@ - import { defineStore } from 'pinia'; -import { useBlockchain } from '@/stores' +import { useBlockchain } from '@/stores'; import { ChainRegistryClient } from '@chain-registry/client'; import type { IBCData } from '@chain-registry/types/ibc_data.schema'; import router from '@/router'; @@ -11,25 +10,25 @@ export const useIBCModule = defineStore('module-ibc', { state: () => { return { info: [] as IBCData[], - connectionId: "" as string, + connectionId: '' as string, registryConf: {} as IBCData, }; }, getters: { chain() { - return useBlockchain() + return useBlockchain(); }, chainName(): string { return this.chain.chainName; }, sourceField(): string { - return this.registryConf?.chain_1?.chain_name === this.chainName ? 'chain_1' : 'chain_2' + return this.registryConf?.chain_1?.chain_name === this.chainName ? 'chain_1' : 'chain_2'; }, destField(): string { - return this.registryConf?.chain_1?.chain_name === this.chainName ? 'chain_2' : 'chain_1' + return this.registryConf?.chain_1?.chain_name === this.chainName ? 'chain_2' : 'chain_1'; }, registryChannels(): any { - return this.registryConf.channels + return this.registryConf.channels; }, }, actions: { @@ -45,43 +44,41 @@ export const useIBCModule = defineStore('module-ibc', { }); client.fetchUrls().then(() => { - const info = client.getChainIbcData(this.chainName) + const info = client.getChainIbcData(this.chainName); this.info = info.sort((a, b) => { // Sort by remote chain name (not equal to this.chainName) - const getRemote = (x: any) => x.chain_1.chain_name === this.chainName ? x.chain_2.chain_name : x.chain_1.chain_name; + const getRemote = (x: any) => + x.chain_1.chain_name === this.chainName ? x.chain_2.chain_name : x.chain_1.chain_name; return getRemote(a).localeCompare(getRemote(b)); }); - - }) + }); }); - }, async fetchIBCUrls(): Promise { - let ibcEndpoint = 'https://api.github.com/repos/cosmos/chain-registry/contents/_IBC' - if (this.chainName.includes("testnet")) { - console.log(this.chainName) - ibcEndpoint = 'https://api.github.com/repos/cosmos/chain-registry/contents/testnets/_IBC' + let ibcEndpoint = 'https://api.github.com/repos/cosmos/chain-registry/contents/_IBC'; + if (this.chainName.includes('testnet')) { + console.log(this.chainName); + ibcEndpoint = 'https://api.github.com/repos/cosmos/chain-registry/contents/testnets/_IBC'; } - const entries = await fetch(ibcEndpoint).then((res) => res.json()) + const entries = await fetch(ibcEndpoint).then((res) => res.json()); return entries.filter((x: any) => x.name.match(this.chainName)); }, fetchConnection(index: number) { const res = this.info[index]; - const isFirstChain = res.chain_1.chain_name === this.chain.current?.prettyName || res.chain_1.chain_name === this.chain.chainName; + const isFirstChain = + res.chain_1.chain_name === this.chain.current?.prettyName || res.chain_1.chain_name === this.chain.chainName; - const connId = isFirstChain - ? res.chain_1.connection_id - : res.chain_2.connection_id; + const connId = isFirstChain ? res.chain_1.connection_id : res.chain_2.connection_id; this.registryConf = res; this.showConnection(connId); }, showConnection(connId?: string | number) { if (!connId) { - this.registryConf = {} as any + this.registryConf = {} as any; } - const path = `/${this.chain.chainName}/ibc/connection/${connId || `connection-${this.connectionId || 0}`}` - router.push(path) - } + const path = `/${this.chain.chainName}/ibc/connection/${connId || `connection-${this.connectionId || 0}`}`; + router.push(path); + }, }, }); diff --git a/src/modules/[chain]/ibc/connection.vue b/src/modules/[chain]/ibc/connection.vue index f0a136f3..59695a02 100644 --- a/src/modules/[chain]/ibc/connection.vue +++ b/src/modules/[chain]/ibc/connection.vue @@ -8,57 +8,63 @@ import { useIBCModule } from './connStore'; const props = defineProps(['chain']); const chainStore = useBlockchain(); -const ibcStore = useIBCModule() +const ibcStore = useIBCModule(); const list = ref([] as Connection[]); -const pageRequest = ref(new PageRequest()) -const pageResponse = ref({} as Pagination) +const pageRequest = ref(new PageRequest()); +const pageResponse = ref({} as Pagination); const tab = ref('registry'); onMounted(() => { - pageload(1) - ibcStore.load() + pageload(1); + ibcStore.load(); }); function pageload(p: number) { - pageRequest.value.setPage(p) + pageRequest.value.setPage(p); chainStore.rpc.getIBCConnections(pageRequest.value).then((x) => { list.value = x.connections; - pageResponse.value = x.pagination + pageResponse.value = x.pagination; if (x.pagination.total && Number(x.pagination.total) > 0) { ibcStore.showConnection(list.value[0].id); } }); } -