From 017cf6ca7e36dfdc5167c0a8cc53190220ad0bea Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Wed, 4 Dec 2024 19:13:24 +0100 Subject: [PATCH] feat(@desktop/wallet): Making changes so that simple send can be launched outside of storybook --- .../popups/simpleSend/SimpleSendModal.qml | 1 + ui/app/mainui/AppMain.qml | 8 ++ ui/app/mainui/SendModalHandler.qml | 98 ++++++++++++++++++- 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml b/ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml index e58262c3f6..751ef54f2f 100644 --- a/ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml @@ -61,6 +61,7 @@ StatusDialog { - chainId: network chain id - chainName: name of network - iconUrl: network icon url + Only networks valid as per mainnet/testnet selection **/ required property var networksModel diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 2a08b373bd..715f70473e 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -660,6 +660,14 @@ Item { simpleSendEnabled: appMain.featureFlagsStore.simpleSendEnabled + walletAccountsModel: WalletStores.RootStore.accounts + flatNetworksModel: WalletStores.RootStore.flatNetworks + areTestNetworksEnabled: WalletStores.RootStore.areTestNetworksEnabled + groupedAccountAssetsModel: appMain.walletAssetsStore.groupedAccountAssetsModel + currentCurrency: appMain.currencyStore.currentCurrency + showCommunityAssetsInSend: appMain.tokensStore.showCommunityAssetsInSend + collectiblesBySymbolModel: WalletStores.RootStore.collectiblesStore.jointCollectiblesBySymbolModel + Component.onCompleted: { // It's requested from many nested places, so as a workaround we use // Global to shorten the path via global signal. diff --git a/ui/app/mainui/SendModalHandler.qml b/ui/app/mainui/SendModalHandler.qml index 56e857a42e..adc7bddac0 100644 --- a/ui/app/mainui/SendModalHandler.qml +++ b/ui/app/mainui/SendModalHandler.qml @@ -1,10 +1,13 @@ import QtQuick 2.15 +import SortFilterProxyModel 0.2 + import StatusQ.Core 0.1 import StatusQ.Core.Utils 0.1 as SQUtils import AppLayouts.Wallet.stores 1.0 as WalletStores import AppLayouts.Wallet.popups.simpleSend 1.0 +import AppLayouts.Wallet.adaptors 1.0 import shared.popups.send 1.0 import shared.stores.send 1.0 @@ -19,19 +22,71 @@ QtObject { required property TransactionStore transactionStore required property WalletStores.CollectiblesStore walletCollectiblesStore - // for ens flows + /** for ens flows **/ required property string myPublicKey required property string ensRegisteredAddress - // TODO: This should probably be a property and not a function. Needs changes on backend side + /** TODO: This should probably be a property and not + a function. Needs changes on backend side **/ property var getStatusTokenKey: function() {} - // for sticker flows + /** for sticker flows **/ required property string stickersMarketAddress required property string stickersNetworkId - // Feature flag for single network send until its feature complete + /** Feature flag for single network send until its feature complete **/ required property bool simpleSendEnabled + /** For simple send modal flows, decoupling from transaction store **/ + + /** curently selected fiat currency symbol **/ + required property string currentCurrency + /** Expected model structure: + - name: name of account + - address: wallet address + - color: color of the account + - emoji: emoji selected for the account + - currencyBalance: total currency balance in CurrencyAmount + - accountBalance: balance of selected token + selected chain + **/ + required property var walletAccountsModel + /** Expected model structure: + - tokensKey: unique string ID of the token (asset); e.g. "ETH" or contract address + - name: user visible token name (e.g. "Ethereum") + - symbol: user visible token symbol (e.g. "ETH") + - decimals: number of decimal places + - communityId: optional; ID of the community this token belongs to, if any + - marketDetails: object containing props like `currencyPrice` for the computed values below + - balances: submodel[ chainId:int, account:string, balance:BigIntString, iconUrl:string ] + **/ + required property var groupedAccountAssetsModel + /** Expected model structure: + - symbol [string] - unique identifier of a collectible + - collectionUid [string] - unique identifier of a collection + - contractAddress [string] - collectible's contract address + - name [string] - collectible's name e.g. "Magicat" + - collectionName [string] - collection name e.g. "Crypto Kitties" + - mediaUrl [url] - collectible's media url + - imageUrl [url] - collectible's image url + - communityId [string] - unique identifier of a community for community collectible or empty + - ownership [model] - submodel of balances per chain/account + - balance [int] - balance (always 1 for ERC-721) + - accountAddress [string] - unique identifier of an account + **/ + required property var collectiblesBySymbolModel + /** + Expected model structure: + - chainId: network chain id + - chainName: name of network + - iconUrl: network icon url + networks on both mainnet & testnet + **/ + required property var flatNetworksModel + /** true if testnet mode is on **/ + required property var areTestNetworksEnabled + /** whether community tokens are shown in send modal + based on a global setting **/ + required property var showCommunityAssetsInSend + function openSend(params = {}) { // TODO remove once simple send is feature complete let sendModalCmp = root.simpleSendEnabled ? simpleSendModalComponent: sendModalComponent @@ -155,7 +210,42 @@ QtObject { readonly property Component simpleSendModalComponent: Component { SimpleSendModal { + id: simpleSendModal + /** TODO: use the newly defined WalletAccountsSelectorAdaptor + in https://github.com/status-im/status-desktop/pull/16834 **/ + accountsModel: root.walletAccountsModel + assetsModel: assetsSelectorViewAdaptor.outputAssetsModel + collectiblesModel: collectiblesSelectionAdaptor.model + networksModel: root.filteredFlatNetworksModel + onClosed: destroy() + + TokenSelectorViewAdaptor { + id: assetsSelectorViewAdaptor + + // TODO: remove all store dependecies and add specific properties to the handler instead + assetsModel: root.groupedAccountAssetsModel + flatNetworksModel: root.flatNetworksModel + + currentCurrency: root.currentCurrency + showCommunityAssets: root.showCommunityAssetsInSend + + accountAddress: simpleSendModal.selectedAccountAddress + enabledChainIds: [simpleSendModal.selectedChainId] + } + CollectiblesSelectionAdaptor { + id: collectiblesSelectionAdaptor + + accountKey: simpleSendModal.selectedAccountAddress + + networksModel: root.filteredFlatNetworksModel + collectiblesModel: root.collectiblesBySymbolModel + } } } + + readonly property var filteredFlatNetworksModel: SortFilterProxyModel { + sourceModel: root.flatNetworksModel + filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled } + } }