import QtQuick 2.14 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.14 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 import StatusQ.Controls 0.1 as StatusQControls import StatusQ.Components 0.1 import utils 1.0 import shared 1.0 import shared.panels 1.0 import shared.status 1.0 import shared.controls 1.0 import shared.popups 1.0 Item { id: root property var ensUsernamesStore property var contactsStore property int profileContentWidth signal continueClicked(string output, string username) signal usernameUpdated(username: string); property string validationMessage: "" property bool valid: false property bool isStatus: true property bool loading: false property string ensStatus: "" property var validateENS: Backpressure.debounce(root, 500, function (ensName, isStatus){ root.ensUsernamesStore.checkEnsUsernameAvailability(ensName, isStatus) }); function validate(ensUsername) { validationMessage = ""; valid = false; ensStatus = ""; if (ensUsername.length < 4) { validationMessage = qsTr("At least 4 characters. Latin letters, numbers, and lowercase only."); } else if(isStatus && !ensUsername.match(/^[a-z0-9]+$/)){ validationMessage = qsTr("Letters and numbers only."); } else if(!isStatus && !ensUsername.endsWith(".eth")){ validationMessage = qsTr("Type the entire username including the custom domain like username.domain.eth") } return validationMessage === ""; } function onKeyReleased(ensUsername){ if (!validate(ensUsername)) { return; } loading = true; Qt.callLater(validateENS, ensUsername, isStatus) } Component { id: transactionDialogComponent SendModal { id: connectEnsModal modalHeader: qsTr("Connect username with your pubkey") interactive: false sendType: Constants.SendType.ENSSetPubKey preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) preSelectedAsset: { let assetsList = connectEnsModal.store.currentAccount.assets for(var i=0; i< assetsList.count;i++) { if("ETH" === assetsList.rowData(i, "symbol")) return { name: assetsList.rowData(i, "name"), symbol: assetsList.rowData(i, "symbol"), totalBalance: assetsList.rowData(i, "totalBalance"), totalCurrencyBalance: assetsList.rowData(i, "totalCurrencyBalance"), balances: assetsList.rowData(i, "balances"), decimals: assetsList.rowData(i, "decimals") } } return {} } sendTransaction: function() { if(bestRoutes.length === 1) { let path = bestRoutes[0] let eip1559Enabled = path.gasFees.eip1559Enabled root.ensUsernamesStore.authenticateAndSetPubKey( root.ensUsernamesStore.chainId, ensUsername.text + (isStatus ? ".stateofus.eth" : "" ), selectedAccount.address, path.gasAmount, eip1559Enabled ? "" : path.gasFees.gasPrice, "", "", eip1559Enabled, ) } } Connections { target: root.ensUsernamesStore.ensUsernamesModule function onTransactionWasSent(txResult: string) { try { let response = JSON.parse(txResult) if (!response.success) { if (response.result.includes(Constants.walletSection.cancelledMessage)) { return } connectEnsModal.sendingError.text = response.result return connectEnsModal.sendingError.open() } for(var i=0; i