feat(desktop/wallet): Adding Setttings tab in wallet 2

Added nim api's to get the account signing phrase

fixes #3303
This commit is contained in:
Khushboo Mehta 2021-08-31 14:06:13 +02:00 committed by Iuri Matias
parent 7013a677ac
commit 35e15f7ed0
6 changed files with 238 additions and 2 deletions

View File

@ -48,6 +48,9 @@ proc init*(self: WalletController) =
var data = WalletSignal(e)
debug "TODO: handle wallet signal", signalType=data.eventType
self.view.setSigningPhrase(self.status.settings.getSetting[:string](Setting.SigningPhrase))
self.view.setEtherscanLink(self.status.settings.getCurrentNetworkDetails().etherscanLink)
self.status.events.on("cryptoServicesFetched") do(e: Args):
var args = CryptoServicesArg(e)
self.view.onCryptoServicesFetched(args.services)

View File

@ -2,7 +2,7 @@ import atomics, strformat, strutils, sequtils, json, std/wrapnils, parseUtils, t
import NimQml, chronicles, stint
import status/[status, wallet2]
import views/[accounts, account_list, collectibles]
import views/[accounts, account_list, collectibles, settings]
import views/buy_sell_crypto/[service_controller]
import ../../../app_service/[main]
@ -13,6 +13,7 @@ QtObject:
appService: AppService
accountsView: AccountsView
collectiblesView: CollectiblesView
settingsView*: SettingsView
cryptoServiceController: CryptoServiceController
proc delete(self: WalletView) =
@ -20,6 +21,7 @@ QtObject:
self.collectiblesView.delete
self.cryptoServiceController.delete
self.QAbstractListModel.delete
self.settingsView.delete
proc setup(self: WalletView) =
self.QAbstractListModel.setup
@ -30,6 +32,7 @@ QtObject:
result.appService = appService
result.accountsView = newAccountsView(status)
result.collectiblesView = newCollectiblesView(status, appService)
result.settingsView = newSettingsView()
result.cryptoServiceController = newCryptoServiceController(status, appService)
result.setup
@ -42,6 +45,10 @@ QtObject:
proc getCollectibles(self: WalletView): QVariant {.slot.} =
return newQVariant(self.collectiblesView)
proc getSettings(self: WalletView): QVariant {.slot.} = newQVariant(self.settingsView)
QtProperty[QVariant] settingsView:
read = getSettings
QtProperty[QVariant] collectiblesView:
read = getCollectibles
@ -61,6 +68,12 @@ QtObject:
if (self.accountsView.accounts.rowCount == 1):
self.setCurrentAccountByIndex(0)
proc setSigningPhrase*(self: WalletView, signingPhrase: string) =
self.settingsView.setSigningPhrase(signingPhrase)
proc setEtherscanLink*(self: WalletView, link: string) =
self.settingsView.setEtherscanLink(link)
proc getCryptoServiceController*(self: WalletView): QVariant {.slot.} =
newQVariant(self.cryptoServiceController)

View File

@ -0,0 +1,45 @@
import atomics, strformat, strutils, sequtils, json, std/wrapnils, parseUtils, tables, chronicles, web3/[ethtypes, conversions], stint
import NimQml, json, sequtils, chronicles, strutils, strformat, json
logScope:
topics = "settings-view"
QtObject:
type SettingsView* = ref object of QObject
etherscanLink: string
signingPhrase: string
proc setup(self: SettingsView) = self.QObject.setup
proc delete(self: SettingsView) = self.QObject.delete
proc newSettingsView*(): SettingsView =
new(result, delete)
result.etherscanLink = ""
result.signingPhrase = ""
result.setup
proc etherscanLinkChanged*(self: SettingsView) {.signal.}
proc getEtherscanLink*(self: SettingsView): QVariant {.slot.} =
newQVariant(self.etherscanLink.replace("/address", "/tx"))
proc setEtherscanLink*(self: SettingsView, link: string) =
self.etherscanLink = link
self.etherscanLinkChanged()
proc signingPhraseChanged*(self: SettingsView) {.signal.}
proc getSigningPhrase*(self: SettingsView): QVariant {.slot.} =
newQVariant(self.signingPhrase)
proc setSigningPhrase*(self: SettingsView, signingPhrase: string) =
self.signingPhrase = signingPhrase
self.signingPhraseChanged()
QtProperty[QVariant] etherscanLink:
read = getEtherscanLink
notify = etherscanLinkChanged
QtProperty[QVariant] signingPhrase:
read = getSigningPhrase
notify = signingPhraseChanged

View File

@ -0,0 +1,164 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import "../../../imports"
import "../Profile/Sections"
Item {
id: root
Column {
anchors.top:parent.top
leftPadding: 20
rightPadding: 20
width: parent.width
spacing: 12
StatusExpandableItem {
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
visible : (walletV2Model.accountsView.currentAccount.walletType !== Constants.seedWalletType) &&
(walletV2Model.accountsView.currentAccount.walletType !== Constants.watchWalletType) &&
(walletV2Model.accountsView.currentAccount.walletType !== Constants.keyWalletType)
expandable: false
icon.name: "seed-phrase"
primaryText: qsTr("Back up seed phrase")
secondaryText: qsTr("Back up your seed phrase now to secure this account")
button.text: qsTr("Back up seed phrase")
button.enabled: !profileModel.mnemonic.isBackedUp
button.onClicked: backupSeedModal.open()
}
StatusExpandableItem {
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
visible : walletV2Model.accountsView.currentAccount.walletType !== Constants.watchWalletType
expandable: true
icon.name: "secret"
primaryText: qsTr("Account signing phrase")
secondaryText: qsTr("View your signing phrase and ensure that you never get scammed")
expandableComponent: showSigningPhraseExpandableRegion
}
StatusExpandableItem {
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
visible : (walletV2Model.accountsView.currentAccount.walletType === Constants.keyWalletType) ||
(walletV2Model.accountsView.currentAccount.walletType === Constants.seedWalletType)
expandable: true
icon.name: "seed-phrase"
primaryText: qsTr("View private key")
secondaryText: qsTr("View your seed phrase and ensure it's stored in a safe place")
button.text: qsTr("View private key")
expandableComponent: notImplemented
button.onClicked: {
// To-do open enter password Modal
expanded = !expanded
}
}
StatusExpandableItem {
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
expandable: true
icon.name: "security"
primaryText: qsTr("Security preferences")
secondaryText: qsTr("View & set security preferences for this wallet")
expandableComponent: notImplemented
}
}
Component {
id: notImplemented
Rectangle {
anchors.centerIn: parent
width: 654
height: infoText.implicitHeight
color: Theme.palette.baseColor5
StatusBaseText {
id: infoText
anchors.centerIn: parent
color: Theme.palette.directColor4
font.pixelSize: 15
lineHeight: 22
lineHeightMode: Text.FixedHeight
font.weight: Font.Medium
text: qsTr("Not Implemented")
}
}
}
Component {
id: showSigningPhraseExpandableRegion
Row {
spacing: 1
anchors.centerIn: parent
width: 654
Rectangle {
id: keyRect
color: Theme.palette.baseColor5
width: Math.min(keyText.implicitWidth, 200) + keyText.anchors.leftMargin + keyText.anchors.rightMargin
height: Math.max(keyText.implicitHeight, infoText.implicitHeight) + 42
StatusBaseText {
id: keyText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 21
anchors.right: parent.right
anchors.rightMargin: 21
width: Math.min(implicitWidth, 200)
color: Theme.palette.dangerColor1
font.pixelSize: 15
lineHeight: 22
lineHeightMode: Text.FixedHeight
elide: Text.ElideRight
wrapMode: Text.Wrap
text: walletV2Model.settingsView.signingPhrase
}
}
Rectangle {
id: infoRect
color: Theme.palette.baseColor5
width: parent.width - keyRect.width
height: Math.max(keyText.implicitHeight, infoText.implicitHeight) + 42
StatusBaseText {
id: infoText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 25
width: 366
color: Theme.palette.directColor4
font.pixelSize: 12
lineHeight: 16
lineHeightMode: Text.FixedHeight
elide: Text.ElideRight
wrapMode: Text.Wrap
text: qsTr("If you see something different, you should immediately sign out and reinstall Status")
}
}
}
}
BackupSeedModal {
id: backupSeedModal
}
}

View File

@ -85,6 +85,12 @@ Item {
id: collectiblesBtn
btnText: qsTr("Collectibles")
}
StatusTabButton {
id: settingsBtn
anchors.left: collectiblesBtn.right
anchors.leftMargin: walletInfoContent.width - collectiblesBtn.width - 100
btnText: qsTr("Settings")
}
}
StackLayout {
@ -93,12 +99,16 @@ Item {
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.topMargin: Style.current.bigPadding
anchors.topMargin: Style.current.padding
currentIndex: walletTabBar.currentIndex
CollectiblesTab {
id: collectiblesTab
}
SettingsTab {
id: settingsTab
}
}
}
}

View File

@ -2,3 +2,4 @@ LeftTab 1.0 LeftTab.qml
WalletHeader 1.0 WalletHeader.qml
AssetsTab 1.0 AssetsTab.qml
CollectiblesTab 1.0 CollectiblesTab.qml
SettingsTab SettingsTab.qml