feat(@desktop/wallet): Include watch only per account

fixes #12305
This commit is contained in:
Khushboo Mehta 2023-10-10 17:46:43 +02:00 committed by Khushboo-dev-cpp
parent 2c5eeea503
commit bc85bc8cd3
53 changed files with 219 additions and 234 deletions

View File

@ -447,10 +447,6 @@ proc connectForNotificationsOnly[T](self: Module[T]) =
let args = NetworkEndpointUpdatedArgs(e)
self.view.showNetworkEndpointUpdated(args.networkName, args.isTest, args.revertedToDefault)
self.events.on(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED) do(e: Args):
let args = SettingsBoolValueArgs(e)
self.view.showIncludeWatchOnlyAccountUpdated(args.value)
self.events.on(SIGNAL_KEYPAIR_DELETED) do(e: Args):
let args = KeypairArgs(e)
self.view.showToastKeypairRemoved(args.keyPairName)

View File

@ -52,12 +52,6 @@ proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
proc getKeypairs*(self: Controller): seq[KeypairDto] =
return self.walletAccountService.getKeypairs()
proc toggleIncludeWatchOnlyAccount*(self: Controller) =
self.walletAccountService.toggleIncludeWatchOnlyAccount()
proc isIncludeWatchOnlyAccount*(self: Controller): bool =
return self.walletAccountService.isIncludeWatchOnlyAccount()
proc getEnabledChainIds*(self: Controller): seq[int] =
return self.walletAccountService.getEnabledChainIds()
@ -78,3 +72,6 @@ proc areTestNetworksEnabled*(self: Controller): bool =
proc getCurrencyBalance*(self: Controller, address: string, chainIds: seq[int], currency: string): float64 =
return self.walletAccountService.getCurrencyBalance(address, chainIds, currency)
proc updateWatchAccountHiddenFromTotalBalance*(self: Controller, address: string, hideFromTotalBalance: bool) =
discard self.walletAccountService.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -46,11 +46,11 @@ method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
method getCollectiblesModel*(self: AccessInterface): QVariant {.base.} =
raise newException(ValueError, "No implementation available")
method toggleIncludeWatchOnlyAccount*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountProdPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWatchAccountHiddenFromTotalBalance*(self: AccessInterface, address: string, hideFromTotalBalance: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -79,7 +79,8 @@ method convertWalletAccountDtoToKeyPairAccountItem(self: Module, account: Wallet
isDefaultAccount = account.isWallet,
self.controller.areTestNetworksEnabled(),
prodPreferredChainIds = account.prodPreferredChainIds,
testPreferredChainIds = account.testPreferredChainIds)
testPreferredChainIds = account.testPreferredChainIds,
hideFromTotalBalance = account.hideFromTotalBalance)
method setBalance(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) =
let enabledChainIds = self.controller.getEnabledChainIds()
@ -179,17 +180,16 @@ method load*(self: Module) =
self.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args):
self.refreshWalletAccounts()
self.events.on(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED) do(e: Args):
let args = SettingsBoolValueArgs(e)
self.view.setIncludeWatchOnlyAccount(args.value)
self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e: Args):
let args = AccountArgs(e)
self.view.onPreferredSharingChainsUpdated(args.account.keyUid, args.account.address, args.account.prodPreferredChainIds, args.account.testPreferredChainIds)
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
let args = AccountArgs(e)
self.view.onHideFromTotalBalanceUpdated(args.account.keyUid, args.account.address, args.account.hideFromTotalBalance)
self.controller.init()
self.view.load()
self.view.setIncludeWatchOnlyAccount(self.controller.isIncludeWatchOnlyAccount())
method isLoaded*(self: Module): bool =
return self.moduleLoaded
@ -211,9 +211,6 @@ method deleteAccount*(self: Module, address: string) =
method deleteKeypair*(self: Module, keyUid: string) =
self.controller.deleteKeypair(keyUid)
method toggleIncludeWatchOnlyAccount*(self: Module) =
self.controller.toggleIncludeWatchOnlyAccount()
method renameKeypair*(self: Module, keyUid: string, name: string) =
self.controller.renameKeypair(keyUid, name)
@ -225,3 +222,6 @@ method updateWalletAccountProdPreferredChains*(self: Module, address, preferredC
method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds)
method updateWatchAccountHiddenFromTotalBalance*(self: Module, address: string, hideFromTotalBalance: bool) =
self.controller.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -13,7 +13,6 @@ QtObject:
accounts: Model
accountsVariant: QVariant
keyPairModel: KeyPairModel
includeWatchOnlyAccount: bool
proc delete*(self: View) =
self.accounts.delete
@ -57,6 +56,9 @@ QtObject:
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
proc onHideFromTotalBalanceUpdated*(self: View, keyUid, address: string, hideFromTotalBalance: bool) =
self.keyPairModel.onHideFromTotalBalanceUpdated(keyUid, address, hideFromTotalBalance)
proc deleteAccount*(self: View, address: string) {.slot.} =
self.delegate.deleteAccount(address)
@ -77,20 +79,6 @@ QtObject:
self.keyPairModel.setItems(items)
self.keyPairModelChanged()
proc includeWatchOnlyAccountChanged*(self: View) {.signal.}
proc getIncludeWatchOnlyAccount(self: View): bool {.slot.} =
return self.includeWatchOnlyAccount
QtProperty[bool] includeWatchOnlyAccount:
read = getIncludeWatchOnlyAccount
notify = includeWatchOnlyAccountChanged
proc toggleIncludeWatchOnlyAccount*(self: View) {.slot.} =
self.delegate.toggleIncludeWatchOnlyAccount()
proc setIncludeWatchOnlyAccount*(self: View, includeWatchOnlyAccount: bool) =
self.includeWatchOnlyAccount = includeWatchOnlyAccount
self.includeWatchOnlyAccountChanged()
proc keypairNameExists*(self: View, name: string): bool {.slot.} =
return self.keyPairModel.keypairNameExists(name)
@ -111,3 +99,6 @@ QtObject:
proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) =
self.keyPairModel.setBalanceForAddress(address, balance)
proc updateWatchAccountHiddenFromTotalBalance*(self: View, address: string, hideFromTotalBalance: bool) {.slot.} =
self.delegate.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -293,7 +293,6 @@ QtObject:
proc showToastAccountAdded*(self: View, name: string) {.signal.}
proc showToastKeypairRenamed*(self: View, oldName: string, newName: string) {.signal.}
proc showNetworkEndpointUpdated*(self: View, name: string, isTest: bool, revertedToDefault: bool) {.signal.}
proc showIncludeWatchOnlyAccountUpdated*(self: View, includeWatchOnly: bool) {.signal.}
proc showToastKeypairRemoved*(self: View, keypairName: string) {.signal.}
proc showToastKeypairsImported*(self: View, keypairName: string, keypairsCount: int, error: string) {.signal.}
proc showToastTransactionSent*(self: View, chainId: int, txHash: string, uuid: string, error: string) {.signal.}

View File

@ -70,3 +70,6 @@ proc areTestNetworksEnabled*(self: Controller): bool =
proc getCurrencyBalance*(self: Controller, address: string, chainIds: seq[int], currency: string): float64 =
return self.walletAccountService.getCurrencyBalance(address, chainIds, currency)
proc updateWatchAccountHiddenFromTotalBalance*(self: Controller, address: string, hideFromTotalBalance: bool) =
discard self.walletAccountService.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -36,3 +36,6 @@ method updateWalletAccountProdPreferredChains*(self: AccessInterface, address, p
method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWatchAccountHiddenFromTotalBalance*(self: AccessInterface, address: string, hideFromTotalBalance: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -27,7 +27,8 @@ proc initItem*(
isWallet: bool = false,
areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "",
testPreferredChainIds: string = ""
testPreferredChainIds: string = "",
hideFromTotalBalance: bool = false
): Item =
result = Item()
result.WalletAccountItem.setup(name,
@ -42,7 +43,8 @@ proc initItem*(
operability = wa_dto.AccountFullyOperable,
areTestNetworksEnabled,
prodPreferredChainIds,
testPreferredChainIds)
testPreferredChainIds,
hideFromTotalBalance)
result.createdAt = createdAt
result.assetsLoading = assetsLoading
result.currencyBalance = currencyBalance

View File

@ -19,7 +19,8 @@ type
KeycardAccount,
AssetsLoading,
IsWallet,
PreferredSharingChainIds
PreferredSharingChainIds,
HideFromTotalBalance
QtObject:
type
@ -69,7 +70,8 @@ QtObject:
ModelRole.KeycardAccount.int: "keycardAccount",
ModelRole.AssetsLoading.int: "assetsLoading",
ModelRole.IsWallet.int: "isWallet",
ModelRole.PreferredSharingChainIds.int: "preferredSharingChainIds"
ModelRole.PreferredSharingChainIds.int: "preferredSharingChainIds",
ModelRole.HideFromTotalBalance.int: "hideFromTotalBalance"
}.toTable
@ -121,6 +123,8 @@ QtObject:
result = newQVariant(item.isWallet())
of ModelRole.PreferredSharingChainIds:
result = newQVariant(item.preferredSharingChainIds())
of ModelRole.HideFromTotalBalance:
result = newQVariant(item.hideFromTotalBalance())
proc getNameByAddress*(self: Model, address: string): string =
for item in self.items:
@ -144,4 +148,4 @@ QtObject:
for item in self.items:
if cmpIgnoreCase(item.address(), address) == 0 and item.walletType != "watch":
return true
return false
return false

View File

@ -83,3 +83,6 @@ method updateWalletAccountProdPreferredChains*(self: Module, address, preferredC
method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds)
method updateWatchAccountHiddenFromTotalBalance*(self: Module, address: string, hideFromTotalBalance: bool) =
self.controller.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -63,3 +63,6 @@ QtObject:
proc updateWalletAccountTestPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountTestPreferredChains(address, preferredChainIds)
proc updateWatchAccountHiddenFromTotalBalance*(self: View, address: string, hideFromTotalBalance: bool) {.slot.} =
self.delegate.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -63,14 +63,8 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)
proc toggleIncludeWatchOnlyAccount*(self: Controller) =
self.walletAccountService.toggleIncludeWatchOnlyAccount()
proc isIncludeWatchOnlyAccount*(self: Controller): bool =
return self.walletAccountService.isIncludeWatchOnlyAccount()
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
return self.walletAccountService.getKeypairByAccountAddress(address)
proc hasPairedDevices*(self: Controller): bool =
return self.walletAccountService.hasPairedDevices()
return self.walletAccountService.hasPairedDevices()

View File

@ -27,17 +27,11 @@ proc `$`*(self: Filter): string =
proc setFillterAllAddresses*(self: Filter) =
self.allAddresses = true
self.addresses = self.controller.getWalletAccounts().map(a => a.address)
proc toggleWatchOnlyAccounts*(self: Filter) =
self.controller.toggleIncludeWatchOnlyAccount()
proc includeWatchOnlyToggled*(self: Filter) =
let includeWatchOnly = self.controller.isIncludeWatchOnlyAccount()
if includeWatchOnly:
self.setFillterAllAddresses()
else:
self.addresses = self.controller.getWalletAccounts().filter(a => a.walletType != "watch").map(a => a.address)
var allAccounts = self.controller.getWalletAccounts()
var accountsExclWatchAccs = allAccounts.filter(a => not a.hideFromTotalBalance)
if allAccounts.len != accountsExclWatchAccs.len:
self.allAddresses = false
self.addresses = self.controller.getWalletAccounts().filter(a => not a.hideFromTotalBalance).map(a => a.address)
proc setAddress*(self: Filter, address: string) =
self.allAddresses = false
@ -58,5 +52,5 @@ proc updateNetworks*(self: Filter) =
self.allChainsEnabled = (self.chainIds.len == self.controller.getNetworks().len)
proc load*(self: Filter) =
self.includeWatchOnlyToggled()
self.updateNetworks()
self.setFillterAllAddresses()
self.updateNetworks()

View File

@ -21,9 +21,6 @@ method setFilterAddress*(self: AccessInterface, address: string) {.base.} =
method setFillterAllAddresses*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleWatchOnlyAccounts*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
raise newException(ValueError, "No implementation available")
@ -116,4 +113,4 @@ method destroyKeypairImportPopup*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method hasPairedDevices*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
raise newException(ValueError, "No implementation available")

View File

@ -163,32 +163,23 @@ method getCurrentCurrency*(self: Module): string =
self.controller.getCurrency()
method setTotalCurrencyBalance*(self: Module) =
var addresses: seq[string] = @[]
let walletAccounts = self.controller.getWalletAccounts()
if self.controller.isIncludeWatchOnlyAccount():
addresses = walletAccounts.map(a => a.address)
else:
addresses = walletAccounts.filter(a => a.walletType != "watch").map(a => a.address)
var addresses = walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address)
self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance(addresses))
method notifyFilterChanged(self: Module) =
let includeWatchOnly = self.controller.isIncludeWatchOnlyAccount()
self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds, includeWatchOnly, self.filter.allAddresses)
self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds, self.filter.allAddresses)
self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
self.accountsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
self.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds)
self.activityController.globalFilterChanged(self.filter.addresses, self.filter.allAddresses, self.filter.chainIds, self.filter.allChainsEnabled)
self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
if self.filter.addresses.len > 0:
self.view.filterChanged(self.filter.addresses[0], includeWatchOnly, self.filter.allAddresses)
self.view.filterChanged(self.filter.addresses[0], self.filter.allAddresses)
method getCurrencyAmount*(self: Module, amount: float64, symbol: string): CurrencyAmount =
return self.controller.getCurrencyAmount(amount, symbol)
method toggleWatchOnlyAccounts*(self: Module) =
self.filter.toggleWatchOnlyAccounts()
method setFilterAddress*(self: Module, address: string) =
let keypair = self.controller.getKeypairByAccountAddress(address)
if keypair.isNil:
@ -247,10 +238,6 @@ method load*(self: Module) =
self.notifyFilterChanged()
self.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args):
self.notifyFilterChanged()
self.events.on(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED) do(e: Args):
self.filter.includeWatchOnlyToggled()
self.notifyFilterChanged()
self.setTotalCurrencyBalance()
self.events.on(SIGNAL_HISTORY_NON_ARCHIVAL_NODE) do (e:Args):
self.view.setIsNonArchivalNode(true)
self.events.on(SIGNAL_TRANSACTION_DECODED) do(e: Args):
@ -263,7 +250,11 @@ method load*(self: Module) =
self.onUpdatedKeypairsOperability(args.keypairs)
self.events.on(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e:Args):
let data = LocalPairingStatus(e)
self.onLocalPairingStatusUpdate(data)
self.onLocalPairingStatusUpdate(data)
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
self.filter.setFillterAllAddresses()
self.notifyFilterChanged()
self.setTotalCurrencyBalance()
self.controller.init()
self.view.load()
@ -428,4 +419,4 @@ method hasPairedDevices*(self: Module): bool =
proc onLocalPairingStatusUpdate*(self: Module, data: LocalPairingStatus) =
if data.state == LocalPairingState.Finished:
self.view.emitHasPairedDevicesChangedSignal()
self.view.emitHasPairedDevicesChangedSignal()

View File

@ -17,5 +17,5 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method filterChanged*(self: AccessInterface, addresses: seq[string], chainIds: seq[int], includeWatchOnly: bool, allAddresses: bool) {.base.} =
method filterChanged*(self: AccessInterface, addresses: seq[string], chainIds: seq[int], allAddresses: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -10,7 +10,6 @@ type
emoji: string
isWatchOnlyAccount: bool
isAllAccounts: bool
includeWatchOnly: bool
colorIds: seq[string]
proc initItem*(
@ -22,7 +21,6 @@ proc initItem*(
emoji: string,
isWatchOnlyAccount: bool=false,
isAllAccounts: bool = false,
includeWatchOnly: bool = true,
colorIds: seq[string] = @[]
): Item =
result.name = name
@ -32,7 +30,6 @@ proc initItem*(
result.colorId = colorId
result.emoji = emoji
result.isAllAccounts = isAllAccounts
result.includeWatchOnly = includeWatchOnly
result.colorIds = colorIds
result.isWatchOnlyAccount = isWatchOnlyAccount
@ -46,7 +43,6 @@ proc `$`*(self: Item): string =
emoji: {self.emoji},
isWatchOnlyAccount: {self.isWatchOnlyAccount},
isAllAccounts: {self.isAllAccounts},
includeWatchOnly: {self.includeWatchOnly},
colorIds: {self.colorIds}
]"""
@ -71,9 +67,6 @@ proc getEmoji*(self: Item): string =
proc getIsAllAccounts*(self: Item): bool =
return self.isAllAccounts
proc getIncludeWatchOnly*(self: Item): bool =
return self.includeWatchOnly
proc getColorIds*(self: Item): string =
return self.colorIds.join(";")

View File

@ -65,7 +65,7 @@ proc getWalletAccoutColors(self: Module, walletAccounts: seq[WalletAccountDto])
colors.add(account.colorId)
return colors
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int], includeWatchOnly: bool, allAddresses: bool) =
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int], allAddresses: bool) =
let walletAccounts = self.controller.getWalletAccountsByAddresses(addresses)
if allAddresses:
let item = initItem(
@ -77,7 +77,6 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int],
"",
isWatchOnlyAccount=false,
isAllAccounts=true,
includeWatchOnly=includeWatchOnly,
self.getWalletAccoutColors(walletAccounts)
)
self.view.setData(item)

View File

@ -17,7 +17,6 @@ QtObject:
colorId: string
emoji: string
isAllAccounts: bool
includeWatchOnly: bool
colorIds: string
isWatchOnlyAccount: bool
@ -99,13 +98,6 @@ QtObject:
read = getIsAllAccounts
notify = isAllAccountsChanged
proc getIncludeWatchOnly(self: View): QVariant {.slot.} =
return newQVariant(self.includeWatchOnly)
proc includeWatchOnlyChanged(self: View) {.signal.}
QtProperty[QVariant] includeWatchOnly:
read = getIncludeWatchOnly
notify = includeWatchOnlyChanged
proc getColorIds(self: View): QVariant {.slot.} =
return newQVariant(self.colorIds)
proc colorIdsChanged(self: View) {.signal.}
@ -147,6 +139,3 @@ QtObject:
if(self.isAllAccounts != item.getIsAllAccounts()):
self.isAllAccounts = item.getIsAllAccounts()
self.isAllAccountsChanged()
if(self.includeWatchOnly != item.getIncludeWatchOnly()):
self.includeWatchOnly = item.getIncludeWatchOnly()
self.includeWatchOnlyChanged()

View File

@ -227,6 +227,9 @@ method load*(self: Module) =
self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e:Args):
self.refreshWalletAccounts()
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
self.refreshWalletAccounts()
self.controller.init()
self.view.load()

View File

@ -47,7 +47,7 @@ QtObject:
QtProperty[string] currentCurrency:
read = getCurrentCurrency
proc filterChanged*(self: View, addresses: string, includeWatchOnly: bool, allAddresses: bool) {.signal.}
proc filterChanged*(self: View, addresses: string, allAddresses: bool) {.signal.}
proc totalCurrencyBalanceChanged*(self: View) {.signal.}
@ -76,9 +76,6 @@ QtObject:
proc setFillterAllAddresses(self: View) {.slot.} =
self.delegate.setFillterAllAddresses()
proc toggleWatchOnlyAccounts(self: View) {.slot.} =
self.delegate.toggleWatchOnlyAccounts()
proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: CurrencyAmount) =
self.totalCurrencyBalance = totalCurrencyBalance
self.totalCurrencyBalanceChanged()
@ -205,4 +202,4 @@ QtObject:
proc destroyKeypairImportPopup*(self: View) {.signal.}
proc emitDestroyKeypairImportPopup*(self: View) =
self.destroyKeypairImportPopup()
self.destroyKeypairImportPopup()

View File

@ -48,7 +48,7 @@ proc buildKeypairItem*(keypair: KeypairDto, areTestNetworksEnabled: bool): KeyPa
icon = "wallet"
item.addAccount(newKeyPairAccountItem(acc.name, acc.path, acc.address, acc.publicKey, acc.emoji, acc.colorId,
icon, newCurrencyAmount(), balanceFetched = true, operability = acc.operable, acc.isWallet, areTestNetworksEnabled,
acc.prodPreferredChainIds, acc.testPreferredChainIds))
acc.prodPreferredChainIds, acc.testPreferredChainIds, acc.hideFromTotalBalance))
return item
proc buildKeyPairsList*(keypairs: seq[KeypairDto], excludeAlreadyMigratedPairs: bool,
@ -68,4 +68,4 @@ proc buildKeyPairsList*(keypairs: seq[KeypairDto], excludeAlreadyMigratedPairs:
items.add(item)
if items.len == 0:
debug "sm_there is no any key pair for the logged in user that is not already migrated to a keycard"
return items
return items

View File

@ -42,7 +42,8 @@ proc walletAccountToWalletAccountItem*(w: WalletAccountDto, keycardAccount: bool
w.operable,
areTestNetworksEnabled,
w.prodPreferredChainIds,
w.testPreferredChainIds
w.testPreferredChainIds,
w.hideFromTotalBalance
)
proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: bool,
@ -63,7 +64,8 @@ proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: boo
w.isWallet,
areTestNetworksEnabled,
w.prodPreferredChainIds,
w.testPreferredChainIds
w.testPreferredChainIds,
w.hideFromTotalBalance
)
proc walletAccountToWalletAssetsItem*(w: WalletAccountDto): wallet_assets_item.Item =

View File

@ -20,13 +20,14 @@ QtObject:
areTestNetworksEnabled: bool
prodPreferredChainIds: string
testPreferredChainIds: string
hideFromTotalBalance: bool
proc delete*(self: KeyPairAccountItem) =
self.QObject.delete
proc newKeyPairAccountItem*(name = "", path = "", address = "", pubKey = "", emoji = "", colorId = "", icon = "",
balance = newCurrencyAmount(), balanceFetched = true, operability = wa_dto.AccountFullyOperable,
isDefaultAccount = false, areTestNetworksEnabled =false, prodPreferredChainIds = "", testPreferredChainIds = ""): KeyPairAccountItem =
isDefaultAccount = false, areTestNetworksEnabled =false, prodPreferredChainIds = "", testPreferredChainIds = "", hideFromTotalBalance = false): KeyPairAccountItem =
new(result, delete)
result.QObject.setup
result.name = name
@ -43,6 +44,7 @@ QtObject:
result.areTestNetworksEnabled = areTestNetworksEnabled
result.prodPreferredChainIds = prodPreferredChainIds
result.testPreferredChainIds = testPreferredChainIds
result.hideFromTotalBalance = hideFromTotalBalance
proc `$`*(self: KeyPairAccountItem): string =
result = fmt"""KeyPairAccountItem[
@ -59,7 +61,8 @@ QtObject:
isDefaultAccount: {self.isDefaultAccount},
areTestNetworksEnabled: {self.areTestNetworksEnabled},
prodPreferredChainIds: {self.prodPreferredChainIds},
testPreferredChainIds: {self.testPreferredChainIds}
testPreferredChainIds: {self.testPreferredChainIds},
hideFromTotalBalance: {self.hideFromTotalBalance}
]"""
proc nameChanged*(self: KeyPairAccountItem) {.signal.}
@ -191,3 +194,13 @@ QtObject:
QtProperty[string] preferredSharingChainIds:
read = preferredSharingChainIds
notify = preferredSharingChainIdsChanged
proc hideFromTotalBalanceChanged*(self: KeyPairAccountItem) {.signal.}
proc hideFromTotalBalance*(self: KeyPairAccountItem): bool {.slot.} =
return self.hideFromTotalBalance
proc setHideFromTotalBalance*(self: KeyPairAccountItem, value: bool) =
self.hideFromTotalBalance = value
self.hideFromTotalBalanceChanged()
QtProperty[bool] hideFromTotalBalance:
read = hideFromTotalBalance
notify = hideFromTotalBalanceChanged

View File

@ -141,3 +141,8 @@ QtObject:
self.items[i].setProdPreferredChainIds(prodPreferredChainIds)
if testPreferredChainIds.len > 0:
self.items[i].setTestPreferredChainIds(testPreferredChainIds)
proc updateAccountHiddenInTotalBalance*(self: KeyPairAccountModel, address: string, hideFromTotalBalance: bool) =
for i in 0 ..< self.items.len:
if cmpIgnoreCase(self.items[i].getAddress(), address) == 0:
self.items[i].setHideFromTotalBalance(hideFromTotalBalance)

View File

@ -268,6 +268,8 @@ QtObject:
self.accounts.updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji)
proc updatePreferredSharingChainsForAddress*(self: KeyPairItem, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.accounts.updatePreferredSharingChainsForAddress(address, prodPreferredChainIds, testPreferredChainIds)
proc updateAccountHiddenInTotalBalance*(self: KeyPairItem, address: string, hideFromTotalBalance: bool) =
self.accounts.updateAccountHiddenInTotalBalance(address, hideFromTotalBalance)
proc setBalanceForAddress*(self: KeyPairItem, address: string, balance: CurrencyAmount) =
self.accounts.setBalanceForAddress(address, balance)
proc updateOperabilityForAllAddresses*(self: KeyPairItem, operability: string) =

View File

@ -88,12 +88,18 @@ QtObject:
item.updateOperabilityForAllAddresses(operability)
break
proc onPreferredSharingChainsUpdated*(self: KeyPairModel,keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
proc onPreferredSharingChainsUpdated*(self: KeyPairModel, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
for item in self.items:
if keyUid == item.getKeyUid():
item.getAccountsModel().updatePreferredSharingChainsForAddress(address, prodPreferredChainIds, testPreferredChainIds)
break
proc onHideFromTotalBalanceUpdated*(self: KeyPairModel, keyUid, address: string, hideFromTotalBalance: bool) =
for item in self.items:
if keyUid == item.getKeyUid():
item.getAccountsModel().updateAccountHiddenInTotalBalance(address, hideFromTotalBalance)
break
proc keypairNameExists*(self: KeyPairModel, name: string): bool =
return self.items.any(x => x.getName() == name)

View File

@ -18,6 +18,7 @@ QtObject:
areTestNetworksEnabled: bool
prodPreferredChainIds: string
testPreferredChainIds: string
hideFromTotalBalance: bool
proc setup*(self: WalletAccountItem,
name: string = "",
@ -32,7 +33,8 @@ QtObject:
operability: string = wa_dto.AccountFullyOperable,
areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "",
testPreferredChainIds: string = ""
testPreferredChainIds: string = "",
hideFromTotalBalance: bool = true
) =
self.QObject.setup
self.name = name
@ -48,6 +50,7 @@ QtObject:
self.areTestNetworksEnabled = areTestNetworksEnabled
self.prodPreferredChainIds = prodPreferredChainIds
self.testPreferredChainIds = testPreferredChainIds
self.hideFromTotalBalance = hideFromTotalBalance
proc delete*(self: WalletAccountItem) =
self.QObject.delete
@ -65,7 +68,8 @@ QtObject:
operability: string = wa_dto.AccountFullyOperable,
areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "",
testPreferredChainIds: string = ""): WalletAccountItem =
testPreferredChainIds: string = "",
hideFromTotalBalance: bool = true): WalletAccountItem =
new(result, delete)
result.QObject.setup
result.name = name
@ -81,6 +85,7 @@ QtObject:
result.areTestNetworksEnabled = areTestNetworksEnabled
result.prodPreferredChainIds = prodPreferredChainIds
result.testPreferredChainIds = testPreferredChainIds
result.hideFromTotalBalance = hideFromTotalBalance
proc `$`*(self: WalletAccountItem): string =
result = fmt"""WalletAccountItem(
@ -97,6 +102,7 @@ QtObject:
areTestNetworksEnabled: {self.areTestNetworksEnabled},
prodPreferredChainIds: {self.prodPreferredChainIds},
testPreferredChainIds: {self.testPreferredChainIds},
hideFromTotalBalance: {self.hideFromTotalBalance}
]"""
proc nameChanged*(self: WalletAccountItem) {.signal.}
@ -198,3 +204,10 @@ QtObject:
QtProperty[string] preferredSharingChainIds:
read = preferredSharingChainIds
notify = preferredSharingChainIdsChanged
proc hideFromTotalBalanceChanged*(self: WalletAccountItem) {.signal.}
proc hideFromTotalBalance*(self: WalletAccountItem): bool {.slot.} =
return self.hideFromTotalBalance
QtProperty[bool] hideFromTotalBalance:
read = hideFromTotalBalance
notify = hideFromTotalBalanceChanged

View File

@ -145,7 +145,7 @@ proc fetchDetailsForAddresses*(self: Controller, addresses: seq[string]) =
self.walletAccountService.fetchDetailsForAddresses(self.uniqueFetchingDetailsId, addresses)
proc addWalletAccount*(self: Controller, createKeystoreFile, doPasswordHashing: bool, name, address, path, publicKey,
keyUid, accountType, colorId, emoji: string): bool =
keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool): bool =
var password: string
if createKeystoreFile:
password = self.getPassword()
@ -153,7 +153,7 @@ proc addWalletAccount*(self: Controller, createKeystoreFile, doPasswordHashing:
info "cannot create keystore file if provided password is empty", name=name, address=address
return false
let err = self.walletAccountService.addWalletAccount(password, doPasswordHashing, name, address, path, publicKey,
keyUid, accountType, colorId, emoji)
keyUid, accountType, colorId, emoji, hideFromTotalBalance)
if err.len > 0:
info "adding wallet account failed", name=name, address=address
return false

View File

@ -599,6 +599,7 @@ proc doAddAccount[T](self: Module[T]) =
keyUid = selectedOrigin.getKeyUid()
createKeystoreFile = not selectedOrigin.getMigratedToKeycard()
doPasswordHashing = not singletonInstance.userProfile.getIsKeycardUser()
hideFromTotalBalance = false
if selectedOrigin.getPairType() == KeyPairType.Profile.int:
accountType = account_constants.GENERATED
@ -616,6 +617,7 @@ proc doAddAccount[T](self: Module[T]) =
addingNewKeyPair = not self.isKeyPairAlreadyAdded(keyUid)
else:
accountType = account_constants.WATCH
hideFromTotalBalance = true
createKeystoreFile = false
doPasswordHashing = false
keypairName = ""
@ -678,7 +680,8 @@ proc doAddAccount[T](self: Module[T]) =
keyUid = keyUid,
accountType = accountType,
colorId = self.view.getSelectedColorId(),
emoji = self.view.getSelectedEmoji())
emoji = self.view.getSelectedEmoji(),
hideFromTotalBalance = hideFromTotalBalance)
if not success:
error "failed to store account", address=selectedAddrItem.getAddress()

View File

@ -744,16 +744,6 @@ proc updateKeycardUid*(self: Controller, keyUid: string, keycardUid: string) =
self.tmpKeycardUid = keycardUid
info "update keycard uid failed", oldKeycardUid=self.tmpKeycardUid, newKeycardUid=keycardUid
proc addWalletAccount*(self: Controller, name, address, path, publicKey, keyUid, accountType, colorId, emoji: string): bool =
if not serviceApplicable(self.walletAccountService):
return false
let err = self.walletAccountService.addWalletAccount(password = "", doPasswordHashing = false, name, address, path,
publicKey, keyUid, accountType, colorId, emoji)
if err.len > 0:
info "adding wallet account failed", name=name, path=path
return false
return true
proc addNewSeedPhraseKeypair*(self: Controller, seedPhrase, keyUid, keypairName, rootWalletMasterKey: string,
accounts: seq[WalletAccountDto]): bool =
let err = self.walletAccountService.addNewSeedPhraseKeypair(seedPhrase, password = "", doPasswordHashing = false, keyUid,

View File

@ -45,7 +45,6 @@ const KEY_DISPLAY_NAME* = "display-name"
const KEY_BIO* = "bio"
const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?"
const KEY_IS_SEPOLIA_ENABLED* = "is-sepolia-enabled?"
const INCLUDE_WATCH_ONLY_ACCOUNT* = "include-watch-only-account?"
const PROFILE_MIGRATION_NEEDED* = "profile-migration-needed"
# Notifications Settings Values
@ -138,7 +137,6 @@ type
notificationsSoundsEnabled*: bool
notificationsVolume*: int
notificationsMessagePreview*: int
includeWatchOnlyAccount*: bool
profileMigrationNeeded*: bool
isSepoliaEnabled*: bool
@ -195,7 +193,6 @@ proc toSettingsDto*(jsonObj: JsonNode): SettingsDto =
discard jsonObj.getProp(KEY_GIF_FAVORITES, result.gifFavorites)
discard jsonObj.getProp(KEY_TEST_NETWORKS_ENABLED, result.testNetworksEnabled)
discard jsonObj.getProp(KEY_IS_SEPOLIA_ENABLED, result.isSepoliaEnabled)
discard jsonObj.getProp(INCLUDE_WATCH_ONLY_ACCOUNT, result.includeWatchOnlyAccount)
discard jsonObj.getProp(PROFILE_MIGRATION_NEEDED, result.profileMigrationNeeded)
var pinnedMailserverObj: JsonNode

View File

@ -27,7 +27,6 @@ const SIGNAL_BIO_UPDATED* = "bioUpdated"
const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved"
const SIGNAL_SOCIAL_LINKS_UPDATED* = "socialLinksUpdated"
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
const SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED* = "includeWatchOnlyAccounts"
const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated"
logScope:
@ -114,9 +113,6 @@ QtObject:
if settingsField.name == KEY_MNEMONIC:
self.settings.mnemonic = ""
self.events.emit(SIGNAL_MNEMONIC_REMOVED, Args())
if settingsField.name == INCLUDE_WATCH_ONLY_ACCOUNT:
self.settings.includeWatchOnlyAccount = settingsField.value.getBool
self.events.emit(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED, SettingsBoolValueArgs(value: self.settings.includeWatchOnlyAccount))
if settingsField.name == PROFILE_MIGRATION_NEEDED:
self.settings.profileMigrationNeeded = settingsField.value.getBool
self.events.emit(SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED, SettingsBoolValueArgs(value: self.settings.profileMigrationNeeded))
@ -984,14 +980,5 @@ QtObject:
error "error saving social links", errDescription=data.error
self.storeSocialLinksAndNotify(data)
proc isIncludeWatchOnlyAccount*(self: Service): bool =
return self.settings.includeWatchOnlyAccount
proc toggleIncludeWatchOnlyAccount*(self: Service) =
let newValue = not self.settings.includeWatchOnlyAccount
if(self.saveSetting(INCLUDE_WATCH_ONLY_ACCOUNT, newValue)):
self.settings.includeWatchOnlyAccount = newValue
self.events.emit(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED, SettingsBoolValueArgs(value: newValue))
proc getProfileMigrationNeeded*(self: Service): bool =
self.settings.profileMigrationNeeded
self.settings.profileMigrationNeeded

View File

@ -38,6 +38,7 @@ type
position*: int
prodPreferredChainIDs*: string
testPreferredChainIDs*: string
hideFromTotalBalance*: bool
proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
result = WalletAccountDto()
@ -59,6 +60,7 @@ proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
discard jsonObj.getProp("position", result.position)
discard jsonObj.getProp("prodPreferredChainIds", result.prodPreferredChainIds)
discard jsonObj.getProp("testPreferredChainIds", result.testPreferredChainIds)
discard jsonObj.getProp("hidden", result.hideFromTotalBalance)
result.assetsLoading = true
result.hasBalanceCache = false
result.hasMarketValuesCache = false
@ -81,5 +83,6 @@ proc `$`*(self: WalletAccountDto): string =
removed: {self.removed},
operable: {self.operable},
prodPreferredChainIds: {self.prodPreferredChainIds},
testPreferredChainIds: {self.testPreferredChainIds}
]"""
testPreferredChainIds: {self.testPreferredChainIds},
hideFromTotalBalance: {self.hideFromTotalBalance}
]"""

View File

@ -319,18 +319,18 @@ proc updatePreferredSharingChainsAndNotify(self: Service, address, prodPreferred
## if password is not provided local keystore file won't be created
proc addWalletAccount*(self: Service, password: string, doPasswordHashing: bool, name, address, path, publicKey,
keyUid, accountType, colorId, emoji: string): string =
keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool): string =
try:
var response: RpcResponse[JsonNode]
if password.len == 0:
response = status_go_accounts.addAccountWithoutKeystoreFileCreation(name, address, path, publicKey, keyUid,
accountType, colorId, emoji)
accountType, colorId, emoji, hideFromTotalBalance)
else:
var finalPassword = password
if doPasswordHashing:
finalPassword = utils.hashPassword(password)
response = status_go_accounts.addAccount(finalPassword, name, address, path, publicKey, keyUid, accountType,
colorId, emoji)
colorId, emoji, hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="addWalletAccount", errCode=response.error.code, errDesription=response.error.message
return response.error.message
@ -546,7 +546,7 @@ proc updateWalletAccount*(self: Service, address: string, accountName: string, c
error "account's address is not among known addresses: ", address=address, procName="updateWalletAccount"
return false
let response = status_go_accounts.updateAccount(accountName, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, colorId, emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, account.testPreferredChainIds)
account.keyUid, account.walletType, colorId, emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, account.testPreferredChainIds, account.hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWalletAccount", errCode=response.error.code, errDesription=response.error.message
return false
@ -563,7 +563,7 @@ proc updateWalletAccountProdPreferredChains*(self: Service, address, preferredCh
error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountProdPreferredChains"
return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, preferredChainIds, account.testPreferredChainIds)
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, preferredChainIds, account.testPreferredChainIds, account.hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWalletAccountProdPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false
@ -580,7 +580,7 @@ proc updateWalletAccountTestPreferredChains*(self: Service, address, preferredCh
error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountTestPreferredChains"
return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, preferredChainIds)
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, preferredChainIds, account.hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWalletAccountTestPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false
@ -590,6 +590,25 @@ proc updateWalletAccountTestPreferredChains*(self: Service, address, preferredCh
error "error: ", procName="updateWalletAccountTestPreferredChains", errName=e.name, errDesription=e.msg
return false
proc updateWatchAccountHiddenFromTotalBalance*(self: Service, address: string, hideFromTotalBalance: bool): bool =
try:
var account = self.getAccountByAddress(address)
if account.isNil:
error "account's address is not among known addresses: ", address=address, procName="updateWatchAccountHiddenFromTotalBalance"
return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, account.testPreferredChainIds, hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWatchAccountHiddenFromTotalBalance", errCode=response.error.code, errDesription=response.error.message
return false
if hideFromTotalBalance != account.hideFromTotalBalance:
account.hideFromTotalBalance = hideFromTotalBalance
self.events.emit(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED, AccountArgs(account: account))
return true
except Exception as e:
error "error: ", procName="updateWatchAccountHiddenFromTotalBalance", errName=e.name, errDesription=e.msg
return false
proc moveAccountFinally*(self: Service, fromPosition: int, toPosition: int) =
var updated = false
try:
@ -724,12 +743,6 @@ proc handleKeypair(self: Service, keypair: KeypairDto) =
# notify all interested parts about the keypair change
self.events.emit(SIGNAL_KEYPAIR_SYNCED, KeypairArgs(keypair: keypair))
proc isIncludeWatchOnlyAccount*(self: Service): bool =
return self.settingsService.isIncludeWatchOnlyAccount()
proc toggleIncludeWatchOnlyAccount*(self: Service) =
self.settingsService.toggleIncludeWatchOnlyAccount()
proc onFetchChainIdForUrl*(self: Service, jsonString: string) {.slot.} =
let response = parseJson(jsonString)
self.events.emit(SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED, ChainIdForUrlArgs(

View File

@ -21,6 +21,7 @@ const SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED* = "walletAccount/positionUpdated"
const SIGNAL_WALLET_ACCOUNT_OPERABILITY_UPDATED* = "walletAccount/operabilityUpdated"
const SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED* = "walletAccount/chainIdForUrlFetched"
const SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED* = "walletAccount/preferredSharingChainsUpdated"
const SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED* = "walletAccount/accountHiddenChanged"
const SIGNAL_KEYPAIR_SYNCED* = "keypairSynced"
const SIGNAL_KEYPAIR_NAME_CHANGED* = "keypairNameChanged"

View File

@ -41,7 +41,7 @@ proc deleteKeypair*(keyUid: string): RpcResponse[JsonNode] {.raises: [Exception]
return core.callPrivateRPC("accounts_deleteKeypair", payload)
## Adds a new account and creates a Keystore file if password is provided, otherwise it only creates a new account. Notifies paired devices.
proc addAccount*(password, name, address, path, publicKey, keyUid, accountType, colorId, emoji: string):
proc addAccount*(password, name, address, path, publicKey, keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool):
RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [
password,
@ -56,7 +56,7 @@ proc addAccount*(password, name, address, path, publicKey, keyUid, accountType,
"name": name,
"emoji": emoji,
"colorId": colorId,
#"hidden" present on the status-go side, but we don't use it
"hidden": hideFromTotalBalance
#"clock" we leave this empty, set on the status-go side
#"removed" present on the status-go side, used for synchronization, no need to set it here
}
@ -90,7 +90,7 @@ proc addKeypair*(password, keyUid, keypairName, keypairType, rootWalletMasterKey
"name": acc.name,
"emoji": acc.emoji,
"colorId": acc.colorId,
#"hidden" present on the status-go side, but we don't use it
"hidden": acc.hideFromTotalBalance
#"clock" we leave this empty, set on the status-go side
#"removed" present on the status-go side, used for synchronization, no need to set it here
}
@ -100,13 +100,13 @@ proc addKeypair*(password, keyUid, keypairName, keypairType, rootWalletMasterKey
return core.callPrivateRPC("accounts_addKeypair", payload)
## Adds a new account without creating a Keystore file and notifies paired devices
proc addAccountWithoutKeystoreFileCreation*(name, address, path, publicKey, keyUid, accountType, colorId, emoji: string):
proc addAccountWithoutKeystoreFileCreation*(name, address, path, publicKey, keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool):
RpcResponse[JsonNode] {.raises: [Exception].} =
return addAccount(password = "", name, address, path, publicKey, keyUid, accountType, colorId, emoji)
return addAccount(password = "", name, address, path, publicKey, keyUid, accountType, colorId, emoji, hideFromTotalBalance)
## Updates either regular or keycard account, without interaction to a Keystore file and notifies paired devices
proc updateAccount*(name, address, path: string, publicKey, keyUid, accountType, colorId, emoji: string,
walletDefaultAccount: bool, chatDefaultAccount: bool, prodPreferredChainIds, testPreferredChainIds: string):
walletDefaultAccount: bool, chatDefaultAccount: bool, prodPreferredChainIds, testPreferredChainIds: string, hideFromTotalBalance: bool):
RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [
{
@ -121,8 +121,8 @@ proc updateAccount*(name, address, path: string, publicKey, keyUid, accountType,
"emoji": emoji,
"colorId": colorId,
"prodPreferredChainIds": prodPreferredChainIds,
"testPreferredChainIds": testPreferredChainIds
#"hidden" present on the status-go side, but we don't use it
"testPreferredChainIds": testPreferredChainIds,
"hidden": hideFromTotalBalance
#"clock" we leave this empty, set on the status-go side
#"removed" present on the status-go side, used for synchronization, no need to set it here
}

View File

@ -39,7 +39,6 @@ SplitView {
displayDecimals: 4,
stripTrailingZeroes: false}),
isAllAccounts: false,
includeWatchOnly: false,
path: "m/44/60/0/0/34",
preferredSharingChainIds: walletStore.areTestNetworksEnabled ? "5:420:421613": "1:10:42161"
})
@ -87,6 +86,9 @@ SplitView {
account: d.dummyOverview
walletStore: d.walletStore
keyPair: d.keyPairModel.data[0].keyPair
onUpdateWatchAccountHiddenFromTotalBalance: {
console.warn("updateWatchAccountHiddenFromTotalBalance :: address ::", address, "hideFromTotalBalance :: ", hideFromTotalBalance)
}
}
}

View File

@ -48,7 +48,6 @@ SplitView {
displayDecimals: 4,
stripTrailingZeroes: false}),
isAllAccounts: false,
includeWatchOnly: false
})
function getNameForAddress(address) {

View File

@ -56,7 +56,6 @@ SplitView {
displayDecimals: 4,
stripTrailingZeroes: false}),
isAllAccounts: false,
includeWatchOnly: false
})
}
@ -73,7 +72,6 @@ SplitView {
displayDecimals: 4,
stripTrailingZeroes: false}),
isAllAccounts: true,
includeWatchOnly: true,
colorIds: "purple;pink;magenta"
})

View File

@ -18,10 +18,8 @@ Rectangle {
property bool hasPairedDevices
property var getNetworkShortNames: function(chainIds){}
property string userProfilePublicKey
property bool includeWatchOnlyAccount
signal goToAccountView(var account)
signal toggleIncludeWatchOnlyAccount()
signal runExportQrFlow()
signal runImportViaQrFlow()
signal runImportViaSeedPhraseFlow()
@ -98,16 +96,6 @@ Rectangle {
onRunStopUsingKeycardFlow: root.runStopUsingKeycardFlow()
}
}
},
StatusBaseText {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Include in total balance")
visible: d.isWatchOnly
},
StatusSwitch {
visible: d.isWatchOnly
checked: root.includeWatchOnlyAccount
onClicked: root.toggleIncludeWatchOnlyAccount()
}
]
}
@ -120,6 +108,7 @@ Rectangle {
model: d.relatedAccounts
delegate: WalletAccountDelegate {
width: ListView.view.width
label: keyPair.pairType !== Constants.keypair.type.watchOnly ? "" : model.account.hideFromTotalBalance ? qsTr("Excl. from total balance"): qsTr("Incl. in total balance")
account: model.account
totalCount: ListView.view.count
getNetworkShortNames: root.getNetworkShortNames

View File

@ -28,11 +28,6 @@ QtObject {
property var assets: walletSectionAssets.assets
property var accounts: Global.appIsReady? accountsModule.accounts : null
property var originModel: accountsModule.keyPairModel
property bool includeWatchOnlyAccount: accountsModule.includeWatchOnlyAccount
function toggleIncludeWatchOnlyAccount() {
accountsModule.toggleIncludeWatchOnlyAccount()
}
property string userProfilePublicKey: userProfile.pubKey
@ -150,4 +145,8 @@ QtObject {
layer: combinedNetwork.layer
}
}
function updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance) {
accountsModule.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
}
}

View File

@ -199,6 +199,9 @@ SettingsContentBase {
onRunStopUsingKeycardFlow: {
root.rootStore.keycardStore.runStopUsingKeycardPopup(keyPair.keyUid)
}
onUpdateWatchAccountHiddenFromTotalBalance: {
root.walletStore.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
}
}
DappPermissionsView {

View File

@ -29,6 +29,7 @@ ColumnLayout {
signal runImportMissingKeypairFlow()
signal runMoveKeypairToKeycardFlow()
signal runStopUsingKeycardFlow()
signal updateWatchAccountHiddenFromTotalBalance(string address, bool hideFromTotalBalance)
property var account
property var keyPair
@ -218,6 +219,27 @@ ColumnLayout {
StatusListItem {
Layout.fillWidth: true
title: qsTr("Include in total balance")
visible: d.watchOnlyAccount
color: Theme.palette.transparent
components: [
StatusSwitch {
checked: !!root.account && !account.hideFromTotalBalance
onToggled: root.updateWatchAccountHiddenFromTotalBalance(account.address, !checked)
}
]
}
Separator {
visible: d.watchOnlyAccount
Layout.fillWidth: true
Layout.preferredHeight: 1
color: Theme.palette.baseColor2
}
StatusListItem {
Layout.fillWidth: true
Layout.topMargin: Style.current.halfPadding
title: qsTr("Preferred networks when sharing this address")
color: Theme.palette.transparent
components: [

View File

@ -223,9 +223,7 @@ Column {
hasPairedDevices: root.walletStore.walletModule.hasPairedDevices
getNetworkShortNames: walletStore.getNetworkShortNames
userProfilePublicKey: walletStore.userProfilePublicKey
includeWatchOnlyAccount: walletStore.includeWatchOnlyAccount
onGoToAccountView: root.goToAccountView(account, keyPair)
onToggleIncludeWatchOnlyAccount: walletStore.toggleIncludeWatchOnlyAccount()
onRunRenameKeypairFlow: root.runRenameKeypairFlow(model)
onRunRemoveKeypairFlow: root.runRemoveKeypairFlow(model)
onRunImportViaSeedPhraseFlow: {

View File

@ -30,7 +30,7 @@ Item {
Connections {
target: walletSection
function onFilterChanged(address, includeWatchOnly, allAddresses) {
function onFilterChanged(address, allAddresses) {
root.showAllAccounts = allAddresses
}

View File

@ -82,31 +82,6 @@ Item {
visible: !overview.isAllAccounts
}
StatusButton {
objectName: "hideShowWatchOnlyButton"
Layout.preferredHeight: 38
Layout.alignment: Qt.AlignTop
spacing: 8
size: StatusBaseButton.Size.Small
borderColor: Theme.palette.directColor7
normalColor: Theme.palette.transparent
hoverColor: Theme.palette.baseColor2
font.weight: Font.Normal
textColor: Theme.palette.baseColor1
text: overview.includeWatchOnly ? qsTr("Hide watched addresses"): qsTr("Show watched addresses")
icon.name: overview.includeWatchOnly ? "hide" : "show"
icon.height: 16
icon.width: 16
icon.color: Theme.palette.baseColor1
onClicked: switchHideWatchOnlyAccounts()
visible: overview.isAllAccounts
}
// network filter
NetworkFilter {
id: networkFilter

View File

@ -378,4 +378,8 @@ QtObject {
}
return prefChains
}
function updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance) {
walletSectionAccounts.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
}
}

View File

@ -5,6 +5,8 @@ import StatusQ.Popups 0.1
import "../stores"
import utils 1.0
StatusMenu {
id: root
@ -14,6 +16,7 @@ StatusMenu {
signal deleteAccountClicked()
signal addNewAccountClicked()
signal addWatchOnlyAccountClicked()
signal hideFromTotalBalanceClicked(string address, bool hideFromTotalBalance)
width: 204
@ -40,6 +43,14 @@ StatusMenu {
onTriggered: {
root.editAccountClicked()
}
}
StatusAction {
objectName: "AccountMenu-HideFromTotalBalance-%1".arg(root.uniqueIdentifier)
enabled: !!root.account && root.account.walletType === Constants.watchWalletType
text: !!root.account ? root.account.hideFromTotalBalance ? qsTr("Include in total balance"): qsTr("Exclude from total balance"): ""
icon.name: !!root.account ? root.account.hideFromTotalBalance ? "show" : "hide": ""
onTriggered: root.hideFromTotalBalanceClicked(root.account.address, !root.account.hideFromTotalBalance)
}
StatusAction {

View File

@ -115,6 +115,8 @@ Rectangle {
removeAccountConfirmation.accountDerivationPath = account.path
removeAccountConfirmation.active = true
}
onHideFromTotalBalanceClicked: RootStore.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
}
}
@ -158,7 +160,7 @@ Rectangle {
function onDestroyAddAccountPopup() {
addAccount.active = false
}
function onFilterChanged(address, includeWatchOnly, allAddresses) {
function onFilterChanged(address, allAddresses) {
root.currentAddress = allAddresses ? "" : address
root.showAllAccounts = allAddresses
}
@ -269,7 +271,7 @@ Rectangle {
}
anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined
title: model.name
subTitle: LocaleUtils.currencyAmountToLocaleString(model.currencyBalance)
subTitle: !model.hideFromTotalBalance ? LocaleUtils.currencyAmountToLocaleString(model.currencyBalance): ""
asset.emoji: !!model.emoji ? model.emoji: ""
asset.color: Utils.getColorForId(model.colorId)
asset.name: !model.emoji ? "filled-account": ""

View File

@ -142,16 +142,6 @@ Item {
)
}
function onShowIncludeWatchOnlyAccountUpdated(includeWatchOnly: bool) {
Global.displayToastMessage(
includeWatchOnly ? qsTr("Your wallets total balance will now include balances of watched addresses") : qsTr("Your wallets total balance will not include balances of watched addresses") ,
"",
"checkmark-circle",
false,
Constants.ephemeralNotificationType.success,
"")
}
function onShowToastKeypairRemoved(keypairName: string) {
Global.displayToastMessage(
qsTr("“%1” keypair and its derived accounts were successfully removed from all devices").arg(keypairName),

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 11b5aed27a3ed167c6e39e185737e07c246de029
Subproject commit ac813ef5d8f012ba4a0b532483ceeebc553aa3b1