diff --git a/src/components/TableItemParameter.vue b/src/components/TableItemParameter.vue new file mode 100644 index 00000000..d66f34bd --- /dev/null +++ b/src/components/TableItemParameter.vue @@ -0,0 +1,115 @@ + + + 8888 + + + + + \ No newline at end of file diff --git a/src/components/TableParameter.vue b/src/components/TableParameter.vue index 878d7df0..5530c16e 100644 --- a/src/components/TableParameter.vue +++ b/src/components/TableParameter.vue @@ -1,16 +1,39 @@ - + + - + --> + + + + + + + + - diff --git a/src/components/dynamic/ArrayObjectElement.vue b/src/components/dynamic/ArrayObjectElement.vue index a6916085..fc76a96d 100644 --- a/src/components/dynamic/ArrayObjectElement.vue +++ b/src/components/dynamic/ArrayObjectElement.vue @@ -4,6 +4,10 @@ import DynamicComponent from './DynamicComponent.vue'; const props = defineProps({ value: { type: Array}, + thead: { + type: Boolean, + default: true + } }) const header = computed(() => { @@ -15,8 +19,8 @@ const header = computed(() => { - - + + {{ k }} 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]/params/index.vue b/src/modules/[chain]/params/index.vue index bab249eb..e53622c4 100644 --- a/src/modules/[chain]/params/index.vue +++ b/src/modules/[chain]/params/index.vue @@ -1,18 +1,20 @@ - + {{ chain.title }} @@ -29,20 +31,32 @@ onMounted(() => { - - - - - - - - - - + + + + + + + + + + + + + {{ store.appVersion?.title }} + + + + + + {{ store.nodeVersion?.title }} + + + - + - +