From 270cd1bdbad7ab88ea23a95f3cf034b4d1dae3ba Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 27 May 2023 17:31:40 +0800 Subject: [PATCH] improve --- public/logos/keplr-logo.svg | 10 ++++++++++ public/logos/ledger.png | Bin 0 -> 41939 bytes src/components/ProposalListItem.vue | 16 ++++------------ src/modules/[chain]/gov/[proposal_id].vue | 15 ++++++++++++--- src/modules/[chain]/index.vue | 4 +--- src/stores/useDashboard.ts | 2 +- src/stores/useFormatter.ts | 9 ++++++--- src/stores/useWalletStore.ts | 3 ++- 8 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 public/logos/keplr-logo.svg create mode 100644 public/logos/ledger.png diff --git a/public/logos/keplr-logo.svg b/public/logos/keplr-logo.svg new file mode 100644 index 00000000..666736bc --- /dev/null +++ b/public/logos/keplr-logo.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/public/logos/ledger.png b/public/logos/ledger.png new file mode 100644 index 0000000000000000000000000000000000000000..aa4c8445e57be7107042114f73084e3c892aaa0e GIT binary patch literal 41939 zcmeI5e@qi+7{_0vj>`Daf+GYRE0ZN)_5*{-#@JX}%4jtqAmAcnYBEztGJ^?hR3lPg zY~YMEj4Y`ZAw)N4+zd0o2*Q|4WD5;LP3Rb+-DE%vY-BRnMC|VDz4u=IW5EPsA>T{j zxWXNGpZ9yu`@GNlyzg6`k)9UlAK_032{h<+TL}rMB*cGI{uuX3PXEUmZntKietRJy z&#&jdd`zcad!G;$G3YeeCfmf2X0LBXz-o=_^o3kwU|swd7f+`CwjsQ>cSC~W?$Lo0 z)_;##8+^E{m@UJv&a5J2$M3endTW8-YVI@D$f4#iZcjILO{|Rm%V;E< z0stlf1k^-9KoXP$tOTqCDh@#ds9&jBfFvLZRFd>kr^Yw^x=a!sk`-Mp1FOd;O zkr9IYH^u_lej*EWz=$Z2K*~_STu4~JT!=8d(_D;CZsPCojB)hkvAm#|Ti1t&_PcMn zJL`PMC137mRlc!n%vLj7b!YMqhxp4EdZnF?(^bd`cVk1I3+2G=k>|o-Ac2>$SZFsr ze};G3O$?Y3OB2l_5d{WAF%)=j84E;H7>i|VF1i~^l2p9YtC)7Zm$Yi0CV(NjNDCJM zXMqGH0ZAYMkZJ%um6XJyH2{}{ zl2{a%gufUJ3`L4MM<4-7tQ<+`Cx(31aF1hdbe$Vgjt5J7e?L6wG3QrwoG??w{iolh z_m~bMyw;vIo*^nDnUblHeOK~nS@`D0 z!5_}X%VjC@iooi;+;9Ca+S@Czo(C<7r7H$6X^8AGb{R(}UuoLWF;^7DJ$2sI#IcPD z!L!^PGcIRwacKabUg#+7+uj!XcggHJo=Z;0oYh+6E94q}({$V+O*=dQ@$iuNZN-ZR ztIE0y8guGkp<+P^h_%sI0`43mfvP~l0-<>Z1LlIU@Dh)Bah;m9y8K%#7l1x2rdp#U z5S?QrFf*fs1)_5d2FwLx;e87hPxW*?c}=DGo+yqeOV-t^;~b@-iP4vR4sNsS^SkdQ z=E4(Z#RpGV!UCQ!g8@&Nu~?CwFnc^yXN-mSRc8ohBA6-Y6E>N>sIbW*3-oJ=D3CbF zP&~54!H`PHO%Qk&j0U_5kp(i}L=;{zNDi5AtUSClK-AcAN?F`z?+xMddz`L`&S7o_ zF>`~}dVAjWP7{CkbyeEaNy)+P2XRK$vZy-dOz+F)IWC4 q-i+s*(4BpWKehHW@=vw<-5XC0ZF-}j*4~xI9~)BBbzfVote + {{ item?.voterStatus.replace("VOTE_OPTION_", "")}} + Vote + -
- - {{ item?.voterStatus }} -
diff --git a/src/modules/[chain]/gov/[proposal_id].vue b/src/modules/[chain]/gov/[proposal_id].vue index d0152fd5..c3d5f4fe 100644 --- a/src/modules/[chain]/gov/[proposal_id].vue +++ b/src/modules/[chain]/gov/[proposal_id].vue @@ -18,12 +18,14 @@ PageRequest, import { ref, reactive } from 'vue'; import Countdown from '@/components/Countdown.vue'; import PaginationBar from '@/components/PaginationBar.vue' +import { fromBech32, toHex } from '@cosmjs/encoding'; const props = defineProps(['proposal_id', 'chain']); const proposal = ref({} as GovProposal); const format = useFormatter(); const store = useGovStore(); const dialog = useTxDialog(); +const stakingStore = useStakingStore(); store.fetchProposal(props.proposal_id).then((res) => { const proposalDetail = reactive(res.proposal); @@ -102,7 +104,7 @@ const total = computed(() => { const turnout = computed(() => { if (total.value > 0) { - const bonded = useStakingStore().pool?.bonded_tokens || '1'; + const bonded = stakingStore.pool?.bonded_tokens || '1'; return format.percent(total.value / Number(bonded)); } return 0; @@ -149,6 +151,13 @@ const processList = computed(() => { ]; }); +function showValidatorName(voter: string) { + const {data} = fromBech32(voter) + const hex = toHex(data) + const v = stakingStore.validators.find( x => toHex(fromBech32(x.operator_address).data) === hex) + return v? v.description.moniker : voter +} + function pageload(p: number) { pageRequest.value.setPage(p) store @@ -324,7 +333,7 @@ function pageload(p: number) { - + diff --git a/src/modules/[chain]/index.vue b/src/modules/[chain]/index.vue index 81971af4..ff35ed95 100644 --- a/src/modules/[chain]/index.vue +++ b/src/modules/[chain]/index.vue @@ -267,9 +267,7 @@ const color = computed(() => { {{ format.formatToken(walletStore.balanceOfStakingToken) }}
- - ${{ format.tokenValue(walletStore.balanceOfStakingToken) }} - + ${{ format.tokenValue(walletStore.balanceOfStakingToken) }}
diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index 78fa9a17..269acc5e 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -265,7 +265,7 @@ export const useDashboard = defineStore('dashboard', { favorite: fav as string[], favoriteMap: favMap as Record, chains: {} as Record, - prices: {}, + prices: {} as Record, coingecko: {} as Record, }; }, diff --git a/src/stores/useFormatter.ts b/src/stores/useFormatter.ts index 0e9de4a0..13b3583c 100644 --- a/src/stores/useFormatter.ts +++ b/src/stores/useFormatter.ts @@ -69,7 +69,7 @@ export const useFormatter = defineStore('formatter', { return trace; }, priceInfo(denom: string) { - const id = this.dashboard.coingecko[denom]?.coinId; + const id = this.dashboard.coingecko[denom]?.coinId || ""; const prices = this.dashboard.prices[id]; return prices; }, @@ -96,7 +96,10 @@ export const useFormatter = defineStore('formatter', { return v!==0 ? numeral(v).format("+0,0.[00]"): "" }, tokenValue(token?: Coin) { - return token ? numeral(this.formatTokenAmount(token)).format('0,0.[00]') : "" + if(token) { + return numeral(this.tokenValueNumber(token)).format("0,0.[00]") + } + return "" }, tokenValueNumber(token?: Coin) { if(!token) return 0 @@ -129,7 +132,7 @@ export const useFormatter = defineStore('formatter', { formatToken( token?: { denom: string; amount: string }, withDenom = true, - fmt = '0.0a', + fmt = '0,0.[0]', mode = 'local' ): string { if (token && token.amount && token?.denom) { diff --git a/src/stores/useWalletStore.ts b/src/stores/useWalletStore.ts index 9643e564..eebea3a1 100644 --- a/src/stores/useWalletStore.ts +++ b/src/stores/useWalletStore.ts @@ -42,8 +42,9 @@ export const useWalletStore = defineStore('walletStore', { ); }, stakingAmount() { + const stakingStore = useStakingStore(); let amt = 0; - let denom = ''; + let denom = stakingStore.params.bond_denom; this.delegations.forEach((i) => { amt += Number(i.balance.amount); denom = i.balance.denom;
{{ item.voter }}{{ showValidatorName(item.voter) }} - {{ item.option }} + {{ String(item.option).replace("VOTE_OPTION_", "") }}