fix(dapps) fail to process a transaction if missing usual fields (#15481)

Updates: #15189

Co-authored-by: Stefan <stefand@status.im>
This commit is contained in:
Roman Chornii 2024-07-15 12:23:35 +03:00 committed by GitHub
parent 046892dd98
commit c4d930ef88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 243 additions and 117 deletions

View File

@ -0,0 +1,29 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
import Models 1.0
import Storybook 1.0
import shared.popups.walletconnect 1.0
Item {
id: root
DAppConfirmDisconnectPopup {
anchors.centerIn: parent
visible: true
dappIcon: "https://opensea.io/static/images/logos/opensea-logo.svg"
dappUrl: "opensea.io"
dappName: "OpenSea"
destroyOnClose: false
}
}
// category: Popups
// https://www.figma.com/design/HrmZp1y4S77QJezRFRl6ku/dApp-Interactions---Milestone-1?node-id=3620-39188&t=py67JrptsxbHYMHW-0

View File

@ -31,7 +31,40 @@ DappsComboBox {
}
onDisconnectDapp: (dappUrl) => {
root.wcService.disconnectDapp(dappUrl)
disconnectdAppDialogLoader.dAppUrl = dappUrl
disconnectdAppDialogLoader.active = true
}
Loader {
id: disconnectdAppDialogLoader
property string dAppUrl
active: false
onLoaded: {
const dApp = wcService.getDApp(dAppUrl);
if (dApp) {
item.dappName = dApp.name;
item.dappIcon = dApp.iconUrl;
item.dappUrl = disconnectdAppDialogLoader.dAppUrl;
}
item.open();
}
sourceComponent: DAppConfirmDisconnectPopup {
visible: true
onClosed: {
disconnectdAppDialogLoader.active = false
}
onAccepted: {
root.wcService.disconnectDapp(dappUrl)
}
}
}
Loader {

View File

@ -119,6 +119,10 @@ QObject {
});
}
function getDApp(dAppUrl) {
return ModelUtils.getByKey(dappsModel, "url", dAppUrl);
}
signal connectDApp(var dappChains, var sessionProposal, var approvedNamespaces)
signal approveSessionResult(var session, var error)
signal sessionRequest(SessionRequestResolved request)
@ -263,4 +267,4 @@ QObject {
d.reportPairErrorState(Pairing.errors.unknownError)
}
}
}
}

View File

@ -0,0 +1,62 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml.Models 2.15
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
import StatusQ.Components 0.1
import StatusQ.Popups.Dialog 0.1
StatusDialog {
id: root
objectName: "dappConfirmDisconnectPopup"
property string dappName
property url dappIcon
property string dappUrl
implicitWidth: 640
contentItem: StatusBaseText {
text: qsTr("Are you sure you want to disconnect %1 from all accounts?").arg(StringUtils.extractDomainFromLink(dappUrl))
wrapMode: Text.WrapAnywhere
}
header: StatusDialogHeader {
leftComponent: StatusRoundedImage {
height: 40
width: height
image.source: root.dappIcon
}
headline.title: qsTr("Disconnect %1").arg(root.dappName)
headline.subtitle: StringUtils.extractDomainFromLink(root.dappUrl)
actions.closeButton.visible: true
actions.closeButton.onClicked: root.close()
}
footer: StatusDialogFooter {
spacing: 16
rightButtons: ObjectModel {
StatusFlatButton {
text: qsTr("Cancel")
onClicked: root.reject();
}
StatusButton {
type: StatusButton.Danger
text: qsTr("Disconnect dApp")
icon.name: "disconnect"
onClicked: {
root.accepted();
root.close();
}
}
}
}
}

View File

@ -1,5 +0,0 @@
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Feature / Sign">
<path id="Vector 32" d="M3.30026 5.87295C2.67249 5.56241 1.93965 5.00104 1.46227 4.33462C0.711792 3.28696 0.491562 2.00625 1.53098 1.23526C2.3099 0.657513 3.61233 1.37874 4.10757 2.49686C4.7675 3.98668 4.6573 6.28428 3.42906 8.2263C2.8116 9.2026 1.86004 9.10424 1.53098 8.54312C1.07672 7.76851 1.54754 6.07397 3.70877 4.99336C5.59513 4.05019 6.12334 4.52806 6.01429 5.03985C5.9758 5.22047 5.55049 5.95884 6.11735 5.95884C6.60595 5.95884 7.02642 5.354 7.42285 5.03985C7.92791 4.63959 8.4535 4.51593 8.38977 5.26933C8.36595 5.55093 8.48785 6.15638 9.17496 5.81283" stroke="white" stroke-width="0.833333" stroke-linecap="round"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 759 B

View File

@ -1,110 +1,112 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import StatusQ.Components 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
ColumnLayout {
id: root
spacing: 8
required property string dappName
required property url dappIcon
required property var account
property string userDisplayNaming
// Icons
Item {
Layout.fillWidth: true
Layout.preferredHeight: 40
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 8
StatusRoundedImage {
width: height
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -16
anchors.verticalCenter: parent.verticalCenter
image.source: root.dappIcon
}
StatusRoundIcon {
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: 16
anchors.verticalCenter: parent.verticalCenter
asset: StatusAssetSettings {
width: 24
height: 24
color: Theme.palette.primaryColor1
bgWidth: 40
bgHeight: 40
bgColor: Theme.palette.desktopBlue10
bgRadius: bgWidth / 2
bgBorderWidth: 2
bgBorderColor: Theme.palette.statusAppLayout.backgroundColor
source: "assets/sign.svg"
}
}
}
// Names and intentions
StatusBaseText {
text: qsTr("%1 wants you to %2 with %3").arg(dappName).arg(root.userDisplayNaming).arg(account.name)
Layout.preferredWidth: 400
Layout.alignment: Qt.AlignHCenter
font.pixelSize: 15
font.weight: Font.DemiBold
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
// TODO #14762: externalize as a InfoPill and merge base implementation with
// the existing IssuePill reusable component
Rectangle {
Layout.preferredWidth: operationStatusLayout.implicitWidth + 24
Layout.preferredHeight: operationStatusLayout.implicitHeight + 14
Layout.alignment: Qt.AlignHCenter
visible: true
border.color: Theme.palette.successColor2
border.width: 1
color: "transparent"
radius: height / 2
RowLayout {
id: operationStatusLayout
spacing: 8
anchors.centerIn: parent
StatusIcon {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
visible: true
color: Theme.palette.directColor1
icon: "info"
}
StatusBaseText {
text: qsTr("Only sign if you trust the dApp")
font.pixelSize: 12
color: Theme.palette.directColor1
}
}
}
}
import QtQuick 2.15
import QtQuick.Layouts 1.15
import StatusQ.Components 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0
ColumnLayout {
id: root
spacing: 8
required property string dappName
required property url dappIcon
required property var account
property string userDisplayNaming
// Icons
Item {
Layout.fillWidth: true
Layout.preferredHeight: 40
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 8
StatusRoundedImage {
width: height
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -16
anchors.verticalCenter: parent.verticalCenter
image.source: root.dappIcon
}
StatusRoundIcon {
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: 16
anchors.verticalCenter: parent.verticalCenter
asset: StatusAssetSettings {
width: 24
height: 24
color: Theme.palette.primaryColor1
bgWidth: 40
bgHeight: 40
bgColor: Theme.palette.desktopBlue10
bgRadius: bgWidth / 2
bgBorderWidth: 2
bgBorderColor: Theme.palette.statusAppLayout.backgroundColor
source: Style.svg("sign")
}
}
}
// Names and intentions
StatusBaseText {
text: qsTr("%1 wants you to %2 with %3").arg(dappName).arg(root.userDisplayNaming).arg(account.name)
Layout.preferredWidth: 400
Layout.alignment: Qt.AlignHCenter
font.pixelSize: 15
font.weight: Font.DemiBold
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
// TODO #14762: externalize as a InfoPill and merge base implementation with
// the existing IssuePill reusable component
Rectangle {
Layout.preferredWidth: operationStatusLayout.implicitWidth + 24
Layout.preferredHeight: operationStatusLayout.implicitHeight + 14
Layout.alignment: Qt.AlignHCenter
visible: true
border.color: Theme.palette.successColor2
border.width: 1
color: "transparent"
radius: height / 2
RowLayout {
id: operationStatusLayout
spacing: 8
anchors.centerIn: parent
StatusIcon {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
visible: true
color: Theme.palette.directColor1
icon: "info"
}
StatusBaseText {
text: qsTr("Only sign if you trust the dApp")
font.pixelSize: 12
color: Theme.palette.directColor1
}
}
}
}

View File

@ -5,3 +5,4 @@ ConnectionStatusTag 1.0 ConnectionStatusTag.qml
DAppSignRequestModal 1.0 DAppSignRequestModal.qml
DAppsUriCopyInstructionsPopup 1.0 DAppsUriCopyInstructionsPopup.qml
RoundImageWithBadge 1.0 RoundImageWithBadge.qml
DAppConfirmDisconnectPopup 1.0 DAppConfirmDisconnectPopup.qml