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 =
|
||||
try:
|
||||
let response = status_general.validateMnemonic(mnemonic)
|
||||
|
||||
var error = "response doesn't contain \"error\""
|
||||
if(response.result.contains("error")):
|
||||
error = response.result["error"].getStr
|
||||
|
||||
# An empty error means that mnemonic is valid.
|
||||
return error
|
||||
|
||||
if response.result.contains("error"):
|
||||
return response.result["error"].getStr
|
||||
return ""
|
||||
except Exception as e:
|
||||
error "error: ", procName="validateMnemonic", errName = e.name, errDesription = e.msg
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import "./states"
|
|||
StatusModal {
|
||||
id: root
|
||||
|
||||
property AddAccountStore store
|
||||
property AddAccountStore store: AddAccountStore { }
|
||||
|
||||
width: Constants.addAccountPopup.popupWidth
|
||||
height: {
|
||||
|
|
|
@ -25,7 +25,7 @@ Column {
|
|||
maximumHeight: Constants.addAccountPopup.itemHeight
|
||||
minimumHeight: Constants.addAccountPopup.itemHeight
|
||||
label: qsTr("Ethereum address or ENS name")
|
||||
placeholderText: "e.g.0x95222293DD7278Aa3Cdd389Cc1D1d165CCBAfe5"
|
||||
placeholderText: "0x95222293DD7278Aa3Cdd389Cc1D1d165CCBAfe5"
|
||||
input.multiline: true
|
||||
input.rightComponent: StatusButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
|
@ -48,6 +48,20 @@ Item {
|
|||
}
|
||||
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 {
|
||||
|
@ -93,14 +107,18 @@ Item {
|
|||
input.asset.color: root.store.addAccountModule.selectedColor
|
||||
input.asset.emoji: root.store.addAccountModule.selectedEmoji
|
||||
onIconClicked: {
|
||||
if (!root.store.emojiPopup) {
|
||||
return
|
||||
d.openEmojiPopup(true)
|
||||
}
|
||||
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: {
|
||||
|
|
|
@ -4,23 +4,23 @@ import utils 1.0
|
|||
QtObject {
|
||||
id: root
|
||||
|
||||
property var addAccountModule
|
||||
required property var addAccountModule
|
||||
required property var emojiPopup
|
||||
|
||||
property var emojiPopup: null
|
||||
property string userProfilePublicKey: userProfile.pubKey
|
||||
property string userProfileKeyUid: userProfile.keyUid
|
||||
property bool userProfileIsKeycardUser: userProfile.isKeycardUser
|
||||
property bool userProfileUsingBiometricLogin: userProfile.usingBiometricLogin
|
||||
|
||||
// Module Properties
|
||||
property var currentState: root.addAccountModule? root.addAccountModule.currentState : null
|
||||
property var originModel: root.addAccountModule? root.addAccountModule.originModel : []
|
||||
property var selectedOrigin: root.addAccountModule? root.addAccountModule.selectedOrigin : null
|
||||
property var derivedAddressModel: root.addAccountModule? root.addAccountModule.derivedAddressModel : []
|
||||
property var selectedDerivedAddress: root.addAccountModule? root.addAccountModule.selectedDerivedAddress : null
|
||||
property var watchOnlyAccAddress: root.addAccountModule? root.addAccountModule.watchOnlyAccAddress : null
|
||||
property var privateKeyAccAddress: root.addAccountModule? root.addAccountModule.privateKeyAccAddress : null
|
||||
property bool disablePopup: root.addAccountModule? root.addAccountModule.disablePopup : false
|
||||
property var currentState: root.addAccountModule.currentState
|
||||
property var originModel: root.addAccountModule.originModel
|
||||
property var selectedOrigin: root.addAccountModule.selectedOrigin
|
||||
property var derivedAddressModel: root.addAccountModule.derivedAddressModel
|
||||
property var selectedDerivedAddress: root.addAccountModule.selectedDerivedAddress
|
||||
property var watchOnlyAccAddress: root.addAccountModule.watchOnlyAccAddress
|
||||
property var privateKeyAccAddress: root.addAccountModule.privateKeyAccAddress
|
||||
property bool disablePopup: root.addAccountModule.disablePopup
|
||||
|
||||
property bool enteredSeedPhraseIsValid: false
|
||||
property bool enteredPrivateKeyIsValid: false
|
||||
|
@ -64,16 +64,8 @@ QtObject {
|
|||
root.cleanSeedPhrase()
|
||||
}
|
||||
|
||||
function moduleInitialized() {
|
||||
if (!root.addAccountModule) {
|
||||
console.warn("addAccountModule not initialized")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function submitAddAccount(event) {
|
||||
if (!root.moduleInitialized() || !root.primaryPopupButtonEnabled) {
|
||||
if (!root.primaryPopupButtonEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -87,118 +79,70 @@ QtObject {
|
|||
}
|
||||
|
||||
function getSeedPhrase() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
return root.addAccountModule.getSeedPhrase()
|
||||
}
|
||||
|
||||
function changeSelectedOrigin(keyUid) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeSelectedOrigin(keyUid)
|
||||
}
|
||||
|
||||
readonly property var changeDerivationPathPostponed: Backpressure.debounce(root, 400, function (path) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.changeDerivationPath(path)
|
||||
})
|
||||
|
||||
readonly property var changeWatchOnlyAccountAddressPostponed: Backpressure.debounce(root, 400, function (address) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeWatchOnlyAccountAddress(address)
|
||||
})
|
||||
|
||||
function cleanWatchOnlyAccountAddress() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeWatchOnlyAccountAddress("")
|
||||
}
|
||||
|
||||
readonly property var changePrivateKeyPostponed: Backpressure.debounce(root, 400, function (privateKey) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changePrivateKey(privateKey)
|
||||
})
|
||||
|
||||
function cleanPrivateKey() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.enteredPrivateKeyIsValid = false
|
||||
root.addAccountModule.newKeyPairName = ""
|
||||
root.addAccountModule.changePrivateKey("")
|
||||
}
|
||||
|
||||
function changeDerivationPath(path) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeDerivationPath(path)
|
||||
}
|
||||
|
||||
function changeRootDerivationPath(rootPath) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.selectedRootPath = rootPath
|
||||
root.addAccountModule.derivationPath = "%1/".arg(rootPath)
|
||||
}
|
||||
|
||||
function changeSelectedDerivedAddress(address) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeSelectedDerivedAddress(address)
|
||||
}
|
||||
|
||||
function resetDerivationPath() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.selectedRootPath = Constants.addAccountPopup.predefinedPaths.ethereum
|
||||
root.addAccountModule.resetDerivationPath()
|
||||
}
|
||||
|
||||
function authenticateForEditingDerivationPath() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.authenticateForEditingDerivationPath()
|
||||
}
|
||||
|
||||
function startScanningForActivity() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.startScanningForActivity()
|
||||
}
|
||||
|
||||
function validSeedPhrase(seedPhrase) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
return root.addAccountModule.validSeedPhrase(seedPhrase)
|
||||
}
|
||||
|
||||
function changeSeedPhrase(seedPhrase) {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.addAccountModule.changeSeedPhrase(seedPhrase)
|
||||
}
|
||||
|
||||
function cleanSeedPhrase() {
|
||||
if (!root.moduleInitialized()) {
|
||||
return
|
||||
}
|
||||
root.enteredSeedPhraseIsValid = false
|
||||
root.addAccountModule.newKeyPairName = ""
|
||||
root.changeSeedPhrase("")
|
||||
|
|
|
@ -189,9 +189,6 @@ QtObject {
|
|||
globalUtils.copyToClipboard(text)
|
||||
}
|
||||
|
||||
property AddAccountStore addAccountStore: AddAccountStore {
|
||||
}
|
||||
|
||||
function runAddAccountPopup() {
|
||||
walletSection.runAddAccountPopup()
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ Rectangle {
|
|||
asynchronous: true
|
||||
|
||||
sourceComponent: AddAccountPopup {
|
||||
store: RootStore.addAccountStore
|
||||
store.emojiPopup: root.emojiPopup
|
||||
store.addAccountModule: walletSection.addAccountModule
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
|
@ -54,8 +55,6 @@ Rectangle {
|
|||
target: walletSection
|
||||
|
||||
function onDisplayAddAccountPopup() {
|
||||
RootStore.addAccountStore.emojiPopup = root.emojiPopup
|
||||
RootStore.addAccountStore.addAccountModule = walletSection.addAccountModule
|
||||
addAccount.active = true
|
||||
}
|
||||
function onDestroyAddAccountPopup() {
|
||||
|
|
Loading…
Reference in New Issue