Fix kelpr & delegation issue

This commit is contained in:
liangping 2021-09-16 22:43:58 +08:00
parent 310e022b26
commit ef730e4eaa
3 changed files with 8 additions and 9 deletions

View File

@ -129,7 +129,7 @@ export async function sign(device, chainId, signerAddress, messages, fee, memo,
// Ensure the address has some tokens to spend // Ensure the address has some tokens to spend
const client = await SigningStargateClient.offline(signer) const client = await SigningStargateClient.offline(signer)
return client.signAmino(toSignAddress(signerAddress), messages, fee, memo, signerData) return client.signAmino(device === 'keplr' ? signerAddress : toSignAddress(signerAddress), messages, fee, memo, signerData)
// return signDirect(signer, signerAddress, messages, fee, memo, signerData) // return signDirect(signer, signerAddress, messages, fee, memo, signerData)
} }

View File

@ -481,13 +481,13 @@ export default {
sign( sign(
this.wallet, this.wallet,
this.chainId, this.chainId,
this.address, this.selectedAddress,
txMsgs, txMsgs,
txFee, txFee,
this.memo, this.memo,
signerData, signerData,
).then(bodyBytes => { ).then(bodyBytes => {
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => { this.$http.broadcastTx(bodyBytes).then(res => {
setLocalTxHistory({ op: 'delegate', hash: res.tx_response.txhash, time: new Date() }) setLocalTxHistory({ op: 'delegate', hash: res.tx_response.txhash, time: new Date() })
this.$bvModal.hide('delegate-window') this.$bvModal.hide('delegate-window')
this.$toast({ this.$toast({

View File

@ -8,7 +8,7 @@
hide-header-close hide-header-close
scrollable scrollable
ok-title="Send" ok-title="Send"
:ok-disabled="!selectedAddress" :ok-disabled="!address"
@hidden="resetModal" @hidden="resetModal"
@ok="handleOk" @ok="handleOk"
@show="loadBalance" @show="loadBalance"
@ -270,7 +270,6 @@ export default {
}, },
data() { data() {
return { return {
selectedAddress: this.address,
availableAddress: [], availableAddress: [],
validators: [], validators: [],
selectedValidator: this.validatorAddress, selectedValidator: this.validatorAddress,
@ -310,7 +309,7 @@ export default {
}, },
tokenOptions() { tokenOptions() {
if (!this.delegations) return [] if (!this.delegations) return []
return this.delegations.filter(x => x.delegation.validator_address === this.selectedValidator).map(x => ({ value: x.balance.denom, label: formatToken(x.balance) })) return this.delegations.filter(x => x.delegation.validator_address === this.validatorAddress).map(x => ({ value: x.balance.denom, label: formatToken(x.balance) }))
}, },
feeDenoms() { feeDenoms() {
if (!this.balance) return [] if (!this.balance) return []
@ -335,7 +334,7 @@ export default {
this.balance = res this.balance = res
} }
}) })
this.$http.getLatestBlock(this.selectedChain).then(ret => { this.$http.getLatestBlock().then(ret => {
this.chainId = ret.block.header.chain_id this.chainId = ret.block.header.chain_id
const notSynced = timeIn(ret.block.header.time, 10, 'm') const notSynced = timeIn(ret.block.header.time, 10, 'm')
if (notSynced) { if (notSynced) {
@ -344,7 +343,7 @@ export default {
this.error = null this.error = null
} }
}) })
this.$http.getAuthAccount(this.selectedAddress, this.selectedChain).then(ret => { this.$http.getAuthAccount(this.address).then(ret => {
if (ret.value.base_vesting_account) { if (ret.value.base_vesting_account) {
this.accountNumber = ret.value.base_vesting_account.base_account.account_number this.accountNumber = ret.value.base_vesting_account.base_account.account_number
this.sequence = ret.value.base_vesting_account.base_account.sequence this.sequence = ret.value.base_vesting_account.base_account.sequence
@ -354,7 +353,7 @@ export default {
this.sequence = ret.value.sequence ? ret.value.sequence : 0 this.sequence = ret.value.sequence ? ret.value.sequence : 0
} }
}) })
this.$http.getStakingDelegations(this.selectedAddress).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
this.delegations = res.delegation_responses this.delegations = res.delegation_responses
this.delegations.forEach(x => { this.delegations.forEach(x => {
if (x.delegation.validator_address === this.validatorAddress) { if (x.delegation.validator_address === this.validatorAddress) {