fix(@desktop/wallet): keycard accounts do not display a keycard icon in the wallet list of accounts
Closes: #10643
This commit is contained in:
parent
38ce51e4bb
commit
1d41590d56
|
@ -36,16 +36,19 @@ proc init*(self: Controller) =
|
||||||
proc getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
|
proc getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
|
||||||
return self.walletAccountService.getWalletAccount(accountIndex)
|
return self.walletAccountService.getWalletAccount(accountIndex)
|
||||||
|
|
||||||
|
proc isKeycardAccount*(self: Controller, account: WalletAccountDto): bool =
|
||||||
|
return self.walletAccountService.isKeycardAccount(account)
|
||||||
|
|
||||||
proc getIndex*(self: Controller, address: string): int =
|
proc getIndex*(self: Controller, address: string): int =
|
||||||
return self.walletAccountService.getIndex(address)
|
return self.walletAccountService.getIndex(address)
|
||||||
|
|
||||||
proc findTokenSymbolByAddress*(self: Controller, address: string): string =
|
proc findTokenSymbolByAddress*(self: Controller, address: string): string =
|
||||||
return self.walletAccountService.findTokenSymbolByAddress(address)
|
return self.walletAccountService.findTokenSymbolByAddress(address)
|
||||||
|
|
||||||
proc getChainIds*(self: Controller): seq[int] =
|
proc getChainIds*(self: Controller): seq[int] =
|
||||||
return self.networkService.getNetworks().map(n => n.chainId)
|
return self.networkService.getNetworks().map(n => n.chainId)
|
||||||
|
|
||||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||||
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)
|
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||||
|
|
||||||
proc getCurrentCurrency*(self: Controller): string =
|
proc getCurrentCurrency*(self: Controller): string =
|
||||||
|
|
|
@ -54,13 +54,16 @@ proc setAssets(self: Module, tokens: seq[WalletTokenDto]) =
|
||||||
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
||||||
|
|
||||||
let items = tokens.map(t => walletTokenToItem(t, chainIds, enabledChainIds, currency, currencyFormat, self.controller.getCurrencyFormat(t.symbol)))
|
let items = tokens.map(t => walletTokenToItem(t, chainIds, enabledChainIds, currency, currencyFormat, self.controller.getCurrencyFormat(t.symbol)))
|
||||||
|
|
||||||
self.view.getAssetsModel().setItems(items)
|
self.view.getAssetsModel().setItems(items)
|
||||||
|
|
||||||
proc switchAccount*(self: Module, accountIndex: int) =
|
proc switchAccount*(self: Module, accountIndex: int) =
|
||||||
self.currentAccountIndex = accountIndex
|
self.currentAccountIndex = accountIndex
|
||||||
|
|
||||||
let walletAccount = self.controller.getWalletAccount(accountIndex)
|
let walletAccount = self.controller.getWalletAccount(accountIndex)
|
||||||
|
if walletAccount.isNil:
|
||||||
|
return
|
||||||
|
let keycardAccount = self.controller.isKeycardAccount(walletAccount)
|
||||||
let currency = self.controller.getCurrentCurrency()
|
let currency = self.controller.getCurrentCurrency()
|
||||||
let enabledChainIds = self.controller.getEnabledChainIds()
|
let enabledChainIds = self.controller.getEnabledChainIds()
|
||||||
|
|
||||||
|
@ -68,6 +71,7 @@ proc switchAccount*(self: Module, accountIndex: int) =
|
||||||
|
|
||||||
let accountItem = walletAccountToWalletAccountsItem(
|
let accountItem = walletAccountToWalletAccountsItem(
|
||||||
walletAccount,
|
walletAccount,
|
||||||
|
keycardAccount,
|
||||||
enabledChainIds,
|
enabledChainIds,
|
||||||
currency,
|
currency,
|
||||||
currencyFormat,
|
currencyFormat,
|
||||||
|
@ -100,7 +104,7 @@ method isLoaded*(self: Module): bool =
|
||||||
|
|
||||||
method viewDidLoad*(self: Module) =
|
method viewDidLoad*(self: Module) =
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
|
|
||||||
method switchAccountByAddress*(self: Module, address: string) =
|
method switchAccountByAddress*(self: Module, address: string) =
|
||||||
let accountIndex = self.controller.getIndex(address)
|
let accountIndex = self.controller.getIndex(address)
|
||||||
self.switchAccount(accountIndex)
|
self.switchAccount(accountIndex)
|
||||||
|
|
|
@ -34,5 +34,8 @@ proc deleteAccount*(self: Controller, address: string) =
|
||||||
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
proc getKeycardByKeyUid*(self: Controller, keyUid: string): seq[KeycardDto] =
|
||||||
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
return self.walletAccountService.getKeycardByKeyUid(keyUid)
|
||||||
|
|
||||||
|
proc isKeycardAccount*(self: Controller, account: WalletAccountDto): bool =
|
||||||
|
return self.walletAccountService.isKeycardAccount(account)
|
||||||
|
|
||||||
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
|
||||||
return self.walletAccountService.getAccountByAddress(address)
|
return self.walletAccountService.getAccountByAddress(address)
|
|
@ -17,6 +17,7 @@ proc initItem*(
|
||||||
emoji: string = "",
|
emoji: string = "",
|
||||||
relatedAccounts: related_accounts_model.Model = nil,
|
relatedAccounts: related_accounts_model.Model = nil,
|
||||||
keyUid: string = "",
|
keyUid: string = "",
|
||||||
|
keycardAccount: bool = false
|
||||||
): Item =
|
): Item =
|
||||||
result = Item()
|
result = Item()
|
||||||
result.WalletAccountItem.setup(name,
|
result.WalletAccountItem.setup(name,
|
||||||
|
@ -25,9 +26,10 @@ proc initItem*(
|
||||||
emoji,
|
emoji,
|
||||||
walletType,
|
walletType,
|
||||||
path,
|
path,
|
||||||
keyUid)
|
keyUid,
|
||||||
|
keycardAccount)
|
||||||
result.relatedAccounts = relatedAccounts
|
result.relatedAccounts = relatedAccounts
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
proc `$`*(self: Item): string =
|
||||||
result = "ProfileSection-Accounts-Item("
|
result = "ProfileSection-Accounts-Item("
|
||||||
result = result & $self.WalletAccountItem
|
result = result & $self.WalletAccountItem
|
||||||
|
|
|
@ -48,7 +48,8 @@ method refreshWalletAccounts*(self: Module) =
|
||||||
let walletAccounts = self.controller.getWalletAccounts()
|
let walletAccounts = self.controller.getWalletAccounts()
|
||||||
|
|
||||||
let items = walletAccounts.map(w => (block:
|
let items = walletAccounts.map(w => (block:
|
||||||
walletAccountToWalletSettingsAccountsItem(w)
|
let keycardAccount = self.controller.isKeycardAccount(w)
|
||||||
|
walletAccountToWalletSettingsAccountsItem(w, keycardAccount)
|
||||||
))
|
))
|
||||||
|
|
||||||
self.view.setItems(items)
|
self.view.setItems(items)
|
||||||
|
@ -62,7 +63,8 @@ method load*(self: Module) =
|
||||||
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
||||||
let args = WalletAccountUpdated(e)
|
let args = WalletAccountUpdated(e)
|
||||||
self.view.onUpdatedAccount(walletAccountToWalletSettingsAccountsItem(args.account))
|
let keycardAccount = self.controller.isKeycardAccount(args.account)
|
||||||
|
self.view.onUpdatedAccount(walletAccountToWalletSettingsAccountsItem(args.account, keycardAccount))
|
||||||
|
|
||||||
self.events.on(SIGNAL_NEW_KEYCARD_SET) do(e: Args):
|
self.events.on(SIGNAL_NEW_KEYCARD_SET) do(e: Args):
|
||||||
let args = KeycardActivityArgs(e)
|
let args = KeycardActivityArgs(e)
|
||||||
|
|
|
@ -35,10 +35,13 @@ proc init*(self: Controller) =
|
||||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||||
return self.walletAccountService.getWalletAccounts()
|
return self.walletAccountService.getWalletAccounts()
|
||||||
|
|
||||||
|
proc isKeycardAccount*(self: Controller, account: WalletAccountDto): bool =
|
||||||
|
return self.walletAccountService.isKeycardAccount(account)
|
||||||
|
|
||||||
proc deleteAccount*(self: Controller, address: string) =
|
proc deleteAccount*(self: Controller, address: string) =
|
||||||
self.walletAccountService.deleteAccount(address)
|
self.walletAccountService.deleteAccount(address)
|
||||||
|
|
||||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||||
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)
|
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||||
|
|
||||||
proc getCurrentCurrency*(self: Controller): string =
|
proc getCurrentCurrency*(self: Controller): string =
|
||||||
|
|
|
@ -18,6 +18,7 @@ proc initItem*(
|
||||||
currencyBalance: CurrencyAmount = nil,
|
currencyBalance: CurrencyAmount = nil,
|
||||||
emoji: string = "",
|
emoji: string = "",
|
||||||
keyUid: string = "",
|
keyUid: string = "",
|
||||||
|
keycardAccount: bool = false,
|
||||||
assetsLoading: bool = true,
|
assetsLoading: bool = true,
|
||||||
): Item =
|
): Item =
|
||||||
result = Item()
|
result = Item()
|
||||||
|
@ -27,17 +28,18 @@ proc initItem*(
|
||||||
emoji,
|
emoji,
|
||||||
walletType,
|
walletType,
|
||||||
path,
|
path,
|
||||||
keyUid)
|
keyUid,
|
||||||
|
keycardAccount)
|
||||||
result.assetsLoading = assetsLoading
|
result.assetsLoading = assetsLoading
|
||||||
result.currencyBalance = currencyBalance
|
result.currencyBalance = currencyBalance
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
proc `$`*(self: Item): string =
|
||||||
result = "WalletSection-Accounts-Item("
|
result = "WalletSection-Accounts-Item("
|
||||||
result = result & $self.WalletAccountItem
|
result = result & $self.WalletAccountItem
|
||||||
result = result & "\nassetsLoading: " & $self.assetsLoading
|
result = result & "\nassetsLoading: " & $self.assetsLoading
|
||||||
result = result & "\ncurrencyBalance: " & $self.currencyBalance
|
result = result & "\ncurrencyBalance: " & $self.currencyBalance
|
||||||
result = result & ")"
|
result = result & ")"
|
||||||
|
|
||||||
proc currencyBalance*(self: Item): CurrencyAmount =
|
proc currencyBalance*(self: Item): CurrencyAmount =
|
||||||
return self.currencyBalance
|
return self.currencyBalance
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ type
|
||||||
CurrencyBalance,
|
CurrencyBalance,
|
||||||
Emoji,
|
Emoji,
|
||||||
KeyUid,
|
KeyUid,
|
||||||
|
KeycardAccount,
|
||||||
AssetsLoading,
|
AssetsLoading,
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
|
@ -59,6 +60,7 @@ QtObject:
|
||||||
ModelRole.CurrencyBalance.int:"currencyBalance",
|
ModelRole.CurrencyBalance.int:"currencyBalance",
|
||||||
ModelRole.Emoji.int: "emoji",
|
ModelRole.Emoji.int: "emoji",
|
||||||
ModelRole.KeyUid.int: "keyUid",
|
ModelRole.KeyUid.int: "keyUid",
|
||||||
|
ModelRole.KeycardAccount.int: "keycardAccount",
|
||||||
ModelRole.AssetsLoading.int: "assetsLoading",
|
ModelRole.AssetsLoading.int: "assetsLoading",
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
|
@ -99,6 +101,8 @@ QtObject:
|
||||||
result = newQVariant(item.emoji())
|
result = newQVariant(item.emoji())
|
||||||
of ModelRole.KeyUid:
|
of ModelRole.KeyUid:
|
||||||
result = newQVariant(item.keyUid())
|
result = newQVariant(item.keyUid())
|
||||||
|
of ModelRole.KeycardAccount:
|
||||||
|
result = newQVariant(item.keycardAccount())
|
||||||
of ModelRole.AssetsLoading:
|
of ModelRole.AssetsLoading:
|
||||||
result = newQVariant(item.assetsLoading())
|
result = newQVariant(item.assetsLoading())
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,10 @@ method refreshWalletAccounts*(self: Module) =
|
||||||
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
||||||
|
|
||||||
let items = walletAccounts.map(w => (block:
|
let items = walletAccounts.map(w => (block:
|
||||||
|
let keycardAccount = self.controller.isKeycardAccount(w)
|
||||||
walletAccountToWalletAccountsItem(
|
walletAccountToWalletAccountsItem(
|
||||||
w,
|
w,
|
||||||
|
keycardAccount,
|
||||||
enabledChainIds,
|
enabledChainIds,
|
||||||
currency,
|
currency,
|
||||||
currencyFormat,
|
currencyFormat,
|
||||||
|
|
|
@ -26,7 +26,8 @@ QtObject:
|
||||||
emoji,
|
emoji,
|
||||||
walletType,
|
walletType,
|
||||||
path = "",
|
path = "",
|
||||||
keyUid = "")
|
keyUid = "",
|
||||||
|
keycardAccount = false)
|
||||||
self.assets = assets
|
self.assets = assets
|
||||||
self.currencyBalance = currencyBalance
|
self.currencyBalance = currencyBalance
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ QtObject:
|
||||||
): AccountItem =
|
): AccountItem =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.setup(name, address, color, emoji, walletType, assets, currencyBalance)
|
result.setup(name, address, color, emoji, walletType, assets, currencyBalance)
|
||||||
|
|
||||||
proc `$`*(self: AccountItem): string =
|
proc `$`*(self: AccountItem): string =
|
||||||
result = "WalletSection-Send-Item("
|
result = "WalletSection-Send-Item("
|
||||||
result = result & $self.WalletAccountItem
|
result = result & $self.WalletAccountItem
|
||||||
|
|
|
@ -33,7 +33,8 @@ proc walletAccountToRelatedAccountItem*(w: WalletAccountDto) : related_account_i
|
||||||
w.emoji,
|
w.emoji,
|
||||||
)
|
)
|
||||||
|
|
||||||
proc walletAccountToWalletSettingsAccountsItem*(w: WalletAccountDto): wallet_settings_accounts_item.Item =
|
proc walletAccountToWalletSettingsAccountsItem*(w: WalletAccountDto, keycardAccount: bool): wallet_settings_accounts_item.Item =
|
||||||
|
discard
|
||||||
let relatedAccounts = related_accounts_model.newModel()
|
let relatedAccounts = related_accounts_model.newModel()
|
||||||
if w.isNil:
|
if w.isNil:
|
||||||
return wallet_settings_accounts_item.initItem()
|
return wallet_settings_accounts_item.initItem()
|
||||||
|
@ -49,9 +50,10 @@ proc walletAccountToWalletSettingsAccountsItem*(w: WalletAccountDto): wallet_set
|
||||||
w.emoji,
|
w.emoji,
|
||||||
relatedAccounts,
|
relatedAccounts,
|
||||||
w.keyUid,
|
w.keyUid,
|
||||||
|
keycardAccount
|
||||||
)
|
)
|
||||||
|
|
||||||
proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, enabledChainIds: seq[int], currency: string,
|
proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: bool, enabledChainIds: seq[int], currency: string,
|
||||||
currencyFormat: CurrencyFormatDto): wallet_accounts_item.Item =
|
currencyFormat: CurrencyFormatDto): wallet_accounts_item.Item =
|
||||||
return wallet_accounts_item.initItem(
|
return wallet_accounts_item.initItem(
|
||||||
w.name,
|
w.name,
|
||||||
|
@ -62,6 +64,7 @@ proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, enabledChainIds: se
|
||||||
currencyAmountToItem(w.getCurrencyBalance(enabledChainIds, currency), currencyFormat),
|
currencyAmountToItem(w.getCurrencyBalance(enabledChainIds, currency), currencyFormat),
|
||||||
w.emoji,
|
w.emoji,
|
||||||
w.keyUid,
|
w.keyUid,
|
||||||
|
keycardAccount,
|
||||||
w.assetsLoading,
|
w.assetsLoading,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ QtObject:
|
||||||
walletType: string
|
walletType: string
|
||||||
path: string
|
path: string
|
||||||
keyUid: string
|
keyUid: string
|
||||||
|
keycardAccount: bool
|
||||||
|
|
||||||
proc setup*(self: WalletAccountItem,
|
proc setup*(self: WalletAccountItem,
|
||||||
name: string = "",
|
name: string = "",
|
||||||
|
@ -17,7 +18,8 @@ QtObject:
|
||||||
emoji: string = "",
|
emoji: string = "",
|
||||||
walletType: string = "",
|
walletType: string = "",
|
||||||
path: string = "",
|
path: string = "",
|
||||||
keyUid: string = ""
|
keyUid: string = "",
|
||||||
|
keycardAccount: bool = false
|
||||||
) =
|
) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -27,6 +29,7 @@ QtObject:
|
||||||
self.walletType = walletType
|
self.walletType = walletType
|
||||||
self.path = path
|
self.path = path
|
||||||
self.keyUid = keyUid
|
self.keyUid = keyUid
|
||||||
|
self.keycardAccount = keycardAccount
|
||||||
|
|
||||||
proc delete*(self: WalletAccountItem) =
|
proc delete*(self: WalletAccountItem) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
@ -40,6 +43,7 @@ QtObject:
|
||||||
walletType: {self.walletType},
|
walletType: {self.walletType},
|
||||||
path: {self.path},
|
path: {self.path},
|
||||||
keyUid: {self.keyUid},
|
keyUid: {self.keyUid},
|
||||||
|
keycardAccount: {self.keycardAccount},
|
||||||
]"""
|
]"""
|
||||||
|
|
||||||
proc nameChanged*(self: WalletAccountItem) {.signal.}
|
proc nameChanged*(self: WalletAccountItem) {.signal.}
|
||||||
|
@ -103,4 +107,11 @@ QtObject:
|
||||||
read = keyUid
|
read = keyUid
|
||||||
notify = keyUidChanged
|
notify = keyUidChanged
|
||||||
|
|
||||||
|
proc keycardAccountChanged*(self: WalletAccountItem) {.signal.}
|
||||||
|
proc keycardAccount*(self: WalletAccountItem): bool {.slot.} =
|
||||||
|
return self.keycardAccount
|
||||||
|
QtProperty[bool] keycardAccount:
|
||||||
|
read = keycardAccount
|
||||||
|
notify = keycardAccountChanged
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ proc priorityTokenCmp(a, b: WalletTokenDto): int =
|
||||||
return -1
|
return -1
|
||||||
if b.symbol == symbol:
|
if b.symbol == symbol:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cmp(a.name, b.name)
|
cmp(a.name, b.name)
|
||||||
|
|
||||||
proc hex2Balance*(input: string, decimals: int): string =
|
proc hex2Balance*(input: string, decimals: int): string =
|
||||||
|
@ -84,7 +84,7 @@ type WalletAccountUpdated* = ref object of Args
|
||||||
account*: WalletAccountDto
|
account*: WalletAccountDto
|
||||||
|
|
||||||
type DerivedAddressesArgs* = ref object of Args
|
type DerivedAddressesArgs* = ref object of Args
|
||||||
uniqueId*: string
|
uniqueId*: string
|
||||||
derivedAddresses*: seq[DerivedAddressDto]
|
derivedAddresses*: seq[DerivedAddressDto]
|
||||||
error*: string
|
error*: string
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ QtObject:
|
||||||
if keypair.isNil:
|
if keypair.isNil:
|
||||||
return
|
return
|
||||||
account.relatedAccounts = keypair.accounts
|
account.relatedAccounts = keypair.accounts
|
||||||
|
|
||||||
proc setRelatedAccountsForAllAccounts(self: Service, keyUid: string) =
|
proc setRelatedAccountsForAllAccounts(self: Service, keyUid: string) =
|
||||||
for wAcc in self.walletAccounts.mvalues:
|
for wAcc in self.walletAccounts.mvalues:
|
||||||
if wAcc.keyUid == keyUid:
|
if wAcc.keyUid == keyUid:
|
||||||
|
@ -224,7 +224,7 @@ QtObject:
|
||||||
if updateRelatedAccounts:
|
if updateRelatedAccounts:
|
||||||
# updating related accounts for already added accounts
|
# updating related accounts for already added accounts
|
||||||
self.setRelatedAccountsForAllAccounts(account.keyUid)
|
self.setRelatedAccountsForAllAccounts(account.keyUid)
|
||||||
# add new account to store
|
# add new account to store
|
||||||
self.walletAccounts[account.address] = account
|
self.walletAccounts[account.address] = account
|
||||||
|
|
||||||
proc storeTokensForAccount*(self: Service, address: string, tokens: seq[WalletTokenDto], areBalancesCached: bool, areMarketValuesCached: bool) =
|
proc storeTokensForAccount*(self: Service, address: string, tokens: seq[WalletTokenDto], areBalancesCached: bool, areMarketValuesCached: bool) =
|
||||||
|
@ -284,7 +284,7 @@ QtObject:
|
||||||
return
|
return
|
||||||
result = self.walletAccounts[address]
|
result = self.walletAccounts[address]
|
||||||
|
|
||||||
proc getAccountsByAddresses*(self: Service, addresses: seq[string]): seq[WalletAccountDto] =
|
proc getAccountsByAddresses*(self: Service, addresses: seq[string]): seq[WalletAccountDto] =
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
result.add(self.getAccountByAddress(address))
|
result.add(self.getAccountByAddress(address))
|
||||||
|
|
||||||
|
@ -428,18 +428,18 @@ QtObject:
|
||||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_UPDATED, WalletAccountUpdated(account: account))
|
self.events.emit(SIGNAL_WALLET_ACCOUNT_UPDATED, WalletAccountUpdated(account: account))
|
||||||
|
|
||||||
## if password is not provided local keystore file won't be created
|
## if password is not provided local keystore file won't be created
|
||||||
proc addWalletAccount*(self: Service, password: string, doPasswordHashing: bool, name, address, path, publicKey,
|
proc addWalletAccount*(self: Service, password: string, doPasswordHashing: bool, name, address, path, publicKey,
|
||||||
keyUid, accountType, color, emoji: string): string =
|
keyUid, accountType, color, emoji: string): string =
|
||||||
try:
|
try:
|
||||||
var response: RpcResponse[JsonNode]
|
var response: RpcResponse[JsonNode]
|
||||||
if password.len == 0:
|
if password.len == 0:
|
||||||
response = status_go_accounts.addAccountWithoutKeystoreFileCreation(name, address, path, publicKey, keyUid,
|
response = status_go_accounts.addAccountWithoutKeystoreFileCreation(name, address, path, publicKey, keyUid,
|
||||||
accountType, color, emoji)
|
accountType, color, emoji)
|
||||||
else:
|
else:
|
||||||
var finalPassword = password
|
var finalPassword = password
|
||||||
if doPasswordHashing:
|
if doPasswordHashing:
|
||||||
finalPassword = utils.hashPassword(password)
|
finalPassword = utils.hashPassword(password)
|
||||||
response = status_go_accounts.addAccount(finalPassword, name, address, path, publicKey, keyUid, accountType,
|
response = status_go_accounts.addAccount(finalPassword, name, address, path, publicKey, keyUid, accountType,
|
||||||
color, emoji)
|
color, emoji)
|
||||||
if not response.error.isNil:
|
if not response.error.isNil:
|
||||||
error "status-go error", procName="addWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
error "status-go error", procName="addWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
||||||
|
@ -451,7 +451,7 @@ QtObject:
|
||||||
return e.msg
|
return e.msg
|
||||||
|
|
||||||
## Mandatory fields for account: `address`, `keyUid`, `walletType`, `path`, `publicKey`, `name`, `emoji`, `color`
|
## Mandatory fields for account: `address`, `keyUid`, `walletType`, `path`, `publicKey`, `name`, `emoji`, `color`
|
||||||
proc addNewPrivateKeyKeypair*(self: Service, privateKey, password: string, doPasswordHashing: bool,
|
proc addNewPrivateKeyKeypair*(self: Service, privateKey, password: string, doPasswordHashing: bool,
|
||||||
keyUid, keypairName, rootWalletMasterKey: string, account: WalletAccountDto): string =
|
keyUid, keypairName, rootWalletMasterKey: string, account: WalletAccountDto): string =
|
||||||
if password.len == 0:
|
if password.len == 0:
|
||||||
error "for adding new private key account, password must be provided"
|
error "for adding new private key account, password must be provided"
|
||||||
|
@ -475,13 +475,13 @@ QtObject:
|
||||||
return e.msg
|
return e.msg
|
||||||
|
|
||||||
## Mandatory fields for all accounts: `address`, `keyUid`, `walletType`, `path`, `publicKey`, `name`, `emoji`, `color`
|
## Mandatory fields for all accounts: `address`, `keyUid`, `walletType`, `path`, `publicKey`, `name`, `emoji`, `color`
|
||||||
proc addNewSeedPhraseKeypair*(self: Service, seedPhrase, password: string, doPasswordHashing: bool,
|
proc addNewSeedPhraseKeypair*(self: Service, seedPhrase, password: string, doPasswordHashing: bool,
|
||||||
keyUid, keypairName, rootWalletMasterKey: string, accounts: seq[WalletAccountDto]): string =
|
keyUid, keypairName, rootWalletMasterKey: string, accounts: seq[WalletAccountDto]): string =
|
||||||
var finalPassword = password
|
var finalPassword = password
|
||||||
if password.len > 0 and doPasswordHashing:
|
if password.len > 0 and doPasswordHashing:
|
||||||
finalPassword = utils.hashPassword(password)
|
finalPassword = utils.hashPassword(password)
|
||||||
try:
|
try:
|
||||||
if seedPhrase.len > 0 and password.len > 0:
|
if seedPhrase.len > 0 and password.len > 0:
|
||||||
let response = status_go_accounts.importMnemonic(seedPhrase, finalPassword)
|
let response = status_go_accounts.importMnemonic(seedPhrase, finalPassword)
|
||||||
if not response.error.isNil:
|
if not response.error.isNil:
|
||||||
error "status-go error importing private key", procName="addNewSeedPhraseKeypair", errCode=response.error.code, errDesription=response.error.message
|
error "status-go error importing private key", procName="addNewSeedPhraseKeypair", errCode=response.error.code, errDesription=response.error.message
|
||||||
|
@ -516,7 +516,7 @@ QtObject:
|
||||||
return
|
return
|
||||||
self.removeAccountFromLocalStoreAndNotify(address)
|
self.removeAccountFromLocalStoreAndNotify(address)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="deleteAccount", errName = e.name, errDesription = e.msg
|
error "error: ", procName="deleteAccount", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
proc getCurrency*(self: Service): string =
|
proc getCurrency*(self: Service): string =
|
||||||
return self.settingsService.getCurrency()
|
return self.settingsService.getCurrency()
|
||||||
|
@ -542,7 +542,7 @@ QtObject:
|
||||||
return false
|
return false
|
||||||
try:
|
try:
|
||||||
var account = self.getAccountByAddress(address)
|
var account = self.getAccountByAddress(address)
|
||||||
let response = status_go_accounts.updateAccount(accountName, account.address, account.path, account.publicKey,
|
let response = status_go_accounts.updateAccount(accountName, account.address, account.path, account.publicKey,
|
||||||
account.keyUid, account.walletType, color, emoji, account.isWallet, account.isChat)
|
account.keyUid, account.walletType, color, emoji, account.isWallet, account.isChat)
|
||||||
if not response.error.isNil:
|
if not response.error.isNil:
|
||||||
error "status-go error", procName="updateWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
error "status-go error", procName="updateWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
||||||
|
@ -697,7 +697,7 @@ QtObject:
|
||||||
let accounts = self.getWalletAccounts()
|
let accounts = self.getWalletAccounts()
|
||||||
for walletAccount in accounts:
|
for walletAccount in accounts:
|
||||||
result += walletAccount.getCurrencyBalance(@[network.chainId], self.getCurrentCurrencyIfEmpty(currency))
|
result += walletAccount.getCurrencyBalance(@[network.chainId], self.getCurrentCurrencyIfEmpty(currency))
|
||||||
|
|
||||||
proc findTokenSymbolByAddress*(self: Service, address: string): string =
|
proc findTokenSymbolByAddress*(self: Service, address: string): string =
|
||||||
return self.tokenService.findTokenSymbolByAddress(address)
|
return self.tokenService.findTokenSymbolByAddress(address)
|
||||||
|
|
||||||
|
@ -736,7 +736,7 @@ QtObject:
|
||||||
|
|
||||||
proc emitAddKeycardAddAccountsChange(self: Service, success: bool, keycard: KeycardDto) =
|
proc emitAddKeycardAddAccountsChange(self: Service, success: bool, keycard: KeycardDto) =
|
||||||
let data = KeycardActivityArgs(
|
let data = KeycardActivityArgs(
|
||||||
success: success,
|
success: success,
|
||||||
keycard: keycard
|
keycard: keycard
|
||||||
)
|
)
|
||||||
self.events.emit(SIGNAL_NEW_KEYCARD_SET, data)
|
self.events.emit(SIGNAL_NEW_KEYCARD_SET, data)
|
||||||
|
@ -780,10 +780,10 @@ QtObject:
|
||||||
)
|
)
|
||||||
self.threadpool.start(arg)
|
self.threadpool.start(arg)
|
||||||
|
|
||||||
proc emitKeycardRemovedAccountsChange(self: Service, success: bool, keyUid: string, keycardUid: string,
|
proc emitKeycardRemovedAccountsChange(self: Service, success: bool, keyUid: string, keycardUid: string,
|
||||||
removedAccounts: seq[string]) =
|
removedAccounts: seq[string]) =
|
||||||
let data = KeycardActivityArgs(
|
let data = KeycardActivityArgs(
|
||||||
success: success,
|
success: success,
|
||||||
keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: removedAccounts)
|
keycard: KeycardDto(keyUid: keyUid, keycardUid: keycardUid, accountsAddresses: removedAccounts)
|
||||||
)
|
)
|
||||||
self.events.emit(SIGNAL_KEYCARD_ACCOUNTS_REMOVED, data)
|
self.events.emit(SIGNAL_KEYCARD_ACCOUNTS_REMOVED, data)
|
||||||
|
@ -803,7 +803,7 @@ QtObject:
|
||||||
error "error handilng migrated keycard response", errDesription=e.msg
|
error "error handilng migrated keycard response", errDesription=e.msg
|
||||||
self.emitKeycardRemovedAccountsChange(success = false, keyUid = "", keycardUid = "", removedAccounts = @[])
|
self.emitKeycardRemovedAccountsChange(success = false, keyUid = "", keycardUid = "", removedAccounts = @[])
|
||||||
|
|
||||||
proc getAllKnownKeycards*(self: Service): seq[KeycardDto] =
|
proc getAllKnownKeycards*(self: Service): seq[KeycardDto] =
|
||||||
try:
|
try:
|
||||||
let response = backend.getAllKnownKeycards()
|
let response = backend.getAllKnownKeycards()
|
||||||
if responseHasNoErrors("getAllKnownKeycards", response):
|
if responseHasNoErrors("getAllKnownKeycards", response):
|
||||||
|
@ -811,7 +811,7 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="getAllKnownKeycards", errName = e.name, errDesription = e.msg
|
error "error: ", procName="getAllKnownKeycards", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
proc getKeycardWithKeycardUid*(self: Service, keycardUid: string): KeycardDto =
|
proc getKeycardWithKeycardUid*(self: Service, keycardUid: string): KeycardDto =
|
||||||
let allKnownKeycards = self.getAllKnownKeycards()
|
let allKnownKeycards = self.getAllKnownKeycards()
|
||||||
let keycardsWithKeycardUid = allKnownKeycards.filter(kp => kp.keycardUid == keycardUid)
|
let keycardsWithKeycardUid = allKnownKeycards.filter(kp => kp.keycardUid == keycardUid)
|
||||||
if keycardsWithKeycardUid.len == 0:
|
if keycardsWithKeycardUid.len == 0:
|
||||||
|
@ -821,7 +821,7 @@ QtObject:
|
||||||
return
|
return
|
||||||
return keycardsWithKeycardUid[0]
|
return keycardsWithKeycardUid[0]
|
||||||
|
|
||||||
proc getAllKnownKeycardsGroupedByKeyUid*(self: Service): seq[KeycardDto] =
|
proc getAllKnownKeycardsGroupedByKeyUid*(self: Service): seq[KeycardDto] =
|
||||||
try:
|
try:
|
||||||
let response = backend.getAllKnownKeycardsGroupedByKeyUid()
|
let response = backend.getAllKnownKeycardsGroupedByKeyUid()
|
||||||
if responseHasNoErrors("getAllKnownKeycardsGroupedByKeyUid", response):
|
if responseHasNoErrors("getAllKnownKeycardsGroupedByKeyUid", response):
|
||||||
|
@ -829,7 +829,7 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="getAllKnownKeycardsGroupedByKeyUid", errName = e.name, errDesription = e.msg
|
error "error: ", procName="getAllKnownKeycardsGroupedByKeyUid", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
proc getKeycardByKeyUid*(self: Service, keyUid: string): seq[KeycardDto] =
|
proc getKeycardByKeyUid*(self: Service, keyUid: string): seq[KeycardDto] =
|
||||||
try:
|
try:
|
||||||
let response = backend.getKeycardByKeyUid(keyUid)
|
let response = backend.getKeycardByKeyUid(keyUid)
|
||||||
if responseHasNoErrors("getKeycardByKeyUid", response):
|
if responseHasNoErrors("getKeycardByKeyUid", response):
|
||||||
|
@ -837,6 +837,15 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "error: ", procName="getKeycardByKeyUid", errName = e.name, errDesription = e.msg
|
error "error: ", procName="getKeycardByKeyUid", errName = e.name, errDesription = e.msg
|
||||||
|
|
||||||
|
proc isKeycardAccount*(self: Service, account: WalletAccountDto): bool =
|
||||||
|
if account.isNil or
|
||||||
|
account.keyUid.len == 0 or
|
||||||
|
account.path.len == 0 or
|
||||||
|
utils.isPathOutOfTheDefaultStatusDerivationTree(account.path):
|
||||||
|
return false
|
||||||
|
let keycards = self.getKeycardByKeyUid(account.keyUid)
|
||||||
|
return keycards.len > 0
|
||||||
|
|
||||||
proc emitKeycardNameChange(self: Service, keycardUid: string, name: string) =
|
proc emitKeycardNameChange(self: Service, keycardUid: string, name: string) =
|
||||||
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keycardUid: keycardUid, keycardName: name))
|
let data = KeycardActivityArgs(success: true, keycard: KeycardDto(keycardUid: keycardUid, keycardName: name))
|
||||||
self.events.emit(SIGNAL_KEYCARD_NAME_CHANGED, data)
|
self.events.emit(SIGNAL_KEYCARD_NAME_CHANGED, data)
|
||||||
|
@ -914,7 +923,7 @@ QtObject:
|
||||||
|
|
||||||
proc handleKeycardActions(self: Service, keycardActions: seq[KeycardActionDto]) =
|
proc handleKeycardActions(self: Service, keycardActions: seq[KeycardActionDto]) =
|
||||||
if keycardActions.len == 0:
|
if keycardActions.len == 0:
|
||||||
return
|
return
|
||||||
for kcAction in keycardActions:
|
for kcAction in keycardActions:
|
||||||
if kcAction.action == KeycardActionKeycardAdded or
|
if kcAction.action == KeycardActionKeycardAdded or
|
||||||
kcAction.action == KeycardActionAccountsAdded:
|
kcAction.action == KeycardActionAccountsAdded:
|
||||||
|
@ -951,4 +960,4 @@ QtObject:
|
||||||
if token.symbol == symbol:
|
if token.symbol == symbol:
|
||||||
totalTokenBalance += token.getTotalBalanceOfSupportedChains()
|
totalTokenBalance += token.getTotalBalanceOfSupportedChains()
|
||||||
|
|
||||||
return totalTokenBalance
|
return totalTokenBalance
|
||||||
|
|
|
@ -238,7 +238,7 @@ Rectangle {
|
||||||
width: !!icon ? 15: 0
|
width: !!icon ? 15: 0
|
||||||
height: !!icon ? 15: 0
|
height: !!icon ? 15: 0
|
||||||
color: Theme.palette.directColor1
|
color: Theme.palette.directColor1
|
||||||
icon: model.migratedToKeycard ? "keycard" : ""
|
icon: model.keycardAccount ? "keycard" : ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue