feat(WC): Enable Wallet Connect feature by default

+ Update the dialog where the user choses the connection to enable or disable the connection option based on flags
+ Separating the walletConnect flag and browserConnect flag usage so that either one can be disabled without affecting the other feature
+ Update qml test
This commit is contained in:
Alex Jbanca 2024-10-25 22:28:45 +03:00
parent 8a55d063a5
commit 4636f80260
No known key found for this signature in database
GPG Key ID: 6004079575C21C5D
11 changed files with 104 additions and 15 deletions

View File

@ -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

View File

@ -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,6 +214,7 @@ Item {
// spacer
ColumnLayout {}
RowLayout {
CheckBox {
text: "Enable SDK"
@ -220,6 +224,23 @@ Item {
}
}
CheckBox {
text: "WC feature flag"
checked: true
onCheckedChanged: {
walletConnectService.walletConnectFeatureEnabled = checked
}
}
CheckBox {
text: "Connector feature flag"
checked: true
onCheckedChanged: {
walletConnectService.connectorFeatureEnabled = checked
}
}
}
RowLayout {
StatusBaseText { text: "URI" }
StatusInput {

View File

@ -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)
}
}
}

View File

@ -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)

View File

@ -18,6 +18,9 @@ import StatusQ.Components.private 0.1 as SQP
ComboBox {
id: root
property bool walletConnectEnabled: true
property bool connectorEnabled: true
signal dappsListReady
signal pairDapp
signal disconnectDapp(string dappUrl)
@ -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"

View File

@ -29,8 +29,6 @@ Item {
property WalletStores.RootStore walletStore
property var overview
property bool dappsEnabled
property int loginType // RootStore.loginType -> Constants.LoginType enum
property alias headerButton: headerButton
@ -144,10 +142,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

View File

@ -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)
}

View File

@ -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()
}

View File

@ -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
@ -296,6 +299,7 @@ QObject {
DAppsListProvider {
id: dappsProvider
enabled: root.walletConnectFeatureEnabled
sdk: root.wcSDK
store: root.store
supportedAccountsModel: root.walletRootStore.nonWatchAccounts
@ -303,6 +307,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

View File

@ -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
}

View File

@ -1430,7 +1430,6 @@ Item {
sendModalPopup: sendModal
networkConnectionStore: appMain.networkConnectionStore
appMainVisible: appMain.visible
dappsEnabled: featureFlagsStore.dappsEnabled
swapEnabled: featureFlagsStore.swapEnabled
}
onLoaded: {
@ -2210,6 +2209,9 @@ Item {
walletRootStore: WalletStores.RootStore
blockchainNetworksDown: appMain.networkConnectionStore.blockchainNetworksDown
connectorFeatureEnabled: featureFlagsStore.connectorEnabled
walletConnectFeatureEnabled: featureFlagsStore.dappsEnabled
Component.onCompleted: {
Global.walletConnectService = walletConnectService
}