mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-02 09:46:38 +00:00
fix(@desktop/wallet): Disconnect button doesnt disconnect Wallet from Browser
fixes #4053
This commit is contained in:
parent
6e453dbbba
commit
ade6a22fda
@ -37,6 +37,9 @@ method setDappsAddress*(self: Controller, address: string) =
|
|||||||
method getCurrentNetworkId*(self: Controller): int =
|
method getCurrentNetworkId*(self: Controller): int =
|
||||||
return self.settingsService.getCurrentNetworkId()
|
return self.settingsService.getCurrentNetworkId()
|
||||||
|
|
||||||
|
method getCurrentNetwork*(self: Controller): string =
|
||||||
|
return self.settingsService.getCurrentNetwork()
|
||||||
|
|
||||||
method postMessage*(self: Controller, requestType: string, message: string): string =
|
method postMessage*(self: Controller, requestType: string, message: string): string =
|
||||||
return self.providerService.postMessage(requestType, message)
|
return self.providerService.postMessage(requestType, message)
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ method setDappsAddress*(self: AccessInterface, address: string) {.base.} =
|
|||||||
method getCurrentNetworkId*(self: AccessInterface): int {.base.} =
|
method getCurrentNetworkId*(self: AccessInterface): int {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method getCurrentNetwork*(self: AccessInterface): string {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method postMessage*(self: AccessInterface, requestType: string, message: string): string {.base.} =
|
method postMessage*(self: AccessInterface, requestType: string, message: string): string {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ method load*(self: Module) =
|
|||||||
singletonInstance.engine.setRootContextProperty("providerModule", self.viewVariant)
|
singletonInstance.engine.setRootContextProperty("providerModule", self.viewVariant)
|
||||||
self.view.dappsAddress = self.controller.getDappsAddress()
|
self.view.dappsAddress = self.controller.getDappsAddress()
|
||||||
self.view.networkId = self.controller.getCurrentNetworkId()
|
self.view.networkId = self.controller.getCurrentNetworkId()
|
||||||
|
self.view.currentNetwork = self.controller.getCurrentNetwork()
|
||||||
self.view.load()
|
self.view.load()
|
||||||
|
|
||||||
method isLoaded*(self: Module): bool =
|
method isLoaded*(self: Module): bool =
|
||||||
|
@ -8,6 +8,7 @@ QtObject:
|
|||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
dappsAddress: string
|
dappsAddress: string
|
||||||
networkId: int
|
networkId: int
|
||||||
|
currentNetwork: string
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
@ -50,6 +51,19 @@ QtObject:
|
|||||||
read = networkId
|
read = networkId
|
||||||
notify = networkIdChanged
|
notify = networkIdChanged
|
||||||
|
|
||||||
|
proc currentNetworkChanged(self: View) {.signal.}
|
||||||
|
|
||||||
|
proc `currentNetwork=`*(self: View, value: string) =
|
||||||
|
self.currentNetwork = value
|
||||||
|
self.currentNetworkChanged()
|
||||||
|
|
||||||
|
proc currentNetwork*(self: View): string {.slot.} =
|
||||||
|
result = self.currentNetwork
|
||||||
|
|
||||||
|
QtProperty[string] currentNetwork:
|
||||||
|
read = currentNetwork
|
||||||
|
notify = currentNetworkChanged
|
||||||
|
|
||||||
proc replaceHostByENS*(self: View, url: string, ens: string): string {.slot.} =
|
proc replaceHostByENS*(self: View, url: string, ens: string): string {.slot.} =
|
||||||
result = url_replaceHostAndAddPath(url, ens)
|
result = url_replaceHostAndAddPath(url, ens)
|
||||||
|
|
||||||
|
@ -492,8 +492,9 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDisconnect: {
|
onDisconnect: {
|
||||||
Web3ProviderStore.web3ProviderInst.disconnect()
|
Web3ProviderStore.disconnect(Utils.getHostname(_internal.currentWebView.url))
|
||||||
provider.postMessage("web3-disconnect-account", "{}");
|
provider.postMessage("web3-disconnect-account", "{}");
|
||||||
|
_internal.currentWebView.reload()
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,6 +602,7 @@ Rectangle {
|
|||||||
target: _internal.currentWebView
|
target: _internal.currentWebView
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
browserHeader.addressBar.text = Web3ProviderStore.obtainAddress(_internal.currentWebView.url)
|
browserHeader.addressBar.text = Web3ProviderStore.obtainAddress(_internal.currentWebView.url)
|
||||||
|
RootStore.currentTabConnected = Web3ProviderStore.hasWalletConnected(Utils.getHostname(_internal.currentWebView.url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ Popup {
|
|||||||
height: 8
|
height: 8
|
||||||
radius: width / 2
|
radius: width / 2
|
||||||
color: {
|
color: {
|
||||||
switch (RootStore.currentNetwork) {
|
switch (Web3ProviderStore.currentNetwork) {
|
||||||
case Constants.networkMainnet: return Style.current.green;
|
case Constants.networkMainnet: return Style.current.green;
|
||||||
case Constants.networkRopsten: return Style.current.turquoise;
|
case Constants.networkRopsten: return Style.current.turquoise;
|
||||||
default: return Style.current.red
|
default: return Style.current.red
|
||||||
@ -71,7 +71,7 @@ Popup {
|
|||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
id: networkText
|
id: networkText
|
||||||
text: {
|
text: {
|
||||||
switch (RootStore.currentNetwork) {
|
switch (Web3ProviderStore.currentNetwork) {
|
||||||
//% "Mainnet"
|
//% "Mainnet"
|
||||||
case Constants.networkMainnet: return qsTrId("mainnet");
|
case Constants.networkMainnet: return qsTrId("mainnet");
|
||||||
//% "Ropsten"
|
//% "Ropsten"
|
||||||
@ -94,6 +94,7 @@ Popup {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: Style.current.danger
|
color: Style.current.danger
|
||||||
|
visible: RootStore.currentTabConnected
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
@ -10,9 +10,6 @@ QtObject {
|
|||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
// property string activeChannelName: chatsModel.channelView.activeChannel.name
|
// property string activeChannelName: chatsModel.channelView.activeChannel.name
|
||||||
|
|
||||||
// Not Refactored Yet
|
|
||||||
// property var currentNetwork: profileModel.network.current
|
|
||||||
|
|
||||||
property bool currentTabConnected: false
|
property bool currentTabConnected: false
|
||||||
|
|
||||||
function getUrlFromUserInput(input) {
|
function getUrlFromUserInput(input) {
|
||||||
|
@ -2,6 +2,8 @@ pragma Singleton
|
|||||||
|
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
@ -9,9 +11,14 @@ QtObject {
|
|||||||
property var urlENSDictionary: ({})
|
property var urlENSDictionary: ({})
|
||||||
|
|
||||||
property int networkId: providerModule.networkId
|
property int networkId: providerModule.networkId
|
||||||
|
property string currentNetwork: providerModule.currentNetwork
|
||||||
|
|
||||||
function disconnectAddress(dappName, address){
|
function disconnectAddress(dappName, address){
|
||||||
dappPermissionsModule.disconnectAddress(address)
|
dappPermissionsModule.disconnectAddress(dappName, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnect(hostname) {
|
||||||
|
dappPermissionsModule.disconnect(hostname)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPermission(hostname, address, permission){
|
function addPermission(hostname, address, permission){
|
||||||
@ -22,6 +29,10 @@ QtObject {
|
|||||||
return dappPermissionsModule.hasPermission(hostname, address, permission)
|
return dappPermissionsModule.hasPermission(hostname, address, permission)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasWalletConnected(hostname) {
|
||||||
|
return hasPermission(hostname, WalletStore.dappBrowserAccount.address, "web3")
|
||||||
|
}
|
||||||
|
|
||||||
function determineRealURL(text){
|
function determineRealURL(text){
|
||||||
var url = RootStore.getUrlFromUserInput(text);
|
var url = RootStore.getUrlFromUserInput(text);
|
||||||
var host = providerModule.getHost(url);
|
var host = providerModule.getHost(url);
|
||||||
|
@ -43,7 +43,7 @@ QtObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (requestType === Constants.web3DisconnectAccount) {
|
if (requestType === Constants.web3DisconnectAccount) {
|
||||||
RootStore.currentTabConnected = true
|
RootStore.currentTabConnected = false
|
||||||
web3Response(JSON.stringify({type: Constants.web3DisconnectAccount}));
|
web3Response(JSON.stringify({type: Constants.web3DisconnectAccount}));
|
||||||
} else if (requestType === Constants.api_request) {
|
} else if (requestType === Constants.api_request) {
|
||||||
if (!Web3ProviderStore.hasPermission(request.hostname, request.address, request.permission)) {
|
if (!Web3ProviderStore.hasPermission(request.hostname, request.address, request.permission)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user