-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BC): Unify dapp sessions between WalletConnect and BrowserConnect
New component introduced (DAppsModel) to provide a common model for WC and BC. The WCDappsProvider and BCDappsProvider components are responsible to fill the model from different sources
- Loading branch information
Showing
14 changed files
with
305 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ui/app/AppLayouts/Wallet/services/dapps/BCDappsProvider.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import QtQuick 2.15 | ||
|
||
import AppLayouts.Wallet.services.dapps 1.0 | ||
import StatusQ.Core.Utils 0.1 | ||
|
||
import shared.stores 1.0 | ||
import utils 1.0 | ||
|
||
DAppsModel { | ||
id: root | ||
|
||
required property BrowserConnectStore store | ||
|
||
readonly property int connectorId: Constants.StatusConnect | ||
property bool enabled: true | ||
|
||
Connections { | ||
target: root.store | ||
enabled: root.enabled | ||
|
||
function onConnected(dappJson) { | ||
const dapp = JSON.parse(dappJson) | ||
const { url, name, icon, sharedAccount } = dapp | ||
|
||
if (!url) { | ||
console.warn(invalidDAppUrlError) | ||
return | ||
} | ||
root.append({ | ||
name, | ||
url, | ||
iconUrl: icon, | ||
topic: url, | ||
connectorId: root.connectorId, | ||
accountAddresses: [{address: sharedAccount}], | ||
rawSessions: [dapp] | ||
}) | ||
} | ||
|
||
function onDisconnected(dappJson) { | ||
const dapp = JSON.parse(dappJson) | ||
const { url } = dapp | ||
|
||
if (!url) { | ||
console.warn(invalidDAppUrlError) | ||
return | ||
} | ||
root.remove(dapp.url) | ||
} | ||
} | ||
|
||
Component.onCompleted: { | ||
if (root.enabled) { | ||
const dappsStr = root.store.getDApps() | ||
if (dappsStr) { | ||
const dapps = JSON.parse(dappsStr) | ||
dapps.forEach(dapp => { | ||
const { url, name, iconUrl, sharedAccount } = dapp | ||
root.append({ | ||
name, | ||
url, | ||
iconUrl, | ||
topic: url, | ||
connectorId: root.connectorId, | ||
accountAddresses: [{address: sharedAccount}], | ||
rawSessions: [dapp] | ||
}) | ||
}) | ||
} | ||
} | ||
} | ||
} |
106 changes: 0 additions & 106 deletions
106
ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.qml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.