From 1e414d5c686e9e6aef1269764b275cc324069fd7 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 18 May 2023 12:38:17 +0800 Subject: [PATCH] improve tx dialog --- chains/mainnet/neutron.json | 22 ++++++++++++++++ src/modules/[chain]/block/index.vue | 4 +-- src/modules/[chain]/index.vue | 35 ++++++++++++------------- src/modules/[chain]/staking/index.vue | 2 -- src/modules/[chain]/statesync/index.vue | 2 +- src/modules/[chain]/uptime/index.vue | 2 +- src/stores/template.ts | 2 +- src/stores/useBlockchain.ts | 17 +++++++++++- src/stores/useDashboard.ts | 15 +++++++++++ src/stores/useParamsStore.ts | 2 -- src/stores/useStakingStore.ts | 19 ++++++++++++++ 11 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 chains/mainnet/neutron.json diff --git a/chains/mainnet/neutron.json b/chains/mainnet/neutron.json new file mode 100644 index 00000000..aba5d4de --- /dev/null +++ b/chains/mainnet/neutron.json @@ -0,0 +1,22 @@ +{ + "chain_name": "neutron", + "api": ["https://neutron-api.lavenderfive.com/"], + "rpc": ["https://rpc-palvus.pion-1.ntrn.tech"], + "provider_chain": { + "api": ["https://api-cosmoshub-ia.cosmosia.notional.ventures"] + }, + "features": ["dashboard", "blocks", "ibc", "cosmwasm", "uptime", "parameters", "state-sync"], + "sdk_version": "0.45.1", + "coin_type": "118", + "min_tx_fee": "8000", + "assets": [{ + "base": "untrn", + "symbol": "NTRN", + "exponent": "6", + "coingecko_id": "neutron", + "logo": "/logos/nym.jpeg" + }], + "addr_prefix": "neutron", + "theme_color": "", + "logo": "/logos/nym.jpeg" +} diff --git a/src/modules/[chain]/block/index.vue b/src/modules/[chain]/block/index.vue index 9a0fe409..5f44063f 100644 --- a/src/modules/[chain]/block/index.vue +++ b/src/modules/[chain]/block/index.vue @@ -27,7 +27,7 @@ const format = useFormatter();
| Height | @@ -60,7 +60,7 @@ const format = useFormatter(); v-show="tab === 'transactions'" class="bg-base-100 rounded overflow-x-auto" > -
|---|
| Height | diff --git a/src/modules/[chain]/index.vue b/src/modules/[chain]/index.vue index d1e3238c..0e1b9f9f 100644 --- a/src/modules/[chain]/index.vue +++ b/src/modules/[chain]/index.vue @@ -17,6 +17,8 @@ import { computed } from '@vue/reactivity'; import CardStatisticsVertical from '@/components/CardStatisticsVertical.vue'; import ProposalListItem from '@/components/ProposalListItem.vue'; +const props = defineProps(['chain']); + const blockchain = useBlockchain(); const store = useIndexModule(); const walletStore = useWalletStore(); @@ -229,7 +231,7 @@ const color = computed(() => { -
|---|
| {{ format.formatToken(item?.balance) }} | {{ - format.formatToken( + format.formatTokens( walletStore?.rewards?.rewards?.find( (el) => el?.validator_address === item?.delegation?.validator_address - )?.reward?.[0] - ) + )?.reward) }} |
-
-
+
|
|
| {{ i+1 }}. {{ v.description.moniker }} | +{{ i+1 }}. {{ v.description.moniker }} |
{{ signing?.start_height }} | {{ signing?.index_offset }} diff --git a/src/stores/template.ts b/src/stores/template.ts index 0ab51adf..dcdf0818 100644 --- a/src/stores/template.ts +++ b/src/stores/template.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; -export const useStoreName = defineStore('bankstore', { +export const useStoreName = defineStore('template', { state: () => { return {}; }, diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 502c8f94..a9f4738b 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -1,4 +1,5 @@ import { defineStore } from 'pinia'; +import { useTheme } from 'vuetify'; import { useDashboard, type ChainConfig, @@ -50,6 +51,10 @@ export const useBlockchain = defineStore('blockchain', { dashboard() { return useDashboard(); }, + isConsumerChain() { + // @ts-ignore + return this.current && this.current.providerChain + }, computedChainMenu() { let currNavItem: VerticalNavItems = []; @@ -61,8 +66,11 @@ export const useBlockchain = defineStore('blockchain', { title: this.current?.prettyName || this.chainName || '', icon: { image: this.current.logo, size: '22' }, i18n: false, + badgeContent: this.isConsumerChain? 'Consumer': undefined, + badgeClass: 'bg-secondary', children: routes - .filter((x) => x.meta.i18n) + .filter((x) => x.meta.i18n) // defined menu name + .filter((x) => !this.current?.features || this.current.features.includes(String(x.meta.i18n))) // filter none-custom module .map((x) => ({ title: `module.${x.meta.i18n}`, to: { path: x.path.replace(':chain', this.chainName) }, @@ -112,6 +120,10 @@ export const useBlockchain = defineStore('blockchain', { }, actions: { async initial() { + // this.current?.themeColor { + // const { global } = useTheme(); + // global.current + // } await this.randomSetupEndpoint(); await useStakingStore().init(); useBankStore().initial(); @@ -146,5 +158,8 @@ export const useBlockchain = defineStore('blockchain', { this.chainName = name; } }, + supportModule(mod: string) { + return !this.current?.features || this.current.features.includes(mod) + } }, }); diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index 33c7e015..610b9d7b 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -61,6 +61,7 @@ export interface ChainConfig { coinType: string; assets: Asset[]; themeColor?: string; + features?: string[] endpoints: { rest?: Endpoint[]; rpc?: Endpoint[]; @@ -74,12 +75,18 @@ export interface ChainConfig { }; exponent: string; excludes?: string; + providerChain: { + api: Endpoint[] + }; } export interface LocalConfig { addr_prefix: string; alias: string; api: string[] | Endpoint[]; + provider_chain: { + api: string[] | Endpoint[] + } assets: { base: string; coingecko_id: string; @@ -90,10 +97,12 @@ export interface LocalConfig { chain_name: string; coin_type: string; logo: string; + theme_color?: string; min_tx_fee: string; rpc: string[] | Endpoint[]; sdk_version: string; registry_name?: string; + features?: string[]; } function apiConverter(api: any[]) { @@ -135,6 +144,12 @@ export function fromLocal(lc: LocalConfig): ChainConfig { rest: apiConverter(lc.api), rpc: apiConverter(lc.rpc), }; + if(lc.provider_chain) { + conf.providerChain = { + api: apiConverter(lc.provider_chain.api) + } + } + conf.features = lc.features conf.logo = lc.logo; return conf; } diff --git a/src/stores/useParamsStore.ts b/src/stores/useParamsStore.ts index f4bd5bed..e2dc4494 100644 --- a/src/stores/useParamsStore.ts +++ b/src/stores/useParamsStore.ts @@ -156,7 +156,6 @@ export const useParamStore = defineStore('paramstore', { // this.chain.items[chainIndex].value = `${percent(res)}%` // }) const res = await this.getMintParam(); - console.log(res, 'mint'); }, async handleSlashingParams() { const res = await this.getSlashingParams(); @@ -200,7 +199,6 @@ export const useParamStore = defineStore('paramstore', { 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(); diff --git a/src/stores/useStakingStore.ts b/src/stores/useStakingStore.ts index 450f7e16..4fca50ef 100644 --- a/src/stores/useStakingStore.ts +++ b/src/stores/useStakingStore.ts @@ -3,6 +3,9 @@ import { useBlockchain } from './useBlockchain'; import { get } from '@/libs/http'; import type { StakingParam, StakingPool, Validator } from '@/types'; +import { CosmosRestClient } from '@/libs/client'; +import { consensusPubkeyToHexAddress, valconsToBase64 } from '@/libs'; +import { toHex, fromBase64 } from '@cosmjs/encoding'; export const useStakingStore = defineStore('stakingStore', { state: () => { @@ -77,6 +80,20 @@ export const useStakingStore = defineStore('stakingStore', { ); }, async fetchValidators(status: string) { + if(this.blockchain.isConsumerChain) { + if(this.blockchain.current?.providerChain.api && this.blockchain.current.providerChain.api.length > 0) { + const client = CosmosRestClient.newDefault(this.blockchain.current.providerChain.api[0].address) + // const vals = await client.getBaseValidatorsetLatest(0) + const res = await client.getStakingValidators(status) + const proVals = res.validators.sort( + (a, b) => Number(b.delegator_shares) - Number(a.delegator_shares) + ) + if (status === 'BOND_STATUS_BONDED') { + this.validators = proVals; + } + return proVals + } + } return this.blockchain.rpc?.getStakingValidators(status).then((res) => { const vals = res.validators.sort( (a, b) => Number(b.delegator_shares) - Number(a.delegator_shares) @@ -89,3 +106,5 @@ export const useStakingStore = defineStore('stakingStore', { }, }, }); + + |