diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 8c765164..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - { - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "last_opened_file_path": "/Users/ping/workspace/dashboard" - } -} - - - $USER_HOME$/.subversion - - - - - 1678753718354 - - - - - - - - - - - \ No newline at end of file diff --git a/package.json b/package.json index ef876196..5458ac09 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "unplugin-auto-import": "^0.13.0", "unplugin-vue-components": "^0.23.0", "unplugin-vue-define-options": "1.1.4", - "vite": "^4.3.3", + "vite": "^4.3.5", "vite-plugin-pages": "^0.28.0", "vue-tsc": "^1.0.12" } diff --git a/src/App.vue b/src/App.vue index b7c44406..3460a20b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,26 +1,34 @@ diff --git a/src/components/dynamic/NumberElement.vue b/src/components/dynamic/NumberElement.vue index c9b45445..9bcdb11a 100644 --- a/src/components/dynamic/NumberElement.vue +++ b/src/components/dynamic/NumberElement.vue @@ -1,6 +1,6 @@ \ No newline at end of file + {{ Number(props.value) }} + diff --git a/src/components/dynamic/ObjectElement.vue b/src/components/dynamic/ObjectElement.vue index 2d92f453..48cbbf10 100644 --- a/src/components/dynamic/ObjectElement.vue +++ b/src/components/dynamic/ObjectElement.vue @@ -1,23 +1,29 @@ \ No newline at end of file +
+ + + + + + + +
{{ k }} +
+ +
+
+
+ diff --git a/src/components/dynamic/ObjectHorizontalElement.vue b/src/components/dynamic/ObjectHorizontalElement.vue index de8815da..1db000aa 100644 --- a/src/components/dynamic/ObjectHorizontalElement.vue +++ b/src/components/dynamic/ObjectHorizontalElement.vue @@ -1,17 +1,19 @@ \ No newline at end of file +
+ + {{ k }} + + + + +
+ diff --git a/src/components/dynamic/TextElement.vue b/src/components/dynamic/TextElement.vue index 8482d710..7c9f5079 100644 --- a/src/components/dynamic/TextElement.vue +++ b/src/components/dynamic/TextElement.vue @@ -2,16 +2,23 @@ import { useFormatter } from '@/stores'; import MdEditor from 'md-editor-v3'; -const props = defineProps(["value"]); -const format = useFormatter() +const props = defineProps(['value']); +const format = useFormatter(); function isMD() { - if(props.value && (props.value.indexOf("\n") > -1 || props.value.indexOf("\\n") > -1)){ - return true - } - return false + if ( + props.value && + (props.value.indexOf('\n') > -1 || props.value.indexOf('\\n') > -1) + ) { + return true; + } + return false; } - \ No newline at end of file + diff --git a/src/components/dynamic/TxsElement.vue b/src/components/dynamic/TxsElement.vue index c06c7522..2bbe6052 100644 --- a/src/components/dynamic/TxsElement.vue +++ b/src/components/dynamic/TxsElement.vue @@ -1,35 +1,51 @@ \ No newline at end of file + + + + Hash + Msgs + Memo + + + + + + {{ + item.hash + }} + + + {{ + format.messages( + item.tx.body.messages.map((x) => ({ '@type': x.typeUrl })) + ) + }} + + {{ item.tx.body.memo }} + + + +
[]
+ diff --git a/src/components/dynamic/UInt8Array.vue b/src/components/dynamic/UInt8Array.vue index 6134cf4a..6d07a2e3 100644 --- a/src/components/dynamic/UInt8Array.vue +++ b/src/components/dynamic/UInt8Array.vue @@ -2,15 +2,17 @@ import { toBase64, toHex } from '@cosmjs/encoding'; import { computed } from '@vue/reactivity'; -const props = defineProps(["value"]); -const format = ref('base64') -const text = computed(()=> { - return format.value === 'hex'? toHex(props.value) : toBase64(props.value) -}) +const props = defineProps(['value']); +const format = ref('base64'); +const text = computed(() => { + return format.value === 'hex' ? toHex(props.value) : toBase64(props.value); +}); function change() { - format.value = format.value === 'hex'? 'base64': 'hex' + format.value = format.value === 'hex' ? 'base64' : 'hex'; } \ No newline at end of file + {{ text }} + diff --git a/src/components/dynamic/index.ts b/src/components/dynamic/index.ts index cfa736ac..7053bf6f 100644 --- a/src/components/dynamic/index.ts +++ b/src/components/dynamic/index.ts @@ -1,39 +1,39 @@ -import ObjectElement from './ObjectElement.vue' -import TextElement from './TextElement.vue' -import ArrayElement from './ArrayElement.vue' -import UInt8Array from './UInt8Array.vue' -import NumberElement from './NumberElement.vue' -import TxsElement from './TxsElement.vue' -import ObjectHorizontalElement from './ObjectHorizontalElement.vue' -import Long from 'long' +import ObjectElement from './ObjectElement.vue'; +import TextElement from './TextElement.vue'; +import ArrayElement from './ArrayElement.vue'; +import UInt8Array from './UInt8Array.vue'; +import NumberElement from './NumberElement.vue'; +import TxsElement from './TxsElement.vue'; +import ObjectHorizontalElement from './ObjectHorizontalElement.vue'; +import Long from 'long'; export function select(v: any, direct?: string) { - // if(k === 'txs' && v) { - // return TxsElement - // } else { - const type = typeof v - switch(type) { - case 'object': - return selectObject(v, direct) - case 'number': - return NumberElement - default: - return TextElement - } - // } + // if(k === 'txs' && v) { + // return TxsElement + // } else { + const type = typeof v; + switch (type) { + case 'object': + return selectObject(v, direct); + case 'number': + return NumberElement; + default: + return TextElement; + } + // } } function selectObject(v: Object, direct?: string) { - switch(true) { - case v instanceof Long: - return NumberElement - case v instanceof Uint8Array: - return UInt8Array - case Array.isArray(v): - return ArrayElement - case direct === 'horizontal': - return ObjectHorizontalElement - default: - return ObjectElement - } -} \ No newline at end of file + switch (true) { + case v instanceof Long: + return NumberElement; + case v instanceof Uint8Array: + return UInt8Array; + case Array.isArray(v): + return ArrayElement; + case direct === 'horizontal': + return ObjectHorizontalElement; + default: + return ObjectElement; + } +} diff --git a/src/components/icons/IconCommunity.vue b/src/components/icons/IconCommunity.vue index 2dc8b055..ea8ddefb 100644 --- a/src/components/icons/IconCommunity.vue +++ b/src/components/icons/IconCommunity.vue @@ -1,5 +1,10 @@ \ No newline at end of file + diff --git a/src/layouts/components/ChainProfile.vue b/src/layouts/components/ChainProfile.vue index e019a8c7..66b81d0e 100644 --- a/src/layouts/components/ChainProfile.vue +++ b/src/layouts/components/ChainProfile.vue @@ -1,61 +1,72 @@ + {{ + baseStore.latest.block?.header?.chain_id || chainStore.chainName || '' + }} + + {{ chainStore.connErr || chainStore.endpoint.address }} diff --git a/src/layouts/components/DefaultLayout.vue b/src/layouts/components/DefaultLayout.vue index bb128f87..a0bf2b9c 100644 --- a/src/layouts/components/DefaultLayout.vue +++ b/src/layouts/components/DefaultLayout.vue @@ -1,4 +1,5 @@ diff --git a/src/layouts/components/NavBarNotifications.vue b/src/layouts/components/NavBarNotifications.vue index e5440054..cfb91ac3 100644 --- a/src/layouts/components/NavBarNotifications.vue +++ b/src/layouts/components/NavBarNotifications.vue @@ -1,12 +1,12 @@ diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index 05a1165c..003878e3 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -1,212 +1,234 @@ -import { useBlockchain, useCoingecko, useBaseStore, useBankStore, useFormatter, useGovStore } from "@/stores"; -import { useDistributionStore } from "@/stores/useDistributionStore"; -import { useMintStore } from "@/stores/useMintStore"; -import { useStakingStore } from "@/stores/useStakingStore"; -import type { GovProposal, PaginatedProposals, Tally } from "@/types"; -import numeral from "numeral"; -import { defineStore } from "pinia"; +import { + useBlockchain, + useCoingecko, + useBaseStore, + useBankStore, + useFormatter, + useGovStore, +} from '@/stores'; +import { useDistributionStore } from '@/stores/useDistributionStore'; +import { useMintStore } from '@/stores/useMintStore'; +import { useStakingStore } from '@/stores/useStakingStore'; +import type { GovProposal, PaginatedProposals, Tally } from '@/types'; +import numeral from 'numeral'; +import { defineStore } from 'pinia'; function colorMap(color: string) { - switch (color) { - case 'yellow': - return 'warning' - case 'green': - return 'success' - default: - return 'secondary' - } + switch (color) { + case 'yellow': + return 'warning'; + case 'green': + return 'success'; + default: + return 'secondary'; + } } export const useIndexModule = defineStore('module-index', { - state: () => { - return { - days: 14, - tickerIndex: 0, - coinInfo: { - name: '', - symbol: '', - description: { - en: '' - }, - categories: [] as string[], - market_cap_rank: 0, - links: { - twitter_screen_name: '', - homepage: [] as string[], - repos_url: { - github: [] - }, - telegram_channel_identifier: '' - }, - market_data: { - price_change_percentage_24h: 0 - }, - tickers: [] as { - market: { - name: string, - identifier: string, - }, - coin_id: string, - target_coin_id: string, - trust_score: string, - trade_url: string, - converted_last: { - btc: number, - eth: number, - usd: number, - }, - base: string, - target: string, - }[] - }, - marketData: { - market_caps: [], - prices: [] as number[], - total_volumes: [] as number[], - }, - communityPool: [] as {amount: string, denom: string}[], - proposals: {} as PaginatedProposals, - tally: {} as Record - } + state: () => { + return { + days: 14, + tickerIndex: 0, + coinInfo: { + name: '', + symbol: '', + description: { + en: '', + }, + categories: [] as string[], + market_cap_rank: 0, + links: { + twitter_screen_name: '', + homepage: [] as string[], + repos_url: { + github: [], + }, + telegram_channel_identifier: '', + }, + market_data: { + price_change_percentage_24h: 0, + }, + tickers: [] as { + market: { + name: string; + identifier: string; + }; + coin_id: string; + target_coin_id: string; + trust_score: string; + trade_url: string; + converted_last: { + btc: number; + eth: number; + usd: number; + }; + base: string; + target: string; + }[], + }, + marketData: { + market_caps: [], + prices: [] as number[], + total_volumes: [] as number[], + }, + communityPool: [] as { amount: string; denom: string }[], + proposals: {} as PaginatedProposals, + tally: {} as Record, + }; + }, + getters: { + blockchain() { + const chain = useBlockchain(); + return chain.current; }, - getters: { - blockchain() { - const chain = useBlockchain() - return chain.current - }, - coingecko() { - return useCoingecko() - }, - bankStore() { - return useBankStore() - }, - twitter() : string { - return `https://twitter.com/${this.coinInfo.links.twitter_screen_name}` - }, - homepage(): string { - const [page1, page2, page3] = this.coinInfo.links?.homepage - return page1 || page2 || page3 - }, - github(): string { - const [page1, page2, page3] = this.coinInfo.links?.repos_url?.github - return page1 || page2 || page3 - }, - telegram() : string { - return `https://t.me/${this.coinInfo.links.telegram_channel_identifier}` - }, - - priceChange(): string { - const change = this.coinInfo.market_data?.price_change_percentage_24h || 0 - return numeral(change).format('+0.[00]') - }, - - priceColor() : string { - const change = this.coinInfo.market_data?.price_change_percentage_24h || 0 - switch (true) { - case change > 0: - return 'text-success' - case change < 0: - return 'text-error' - default: - return '' - } - }, - trustColor() : string { - const change = this.coinInfo.tickers[this.tickerIndex]?.trust_score - return colorMap(change) - }, - - pool() { - const staking = useStakingStore() - return staking.pool - }, - - stats () { - const base = useBaseStore() - const bank = useBankStore() - const staking = useStakingStore() - const mintStore = useMintStore() - const formatter = useFormatter() - - return [ - { - title: 'Height', - color: 'primary', - icon: 'mdi-pound', - stats: String(base.latest.block?.header?.height || 0), - change: 0, - }, - { - title: 'Validators', - color: 'error', - icon: 'mdi-human-queue', - stats: String(base.latest.block?.last_commit?.signatures.length || 0), - change: 0, - }, - { - title: 'Supply', - color: 'success', - icon: 'mdi-currency-usd', - stats: formatter.formatTokenAmount(bank.supply), - change: 0, - }, - { - title: 'Bonded Tokens', - color: 'warning', - icon: 'mdi-lock', - stats: formatter.formatTokenAmount({amount: this.pool.bonded_tokens, denom: staking.params.bond_denom }), - change: 0, - }, - { - title: 'Inflation', - color: 'success', - icon: 'mdi-chart-multiple', - stats: formatter.formatDecimalToPercent(mintStore.inflation), - change: 0, - }, - { - title: 'Community Pool', - color: 'primary', - icon: 'mdi-bank', - stats: formatter.formatTokens(this.communityPool?.filter(x => x.denom === staking.params.bond_denom)), - change: 0, - }, - ] - }, + coingecko() { + return useCoingecko(); }, - actions: { - async loadDashboard() { - this.$reset() - this.initCoingecko() - useMintStore().fetchInflation() - useDistributionStore().fetchCommunityPool().then(x => { - this.communityPool = x.pool.filter(t => t.denom.length < 10).map(t => ({ - amount: String(parseInt(t.amount)), - denom: t.denom - })) - }) - const gov = useGovStore() - gov.fetchProposals("2").then(x => { - this.proposals = x - }) + bankStore() { + return useBankStore(); + }, + twitter(): string { + return `https://twitter.com/${this.coinInfo.links.twitter_screen_name}`; + }, + homepage(): string { + const [page1, page2, page3] = this.coinInfo.links?.homepage; + return page1 || page2 || page3; + }, + github(): string { + const [page1, page2, page3] = this.coinInfo.links?.repos_url?.github; + return page1 || page2 || page3; + }, + telegram(): string { + return `https://t.me/${this.coinInfo.links.telegram_channel_identifier}`; + }, + + priceChange(): string { + const change = + this.coinInfo.market_data?.price_change_percentage_24h || 0; + return numeral(change).format('+0.[00]'); + }, + + priceColor(): string { + const change = + this.coinInfo.market_data?.price_change_percentage_24h || 0; + switch (true) { + case change > 0: + return 'text-success'; + case change < 0: + return 'text-error'; + default: + return ''; + } + }, + trustColor(): string { + const change = this.coinInfo.tickers[this.tickerIndex]?.trust_score; + return colorMap(change); + }, + + pool() { + const staking = useStakingStore(); + return staking.pool; + }, + + stats() { + const base = useBaseStore(); + const bank = useBankStore(); + const staking = useStakingStore(); + const mintStore = useMintStore(); + const formatter = useFormatter(); + + return [ + { + title: 'Height', + color: 'primary', + icon: 'mdi-pound', + stats: String(base.latest.block?.header?.height || 0), + change: 0, }, - tickerColor(color: string) { - return colorMap(color) - }, - initCoingecko() { - this.tickerIndex = 0 - const [firstAsset] = this.blockchain?.assets || [] - if (firstAsset && firstAsset.coingecko_id) { - this.coingecko.getCoinInfo(firstAsset.coingecko_id).then(x => { - this.coinInfo = x - }) - this.coingecko.getMarketChart(this.days, firstAsset.coingecko_id).then(x => { - this.marketData = x - }) - } + { + title: 'Validators', + color: 'error', + icon: 'mdi-human-queue', + stats: String(base.latest.block?.last_commit?.signatures.length || 0), + change: 0, }, - selectTicker(i: number) { - this.tickerIndex = i - } - } -}) \ No newline at end of file + { + title: 'Supply', + color: 'success', + icon: 'mdi-currency-usd', + stats: formatter.formatTokenAmount(bank.supply), + change: 0, + }, + { + title: 'Bonded Tokens', + color: 'warning', + icon: 'mdi-lock', + stats: formatter.formatTokenAmount({ + amount: this.pool.bonded_tokens, + denom: staking.params.bond_denom, + }), + change: 0, + }, + { + title: 'Inflation', + color: 'success', + icon: 'mdi-chart-multiple', + stats: formatter.formatDecimalToPercent(mintStore.inflation), + change: 0, + }, + { + title: 'Community Pool', + color: 'primary', + icon: 'mdi-bank', + stats: formatter.formatTokens( + this.communityPool?.filter( + (x) => x.denom === staking.params.bond_denom + ) + ), + change: 0, + }, + ]; + }, + }, + actions: { + async loadDashboard() { + this.$reset(); + this.initCoingecko(); + useMintStore().fetchInflation(); + useDistributionStore() + .fetchCommunityPool() + .then((x) => { + this.communityPool = x.pool + .filter((t) => t.denom.length < 10) + .map((t) => ({ + amount: String(parseInt(t.amount)), + denom: t.denom, + })); + }); + const gov = useGovStore(); + gov.fetchProposals('2').then((x) => { + this.proposals = x; + }); + }, + tickerColor(color: string) { + return colorMap(color); + }, + initCoingecko() { + this.tickerIndex = 0; + const [firstAsset] = this.blockchain?.assets || []; + if (firstAsset && firstAsset.coingecko_id) { + this.coingecko.getCoinInfo(firstAsset.coingecko_id).then((x) => { + this.coinInfo = x; + }); + this.coingecko + .getMarketChart(this.days, firstAsset.coingecko_id) + .then((x) => { + this.marketData = x; + }); + } + }, + selectTicker(i: number) { + this.tickerIndex = i; + }, + }, +}); diff --git a/src/modules/[chain]/params/index.vue b/src/modules/[chain]/params/index.vue index 7a67439e..80276c84 100644 --- a/src/modules/[chain]/params/index.vue +++ b/src/modules/[chain]/params/index.vue @@ -1,15 +1,14 @@ diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index f9d6572b..d90a9823 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -1,275 +1,399 @@ diff --git a/src/modules/[chain]/statesync/index.vue b/src/modules/[chain]/statesync/index.vue index f5d79060..296be8bf 100644 --- a/src/modules/[chain]/statesync/index.vue +++ b/src/modules/[chain]/statesync/index.vue @@ -5,76 +5,97 @@ import { fromBase64, toHex } from '@cosmjs/encoding'; import { onMounted, ref } from 'vue'; import { computed } from 'vue'; -const props = defineProps(['hash', 'chain']) -const blockchain = useBlockchain() -const base = useBaseStore() -const nodeInfo = ref({} as NodeInfo) +const props = defineProps(['hash', 'chain']); +const blockchain = useBlockchain(); +const base = useBaseStore(); +const nodeInfo = ref({} as NodeInfo); -const state = computed(()=> { - const rpcs = blockchain.current?.endpoints?.rpc?.map(x => x.address).join(',') - return `[statesync] +const state = computed(() => { + const rpcs = blockchain.current?.endpoints?.rpc + ?.map((x) => x.address) + .join(','); + return `[statesync] enable = true rpc_servers = "${rpcs}" trust_height = ${base.latest.block?.header?.height || 'loading'} -trust_hash = "${base.latest.block_id? toHex(fromBase64(base.latest.block_id?.hash)) : ''}" +trust_hash = "${ + base.latest.block_id ? toHex(fromBase64(base.latest.block_id?.hash)) : '' + }" trust_period = "168h" # 2/3 of unbonding time" -` -}) +`; +}); -const appName = computed(()=> { - return nodeInfo.value.application_version?.app_name || "gaiad" -}) +const appName = computed(() => { + return nodeInfo.value.application_version?.app_name || 'gaiad'; +}); onMounted(() => { - blockchain.rpc.getBaseNodeInfo().then(x => { - console.log('node info', x) - nodeInfo.value = x - }) -}) - + blockchain.rpc.getBaseNodeInfo().then((x) => { + console.log('node info', x); + nodeInfo.value = x; + }); +}); @@ -83,4 +104,4 @@ snapshot-keep-recent = 2"> i18n: 'state-sync' } } - \ No newline at end of file + diff --git a/src/modules/[chain]/tx/[hash].vue b/src/modules/[chain]/tx/[hash].vue index 681df2dc..7d17492e 100644 --- a/src/modules/[chain]/tx/[hash].vue +++ b/src/modules/[chain]/tx/[hash].vue @@ -6,58 +6,99 @@ import type { Tx, TxResponse } from '@/types'; import VueJsonPretty from 'vue-json-pretty'; import 'vue-json-pretty/lib/styles.css'; -const props = defineProps(['hash', 'chain']) +const props = defineProps(['hash', 'chain']); -const blockchain = useBlockchain() -const format = useFormatter() -const tx = ref({} as { +const blockchain = useBlockchain(); +const format = useFormatter(); +const tx = ref( + {} as { tx: Tx; - tx_response: TxResponse -}) -if(props.hash) { - blockchain.rpc.getTx(props.hash).then(x => tx.value = x) + tx_response: TxResponse; + } +); +if (props.hash) { + blockchain.rpc.getTx(props.hash).then((x) => (tx.value = x)); } const messages = computed(() => { - return tx.value.tx?.body?.messages||[] -}) + return tx.value.tx?.body?.messages || []; +}); \ No newline at end of file + + + + + + + diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue index ef52fe40..ba164c0d 100644 --- a/src/modules/[chain]/uptime/index.vue +++ b/src/modules/[chain]/uptime/index.vue @@ -1,107 +1,162 @@ @@ -113,7 +168,7 @@ watchEffect(() => { \ No newline at end of file + diff --git a/src/modules/wallet/test.vue b/src/modules/wallet/test.vue index cc5cb93b..47f1a442 100644 --- a/src/modules/wallet/test.vue +++ b/src/modules/wallet/test.vue @@ -2,14 +2,14 @@ import { CosmosRestClient } from '@/libs/client'; async function tt() { - const address = "echelon1uattqtrtv8944qkmh44ll97qjacj6tgrekqzm9" - const validator = "echelonvaloper1uattqtrtv8944qkmh44ll97qjacj6tgr2cupk4" - const client = new CosmosRestClient("https://api.ech.network") + const address = 'echelon1uattqtrtv8944qkmh44ll97qjacj6tgrekqzm9'; + const validator = 'echelonvaloper1uattqtrtv8944qkmh44ll97qjacj6tgr2cupk4'; + const client = new CosmosRestClient('https://api.ech.network'); let response = await client.getBaseBlockLatest(); - console.log('response:', response) + console.log('response:', response); } -tt() +tt(); \ No newline at end of file + diff --git a/src/pages/[...all].vue b/src/pages/[...all].vue index e5a39b58..23d3ee8f 100644 --- a/src/pages/[...all].vue +++ b/src/pages/[...all].vue @@ -1,35 +1,50 @@ diff --git a/src/pages/index.vue b/src/pages/index.vue index 202275b5..a868abbd 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -34,7 +34,7 @@ const chain = useBlockchain();

Ping dashboard

-
+
Beta
diff --git a/src/pages/second-page.vue b/src/pages/second-page.vue index c89c7827..7291f3df 100644 --- a/src/pages/second-page.vue +++ b/src/pages/second-page.vue @@ -4,15 +4,14 @@ This is your second page. Chocolate sesame snaps pie carrot cake pastry pie lollipop muffin. - Carrot cake dragée chupa chups jujubes. Macaroon liquorice cookie - wafer tart marzipan bonbon. Gingerbread jelly-o dragée - chocolate. + Carrot cake dragée chupa chups jujubes. Macaroon liquorice cookie wafer + tart marzipan bonbon. Gingerbread jelly-o dragée chocolate. - meta: - layout: blank - bgColor: yellow - \ No newline at end of file +meta: + layout: blank + bgColor: yellow +
diff --git a/src/plugins/i18n/index.ts b/src/plugins/i18n/index.ts index 89c684d8..7641c067 100644 --- a/src/plugins/i18n/index.ts +++ b/src/plugins/i18n/index.ts @@ -1,15 +1,15 @@ -import { createI18n } from 'vue-i18n' +import { createI18n } from 'vue-i18n'; const messages = Object.fromEntries( Object.entries( // eslint-disable-next-line @typescript-eslint/no-explicit-any - import.meta.glob<{ default: any }>('./locales/*.json', { eager: true })) - .map(([key, value]) => [key.slice(10, -5), value.default]), -) + import.meta.glob<{ default: any }>('./locales/*.json', { eager: true }) + ).map(([key, value]) => [key.slice(10, -5), value.default]) +); export default createI18n({ legacy: false, locale: localStorage.getItem('lang') || 'en', fallbackLocale: 'en', messages, -}) +}); diff --git a/src/plugins/pinia/ClientProperties.ts b/src/plugins/pinia/ClientProperties.ts index 0de163e8..8e699525 100644 --- a/src/plugins/pinia/ClientProperties.ts +++ b/src/plugins/pinia/ClientProperties.ts @@ -1,11 +1,11 @@ -import type { CosmosRestClient } from '@/libs/client' -import 'pinia' -import type { Ref } from 'vue' +import type { CosmosRestClient } from '@/libs/client'; +import 'pinia'; +import type { Ref } from 'vue'; declare module 'pinia' { export interface PiniaCustomProperties { // by using a setter we can allow both strings and refs - set rpc(value: CosmosRestClient | Ref) - get rpc(): CosmosRestClient + set rpc(value: CosmosRestClient | Ref); + get rpc(): CosmosRestClient; } -} \ No newline at end of file +} diff --git a/src/stores/index.ts b/src/stores/index.ts index 5b19cadb..b204e90e 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1,12 +1,12 @@ -export * from './useBankStore' -export * from './useBlockchain' -export * from './useCoinGecko' -export * from './useDashboard' -export * from './useBaseStore' -export * from './useFormatter' -export * from './useGovStore' -export * from './useMintStore' -export * from './useStakingStore' -export * from './useDistributionStore' -export * from './useParamsStore' -export * from './useWalletStore' \ No newline at end of file +export * from './useBankStore'; +export * from './useBlockchain'; +export * from './useCoinGecko'; +export * from './useDashboard'; +export * from './useBaseStore'; +export * from './useFormatter'; +export * from './useGovStore'; +export * from './useMintStore'; +export * from './useStakingStore'; +export * from './useDistributionStore'; +export * from './useParamsStore'; +export * from './useWalletStore'; diff --git a/src/stores/template.ts b/src/stores/template.ts index 136e0905..0ab51adf 100644 --- a/src/stores/template.ts +++ b/src/stores/template.ts @@ -1,13 +1,9 @@ -import { defineStore } from "pinia"; +import { defineStore } from 'pinia'; export const useStoreName = defineStore('bankstore', { - state: () => { - return { - } - }, - getters: { - - }, - actions: { - } -}) \ No newline at end of file + state: () => { + return {}; + }, + getters: {}, + actions: {}, +}); diff --git a/src/stores/useBankStore.ts b/src/stores/useBankStore.ts index 3d792f56..d5064915 100644 --- a/src/stores/useBankStore.ts +++ b/src/stores/useBankStore.ts @@ -1,48 +1,50 @@ -import { defineStore } from "pinia"; +import { defineStore } from 'pinia'; -import { useBlockchain } from "./useBlockchain"; -import { useStakingStore } from "./useStakingStore"; -import type { Coin, DenomTrace } from "@/types"; +import { useBlockchain } from './useBlockchain'; +import { useStakingStore } from './useStakingStore'; +import type { Coin, DenomTrace } from '@/types'; export const useBankStore = defineStore('bankstore', { - state: () => { - return { - supply: {} as Coin, - balances: {} as Record, - totalSupply: {supply: [] as Coin[]} , - } + state: () => { + return { + supply: {} as Coin, + balances: {} as Record, + totalSupply: { supply: [] as Coin[] }, + }; + }, + getters: { + blockchain() { + return useBlockchain(); }, - getters: { - blockchain() { - return useBlockchain() - }, - staking() { - return useStakingStore() - } + staking() { + return useStakingStore(); }, - actions: { - initial() { - this.$reset() - this.supply = {} as Coin - const denom = this.staking.params.bond_denom || this.blockchain.current?.assets[0].base - if(denom) { - this.blockchain.rpc.getBankSupplyByDenom(denom).then(res => { - if(res.amount) this.supply = res.amount - }) - } - }, - async fetchSupply(denom: string) { - return this.blockchain.rpc.getBankSupplyByDenom( denom ) - }, - async fetchDenomTrace(denom: string) { - const hash = denom.replace("ibc/", "") - let trace = this.ibcDenoms[hash] - if(!trace) { - trace = (await this.blockchain.rpc.getIBCAppTransferDenom( hash )).denom_trace - this.ibcDenoms[hash] = trace - } - return trace - } - } -}) - + }, + actions: { + initial() { + this.$reset(); + this.supply = {} as Coin; + const denom = + this.staking.params.bond_denom || + this.blockchain.current?.assets[0].base; + if (denom) { + this.blockchain.rpc.getBankSupplyByDenom(denom).then((res) => { + if (res.amount) this.supply = res.amount; + }); + } + }, + async fetchSupply(denom: string) { + return this.blockchain.rpc.getBankSupplyByDenom(denom); + }, + async fetchDenomTrace(denom: string) { + const hash = denom.replace('ibc/', ''); + let trace = this.ibcDenoms[hash]; + if (!trace) { + trace = (await this.blockchain.rpc.getIBCAppTransferDenom(hash)) + .denom_trace; + this.ibcDenoms[hash] = trace; + } + return trace; + }, + }, +}); diff --git a/src/stores/useBaseStore.ts b/src/stores/useBaseStore.ts index bdc03f01..c66acb95 100644 --- a/src/stores/useBaseStore.ts +++ b/src/stores/useBaseStore.ts @@ -1,65 +1,74 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "@/stores"; -import dayjs from "dayjs"; -import type { Block } from "@/types"; +import { defineStore } from 'pinia'; +import { useBlockchain } from '@/stores'; +import dayjs from 'dayjs'; +import type { Block } from '@/types'; export const useBaseStore = defineStore('baseStore', { - state: () => { - return { - earlest: {} as Block, - latest: {} as Block, - recents: [] as Block[] + state: () => { + return { + earlest: {} as Block, + latest: {} as Block, + recents: [] as Block[], + }; + }, + getters: { + blocktime(): number { + if (this.earlest && this.latest) { + if ( + this.latest.block?.header?.height !== + this.earlest.block?.header?.height + ) { + const diff = dayjs(this.latest.block?.header?.time).diff( + this.earlest.block?.header?.time + ); + return diff; } + } + return 6000; }, - getters: { - blocktime(): number { - if(this.earlest && this.latest) { - if(this.latest.block?.header?.height !== this.earlest.block?.header?.height) { - const diff = dayjs(this.latest.block?.header?.time).diff(this.earlest.block?.header?.time) - return diff - } - } - return 6000 - }, - blockchain() { - return useBlockchain() - } + blockchain() { + return useBlockchain(); + }, + }, + actions: { + async initial() { + this.fetchLatest(); + }, + async clearRecentBlocks() { + this.recents = []; + }, + async fetchLatest() { + this.latest = await this.blockchain.rpc.getBaseBlockLatest(); + if ( + !this.earlest || + this.earlest.block?.header?.chain_id != + this.latest.block?.header?.chain_id + ) { + //reset earlest and recents + this.earlest = this.latest; + this.recents = []; + } + if (this.recents.length >= 50) { + this.recents.pop(); + } + this.recents.push(this.latest); + return this.latest; }, - actions: { - async initial() { - this.fetchLatest() - }, - async clearRecentBlocks() { - this.recents = [] - }, - async fetchLatest() { - this.latest = await this.blockchain.rpc.getBaseBlockLatest() - if(!this.earlest || this.earlest.block?.header?.chain_id != this.latest.block?.header?.chain_id) { - //reset earlest and recents - this.earlest = this.latest - this.recents = [] - } - if(this.recents.length>= 50) { - this.recents.pop() - } - this.recents.push(this.latest) - return this.latest - }, - async fetchValidatorByHeight(height?: number, offset = 0) { - return this.blockchain.rpc.getBaseValidatorsetAt(String(height)) - }, - async fetchLatestValidators(offset = 0) { - return this.blockchain.rpc.getBaseValidatorsetLatest() - }, - async fetchBlock(height?: number) { - return this.blockchain.rpc.getBaseBlockAt(String(height)) - }, - async fetchAbciInfo() { - return this.blockchain.rpc.getBaseNodeInfo() - } - // async fetchNodeInfo() { - // return this.blockchain.rpc.no() - // } - } -}) \ No newline at end of file + async fetchValidatorByHeight(height?: number, offset = 0) { + return this.blockchain.rpc.getBaseValidatorsetAt(String(height)); + }, + async fetchLatestValidators(offset = 0) { + return this.blockchain.rpc.getBaseValidatorsetLatest(); + }, + async fetchBlock(height?: number) { + return this.blockchain.rpc.getBaseBlockAt(String(height)); + }, + async fetchAbciInfo() { + return this.blockchain.rpc.getBaseNodeInfo(); + }, + // async fetchNodeInfo() { + // return this.blockchain.rpc.no() + // } + }, +}); diff --git a/src/stores/useCoinGecko.ts b/src/stores/useCoinGecko.ts index 4032b020..9ee2b7fa 100644 --- a/src/stores/useCoinGecko.ts +++ b/src/stores/useCoinGecko.ts @@ -1,51 +1,54 @@ -import { defineStore } from "pinia"; -import { get } from '../libs/http' -import type { LoadingStatus } from "./useDashboard"; +import { defineStore } from 'pinia'; +import { get } from '../libs/http'; +import type { LoadingStatus } from './useDashboard'; export interface PriceMeta { - usd?: string, - usd_24h_change?: string, - cny?: string, - cny_24h_change? : string, - eur?: string, - eur_24h_change?: string, + usd?: string; + usd_24h_change?: string; + cny?: string; + cny_24h_change?: string; + eur?: string; + eur_24h_change?: string; } -const LocalStoreKey = 'currency' +const LocalStoreKey = 'currency'; export const useCoingecko = defineStore('coingecko', { - state: () => { - const currency = localStorage.getItem(LocalStoreKey) - return { - currency, // secondary currency - loadStatus: {} as Record, - prices: {} as Record, - marketChart: {} - } + state: () => { + const currency = localStorage.getItem(LocalStoreKey); + return { + currency, // secondary currency + loadStatus: {} as Record, + prices: {} as Record, + marketChart: {}, + }; + }, + getters: {}, + + actions: { + getMarketChart(days = 30, coinId = 'cosmos') { + return get( + `https://api.coingecko.com/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}` + ); }, - getters: { - + + fetchCoinPrice(ids: string[]) { + const url = `https://api.coingecko.com/api/v3/simple/price?include_24hr_change=true&vs_currencies=${[ + 'usd', + this.currency, + ].join(',')}&ids=${ids.join(',')}`; + get(url).then((data) => { + this.prices = { ...this.prices, ...data }; + }); }, - - actions: { - getMarketChart(days = 30, coinId = 'cosmos') { - return get(`https://api.coingecko.com/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}`) - }, - - fetchCoinPrice(ids: string[]) { - const url = `https://api.coingecko.com/api/v3/simple/price?include_24hr_change=true&vs_currencies=${['usd', this.currency].join(',')}&ids=${ids.join(',')}` - get(url).then(data => { - this.prices = {...this.prices, ...data} - }) - }, - getCoinInfo(coinId: string) { - return get(`https://api.coingecko.com/api/v3/coins/${coinId}`) - }, - setSecondaryCurrency(currency: string) { - if(currency !== 'usd') { - localStorage.setItem(LocalStoreKey, currency) - this.currency = currency - } - } - } -}) \ No newline at end of file + getCoinInfo(coinId: string) { + return get(`https://api.coingecko.com/api/v3/coins/${coinId}`); + }, + setSecondaryCurrency(currency: string) { + if (currency !== 'usd') { + localStorage.setItem(LocalStoreKey, currency); + this.currency = currency; + } + }, + }, +}); diff --git a/src/stores/useDistributionStore.ts b/src/stores/useDistributionStore.ts index 950dcbbe..7784605c 100644 --- a/src/stores/useDistributionStore.ts +++ b/src/stores/useDistributionStore.ts @@ -1,19 +1,18 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; export const useDistributionStore = defineStore('distributionStore', { - state: () => { - return { - } + state: () => { + return {}; + }, + getters: { + blockchain() { + return useBlockchain(); }, - getters: { - blockchain() { - return useBlockchain() - } + }, + actions: { + async fetchCommunityPool() { + return this.blockchain.rpc.getDistributionCommunityPool(); }, - actions: { - async fetchCommunityPool() { - return this.blockchain.rpc.getDistributionCommunityPool() - } - } -}) \ No newline at end of file + }, +}); diff --git a/src/stores/useFormatter.ts b/src/stores/useFormatter.ts index f931444c..545e6312 100644 --- a/src/stores/useFormatter.ts +++ b/src/stores/useFormatter.ts @@ -1,23 +1,23 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; -import numeral from "numeral"; +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; +import numeral from 'numeral'; import dayjs from 'dayjs'; -import duration from 'dayjs/plugin/duration' -import relativeTime from 'dayjs/plugin/relativeTime' -import updateLocale from 'dayjs/plugin/updateLocale' -import utc from 'dayjs/plugin/utc' -import localeData from 'dayjs/plugin/localeData' -import { useStakingStore } from "./useStakingStore"; -import { fromBase64, fromBech32, fromHex, toHex } from "@cosmjs/encoding"; -import { consensusPubkeyToHexAddress } from "@/libs"; -import { useBankStore } from "./useBankStore"; -import type { DenomTrace } from "@/types"; +import duration from 'dayjs/plugin/duration'; +import relativeTime from 'dayjs/plugin/relativeTime'; +import updateLocale from 'dayjs/plugin/updateLocale'; +import utc from 'dayjs/plugin/utc'; +import localeData from 'dayjs/plugin/localeData'; +import { useStakingStore } from './useStakingStore'; +import { fromBase64, fromBech32, fromHex, toHex } from '@cosmjs/encoding'; +import { consensusPubkeyToHexAddress } from '@/libs'; +import { useBankStore } from './useBankStore'; +import type { DenomTrace } from '@/types'; -dayjs.extend(localeData) -dayjs.extend(duration) -dayjs.extend(relativeTime) -dayjs.extend(updateLocale) -dayjs.extend(utc) +dayjs.extend(localeData); +dayjs.extend(duration); +dayjs.extend(relativeTime); +dayjs.extend(updateLocale); +dayjs.extend(utc); dayjs.updateLocale('en', { relativeTime: { future: 'in %s', @@ -34,168 +34,190 @@ dayjs.updateLocale('en', { y: 'a year', yy: '%d years', }, -}) +}); export const useFormatter = defineStore('formatter', { - state: () => { - return { - ibcDenoms: {} as Record - } + state: () => { + return { + ibcDenoms: {} as Record, + }; + }, + getters: { + blockchain() { + return useBlockchain(); }, - getters: { - blockchain() { - return useBlockchain() - }, - staking() { - return useStakingStore() - }, - useBank() { - return useBankStore() - } + staking() { + return useStakingStore(); }, - actions: { - async fetchDenomTrace(denom: string) { - const hash = denom.replace("ibc/", "") - let trace = this.ibcDenoms[hash] - if(!trace) { - trace = (await this.blockchain.rpc.getIBCAppTransferDenom( hash )).denom_trace - this.ibcDenoms[hash] = trace - } - return trace - }, - formatTokenAmount(token: {denom: string, amount: string;}) { - return this.formatToken(token, false) - }, - formatToken2(token: { denom: string, amount: string;}, withDenom = true) { - return this.formatToken(token, true, '0,0.[00]') - }, - formatToken(token: { denom: string, amount: string;}, withDenom = true, fmt='0.0a') : string { - if(token && token.amount) { - let amount = Number(token.amount) - let denom = token.denom + useBank() { + return useBankStore(); + }, + }, + actions: { + async fetchDenomTrace(denom: string) { + const hash = denom.replace('ibc/', ''); + let trace = this.ibcDenoms[hash]; + if (!trace) { + trace = (await this.blockchain.rpc.getIBCAppTransferDenom(hash)) + .denom_trace; + this.ibcDenoms[hash] = trace; + } + return trace; + }, + formatTokenAmount(token: { denom: string; amount: string }) { + return this.formatToken(token, false); + }, + formatToken2(token: { denom: string; amount: string }, withDenom = true) { + return this.formatToken(token, true, '0,0.[00]'); + }, + formatToken( + token: { denom: string; amount: string }, + withDenom = true, + fmt = '0.0a' + ): string { + if (token && token.amount) { + let amount = Number(token.amount); + let denom = token.denom; - if( denom && denom.startsWith("ibc/")) { - let ibcDenom = this.ibcDenoms[denom.replace("ibc/", "")] - if(ibcDenom) { - denom = ibcDenom.base_denom - } - } + if (denom && denom.startsWith('ibc/')) { + let ibcDenom = this.ibcDenoms[denom.replace('ibc/', '')]; + if (ibcDenom) { + denom = ibcDenom.base_denom; + } + } - const conf = this.blockchain.current?.assets?.find(x => x.base === token.denom || x.base.denom === token.denom) - if(conf) { - let unit = {exponent: 6, denom: ''} - // find the max exponent for display - conf.denom_units.forEach(x => { - if(x.exponent >= unit.exponent) { - unit = x - } - }) - if(unit && unit.exponent > 0) { - amount = amount / Math.pow(10, unit.exponent || 6) - denom = unit.denom.toUpperCase() - } - } - return `${numeral(amount).format(fmt)} ${withDenom ? denom.substring(0, 10): ''}` - } - return '-' - }, - formatTokens(tokens?: { denom: string, amount: string;}[], withDenom = true, fmt='0.0a') : string { - if(!tokens) return '' - return tokens.map(x => this.formatToken(x, withDenom, fmt)).join(', ') - }, - calculateBondedRatio(pool: {bonded_tokens: string, not_bonded_tokens: string}|undefined) { - if(pool && pool.bonded_tokens) { - const b = Number(pool.bonded_tokens) - const nb = Number(pool.not_bonded_tokens) - const p = b/(b+nb) - return numeral(p).format('0.[00]%') + const conf = this.blockchain.current?.assets?.find( + (x) => x.base === token.denom || x.base.denom === token.denom + ); + if (conf) { + let unit = { exponent: 6, denom: '' }; + // find the max exponent for display + conf.denom_units.forEach((x) => { + if (x.exponent >= unit.exponent) { + unit = x; } - return '-' - }, - validator(address: string) { - if(!address) return address - - const txt = toHex(fromBase64(address)).toUpperCase() - const validator = this.staking.validators.find(x => consensusPubkeyToHexAddress(x.consensus_pubkey) === txt) - return validator?.description?.moniker - }, - validatorFromBech32(address: string) { - if(!address) return address - const validator = this.staking.validators.find(x => x.operator_address === address) - return validator?.description?.moniker - }, - calculatePercent(input?: string|number, total?: string|number ) { - if(!input || !total) return '0' - const percent = Number(input)/Number(total) - return numeral(percent>0.0001?percent: 0).format("0.[00]%") - }, - formatDecimalToPercent(decimal: string) { - return numeral(decimal).format('0.[00]%') - }, - formatCommissionRate(rate?: string) { - if(!rate) return '-' - return this.percent(rate) - }, - percent(decimal?: string|number) { - return decimal ? numeral(decimal).format('0.[00]%') : '-' - }, - numberAndSign(input: number, fmt="+0,0") { - return numeral(input).format(fmt) - }, - toDay(time?: string, format = 'long') { - if(!time) return '' - if (format === 'long') { - return dayjs(time).format('YYYY-MM-DD HH:mm') - } - if (format === 'date') { - return dayjs(time).format('YYYY-MM-DD') - } - if (format === 'time') { - return dayjs(time).format('HH:mm:ss') - } - if (format === 'from') { - return dayjs(time).fromNow() - } - if (format === 'to') { - return dayjs(time).toNow() - } - return dayjs(time).format('YYYY-MM-DD HH:mm:ss') - }, - messages(msgs: {"@type": string}[]) { - if(msgs) { - const sum: Record = msgs.map(msg => { - return msg["@type"].substring(msg["@type"].lastIndexOf('.') + 1).replace('Msg', '') - }).reduce((s, c) => { - const sh: Record = s - if (sh[c]) { - sh[c] += 1 - } else { - sh[c] = 1 - } - return sh - }, {}) - const output: string[] = [] - Object.keys(sum).forEach(k => { - output.push(sum[k] > 1 ? `${k}×${sum[k]}` : k) - }) - return output.join(', ') - } - }, - multiLine(v: string) { - return v? v.replaceAll("\\n","\n"): "" - }, - hexToString(hex: string) { - if(hex) { - return new TextDecoder().decode(fromHex(hex)) - } - return "" - }, - base64ToString(hex: string) { - if(hex) { - return new TextDecoder().decode(fromBase64(hex)) - } - return "" - } - } -}) + }); + if (unit && unit.exponent > 0) { + amount = amount / Math.pow(10, unit.exponent || 6); + denom = unit.denom.toUpperCase(); + } + } + return `${numeral(amount).format(fmt)} ${ + withDenom ? denom.substring(0, 10) : '' + }`; + } + return '-'; + }, + formatTokens( + tokens?: { denom: string; amount: string }[], + withDenom = true, + fmt = '0.0a' + ): string { + if (!tokens) return ''; + return tokens.map((x) => this.formatToken(x, withDenom, fmt)).join(', '); + }, + calculateBondedRatio( + pool: { bonded_tokens: string; not_bonded_tokens: string } | undefined + ) { + if (pool && pool.bonded_tokens) { + const b = Number(pool.bonded_tokens); + const nb = Number(pool.not_bonded_tokens); + const p = b / (b + nb); + return numeral(p).format('0.[00]%'); + } + return '-'; + }, + validator(address: string) { + if (!address) return address; + const txt = toHex(fromBase64(address)).toUpperCase(); + const validator = this.staking.validators.find( + (x) => consensusPubkeyToHexAddress(x.consensus_pubkey) === txt + ); + return validator?.description?.moniker; + }, + validatorFromBech32(address: string) { + if (!address) return address; + const validator = this.staking.validators.find( + (x) => x.operator_address === address + ); + return validator?.description?.moniker; + }, + calculatePercent(input?: string | number, total?: string | number) { + if (!input || !total) return '0'; + const percent = Number(input) / Number(total); + return numeral(percent > 0.0001 ? percent : 0).format('0.[00]%'); + }, + formatDecimalToPercent(decimal: string) { + return numeral(decimal).format('0.[00]%'); + }, + formatCommissionRate(rate?: string) { + if (!rate) return '-'; + return this.percent(rate); + }, + percent(decimal?: string | number) { + return decimal ? numeral(decimal).format('0.[00]%') : '-'; + }, + numberAndSign(input: number, fmt = '+0,0') { + return numeral(input).format(fmt); + }, + toDay(time?: string, format = 'long') { + if (!time) return ''; + if (format === 'long') { + return dayjs(time).format('YYYY-MM-DD HH:mm'); + } + if (format === 'date') { + return dayjs(time).format('YYYY-MM-DD'); + } + if (format === 'time') { + return dayjs(time).format('HH:mm:ss'); + } + if (format === 'from') { + return dayjs(time).fromNow(); + } + if (format === 'to') { + return dayjs(time).toNow(); + } + return dayjs(time).format('YYYY-MM-DD HH:mm:ss'); + }, + messages(msgs: { '@type': string }[]) { + if (msgs) { + const sum: Record = msgs + .map((msg) => { + return msg['@type'] + .substring(msg['@type'].lastIndexOf('.') + 1) + .replace('Msg', ''); + }) + .reduce((s, c) => { + const sh: Record = s; + if (sh[c]) { + sh[c] += 1; + } else { + sh[c] = 1; + } + return sh; + }, {}); + const output: string[] = []; + Object.keys(sum).forEach((k) => { + output.push(sum[k] > 1 ? `${k}×${sum[k]}` : k); + }); + return output.join(', '); + } + }, + multiLine(v: string) { + return v ? v.replaceAll('\\n', '\n') : ''; + }, + hexToString(hex: string) { + if (hex) { + return new TextDecoder().decode(fromHex(hex)); + } + return ''; + }, + base64ToString(hex: string) { + if (hex) { + return new TextDecoder().decode(fromBase64(hex)); + } + return ''; + }, + }, +}); diff --git a/src/stores/useGovStore.ts b/src/stores/useGovStore.ts index 75b91a09..056fdaf3 100644 --- a/src/stores/useGovStore.ts +++ b/src/stores/useGovStore.ts @@ -1,63 +1,64 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; -import type { PageRequest, PaginatedProposals } from "@/types"; -import { LoadingStatus } from "./useDashboard"; -import {reactive} from 'vue' +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; +import type { PageRequest, PaginatedProposals } from '@/types'; +import { LoadingStatus } from './useDashboard'; +import { reactive } from 'vue'; export const useGovStore = defineStore('govStore', { - state: () => { - return { - params: { - deposit: {}, - voting: {}, - tally: {}, - }, - proposals: {} as Record, - loading: {} as Record - } + state: () => { + return { + params: { + deposit: {}, + voting: {}, + tally: {}, + }, + proposals: {} as Record, + loading: {} as Record, + }; + }, + getters: { + blockchain() { + return useBlockchain(); }, - getters: { - blockchain() { - return useBlockchain() - } + }, + actions: { + initial() { + this.fetchParams(); }, - actions: { - initial() { - this.fetchParams() - }, - async fetchProposals( status: string, pagination?: PageRequest ) { - if(!this.loading[status]) { - this.loading[status] = LoadingStatus.Loading - const proposals = reactive(await this.blockchain.rpc.getGovProposals(status)) - if(status === '2') { - proposals.proposals.forEach(async(x1) => { - await this.fetchTally(x1.proposal_id).then(res => { - x1.final_tally_result = res?.tally - }) - }) - } - this.loading[status] = LoadingStatus.Loaded - this.proposals[status] = proposals - } - return this.proposals[status] - }, - async fetchParams() { - // this.blockchain.rpc.getGovParamsDeposit().then(x => { - // this.params.deposit = x.deposit - // }) - }, - async fetchTally(proposalId: string) { - return await this.blockchain.rpc.getGovProposalTally(proposalId) - }, - async fetchProposal(proposalId: string) { - return this.blockchain.rpc.getGovProposal(proposalId) - }, - async fetchProposalDeposits(proposalId: string) { - return this.blockchain.rpc.getGovProposalDeposits(proposalId) - }, - async fetchProposalVotes(proposalId: string, next_key?: string) { - return this.blockchain.rpc.getGovProposalVotes(proposalId, next_key) + async fetchProposals(status: string, pagination?: PageRequest) { + if (!this.loading[status]) { + this.loading[status] = LoadingStatus.Loading; + const proposals = reactive( + await this.blockchain.rpc.getGovProposals(status) + ); + if (status === '2') { + proposals.proposals.forEach(async (x1) => { + await this.fetchTally(x1.proposal_id).then((res) => { + x1.final_tally_result = res?.tally; + }); + }); } + this.loading[status] = LoadingStatus.Loaded; + this.proposals[status] = proposals; + } + return this.proposals[status]; }, - -}) + async fetchParams() { + // this.blockchain.rpc.getGovParamsDeposit().then(x => { + // this.params.deposit = x.deposit + // }) + }, + async fetchTally(proposalId: string) { + return await this.blockchain.rpc.getGovProposalTally(proposalId); + }, + async fetchProposal(proposalId: string) { + return this.blockchain.rpc.getGovProposal(proposalId); + }, + async fetchProposalDeposits(proposalId: string) { + return this.blockchain.rpc.getGovProposalDeposits(proposalId); + }, + async fetchProposalVotes(proposalId: string, next_key?: string) { + return this.blockchain.rpc.getGovProposalVotes(proposalId, next_key); + }, + }, +}); diff --git a/src/stores/useMintStore.ts b/src/stores/useMintStore.ts index 832bb7ee..0957ee2c 100644 --- a/src/stores/useMintStore.ts +++ b/src/stores/useMintStore.ts @@ -1,27 +1,30 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; export const useMintStore = defineStore('mintStore', { - state: () => { - return { - inflation: "0", - } + state: () => { + return { + inflation: '0', + }; + }, + getters: { + blockchain() { + return useBlockchain(); }, - getters: { - blockchain() { - return useBlockchain() - } + }, + actions: { + initial() { + this.fetchInflation(); }, - actions: { - initial() { - this.fetchInflation() - }, - async fetchInflation() { - this.blockchain.rpc.getMintInflation().then(x => { - this.inflation = x.inflation - }).catch(() => { - this.inflation = "0" - }) - } - } -}) \ No newline at end of file + async fetchInflation() { + this.blockchain.rpc + .getMintInflation() + .then((x) => { + this.inflation = x.inflation; + }) + .catch(() => { + this.inflation = '0'; + }); + }, + }, +}); diff --git a/src/stores/useParamsStore.ts b/src/stores/useParamsStore.ts index a59c56e6..75cf803a 100644 --- a/src/stores/useParamsStore.ts +++ b/src/stores/useParamsStore.ts @@ -1,195 +1,246 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; -import { percent,formatNumber,formatTokenAmount } from '@/libs/utils' +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; +import { percent, formatNumber, formatTokenAmount } from '@/libs/utils'; export interface stakingItem { - unbonding_time: string - max_validators: number - max_entries:number - historical_entries:number - bond_denom: string - min_commission_rate: string - min_self_delegation:string + unbonding_time: string; + max_validators: number; + max_entries: number; + historical_entries: number; + bond_denom: string; + min_commission_rate: string; + min_self_delegation: string; } -export const useParamStore = defineStore("paramstore", { - state: () => ({ - latestTime: '', - chain: { - title: '', - class: 'border-primary', - items: [ - { subtitle: 'height', icon: 'BoxIcon', color: 'light-success', value: '-' }, - { subtitle: 'bonded_and_supply', icon: 'DollarSignIcon', color: 'light-danger', value: '-' }, - { subtitle: 'bonded_ratio', icon: 'PercentIcon', color: 'light-warning', value: '-' }, - { subtitle: 'inflation', icon: 'TrendingUpIcon', color: 'light-primary', value: '-' }, - ], +export const useParamStore = defineStore('paramstore', { + state: () => ({ + latestTime: '', + chain: { + title: '', + class: 'border-primary', + items: [ + { + subtitle: 'height', + icon: 'BoxIcon', + color: 'light-success', + value: '-', }, - mint: { - title: 'Mint Parameters', - items: [] as Array, + { + subtitle: 'bonded_and_supply', + icon: 'DollarSignIcon', + color: 'light-danger', + value: '-', }, - staking: { - title: 'Staking Parameters', - items: [] as Array, + { + subtitle: 'bonded_ratio', + icon: 'PercentIcon', + color: 'light-warning', + value: '-', }, - distribution: { - title: 'Distribution Parameters', - items: [] as Array, - }, - slashing: { - title: 'Slashing Parameters', - items: [] as Array, - }, - gov: { - title: 'Governance Parameters', - items: [] as Array, - }, - appVersion: { - title: 'Application Version', - items: {}, - }, - nodeVersion: { - title: 'Node Information', - items: {}, - }, - }), - getters: { - blockchain() { - return useBlockchain() + { + subtitle: 'inflation', + icon: 'TrendingUpIcon', + color: 'light-primary', + value: '-', }, + ], }, - actions: { - initial() { - this.handleBaseBlockLatest() - // this.handleMintParam() - this.handleStakingParams() - this.handleSlashingParams() - this.handleDistributionParams() - this.handleGovernanceParams() - this.handleAbciInfo() - }, - async handleBaseBlockLatest() { - try { - const res = await this.getBaseTendermintBlockLatest() - const height = this.chain.items.findIndex(x => x.subtitle === 'height') - this.chain.title = `Chain ID: ${res.block.header.chain_id}` - this.chain.items[height].value = res.block.header.height - // if (timeIn(res.block.header.time, 3, 'm')) { - // this.syncing = true - // } else { - // this.syncing = false - // } - // this.latestTime = toDay(res.block.header.time, 'long') - this.latestTime = res.block.header.time - } catch (error) { - console.warn(error) - } - }, - async handleStakingParams() { - const res = await this.getStakingParams() - const bond_denom = res?.params.bond_denom - this.staking.items = Object.entries(res.params).map(([key, value]) => ({ subtitle:key, - value: value })).filter((item: any) => { - if (!['min_commission_rate','min_self_delegation'].includes(item.subtitle)) return item - }) - Promise.all([this.getStakingPool(), this.getBankTotal(bond_denom)]) - .then(resArr => { - const pool = resArr[0]?.pool - const amount =resArr[1]?.amount?.amount - const assets = this.blockchain.current?.assets - const bondedAndSupply = this.chain.items.findIndex(x => x.subtitle === 'bonded_and_supply') - this.chain.items[bondedAndSupply].value = `${formatNumber(formatTokenAmount(assets,pool.bonded_tokens, 2, bond_denom, false), true, 0)}/${formatNumber(formatTokenAmount(assets,amount, 2, bond_denom, false), true, 0)}` - const bondedRatio = this.chain.items.findIndex(x => x.subtitle === 'bonded_ratio') - this.chain.items[bondedRatio].value = `${percent(Number(pool.bonded_tokens) /Number(amount)) }%` - }) - }, - async handleMintParam() { - const excludes = this.blockchain.current?.excludes - if(excludes && excludes.indexOf('mint') > -1){ - return - } - // this.getMintingInflation().then(res => { - // const chainIndex = this.chain.items.findIndex(x => x.subtitle === 'inflation') - // this.chain.items[chainIndex].value = `${percent(res)}%` - // }) - const res = await this.getMintParam() - console.log(res, 'mint') - }, - async handleSlashingParams(){ - const res = await this.getSlashingParams() - this.slashing.items = Object.entries(res.params).map(([key, value]) => ({ subtitle:key, - value: value })) - }, - async handleDistributionParams(){ - const res = await this.getDistributionParams() - this.distribution.items = Object.entries(res.params).map(([key, value]) => ({ subtitle: key, - value: value })) - }, - async handleGovernanceParams() { - const excludes = this.blockchain.current?.excludes - if(excludes && excludes.indexOf('governance') > -1){ - return - } - Promise.all([this.getGovParamsVoting(),this.getGovParamsDeposit(),this.getGovParamsTally()]).then((resArr) => { - const govParams = {...resArr[0]?.voting_params,...resArr[1]?.deposit_params,...resArr[2]?.tally_params} - this.gov.items = Object.entries(govParams).map(([key, value]) => ({ subtitle:key, - value: value })) - }) - - }, - async handleAbciInfo(){ - const res = await this.fetchAbciInfo() - this.appVersion.items = Object.entries(res.application_version).map(([key, value]) => ({ subtitle:key, - value: value })) - this.nodeVersion.items = Object.entries(res.default_node_info).map(([key, value]) => ({ subtitle:key, - value: value })) - console.log('handleAbciInfo', this.nodeVersion.items) - }, - async getBaseTendermintBlockLatest() { - return await this.blockchain.rpc.getBaseBlockLatest() - }, - async getMintParam() { - return await this.blockchain.rpc.getMintParam() - }, - async getStakingParams() { - return await this.blockchain.rpc.getStakingParams() - }, - async getStakingPool(){ - return await this.blockchain.rpc.getStakingPool() - }, - async getBankTotal(denom: string){ - return await this.blockchain.rpc.getBankSupplyByDenom(denom) - // if (compareVersions(this.config.sdk_version, '0.46.2') > 0) { - // return this.get(`/cosmos/bank/v1beta1/supply/by_denom?denom=${denom}`).then(data => commonProcess(data).amount) - // } - // if (compareVersions(this.config.sdk_version, '0.40') < 0) { - // return this.get(`/supply/total/${denom}`).then(data => ({ amount: commonProcess(data), denom })) - // } - // return this.get(`/cosmos/bank/v1beta1/supply/${denom}`).then(data => commonProcess(data).amount) - }, - async getSlashingParams() { - return await this.blockchain.rpc.getSlashingParams() - }, - async getDistributionParams() { - return await this.blockchain.rpc.getDistributionParams() - }, - async getGovParamsVoting() { - return await this.blockchain.rpc.getGovParamsVoting() - }, - async getGovParamsDeposit() { - return await this.blockchain.rpc.getGovParamsDeposit() - }, - async getGovParamsTally() { - return await this.blockchain.rpc.getGovParamsTally() - }, - async fetchAbciInfo() { - return this.blockchain.rpc.getBaseNodeInfo() + mint: { + title: 'Mint Parameters', + items: [] as Array, + }, + staking: { + title: 'Staking Parameters', + items: [] as Array, + }, + distribution: { + title: 'Distribution Parameters', + items: [] as Array, + }, + slashing: { + title: 'Slashing Parameters', + items: [] as Array, + }, + gov: { + title: 'Governance Parameters', + items: [] as Array, + }, + appVersion: { + title: 'Application Version', + items: {}, + }, + nodeVersion: { + title: 'Node Information', + items: {}, + }, + }), + getters: { + blockchain() { + return useBlockchain(); + }, + }, + actions: { + initial() { + this.handleBaseBlockLatest(); + // this.handleMintParam() + this.handleStakingParams(); + this.handleSlashingParams(); + this.handleDistributionParams(); + this.handleGovernanceParams(); + this.handleAbciInfo(); + }, + async handleBaseBlockLatest() { + try { + const res = await this.getBaseTendermintBlockLatest(); + const height = this.chain.items.findIndex( + (x) => x.subtitle === 'height' + ); + this.chain.title = `Chain ID: ${res.block.header.chain_id}`; + this.chain.items[height].value = res.block.header.height; + // if (timeIn(res.block.header.time, 3, 'm')) { + // this.syncing = true + // } else { + // this.syncing = false + // } + // this.latestTime = toDay(res.block.header.time, 'long') + this.latestTime = res.block.header.time; + } catch (error) { + console.warn(error); + } + }, + async handleStakingParams() { + const res = await this.getStakingParams(); + const bond_denom = res?.params.bond_denom; + this.staking.items = Object.entries(res.params) + .map(([key, value]) => ({ subtitle: key, value: value })) + .filter((item: any) => { + if ( + !['min_commission_rate', 'min_self_delegation'].includes( + item.subtitle + ) + ) + return item; + }); + Promise.all([this.getStakingPool(), this.getBankTotal(bond_denom)]).then( + (resArr) => { + const pool = resArr[0]?.pool; + const amount = resArr[1]?.amount?.amount; + const assets = this.blockchain.current?.assets; + const bondedAndSupply = this.chain.items.findIndex( + (x) => x.subtitle === 'bonded_and_supply' + ); + this.chain.items[bondedAndSupply].value = `${formatNumber( + formatTokenAmount(assets, pool.bonded_tokens, 2, bond_denom, false), + true, + 0 + )}/${formatNumber( + formatTokenAmount(assets, amount, 2, bond_denom, false), + true, + 0 + )}`; + const bondedRatio = this.chain.items.findIndex( + (x) => x.subtitle === 'bonded_ratio' + ); + this.chain.items[bondedRatio].value = `${percent( + Number(pool.bonded_tokens) / Number(amount) + )}%`; } - - - } - - - - -}) \ No newline at end of file + ); + }, + async handleMintParam() { + const excludes = this.blockchain.current?.excludes; + if (excludes && excludes.indexOf('mint') > -1) { + return; + } + // this.getMintingInflation().then(res => { + // const chainIndex = this.chain.items.findIndex(x => x.subtitle === 'inflation') + // this.chain.items[chainIndex].value = `${percent(res)}%` + // }) + const res = await this.getMintParam(); + console.log(res, 'mint'); + }, + async handleSlashingParams() { + const res = await this.getSlashingParams(); + this.slashing.items = Object.entries(res.params).map(([key, value]) => ({ + subtitle: key, + value: value, + })); + }, + async handleDistributionParams() { + const res = await this.getDistributionParams(); + this.distribution.items = Object.entries(res.params).map( + ([key, value]) => ({ subtitle: key, value: value }) + ); + }, + async handleGovernanceParams() { + const excludes = this.blockchain.current?.excludes; + if (excludes && excludes.indexOf('governance') > -1) { + return; + } + Promise.all([ + this.getGovParamsVoting(), + this.getGovParamsDeposit(), + this.getGovParamsTally(), + ]).then((resArr) => { + const govParams = { + ...resArr[0]?.voting_params, + ...resArr[1]?.deposit_params, + ...resArr[2]?.tally_params, + }; + this.gov.items = Object.entries(govParams).map(([key, value]) => ({ + subtitle: key, + value: value, + })); + }); + }, + async handleAbciInfo() { + const res = await this.fetchAbciInfo(); + this.appVersion.items = Object.entries(res.application_version).map( + ([key, value]) => ({ subtitle: key, value: value }) + ); + this.nodeVersion.items = Object.entries(res.default_node_info).map( + ([key, value]) => ({ subtitle: key, value: value }) + ); + console.log('handleAbciInfo', this.nodeVersion.items); + }, + async getBaseTendermintBlockLatest() { + return await this.blockchain.rpc.getBaseBlockLatest(); + }, + async getMintParam() { + return await this.blockchain.rpc.getMintParam(); + }, + async getStakingParams() { + return await this.blockchain.rpc.getStakingParams(); + }, + async getStakingPool() { + return await this.blockchain.rpc.getStakingPool(); + }, + async getBankTotal(denom: string) { + return await this.blockchain.rpc.getBankSupplyByDenom(denom); + // if (compareVersions(this.config.sdk_version, '0.46.2') > 0) { + // return this.get(`/cosmos/bank/v1beta1/supply/by_denom?denom=${denom}`).then(data => commonProcess(data).amount) + // } + // if (compareVersions(this.config.sdk_version, '0.40') < 0) { + // return this.get(`/supply/total/${denom}`).then(data => ({ amount: commonProcess(data), denom })) + // } + // return this.get(`/cosmos/bank/v1beta1/supply/${denom}`).then(data => commonProcess(data).amount) + }, + async getSlashingParams() { + return await this.blockchain.rpc.getSlashingParams(); + }, + async getDistributionParams() { + return await this.blockchain.rpc.getDistributionParams(); + }, + async getGovParamsVoting() { + return await this.blockchain.rpc.getGovParamsVoting(); + }, + async getGovParamsDeposit() { + return await this.blockchain.rpc.getGovParamsDeposit(); + }, + async getGovParamsTally() { + return await this.blockchain.rpc.getGovParamsTally(); + }, + async fetchAbciInfo() { + return this.blockchain.rpc.getBaseNodeInfo(); + }, + }, +}); diff --git a/src/stores/useStakingStore.ts b/src/stores/useStakingStore.ts index 51fa0422..74e7291e 100644 --- a/src/stores/useStakingStore.ts +++ b/src/stores/useStakingStore.ts @@ -1,77 +1,89 @@ -import { defineStore } from "pinia"; -import { useBlockchain } from "./useBlockchain"; +import { defineStore } from 'pinia'; +import { useBlockchain } from './useBlockchain'; -import { get } from "@/libs/http"; -import type { StakingParam, StakingPool, Validator } from "@/types"; +import { get } from '@/libs/http'; +import type { StakingParam, StakingPool, Validator } from '@/types'; export const useStakingStore = defineStore('stakingStore', { - state: () => { - return { - validators: [] as Validator[], - params: {} as { - "unbonding_time": string, - "max_validators": number, - "max_entries": number, - "historical_entries": number, - "bond_denom": string, - "min_commission_rate": string, - "min_self_delegation": string - }, - pool: {} as { - bonded_tokens: string, - not_bonded_tokens: string, - }, - } + state: () => { + return { + validators: [] as Validator[], + params: {} as { + unbonding_time: string; + max_validators: number; + max_entries: number; + historical_entries: number; + bond_denom: string; + min_commission_rate: string; + min_self_delegation: string; + }, + pool: {} as { + bonded_tokens: string; + not_bonded_tokens: string; + }, + }; + }, + getters: { + totalPower(): number { + const sum = (s: number, e: Validator) => { + return s + parseInt(e.delegator_shares); + }; + return this.validators ? this.validators.reduce(sum, 0) : 0; }, - getters: { - totalPower(): number { - const sum = (s:number, e: Validator) => { return s + parseInt(e.delegator_shares) } - return this.validators ? this.validators.reduce(sum, 0): 0 - }, - blockchain() { - return useBlockchain() - } + blockchain() { + return useBlockchain(); }, - actions: { - async init() { - this.$reset() - this.fetchPool() - this.fetchAcitveValdiators() - return await this.fetchParams() - }, - async keybase(identity: string) { - return get(`https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}&fields=pictures`) - }, - async fetchParams() { - const response = await this.blockchain.rpc.getStakingParams() - if(response.params) this.params = response.params - return this.params - }, - async fetchPool() { - const response = await this.blockchain.rpc.getStakingPool() - response.pool.bonded_tokens - this.pool = response.pool - }, - async fetchAcitveValdiators() { - return this.fetchValidators('BOND_STATUS_BONDED') - }, - async fetchInacitveValdiators() { - return this.fetchValidators('BOND_STATUS_UNBONDED') - }, - async fetchValidator(validatorAddr: string) { - return this.blockchain.rpc.getStakingValidator(validatorAddr) - }, - async fetchValidatorDelegation(validatorAddr: string, delegatorAddr: string) { - return await this.blockchain.rpc.getStakingValidatorsDelegationsDelegator(validatorAddr, delegatorAddr) - }, - async fetchValidators(status: string) { - return this.blockchain.rpc.getStakingValidators(status).then(res => { - const vals = res.validators.sort((a, b) => (Number(b.delegator_shares) - Number(a.delegator_shares))) - if(status==='BOND_STATUS_BONDED') { - this.validators = vals - } - return vals - }) + }, + actions: { + async init() { + this.$reset(); + this.fetchPool(); + this.fetchAcitveValdiators(); + return await this.fetchParams(); + }, + async keybase(identity: string) { + return get( + `https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}&fields=pictures` + ); + }, + async fetchParams() { + const response = await this.blockchain.rpc.getStakingParams(); + if (response.params) this.params = response.params; + return this.params; + }, + async fetchPool() { + const response = await this.blockchain.rpc.getStakingPool(); + response.pool.bonded_tokens; + this.pool = response.pool; + }, + async fetchAcitveValdiators() { + return this.fetchValidators('BOND_STATUS_BONDED'); + }, + async fetchInacitveValdiators() { + return this.fetchValidators('BOND_STATUS_UNBONDED'); + }, + async fetchValidator(validatorAddr: string) { + return this.blockchain.rpc.getStakingValidator(validatorAddr); + }, + async fetchValidatorDelegation( + validatorAddr: string, + delegatorAddr: string + ) { + return await this.blockchain.rpc.getStakingValidatorsDelegationsDelegator( + validatorAddr, + delegatorAddr + ); + }, + async fetchValidators(status: string) { + return this.blockchain.rpc.getStakingValidators(status).then((res) => { + const vals = res.validators.sort( + (a, b) => Number(b.delegator_shares) - Number(a.delegator_shares) + ); + if (status === 'BOND_STATUS_BONDED') { + this.validators = vals; } - } -}) \ No newline at end of file + return vals; + }); + }, + }, +}); diff --git a/src/stores/useWalletStore.ts b/src/stores/useWalletStore.ts index f08e1f2e..acc74820 100644 --- a/src/stores/useWalletStore.ts +++ b/src/stores/useWalletStore.ts @@ -1,13 +1,9 @@ -import { defineStore } from "pinia"; +import { defineStore } from 'pinia'; export const useWalletStore = defineStore('walletStore', { - state: () => { - return { - } - }, - getters: { - - }, - actions: { - } -}) \ No newline at end of file + state: () => { + return {}; + }, + getters: {}, + actions: {}, +}); diff --git a/tailwind.config.js b/tailwind.config.js index 38e06972..38e17d4e 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -22,17 +22,15 @@ module.exports = { light: { ...require('daisyui/src/colors/themes')['[data-theme=light]'], primary: '#666cff', - info: '#666CFF', - 'base-content': '#e9eaeb' + 'base-content': '#e9eaeb', }, }, { dark: { ...require('daisyui/src/colors/themes')['[data-theme=dark]'], primary: '#666cff', - info: '#666CFF', 'base-100': '#2a334c', - 'base-content': '#373f57' + 'base-content': '#373f57', }, }, ], diff --git a/vite.config.ts b/vite.config.ts index 9e3b281b..f28f684d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,16 +1,16 @@ -import { fileURLToPath, URL } from "node:url"; +import { fileURLToPath, URL } from 'node:url'; -import { defineConfig } from "vite"; -import vue from "@vitejs/plugin-vue"; -import vueJsx from "@vitejs/plugin-vue-jsx"; -import vuetify from "vite-plugin-vuetify"; -import Layouts from "vite-plugin-vue-layouts"; -import DefineOptions from "unplugin-vue-define-options/vite"; -import Components from "unplugin-vue-components/vite"; -import AutoImport from "unplugin-auto-import/vite"; -import Pages from "vite-plugin-pages"; +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +import vuetify from 'vite-plugin-vuetify'; +import Layouts from 'vite-plugin-vue-layouts'; +import DefineOptions from 'unplugin-vue-define-options/vite'; +import Components from 'unplugin-vue-components/vite'; +import AutoImport from 'unplugin-auto-import/vite'; +import Pages from 'vite-plugin-pages'; -import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' +import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; // https://vitejs.dev/config/ export default defineConfig({ @@ -19,61 +19,70 @@ export default defineConfig({ vueJsx(), vuetify({ styles: { - configFile: "src/plugins/vuetify/styles/variables/_vuetify.scss", + configFile: 'src/plugins/vuetify/styles/variables/_vuetify.scss', }, }), Pages({ - dirs: ["./src/modules", "./src/pages", ], + dirs: ['./src/modules', './src/pages'], exclude: ['**/*.ts'], // only load .vue as modules }), Layouts({ - layoutsDirs: "./src/layouts/", + layoutsDirs: './src/layouts/', }), Components({ - dirs: ["src/plugins/vuetify/@core/components"], + dirs: ['src/plugins/vuetify/@core/components'], dts: true, }), AutoImport({ - imports: ["vue", "vue-router", "@vueuse/core", "@vueuse/math", "vue-i18n", "pinia"], + imports: [ + 'vue', + 'vue-router', + '@vueuse/core', + '@vueuse/math', + 'vue-i18n', + 'pinia', + ], vueTemplate: true, }), VueI18nPlugin({ runtimeOnly: true, compositionOnly: true, include: [ - fileURLToPath(new URL('./src/plugins/i18n/locales/**', import.meta.url)), + fileURLToPath( + new URL('./src/plugins/i18n/locales/**', import.meta.url) + ), ], }), DefineOptions(), ], resolve: { alias: { - "@": fileURLToPath(new URL("./src", import.meta.url)), - "@themeConfig": fileURLToPath( - new URL("./themeConfig.ts", import.meta.url) + '@': fileURLToPath(new URL('./src', import.meta.url)), + '@themeConfig': fileURLToPath( + new URL('./themeConfig.ts', import.meta.url) ), - "@configured-variables": fileURLToPath( + '@configured-variables': fileURLToPath( new URL( - "./src/plugins/vuetify/styles/variables/_template.scss", + './src/plugins/vuetify/styles/variables/_template.scss', import.meta.url ) ), - "@core": fileURLToPath( - new URL("./src/plugins/vuetify/@core", import.meta.url) + '@core': fileURLToPath( + new URL('./src/plugins/vuetify/@core', import.meta.url) ), - "@layouts": fileURLToPath( - new URL("./src/plugins/vuetify/@layouts", import.meta.url) + '@layouts': fileURLToPath( + new URL('./src/plugins/vuetify/@layouts', import.meta.url) ), - "@images": fileURLToPath( - new URL("./src/plugins/vuetify/images/", import.meta.url) + '@images': fileURLToPath( + new URL('./src/plugins/vuetify/images/', import.meta.url) ), - "@styles": fileURLToPath( - new URL("./src/plugins/vuetify/styles/", import.meta.url) + '@styles': fileURLToPath( + new URL('./src/plugins/vuetify/styles/', import.meta.url) ), }, }, optimizeDeps: { - exclude: ["vuetify"], - entries: ["./src/**/*.vue"], + exclude: ['vuetify'], + entries: ['./src/**/*.vue'], }, }); diff --git a/yarn.lock b/yarn.lock index c7241904..cd3ea53a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7892,10 +7892,10 @@ vite-plugin-vuetify@^1.0.2: debug "^4.3.3" upath "^2.0.1" -vite@^4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.3.tgz#26adb4aa01439fc4546c480ea547674d87289396" - integrity sha512-MwFlLBO4udZXd+VBcezo3u8mC77YQk+ik+fbc0GZWGgzfbPP+8Kf0fldhARqvSYmtIWoAJ5BXPClUbMTlqFxrA== +vite@^4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.5.tgz#3871fe0f4b582ea7f49a85386ac80e84826367d9" + integrity sha512-0gEnL9wiRFxgz40o/i/eTBwm+NEbpUeTWhzKrZDSdKm6nplj+z4lKz8ANDgildxHm47Vg8EUia0aicKbawUVVA== dependencies: esbuild "^0.17.5" postcss "^8.4.23"