diff --git a/package.json b/package.json index f832a4c0..d141594f 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "unplugin-auto-import": "^0.13.0", "unplugin-vue-components": "^0.23.0", "unplugin-vue-define-options": "1.1.4", - "vite": "^4.3.1", + "vite": "^4.3.3", "vite-plugin-pages": "^0.28.0", "vue-tsc": "^1.0.12" } diff --git a/src/components/CardParameter.vue b/src/components/CardParameter.vue index 20078378..97bc1907 100644 --- a/src/components/CardParameter.vue +++ b/src/components/CardParameter.vue @@ -1,22 +1,28 @@ \ No newline at end of file + + diff --git a/src/components/TableParameter.vue b/src/components/TableParameter.vue deleted file mode 100644 index 3433a101..00000000 --- a/src/components/TableParameter.vue +++ /dev/null @@ -1,26 +0,0 @@ - - \ No newline at end of file diff --git a/src/components/dynamic/ArrayObjectElement.vue b/src/components/dynamic/ArrayObjectElement.vue index a6916085..079b41a6 100644 --- a/src/components/dynamic/ArrayObjectElement.vue +++ b/src/components/dynamic/ArrayObjectElement.vue @@ -3,7 +3,11 @@ import { computed } from '@vue/reactivity'; import DynamicComponent from './DynamicComponent.vue'; const props = defineProps({ - value: { type: Array}, + value: { type: null as any }, + thead: { + type: Boolean, + default: true + } }) const header = computed(() => { @@ -15,16 +19,20 @@ const header = computed(() => { \ No newline at end of file diff --git a/src/libs/utils.ts b/src/libs/utils.ts index d053bee6..b16717bd 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -46,3 +46,65 @@ export function numberWithCommas(x: any) { return parts.join('.') } +export function tokenFormatter(tokens:any, denoms = {}, decimal = 2) { + if (Array.isArray(tokens)) { + return tokens.map(t => formatToken(t, denoms, decimal)).join(', ') + } + return formatToken(tokens, denoms, 2) +} +export function formatToken(token:any, IBCDenom = {}, decimals = 2, withDenom = true) { + if (token) { + const denom = IBCDenom[token.denom] || token.denom + if (withDenom) { + return `${formatTokenAmount(token.amount, decimals, denom)} ${formatTokenDenom(denom)}` + } + return formatTokenAmount(token.amount, decimals, denom) + } + return token + } +export function formatTokenDenom(tokenDenom:any) { + if (tokenDenom && tokenDenom.code === undefined) { + let denom = tokenDenom.denom_trace ? tokenDenom.denom_trace.base_denom : tokenDenom + const chains = getLocalChains() + const selected = localStorage.getItem('selected_chain') + const selChain = chains[selected] + const nativeAsset = selChain.assets.find(a => (a.base === denom)) + if (nativeAsset) { + denom = nativeAsset.symbol + } else { + const config = Object.values(chains) + config.forEach(x => { + if (x.assets) { + const asset = x.assets.find(a => (a.base === denom)) + if (asset) denom = asset.symbol + } + }) + } + return denom.length > 10 ? `${denom.substring(0, 7).toUpperCase()}..${denom.substring(denom.length - 3)}` : denom.toUpperCase() + } + return '' +} + +export function isToken(value: string) { + let is = false + if (Array.isArray(value)) { + is = value.findIndex(x => Object.keys(x).includes('denom')) > -1 + } else { + is = Object.keys(value).includes('denom') + } + return is + } + export function isStringArray(value: any) { + let is = false + if (Array.isArray(value)) { + is = value.findIndex(x => typeof x === 'string') > -1 + } + return is + } + + export function isHexAddress(v: any) { + // const re = /^[A-Z\d]{40}$/ + // return re.test(v) + return v.length === 28 + } + diff --git a/src/modules/[chain]/gov/index.vue b/src/modules/[chain]/gov/index.vue index b051b96d..373c7445 100644 --- a/src/modules/[chain]/gov/index.vue +++ b/src/modules/[chain]/gov/index.vue @@ -1,36 +1,35 @@ { @@ -38,4 +37,4 @@ onMounted(()=>{ i18n: 'governance' } } - \ No newline at end of file + diff --git a/src/modules/[chain]/params/index.vue b/src/modules/[chain]/params/index.vue index 13b36e7e..42f9c33f 100644 --- a/src/modules/[chain]/params/index.vue +++ b/src/modules/[chain]/params/index.vue @@ -2,8 +2,7 @@ import { useParamStore } from '@/stores'; import { ref, onMounted } from 'vue' import CardParameter from '@/components/CardParameter.vue' -import TableParameter from '@/components/TableParameter.vue' -import { sort } from 'semver'; +import ArrayObjectElement from '@/components/dynamic/ArrayObjectElement.vue'; const store = useParamStore() const chain = ref(store.chain) onMounted(() => { @@ -13,17 +12,23 @@ onMounted(() => { + { - meta: { + meta: { i18n: 'parameters' - } + } } - \ No newline at end of file + diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue new file mode 100644 index 00000000..13437e58 --- /dev/null +++ b/src/modules/[chain]/uptime/index.vue @@ -0,0 +1,12 @@ + + + { + meta: { + i18n: 'uptime' + } + } + diff --git a/src/plugins/i18n/locales/cn.json b/src/plugins/i18n/locales/cn.json index 03852525..c2f010df 100644 --- a/src/plugins/i18n/locales/cn.json +++ b/src/plugins/i18n/locales/cn.json @@ -4,7 +4,8 @@ "blocks": "区块和交易", "staking": "质押生息", "governance": "社区治理", - "parameters": "参数" + "parameters": "参数", + "uptime": "状态" }, "index": { "slogan": "Ping Dashboard 是一个区块链浏览器,也是一个网页钱包,还有更多 ... 🛠", diff --git a/src/plugins/i18n/locales/en.json b/src/plugins/i18n/locales/en.json index 4bdd6446..6bc0715a 100644 --- a/src/plugins/i18n/locales/en.json +++ b/src/plugins/i18n/locales/en.json @@ -4,7 +4,8 @@ "blocks": "Blocks&Transaction", "staking": "Staking", "governance": "Governance", - "parameters": "Parameters" + "parameters": "Parameters", + "uptime": "Uptime" }, "index": { "slogan": "Ping Dashboard is not just an explorer but also a wallet and more ... 🛠", diff --git a/src/stores/useParamsStore.ts b/src/stores/useParamsStore.ts index 05da9ba2..a59c56e6 100644 --- a/src/stores/useParamsStore.ts +++ b/src/stores/useParamsStore.ts @@ -143,7 +143,7 @@ export const useParamStore = defineStore("paramstore", { value: value })) this.nodeVersion.items = Object.entries(res.default_node_info).map(([key, value]) => ({ subtitle:key, value: value })) - console.log('handleAbciInfo', res) + console.log('handleAbciInfo', this.nodeVersion.items) }, async getBaseTendermintBlockLatest() { return await this.blockchain.rpc.getBaseBlockLatest() diff --git a/yarn.lock b/yarn.lock index 5b5cf531..740fa4cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6609,7 +6609,7 @@ postcss@^8.0.9, postcss@^8.4.23: picocolors "^1.0.0" source-map-js "^1.0.2" -postcss@^8.1.10, postcss@^8.4.21: +postcss@^8.1.10: version "8.4.21" resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz" integrity sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg== @@ -6886,9 +6886,9 @@ rimraf@3.0.2, rimraf@^3.0.2: dependencies: glob "^7.1.3" -rollup@^3.20.2: +rollup@^3.21.0: version "3.21.0" - resolved "https://registry.npmjs.org/rollup/-/rollup-3.21.0.tgz" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.21.0.tgz#0a71517db56e150222670f88e5e7acfa4fede7c8" integrity sha512-ANPhVcyeHvYdQMUyCbczy33nbLzI7RzrBje4uvNiTDJGIMtlKoOStmympwr9OtS1LZxiDmE2wvxHyVhoLtf1KQ== optionalDependencies: fsevents "~2.3.2" @@ -7365,7 +7365,7 @@ symbol-observable@^2.0.3: tailwindcss@^3.3.1: version "3.3.1" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.3.1.tgz#b6662fab6a9b704779e48d083a9fef5a81d2b81e" + resolved "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.1.tgz#b6662fab6a9b704779e48d083a9fef5a81d2b81e" integrity sha512-Vkiouc41d4CEq0ujXl6oiGFQ7bA3WEhUZdTgXAhtKxSy49OmKs8rEfQmupsfF0IGW8fv2iQkp1EVUuapCFrZ9g== dependencies: arg "^5.0.2" @@ -7749,14 +7749,14 @@ vite-plugin-vuetify@^1.0.2: debug "^4.3.3" upath "^2.0.1" -vite@^4.3.1: - version "4.3.1" - resolved "https://registry.npmjs.org/vite/-/vite-4.3.1.tgz" - integrity sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg== +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== dependencies: esbuild "^0.17.5" - postcss "^8.4.21" - rollup "^3.20.2" + postcss "^8.4.23" + rollup "^3.21.0" optionalDependencies: fsevents "~2.3.2"