This commit is contained in:
liangping 2023-05-27 17:31:40 +08:00
parent bd841633b1
commit 270cd1bdba
8 changed files with 36 additions and 23 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 148 KiB

BIN
public/logos/ledger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -115,19 +115,11 @@ const proposalInfo = ref();
for="vote" for="vote"
class="btn btn-xs btn-primary rounded-sm" class="btn btn-xs btn-primary rounded-sm"
@click="dialog.open('vote', { proposal_id: item?.proposal_id })" @click="dialog.open('vote', { proposal_id: item?.proposal_id })"
>Vote</label
> >
<div <span v-if="item?.voterStatus">{{ item?.voterStatus.replace("VOTE_OPTION_", "")}}</span>
class="text-xs truncate relative py-1 px-3 rounded-full w-fit" <span v-else>Vote</span>
:class="`text-${voterStatusMap?.[item?.voterStatus]}`" </label
v-show="item?.voterStatus !== 'No With Veto'"
> >
<span
class="inset-x-0 inset-y-0 opacity-10 absolute"
:class="`bg-${voterStatusMap?.[item?.voterStatus]}`"
></span>
{{ item?.voterStatus }}
</div>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -18,12 +18,14 @@ PageRequest,
import { ref, reactive } from 'vue'; import { ref, reactive } from 'vue';
import Countdown from '@/components/Countdown.vue'; import Countdown from '@/components/Countdown.vue';
import PaginationBar from '@/components/PaginationBar.vue' import PaginationBar from '@/components/PaginationBar.vue'
import { fromBech32, toHex } from '@cosmjs/encoding';
const props = defineProps(['proposal_id', 'chain']); const props = defineProps(['proposal_id', 'chain']);
const proposal = ref({} as GovProposal); const proposal = ref({} as GovProposal);
const format = useFormatter(); const format = useFormatter();
const store = useGovStore(); const store = useGovStore();
const dialog = useTxDialog(); const dialog = useTxDialog();
const stakingStore = useStakingStore();
store.fetchProposal(props.proposal_id).then((res) => { store.fetchProposal(props.proposal_id).then((res) => {
const proposalDetail = reactive(res.proposal); const proposalDetail = reactive(res.proposal);
@ -102,7 +104,7 @@ const total = computed(() => {
const turnout = computed(() => { const turnout = computed(() => {
if (total.value > 0) { 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 format.percent(total.value / Number(bonded));
} }
return 0; 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) { function pageload(p: number) {
pageRequest.value.setPage(p) pageRequest.value.setPage(p)
store store
@ -324,7 +333,7 @@ function pageload(p: number) {
<table class="table w-full table-zebra"> <table class="table w-full table-zebra">
<tbody> <tbody>
<tr v-for="(item, index) of votes" :key="index"> <tr v-for="(item, index) of votes" :key="index">
<td class="py-2 text-sm">{{ item.voter }}</td> <td class="py-2 text-sm">{{ showValidatorName(item.voter) }}</td>
<td <td
class="py-2 text-sm" class="py-2 text-sm"
:class="{ :class="{
@ -332,7 +341,7 @@ function pageload(p: number) {
'text-gray-400': item.option === 'VOTE_OPTION_ABSTAIN', 'text-gray-400': item.option === 'VOTE_OPTION_ABSTAIN',
}" }"
> >
{{ item.option }} {{ String(item.option).replace("VOTE_OPTION_", "") }}
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -267,9 +267,7 @@ const color = computed(() => {
{{ format.formatToken(walletStore.balanceOfStakingToken) }} {{ format.formatToken(walletStore.balanceOfStakingToken) }}
</div> </div>
<div class="text-sm" :class="color"> <div class="text-sm" :class="color">
<span class="ml-1">
${{ format.tokenValue(walletStore.balanceOfStakingToken) }} ${{ format.tokenValue(walletStore.balanceOfStakingToken) }}
</span>
</div> </div>
</div> </div>
<div class="bg-gray-100 dark:bg-[#373f59] rounded-sm px-4 py-3"> <div class="bg-gray-100 dark:bg-[#373f59] rounded-sm px-4 py-3">

View File

@ -265,7 +265,7 @@ export const useDashboard = defineStore('dashboard', {
favorite: fav as string[], favorite: fav as string[],
favoriteMap: favMap as Record<string, boolean>, favoriteMap: favMap as Record<string, boolean>,
chains: {} as Record<string, ChainConfig>, chains: {} as Record<string, ChainConfig>,
prices: {}, prices: {} as Record<string, any>,
coingecko: {} as Record<string, {coinId: string, exponent: number, symbol: string}>, coingecko: {} as Record<string, {coinId: string, exponent: number, symbol: string}>,
}; };
}, },

View File

@ -69,7 +69,7 @@ export const useFormatter = defineStore('formatter', {
return trace; return trace;
}, },
priceInfo(denom: string) { priceInfo(denom: string) {
const id = this.dashboard.coingecko[denom]?.coinId; const id = this.dashboard.coingecko[denom]?.coinId || "";
const prices = this.dashboard.prices[id]; const prices = this.dashboard.prices[id];
return prices; return prices;
}, },
@ -96,7 +96,10 @@ export const useFormatter = defineStore('formatter', {
return v!==0 ? numeral(v).format("+0,0.[00]"): "" return v!==0 ? numeral(v).format("+0,0.[00]"): ""
}, },
tokenValue(token?: Coin) { 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) { tokenValueNumber(token?: Coin) {
if(!token) return 0 if(!token) return 0
@ -129,7 +132,7 @@ export const useFormatter = defineStore('formatter', {
formatToken( formatToken(
token?: { denom: string; amount: string }, token?: { denom: string; amount: string },
withDenom = true, withDenom = true,
fmt = '0.0a', fmt = '0,0.[0]',
mode = 'local' mode = 'local'
): string { ): string {
if (token && token.amount && token?.denom) { if (token && token.amount && token?.denom) {

View File

@ -42,8 +42,9 @@ export const useWalletStore = defineStore('walletStore', {
); );
}, },
stakingAmount() { stakingAmount() {
const stakingStore = useStakingStore();
let amt = 0; let amt = 0;
let denom = ''; let denom = stakingStore.params.bond_denom;
this.delegations.forEach((i) => { this.delegations.forEach((i) => {
amt += Number(i.balance.amount); amt += Number(i.balance.amount);
denom = i.balance.denom; denom = i.balance.denom;