diff --git a/src/app/global/feature_flags.nim b/src/app/global/feature_flags.nim index 40cf2bffec4..5c7740817cc 100644 --- a/src/app/global/feature_flags.nim +++ b/src/app/global/feature_flags.nim @@ -1,7 +1,7 @@ import NimQml import os -const DEFAULT_FLAG_DAPPS_ENABLED = false +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 diff --git a/storybook/pages/DAppsWorkflowPage.qml b/storybook/pages/DAppsWorkflowPage.qml index 56ae94df026..3bb9a8802de 100644 --- a/storybook/pages/DAppsWorkflowPage.qml +++ b/storybook/pages/DAppsWorkflowPage.qml @@ -74,6 +74,9 @@ Item { sessionRequestsModel: wcService.sessionRequestsModel enabled: wcService.isServiceOnline + walletConnectEnabled: wcService.walletConnectFeatureEnabled + connectorEnabled: wcService.connectorFeatureEnabled + //formatBigNumber: (number, symbol, noSymbolOption) => wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption) onDisconnectRequested: (connectionId) => wcService.disconnectDapp(connectionId) @@ -211,12 +214,30 @@ Item { // spacer ColumnLayout {} - CheckBox { + RowLayout { + CheckBox { - text: "Enable SDK" - checked: settings.enableSDK - onCheckedChanged: { - settings.enableSDK = checked + text: "Enable SDK" + checked: settings.enableSDK + onCheckedChanged: { + settings.enableSDK = checked + } + } + + CheckBox { + text: "WC feature flag" + checked: true + onCheckedChanged: { + walletConnectService.walletConnectFeatureEnabled = checked + } + } + + CheckBox { + text: "Connector feature flag" + checked: true + onCheckedChanged: { + walletConnectService.connectorFeatureEnabled = checked + } } } diff --git a/storybook/qmlTests/tests/tst_DappsComboBox.qml b/storybook/qmlTests/tests/tst_DappsComboBox.qml index 2daec2ea704..f18b8d8fcf6 100644 --- a/storybook/qmlTests/tests/tst_DappsComboBox.qml +++ b/storybook/qmlTests/tests/tst_DappsComboBox.qml @@ -96,5 +96,35 @@ Item { compare(background.active, false) compare(dappTooltip.visible, false) } + + function test_connectorsEnabledOrDisabled() { + mouseClick(controlUnderTest) + const dappListPopup = findChild(controlUnderTest, "dappsListPopup") + verify(!!dappListPopup) + + dappListPopup.connectDapp() + waitForRendering(controlUnderTest) + waitForItemPolished(controlUnderTest) + + const connectorButton = findChild(controlUnderTest, "btnStatusConnector") + const wcButton = findChild(controlUnderTest, "btnWalletConnect") + verify(!!connectorButton) + verify(!!wcButton) + + compare(controlUnderTest.walletConnectEnabled, true) + compare(controlUnderTest.connectorEnabled, true) + + controlUnderTest.walletConnectEnabled = false + compare(wcButton.enabled, false) + + controlUnderTest.walletConnectEnabled = true + compare(wcButton.enabled, true) + + controlUnderTest.connectorEnabled = false + compare(connectorButton.enabled, false) + + controlUnderTest.connectorEnabled = true + compare(connectorButton.enabled, true) + } } } diff --git a/ui/app/AppLayouts/Wallet/WalletLayout.qml b/ui/app/AppLayouts/Wallet/WalletLayout.qml index d547d8a5258..3986e993874 100644 --- a/ui/app/AppLayouts/Wallet/WalletLayout.qml +++ b/ui/app/AppLayouts/Wallet/WalletLayout.qml @@ -41,7 +41,6 @@ Item { property SharedStores.NetworkConnectionStore networkConnectionStore property bool appMainVisible - property bool dappsEnabled property bool swapEnabled onAppMainVisibleChanged: { @@ -228,7 +227,6 @@ Item { sendModal: root.sendModalPopup networkConnectionStore: root.networkConnectionStore - dappsEnabled: root.dappsEnabled swapEnabled: root.swapEnabled headerButton.text: RootStore.overview.ens || StatusQUtils.Utils.elideAndFormatWalletAddress(RootStore.overview.mixedcaseAddress) diff --git a/ui/app/AppLayouts/Wallet/controls/DappsComboBox.qml b/ui/app/AppLayouts/Wallet/controls/DappsComboBox.qml index e8088832471..63056647875 100644 --- a/ui/app/AppLayouts/Wallet/controls/DappsComboBox.qml +++ b/ui/app/AppLayouts/Wallet/controls/DappsComboBox.qml @@ -17,6 +17,9 @@ import StatusQ.Components.private 0.1 as SQP ComboBox { id: root + + property bool walletConnectEnabled: true + property bool connectorEnabled: true signal dappsListReady signal pairDapp @@ -86,6 +89,7 @@ ComboBox { id: dappConnectSelectComponent StatusDialog { id: dappConnectSelect + objectName: "dappConnectSelect" width: 480 topPadding: Theme.bigPadding leftPadding: Theme.padding @@ -111,9 +115,11 @@ ComboBox { text: qsTr("How would you like to connect?") } StatusListItem { + objectName: "btnStatusConnector" title: "Status Connector" asset.name: Theme.png("status-logo") asset.isImage: true + enabled: root.connectorEnabled components: [ StatusIcon { icon: "external-link" @@ -130,6 +136,7 @@ ComboBox { title: "Wallet Connect" asset.name: Theme.svg("walletconnect") asset.isImage: true + enabled: root.walletConnectEnabled components: [ StatusIcon { icon: "next" diff --git a/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml b/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml index 08af2df36fa..a14fde064ec 100644 --- a/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml +++ b/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml @@ -30,7 +30,6 @@ Item { property var overview property WalletStores.RootStore walletStore - property bool dappsEnabled property int loginType // RootStore.loginType -> Constants.LoginType enum property alias headerButton: headerButton @@ -144,10 +143,12 @@ Item { spacing: 8 visible: !root.walletStore.showSavedAddresses - && root.dappsEnabled + && (wcService.walletConnectFeatureEnabled || wcService.connectorFeatureEnabled) && wcService.serviceAvailableToCurrentAddress enabled: !!wcService && wcService.isServiceOnline + walletConnectEnabled: wcService.walletConnectFeatureEnabled + connectorEnabled: wcService.connectorFeatureEnabled loginType: root.loginType selectedAccountAddress: root.walletStore.selectedAddress diff --git a/ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.qml b/ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.qml index 438083506fb..59a00cc445d 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.qml +++ b/ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.qml @@ -11,8 +11,13 @@ QObject { readonly property alias dappsModel: d.dappsModel readonly property int connectorId: Constants.StatusConnect + property bool enabled: true function addSession(url, name, iconUrl, accountAddress) { + if (!enabled) { + return + } + if (!url || !name || !iconUrl || !accountAddress) { console.error("addSession: missing required parameters") return @@ -38,10 +43,18 @@ QObject { } function revokeSession(topic) { + if (!enabled) { + return + } + d.revokeSession(topic) } function getActiveSession(topic) { + if (!enabled) { + return + } + return d.getActiveSession(topic) } diff --git a/ui/app/AppLayouts/Wallet/services/dapps/DAppsListProvider.qml b/ui/app/AppLayouts/Wallet/services/dapps/DAppsListProvider.qml index a1ab1704ca7..90cce12d2e8 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/DAppsListProvider.qml +++ b/ui/app/AppLayouts/Wallet/services/dapps/DAppsListProvider.qml @@ -18,11 +18,24 @@ QObject { readonly property int connectorId: Constants.WalletConnect readonly property var dappsModel: d.dappsModel + property bool enabled: true + Component.onCompleted: { + if (!enabled) { + return + } // Just in case the SDK is already initialized d.updateDappsModel() } + onEnabledChanged: { + if (enabled) { + d.updateDappsModel() + } else { + d.dappsModel.clear() + } + } + QObject { id: d @@ -33,6 +46,8 @@ QObject { property Connections sdkConnections: Connections { target: root.sdk + enabled: root.enabled + function onSessionDelete(topic, err) { d.updateDappsModel() } diff --git a/ui/app/AppLayouts/Wallet/services/dapps/WalletConnectService.qml b/ui/app/AppLayouts/Wallet/services/dapps/WalletConnectService.qml index 42b16f925d3..bba8cf8345d 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/WalletConnectService.qml +++ b/ui/app/AppLayouts/Wallet/services/dapps/WalletConnectService.qml @@ -35,6 +35,9 @@ QObject { // // Array[chainId] of the networks that are down required property var blockchainNetworksDown + property bool walletConnectFeatureEnabled: true + property bool connectorFeatureEnabled: true + //output properties /// Model contaning all dApps available for the currently selected account readonly property var dappsModel: d.filteredDappsModel @@ -77,7 +80,7 @@ QObject { timeoutTimer.start() requestHandler.pair(uri) } - + /// Approves or rejects the session proposal function approvePairSession(key, approvedChainIds, accountAddress) { requestHandler.approvePairSession(key, approvedChainIds, accountAddress) @@ -292,6 +295,7 @@ QObject { DAppsListProvider { id: dappsProvider + enabled: root.walletConnectFeatureEnabled sdk: root.wcSDK store: root.store supportedAccountsModel: root.walletRootStore.nonWatchAccounts @@ -299,6 +303,7 @@ QObject { ConnectorDAppsListProvider { id: connectorDAppsProvider + enabled: root.connectorFeatureEnabled } // Timeout for the corner case where the URL was already dismissed and the SDK doesn't respond with an error nor advances with the proposal diff --git a/ui/app/AppLayouts/Wallet/views/RightTabBaseView.qml b/ui/app/AppLayouts/Wallet/views/RightTabBaseView.qml index 01f4882e89b..27427a7361e 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabBaseView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabBaseView.qml @@ -19,7 +19,6 @@ FocusScope { property CommunitiesStore communitiesStore property NetworkConnectionStore networkConnectionStore - property bool dappsEnabled property bool swapEnabled property var sendModal @@ -40,7 +39,6 @@ FocusScope { overview: WalletStores.RootStore.overview walletStore: WalletStores.RootStore networkConnectionStore: root.networkConnectionStore - dappsEnabled: root.dappsEnabled loginType: root.store.loginType } diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 8c2caaa00a5..15470992709 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1424,7 +1424,6 @@ Item { sendModalPopup: sendModal networkConnectionStore: appMain.networkConnectionStore appMainVisible: appMain.visible - dappsEnabled: featureFlagsStore.dappsEnabled swapEnabled: featureFlagsStore.swapEnabled } onLoaded: { @@ -2201,6 +2200,9 @@ Item { walletRootStore: WalletStores.RootStore blockchainNetworksDown: appMain.networkConnectionStore.blockchainNetworksDown + connectorFeatureEnabled: featureFlagsStore.connectorEnabled + walletConnectFeatureEnabled: featureFlagsStore.dappsEnabled + Component.onCompleted: { Global.walletConnectService = walletConnectService }