2020-08-06 19:45:57 +00:00
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQuick.Controls 2.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2020-08-06 19:45:57 +00:00
|
|
|
|
import "../../../../../shared"
|
2021-04-26 10:25:01 +00:00
|
|
|
|
import "../../../../../shared/status/core"
|
2021-01-28 11:04:10 +00:00
|
|
|
|
import "../../../../../shared/status"
|
2020-08-06 19:45:57 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
property string username: ""
|
|
|
|
|
property string walletAddress: "-"
|
|
|
|
|
property string key: "-"
|
2021-08-09 22:23:52 +00:00
|
|
|
|
property var expiration: 0
|
2020-08-06 19:45:57 +00:00
|
|
|
|
|
2020-08-07 16:27:41 +00:00
|
|
|
|
signal backBtnClicked();
|
2021-08-09 22:23:52 +00:00
|
|
|
|
signal usernameReleased(username: string);
|
2020-08-07 16:27:41 +00:00
|
|
|
|
|
2020-08-06 19:45:57 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: sectionTitle
|
|
|
|
|
text: username
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 20
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: loadingImageComponent
|
2021-04-26 10:25:01 +00:00
|
|
|
|
StatusLoadingIndicator {}
|
2020-08-06 19:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: loadingImg
|
|
|
|
|
active: false
|
|
|
|
|
sourceComponent: loadingImageComponent
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: Style.currentPadding
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: profileModel.ens
|
|
|
|
|
onDetailsObtained: {
|
|
|
|
|
if(username != ensName) return;
|
|
|
|
|
walletAddressLbl.text = address;
|
|
|
|
|
walletAddressLbl.textToCopy = address;
|
|
|
|
|
keyLbl.text = pubkey.substring(0, 20) + "..." + pubkey.substring(pubkey.length - 20);
|
|
|
|
|
keyLbl.textToCopy = pubkey;
|
|
|
|
|
walletAddressLbl.visible = true;
|
|
|
|
|
keyLbl.visible = true;
|
2021-08-09 22:23:52 +00:00
|
|
|
|
releaseBtn.visible = isStatus
|
|
|
|
|
releaseBtn.enabled = (Date.now() / 1000) > expirationTime && expirationTime > 0 && profileModel.ens.preferredUsername != username
|
|
|
|
|
expiration = new Date(expirationTime * 1000).getTime()
|
2020-08-06 19:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
onLoading: {
|
|
|
|
|
loadingImg.active = isLoading
|
|
|
|
|
if(!isLoading) return;
|
|
|
|
|
walletAddressLbl.visible = false;
|
|
|
|
|
keyLbl.visible = false;
|
2021-08-09 22:23:52 +00:00
|
|
|
|
releaseBtn.visible = false;
|
|
|
|
|
expiration = 0;
|
2020-08-06 19:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
|
id: walletAddressLbl
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Wallet address"
|
|
|
|
|
label: qsTrId("wallet-address")
|
2020-08-06 19:45:57 +00:00
|
|
|
|
visible: false
|
|
|
|
|
text: ""
|
|
|
|
|
textToCopy: ""
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
anchors.top: sectionTitle.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
|
id: keyLbl
|
|
|
|
|
visible: false
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Key"
|
|
|
|
|
label: qsTrId("key")
|
2020-08-06 19:45:57 +00:00
|
|
|
|
text: ""
|
|
|
|
|
textToCopy: ""
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
anchors.top: walletAddressLbl.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-09 22:23:52 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: transactionDialogComponent
|
|
|
|
|
StatusETHTransactionModal {
|
|
|
|
|
onOpened: {
|
|
|
|
|
walletModel.gasView.getGasPricePredictions()
|
|
|
|
|
}
|
|
|
|
|
title: qsTr("Connect username with your pubkey")
|
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
|
|
|
|
}
|
|
|
|
|
estimateGasFunction: function(selectedAccount) {
|
|
|
|
|
if (username === "" || !selectedAccount) return 100000;
|
|
|
|
|
return profileModel.ens.releaseEstimate(Utils.removeStatusEns(username), selectedAccount.address)
|
|
|
|
|
}
|
|
|
|
|
onSendTransaction: function(selectedAddress, gasLimit, gasPrice, password) {
|
|
|
|
|
return profileModel.ens.release(username,
|
|
|
|
|
selectedAddress,
|
|
|
|
|
gasLimit,
|
|
|
|
|
gasPrice,
|
|
|
|
|
password)
|
|
|
|
|
}
|
|
|
|
|
onSuccess: function(){
|
|
|
|
|
usernameReleased(username);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
width: 475
|
|
|
|
|
height: 500
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
|
id: releaseBtn
|
|
|
|
|
visible: false
|
|
|
|
|
enabled: false
|
|
|
|
|
anchors.top: keyLbl.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
text: qsTrId("Release username")
|
|
|
|
|
onClicked: {
|
|
|
|
|
openPopup(transactionDialogComponent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
visible: releaseBtn.visible && !releaseBtn.enabled
|
|
|
|
|
anchors.top: releaseBtn.bottom
|
|
|
|
|
anchors.topMargin: 2
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
2021-08-10 17:40:10 +00:00
|
|
|
|
text: qsTr("Username locked. You won’t be able to release it until %1").arg(Utils.formatShortDateStr(new Date(expiration).toDateString()))
|
2021-08-09 22:23:52 +00:00
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-28 11:04:10 +00:00
|
|
|
|
StatusButton {
|
2020-08-06 19:45:57 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Back"
|
2021-01-28 11:04:10 +00:00
|
|
|
|
text: qsTrId("back")
|
2020-08-07 16:27:41 +00:00
|
|
|
|
onClicked: backBtnClicked()
|
2020-08-06 19:45:57 +00:00
|
|
|
|
}
|
2020-09-14 12:12:47 +00:00
|
|
|
|
}
|