2020-08-04 22:22:51 +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
2021-10-25 14:33:41 +00:00
2021-10-27 21:27:49 +00:00
import shared . popups 1.0
import shared . status 1.0
2023-09-05 15:27:30 +00:00
import shared . popups . send 1.0
2021-10-06 09:16:39 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Controls 0.1
import StatusQ . Components 0.1
2020-08-04 22:22:51 +00:00
Item {
2021-10-06 09:16:39 +00:00
id: root
2020-08-26 21:13:26 +00:00
2022-01-17 08:56:44 +00:00
property var ensUsernamesStore
property var contactsStore
2022-04-19 11:13:57 +00:00
property var stickersStore
2022-01-17 08:56:44 +00:00
property string username: ""
2021-12-22 13:41:39 +00:00
2020-08-26 21:13:26 +00:00
signal backBtnClicked ( ) ;
2020-08-27 16:06:53 +00:00
signal usernameRegistered ( userName: string ) ;
2020-08-26 21:13:26 +00:00
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-08-04 22:22:51 +00:00
id: sectionTitle
2022-04-04 11:26:30 +00:00
text: qsTr ( "ENS usernames" )
2020-08-04 22:22:51 +00:00
anchors.left: parent . left
anchors.leftMargin: 24
anchors.top: parent . top
anchors.topMargin: 24
font.weight: Font . Bold
font.pixelSize: 20
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-04 22:22:51 +00:00
}
2020-11-03 10:29:56 +00:00
Loader {
2020-08-27 16:06:53 +00:00
id: transactionDialog
2020-11-03 10:29:56 +00:00
function open ( ) {
this . active = true
this . item . open ( )
}
function closed ( ) {
this . active = false // kill an opened instance
}
2022-10-17 10:17:25 +00:00
sourceComponent: SendModal {
id: buyEnsModal
interactive: false
2023-09-20 16:07:09 +00:00
preSelectedSendType: Constants . SendType . ENSRegister
2022-10-17 10:17:25 +00:00
preSelectedRecipient: root . ensUsernamesStore . getEnsRegisteredAddress ( )
preDefinedAmountToSend: LocaleUtils . numberToLocaleString ( 10 )
2023-09-26 13:45:44 +00:00
preSelectedHoldingID: JSON . parse ( root . stickersStore . getStatusToken ( ) ) . symbol
2023-11-07 22:45:47 +00:00
preSelectedHoldingType: Constants . TokenType . ERC20
2022-10-17 10:17:25 +00:00
sendTransaction: function ( ) {
2023-08-15 18:21:51 +00:00
if ( bestRoutes . count === 1 ) {
let path = bestRoutes . firstItem ( )
2022-10-17 10:17:25 +00:00
let eip1559Enabled = path . gasFees . eip1559Enabled
2022-11-30 12:59:21 +00:00
let maxFeePerGas = path . gasFees . maxFeePerGasM
2022-10-17 10:17:25 +00:00
root . ensUsernamesStore . authenticateAndRegisterEns (
2023-01-11 16:10:13 +00:00
root . ensUsernamesStore . chainId ,
2022-10-17 10:17:25 +00:00
username ,
2023-09-20 16:07:09 +00:00
store . selectedSenderAccount . address ,
2022-10-17 10:17:25 +00:00
path . gasAmount ,
eip1559Enabled ? "" : path . gasFees . gasPrice ,
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "" ,
eip1559Enabled ? maxFeePerGas: path . gasFees . gasPrice ,
eip1559Enabled ,
)
}
2021-07-27 14:04:05 +00:00
}
2022-10-17 10:17:25 +00:00
Connections {
target: root . ensUsernamesStore . ensUsernamesModule
2023-08-15 18:21:51 +00:00
function onTransactionWasSent ( chainId: int , txHash: string , error: string ) {
if ( ! ! error ) {
if ( error . includes ( Constants . walletSection . cancelledMessage ) ) {
2022-10-17 10:17:25 +00:00
return
}
2023-08-15 18:21:51 +00:00
buyEnsModal . sendingError . text = error
2022-10-17 10:17:25 +00:00
return buyEnsModal . sendingError . open ( )
}
2022-12-08 15:56:02 +00:00
usernameRegistered ( username )
2023-08-15 18:21:51 +00:00
let url = "%1/%2" . arg ( buyEnsModal . store . getEtherscanLink ( chainId ) ) . arg ( txHash )
2022-12-08 15:56:02 +00:00
Global . displayToastMessage ( qsTr ( "Transaction pending..." ) ,
qsTr ( "View on etherscan" ) ,
"" ,
true ,
Constants . ephemeralNotificationType . normal ,
url )
2022-10-17 10:17:25 +00:00
}
2020-11-03 10:29:56 +00:00
}
}
2020-08-27 16:06:53 +00:00
}
2021-10-06 09:16:39 +00:00
// TODO: Replace with StatusModal
2020-08-26 21:13:26 +00:00
ModalPopup {
id: popup
2022-04-04 11:26:30 +00:00
title: qsTr ( "Terms of name registration" )
2020-08-26 21:13:26 +00:00
2022-07-13 12:29:38 +00:00
StatusScrollView {
2022-07-20 14:54:30 +00:00
id: scroll
2023-05-31 20:58:23 +00:00
anchors.fill: parent
contentWidth: availableWidth
2020-08-26 21:13:26 +00:00
Column {
spacing: Style . current . halfPadding
2022-07-20 14:54:30 +00:00
width: scroll . availableWidth
2022-02-09 09:43:23 +00:00
2020-08-26 21:13:26 +00:00
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "Funds are deposited for 1 year. Your SNT will be locked, but not spent." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "After 1 year, you can release the name and get your deposit back, or take no action to keep the name." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "If terms of the contract change — e.g. Status makes contract upgrades — user has the right to release the username regardless of time held." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "The contract controller cannot access your deposited funds. They can only be moved back to the address that sent them." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "Your address(es) will be publicly associated with your ENS name." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "Usernames are created as subdomain nodes of stateofus.eth and are subject to the ENS smart contract terms." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "You authorize the contract to transfer SNT on your behalf. This can only occur when you approve a transaction to authorize the transfer." )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "These terms are guaranteed by the smart contract logic at addresses:" )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
font.weight: Font . Bold
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "%1 (Status UsernameRegistrar)." ) . arg ( root . ensUsernamesStore . getEnsRegisteredAddress ( ) )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2022-09-15 15:23:51 +00:00
font.family: Style . current . monoFont . name
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "<a href='%1%2'>Look up on Etherscan</a>" )
2022-01-17 08:56:44 +00:00
. arg ( root . ensUsernamesStore . getEtherscanLink ( ) )
. arg ( root . ensUsernamesStore . getEnsRegisteredAddress ( ) )
2020-08-26 21:13:26 +00:00
anchors.left: parent . left
anchors.right: parent . right
2021-12-06 21:10:54 +00:00
onLinkActivated: Global . openLink ( link )
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
MouseArea {
anchors.fill: parent
acceptedButtons: Qt . NoButton // we don't want to eat clicks on the Text
cursorShape: parent . hoveredLink ? Qt.PointingHandCursor : Qt . ArrowCursor
}
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "%1 (ENS Registry)." ) . arg ( root . ensUsernamesStore . getEnsRegistry ( ) )
2020-08-26 21:13:26 +00:00
wrapMode: Text . WordWrap
anchors.left: parent . left
anchors.right: parent . right
2022-09-15 15:23:51 +00:00
font.family: Style . current . monoFont . name
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "<a href='%1%2'>Look up on Etherscan</a>" )
2022-01-17 08:56:44 +00:00
. arg ( root . ensUsernamesStore . getEtherscanLink ( ) )
. arg ( root . ensUsernamesStore . getEnsRegistry ( ) )
2020-08-26 21:13:26 +00:00
anchors.left: parent . left
anchors.right: parent . right
2021-12-06 21:10:54 +00:00
onLinkActivated: Global . openLink ( link )
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
MouseArea {
anchors.fill: parent
acceptedButtons: Qt . NoButton // we don't want to eat clicks on the Text
cursorShape: parent . hoveredLink ? Qt.PointingHandCursor : Qt . ArrowCursor
}
}
}
}
}
2022-07-13 12:29:38 +00:00
StatusScrollView {
2020-08-04 22:22:51 +00:00
id: sview
anchors.top: sectionTitle . bottom
anchors.topMargin: Style . current . padding
anchors.bottom: startBtn . top
anchors.bottomMargin: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
2023-05-31 20:58:23 +00:00
contentWidth: availableWidth
2020-08-04 22:22:51 +00:00
Item {
id: contentItem
2022-07-20 14:54:30 +00:00
width: sview . availableWidth
2020-08-04 22:22:51 +00:00
2020-08-26 21:13:26 +00:00
Rectangle {
id: circleAt
2020-08-04 22:22:51 +00:00
anchors.top: parent . top
anchors.topMargin: 24
2020-08-26 21:13:26 +00:00
anchors.horizontalCenter: parent . horizontalCenter
width: 60
height: 60
radius: 120
color: Style . current . blue
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-08-26 21:13:26 +00:00
text: "@"
opacity: 0.7
font.weight: Font . Bold
font.pixelSize: 18
color: Style . current . white
anchors.horizontalCenter: parent . horizontalCenter
anchors.verticalCenter: parent . verticalCenter
}
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-08-26 21:13:26 +00:00
id: ensUsername
text: username + ".stateofus.eth"
2020-08-04 22:22:51 +00:00
font.weight: Font . Bold
2020-08-26 21:13:26 +00:00
font.pixelSize: 18
anchors.top: circleAt . bottom
anchors.topMargin: 24
2020-08-04 22:22:51 +00:00
anchors.left: parent . left
anchors.right: parent . right
horizontalAlignment: Text . AlignHCenter
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
}
2021-10-06 09:16:39 +00:00
StatusDescriptionListItem {
2020-08-26 21:13:26 +00:00
id: walletAddressLbl
2022-04-04 11:26:30 +00:00
title: qsTr ( "Wallet address" )
2022-01-17 08:56:44 +00:00
subTitle: root . ensUsernamesStore . getWalletDefaultAddress ( )
2021-10-06 09:16:39 +00:00
tooltip.text: qsTr ( "Copied to clipboard!" )
2022-08-11 11:55:08 +00:00
asset.name: "copy"
2021-10-06 09:16:39 +00:00
iconButton.onClicked: {
2022-01-17 08:56:44 +00:00
root . ensUsernamesStore . copyToClipboard ( subTitle )
2021-10-06 09:16:39 +00:00
tooltip . visible = ! tooltip . visible
}
2020-08-26 21:13:26 +00:00
anchors.top: ensUsername . bottom
anchors.topMargin: 24
}
2021-10-06 09:16:39 +00:00
StatusDescriptionListItem {
2020-08-26 21:13:26 +00:00
id: keyLbl
2022-04-04 11:26:30 +00:00
title: qsTr ( "Key" )
2021-10-06 09:16:39 +00:00
subTitle: {
2022-01-17 08:56:44 +00:00
let pubKey = root . ensUsernamesStore . pubkey ;
2020-08-26 21:13:26 +00:00
return pubKey . substring ( 0 , 20 ) + "..." + pubKey . substring ( pubKey . length - 20 ) ;
}
2021-10-06 09:16:39 +00:00
tooltip.text: qsTr ( "Copied to clipboard!" )
2022-08-11 11:55:08 +00:00
asset.name: "copy"
2021-10-06 09:16:39 +00:00
iconButton.onClicked: {
2022-01-17 08:56:44 +00:00
root . ensUsernamesStore . copyToClipboard ( root . ensUsernamesStore . pubkey )
2021-10-06 09:16:39 +00:00
tooltip . visible = ! tooltip . visible
}
2020-08-26 21:13:26 +00:00
anchors.top: walletAddressLbl . bottom
anchors.topMargin: 24
}
2020-11-27 19:32:49 +00:00
StatusCheckBox {
2020-08-26 21:13:26 +00:00
id: termsAndConditionsCheckbox
2022-08-09 13:52:17 +00:00
objectName: "ensAgreeTerms"
2020-08-26 21:13:26 +00:00
anchors.top: keyLbl . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
anchors.leftMargin: 24
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "Agree to <a href=\"#\">Terms of name registration.</a> I understand that my wallet address will be publicly connected to my username." )
2020-08-26 21:13:26 +00:00
anchors.left: termsAndConditionsCheckbox . right
2022-07-21 16:00:49 +00:00
anchors.leftMargin: Style . current . halfPadding
2020-08-26 21:13:26 +00:00
anchors.right: parent . right
2020-08-04 22:22:51 +00:00
wrapMode: Text . WordWrap
2022-07-21 16:00:49 +00:00
anchors.verticalCenter: termsAndConditionsCheckbox . verticalCenter
2020-08-26 21:13:26 +00:00
onLinkActivated: popup . open ( )
2021-11-01 09:42:00 +00:00
color: Theme . palette . directColor1
2022-07-21 16:00:49 +00:00
TapHandler {
enabled: ! parent . hoveredLink
onSingleTapped: termsAndConditionsCheckbox . toggle ( )
}
2020-08-26 21:13:26 +00:00
MouseArea {
anchors.fill: parent
acceptedButtons: Qt . NoButton // we don't want to eat clicks on the Text
cursorShape: parent . hoveredLink ? Qt.PointingHandCursor : Qt . ArrowCursor
}
2020-08-04 22:22:51 +00:00
}
}
}
2020-09-29 08:51:16 +00:00
StatusButton {
2020-08-26 21:13:26 +00:00
anchors.bottom: parent . bottom
anchors.bottomMargin: Style . current . padding
anchors.left: parent . left
anchors.leftMargin: Style . current . padding
2022-04-04 11:26:30 +00:00
text: qsTr ( "Back" )
2020-08-26 21:13:26 +00:00
onClicked: backBtnClicked ( )
}
Item {
anchors.top: startBtn . top
anchors.right: startBtn . left
anchors.rightMargin: Style . current . padding
width: childrenRect . width
Image {
id: image1
height: 50
2021-07-02 08:55:31 +00:00
width: height
2022-01-17 08:56:44 +00:00
source: Style . png ( "tokens/SNT" )
2021-07-02 08:55:31 +00:00
sourceSize: Qt . size ( width , height )
2023-04-26 15:33:24 +00:00
cache: false
2020-08-26 21:13:26 +00:00
}
2022-02-09 09:43:23 +00:00
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-08-26 21:13:26 +00:00
id: ensPriceLbl
2022-04-04 11:26:30 +00:00
text: qsTr ( "10 SNT" )
2020-08-26 21:13:26 +00:00
anchors.left: image1 . right
anchors.leftMargin: 5
anchors.top: image1 . top
2021-10-06 09:16:39 +00:00
color: Theme . palette . directColor1
2020-08-26 21:13:26 +00:00
font.pixelSize: 14
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2022-04-04 11:26:30 +00:00
text: qsTr ( "Deposit" )
2020-08-26 21:13:26 +00:00
anchors.left: image1 . right
anchors.leftMargin: 5
anchors.topMargin: 5
anchors.top: ensPriceLbl . bottom
2021-11-01 09:42:00 +00:00
color: Theme . palette . baseColor1
2020-08-26 21:13:26 +00:00
font.pixelSize: 14
}
}
2020-09-29 08:51:16 +00:00
StatusButton {
2020-08-04 22:22:51 +00:00
id: startBtn
2022-08-09 13:52:17 +00:00
objectName: "ensStartTransaction"
2020-08-04 22:22:51 +00:00
anchors.bottom: parent . bottom
anchors.bottomMargin: Style . current . padding
2020-08-26 21:13:26 +00:00
anchors.right: parent . right
anchors.rightMargin: Style . current . padding
2022-01-17 08:56:44 +00:00
text: parseFloat ( root . ensUsernamesStore . getSntBalance ( ) ) < 10 ?
2022-04-04 11:26:30 +00:00
qsTr ( "Not enough SNT" ) :
qsTr ( "Register" )
2022-01-17 08:56:44 +00:00
enabled: parseFloat ( root . ensUsernamesStore . getSntBalance ( ) ) >= 10 && termsAndConditionsCheckbox . checked
2022-04-21 10:50:01 +00:00
onClicked: transactionDialog . open ( )
2020-08-04 22:22:51 +00:00
}
2020-09-14 12:12:47 +00:00
}