fetch timeout and channel/port from encounterpart

This commit is contained in:
liangping 2021-11-30 11:59:17 +08:00
parent f9052e2fe0
commit f0ef39e96a
3 changed files with 18 additions and 14 deletions

View File

@ -335,6 +335,12 @@ export default class ChainFetch {
return this.get(`/ibc/core/channel/v1beta1/channels/${channel_id}/ports/${port_id}/client_state`, config).then(data => commonProcess(data)) return this.get(`/ibc/core/channel/v1beta1/channels/${channel_id}/ports/${port_id}/client_state`, config).then(data => commonProcess(data))
} }
// eslint-disable-next-line camelcase
async getIBCChannel(channel_id, port_id, config = null) {
// eslint-disable-next-line camelcase
return this.get(`/ibc/core/channel/v1beta1/channels/${channel_id}/ports/${port_id}`, config).then(data => commonProcess(data))
}
static async getBankBalance(baseurl, address) { static async getBankBalance(baseurl, address) {
return ChainFetch.fetch(baseurl, '/bank/balances/'.concat(address)).then(data => commonProcess(data)) return ChainFetch.fetch(baseurl, '/bank/balances/'.concat(address)).then(data => commonProcess(data))
} }

View File

@ -69,10 +69,7 @@ export function getChainConfigForSymbol(symbol) {
const key = CoinGeckoMap[symbol] const key = CoinGeckoMap[symbol]
if (key) { if (key) {
const confs = getLocalChains() const confs = getLocalChains()
return Object.values(confs).find(x => { return Object.values(confs).find(x => x.coingecko === key[0])
console.log(x.coingecko, key)
return x.coingecko === key[0]
})
} }
return null return null
} }

View File

@ -302,6 +302,7 @@ export default {
paths: {}, paths: {},
destination: {}, destination: {},
channels: [], channels: [],
timeoutHeight: {},
required, required,
password, password,
@ -328,7 +329,6 @@ export default {
} }
} }
this.selectedChain = getChainConfigForSymbol(this.symbol) this.selectedChain = getChainConfigForSymbol(this.symbol)
console.log('selected chain: ', this.selectedChain)
}, },
computeAccount() { computeAccount() {
this.recipientAddress() this.recipientAddress()
@ -351,11 +351,12 @@ export default {
this.token = '' this.token = ''
this.computeAccount() this.computeAccount()
this.loadBalance() this.loadBalance()
console.log('denom trace:', this.denomTrace)
if (this.denomTrace) { if (this.denomTrace) {
const part = this.denomTrace.path.split('/') const part = this.denomTrace.path.split('/')
this.destination = { sourcePort: part[0], sourceChannel: part[1] } this.$http.getIBCChannel(part[1], part[0]).then(data => {
console.log(this.destination) this.destination = data.channel.counterparty
this.timeoutHeight = data.proof_height
})
} }
}, },
loadBalance() { loadBalance() {
@ -415,13 +416,13 @@ export default {
{ {
typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', typeUrl: '/ibc.applications.transfer.v1.MsgTransfer',
value: { value: {
sourcePort: this.destination.sourcePort, sourcePort: this.destination.port_id,
sourceChannel: 'channel-141', // this.destination.sourceChannel, sourceChannel: this.destination.channel_id,
token: coin(Number(getUnitAmount(this.amount, this.denomTrace.base_denom)), this.denomTrace.base_denom), token: coin(Number(getUnitAmount(this.amount, this.denomTrace.base_denom)), this.denomTrace.base_denom),
sender: this.address, sender: this.address,
receiver: this.recipient, receiver: this.recipient,
// timeoutHeight: undefined, // { revisionHeight: '0', revisionNumber: '0' }, timeoutHeight: this.timeoutHeight,
timeoutTimestamp: String((Math.floor(Date.now() / 1000) + 10) * 1_000_000_000), // timeoutTimestamp: '0',
}, },
}, },
] ]
@ -454,8 +455,8 @@ export default {
signerData, signerData,
).then(bodyBytes => { ).then(bodyBytes => {
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => { this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
setLocalTxHistory({ op: 'send', hash: res.txhash, time: new Date() }) setLocalTxHistory({ op: 'ibc_sender', hash: res.txhash, time: new Date() })
this.$bvModal.hide('ibc-transfer-window') this.$bvModal.hide('trading-deposte-window')
this.$toast({ this.$toast({
component: ToastificationContent, component: ToastificationContent,
props: { props: {