show all error message

This commit is contained in:
liangping 2021-09-18 17:05:07 +08:00
parent 9fd2aa33ed
commit ef76cc6752
10 changed files with 68 additions and 32 deletions

View File

@ -357,7 +357,7 @@ export default {
if (this.selectedAddress) { if (this.selectedAddress) {
this.$http.getBankBalances(this.selectedAddress).then(res => { this.$http.getBankBalances(this.selectedAddress).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
const token = this.balance.find(i => !i.denom.startsWith('ibc')) const token = this.balance.find(i => !i.denom.startsWith('ibc'))
this.token = token.denom this.token = token.denom
if (token) this.feeDenom = token.denom if (token) this.feeDenom = token.denom

View File

@ -352,7 +352,7 @@ export default {
}) })
this.$http.getBankBalances(this.address).then(res => { this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
} }
}) })
this.$http.getLatestBlock().then(ret => { this.$http.getLatestBlock().then(ret => {

View File

@ -51,6 +51,7 @@
> >
<b-form-select <b-form-select
v-model="token" v-model="token"
@change="tokenChange"
> >
<b-form-select-option <b-form-select-option
v-for="item in balance" v-for="item in balance"
@ -104,12 +105,12 @@
rules="required" rules="required"
name="destination" name="destination"
> >
<b-input-group class="mb-25">
<v-select <v-select
v-model="destination" v-model="destination"
name="destination"
:options="destinationOptions"
placeholder="Select a channel" placeholder="Select a channel"
/> />
</b-input-group>
<small class="text-danger">{{ errors[0] }}</small> <small class="text-danger">{{ errors[0] }}</small>
</validation-provider> </validation-provider>
</b-form-group> </b-form-group>
@ -131,6 +132,7 @@
id="Recipient" id="Recipient"
v-model="recipient" v-model="recipient"
:state="errors.length > 0 ? false:null" :state="errors.length > 0 ? false:null"
:placeholder="placeholder"
/> />
</b-input-group> </b-input-group>
<small class="text-danger">{{ errors[0] }}</small> <small class="text-danger">{{ errors[0] }}</small>
@ -282,6 +284,8 @@ import {
import { Cosmos } from '@cosmostation/cosmosjs' import { Cosmos } from '@cosmostation/cosmosjs'
import vSelect from 'vue-select' import vSelect from 'vue-select'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue' import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
import { coin } from '@cosmjs/amino'
import dayjs from 'dayjs'
export default { export default {
name: 'TransforDialogue', name: 'TransforDialogue',
@ -335,6 +339,7 @@ export default {
advance: false, advance: false,
paths: {}, paths: {},
destination: {}, destination: {},
channels: [],
required, required,
password, password,
@ -353,11 +358,23 @@ export default {
feeDenoms() { feeDenoms() {
return this.balance.filter(item => !item.denom.startsWith('ibc')) return this.balance.filter(item => !item.denom.startsWith('ibc'))
}, },
destinationOptions() {
const options = this.channels.map(x => ({ port_id: x.port_id, channel_id: x.channel_id, label: `${x.chain_id ? x.chain_id : ''} ${x.port_id}/${x.channel_id}` }))
const query = this.paths[this.token]
return query && String(this.token).startsWith('ibc/') ? options.filter(x => x.channel_id === query.channel_id) : options
},
placeholder() {
return 'Input a destination address'
},
}, },
created() { created() {
// console.log('address: ', this.address) // console.log('address: ', this.address)
}, },
methods: { methods: {
tokenChange() {
this.destination = null
this.recipient = null
},
printDenom() { printDenom() {
return formatTokenDenom(this.IBCDenom[this.token] || this.token) return formatTokenDenom(this.IBCDenom[this.token] || this.token)
}, },
@ -375,12 +392,13 @@ export default {
return null return null
}, },
loadBalance() { loadBalance() {
this.destination = null
this.account = this.computeAccount() this.account = this.computeAccount()
if (this.account && this.account.length > 0) this.address = this.account[0].addr if (this.account && this.account.length > 0) this.address = this.account[0].addr
if (this.address) { if (this.address) {
this.$http.getBankBalances(this.address, this.selectedChain).then(res => { this.$http.getBankBalances(this.address, this.selectedChain).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
this.token = this.balance[0].denom this.token = this.balance[0].denom
this.feeDenom = this.balance.find(x => !x.denom.startsWith('ibc')).denom this.feeDenom = this.balance.find(x => !x.denom.startsWith('ibc')).denom
this.balance.filter(i => i.denom.startsWith('ibc')).forEach(x => { this.balance.filter(i => i.denom.startsWith('ibc')).forEach(x => {
@ -390,8 +408,8 @@ export default {
// console.log(denom.denom_trace) // console.log(denom.denom_trace)
const path = denom.denom_trace.path.split('/') const path = denom.denom_trace.path.split('/')
this.paths[x.denom] = { this.paths[x.denom] = {
channel: path[1], channel_id: path[1],
port: path[0], port_id: path[0],
} }
}) })
} }
@ -425,10 +443,13 @@ export default {
chans.forEach((x, i) => { chans.forEach((x, i) => {
this.$http.getIBCChannelClientState(x.channel_id, x.port_id, this.selectedChain).then(cs => { this.$http.getIBCChannelClientState(x.channel_id, x.port_id, this.selectedChain).then(cs => {
chans[i].chain_id = cs.identified_client_state.client_state.chain_id chans[i].chain_id = cs.identified_client_state.client_state.chain_id
// console.log(i, chans[i]) this.$store.commit('setChannels', { chain: this.selectedChain.chain_name, channels: chans })
this.$set(this, 'channels', chans)
}) })
}) })
}) })
} else {
this.channels = channels
} }
} }
}, },
@ -455,27 +476,25 @@ export default {
cosmos.getAccounts() cosmos.getAccounts()
}, },
async send() { async send() {
if (!this.destination) {
this.error = 'You have to select a destination'
return
}
const txMsgs = [ const txMsgs = [
{ {
typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', typeUrl: '/ibc.applications.transfer.v1.MsgTransfer',
value: { value: {
source_port: this.paths[this.token].port, sourcePort: this.destination.port_id,
source_channel: this.paths[this.token].channel, sourceChannel: this.destination.channel_id,
token: { token: coin(Number(this.amount) * 1000000, this.token),
amount: String((Number(this.amount) * 1000000).toFixed()),
denom: this.token,
},
sender: this.address, sender: this.address,
receiver: this.recipient, receiver: this.recipient,
// timeout_height: this.timeoutHeight ? { revision_height: '', revision_number: '' } : {}, timeoutHeight: { revisionHeight: '1000', revisionNumber: '1000' },
// timeout_timestamp: null, timeoutTimestamp: String(dayjs().add(5, 'm') * 1000),
}, },
}, },
] ]
// console.log(txMsgs)
if (this.token) return
const txFee = { const txFee = {
amount: [ amount: [
{ {
@ -492,6 +511,8 @@ export default {
chainId: this.chainId, chainId: this.chainId,
} }
console.log(txMsgs, txFee, signerData)
sign( sign(
this.wallet, this.wallet,
this.chainId, this.chainId,

View File

@ -354,7 +354,7 @@ export default {
if (this.address) { if (this.address) {
this.$http.getBankBalances(this.address, this.selectedChain).then(res => { this.$http.getBankBalances(this.address, this.selectedChain).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
this.token = this.balance[0].denom this.token = this.balance[0].denom
this.feeDenom = this.balance.find(x => !x.denom.startsWith('ibc')).denom this.feeDenom = this.balance.find(x => !x.denom.startsWith('ibc')).denom
this.balance.filter(i => i.denom.startsWith('ibc')).forEach(x => { this.balance.filter(i => i.denom.startsWith('ibc')).forEach(x => {

View File

@ -331,7 +331,7 @@ export default {
} }
this.$http.getBankBalances(this.address).then(res => { this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
} }
}) })
this.$http.getLatestBlock().then(ret => { this.$http.getLatestBlock().then(ret => {

View File

@ -315,7 +315,7 @@ export default {
if (this.voter) { if (this.voter) {
this.$http.getBankBalances(this.voter).then(res => { this.$http.getBankBalances(this.voter).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
const token = this.balance.find(i => !i.denom.startsWith('ibc')) const token = this.balance.find(i => !i.denom.startsWith('ibc'))
if (token) this.feeDenom = token.denom if (token) this.feeDenom = token.denom
} }

View File

@ -246,7 +246,7 @@ export default {
loadBalance() { loadBalance() {
this.$http.getBankBalances(this.address).then(res => { this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
const token = this.balance.find(i => !i.denom.startsWith('ibc')) const token = this.balance.find(i => !i.denom.startsWith('ibc'))
if (token) this.feeDenom = token.denom if (token) this.feeDenom = token.denom
} }

View File

@ -267,7 +267,7 @@ export default {
if (this.address) { if (this.address) {
this.$http.getBankBalances(this.address).then(res => { this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res this.balance = res.reverse()
const token = this.balance.find(i => !i.denom.startsWith('ibc')) const token = this.balance.find(i => !i.denom.startsWith('ibc'))
if (token) this.feeDenom = token.denom if (token) this.feeDenom = token.denom
} }

View File

@ -24,7 +24,7 @@
<b-tr> <b-tr>
<b-td> <b-td>
{{ 'status' }} {{ 'status' }}
</b-td><b-td> <b-badge </b-td><b-td class="text-wrap"> <b-badge
v-if="tx.code===0" v-if="tx.code===0"
variant="light-success" variant="light-success"
> >

View File

@ -175,11 +175,16 @@
<b-card <b-card
v-if="account" v-if="account"
:title="accountTitle" title="Profile"
class="text-trancate" class="text-trancate"
> >
<b-table-simple stacked="sm"> <b-table-simple stacked="sm">
<b-tbody v-if="account.type === 'cosmos-sdk/BaseAccount'"> <b-tbody v-if="account.type === 'cosmos-sdk/BaseAccount'">
<b-tr>
<b-td>
Account Type
</b-td><b-td> {{ account.type }} </b-td>
</b-tr>
<b-tr> <b-tr>
<b-td class="max-width:100px;"> <b-td class="max-width:100px;">
Account Number Account Number
@ -192,7 +197,12 @@
<b-td> Public Key </b-td><b-td> <object-field-component :tablefield="account.value.public_key" /> </b-td> <b-td> Public Key </b-td><b-td> <object-field-component :tablefield="account.value.public_key" /> </b-td>
</b-tr> </b-tr>
</b-tbody> </b-tbody>
<b-tbody v-if="account.type === 'cosmos-sdk/PeriodicVestingAccount'"> <b-tbody v-else-if="account.type === 'cosmos-sdk/PeriodicVestingAccount'">
<b-tr>
<b-td>
Account Type
</b-td><b-td> {{ account.type }} </b-td>
</b-tr>
<b-tr> <b-tr>
<b-td class="max-width:100px;"> <b-td class="max-width:100px;">
Account Number Account Number
@ -231,7 +241,12 @@
</b-td> </b-td>
</b-tr> </b-tr>
</b-tbody> </b-tbody>
<b-tbody v-if="account.type === 'cosmos-sdk/DelayedVestingAccount'"> <b-tbody v-else-if="account.type === 'cosmos-sdk/DelayedVestingAccount'">
<b-tr>
<b-td>
Account Type
</b-td><b-td> {{ account.type }} </b-td>
</b-tr>
<b-tr> <b-tr>
<b-td style="max-width:100px;"> <b-td style="max-width:100px;">
Account Number Account Number