From 0638cf03ab6d0b8ebc0451cb1e0948b458ad2f85 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Wed, 27 Nov 2024 10:13:24 +0100 Subject: [PATCH] feat(@desktop/wallet): Using chain of heirarchy to propogate laun ch send signals instead of Global signal --- .../popups/TransferOwnershipPopup.qml | 10 ++-- ui/app/AppLayouts/Profile/ProfileLayout.qml | 31 ++++++++++ .../views/EnsTermsAndConditionsView.qml | 11 ++++ ui/app/AppLayouts/Profile/views/EnsView.qml | 57 +++---------------- ui/app/mainui/AppMain.qml | 10 ++++ ui/app/mainui/Popups.qml | 35 +++++------- 6 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml b/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml index 27db279040..bcc50f062f 100644 --- a/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml @@ -29,6 +29,7 @@ StatusDialog { property var token // Expected roles: accountAddress, key, chainId, name, artworkSource signal cancelClicked + signal sendRequested(var sendType, var senderAddress, var tokenId, var tokenType) width: 640 // by design padding: Theme.padding @@ -110,12 +111,9 @@ StatusDialog { onClicked: { // Pre-populated dialog with the relevant Owner token info: const store = WalletStores.RootStore.currentActivityFiltersStore - const uid = store.collectiblesList.getUidForData(token.key, token.tokenAddress, token.chainId); - Global.launchSendWithParams(Constants.SendType.ERC721Transfer, //sendType - token.accountAddress, //senderAddress - uid, //tokenId - Constants.TokenType.ERC721 //tokenType - ) + const uid = store.collectiblesList.getUidForData(token.key, token.tokenAddress, token.chainId) + root.sendRequested(Constants.SendType.ERC721Transfer, token.accountAddress, + uid, Constants.TokenType.ERC721) close() } } diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 3e4a8645d1..b6041aabd5 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -55,6 +55,9 @@ StatusSectionLayout { required property bool isCentralizedMetricsEnabled + signal launchSendModal(int sendType, string senderAddress, string tokenId, + int tokenType, string tokenAmount, int chainId, string publicKey, string ensName) + backButtonName: root.store.backButtonName notificationCount: activityCenterStore.unreadNotificationsCount hasUnseenNotifications: activityCenterStore.hasUnseenNotifications @@ -97,6 +100,10 @@ StatusSectionLayout { // Used to alternatively add an error message to the dirty bubble if ephemeral notification // can clash at smaller viewports readonly property bool toastClashesWithDirtyBubble: root.Window.width <= 1650 // design + + readonly property var sntToken: SQUtils.ModelUtils.getByKey( + root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", + root.store.ensUsernamesStore.getStatusTokenKey()) } SettingsEntriesModel { @@ -251,6 +258,30 @@ StatusSectionLayout { contactsStore: root.store.contactsStore networkConnectionStore: root.networkConnectionStore profileContentWidth: d.contentWidth + onConnectUsername: root.launchSendModal(Constants.SendType.ENSSetPubKey /*sendType*/, + "" /*senderAddress*/, + Constants.ethToken /*tokenId*/, + Constants.TokenType.ERC20 /*tokenType*/, + LocaleUtils.numberToLocaleString(0) /*tokenAmount*/, + selectedChainId /*chainId*/, + publicKey, + ensName) + onRegisterUsername: root.launchSendModal(Constants.SendType.ENSRegister /*sendType*/, + "" /*senderAddress*/, + !!d.sntToken && !!d.sntToken.symbol ? d.sntToken.symbol: "" /*tokenId*/, + Constants.TokenType.ERC20 /*tokenType*/, + LocaleUtils.numberToLocaleString(10) /*tokenAmount*/, + selectedChainId /*chainId*/, + publicKey, + ensName) + onReleaseUsernameRequested: root.launchSendModal(Constants.SendType.ENSRelease /*sendType*/, + senderAddress, + Constants.ethToken /*tokenId*/, + Constants.TokenType.Native /*tokenType*/, + LocaleUtils.numberToLocaleString(0) /*tokenAmount*/, + selectedChainId /*chainId*/, + publicKey, + ensName) } } diff --git a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml index 0f35d98981..c2bed95558 100644 --- a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml @@ -21,12 +21,23 @@ import AppLayouts.Profile.stores 1.0 Item { id: root + required property var accountAssetsModel property EnsUsernamesStore ensUsernamesStore property string username: "" signal backBtnClicked() signal registerUsername() + QtObject { + id: d + readonly property var sntToken: ModelUtils.getByKey(root.accountAssetsModel, "tokensKey", root.ensUsernamesStore.getStatusTokenKey()) + readonly property SumAggregator aggregator: SumAggregator { + model: !!d.sntToken && !!d.sntToken.balances ? d.sntToken.balances: nil + roleName: "balance" + } + property real sntBalance: !!sntToken && !!sntToken.decimals ? aggregator.value/(10 ** sntToken.decimals): 0 + } + StatusBaseText { id: sectionTitle text: qsTr("ENS usernames") diff --git a/ui/app/AppLayouts/Profile/views/EnsView.qml b/ui/app/AppLayouts/Profile/views/EnsView.qml index 9be699c54a..d5c0726e24 100644 --- a/ui/app/AppLayouts/Profile/views/EnsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsView.qml @@ -40,6 +40,9 @@ Item { signal changePubKey(ensUsername: string) signal goToWelcome(); signal goToList(); + signal connectUsername(string publicKey, string ensName) + signal registerUsername(string publicKey, string ensName) + signal releaseUsernameRequested(string senderAddress, string publicKey, string ensName) Layout.fillHeight: true Layout.fillWidth: true @@ -51,13 +54,6 @@ Item { readonly property string registerENS: "RegisterENS" readonly property string setPubKey: "SetPubKey" readonly property string releaseENS: "ReleaseENS" - - readonly property var sntToken: ModelUtils.getByKey(ensView.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", ensView.ensUsernamesStore.getStatusTokenKey()) - readonly property SumAggregator aggregator: SumAggregator { - model: !!d.sntToken && !!d.sntToken.balances ? d.sntToken.balances: nil - roleName: "balance" - } - property real sntBalance: !!sntToken && !!sntToken.decimals ? aggregator.value/(10 ** sntToken.decimals): 0 } DSM.StateMachine { @@ -259,20 +255,7 @@ Item { onConnectUsername: { ensView.selectedUsername = username - - Global.launchSendWithParams(Constants.SendType.ENSSetPubKey, //sendType - "", //senderAddress - Constants.ethToken, //tokenId - Constants.TokenType.ERC20, //tokenType - LocaleUtils.numberToLocaleString(0), //tokenAmount - ensView.selectedChainId, //chainId - ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress - Helpers.RecipientAddressObjectType.Address, //recipientType - false, //onlyAssets - false, //interactive - ensView.contactsStore.myPublicKey, //publicKey - ensView.selectedUsername //ensName - ) + ensView.connectUsername(ensView.contactsStore.myPublicKey, ensView.selectedUsername) } Connections { @@ -292,24 +275,10 @@ Item { EnsTermsAndConditionsView { ensUsernamesStore: ensView.ensUsernamesStore username: selectedUsername + accountAssetsModel: root.walletAssetsStore.groupedAccountAssetsModel onBackBtnClicked: back(); - - onRegisterUsername: { - Global.launchSendWithParams(Constants.SendType.ENSRegister, //sendType - "", //senderAddress - !!d.sntToken && !!d.sntToken.symbol ? d.sntToken.symbol: "", //tokenId - Constants.TokenType.ERC20, //tokenType - LocaleUtils.numberToLocaleString(10), //tokenAmount - ensView.selectedChainId, //chainId - ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress - Helpers.RecipientAddressObjectType.Address, //recipientType - false, //onlyAssets - false, //interactive - ensView.contactsStore.myPublicKey, //publicKey - ensView.selectedUsername //ensName - ) - } + onRegisterUsername: ensView.registerUsername(ensView.contactsStore.myPublicKey, ensView.selectedUsername) Connections { target: ensView.ensUsernamesStore.ensUsernamesModule @@ -386,19 +355,7 @@ Item { return } - Global.launchSendWithParams(Constants.SendType.ENSRelease, //sendType - senderAddress, //senderAddress - Constants.ethToken, //tokenId - Constants.TokenType.Native, //tokenType - LocaleUtils.numberToLocaleString(0), //tokenAmount - ensView.selectedChainId, //chainId - ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress - Helpers.RecipientAddressObjectType.Address, //recipientType - false, //onlyAssets - false, //interactive - ensView.contactsStore.myPublicKey, //publicKey - ensView.selectedUsername //ensName - ) + ensView.releaseUsernameRequested(senderAddress, ensView.contactsStore.myPublicKey, ensView.selectedUsername) } Connections { diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index c2ed1657fa..39148b04c0 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1630,6 +1630,16 @@ Item { } onSettingsSubsectionChanged: profileLoader.settingsSubsection = settingsSubsection + + onLaunchSendModal: { + let ensUsernamesStore = appMain.rootStore.profileSectionStore.ensUsernamesStore + popups.openSendModal(sendType, senderAddress, tokenId, tokenType, tokenAmount, chainId, + ensUsernamesStore.getEnsRegisteredAddress() /*recipientAddress*/, + SendPopups.Helpers.RecipientAddressObjectType.Address /*recipientType*/, + false /*onlyAssets*/, + false /*interactive*/, + publicKey, ensName) + } } } diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 45afb78b07..bf3a6bd7db 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -405,27 +405,19 @@ QtObject { }) } - function openSendModal(sendType, senderAddress, - tokenId, tokenType, - tokenAmount, chainId, - recipientAddress, recipientType, - onlyAssets, interactive, - publicKey, ensName, - stickersPackId) { - console.error("openSendModal >> ", "sendType >> ", sendType, - "senderAddress >> ",senderAddress, - "tokenId >> ",tokenId, - "tokenType >> ",tokenType, - "tokenAmount >> ",tokenAmount, - "chainId >> ",chainId, - "recipientAddress >> ",recipientAddress, - "recipientType >> ",recipientType, - "onlyAssets >> ",onlyAssets, - "interactive >> ",interactive, - "publicKey >> ",publicKey, - "ensName >> ",ensName, - "stickersPackId >> ",stickersPackId) - + function openSendModal(sendType = Constants.SendType.Transfer, + senderAddress = "", + tokenId = "", + tokenType = Constants.TokenType.Unknown, + tokenAmount = "", + chainId = 0, + recipientAddress = "", + recipientType = 0, + onlyAssets = false, + interactive = true, + publicKey = "", + ensName = "", + stickersPackId = "") { openPopup(sendModal, { preSelectedSendType: sendType, preSelectedAccountAddress: senderAddress, @@ -1081,6 +1073,7 @@ QtObject { id: transferOwnershipPopup TransferOwnershipPopup { onClosed: destroy() + onSendRequested: root.openSendModal(sendType, senderAddress, tokenId, tokenType) } },