status-desktop/ui/app/AppLayouts/Browser/SignMessageModal.qml

238 lines
7.5 KiB
QML
Raw Normal View History

2020-10-05 16:24:43 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtQuick.Dialogs 1.3
import QtGraphicalEffects 1.13
2020-10-05 16:24:43 +00:00
import "../../../imports"
import "../../../shared"
import "../../../shared/status"
ModalPopup {
property var request
property var selectedAccount
2020-10-05 16:24:43 +00:00
readonly property int bytes32Length: 66
property bool interactedWith: false
property bool showSigningPhrase: false
2020-10-05 16:24:43 +00:00
property alias transactionSigner: transactionSigner
property var signMessage: function(enteredPassword) {}
property var web3Response
2020-10-05 16:24:43 +00:00
id: root
2021-02-18 16:36:05 +00:00
//% "Signature request"
title: qsTrId("signature-request")
2020-10-05 16:24:43 +00:00
height: 504
onClosed: {
if(!interactedWith){
web3Response(JSON.stringify({
"type": "web3-send-async-callback",
"messageId": request.messageId,
"error": {
"code": 4100
}
}));
}
2020-10-27 16:49:55 +00:00
}
onOpened: {
showSigningPhrase = false;
}
2020-10-27 16:49:55 +00:00
function displayValue(input){
if(Utils.isHex(input) && Utils.startsWith0x(input)){
if (input.length === bytes32Length){
return input;
}
return utilsModel.hex2Ascii(input)
}
return input;
2020-10-05 16:24:43 +00:00
}
function messageToSign(){
switch(request.payload.method){
case Constants.personal_sign:
return displayValue(request.payload.params[0]);
case Constants.eth_sign:
return displayValue(request.payload.params[1]);
case Constants.eth_signTypedData:
case Constants.eth_signTypedData_v3:
return JSON.stringify(request.payload.params[1]); // TODO: requires design
default:
return JSON.stringify(request.payload.params); // support for any unhandled sign method
}
}
TransactionSigner {
id: transactionSigner
width: parent.width
refactor wallet views add getSettings methods to src/status fix issue with calling getSettings; document issue remove most direct references to libstatus; document some common issues remove most references to libstatus wallet add mailserver layer to status lib; remove references to libstatus mailservers remove libstatus accounts references move types out of libstatus; remove libstatus types references remove libstatus browser references refactor libstatus utils references remove more references to libstatus stickers remove references to libstatus constants from src/app remove more libstatus references from src/app refactor token_list usage of libstatus refactor stickers usage of libstatus refactor chat usage of libstatus remove libstatus references from the wallet view remove logic from ens manager view fix issue with import & namespace conflict remove unnecessary imports refactor provider view to not depend on libstatus refactor provider view refactor: move accounts specific code to its own section fix account selection move collectibles to their own module update references to wallet transactions refactor: move gas methods to their own file refactor: extract tokens into their own file refactor: extract ens to its own file refactor: extract dappbrowser code to its own file refactor: extract history related code to its own file refactor: extract balance to its own file refactor: extract utils to its own file clean up wallet imports fix: identicon for transaction commands Fixes #2533
2021-06-08 12:48:31 +00:00
signingPhrase: walletModel.utilsView.signingPhrase
visible: showSigningPhrase
}
Column {
id: content
anchors.left: parent.left
anchors.right: parent.right
visible: !showSigningPhrase
LabelValueRow {
//% "From"
label: qsTrId("from")
value: Item {
id: itmFromValue
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
Row {
spacing: Style.current.halfPadding
rightPadding: 0
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
StyledText {
font.pixelSize: 15
height: 22
text: selectedAccount.name
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
SVGImage {
id: imgFromWallet
sourceSize.height: 18
sourceSize.width: 18
visible: true
horizontalAlignment: Image.AlignLeft
width: undefined
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: "../../img/walletIcon.svg"
ColorOverlay {
visible: parent.visible
anchors.fill: parent
source: parent
color: selectedAccount.iconColor
}
2020-10-05 16:24:43 +00:00
}
}
}
}
LabelValueRow {
2021-02-18 16:36:05 +00:00
//% "Data"
label: qsTrId("data")
value: Item {
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
ModalPopup {
id: messagePopup
2021-02-18 16:36:05 +00:00
//% "Message"
title: qsTrId("message")
height: 286
width: 400
Item {
anchors.fill: parent
anchors.leftMargin: Style.current.padding
anchors.rightMargin: Style.current.padding
ScrollView {
width: parent.width
height: 150
TextArea {
wrapMode: TextEdit.Wrap
readOnly: true
text: messageToSign()
}
}
}
}
Row {
spacing: Style.current.halfPadding
rightPadding: 0
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
StyledText {
width: 250
font.pixelSize: 15
height: 22
text: messageToSign()
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
color: Style.current.secondaryText
}
SVGImage {
width: 13
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: "../../img/caret.svg"
rotation: 270
ColorOverlay {
anchors.fill: parent
source: parent
color: Style.current.secondaryText
}
}
}
MouseArea {
anchors.fill: parent
visible: true
cursorShape: Qt.PointingHandCursor
onClicked: messagePopup.open()
}
}
2020-10-05 16:24:43 +00:00
}
}
footer: Item {
width: parent.width
height: btnReject.height
StatusButton {
id: btnReject
anchors.right:btnNext.left
anchors.rightMargin: Style.current.padding
2021-02-18 16:36:05 +00:00
//% "Reject"
text: qsTrId("reject")
color: Style.current.danger
type: "secondary"
onClicked: close()
}
2020-10-05 16:24:43 +00:00
StatusButton {
id: btnNext
anchors.right: parent.right
2020-11-26 17:15:20 +00:00
text: showSigningPhrase ?
2021-02-18 16:36:05 +00:00
//% "Sign"
qsTrId("transactions-sign") :
//% "Sign with password"
qsTrId("sign-with-password")
onClicked: {
if(!showSigningPhrase){
showSigningPhrase = true;
transactionSigner.forceActiveFocus(Qt.MouseFocusReason)
} else {
root.signMessage(transactionSigner.enteredPassword)
}
}
2020-10-05 16:24:43 +00:00
}
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/