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:
parent
8a81a5fc92
commit
7e1e827148
|
@ -1,7 +1,7 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const DEFAULT_FLAG_DAPPS_ENABLED = false
|
const DEFAULT_FLAG_DAPPS_ENABLED = true
|
||||||
const DEFAULT_FLAG_SWAP_ENABLED = true
|
const DEFAULT_FLAG_SWAP_ENABLED = true
|
||||||
const DEFAULT_FLAG_CONNECTOR_ENABLED* = false
|
const DEFAULT_FLAG_CONNECTOR_ENABLED* = false
|
||||||
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
|
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
|
||||||
|
|
|
@ -74,6 +74,9 @@ Item {
|
||||||
sessionRequestsModel: wcService.sessionRequestsModel
|
sessionRequestsModel: wcService.sessionRequestsModel
|
||||||
enabled: wcService.isServiceOnline
|
enabled: wcService.isServiceOnline
|
||||||
|
|
||||||
|
walletConnectEnabled: wcService.walletConnectFeatureEnabled
|
||||||
|
connectorEnabled: wcService.connectorFeatureEnabled
|
||||||
|
|
||||||
//formatBigNumber: (number, symbol, noSymbolOption) => wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
//formatBigNumber: (number, symbol, noSymbolOption) => wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
||||||
|
|
||||||
onDisconnectRequested: (connectionId) => wcService.disconnectDapp(connectionId)
|
onDisconnectRequested: (connectionId) => wcService.disconnectDapp(connectionId)
|
||||||
|
@ -211,12 +214,30 @@ Item {
|
||||||
// spacer
|
// spacer
|
||||||
ColumnLayout {}
|
ColumnLayout {}
|
||||||
|
|
||||||
CheckBox {
|
RowLayout {
|
||||||
|
CheckBox {
|
||||||
|
|
||||||
text: "Enable SDK"
|
text: "Enable SDK"
|
||||||
checked: settings.enableSDK
|
checked: settings.enableSDK
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
settings.enableSDK = checked
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,5 +96,35 @@ Item {
|
||||||
compare(background.active, false)
|
compare(background.active, false)
|
||||||
compare(dappTooltip.visible, 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ Item {
|
||||||
property SharedStores.NetworkConnectionStore networkConnectionStore
|
property SharedStores.NetworkConnectionStore networkConnectionStore
|
||||||
property bool appMainVisible
|
property bool appMainVisible
|
||||||
|
|
||||||
property bool dappsEnabled
|
|
||||||
property bool swapEnabled
|
property bool swapEnabled
|
||||||
|
|
||||||
onAppMainVisibleChanged: {
|
onAppMainVisibleChanged: {
|
||||||
|
@ -224,7 +223,6 @@ Item {
|
||||||
sendModal: root.sendModalPopup
|
sendModal: root.sendModalPopup
|
||||||
networkConnectionStore: root.networkConnectionStore
|
networkConnectionStore: root.networkConnectionStore
|
||||||
|
|
||||||
dappsEnabled: root.dappsEnabled
|
|
||||||
swapEnabled: root.swapEnabled
|
swapEnabled: root.swapEnabled
|
||||||
|
|
||||||
headerButton.text: RootStore.overview.ens || StatusQUtils.Utils.elideAndFormatWalletAddress(RootStore.overview.mixedcaseAddress)
|
headerButton.text: RootStore.overview.ens || StatusQUtils.Utils.elideAndFormatWalletAddress(RootStore.overview.mixedcaseAddress)
|
||||||
|
|
|
@ -17,6 +17,9 @@ import StatusQ.Components.private 0.1 as SQP
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool walletConnectEnabled: true
|
||||||
|
property bool connectorEnabled: true
|
||||||
|
|
||||||
signal dappsListReady
|
signal dappsListReady
|
||||||
signal pairDapp
|
signal pairDapp
|
||||||
|
@ -86,6 +89,7 @@ ComboBox {
|
||||||
id: dappConnectSelectComponent
|
id: dappConnectSelectComponent
|
||||||
StatusDialog {
|
StatusDialog {
|
||||||
id: dappConnectSelect
|
id: dappConnectSelect
|
||||||
|
objectName: "dappConnectSelect"
|
||||||
width: 480
|
width: 480
|
||||||
topPadding: Theme.bigPadding
|
topPadding: Theme.bigPadding
|
||||||
leftPadding: Theme.padding
|
leftPadding: Theme.padding
|
||||||
|
@ -111,9 +115,11 @@ ComboBox {
|
||||||
text: qsTr("How would you like to connect?")
|
text: qsTr("How would you like to connect?")
|
||||||
}
|
}
|
||||||
StatusListItem {
|
StatusListItem {
|
||||||
|
objectName: "btnStatusConnector"
|
||||||
title: "Status Connector"
|
title: "Status Connector"
|
||||||
asset.name: Theme.png("status-logo")
|
asset.name: Theme.png("status-logo")
|
||||||
asset.isImage: true
|
asset.isImage: true
|
||||||
|
enabled: root.connectorEnabled
|
||||||
components: [
|
components: [
|
||||||
StatusIcon {
|
StatusIcon {
|
||||||
icon: "external-link"
|
icon: "external-link"
|
||||||
|
@ -130,6 +136,7 @@ ComboBox {
|
||||||
title: "Wallet Connect"
|
title: "Wallet Connect"
|
||||||
asset.name: Theme.svg("walletconnect")
|
asset.name: Theme.svg("walletconnect")
|
||||||
asset.isImage: true
|
asset.isImage: true
|
||||||
|
enabled: root.walletConnectEnabled
|
||||||
components: [
|
components: [
|
||||||
StatusIcon {
|
StatusIcon {
|
||||||
icon: "next"
|
icon: "next"
|
||||||
|
|
|
@ -29,8 +29,6 @@ Item {
|
||||||
property WalletStores.RootStore walletStore
|
property WalletStores.RootStore walletStore
|
||||||
|
|
||||||
property var overview
|
property var overview
|
||||||
|
|
||||||
property bool dappsEnabled
|
|
||||||
property int loginType // RootStore.loginType -> Constants.LoginType enum
|
property int loginType // RootStore.loginType -> Constants.LoginType enum
|
||||||
|
|
||||||
property alias headerButton: headerButton
|
property alias headerButton: headerButton
|
||||||
|
@ -144,10 +142,12 @@ Item {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
visible: !root.walletStore.showSavedAddresses
|
visible: !root.walletStore.showSavedAddresses
|
||||||
&& root.dappsEnabled
|
&& (wcService.walletConnectFeatureEnabled || wcService.connectorFeatureEnabled)
|
||||||
&& wcService.serviceAvailableToCurrentAddress
|
&& wcService.serviceAvailableToCurrentAddress
|
||||||
enabled: !!wcService && wcService.isServiceOnline
|
enabled: !!wcService && wcService.isServiceOnline
|
||||||
|
|
||||||
|
walletConnectEnabled: wcService.walletConnectFeatureEnabled
|
||||||
|
connectorEnabled: wcService.connectorFeatureEnabled
|
||||||
|
|
||||||
loginType: root.loginType
|
loginType: root.loginType
|
||||||
selectedAccountAddress: root.walletStore.selectedAddress
|
selectedAccountAddress: root.walletStore.selectedAddress
|
||||||
|
|
|
@ -11,8 +11,13 @@ QObject {
|
||||||
|
|
||||||
readonly property alias dappsModel: d.dappsModel
|
readonly property alias dappsModel: d.dappsModel
|
||||||
readonly property int connectorId: Constants.StatusConnect
|
readonly property int connectorId: Constants.StatusConnect
|
||||||
|
property bool enabled: true
|
||||||
|
|
||||||
function addSession(url, name, iconUrl, accountAddress) {
|
function addSession(url, name, iconUrl, accountAddress) {
|
||||||
|
if (!enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!url || !name || !iconUrl || !accountAddress) {
|
if (!url || !name || !iconUrl || !accountAddress) {
|
||||||
console.error("addSession: missing required parameters")
|
console.error("addSession: missing required parameters")
|
||||||
return
|
return
|
||||||
|
@ -38,10 +43,18 @@ QObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeSession(topic) {
|
function revokeSession(topic) {
|
||||||
|
if (!enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
d.revokeSession(topic)
|
d.revokeSession(topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveSession(topic) {
|
function getActiveSession(topic) {
|
||||||
|
if (!enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return d.getActiveSession(topic)
|
return d.getActiveSession(topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,24 @@ QObject {
|
||||||
readonly property int connectorId: Constants.WalletConnect
|
readonly property int connectorId: Constants.WalletConnect
|
||||||
readonly property var dappsModel: d.dappsModel
|
readonly property var dappsModel: d.dappsModel
|
||||||
|
|
||||||
|
property bool enabled: true
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (!enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
// Just in case the SDK is already initialized
|
// Just in case the SDK is already initialized
|
||||||
d.updateDappsModel()
|
d.updateDappsModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onEnabledChanged: {
|
||||||
|
if (enabled) {
|
||||||
|
d.updateDappsModel()
|
||||||
|
} else {
|
||||||
|
d.dappsModel.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QObject {
|
QObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
|
@ -33,6 +46,8 @@ QObject {
|
||||||
|
|
||||||
property Connections sdkConnections: Connections {
|
property Connections sdkConnections: Connections {
|
||||||
target: root.sdk
|
target: root.sdk
|
||||||
|
enabled: root.enabled
|
||||||
|
|
||||||
function onSessionDelete(topic, err) {
|
function onSessionDelete(topic, err) {
|
||||||
d.updateDappsModel()
|
d.updateDappsModel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ QObject {
|
||||||
// // Array[chainId] of the networks that are down
|
// // Array[chainId] of the networks that are down
|
||||||
required property var blockchainNetworksDown
|
required property var blockchainNetworksDown
|
||||||
|
|
||||||
|
property bool walletConnectFeatureEnabled: true
|
||||||
|
property bool connectorFeatureEnabled: true
|
||||||
|
|
||||||
//output properties
|
//output properties
|
||||||
/// Model contaning all dApps available for the currently selected account
|
/// Model contaning all dApps available for the currently selected account
|
||||||
readonly property var dappsModel: d.filteredDappsModel
|
readonly property var dappsModel: d.filteredDappsModel
|
||||||
|
@ -81,7 +84,7 @@ QObject {
|
||||||
timeoutTimer.start()
|
timeoutTimer.start()
|
||||||
requestHandler.pair(uri)
|
requestHandler.pair(uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Approves or rejects the session proposal
|
/// Approves or rejects the session proposal
|
||||||
function approvePairSession(key, approvedChainIds, accountAddress) {
|
function approvePairSession(key, approvedChainIds, accountAddress) {
|
||||||
requestHandler.approvePairSession(key, approvedChainIds, accountAddress)
|
requestHandler.approvePairSession(key, approvedChainIds, accountAddress)
|
||||||
|
@ -296,6 +299,7 @@ QObject {
|
||||||
|
|
||||||
DAppsListProvider {
|
DAppsListProvider {
|
||||||
id: dappsProvider
|
id: dappsProvider
|
||||||
|
enabled: root.walletConnectFeatureEnabled
|
||||||
sdk: root.wcSDK
|
sdk: root.wcSDK
|
||||||
store: root.store
|
store: root.store
|
||||||
supportedAccountsModel: root.walletRootStore.nonWatchAccounts
|
supportedAccountsModel: root.walletRootStore.nonWatchAccounts
|
||||||
|
@ -303,6 +307,7 @@ QObject {
|
||||||
|
|
||||||
ConnectorDAppsListProvider {
|
ConnectorDAppsListProvider {
|
||||||
id: connectorDAppsProvider
|
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
|
// 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
|
||||||
|
|
|
@ -19,7 +19,6 @@ FocusScope {
|
||||||
property CommunitiesStore communitiesStore
|
property CommunitiesStore communitiesStore
|
||||||
property NetworkConnectionStore networkConnectionStore
|
property NetworkConnectionStore networkConnectionStore
|
||||||
|
|
||||||
property bool dappsEnabled
|
|
||||||
property bool swapEnabled
|
property bool swapEnabled
|
||||||
|
|
||||||
property var sendModal
|
property var sendModal
|
||||||
|
@ -40,7 +39,6 @@ FocusScope {
|
||||||
overview: WalletStores.RootStore.overview
|
overview: WalletStores.RootStore.overview
|
||||||
walletStore: WalletStores.RootStore
|
walletStore: WalletStores.RootStore
|
||||||
networkConnectionStore: root.networkConnectionStore
|
networkConnectionStore: root.networkConnectionStore
|
||||||
dappsEnabled: root.dappsEnabled
|
|
||||||
loginType: root.store.loginType
|
loginType: root.store.loginType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1434,7 +1434,6 @@ Item {
|
||||||
sendModalPopup: sendModal
|
sendModalPopup: sendModal
|
||||||
networkConnectionStore: appMain.networkConnectionStore
|
networkConnectionStore: appMain.networkConnectionStore
|
||||||
appMainVisible: appMain.visible
|
appMainVisible: appMain.visible
|
||||||
dappsEnabled: featureFlagsStore.dappsEnabled
|
|
||||||
swapEnabled: featureFlagsStore.swapEnabled
|
swapEnabled: featureFlagsStore.swapEnabled
|
||||||
}
|
}
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
|
@ -2214,6 +2213,9 @@ Item {
|
||||||
walletRootStore: WalletStores.RootStore
|
walletRootStore: WalletStores.RootStore
|
||||||
blockchainNetworksDown: appMain.networkConnectionStore.blockchainNetworksDown
|
blockchainNetworksDown: appMain.networkConnectionStore.blockchainNetworksDown
|
||||||
|
|
||||||
|
connectorFeatureEnabled: featureFlagsStore.connectorEnabled
|
||||||
|
walletConnectFeatureEnabled: featureFlagsStore.dappsEnabled
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Global.walletConnectService = walletConnectService
|
Global.walletConnectService = walletConnectService
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue