diff --git a/src/app/global/feature_flags.nim b/src/app/global/feature_flags.nim index 6212ac4b93..22b5db3124 100644 --- a/src/app/global/feature_flags.nim +++ b/src/app/global/feature_flags.nim @@ -5,7 +5,7 @@ const DEFAULT_FLAG_DAPPS_ENABLED = true const DEFAULT_FLAG_SWAP_ENABLED = true const DEFAULT_FLAG_CONNECTOR_ENABLED* = false const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true -const DEFAULT_FLAG_PAYMENT_REQUEST_ENABLED = true +const DEFAULT_FLAG_PAYMENT_REQUEST_ENABLED = false proc boolToEnv*(defaultValue: bool): string = return if defaultValue: "1" else: "0" diff --git a/storybook/pages/PaymentRequestModalPage.qml b/storybook/pages/PaymentRequestModalPage.qml index 0608707c1b..8ab6303529 100644 --- a/storybook/pages/PaymentRequestModalPage.qml +++ b/storybook/pages/PaymentRequestModalPage.qml @@ -51,7 +51,7 @@ SplitView { readonly property int selectedNetworkChainId: ctrlSelectedNetworkChainId.currentValue ?? -1 readonly property var tokenAdaptor: TokenSelectorViewAdaptor { - assetsModel: d.walletAssetsStore.groupedAccountAssetsModel + assetsModel: d.walletAssetsStore.baseGroupedAccountAssetModel flatNetworksModel: d.flatNetworks currentCurrency: d.currencyStore.currentCurrency plainTokensBySymbolModel: d.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel @@ -85,7 +85,8 @@ SplitView { closePolicy: Popup.CloseOnEscape destroyOnClose: true - currencyStore: d.currencyStore + currentCurrency: d.currencyStore.currentCurrency + formatCurrencyAmount: d.currencyStore.formatCurrencyAmount flatNetworksModel: d.flatNetworks accountsModel: d.accounts assetsModel: d.tokenAdaptor.outputAssetsModel diff --git a/ui/app/AppLayouts/Chat/popups/PaymentRequestModal.qml b/ui/app/AppLayouts/Chat/popups/PaymentRequestModal.qml index f66620a52b..7bec29c17e 100644 --- a/ui/app/AppLayouts/Chat/popups/PaymentRequestModal.qml +++ b/ui/app/AppLayouts/Chat/popups/PaymentRequestModal.qml @@ -15,17 +15,18 @@ import AppLayouts.Wallet.adaptors 1.0 import shared.popups.send.views 1.0 import shared.controls 1.0 -import shared.stores 1.0 as SharedStores +import StatusQ.Core.Utils 0.1 as SQUtils import utils 1.0 StatusDialog { id: root // models - required property SharedStores.CurrenciesStore currencyStore + required property string currentCurrency required property var flatNetworksModel required property var accountsModel required property var assetsModel + property var formatCurrencyAmount: function() {} // input / output property int selectedNetworkChainId: Constants.chains.mainnetChainId @@ -36,7 +37,7 @@ StatusDialog { if (!d.isSelectedHoldingValidAsset || !d.selectedHolding.item.marketDetails || !d.selectedHolding.item.marketDetails.currencyPrice) { return "0" } - return amountToSendInput.text + return SQUtils.AmountsArithmetic.toNumber(amountToSendInput.amount, amountToSendInput.multiplierIndex) } objectName: "paymentRequestModal" @@ -106,9 +107,9 @@ StatusDialog { multiplierIndex: d.isSelectedHoldingValidAsset && !!d.selectedHolding.item.decimals ? d.selectedHolding.item.decimals : 0 price: d.isSelectedHoldingValidAsset && !!d.selectedHolding.item.marketDetails ? d.selectedHolding.item.marketDetails.currencyPrice.amount : 1 - formatFiat: amount => root.currencyStore.formatCurrencyAmount( - amount, root.currencyStore.currentCurrency) - formatBalance: amount => root.currencyStore.formatCurrencyAmount( + formatFiat: amount => root.formatCurrencyAmount( + amount, root.currentCurrency) + formatBalance: amount => root.formatCurrencyAmount( amount, root.selectedTokenKey) showSeparator: true @@ -159,6 +160,7 @@ StatusDialog { statusListItemTitle.customColor: Theme.palette.directColor1 enabled: false } + onCurrentAccountAddressChanged: root.selectedAccountAddress = currentAccountAddress } StatusBaseText { diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index fd49772598..a0abf76f04 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -272,14 +272,6 @@ QtObject { return result } - function addPaymentRequest(symbol, amount, address, chainId) { - currentChatContentModule().inputAreaModule.paymentRequestModel.addPaymentRequest(address, amount, symbol, chainId) - } - - function removePaymentRequest(index) { - currentChatContentModule().inputAreaModule.paymentRequestModel.removeItemWithIndex(index) - } - function openCloseCreateChatView() { if (root.openCreateChat) { Global.closeCreateChatView() diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 415d195d2d..e22cace714 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -297,6 +297,7 @@ Item { sharedStore: root.sharedRootStore linkPreviewModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.linkPreviewModel : null + paymentRequestModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.paymentRequestModel : null urlsList: d.urlsList askToEnableLinkPreview: { if(!d.activeChatContentModule || !d.activeChatContentModule.inputAreaModule || !d.activeChatContentModule.inputAreaModule.preservedProperties) @@ -372,6 +373,7 @@ Item { chatInput.setText("") chatInput.textInput.textFormat = TextEdit.PlainText; chatInput.textInput.textFormat = TextEdit.RichText; + d.activeChatContentModule.inputAreaModule.removeAllPaymentRequestPreviewData() } } @@ -396,7 +398,7 @@ Item { d.activeChatContentModule.inputAreaModule.setLinkPreviewEnabledForCurrentMessage(false) } onDismissLinkPreview: (index) => d.activeChatContentModule.inputAreaModule.removeLinkPreviewData(index) - onOpenPaymentRequestModal: () => Global.openPaymentRequestModalRequested() + onOpenPaymentRequestModal: () => Global.openPaymentRequestModalRequested(d.activeChatContentModule.inputAreaModule) } ChatPermissionQualificationPanel { diff --git a/ui/app/AppLayouts/Chat/views/CreateChatView.qml b/ui/app/AppLayouts/Chat/views/CreateChatView.qml index 2b647212c6..ad07bc8a45 100644 --- a/ui/app/AppLayouts/Chat/views/CreateChatView.qml +++ b/ui/app/AppLayouts/Chat/views/CreateChatView.qml @@ -164,6 +164,7 @@ Page { closeGifPopupAfterSelection: true usersModel: membersSelector.model sharedStore: root.sharedRootStore + paymentRequestEnabled: false onStickerSelected: { root.createChatPropertiesStore.createChatStickerHashId = hashId; root.createChatPropertiesStore.createChatStickerPackId = packId; diff --git a/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml b/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml index e679f3f241..d9ee76d623 100644 --- a/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/WalletAssetsStore.qml @@ -44,9 +44,9 @@ QtObject { false, Constants.ephemeralNotificationType.success, "") } - /* PRIVATE: This model renames the role "key" to "tokensKey" in TokensBySymbolModel so that + /* This model renames the role "key" to "tokensKey" in TokensBySymbolModel so that it can be easily joined with the Account Assets model */ - readonly property var _renamedTokensBySymbolModel: RolesRenamingModel { + readonly property var renamedTokensBySymbolModel: RolesRenamingModel { sourceModel: walletTokensStore.plainTokensBySymbolModel mapping: [ RoleRename { @@ -87,7 +87,7 @@ QtObject { /* PRIVATE: This model joins the "Tokens By Symbol Model" and "Communities Model" by communityId */ property LeftJoinModel _jointTokensBySymbolModel: LeftJoinModel { - leftModel: _renamedTokensBySymbolModel + leftModel: renamedTokensBySymbolModel rightModel: _renamedCommunitiesModel joinRole: "communityId" } diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 38b967b914..dcf70e369b 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1395,6 +1395,8 @@ Item { emojiPopup: statusEmojiPopup.item stickersPopup: statusStickersPopupLoader.item sendViaPersonalChatEnabled: featureFlagsStore.sendViaPersonalChatEnabled && appMain.networkConnectionStore.sendBuyBridgeEnabled + areTestNetworksEnabled: appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled + paymentRequestEnabled: featureFlagsStore.paymentRequestEnabled onProfileButtonClicked: { Global.changeAppSectionBySectionType(Constants.appSection.profile); @@ -1560,6 +1562,7 @@ Item { transactionStore: appMain.transactionStore walletAssetsStore: appMain.walletAssetsStore currencyStore: appMain.currencyStore + paymentRequestEnabled: featureFlagsStore.paymentRequestEnabled onProfileButtonClicked: { Global.changeAppSectionBySectionType(Constants.appSection.profile); diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 56bfc508c0..f19ad17882 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -53,7 +53,6 @@ QtObject { property WalletStores.CollectiblesStore walletCollectiblesStore property NetworkConnectionStore networkConnectionStore property WalletStores.BuyCryptoStore buyCryptoStore - property ChatStores.RootStore chatStore property bool isDevBuild signal openExternalLink(string link) @@ -105,7 +104,7 @@ QtObject { Global.openSwapModalRequested.connect(openSwapModal) Global.openBuyCryptoModalRequested.connect(openBuyCryptoModal) Global.privacyPolicyRequested.connect(() => openPopup(privacyPolicyPopupComponent)) - Global.openPaymentRequestModalRequested.connect(() => openPopup(paymentRequestPopupComponent)) + Global.openPaymentRequestModalRequested.connect(openPaymentRequestModal) } property var currentPopup @@ -406,6 +405,10 @@ QtObject { }) } + function openPaymentRequestModal(inputAreaModule) { + openPopup(paymentRequestModalComponent, {inputAreaModule: inputAreaModule}) + } + readonly property list _components: [ Component { id: removeContactConfirmationDialog @@ -1277,21 +1280,25 @@ QtObject { } }, Component { - id: paymentRequestPopupComponent + id: paymentRequestModalComponent PaymentRequestModal { + id: paymentRequestModal readonly property var tokenAdaptor: TokenSelectorViewAdaptor { - assetsModel: WalletStores.RootStore.walletAssetsStore.groupedAccountAssetsModel + assetsModel: WalletStores.RootStore.walletAssetsStore._renamedTokensBySymbolModel flatNetworksModel: WalletStores.RootStore.filteredFlatModel - currentCurrency: root.rootStore.currencyStore.currentCurrency + currentCurrency: root.currencyStore.currentCurrency plainTokensBySymbolModel: WalletStores.RootStore.tokensStore.plainTokensBySymbolModel + enabledChainIds: [paymentRequestModal.selectedNetworkChainId] showAllTokens: true } - currencyStore: root.rootStore.currencyStore + property var inputAreaModule: null + currentCurrency: root.currencyStore.currentCurrency + formatCurrencyAmount: root.currencyStore.formatCurrencyAmount flatNetworksModel: WalletStores.RootStore.filteredFlatModel accountsModel: WalletStores.RootStore.nonWatchAccounts assetsModel: tokenAdaptor.outputAssetsModel - onAccepted: root.chatStore.addPaymentRequest(selectedTokenKey, amount, selectedAccountAddress, selectedNetworkChainId) + onAccepted: inputAreaModule.addPaymentRequest(selectedAccountAddress, amount, selectedTokenKey, selectedNetworkChainId) destroyOnClose: true } } diff --git a/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml b/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml index 3b776012fe..9da7811cd7 100644 --- a/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml +++ b/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml @@ -34,7 +34,7 @@ Control { required property bool showLinkPreviewSettings readonly property alias hoveredUrl: d.hoveredUrl - readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 || paymentRequestRepeater.count > 0 + readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 signal imageRemoved(int index) signal imageClicked(var chatImage) diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 0a609bb056..89ccf29b12 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -72,6 +72,7 @@ Rectangle { property var fileUrlsAndSources: [] property var linkPreviewModel: null + property var paymentRequestModel: null property var urlsList: [] @@ -1020,7 +1021,7 @@ Rectangle { text: qsTr("Add payment request") icon.name: "wallet" visibleOnDisabled: control.paymentRequestEnabled - enabled: control.paymentRequestEnabled && !root.areTestNetworksEnabled + enabled: control.paymentRequestEnabled && !control.areTestNetworksEnabled onTriggered: control.openPaymentRequestModal() } diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 2dc0597d21..bb24be8de3 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -92,7 +92,7 @@ QtObject { signal privacyPolicyRequested() - signal openPaymentRequestModalRequested() + signal openPaymentRequestModalRequested(var inputAreaModule) // Swap signal openSwapModalRequested(var formDataParams)