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
|
2020-11-24 20:19:20 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-20 09:45:38 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.views 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2021-09-30 09:43:29 +00:00
|
|
|
import "../stores"
|
2020-10-05 16:24:43 +00:00
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
StatusModal {
|
2020-10-05 16:24:43 +00:00
|
|
|
property var request
|
2020-11-24 20:19:20 +00:00
|
|
|
property var selectedAccount
|
2020-10-05 16:24:43 +00:00
|
|
|
|
|
|
|
readonly property int bytes32Length: 66
|
|
|
|
|
|
|
|
property bool interactedWith: false
|
2020-11-24 20:19:20 +00:00
|
|
|
property bool showSigningPhrase: false
|
2020-10-05 16:24:43 +00:00
|
|
|
|
|
|
|
property alias transactionSigner: transactionSigner
|
|
|
|
|
|
|
|
property var signMessage: function(enteredPassword) {}
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2020-10-05 16:24:43 +00:00
|
|
|
property var web3Response
|
|
|
|
|
2020-11-24 20:19:20 +00:00
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
anchors.centerIn: parent
|
2020-10-05 16:24:43 +00:00
|
|
|
id: root
|
|
|
|
|
2022-04-04 11:26:30 +00:00
|
|
|
header.title: qsTr("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
|
|
|
}
|
|
|
|
|
2020-11-24 20:19:20 +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;
|
|
|
|
}
|
2021-09-30 09:43:29 +00:00
|
|
|
return RootStore.getHex2Ascii(input)
|
2020-10-27 16:49:55 +00:00
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
return input;
|
2020-10-05 16:24:43 +00:00
|
|
|
}
|
|
|
|
|
2020-11-24 20:19:20 +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
|
2022-02-09 09:43:23 +00:00
|
|
|
default:
|
|
|
|
return JSON.stringify(request.payload.params); // support for any unhandled sign method
|
2020-11-24 20:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
contentItem: Item {
|
|
|
|
width: root.width
|
2020-11-24 20:19:20 +00:00
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
TransactionSigner {
|
|
|
|
id: transactionSigner
|
|
|
|
width: parent.width
|
|
|
|
signingPhrase: WalletStore.signingPhrase
|
|
|
|
visible: showSigningPhrase
|
|
|
|
}
|
2020-11-24 20:19:20 +00:00
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
Column {
|
|
|
|
id: content
|
|
|
|
visible: !showSigningPhrase
|
2021-11-18 23:40:49 +00:00
|
|
|
width: root.width - Style.current.padding * 2
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-10-20 09:45:38 +00:00
|
|
|
|
|
|
|
LabelValueRow {
|
2022-04-04 11:26:30 +00:00
|
|
|
label: qsTr("From")
|
2021-10-20 09:45:38 +00:00
|
|
|
value: Item {
|
|
|
|
id: itmFromValue
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
Row {
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
rightPadding: 0
|
|
|
|
anchors.right: parent.right
|
2020-11-24 20:19:20 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-20 09:45:38 +00:00
|
|
|
|
|
|
|
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: Style.svg("walletIcon")
|
|
|
|
ColorOverlay {
|
|
|
|
visible: parent.visible
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: selectedAccount.iconColor
|
|
|
|
}
|
2020-11-24 20:19:20 +00:00
|
|
|
}
|
2020-10-05 16:24:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
LabelValueRow {
|
2022-04-04 11:26:30 +00:00
|
|
|
label: qsTr("Data")
|
2021-10-20 09:45:38 +00:00
|
|
|
value: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
// TODO; replace with StatusModal
|
|
|
|
ModalPopup {
|
|
|
|
id: messagePopup
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Message")
|
2021-10-20 09:45:38 +00:00
|
|
|
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()
|
|
|
|
}
|
2020-11-24 20:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
Row {
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
rightPadding: 0
|
|
|
|
anchors.right: parent.right
|
2020-11-24 20:19:20 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-20 09:45:38 +00:00
|
|
|
StyledText {
|
|
|
|
width: 250
|
|
|
|
font.pixelSize: 15
|
|
|
|
height: 22
|
|
|
|
text: messageToSign()
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
horizontalAlignment: Text.AlignRight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
2020-11-24 20:19:20 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
2021-10-20 09:45:38 +00:00
|
|
|
SVGImage {
|
|
|
|
width: 13
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: Style.svg("caret")
|
|
|
|
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-11-24 20:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 16:24:43 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 09:45:38 +00:00
|
|
|
}
|
2020-10-05 16:24:43 +00:00
|
|
|
|
2021-11-18 23:40:49 +00:00
|
|
|
leftButtons: [
|
2021-10-20 09:45:38 +00:00
|
|
|
StatusFlatButton {
|
2020-11-24 20:19:20 +00:00
|
|
|
id: btnReject
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Reject")
|
2021-11-18 23:40:49 +00:00
|
|
|
type: StatusBaseButton.Type.Danger
|
2020-11-24 20:19:20 +00:00
|
|
|
onClicked: close()
|
2021-11-18 23:40:49 +00:00
|
|
|
}
|
|
|
|
]
|
2020-11-24 20:19:20 +00:00
|
|
|
|
2021-11-18 23:40:49 +00:00
|
|
|
rightButtons: [
|
2020-10-05 16:24:43 +00:00
|
|
|
StatusButton {
|
|
|
|
id: btnNext
|
2022-02-09 09:43:23 +00:00
|
|
|
text: showSigningPhrase ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Sign") :
|
|
|
|
qsTr("Sign with password")
|
2020-11-24 20:19:20 +00:00
|
|
|
onClicked: {
|
|
|
|
if(!showSigningPhrase){
|
|
|
|
showSigningPhrase = true;
|
|
|
|
transactionSigner.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
} else {
|
|
|
|
root.signMessage(transactionSigner.enteredPassword)
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 16:24:43 +00:00
|
|
|
}
|
2021-10-20 09:45:38 +00:00
|
|
|
]
|
2020-10-05 16:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|