fix(@desktop/wallet): Wrong decimal place calculation on bridging

fixes #8660
This commit is contained in:
Khushboo Mehta 2022-12-09 10:10:05 +01:00 committed by Khushboo-dev-cpp
parent 5d318d0304
commit 5b423a6dbd
5 changed files with 21 additions and 7 deletions

View File

@ -67,7 +67,7 @@ StatusDialog {
}
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
if(!!popup.selectedAccount && !!assetSelector.selectedAsset) {
if(!!popup.selectedAccount && !!assetSelector.selectedAsset && d.recipientReady) {
popup.isLoading = true
let amount = parseFloat(amountToSendInput.text) * Math.pow(10, assetSelector.selectedAsset.decimals)
popup.store.suggestedRoutes(popup.selectedAccount.address, amount.toString(16), assetSelector.selectedAsset.symbol,
@ -113,7 +113,8 @@ StatusDialog {
} else {
let chainColor = popup.store.allNetworks.getNetworkColor(splitWords[i])
if(!!chainColor) {
store.addPreferredChain(popup.store.allNetworks.getNetworkChainId(splitWords[i]))
if(!isBridgeTx)
store.addPreferredChain(popup.store.allNetworks.getNetworkChainId(splitWords[i]))
editedText += `<span style='color: %1'>%2</span>`.arg(chainColor).arg(splitWords[i])+':'
}
}
@ -136,8 +137,10 @@ StatusDialog {
onSelectedAccountChanged: popup.recalculateRoutesAndFees()
onOpened: {
store.addPreferredChain(popup.store.getMainnetChainId())
store.addUnpreferredChainsToDisabledChains()
if(!isBridgeTx) {
store.addPreferredChain(popup.store.getMainnetChainId())
store.addUnpreferredChainsToDisabledChains()
}
amountToSendInput.input.edit.forceActiveFocus()

View File

@ -27,7 +27,8 @@ QtObject {
function addRemoveDisabledFromChain(chainID, isDisabled) {
if(isDisabled) {
disabledChainIdsFromList.push(chainID)
if(!root.disabledChainIdsFromList.includes(chainID))
disabledChainIdsFromList.push(chainID)
}
else {
for(var i = 0; i < disabledChainIdsFromList.length;i++) {
@ -40,7 +41,8 @@ QtObject {
function addRemoveDisabledToChain(chainID, isDisabled) {
if(isDisabled) {
root.disabledChainIdsToList.push(chainID)
if(!root.disabledChainIdsToList.includes(chainID))
root.disabledChainIdsToList.push(chainID)
}
else {
for(var i = 0; i < root.disabledChainIdsToList.length;i++) {

View File

@ -80,6 +80,8 @@ Item {
amountToSend: root.amountToSend
isLoading: root.isLoading
store: root.store
selectedAsset: root.selectedAsset
selectedAccount: root.selectedAccount
weiToEth: function(wei) {
return "%1 %2".arg(LocaleUtils.numberToLocaleString(parseFloat(store.getWei2Eth(wei, selectedAsset.decimals)))).arg(selectedAsset.symbol)
}
@ -107,6 +109,7 @@ Item {
bestRoutes: root.bestRoutes
isLoading: root.isLoading
interactive: root.interactive
isBridgeTx: root.isBridgeTx
weiToEth: function(wei) {
return parseFloat(store.getWei2Eth(wei, selectedAsset.decimals))
}
@ -132,6 +135,7 @@ Item {
bestRoutes: root.bestRoutes
isLoading: root.isLoading
interactive: root.interactive
isBridgeTx: root.isBridgeTx
weiToEth: function(wei) {
return parseFloat(store.getWei2Eth(wei, selectedAsset.decimals))
}

View File

@ -25,6 +25,7 @@ ColumnLayout {
property bool errorMode: networksLoader.item ? networksLoader.item.errorMode : false
property var weiToEth: function(wei) {}
property bool interactive: true
property bool isBridgeTx: false
signal reCalculateSuggestedRoute()
@ -61,6 +62,7 @@ ColumnLayout {
icon.width: 16
text: checked ? qsTr("Hide Unpreferred Networks"): qsTr("Show Unpreferred Networks")
onToggled: if(!checked) store.addUnpreferredChainsToDisabledChains()
visible: !isBridgeTx
}
}
StatusBaseText {

View File

@ -20,6 +20,8 @@ RowLayout {
property double amountToSend: 0
property bool isLoading: false
property bool isBridgeTx: false
property var selectedAsset
property var selectedAccount
property var weiToEth: function(wei) {}
property var reCalculateSuggestedRoute: function() {}
@ -114,7 +116,8 @@ RowLayout {
rightPadding: 5
implicitWidth: 150
title: chainName
subTitle: root.weiToEth(balance)
subTitle: selectedAccount && selectedAccount!== undefined && selectedAsset!== undefined ?
selectedAccount.getTokenBalanceOnChain(chainId, selectedAsset.symbol) : ""
statusListItemSubTitle.color: Theme.palette.primaryColor1
asset.width: 32
asset.height: 32