2020-08-03 20:46:37 +00:00
|
|
|
import QtQuick 2.14
|
2020-05-27 21:28:25 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
2020-08-03 20:46:37 +00:00
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQml.StateMachine 1.14 as DSM
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-06-19 18:06:58 +00:00
|
|
|
import "../../../../shared"
|
2021-10-06 09:16:39 +00:00
|
|
|
/* import "./Ens" */
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
import "."
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
id: root
|
|
|
|
|
2020-05-27 21:28:25 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
2021-04-08 15:44:58 +00:00
|
|
|
clip: true
|
2020-05-27 21:28:25 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
property var store
|
|
|
|
|
2020-08-03 20:46:37 +00:00
|
|
|
property bool showSearchScreen: false
|
2020-08-04 22:22:51 +00:00
|
|
|
property string addedUsername: ""
|
2020-08-06 19:45:57 +00:00
|
|
|
property string selectedUsername: ""
|
2020-08-03 20:46:37 +00:00
|
|
|
|
2020-08-04 22:22:51 +00:00
|
|
|
signal next(output: string)
|
2020-08-06 19:45:57 +00:00
|
|
|
signal back()
|
2020-08-27 16:06:53 +00:00
|
|
|
signal done(ensUsername: string)
|
2020-08-04 22:22:51 +00:00
|
|
|
signal connect(ensUsername: string)
|
2020-08-27 20:18:14 +00:00
|
|
|
signal changePubKey(ensUsername: string)
|
|
|
|
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
|
|
signal goToWelcome();
|
|
|
|
signal goToList();
|
|
|
|
|
2021-08-09 15:23:44 +00:00
|
|
|
function goToStart(){
|
2021-10-06 09:16:39 +00:00
|
|
|
if(root.store.ens.rowCount() > 0 && networkGuarded){
|
2020-08-04 22:22:51 +00:00
|
|
|
goToList();
|
|
|
|
} else {
|
|
|
|
goToWelcome();
|
|
|
|
}
|
|
|
|
}
|
2020-08-03 20:46:37 +00:00
|
|
|
|
|
|
|
DSM.StateMachine {
|
|
|
|
id: stateMachine
|
|
|
|
initialState: welcomeState
|
|
|
|
running: true
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: welcomeState
|
|
|
|
onEntered: loader.sourceComponent = welcome
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: searchState
|
|
|
|
signal: next
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
2020-08-03 20:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: searchState
|
|
|
|
onEntered: loader.sourceComponent = search
|
2020-08-04 22:22:51 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: tAndCState
|
|
|
|
signal: next
|
|
|
|
guard: output === "available"
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: addedState
|
|
|
|
signal: connect
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeState
|
|
|
|
signal: goToWelcome
|
|
|
|
}
|
2020-08-27 20:18:14 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: ensConnectedState
|
|
|
|
signal: done
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: addedState
|
|
|
|
onEntered: {
|
|
|
|
loader.sourceComponent = added;
|
|
|
|
loader.item.ensUsername = addedUsername;
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: next
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeState
|
|
|
|
signal: goToWelcome
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: listState
|
|
|
|
onEntered: {
|
|
|
|
loader.sourceComponent = list;
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: searchState
|
|
|
|
signal: next
|
2020-08-06 19:45:57 +00:00
|
|
|
guard: output === "search"
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: detailsState
|
|
|
|
signal: next
|
|
|
|
guard: output === "details"
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeState
|
|
|
|
signal: goToWelcome
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: detailsState
|
|
|
|
onEntered: {
|
|
|
|
loader.sourceComponent = details;
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: back
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeState
|
|
|
|
signal: goToWelcome
|
|
|
|
}
|
2021-08-09 22:23:52 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: ensReleasedState
|
|
|
|
signal: done
|
|
|
|
}
|
2020-08-03 20:46:37 +00:00
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: tAndCState
|
|
|
|
onEntered:loader.sourceComponent = termsAndConditions
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: goToList
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: welcomeState
|
|
|
|
signal: goToWelcome
|
|
|
|
}
|
2020-08-26 21:13:26 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: back
|
|
|
|
}
|
2020-08-27 16:06:53 +00:00
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: back
|
|
|
|
}
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: ensRegisteredState
|
|
|
|
signal: done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DSM.State {
|
|
|
|
id: ensRegisteredState
|
|
|
|
onEntered:loader.sourceComponent = ensRegistered
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: next
|
|
|
|
}
|
2020-08-03 20:46:37 +00:00
|
|
|
}
|
2020-08-27 20:18:14 +00:00
|
|
|
|
2021-08-09 22:23:52 +00:00
|
|
|
DSM.State {
|
|
|
|
id: ensReleasedState
|
|
|
|
onEntered:loader.sourceComponent = ensReleased
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 20:18:14 +00:00
|
|
|
DSM.State {
|
|
|
|
id: ensConnectedState
|
|
|
|
onEntered:loader.sourceComponent = ensConnected
|
|
|
|
DSM.SignalTransition {
|
|
|
|
targetState: listState
|
|
|
|
signal: next
|
|
|
|
}
|
|
|
|
}
|
2020-08-03 20:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: welcome
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsWelcomeView {
|
|
|
|
username: root.store.username
|
2020-08-07 16:27:41 +00:00
|
|
|
onStartBtnClicked: next(null)
|
2020-08-03 20:46:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: search
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsSearchView {
|
|
|
|
store: root.store
|
2020-08-07 16:27:41 +00:00
|
|
|
onContinueClicked: {
|
2020-08-04 22:22:51 +00:00
|
|
|
if(output === "connected"){
|
|
|
|
connect(username)
|
|
|
|
} else {
|
2020-08-26 21:13:26 +00:00
|
|
|
selectedUsername = username;
|
2020-08-04 22:22:51 +00:00
|
|
|
next(output);
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 20:18:14 +00:00
|
|
|
onUsernameUpdated: {
|
|
|
|
selectedUsername = username;
|
|
|
|
done(username);
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: termsAndConditions
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsTermsAndConditionsView {
|
|
|
|
store: root.store
|
2020-08-26 21:13:26 +00:00
|
|
|
username: selectedUsername
|
|
|
|
onBackBtnClicked: back();
|
2020-08-27 16:06:53 +00:00
|
|
|
onUsernameRegistered: done(userName);
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: added
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsAddedView {
|
2020-08-07 16:27:41 +00:00
|
|
|
onOkBtnClicked: next(null)
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 16:06:53 +00:00
|
|
|
Component {
|
|
|
|
id: ensRegistered
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsRegisteredView {
|
2020-08-27 16:06:53 +00:00
|
|
|
ensUsername: selectedUsername
|
|
|
|
onOkBtnClicked: next(null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-09 22:23:52 +00:00
|
|
|
Component {
|
|
|
|
id: ensReleased
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsReleasedView {
|
2021-08-09 22:23:52 +00:00
|
|
|
ensUsername: selectedUsername
|
|
|
|
onOkBtnClicked: next(null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 20:18:14 +00:00
|
|
|
Component {
|
|
|
|
id: ensConnected
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsConnectedView {
|
2020-08-27 20:18:14 +00:00
|
|
|
ensUsername: selectedUsername
|
|
|
|
onOkBtnClicked: next(null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 22:22:51 +00:00
|
|
|
Component {
|
|
|
|
id: list
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsListView {
|
|
|
|
store: root.store
|
2020-08-07 16:27:41 +00:00
|
|
|
onAddBtnClicked: next("search")
|
|
|
|
onSelectEns: {
|
2021-10-06 09:16:39 +00:00
|
|
|
root.store.ensDetails(username)
|
2020-08-06 19:45:57 +00:00
|
|
|
selectedUsername = username;
|
|
|
|
next("details")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: details
|
2021-10-06 09:16:39 +00:00
|
|
|
EnsDetailsView {
|
|
|
|
store: root.store
|
2020-08-06 19:45:57 +00:00
|
|
|
username: selectedUsername
|
2020-08-07 16:27:41 +00:00
|
|
|
onBackBtnClicked: back();
|
2021-08-09 22:23:52 +00:00
|
|
|
onUsernameReleased: {
|
|
|
|
selectedUsername = username;
|
|
|
|
done(username);
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2021-10-06 09:16:39 +00:00
|
|
|
target: root
|
2020-08-04 22:22:51 +00:00
|
|
|
onConnect: {
|
|
|
|
addedUsername = ensUsername;
|
|
|
|
}
|
2020-05-27 21:28:25 +00:00
|
|
|
}
|
2020-09-14 17:38:23 +00:00
|
|
|
|
|
|
|
Connections {
|
2021-10-06 09:16:39 +00:00
|
|
|
target: root.store.ens
|
2020-09-14 17:38:23 +00:00
|
|
|
onTransactionWasSent: {
|
2020-09-18 06:33:20 +00:00
|
|
|
//% "Transaction pending..."
|
|
|
|
toastMessage.title = qsTrId("ens-transaction-pending")
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("loading")
|
2020-09-14 17:38:23 +00:00
|
|
|
toastMessage.iconColor = Style.current.primary
|
|
|
|
toastMessage.iconRotates = true
|
2021-10-06 09:16:39 +00:00
|
|
|
toastMessage.link = `${root.store.etherscanLink}/${txResult}`
|
2020-09-14 17:38:23 +00:00
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
onTransactionCompleted: {
|
|
|
|
switch(trxType){
|
|
|
|
case "RegisterENS":
|
2020-09-14 19:41:09 +00:00
|
|
|
toastMessage.title = !success ?
|
2020-09-18 06:33:20 +00:00
|
|
|
//% "ENS Registration failed"
|
|
|
|
qsTrId("ens-registration-failed")
|
2020-09-14 19:41:09 +00:00
|
|
|
:
|
2020-09-18 06:33:20 +00:00
|
|
|
//% "ENS Registration completed"
|
|
|
|
qsTrId("ens-registration-completed");
|
2020-09-14 17:38:23 +00:00
|
|
|
break;
|
|
|
|
case "SetPubKey":
|
2020-09-14 19:41:09 +00:00
|
|
|
toastMessage.title = !success ?
|
2020-09-18 06:33:20 +00:00
|
|
|
//% "Updating ENS pubkey failed"
|
|
|
|
qsTrId("updating-ens-pubkey-failed")
|
2020-09-14 19:41:09 +00:00
|
|
|
:
|
2020-09-18 06:33:20 +00:00
|
|
|
//% "Updating ENS pubkey completed"
|
|
|
|
qsTrId("updating-ens-pubkey-completed");
|
2020-09-14 17:38:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("check-circle")
|
2020-09-14 17:38:23 +00:00
|
|
|
toastMessage.iconColor = Style.current.success
|
|
|
|
} else {
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("block-icon")
|
2020-09-14 17:38:23 +00:00
|
|
|
toastMessage.iconColor = Style.current.danger
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
toastMessage.link = `${root.store.etherscanLink}/${txHash}`
|
2020-09-14 17:38:23 +00:00
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:28:25 +00:00
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|