Done IBC transfer

This commit is contained in:
liangping 2021-09-18 22:27:45 +08:00
parent ef76cc6752
commit 722a40e7b2
2 changed files with 43 additions and 16 deletions

View File

@ -53,6 +53,13 @@
v-model="token"
@change="tokenChange"
>
<template #first>
<b-form-select-option
value=""
>
-- Please select a token --
</b-form-select-option>
</template>
<b-form-select-option
v-for="item in balance"
:key="item.denom"
@ -285,7 +292,6 @@ import { Cosmos } from '@cosmostation/cosmosjs'
import vSelect from 'vue-select'
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
import { coin } from '@cosmjs/amino'
import dayjs from 'dayjs'
export default {
name: 'TransforDialogue',
@ -359,6 +365,7 @@ export default {
return this.balance.filter(item => !item.denom.startsWith('ibc'))
},
destinationOptions() {
if (!this.token && this.token === '') return []
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
@ -393,13 +400,14 @@ export default {
},
loadBalance() {
this.destination = null
this.token = ''
this.account = this.computeAccount()
if (this.account && this.account.length > 0) this.address = this.account[0].addr
if (this.address) {
this.$http.getBankBalances(this.address, this.selectedChain).then(res => {
if (res && res.length > 0) {
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.balance.filter(i => i.denom.startsWith('ibc')).forEach(x => {
if (!this.IBCDenom[x.denom]) {
@ -407,9 +415,11 @@ export default {
this.IBCDenom[x.denom] = denom.denom_trace.base_denom
// console.log(denom.denom_trace)
const path = denom.denom_trace.path.split('/')
this.paths[x.denom] = {
channel_id: path[1],
port_id: path[0],
if (path.length >= 2) {
this.paths[x.denom] = {
channel_id: path[path.length - 1],
port_id: path[path.length - 2],
}
}
})
}
@ -489,8 +499,8 @@ export default {
token: coin(Number(this.amount) * 1000000, this.token),
sender: this.address,
receiver: this.recipient,
timeoutHeight: { revisionHeight: '1000', revisionNumber: '1000' },
timeoutTimestamp: String(dayjs().add(5, 'm') * 1000),
// timeoutHeight: undefined, // { revisionHeight: '0', revisionNumber: '0' },
timeoutTimestamp: String((Math.floor(Date.now() / 1000) + 60) * 1_000_000_000),
},
},
]
@ -511,8 +521,6 @@ export default {
chainId: this.chainId,
}
console.log(txMsgs, txFee, signerData)
sign(
this.wallet,
this.chainId,

View File

@ -37,13 +37,29 @@
>
<b-card-header class="pt-0 pl-0 pr-0">
<b-card-title>Assets</b-card-title>
<b-button
v-b-modal.transfer-window
variant="primary"
size="sm"
>
Transfer
</b-button>
<div>
<b-button
v-b-modal.transfer-window
variant="primary"
size="sm"
class="mr-25"
><feather-icon
icon="SendIcon"
class="d-md-none"
/>
<span class="d-none d-md-block">Transfer</span>
</b-button>
<b-button
v-b-modal.ibc-transfer-window
variant="success"
size="sm"
><feather-icon
icon="SendIcon"
class="d-md-none"
/>
<span class="d-none d-md-block">IBC Transfer
</span></b-button>
</div>
</b-card-header>
<b-card-body class="pl-0 pr-0">
<b-row>
@ -288,6 +304,7 @@
</b-popover>
<operation-transfer-component :address="address" />
<operation-transfer-2-component :address="address" />
<operation-withdraw-component :address="address" />
<operation-unbond-component
:address="address"
@ -325,6 +342,7 @@ import OperationWithdrawComponent from './OperationWithdrawComponent.vue'
import OperationUnbondComponent from './OperationUnbondComponent.vue'
import OperationDelegateComponent from './OperationDelegateComponent.vue'
import OperationRedelegateComponent from './OperationRedelegateComponent.vue'
import OperationTransfer2Component from './OperationTransfer2Component.vue'
export default {
components: {
@ -354,6 +372,7 @@ export default {
OperationDelegateComponent,
OperationRedelegateComponent,
OperationUnbondComponent,
OperationTransfer2Component,
},
directives: {
'b-modal': VBModal,