From 480a3ed1825c15129a33cd237b82c00d414b2660 Mon Sep 17 00:00:00 2001 From: Noelia Date: Tue, 16 Jul 2024 16:36:44 +0200 Subject: [PATCH] fix(Wallet/BridgeModal): Incorrect preselected recipient value and network model for bridge - Fixed incorrect preselected recipient object for bridge modal. - Fixed network model assignment for bridge. Fixes #15629 --- ui/app/AppLayouts/Wallet/WalletLayout.qml | 1 - ui/imports/shared/popups/send/SendModal.qml | 10 ++++++++ .../popups/send/views/NetworkSelector.qml | 2 +- .../send/views/NetworksSimpleRoutingView.qml | 24 +++++++++++-------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ui/app/AppLayouts/Wallet/WalletLayout.qml b/ui/app/AppLayouts/Wallet/WalletLayout.qml index 4b02823091..27d5a12cae 100644 --- a/ui/app/AppLayouts/Wallet/WalletLayout.qml +++ b/ui/app/AppLayouts/Wallet/WalletLayout.qml @@ -331,7 +331,6 @@ Item { } onLaunchBridgeModal: { root.sendModalPopup.preSelectedSendType = Constants.SendType.Bridge - root.sendModalPopup.preSelectedRecipient = root.sendModalPopup.preSelectedAccount.address root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType root.sendModalPopup.onlyAssets = true diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 9bf158f502..ec566f9efc 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -170,9 +170,19 @@ StatusDialog { onOpened: { amountToSendInput.input.input.edit.forceActiveFocus() + // IMPORTANT: This step must be the first one since it's storing the send type + // into the backend at this stage so that, before this assignement, some properties + // should not have the correct value, like `d.isBridgeTx` if(popup.preSelectedSendType !== Constants.SendType.Unknown) { store.setSendType(popup.preSelectedSendType) } + + // To be removed once bridge is splitted to a different component: + if(d.isBridgeTx && !!popup.preSelectedAccount) { + // Default preselected type is `Helpers.RecipientAddressObjectType.Address` coinciding with bridge usecase + popup.preSelectedRecipient = popup.preSelectedAccount.address + } + if (!!popup.preSelectedHoldingID && popup.preSelectedHoldingType > Constants.TokenType.Native && popup.preSelectedHoldingType < Constants.TokenType.Unknown) { diff --git a/ui/imports/shared/popups/send/views/NetworkSelector.qml b/ui/imports/shared/popups/send/views/NetworkSelector.qml index e05075ad21..f8adb9dcde 100644 --- a/ui/imports/shared/popups/send/views/NetworkSelector.qml +++ b/ui/imports/shared/popups/send/views/NetworkSelector.qml @@ -89,7 +89,7 @@ Item { errorMode: root.errorMode errorType: root.errorType fromNetworksList: root.fromNetworksList - toNetworksList: root.suggestedToNetworksList + suggestedToNetworksList: root.suggestedToNetworksList // Collectibles don't have a symbol selectedSymbol: !!root.selectedAsset && !!root.selectedAsset.symbol ? root.selectedAsset.symbol: "" weiToEth: function(wei) { diff --git a/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml b/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml index 70aa2b76de..c092522eb1 100644 --- a/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml +++ b/ui/imports/shared/popups/send/views/NetworksSimpleRoutingView.qml @@ -22,13 +22,14 @@ RowLayout { property bool isBridgeTx: false property bool isCollectiblesTransfer: false property var fromNetworksList - property var toNetworksList + property var suggestedToNetworksList property var weiToEth: function(wei) {} property var formatCurrencyAmount: function () {} property var reCalculateSuggestedRoute: function() {} property bool errorMode: false property int errorType: Constants.NoError property string selectedSymbol + spacing: 10 StatusRoundIcon { @@ -57,6 +58,7 @@ RowLayout { qsTr("The networks where the recipient will receive tokens. Amounts calculated automatically for the lowest cost.") wrapMode: Text.WordWrap } + ScrollView { Layout.fillWidth: true Layout.preferredHeight: visible ? row.height + 10 : 0 @@ -70,18 +72,20 @@ RowLayout { Column { id: row spacing: Style.current.padding + + // TODO: This transformation should come from an adaptor outside this component + LeftJoinModel { + id: toNetworksListLeftJoinModel + + leftModel: root.suggestedToNetworksList + rightModel: root.store.flatNetworksModel + joinRole: "chainId" + } + Repeater { id: repeater objectName: "networksList" - model: LeftJoinModel { - leftModel: { - const m = isBridgeTx ? root.fromNetworksList : root.toNetworksList - return !!m ? m : null - } - rightModel: root.store.flatNetworksModel - joinRole: "chainId" - } - + model: isBridgeTx ? root.fromNetworksList : toNetworksListLeftJoinModel delegate: isBridgeTx ? networkItem : routeItem } }