fix(@desktop/wallet): Assign an emoji to the default wallet account during onboarding

fixes #6694
This commit is contained in:
Khushboo Mehta 2022-08-25 13:26:04 +02:00 committed by Khushboo-dev-cpp
parent ddb9caf4d7
commit 56e6427260
7 changed files with 29 additions and 3 deletions

View File

@ -140,6 +140,9 @@ proc getDisplayName*(self: Controller): string =
proc setPassword*(self: Controller, value: string) = proc setPassword*(self: Controller, value: string) =
self.tmpPassword = value self.tmpPassword = value
proc setDefaultWalletEmoji*(self: Controller, emoji: string) =
self.accountsService.setDefaultWalletEmoji(emoji)
proc getPassword*(self: Controller): string = proc getPassword*(self: Controller): string =
return self.tmpPassword return self.tmpPassword
@ -202,6 +205,7 @@ proc cleanTmpData*(self: Controller) =
self.tmpKeychainErrorOccurred = true self.tmpKeychainErrorOccurred = true
self.setDisplayName("") self.setDisplayName("")
self.setPassword("") self.setPassword("")
self.setDefaultWalletEmoji("")
self.setPin("") self.setPin("")
self.setPinMatch(false) self.setPinMatch(false)
self.setPuk("") self.setPuk("")
@ -392,4 +396,4 @@ proc buildSeedPhrasesFromIndexes*(self: Controller, seedPhraseIndexes: seq[int])
self.setSeedPhrase(sp.join(" ")) self.setSeedPhrase(sp.join(" "))
proc generateRandomPUK*(self: Controller): string = proc generateRandomPUK*(self: Controller): string =
return self.keycardService.generateRandomPUK() return self.keycardService.generateRandomPUK()

View File

@ -61,6 +61,9 @@ method getDisplayName*(self: AccessInterface): string {.base.} =
method setPassword*(self: AccessInterface, value: string) {.base.} = method setPassword*(self: AccessInterface, value: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method setDefaultWalletEmoji*(self: AccessInterface, emoji: string) {.base.} =
raise newException(ValueError, "No implementation available")
method getPassword*(self: AccessInterface): string {.base.} = method getPassword*(self: AccessInterface): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -189,6 +189,9 @@ method getDisplayName*[T](self: Module[T]): string =
method setPassword*[T](self: Module[T], value: string) = method setPassword*[T](self: Module[T], value: string) =
self.controller.setPassword(value) self.controller.setPassword(value)
method setDefaultWalletEmoji*[T](self: Module[T], emoji: string) =
self.controller.setDefaultWalletEmoji(emoji)
method getPassword*[T](self: Module[T]): string = method getPassword*[T](self: Module[T]): string =
return self.controller.getPassword() return self.controller.getPassword()

View File

@ -154,6 +154,9 @@ QtObject:
proc setPassword*(self: View, value: string) {.slot.} = proc setPassword*(self: View, value: string) {.slot.} =
self.delegate.setPassword(value) self.delegate.setPassword(value)
proc setDefaultWalletEmoji*(self: View, emoji: string) {.slot.} =
self.delegate.setDefaultWalletEmoji(emoji)
proc getPassword*(self: View): string {.slot.} = proc getPassword*(self: View): string {.slot.} =
return self.delegate.getPassword() return self.delegate.getPassword()
@ -245,4 +248,4 @@ QtObject:
proc destroyKeycardSharedModuleFlow*(self: View) {.signal.} proc destroyKeycardSharedModuleFlow*(self: View) {.signal.}
proc emitDestroyKeycardSharedModuleFlow*(self: View) = proc emitDestroyKeycardSharedModuleFlow*(self: View) =
self.destroyKeycardSharedModuleFlow() self.destroyKeycardSharedModuleFlow()

View File

@ -35,6 +35,7 @@ type
importedAccount: GeneratedAccountDto importedAccount: GeneratedAccountDto
isFirstTimeAccountLogin: bool isFirstTimeAccountLogin: bool
keyStoreDir: string keyStoreDir: string
defaultWalletEmoji: string
proc delete*(self: Service) = proc delete*(self: Service) =
discard discard
@ -44,6 +45,7 @@ proc newService*(fleetConfiguration: FleetConfiguration): Service =
result.fleetConfiguration = fleetConfiguration result.fleetConfiguration = fleetConfiguration
result.isFirstTimeAccountLogin = false result.isFirstTimeAccountLogin = false
result.keyStoreDir = main_constants.ROOTKEYSTOREDIR result.keyStoreDir = main_constants.ROOTKEYSTOREDIR
result.defaultWalletEmoji = ""
proc getLoggedInAccount*(self: Service): AccountDto = proc getLoggedInAccount*(self: Service): AccountDto =
return self.loggedInAccount return self.loggedInAccount
@ -58,6 +60,9 @@ proc setKeyStoreDir(self: Service, key: string) =
self.keyStoreDir = joinPath(main_constants.ROOTKEYSTOREDIR, key) & main_constants.sep self.keyStoreDir = joinPath(main_constants.ROOTKEYSTOREDIR, key) & main_constants.sep
discard status_general.initKeystore(self.keyStoreDir) discard status_general.initKeystore(self.keyStoreDir)
proc setDefaultWalletEmoji*(self: Service, emoji: string) =
self.defaultWalletEmoji = emoji
proc init*(self: Service) = proc init*(self: Service) =
try: try:
let response = status_account.generateAddresses(PATHS) let response = status_account.generateAddresses(PATHS)
@ -192,7 +197,8 @@ proc prepareSubaccountJsonObject(self: Service, account: GeneratedAccountDto, di
"wallet": true, "wallet": true,
"path": PATH_DEFAULT_WALLET, "path": PATH_DEFAULT_WALLET,
"name": "Status account", "name": "Status account",
"derived-from": account.address "derived-from": account.address,
"emoji": self.defaultWalletEmoji
}, },
{ {
"public-key": account.derivedAccounts.whisper.publicKey, "public-key": account.derivedAccounts.whisper.publicKey,
@ -362,6 +368,7 @@ proc setupAccountKeycard*(self: Service, keycardData: KeycardEvent) =
"path": PATH_DEFAULT_WALLET, "path": PATH_DEFAULT_WALLET,
"name": "Status account", "name": "Status account",
"derived-from": keycardData.masterKey.address, "derived-from": keycardData.masterKey.address,
"emoji": self.defaultWalletEmoji,
}, },
{ {
"public-key": keycardData.whisperKey.publicKey, "public-key": keycardData.whisperKey.publicKey,

View File

@ -51,6 +51,10 @@ QtObject {
root.startupModuleInst.setPassword(value) root.startupModuleInst.setPassword(value)
} }
function setDefaultWalletEmoji(emoji) {
root.startupModuleInst.setDefaultWalletEmoji(emoji)
}
function getPassword() { function getPassword() {
return root.startupModuleInst.getPassword() return root.startupModuleInst.getPassword()
} }

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import utils 1.0 import utils 1.0
import shared.views 1.0 import shared.views 1.0
@ -27,6 +28,7 @@ Item {
readonly property int zFront: 100 readonly property int zFront: 100
function submit() { function submit() {
root.startupStore.setDefaultWalletEmoji(StatusQUtils.Emoji.getRandomEmoji(StatusQUtils.Emoji.size.verySmall))
root.startupStore.setPassword(view.newPswText) root.startupStore.setPassword(view.newPswText)
root.startupStore.doPrimaryAction() root.startupStore.doPrimaryAction()
} }