From 15e6b92ece09e8b912382aa5fca288333dd11fb9 Mon Sep 17 00:00:00 2001 From: donne1226 <503124742@qq.com> Date: Mon, 21 Mar 2022 23:10:30 +0800 Subject: [PATCH] redelegate --- src/views/WalletAccountDetail.vue | 21 +- .../OperationModal/components/Delegate.vue | 29 ++- .../OperationModal/components/Redelegate.vue | 240 ++++++++++++++++++ src/views/components/OperationModal/index.vue | 53 +--- 4 files changed, 282 insertions(+), 61 deletions(-) create mode 100644 src/views/components/OperationModal/components/Redelegate.vue diff --git a/src/views/WalletAccountDetail.vue b/src/views/WalletAccountDetail.vue index 5e67d6bd..cfc775e6 100644 --- a/src/views/WalletAccountDetail.vue +++ b/src/views/WalletAccountDetail.vue @@ -128,6 +128,7 @@ variant="primary" size="sm" class="mr-25" + @click="setOperationModalType('Delegate')" > + + + @@ -452,6 +462,7 @@ export default { unbonding: [], quotes: {}, transactions: [], + operationModalType: '', } }, computed: { @@ -638,8 +649,12 @@ export default { this.transactions = res }) }, - selectValue(v) { + selectValue(v, type) { this.selectedValidator = v + this.setOperationModalType(type) + }, + setOperationModalType(type) { + this.operationModalType = type }, formatHash: abbrAddress, formatDenom(v) { diff --git a/src/views/components/OperationModal/components/Delegate.vue b/src/views/components/OperationModal/components/Delegate.vue index 1e82b0bf..5a07009c 100644 --- a/src/views/components/OperationModal/components/Delegate.vue +++ b/src/views/components/OperationModal/components/Delegate.vue @@ -210,13 +210,20 @@ export default { }, }, mounted() { - console.log('mounted----------->') this.loadBalance() }, methods: { - printDenom() { - return formatTokenDenom(this.IBCDenom[this.token] || this.token) + loadBalance() { + this.account = this.computeAccount() + this.$http.getValidatorList().then(v => { + this.validators = v + }) + this.$http.getValidatorUnbondedList().then(v => { + this.unbundValidators = v + }) + this.onChange() }, + onChange() { if (this.selectedAddress) { this.$http.getBankBalances(this.selectedAddress).then(res => { @@ -234,7 +241,8 @@ export default { }) } }) - console.log(this.$parent) + console.log('onChange----------->') + // TODO: this.$emit() // this.$parent.getAuthAccount(this.selectedAddress) } }, @@ -254,17 +262,10 @@ export default { this.selectedValidator = this.validatorAddress return array }, - loadBalance() { - this.account = this.computeAccount() - // if (this.account && this.account.length > 0) this.selectedAddress - this.$http.getValidatorList().then(v => { - this.validators = v - }) - this.$http.getValidatorUnbondedList().then(v => { - this.unbundValidators = v - }) - this.onChange() + printDenom() { + return formatTokenDenom(this.IBCDenom[this.token] || this.token) }, + format(v) { return formatToken(v, this.IBCDenom) }, diff --git a/src/views/components/OperationModal/components/Redelegate.vue b/src/views/components/OperationModal/components/Redelegate.vue new file mode 100644 index 00000000..b051962d --- /dev/null +++ b/src/views/components/OperationModal/components/Redelegate.vue @@ -0,0 +1,240 @@ + + + + diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue index 0120d52e..ba92867b 100644 --- a/src/views/components/OperationModal/index.vue +++ b/src/views/components/OperationModal/index.vue @@ -41,7 +41,7 @@ :is="type" ref="component" :address="address" - :validator-address.sync="selectedValidator" + :validator-address="selectedValidator" /> @@ -143,13 +143,14 @@ import { required, email, url, between, alpha, integer, password, min, digits, alphaDash, length, } from '@validations' import { - abbrAddress, extractAccountNumberAndSequence, getLocalAccounts, setLocalTxHistory, sign, timeIn, + extractAccountNumberAndSequence, setLocalTxHistory, sign, timeIn, } from '@/libs/utils' import vSelect from 'vue-select' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import WalletInputVue from '../WalletInput.vue' import Delegate from './components/Delegate.vue' +import Redelegate from './components/Redelegate.vue' export default { name: 'DelegateDialogue', @@ -176,6 +177,7 @@ export default { // eslint-disable-next-line vue/no-unused-components ToastificationContent, Delegate, + Redelegate, }, directives: { Ripple, @@ -197,26 +199,20 @@ export default { data() { return { selectedAddress: this.address, - availableAddress: [], - validators: [], - unbundValidators: [], selectedValidator: null, token: '', - amount: null, chainId: '', - selectedChain: '', balance: [], - delegations: [], IBCDenom: {}, - memo: '', - fee: '900', - feeDenom: '', - wallet: 'ledgerUSB', error: null, sequence: 1, accountNumber: 0, advance: false, + fee: '900', + feeDenom: '', + wallet: 'ledgerUSB', gas: '200000', + memo: '', required, password, @@ -237,35 +233,8 @@ export default { return this.balance.filter(item => !item.denom.startsWith('ibc')) }, }, - created() { - // console.log('address: ', this.address) - }, methods: { - computeAccount() { - const accounts = getLocalAccounts() - const values = accounts ? Object.values(accounts) : [] - let array = [] - 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)) }))) - if (!this.selectedAddress) { - this.selectedAddress = addrs[0].addr - } - } - } - this.selectedValidator = this.validatorAddress - return array - }, loadBalance() { - this.account = this.computeAccount() - // if (this.account && this.account.length > 0) this.selectedAddress - this.$http.getValidatorList().then(v => { - this.validators = v - }) - this.$http.getValidatorUnbondedList().then(v => { - this.unbundValidators = v - }) this.$http.getLatestBlock().then(ret => { this.chainId = ret.block.header.chain_id const notSynced = timeIn(ret.block.header.time, 10, 'm') @@ -303,11 +272,7 @@ export default { }) }, handleOk(bvModalEvt) { - // console.log('send') - // Prevent modal from closing bvModalEvt.preventDefault() - // Trigger submit handler - // this.handleSubmit() this.$refs.simpleRules.validate().then(ok => { if (ok) { this.sendTx().then(ret => { @@ -365,7 +330,7 @@ export default { hash: res.tx_response.txhash, time: new Date(), }) - this.$bvModal.hide('delegate-window') + this.$bvModal.hide('operation-modal') this.$toast({ component: ToastificationContent, props: {