This commit is contained in:
donne1226 2022-04-01 23:28:42 +08:00
parent ae9bf25abf
commit 7c93f6f7c7
9 changed files with 362 additions and 102 deletions

View File

@ -164,6 +164,15 @@
> >
{{ $t('btn_deposit') }} {{ $t('btn_deposit') }}
</b-button> </b-button>
<b-button
v-if="p.status===1"
v-b-modal.operation-modal
variant="primary"
class="btn float-right mg-2"
@click="selectProposal('GovDeposit',p.id, p.title)"
>
{{ $t('btn_deposit') }}1
</b-button>
<b-button <b-button
v-if="p.status===2" v-if="p.status===2"
v-b-modal.vote-window v-b-modal.vote-window

View File

@ -6,7 +6,7 @@
<b-card-header> <b-card-header>
<b-card-title>Outstanding Rewards</b-card-title> <b-card-title>Outstanding Rewards</b-card-title>
<feather-icon <feather-icon
v-b-modal.withdraw-commission-window v-b-modal.operation-modal
icon="MoreVerticalIcon" icon="MoreVerticalIcon"
size="18" size="18"
class="cursor-pointer" class="cursor-pointer"
@ -83,11 +83,24 @@
> >
Withdraw Commission Withdraw Commission
</b-button> </b-button>
<b-button
v-b-modal.operation-modal
block
size="sm"
variant="primary"
>
Withdraw Commission1
</b-button>
</b-card-body> </b-card-body>
<operation-withdraw-commission-component <operation-withdraw-commission-component
:validator-address="validator" :validator-address="validator"
:address="address" :address="address"
/> />
<operation-modal
type="WithdrawCommission"
:address="address"
:validator-address="validator"
/>
</b-card> </b-card>
</template> </template>
@ -98,6 +111,7 @@ import {
import { sha256 } from '@cosmjs/crypto' import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding' import { toHex } from '@cosmjs/encoding'
import { formatToken, numberWithCommas } from '@/libs/utils' import { formatToken, numberWithCommas } from '@/libs/utils'
import OperationModal from '@/views/components/OperationModal/index.vue'
import OperationWithdrawCommissionComponent from './OperationWithdrawCommissionComponent.vue' import OperationWithdrawCommissionComponent from './OperationWithdrawCommissionComponent.vue'
export default { export default {
@ -112,6 +126,7 @@ export default {
BMediaAside, BMediaAside,
BAvatar, BAvatar,
OperationWithdrawCommissionComponent, OperationWithdrawCommissionComponent,
OperationModal,
}, },
props: { props: {
data: { data: {

View File

@ -0,0 +1,194 @@
<template>
<div>
<b-row>
<b-col>
<h4>{{ proposalId }}. {{ proposalTitle }}</h4>
</b-col>
</b-row>
<b-row>
<b-col>
<b-form-group
label="Depositor"
label-for="Voter"
>
<validation-provider
#default="{ errors }"
rules="required"
name="Voter"
>
<b-form-input
v-model="address"
readonly
/>
<small class="text-danger">{{ errors[0] }}</small>
</validation-provider>
</b-form-group>
</b-col>
</b-row>
<b-row>
<b-col>
<b-form-group
label="Available Token"
label-for="Token"
>
<validation-provider
#default="{ errors }"
rules="required"
name="Token"
>
<b-form-select
v-model="token"
>
<b-form-select-option
v-for="item in balanceOptions"
:key="item.denom"
:value="item.denom"
>
{{ format(item) }}
</b-form-select-option>
</b-form-select>
<small class="text-danger">{{ errors[0] }}</small>
</validation-provider>
</b-form-group>
</b-col>
</b-row>
<b-row>
<b-col>
<b-form-group
label="Amount"
label-for="Amount"
>
<validation-provider
v-slot="{ errors }"
rules="required|regex:^([0-9\.]+)$"
name="amount"
>
<b-input-group class="mb-25">
<b-form-input
id="Amount"
v-model="amount"
:state="errors.length > 0 ? false:null"
placeholder="Input a number"
type="number"
/>
<b-input-group-append is-text>
{{ printDenom() }}
</b-input-group-append>
</b-input-group>
<small class="text-danger">{{ errors[0] }}</small>
</validation-provider>
</b-form-group>
</b-col>
</b-row>
</div>
</template>
<script>
import { ValidationProvider } from 'vee-validate'
import {
BRow, BCol, BInputGroup, BFormInput, BFormGroup, BFormSelect,
BInputGroupAppend, BFormSelectOption,
} from 'bootstrap-vue'
import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations'
import {
formatToken, formatTokenDenom, getUnitAmount,
} from '@/libs/utils'
export default {
name: 'DepositDialogue',
components: {
BRow,
BCol,
BInputGroup,
BFormInput,
BFormGroup,
BFormSelect,
BInputGroupAppend,
BFormSelectOption,
ValidationProvider,
},
props: {
proposalId: {
type: Number,
required: true,
},
proposalTitle: {
type: String,
required: true,
},
balance: {
type: Array,
default: () => [],
},
address: {
type: String,
default: null,
},
},
data() {
return {
token: null,
amount: '',
required,
password,
email,
min,
integer,
url,
alpha,
between,
digits,
length,
alphaDash,
}
},
computed: {
msg() {
return [{
typeUrl: '/cosmos.gov.v1beta1.MsgDeposit',
value: {
depositor: this.address,
proposalId: String(this.proposalId),
amount: [
{
amount: getUnitAmount(this.amount, this.token),
denom: this.token,
},
],
},
}]
},
balanceOptions() {
return this.setupBalance()
},
},
mounted() {
this.$emit('update', {
modalTitle: 'Deposit',
historyName: 'deposit',
})
},
methods: {
printDenom() {
return formatTokenDenom(this.token)
},
format(v) {
return formatToken(v)
},
setupBalance() {
if (this.balance && this.balance.length > 0) {
this.token = this.balance[0].denom
return this.balance
}
return []
},
},
}
</script>
<style lang="scss">
@import '@core/scss/vue/libs/vue-select.scss';
</style>

View File

@ -177,7 +177,6 @@ export default {
token: '', token: '',
amount: null, amount: null,
recipient: null, recipient: null,
error: null,
IBCDenom: {}, IBCDenom: {},
paths: {}, paths: {},
destination: {}, destination: {},

View File

@ -119,7 +119,6 @@ export default {
data() { data() {
return { return {
validators: [], validators: [],
selectedValidator: this.validatorAddress,
token: '', token: '',
amount: null, amount: null,
delegations: [], delegations: [],

View File

@ -16,14 +16,11 @@
rules="required" rules="required"
name="Voter" name="Voter"
> >
<b-form-select <b-form-input
v-model="voter" v-model="address"
:options="accounts" readonly
text-field="label"
placeholder="Select an address"
@change="onChange"
/> />
<small class="text-danger">{{ errors[0] }} <strong v-if="!accounts || accounts.length === 0">Please import an account first!</strong> </small> <small class="text-danger">{{ errors[0] }}</small>
</validation-provider> </validation-provider>
</b-form-group> </b-form-group>
</b-col> </b-col>
@ -33,6 +30,11 @@
<b-form-group <b-form-group
label="Option" label="Option"
label-for="option" label-for="option"
>
<validation-provider
#default="{ errors }"
rules="required"
name="option"
> >
<div class="demo-inline-spacing"> <div class="demo-inline-spacing">
@ -69,6 +71,8 @@
Abstain Abstain
</b-form-radio> </b-form-radio>
</div> </div>
<small class="text-danger">{{ errors[0] }}</small>
</validation-provider>
</b-form-group> </b-form-group>
</b-col> </b-col>
</b-row> </b-row>
@ -78,15 +82,14 @@
<script> <script>
import { ValidationProvider } from 'vee-validate' import { ValidationProvider } from 'vee-validate'
import { import {
BRow, BCol, BFormGroup, BFormSelect, BRow, BCol, BFormGroup, BFormInput,
BFormRadio, BFormRadio,
} from 'bootstrap-vue' } from 'bootstrap-vue'
import { import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations' } from '@validations'
import { import {
abbrAddress, formatToken,
formatToken, getLocalAccounts,
} from '@/libs/utils' } from '@/libs/utils'
export default { export default {
@ -95,9 +98,9 @@ export default {
BRow, BRow,
BCol, BCol,
BFormGroup, BFormGroup,
BFormSelect,
BFormRadio, BFormRadio,
ValidationProvider, ValidationProvider,
BFormInput,
}, },
props: { props: {
proposalId: { proposalId: {
@ -108,14 +111,14 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
address: {
type: String,
default: null,
},
}, },
data() { data() {
return { return {
accounts: [],
voter: null,
option: null, option: null,
balance: [],
feeDenom: '',
required, required,
password, password,
@ -135,7 +138,7 @@ export default {
return [{ return [{
typeUrl: '/cosmos.gov.v1beta1.MsgVote', typeUrl: '/cosmos.gov.v1beta1.MsgVote',
value: { value: {
voter: this.voter, voter: this.address,
proposalId: this.proposalId, proposalId: this.proposalId,
option: Number(this.option), option: Number(this.option),
}, },
@ -147,40 +150,9 @@ export default {
modalTitle: 'Vote', modalTitle: 'Vote',
historyName: 'vote', historyName: 'vote',
}) })
this.loadData()
}, },
methods: { methods: {
computeAccount() {
let array = []
const accounts = getLocalAccounts()
if (accounts) {
const values = Object.values(accounts)
for (let i = 0; i < values.length; i += 1) {
const addrs = values[i].address.filter(x => x.chain === this.$route.params.chain)
if (addrs && addrs.length > 0) {
array = array.concat(addrs.map(x => ({ value: x.addr, label: values[i].name.concat(' - ', abbrAddress(x.addr)) })))
}
}
}
return array
},
onChange() {
if (this.voter) {
this.$http.getBankBalances(this.voter).then(res => {
if (res && res.length > 0) {
this.balance = res.reverse()
const token = this.balance.find(i => !i.denom.startsWith('ibc'))
if (token) this.feeDenom = token.denom
}
})
}
},
loadData() {
this.accounts = this.computeAccount()
// eslint-disable-next-line prefer-destructuring
if (this.accounts && this.accounts.length > 0) this.voter = this.accounts[0].value
this.onChange()
},
format(v) { format(v) {
return formatToken(v) return formatToken(v)
}, },

View File

@ -22,9 +22,6 @@
import { import {
BRow, BCol, BInputGroup, BFormInput, BFormGroup, BRow, BCol, BInputGroup, BFormInput, BFormGroup,
} from 'bootstrap-vue' } from 'bootstrap-vue'
import {
required, email, url, between, alpha, integer, password, min, digits, alphaDash, length,
} from '@validations'
export default { export default {
name: 'WithdrawDialogue', name: 'WithdrawDialogue',
@ -47,18 +44,6 @@ export default {
balance: [], balance: [],
delegations: [], delegations: [],
feeDenom: '', feeDenom: '',
required,
password,
email,
min,
integer,
url,
alpha,
between,
digits,
length,
alphaDash,
} }
}, },
computed: { computed: {
@ -87,7 +72,6 @@ export default {
methods: { methods: {
loadData() { loadData() {
this.$http.getStakingDelegations(this.address).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
console.log(res)
this.delegations = res.delegation_responses this.delegations = res.delegation_responses
}) })
}, },

View File

@ -0,0 +1,84 @@
<template>
<div>
<b-row>
<b-col>
<b-form-group
label="Sender"
label-for="Account"
>
<b-input-group class="mb-25">
<b-form-input
:value="address"
readonly
/>
</b-input-group>
</b-form-group>
</b-col>
</b-row>
</div>
</template>
<script>
import {
BRow,
BCol,
BInputGroup,
BFormInput,
BFormGroup,
} from 'bootstrap-vue'
export default {
name: 'WithdrawCommissionDialogue',
components: {
BRow,
BCol,
BInputGroup,
BFormInput,
BFormGroup,
},
props: {
address: {
type: String,
default: '',
},
validatorAddress: {
type: String,
default: '',
},
},
data() {
return {
}
},
computed: {
msg() {
return [
{
typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward',
value: {
delegatorAddress: this.address,
validatorAddress: this.validatorAddress,
},
},
{
typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission',
value: {
validatorAddress: this.validatorAddress,
},
},
]
},
},
mounted() {
this.$emit('update', {
modalTitle: 'Withdraw Validator Commission',
historyName: 'withdraw',
})
},
methods: {
},
}
</script>

View File

@ -40,7 +40,7 @@
<component <component
:is="type" :is="type"
ref="component" ref="component"
:address="address" :address="selectedAddress"
:validator-address="validatorAddress" :validator-address="validatorAddress"
:balance="balance" :balance="balance"
:proposal-id="proposalId" :proposal-id="proposalId"
@ -160,6 +160,8 @@ import Unbond from './components/Unbond.vue'
import Transfer from './components/Transfer.vue' import Transfer from './components/Transfer.vue'
import IBCTransfer from './components/IBCTransfer.vue' import IBCTransfer from './components/IBCTransfer.vue'
import Vote from './components/Vote.vue' import Vote from './components/Vote.vue'
import WithdrawCommission from './components/WithdrawCommission.vue'
import GovDeposit from './components/GovDeposit.vue'
export default { export default {
name: 'DelegateDialogue', name: 'DelegateDialogue',
@ -192,6 +194,8 @@ export default {
Transfer, Transfer,
IBCTransfer, IBCTransfer,
Vote, Vote,
WithdrawCommission,
GovDeposit,
}, },
directives: { directives: {
Ripple, Ripple,