chore(@desktop/wallet): add account modal - improvements
- `AddAccountStore` moved to `AddAccountPopup` - watch only address' placeholder text updated - emoji popup button added to the right side of the account name input field - `validateMnemonic` proc from accounts service updated
This commit is contained in:
parent
51058d9065
commit
5479880cde
|
@ -124,14 +124,9 @@ QtObject:
|
||||||
proc validateMnemonic*(self: Service, mnemonic: string): string =
|
proc validateMnemonic*(self: Service, mnemonic: string): string =
|
||||||
try:
|
try:
|
||||||
let response = status_general.validateMnemonic(mnemonic)
|
let response = status_general.validateMnemonic(mnemonic)
|
||||||
|
if response.result.contains("error"):
|
||||||
var error = "response doesn't contain \"error\""
|
return response.result["error"].getStr
|
||||||
if(response.result.contains("error")):
|
return ""
|
||||||
error = response.result["error"].getStr
|
|
||||||
|
|
||||||
# An empty error means that mnemonic is valid.
|
|
||||||
return error
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="validateMnemonic", errName = e.name, errDesription = e.msg
|
error "error: ", procName="validateMnemonic", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import "./states"
|
||||||
StatusModal {
|
StatusModal {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property AddAccountStore store
|
property AddAccountStore store: AddAccountStore { }
|
||||||
|
|
||||||
width: Constants.addAccountPopup.popupWidth
|
width: Constants.addAccountPopup.popupWidth
|
||||||
height: {
|
height: {
|
||||||
|
|
|
@ -25,7 +25,7 @@ Column {
|
||||||
maximumHeight: Constants.addAccountPopup.itemHeight
|
maximumHeight: Constants.addAccountPopup.itemHeight
|
||||||
minimumHeight: Constants.addAccountPopup.itemHeight
|
minimumHeight: Constants.addAccountPopup.itemHeight
|
||||||
label: qsTr("Ethereum address or ENS name")
|
label: qsTr("Ethereum address or ENS name")
|
||||||
placeholderText: "e.g.0x95222293DD7278Aa3Cdd389Cc1D1d165CCBAfe5"
|
placeholderText: "0x95222293DD7278Aa3Cdd389Cc1D1d165CCBAfe5"
|
||||||
input.multiline: true
|
input.multiline: true
|
||||||
input.rightComponent: StatusButton {
|
input.rightComponent: StatusButton {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
|
@ -48,6 +48,20 @@ Item {
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openEmojiPopup(showLeft) {
|
||||||
|
if (!root.store.emojiPopup) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let inputCoords = accountName.mapToItem(appMain, 0, 0)
|
||||||
|
root.store.emojiPopup.open()
|
||||||
|
root.store.emojiPopup.emojiSize = StatusQUtils.Emoji.size.verySmall
|
||||||
|
root.store.emojiPopup.x = inputCoords.x
|
||||||
|
if (!showLeft) {
|
||||||
|
root.store.emojiPopup.x += accountName.width - root.store.emojiPopup.width
|
||||||
|
}
|
||||||
|
root.store.emojiPopup.y = inputCoords.y + accountName.height + Style.current.halfPadding
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
@ -93,14 +107,18 @@ Item {
|
||||||
input.asset.color: root.store.addAccountModule.selectedColor
|
input.asset.color: root.store.addAccountModule.selectedColor
|
||||||
input.asset.emoji: root.store.addAccountModule.selectedEmoji
|
input.asset.emoji: root.store.addAccountModule.selectedEmoji
|
||||||
onIconClicked: {
|
onIconClicked: {
|
||||||
if (!root.store.emojiPopup) {
|
d.openEmojiPopup(true)
|
||||||
return
|
}
|
||||||
|
input.rightComponent: StatusFlatRoundButton {
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
radius: 30
|
||||||
|
icon.name: "emojis"
|
||||||
|
icon.width: 24
|
||||||
|
icon.height: 24
|
||||||
|
onClicked: {
|
||||||
|
d.openEmojiPopup(false)
|
||||||
}
|
}
|
||||||
let inputCoords = accountName.mapToItem(appMain, 0, 0)
|
|
||||||
root.store.emojiPopup.open()
|
|
||||||
root.store.emojiPopup.emojiSize = StatusQUtils.Emoji.size.verySmall
|
|
||||||
root.store.emojiPopup.x = inputCoords.x
|
|
||||||
root.store.emojiPopup.y = inputCoords.y + accountName.height + Style.current.halfPadding
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
|
|
@ -4,23 +4,23 @@ import utils 1.0
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var addAccountModule
|
required property var addAccountModule
|
||||||
|
required property var emojiPopup
|
||||||
|
|
||||||
property var emojiPopup: null
|
|
||||||
property string userProfilePublicKey: userProfile.pubKey
|
property string userProfilePublicKey: userProfile.pubKey
|
||||||
property string userProfileKeyUid: userProfile.keyUid
|
property string userProfileKeyUid: userProfile.keyUid
|
||||||
property bool userProfileIsKeycardUser: userProfile.isKeycardUser
|
property bool userProfileIsKeycardUser: userProfile.isKeycardUser
|
||||||
property bool userProfileUsingBiometricLogin: userProfile.usingBiometricLogin
|
property bool userProfileUsingBiometricLogin: userProfile.usingBiometricLogin
|
||||||
|
|
||||||
// Module Properties
|
// Module Properties
|
||||||
property var currentState: root.addAccountModule? root.addAccountModule.currentState : null
|
property var currentState: root.addAccountModule.currentState
|
||||||
property var originModel: root.addAccountModule? root.addAccountModule.originModel : []
|
property var originModel: root.addAccountModule.originModel
|
||||||
property var selectedOrigin: root.addAccountModule? root.addAccountModule.selectedOrigin : null
|
property var selectedOrigin: root.addAccountModule.selectedOrigin
|
||||||
property var derivedAddressModel: root.addAccountModule? root.addAccountModule.derivedAddressModel : []
|
property var derivedAddressModel: root.addAccountModule.derivedAddressModel
|
||||||
property var selectedDerivedAddress: root.addAccountModule? root.addAccountModule.selectedDerivedAddress : null
|
property var selectedDerivedAddress: root.addAccountModule.selectedDerivedAddress
|
||||||
property var watchOnlyAccAddress: root.addAccountModule? root.addAccountModule.watchOnlyAccAddress : null
|
property var watchOnlyAccAddress: root.addAccountModule.watchOnlyAccAddress
|
||||||
property var privateKeyAccAddress: root.addAccountModule? root.addAccountModule.privateKeyAccAddress : null
|
property var privateKeyAccAddress: root.addAccountModule.privateKeyAccAddress
|
||||||
property bool disablePopup: root.addAccountModule? root.addAccountModule.disablePopup : false
|
property bool disablePopup: root.addAccountModule.disablePopup
|
||||||
|
|
||||||
property bool enteredSeedPhraseIsValid: false
|
property bool enteredSeedPhraseIsValid: false
|
||||||
property bool enteredPrivateKeyIsValid: false
|
property bool enteredPrivateKeyIsValid: false
|
||||||
|
@ -64,16 +64,8 @@ QtObject {
|
||||||
root.cleanSeedPhrase()
|
root.cleanSeedPhrase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function moduleInitialized() {
|
|
||||||
if (!root.addAccountModule) {
|
|
||||||
console.warn("addAccountModule not initialized")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitAddAccount(event) {
|
function submitAddAccount(event) {
|
||||||
if (!root.moduleInitialized() || !root.primaryPopupButtonEnabled) {
|
if (!root.primaryPopupButtonEnabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,118 +79,70 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSeedPhrase() {
|
function getSeedPhrase() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return root.addAccountModule.getSeedPhrase()
|
return root.addAccountModule.getSeedPhrase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSelectedOrigin(keyUid) {
|
function changeSelectedOrigin(keyUid) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeSelectedOrigin(keyUid)
|
root.addAccountModule.changeSelectedOrigin(keyUid)
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var changeDerivationPathPostponed: Backpressure.debounce(root, 400, function (path) {
|
readonly property var changeDerivationPathPostponed: Backpressure.debounce(root, 400, function (path) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.changeDerivationPath(path)
|
root.changeDerivationPath(path)
|
||||||
})
|
})
|
||||||
|
|
||||||
readonly property var changeWatchOnlyAccountAddressPostponed: Backpressure.debounce(root, 400, function (address) {
|
readonly property var changeWatchOnlyAccountAddressPostponed: Backpressure.debounce(root, 400, function (address) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeWatchOnlyAccountAddress(address)
|
root.addAccountModule.changeWatchOnlyAccountAddress(address)
|
||||||
})
|
})
|
||||||
|
|
||||||
function cleanWatchOnlyAccountAddress() {
|
function cleanWatchOnlyAccountAddress() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeWatchOnlyAccountAddress("")
|
root.addAccountModule.changeWatchOnlyAccountAddress("")
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var changePrivateKeyPostponed: Backpressure.debounce(root, 400, function (privateKey) {
|
readonly property var changePrivateKeyPostponed: Backpressure.debounce(root, 400, function (privateKey) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changePrivateKey(privateKey)
|
root.addAccountModule.changePrivateKey(privateKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
function cleanPrivateKey() {
|
function cleanPrivateKey() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.enteredPrivateKeyIsValid = false
|
root.enteredPrivateKeyIsValid = false
|
||||||
root.addAccountModule.newKeyPairName = ""
|
root.addAccountModule.newKeyPairName = ""
|
||||||
root.addAccountModule.changePrivateKey("")
|
root.addAccountModule.changePrivateKey("")
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDerivationPath(path) {
|
function changeDerivationPath(path) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeDerivationPath(path)
|
root.addAccountModule.changeDerivationPath(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeRootDerivationPath(rootPath) {
|
function changeRootDerivationPath(rootPath) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.selectedRootPath = rootPath
|
root.selectedRootPath = rootPath
|
||||||
root.addAccountModule.derivationPath = "%1/".arg(rootPath)
|
root.addAccountModule.derivationPath = "%1/".arg(rootPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSelectedDerivedAddress(address) {
|
function changeSelectedDerivedAddress(address) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeSelectedDerivedAddress(address)
|
root.addAccountModule.changeSelectedDerivedAddress(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetDerivationPath() {
|
function resetDerivationPath() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.selectedRootPath = Constants.addAccountPopup.predefinedPaths.ethereum
|
root.selectedRootPath = Constants.addAccountPopup.predefinedPaths.ethereum
|
||||||
root.addAccountModule.resetDerivationPath()
|
root.addAccountModule.resetDerivationPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
function authenticateForEditingDerivationPath() {
|
function authenticateForEditingDerivationPath() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.authenticateForEditingDerivationPath()
|
root.addAccountModule.authenticateForEditingDerivationPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
function startScanningForActivity() {
|
function startScanningForActivity() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.startScanningForActivity()
|
root.addAccountModule.startScanningForActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
function validSeedPhrase(seedPhrase) {
|
function validSeedPhrase(seedPhrase) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return root.addAccountModule.validSeedPhrase(seedPhrase)
|
return root.addAccountModule.validSeedPhrase(seedPhrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSeedPhrase(seedPhrase) {
|
function changeSeedPhrase(seedPhrase) {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.addAccountModule.changeSeedPhrase(seedPhrase)
|
root.addAccountModule.changeSeedPhrase(seedPhrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanSeedPhrase() {
|
function cleanSeedPhrase() {
|
||||||
if (!root.moduleInitialized()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
root.enteredSeedPhraseIsValid = false
|
root.enteredSeedPhraseIsValid = false
|
||||||
root.addAccountModule.newKeyPairName = ""
|
root.addAccountModule.newKeyPairName = ""
|
||||||
root.changeSeedPhrase("")
|
root.changeSeedPhrase("")
|
||||||
|
|
|
@ -189,9 +189,6 @@ QtObject {
|
||||||
globalUtils.copyToClipboard(text)
|
globalUtils.copyToClipboard(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
property AddAccountStore addAccountStore: AddAccountStore {
|
|
||||||
}
|
|
||||||
|
|
||||||
function runAddAccountPopup() {
|
function runAddAccountPopup() {
|
||||||
walletSection.runAddAccountPopup()
|
walletSection.runAddAccountPopup()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ Rectangle {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
|
||||||
sourceComponent: AddAccountPopup {
|
sourceComponent: AddAccountPopup {
|
||||||
store: RootStore.addAccountStore
|
store.emojiPopup: root.emojiPopup
|
||||||
|
store.addAccountModule: walletSection.addAccountModule
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +55,6 @@ Rectangle {
|
||||||
target: walletSection
|
target: walletSection
|
||||||
|
|
||||||
function onDisplayAddAccountPopup() {
|
function onDisplayAddAccountPopup() {
|
||||||
RootStore.addAccountStore.emojiPopup = root.emojiPopup
|
|
||||||
RootStore.addAccountStore.addAccountModule = walletSection.addAccountModule
|
|
||||||
addAccount.active = true
|
addAccount.active = true
|
||||||
}
|
}
|
||||||
function onDestroyAddAccountPopup() {
|
function onDestroyAddAccountPopup() {
|
||||||
|
|
Loading…
Reference in New Issue