Skip to content

Commit

Permalink
Merge pull request ava-labs#116 from ava-labs/minor_fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
kanatliemre authored Jan 7, 2021
2 parents 17d5b12 + 615f600 commit ac17888
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/components/wallet/TopCards/BalanceCard/BalanceCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export default class BalanceCard extends Vue {
}
get avmUnlocked(): BN {
console.log(this.ava_asset)
if (!this.ava_asset) return new BN(0)
return this.ava_asset.amount
}
Expand Down
45 changes: 26 additions & 19 deletions src/components/wallet/earn/ChainTransfer/ChainTransfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div v-if="!isImportErr" class="fees">
<h4>{{ $t('earn.transfer.fee') }}</h4>
<p>
{{ fee.toString() }}
<span>AVAX</span>
Export + Import Fee
<span>{{ fee.toString() }} AVAX</span>
</p>
</div>
<div>
Expand Down Expand Up @@ -132,6 +132,8 @@ import { ChainIdType } from '@/constants'
import ChainSwapForm from '@/components/wallet/earn/ChainTransfer/Form.vue'
import { web3 } from '@/evm'
@Component({
name: 'chain_transfer',
components: {
Expand Down Expand Up @@ -220,6 +222,7 @@ export default class ChainTransfer extends Vue {
get formAmtText() {
return bnToBig(this.formAmt, 9).toLocaleString()
}
// Fee is 2 times the tx transfer fee
get fee(): Big {
let feeX = avm.getTxFee()
Expand Down Expand Up @@ -298,14 +301,23 @@ export default class ChainTransfer extends Vue {
let exportTxId
this.exportState = TxState.started
exportTxId = await wallet.chainTransfer(amt, sourceChain, destinationChain)
let nonce = 0
if (this.sourceChain === 'C') {
nonce = await web3.eth.getTransactionCount(this.wallet.ethAddress)
}
try {
exportTxId = await wallet.chainTransfer(amt, sourceChain, destinationChain)
} catch (e) {
throw e
}
this.exportId = exportTxId
this.waitExportStatus(exportTxId)
this.waitExportStatus(exportTxId, nonce)
}
// STEP 2
async waitExportStatus(txId: string) {
async waitExportStatus(txId: string, nonce?: number) {
let status
if (this.sourceChain === 'X') {
status = await avm.getTxStatus(txId)
Expand All @@ -318,25 +330,20 @@ export default class ChainTransfer extends Vue {
this.exportReason = resp.reason
}
} else {
// TODO: Add C Chain waiting logic
// let txIdHex = bintools.cb58Decode(txId).toString('hex')
// let receipt = await web3.eth.getTransactionReceipt('0x' + txIdHex)
// console.log(receipt)
// if (receipt === null) {
// status = 'Unknown'
// } else {
// console.log('check receipt status')
// status = 'success'
// }
status = 'success'
// We can check the nonce to see when the tx is confirmed
let nonceNow = await web3.eth.getTransactionCount(this.wallet.ethAddress)
if (nonceNow === nonce) {
status = 'Processing'
} else {
status = 'Accepted'
}
}
this.exportStatus = status
if (status === 'Unknown' || status === 'Processing') {
// if not confirmed ask again
setTimeout(() => {
this.waitExportStatus(txId)
this.waitExportStatus(txId, nonce)
}, 1000)
return false
} else if (status === 'Dropped') {
Expand Down Expand Up @@ -391,7 +398,7 @@ export default class ChainTransfer extends Vue {
}
} else {
// TODO: Add evm processing
status = 'success'
status = 'Accepted'
}
this.importStatus = status
Expand Down
4 changes: 2 additions & 2 deletions src/js/wallets/AvaHdWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ export default class AvaHdWallet extends HdWalletCore implements IAvaHdWallet {
destinationChain: ChainIdType
): Promise<string> {
let fee = avm.getTxFee()

let amtFee = amt.add(fee)

if (destinationChain === 'C') {
// C Chain imports do not have a fee
// C Chain imports/exports do not have a fee
amtFee = amt
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/wallets/SingletonWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SingletonWallet implements AvaWalletCore, UnsafeWallet {
let fee = avm.getTxFee()
let amtFee = amt.add(fee)
if (destinationChain === 'C') {
// C Chain imports do not have a fee
// C Chain imports/exports do not have a fee
amtFee = amt
}
// EXPORT
Expand Down

0 comments on commit ac17888

Please sign in to comment.