From 8343fe30761e13693f252701040686c59ebdde34 Mon Sep 17 00:00:00 2001 From: Belal Shehab <16547115+belalshehab@users.noreply.github.com> Date: Wed, 31 Jul 2024 20:29:52 +0300 Subject: [PATCH] fix(wallet)_: Filter non-bridgeable assets in Bridge Modal (#15924) - Implemented a bridgeableGroupedAccountAssetsModel in WalletAssetsStore.qml to dynamically filter assets based on their bridgeability. closes: #15697 Co-authored-by: belalshehab --- .../Wallet/stores/WalletAssetsStore.qml | 17 +++++++++++++++++ ui/imports/shared/popups/send/SendModal.qml | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml b/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml index 8c284174a6..5e76e4e159 100644 --- a/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml @@ -101,4 +101,21 @@ QtObject { rightModel: _jointTokensBySymbolModel joinRole: "tokensKey" } + + // This is hard coded for now, and should be updated whenever Hop add new tokens for support + // This should be dynamically fetched somehow in the future + readonly property var tokensSupportedByHopBridge: ["USDC", "USDC.e", "USDT", "DAI", "HOP", "SNX", "sUSD", "rETH", "MAGIC"] + + readonly property SortFilterProxyModel bridgeableGroupedAccountAssetsModel: SortFilterProxyModel { + objectName: "bridgeableGroupedAccountAssetsModel" + sourceModel: root.groupedAccountAssetsModel + + filters: [ + FastExpressionFilter { + expression: root.tokensSupportedByHopBridge.includes(model.symbol) + expectedRoles: ["symbol"] + } + ] + } } + diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index cc550ce9de..36af7eed45 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -358,7 +358,9 @@ StatusDialog { TokenSelectorViewAdaptor { id: assetsAdaptor - assetsModel: popup.store.walletAssetStore.groupedAccountAssetsModel + assetsModel: d.isBridgeTx ? + popup.store.walletAssetStore.bridgeableGroupedAccountAssetsModel : + popup.store.walletAssetStore.groupedAccountAssetsModel flatNetworksModel: popup.store.flatNetworksModel currentCurrency: popup.store.currencyStore.currentCurrency