Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Fix the home delegation data
Browse files Browse the repository at this point in the history
  • Loading branch information
atmoner committed Jan 17, 2024
1 parent 67e7591 commit 8531748
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
49 changes: 27 additions & 22 deletions components/DelegateHomeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
min-width="200"
class="mt-8 white--text"
color="#0FB786"
@click="dialog = true"
@click="openDialog()"
>
<v-icon class="mr-2">
mdi-cube-send
Expand Down Expand Up @@ -67,7 +67,7 @@
>
<v-row>
<v-col cols="12">
<span class="text-left carmenBold">Available: {{ amount }} BCNA</span>
<span class="text-left carmenBold">Available: {{ amountAvailable }} BCNA</span>
<br><br>
<h3 class="mt-1 ml-1 carmenBold">
Amount to delegate*
Expand Down Expand Up @@ -335,7 +335,7 @@ function countPlaces(num) {
export default {
props: [
"chainIdProps",
"balances",
"amountAvailable",
],
setup() {
const store = useAppStore()
Expand Down Expand Up @@ -366,15 +366,15 @@ export default {
'valoper"',
// v => bech32Validation(v) || 'Bad address (not bech32) ' + bech32Validation(v),
],
amount: instance.balances,
amount: instance.amountAvailable,
amountFinal: "",
amountRules: [
(v) => !!v || "Amount is required",
(v) => !isNaN(v) || "Amount must be number",
(v) =>
v <= instance.balances ||
v <= instance.amountAvailable ||
"Amount must be above delegated amount (" +
instance.balances +
instance.amountAvailable +
")",
(v) => countPlaces(v) < 7 || "Bad decimal",
],
Expand Down Expand Up @@ -403,29 +403,34 @@ export default {
}
},
},
async mounted() {
//await this.store.getStakingModule()
const selectValidatorList = [];
for (const i of this.store.allValidators) {
selectValidatorList.push({
'name': i.name,
'address': i.op_address,
});
}
this.validatorList = selectValidatorList;
this.validatorListSearch = this.validatorList;
created() {
},
methods: {
openDialog() {
this.dialog = true;
//await this.store.getStakingModule()
const selectValidatorList = [];
for (const i of this.store.allValidators) {
selectValidatorList.push({
'name': i.name,
'address': i.op_address,
});
}
this.validatorList = selectValidatorList;
this.validatorListSearch = this.validatorList;
},
getMax() {
this.amountFinal = this.amount;
this.amountFinal = this.amountAvailable;
},
getHalf() {
this.amountFinal = (this.amount / 2).toFixed(6);
this.amountFinal = (this.amountAvailable / 2).toFixed(6);
},
getQuarter() {
this.amountFinal = (this.amount / 4).toFixed(6);
this.amountFinal = (this.amountAvailable / 4).toFixed(6);
},
searchVal() {
if (!this.searchTerm) {
Expand Down
7 changes: 4 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@
color="#0FB786"
>
Stake
</v-btn> -->
</v-btn> -->
<DelegateHomeModal
v-if="store.logged"
:chain-id-props="cosmosConfig[store.chainSelected].coinLookup.addressPrefix"
:balances="store.spendableBalances"
:amount-available="store.spendableBalances"
/>
</span>
</v-col>
Expand Down Expand Up @@ -509,6 +509,7 @@ import axios from "axios"
import dayjs from "dayjs"
import QRCodeVue3 from "qrcode-vue3"
import useClipboard from '~/composables/useClipboard'
import { reverse, sortBy, orderBy, uniqWith, groupBy } from "lodash"
Expand All @@ -533,7 +534,7 @@ const categories = [
export default {
components: {
QRCodeVue3
QRCodeVue3
},
layout: "blog",
setup() {
Expand Down
2 changes: 2 additions & 0 deletions stores/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const useAppStore = defineStore('app', {
validatorDelegations: '',
validatorUnDelegations: '',
myAddressBook: [],
dataLoaded: false,
}),
actions: {
async refresh() {
Expand All @@ -64,6 +65,7 @@ export const useAppStore = defineStore('app', {
await this.getGovModule()
await this.getDelegations()
await this.getAddressBook()
this.dataLoaded = true
},
setChainId(chainId) {
this.chainSelected = chainId
Expand Down

0 comments on commit 8531748

Please sign in to comment.