Skip to content

Commit

Permalink
Merge pull request ava-labs#125 from ava-labs/dev
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
kanatliemre authored Jan 8, 2021
2 parents fcfa21a + 1377cff commit cf0bdf5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/components/misc/CurrencyInputDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
<b>Balance:</b>
{{ maxAmountBig.toLocaleString(denomination) }}
</p>
<p v-if="asset_now.id === avaxAsset.id">
<b>$</b>
{{ amountUSD.toLocaleString(2) }}
</p>
<template v-if="asset_now">
<p v-if="asset_now.id === avaxAsset.id">
<b>$</b>
{{ amountUSD.toLocaleString(2) }}
</p>
</template>
</div>
<div></div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/components/wallet/TopCards/BalanceCard/BalanceCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import Big from 'big.js'
import { BN } from 'avalanche/dist'
import { ONEAVAX } from 'avalanche/dist/utils'
import { bnToBig } from '@/helpers/helper'
import { priceDict } from '@/store/types'
import { priceDict, WalletType } from '@/store/types'
@Component({
components: {
Expand Down Expand Up @@ -143,6 +143,7 @@ export default class BalanceCard extends Vue {
}
get evmUnlocked(): BN {
if (!this.wallet) return new BN(0)
// convert from ^18 to ^9
let bal = this.wallet.ethBalance
return bal.divRound(new BN(Math.pow(10, 9).toString()))
Expand Down Expand Up @@ -296,11 +297,12 @@ export default class BalanceCard extends Vue {
}
}
get wallet(): AvaHdWallet {
get wallet(): WalletType | null {
return this.$store.state.activeWallet
}
get isUpdateBalance(): boolean {
if (!this.wallet) return true
return this.wallet.isFetchUtxos
// return this.$store.state.Assets.isUpdateBalance
}
Expand Down
46 changes: 39 additions & 7 deletions src/views/wallet/Transfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ import { ChainIdType } from '@/constants'
import ChainInput from '@/components/wallet/transfer/ChainInput.vue'
import AvaAsset from '../../js/AvaAsset'
import { TxState } from '@/components/wallet/earn/ChainTransfer/types'
@Component({
components: {
FaucetLink,
Expand Down Expand Up @@ -189,6 +190,7 @@ export default class Transfer extends Vue {
txId = ''
canSendAgain = false
txState: TxState | null = null
confirm() {
let isValid = this.formCheck()
Expand Down Expand Up @@ -291,7 +293,7 @@ export default class Transfer extends Vue {
}
}
onsuccess() {
async onsuccess(txId: string) {
this.isAjax = false
this.isSuccess = true
this.clearForm()
Expand All @@ -303,12 +305,21 @@ export default class Transfer extends Vue {
})
// Update the user's balance
this.canSendAgain = false
setTimeout(() => {
this.$store.dispatch('Assets/updateUTXOs')
this.$store.dispatch('History/updateTransactionHistory')
// setTimeout(() => {
await this.$store.dispatch('Assets/updateUTXOs')
await this.$store.dispatch('History/updateTransactionHistory')
this.updateSendAgainLock()
// }, 3000)
}
updateSendAgainLock() {
if (!this.wallet.isFetchUtxos) {
this.canSendAgain = true
}, 3000)
} else {
setTimeout(() => {
this.updateSendAgainLock()
}, 1000)
}
}
onerror(err: any) {
Expand Down Expand Up @@ -336,14 +347,34 @@ export default class Transfer extends Vue {
this.$store
.dispatch('issueBatchTx', txList)
.then((res) => {
this.onsuccess()
this.canSendAgain = false
this.waitTxConfirm(res)
this.txId = res
})
.catch((err) => {
this.onerror(err)
})
}
async waitTxConfirm(txId: string) {
let status = await avm.getTxStatus(txId)
if (status === 'Unknown' || status === 'Processing') {
// if not confirmed ask again
setTimeout(() => {
this.waitTxConfirm(txId)
}, 500)
return false
} else if (status === 'Dropped') {
// If dropped stop the process
this.txState = TxState.failed
return false
} else {
// If success display success page
this.txState = TxState.success
this.onsuccess(txId)
}
}
get networkStatus(): string {
let stat = this.$store.state.Network.status
return stat
Expand Down Expand Up @@ -389,6 +420,7 @@ export default class Transfer extends Vue {
let res = new BN(0)
for (var i = 0; i < this.orders.length; i++) {
let order = this.orders[i]
if (!order.asset) continue
if (order.amount && order.asset.id === this.avaxAsset.id) {
res = res.add(this.orders[i].amount)
}
Expand Down

0 comments on commit cf0bdf5

Please sign in to comment.