feat(wallet): naming of first and subsequent wallet accounts

Closes #12693
This commit is contained in:
Sale Djenic 2024-02-28 15:15:58 +01:00
parent 9faa5a5a3a
commit 01f413671b
12 changed files with 40 additions and 8 deletions

View File

@ -132,6 +132,9 @@ proc getKeypairs*(self: Controller): seq[KeypairDto] =
proc getKeypairByKeyUid*(self: Controller, keyUid: string): KeypairDto =
return self.walletAccountService.getKeypairByKeyUid(keyUid)
proc getIndexForNextAccountNameSuggestion*(self: Controller): int =
return wallet_account_service.getIndexForNextAccountNameSuggestion()
proc getSavedAddress*(self: Controller, address: string): SavedAddressDto =
return self.savedAddressService.getSavedAddress(address)

View File

@ -107,6 +107,9 @@ method removingSavedAddressConfirmed*(self: AccessInterface, address: string) {.
method savedAddressDeleted*(self: AccessInterface, address: string, errorMsg: string) {.base.} =
raise newException(ValueError, "No implementation available")
method getIndexForNextAccountNameSuggestion*(self: AccessInterface): int {.base.} =
raise newException(ValueError, "No implementation available")
type
DelegateInterface* = concept c
c.onAddAccountModuleLoaded()

View File

@ -352,6 +352,9 @@ proc isAuthenticationNeededForSelectedOrigin[T](self: Module[T]): bool =
return false
return true
method getIndexForNextAccountNameSuggestion*[T](self: Module[T]): int =
return self.controller.getIndexForNextAccountNameSuggestion()
method changeDerivationPath*[T](self: Module[T], derivationPath: string) =
self.view.setDerivationPath(derivationPath)
if self.isAuthenticationNeededForSelectedOrigin():

View File

@ -362,4 +362,7 @@ QtObject:
self.delegate.removingSavedAddressConfirmed(address)
proc removingSavedAddressRejected*(self: View) {.slot.} =
self.setDisablePopup(false)
self.setDisablePopup(false)
proc getIndexForNextAccountNameSuggestion*(self: View): int {.slot.} =
return self.delegate.getIndexForNextAccountNameSuggestion()

View File

@ -25,6 +25,7 @@ export dto_generated_accounts
logScope:
topics = "accounts-service"
const DEFAULT_WALLET_ACCOUNT_NAME = "Account 1"
const PATHS = @[PATH_WALLET_ROOT, PATH_EIP_1581, PATH_WHISPER, PATH_DEFAULT_WALLET, PATH_ENCRYPTION]
const ACCOUNT_ALREADY_EXISTS_ERROR* = "account already exists"
const KDF_ITERATIONS* {.intdefine.} = 256_000
@ -240,7 +241,7 @@ QtObject:
"colorId": DEFAULT_COLORID_FOR_DEFAULT_WALLET_ACCOUNT,
"wallet": true,
"path": PATH_DEFAULT_WALLET,
"name": "Status account",
"name": DEFAULT_WALLET_ACCOUNT_NAME,
"derived-from": account.address,
"emoji": self.defaultWalletEmoji
},
@ -493,7 +494,7 @@ QtObject:
"colorId": DEFAULT_COLORID_FOR_DEFAULT_WALLET_ACCOUNT,
"wallet": true,
"path": PATH_DEFAULT_WALLET,
"name": "Status account",
"name": DEFAULT_WALLET_ACCOUNT_NAME,
"derived-from": address,
"emoji": self.defaultWalletEmoji,
},

View File

@ -66,6 +66,15 @@ proc getKeypairByKeyUidFromDb(keyUid: string): KeypairDto =
except Exception as e:
info "no known keypair", keyUid=keyUid, procName="getKeypairByKeyUid", errName = e.name, errDesription = e.msg
proc getIndexForNextAccountNameSuggestion*(): int =
try:
let response = status_go_accounts.getIndexForNextAccountNameSuggestion()
if not response.error.isNil:
return
return response.result.getInt
except Exception as e:
error "error: ", procName="getIndexForNextAccountNameSuggestion", errName = e.name, errDesription = e.msg
proc getEnsName(address: string, chainId: int): string =
try:
let response = backend.getName(chainId, address)

View File

@ -28,6 +28,9 @@ proc getWatchOnlyAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
proc getKeypairs*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("accounts_getKeypairs")
proc getIndexForNextAccountNameSuggestion*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("accounts_getIndexForNextAccountNameSuggestion")
proc getKeypairByKeyUid*(keyUid: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [keyUid]
return core.callPrivateRPC("accounts_getKeypairByKeyUID", payload)

View File

@ -1,7 +1,7 @@
from collections import namedtuple
from enum import Enum
DEFAULT_ACCOUNT_NAME = 'Status account'
DEFAULT_ACCOUNT_NAME = 'Account 1'
account_list_item = namedtuple('AccountListItem', ['name', 'color', 'emoji'])

View File

@ -15,7 +15,7 @@ Feature: Status Desktop Wallet Section Wallet Account Management
Then the account is correctly displayed with "<new_name>" and "#<new_color>" and emoji unicode "<new_emoji_unicode>" in accounts list
Examples:
| name | new_name | new_color | new_emoji | new_emoji_unicode |
| Status account | MyPrimaryAccount | 216266 | sunglasses | 1f60e |
| Account 1 | MyPrimaryAccount | 216266 | sunglasses | 1f60e |
Scenario Outline: The user can add, edit and remove a watch only account
When the user adds a watch only account "<address>" with "<name>" color "#<color>" and emoji "<emoji>"

View File

@ -34,12 +34,15 @@ Item {
root.store.addAccountModule.selectedEmoji = StatusQUtils.Emoji.getRandomEmoji(StatusQUtils.Emoji.size.verySmall)
}
accountName.text = root.store.addAccountModule.accountName
if (d.isEdit) {
accountName.placeholderText = qsTr("Enter an account name...")
accountName.text = root.store.addAccountModule.accountName
accountName.input.asset.emoji = root.store.addAccountModule.selectedEmoji;
} else {
accountName.placeholderText = root.store.getNextAccountNameSuggestion()
accountName.input.asset.isLetterIdenticon = true;
}
accountName.input.edit.cursorPosition = accountName.text.length
accountName.input.edit.forceActiveFocus()
accountName.validate(true)
}
@ -102,7 +105,6 @@ Item {
id: accountName
objectName: "AddAccountPopup-AccountName"
anchors.horizontalCenter: parent.horizontalCenter
placeholderText: qsTr("Enter an account name...")
label: qsTr("Name")
charLimit: 20
text: root.store.addAccountModule.accountName

View File

@ -75,6 +75,11 @@ BasePopupStore {
return root.addAccountModule.getStoredAccountName()
}
function getNextAccountNameSuggestion() {
let index = root.addAccountModule.getIndexForNextAccountNameSuggestion()
return qsTr("Account %1").arg(index)
}
function getStoredSelectedEmoji() {
return root.addAccountModule.getStoredSelectedEmoji()
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 3f98a34eae7275bd5ee055de8e4f32213370cdaa
Subproject commit f767840a9ff18d9aa03e6fa929dc3cdc4fa7547c