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) let args = NetworkEndpointUpdatedArgs(e)
self.view.showNetworkEndpointUpdated(args.networkName, args.isTest, args.revertedToDefault) 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): self.events.on(SIGNAL_KEYPAIR_DELETED) do(e: Args):
let args = KeypairArgs(e) let args = KeypairArgs(e)
self.view.showToastKeypairRemoved(args.keyPairName) self.view.showToastKeypairRemoved(args.keyPairName)

View File

@ -52,12 +52,6 @@ proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
proc getKeypairs*(self: Controller): seq[KeypairDto] = proc getKeypairs*(self: Controller): seq[KeypairDto] =
return self.walletAccountService.getKeypairs() 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] = proc getEnabledChainIds*(self: Controller): seq[int] =
return self.walletAccountService.getEnabledChainIds() 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 = proc getCurrencyBalance*(self: Controller, address: string, chainIds: seq[int], currency: string): float64 =
return self.walletAccountService.getCurrencyBalance(address, chainIds, currency) 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.} = method getCollectiblesModel*(self: AccessInterface): QVariant {.base.} =
raise newException(ValueError, "No implementation available") 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.} = method updateWalletAccountProdPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} = method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available") 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, isDefaultAccount = account.isWallet,
self.controller.areTestNetworksEnabled(), self.controller.areTestNetworksEnabled(),
prodPreferredChainIds = account.prodPreferredChainIds, prodPreferredChainIds = account.prodPreferredChainIds,
testPreferredChainIds = account.testPreferredChainIds) testPreferredChainIds = account.testPreferredChainIds,
hideFromTotalBalance = account.hideFromTotalBalance)
method setBalance(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) = method setBalance(self: Module, accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) =
let enabledChainIds = self.controller.getEnabledChainIds() 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.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args):
self.refreshWalletAccounts() 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): self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e: Args):
let args = AccountArgs(e) let args = AccountArgs(e)
self.view.onPreferredSharingChainsUpdated(args.account.keyUid, args.account.address, args.account.prodPreferredChainIds, args.account.testPreferredChainIds) 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.controller.init()
self.view.load() self.view.load()
self.view.setIncludeWatchOnlyAccount(self.controller.isIncludeWatchOnlyAccount())
method isLoaded*(self: Module): bool = method isLoaded*(self: Module): bool =
return self.moduleLoaded return self.moduleLoaded
@ -211,9 +211,6 @@ method deleteAccount*(self: Module, address: string) =
method deleteKeypair*(self: Module, keyUid: string) = method deleteKeypair*(self: Module, keyUid: string) =
self.controller.deleteKeypair(keyUid) self.controller.deleteKeypair(keyUid)
method toggleIncludeWatchOnlyAccount*(self: Module) =
self.controller.toggleIncludeWatchOnlyAccount()
method renameKeypair*(self: Module, keyUid: string, name: string) = method renameKeypair*(self: Module, keyUid: string, name: string) =
self.controller.renameKeypair(keyUid, name) self.controller.renameKeypair(keyUid, name)
@ -225,3 +222,6 @@ method updateWalletAccountProdPreferredChains*(self: Module, address, preferredC
method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) = method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds) 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 accounts: Model
accountsVariant: QVariant accountsVariant: QVariant
keyPairModel: KeyPairModel keyPairModel: KeyPairModel
includeWatchOnlyAccount: bool
proc delete*(self: View) = proc delete*(self: View) =
self.accounts.delete self.accounts.delete
@ -57,6 +56,9 @@ QtObject:
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) = proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds) 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.} = proc deleteAccount*(self: View, address: string) {.slot.} =
self.delegate.deleteAccount(address) self.delegate.deleteAccount(address)
@ -77,20 +79,6 @@ QtObject:
self.keyPairModel.setItems(items) self.keyPairModel.setItems(items)
self.keyPairModelChanged() 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.} = proc keypairNameExists*(self: View, name: string): bool {.slot.} =
return self.keyPairModel.keypairNameExists(name) return self.keyPairModel.keypairNameExists(name)
@ -111,3 +99,6 @@ QtObject:
proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) = proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) =
self.keyPairModel.setBalanceForAddress(address, balance) 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 showToastAccountAdded*(self: View, name: string) {.signal.}
proc showToastKeypairRenamed*(self: View, oldName: string, newName: string) {.signal.} proc showToastKeypairRenamed*(self: View, oldName: string, newName: string) {.signal.}
proc showNetworkEndpointUpdated*(self: View, name: string, isTest: bool, revertedToDefault: bool) {.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 showToastKeypairRemoved*(self: View, keypairName: string) {.signal.}
proc showToastKeypairsImported*(self: View, keypairName: string, keypairsCount: int, error: 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.} 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 = proc getCurrencyBalance*(self: Controller, address: string, chainIds: seq[int], currency: string): float64 =
return self.walletAccountService.getCurrencyBalance(address, chainIds, currency) 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.} = method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available") 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, isWallet: bool = false,
areTestNetworksEnabled: bool = false, areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "", prodPreferredChainIds: string = "",
testPreferredChainIds: string = "" testPreferredChainIds: string = "",
hideFromTotalBalance: bool = false
): Item = ): Item =
result = Item() result = Item()
result.WalletAccountItem.setup(name, result.WalletAccountItem.setup(name,
@ -42,7 +43,8 @@ proc initItem*(
operability = wa_dto.AccountFullyOperable, operability = wa_dto.AccountFullyOperable,
areTestNetworksEnabled, areTestNetworksEnabled,
prodPreferredChainIds, prodPreferredChainIds,
testPreferredChainIds) testPreferredChainIds,
hideFromTotalBalance)
result.createdAt = createdAt result.createdAt = createdAt
result.assetsLoading = assetsLoading result.assetsLoading = assetsLoading
result.currencyBalance = currencyBalance result.currencyBalance = currencyBalance

View File

@ -19,7 +19,8 @@ type
KeycardAccount, KeycardAccount,
AssetsLoading, AssetsLoading,
IsWallet, IsWallet,
PreferredSharingChainIds PreferredSharingChainIds,
HideFromTotalBalance
QtObject: QtObject:
type type
@ -69,7 +70,8 @@ QtObject:
ModelRole.KeycardAccount.int: "keycardAccount", ModelRole.KeycardAccount.int: "keycardAccount",
ModelRole.AssetsLoading.int: "assetsLoading", ModelRole.AssetsLoading.int: "assetsLoading",
ModelRole.IsWallet.int: "isWallet", ModelRole.IsWallet.int: "isWallet",
ModelRole.PreferredSharingChainIds.int: "preferredSharingChainIds" ModelRole.PreferredSharingChainIds.int: "preferredSharingChainIds",
ModelRole.HideFromTotalBalance.int: "hideFromTotalBalance"
}.toTable }.toTable
@ -121,6 +123,8 @@ QtObject:
result = newQVariant(item.isWallet()) result = newQVariant(item.isWallet())
of ModelRole.PreferredSharingChainIds: of ModelRole.PreferredSharingChainIds:
result = newQVariant(item.preferredSharingChainIds()) result = newQVariant(item.preferredSharingChainIds())
of ModelRole.HideFromTotalBalance:
result = newQVariant(item.hideFromTotalBalance())
proc getNameByAddress*(self: Model, address: string): string = proc getNameByAddress*(self: Model, address: string): string =
for item in self.items: for item in self.items:
@ -144,4 +148,4 @@ QtObject:
for item in self.items: for item in self.items:
if cmpIgnoreCase(item.address(), address) == 0 and item.walletType != "watch": if cmpIgnoreCase(item.address(), address) == 0 and item.walletType != "watch":
return true 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) = method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds) 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.} = proc updateWalletAccountTestPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountTestPreferredChains(address, preferredChainIds) 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] = 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 toggleIncludeWatchOnlyAccount*(self: Controller) =
self.walletAccountService.toggleIncludeWatchOnlyAccount()
proc isIncludeWatchOnlyAccount*(self: Controller): bool =
return self.walletAccountService.isIncludeWatchOnlyAccount()
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto = proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
return self.walletAccountService.getKeypairByAccountAddress(address) return self.walletAccountService.getKeypairByAccountAddress(address)
proc hasPairedDevices*(self: Controller): bool = 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) = proc setFillterAllAddresses*(self: Filter) =
self.allAddresses = true self.allAddresses = true
self.addresses = self.controller.getWalletAccounts().map(a => a.address) var allAccounts = self.controller.getWalletAccounts()
var accountsExclWatchAccs = allAccounts.filter(a => not a.hideFromTotalBalance)
proc toggleWatchOnlyAccounts*(self: Filter) = if allAccounts.len != accountsExclWatchAccs.len:
self.controller.toggleIncludeWatchOnlyAccount() self.allAddresses = false
self.addresses = self.controller.getWalletAccounts().filter(a => not a.hideFromTotalBalance).map(a => a.address)
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)
proc setAddress*(self: Filter, address: string) = proc setAddress*(self: Filter, address: string) =
self.allAddresses = false self.allAddresses = false
@ -58,5 +52,5 @@ proc updateNetworks*(self: Filter) =
self.allChainsEnabled = (self.chainIds.len == self.controller.getNetworks().len) self.allChainsEnabled = (self.chainIds.len == self.controller.getNetworks().len)
proc load*(self: Filter) = proc load*(self: Filter) =
self.includeWatchOnlyToggled() self.setFillterAllAddresses()
self.updateNetworks() self.updateNetworks()

View File

@ -21,9 +21,6 @@ method setFilterAddress*(self: AccessInterface, address: string) {.base.} =
method setFillterAllAddresses*(self: AccessInterface) {.base.} = method setFillterAllAddresses*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method toggleWatchOnlyAccounts*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method updateCurrency*(self: AccessInterface, currency: string) {.base.} = method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -116,4 +113,4 @@ method destroyKeypairImportPopup*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method hasPairedDevices*(self: AccessInterface): bool {.base.} = 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() self.controller.getCurrency()
method setTotalCurrencyBalance*(self: Module) = method setTotalCurrencyBalance*(self: Module) =
var addresses: seq[string] = @[]
let walletAccounts = self.controller.getWalletAccounts() let walletAccounts = self.controller.getWalletAccounts()
if self.controller.isIncludeWatchOnlyAccount(): var addresses = walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address)
addresses = walletAccounts.map(a => a.address)
else:
addresses = walletAccounts.filter(a => a.walletType != "watch").map(a => a.address)
self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance(addresses)) self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance(addresses))
method notifyFilterChanged(self: Module) = method notifyFilterChanged(self: Module) =
let includeWatchOnly = self.controller.isIncludeWatchOnlyAccount() self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds, self.filter.allAddresses)
self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds, includeWatchOnly, self.filter.allAddresses)
self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds) self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds)
self.accountsModule.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.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds)
self.activityController.globalFilterChanged(self.filter.addresses, self.filter.allAddresses, self.filter.chainIds, self.filter.allChainsEnabled) self.activityController.globalFilterChanged(self.filter.addresses, self.filter.allAddresses, self.filter.chainIds, self.filter.allChainsEnabled)
self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds) self.collectiblesController.globalFilterChanged(self.filter.addresses, self.filter.chainIds)
if self.filter.addresses.len > 0: 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 = method getCurrencyAmount*(self: Module, amount: float64, symbol: string): CurrencyAmount =
return self.controller.getCurrencyAmount(amount, symbol) return self.controller.getCurrencyAmount(amount, symbol)
method toggleWatchOnlyAccounts*(self: Module) =
self.filter.toggleWatchOnlyAccounts()
method setFilterAddress*(self: Module, address: string) = method setFilterAddress*(self: Module, address: string) =
let keypair = self.controller.getKeypairByAccountAddress(address) let keypair = self.controller.getKeypairByAccountAddress(address)
if keypair.isNil: if keypair.isNil:
@ -247,10 +238,6 @@ method load*(self: Module) =
self.notifyFilterChanged() self.notifyFilterChanged()
self.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args): self.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args):
self.notifyFilterChanged() 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.events.on(SIGNAL_HISTORY_NON_ARCHIVAL_NODE) do (e:Args):
self.view.setIsNonArchivalNode(true) self.view.setIsNonArchivalNode(true)
self.events.on(SIGNAL_TRANSACTION_DECODED) do(e: Args): self.events.on(SIGNAL_TRANSACTION_DECODED) do(e: Args):
@ -263,7 +250,11 @@ method load*(self: Module) =
self.onUpdatedKeypairsOperability(args.keypairs) self.onUpdatedKeypairsOperability(args.keypairs)
self.events.on(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e:Args): self.events.on(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e:Args):
let data = LocalPairingStatus(e) 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.controller.init()
self.view.load() self.view.load()
@ -428,4 +419,4 @@ method hasPairedDevices*(self: Module): bool =
proc onLocalPairingStatusUpdate*(self: Module, data: LocalPairingStatus) = proc onLocalPairingStatusUpdate*(self: Module, data: LocalPairingStatus) =
if data.state == LocalPairingState.Finished: 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.} = method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") 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") raise newException(ValueError, "No implementation available")

View File

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

View File

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

View File

@ -17,7 +17,6 @@ QtObject:
colorId: string colorId: string
emoji: string emoji: string
isAllAccounts: bool isAllAccounts: bool
includeWatchOnly: bool
colorIds: string colorIds: string
isWatchOnlyAccount: bool isWatchOnlyAccount: bool
@ -99,13 +98,6 @@ QtObject:
read = getIsAllAccounts read = getIsAllAccounts
notify = isAllAccountsChanged 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.} = proc getColorIds(self: View): QVariant {.slot.} =
return newQVariant(self.colorIds) return newQVariant(self.colorIds)
proc colorIdsChanged(self: View) {.signal.} proc colorIdsChanged(self: View) {.signal.}
@ -147,6 +139,3 @@ QtObject:
if(self.isAllAccounts != item.getIsAllAccounts()): if(self.isAllAccounts != item.getIsAllAccounts()):
self.isAllAccounts = item.getIsAllAccounts() self.isAllAccounts = item.getIsAllAccounts()
self.isAllAccountsChanged() 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.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e:Args):
self.refreshWalletAccounts() self.refreshWalletAccounts()
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
self.refreshWalletAccounts()
self.controller.init() self.controller.init()
self.view.load() self.view.load()

View File

@ -47,7 +47,7 @@ QtObject:
QtProperty[string] currentCurrency: QtProperty[string] currentCurrency:
read = getCurrentCurrency 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.} proc totalCurrencyBalanceChanged*(self: View) {.signal.}
@ -76,9 +76,6 @@ QtObject:
proc setFillterAllAddresses(self: View) {.slot.} = proc setFillterAllAddresses(self: View) {.slot.} =
self.delegate.setFillterAllAddresses() self.delegate.setFillterAllAddresses()
proc toggleWatchOnlyAccounts(self: View) {.slot.} =
self.delegate.toggleWatchOnlyAccounts()
proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: CurrencyAmount) = proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: CurrencyAmount) =
self.totalCurrencyBalance = totalCurrencyBalance self.totalCurrencyBalance = totalCurrencyBalance
self.totalCurrencyBalanceChanged() self.totalCurrencyBalanceChanged()
@ -205,4 +202,4 @@ QtObject:
proc destroyKeypairImportPopup*(self: View) {.signal.} proc destroyKeypairImportPopup*(self: View) {.signal.}
proc emitDestroyKeypairImportPopup*(self: View) = proc emitDestroyKeypairImportPopup*(self: View) =
self.destroyKeypairImportPopup() self.destroyKeypairImportPopup()

View File

@ -48,7 +48,7 @@ proc buildKeypairItem*(keypair: KeypairDto, areTestNetworksEnabled: bool): KeyPa
icon = "wallet" icon = "wallet"
item.addAccount(newKeyPairAccountItem(acc.name, acc.path, acc.address, acc.publicKey, acc.emoji, acc.colorId, 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, icon, newCurrencyAmount(), balanceFetched = true, operability = acc.operable, acc.isWallet, areTestNetworksEnabled,
acc.prodPreferredChainIds, acc.testPreferredChainIds)) acc.prodPreferredChainIds, acc.testPreferredChainIds, acc.hideFromTotalBalance))
return item return item
proc buildKeyPairsList*(keypairs: seq[KeypairDto], excludeAlreadyMigratedPairs: bool, proc buildKeyPairsList*(keypairs: seq[KeypairDto], excludeAlreadyMigratedPairs: bool,
@ -68,4 +68,4 @@ proc buildKeyPairsList*(keypairs: seq[KeypairDto], excludeAlreadyMigratedPairs:
items.add(item) items.add(item)
if items.len == 0: 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" 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, w.operable,
areTestNetworksEnabled, areTestNetworksEnabled,
w.prodPreferredChainIds, w.prodPreferredChainIds,
w.testPreferredChainIds w.testPreferredChainIds,
w.hideFromTotalBalance
) )
proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: bool, proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: bool,
@ -63,7 +64,8 @@ proc walletAccountToWalletAccountsItem*(w: WalletAccountDto, keycardAccount: boo
w.isWallet, w.isWallet,
areTestNetworksEnabled, areTestNetworksEnabled,
w.prodPreferredChainIds, w.prodPreferredChainIds,
w.testPreferredChainIds w.testPreferredChainIds,
w.hideFromTotalBalance
) )
proc walletAccountToWalletAssetsItem*(w: WalletAccountDto): wallet_assets_item.Item = proc walletAccountToWalletAssetsItem*(w: WalletAccountDto): wallet_assets_item.Item =

View File

@ -20,13 +20,14 @@ QtObject:
areTestNetworksEnabled: bool areTestNetworksEnabled: bool
prodPreferredChainIds: string prodPreferredChainIds: string
testPreferredChainIds: string testPreferredChainIds: string
hideFromTotalBalance: bool
proc delete*(self: KeyPairAccountItem) = proc delete*(self: KeyPairAccountItem) =
self.QObject.delete self.QObject.delete
proc newKeyPairAccountItem*(name = "", path = "", address = "", pubKey = "", emoji = "", colorId = "", icon = "", proc newKeyPairAccountItem*(name = "", path = "", address = "", pubKey = "", emoji = "", colorId = "", icon = "",
balance = newCurrencyAmount(), balanceFetched = true, operability = wa_dto.AccountFullyOperable, 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) new(result, delete)
result.QObject.setup result.QObject.setup
result.name = name result.name = name
@ -43,6 +44,7 @@ QtObject:
result.areTestNetworksEnabled = areTestNetworksEnabled result.areTestNetworksEnabled = areTestNetworksEnabled
result.prodPreferredChainIds = prodPreferredChainIds result.prodPreferredChainIds = prodPreferredChainIds
result.testPreferredChainIds = testPreferredChainIds result.testPreferredChainIds = testPreferredChainIds
result.hideFromTotalBalance = hideFromTotalBalance
proc `$`*(self: KeyPairAccountItem): string = proc `$`*(self: KeyPairAccountItem): string =
result = fmt"""KeyPairAccountItem[ result = fmt"""KeyPairAccountItem[
@ -59,7 +61,8 @@ QtObject:
isDefaultAccount: {self.isDefaultAccount}, isDefaultAccount: {self.isDefaultAccount},
areTestNetworksEnabled: {self.areTestNetworksEnabled}, areTestNetworksEnabled: {self.areTestNetworksEnabled},
prodPreferredChainIds: {self.prodPreferredChainIds}, prodPreferredChainIds: {self.prodPreferredChainIds},
testPreferredChainIds: {self.testPreferredChainIds} testPreferredChainIds: {self.testPreferredChainIds},
hideFromTotalBalance: {self.hideFromTotalBalance}
]""" ]"""
proc nameChanged*(self: KeyPairAccountItem) {.signal.} proc nameChanged*(self: KeyPairAccountItem) {.signal.}
@ -191,3 +194,13 @@ QtObject:
QtProperty[string] preferredSharingChainIds: QtProperty[string] preferredSharingChainIds:
read = preferredSharingChainIds read = preferredSharingChainIds
notify = preferredSharingChainIdsChanged 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) self.items[i].setProdPreferredChainIds(prodPreferredChainIds)
if testPreferredChainIds.len > 0: if testPreferredChainIds.len > 0:
self.items[i].setTestPreferredChainIds(testPreferredChainIds) 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) self.accounts.updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji)
proc updatePreferredSharingChainsForAddress*(self: KeyPairItem, address, prodPreferredChainIds, testPreferredChainIds: string) = proc updatePreferredSharingChainsForAddress*(self: KeyPairItem, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.accounts.updatePreferredSharingChainsForAddress(address, prodPreferredChainIds, testPreferredChainIds) 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) = proc setBalanceForAddress*(self: KeyPairItem, address: string, balance: CurrencyAmount) =
self.accounts.setBalanceForAddress(address, balance) self.accounts.setBalanceForAddress(address, balance)
proc updateOperabilityForAllAddresses*(self: KeyPairItem, operability: string) = proc updateOperabilityForAllAddresses*(self: KeyPairItem, operability: string) =

View File

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

View File

@ -18,6 +18,7 @@ QtObject:
areTestNetworksEnabled: bool areTestNetworksEnabled: bool
prodPreferredChainIds: string prodPreferredChainIds: string
testPreferredChainIds: string testPreferredChainIds: string
hideFromTotalBalance: bool
proc setup*(self: WalletAccountItem, proc setup*(self: WalletAccountItem,
name: string = "", name: string = "",
@ -32,7 +33,8 @@ QtObject:
operability: string = wa_dto.AccountFullyOperable, operability: string = wa_dto.AccountFullyOperable,
areTestNetworksEnabled: bool = false, areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "", prodPreferredChainIds: string = "",
testPreferredChainIds: string = "" testPreferredChainIds: string = "",
hideFromTotalBalance: bool = true
) = ) =
self.QObject.setup self.QObject.setup
self.name = name self.name = name
@ -48,6 +50,7 @@ QtObject:
self.areTestNetworksEnabled = areTestNetworksEnabled self.areTestNetworksEnabled = areTestNetworksEnabled
self.prodPreferredChainIds = prodPreferredChainIds self.prodPreferredChainIds = prodPreferredChainIds
self.testPreferredChainIds = testPreferredChainIds self.testPreferredChainIds = testPreferredChainIds
self.hideFromTotalBalance = hideFromTotalBalance
proc delete*(self: WalletAccountItem) = proc delete*(self: WalletAccountItem) =
self.QObject.delete self.QObject.delete
@ -65,7 +68,8 @@ QtObject:
operability: string = wa_dto.AccountFullyOperable, operability: string = wa_dto.AccountFullyOperable,
areTestNetworksEnabled: bool = false, areTestNetworksEnabled: bool = false,
prodPreferredChainIds: string = "", prodPreferredChainIds: string = "",
testPreferredChainIds: string = ""): WalletAccountItem = testPreferredChainIds: string = "",
hideFromTotalBalance: bool = true): WalletAccountItem =
new(result, delete) new(result, delete)
result.QObject.setup result.QObject.setup
result.name = name result.name = name
@ -81,6 +85,7 @@ QtObject:
result.areTestNetworksEnabled = areTestNetworksEnabled result.areTestNetworksEnabled = areTestNetworksEnabled
result.prodPreferredChainIds = prodPreferredChainIds result.prodPreferredChainIds = prodPreferredChainIds
result.testPreferredChainIds = testPreferredChainIds result.testPreferredChainIds = testPreferredChainIds
result.hideFromTotalBalance = hideFromTotalBalance
proc `$`*(self: WalletAccountItem): string = proc `$`*(self: WalletAccountItem): string =
result = fmt"""WalletAccountItem( result = fmt"""WalletAccountItem(
@ -97,6 +102,7 @@ QtObject:
areTestNetworksEnabled: {self.areTestNetworksEnabled}, areTestNetworksEnabled: {self.areTestNetworksEnabled},
prodPreferredChainIds: {self.prodPreferredChainIds}, prodPreferredChainIds: {self.prodPreferredChainIds},
testPreferredChainIds: {self.testPreferredChainIds}, testPreferredChainIds: {self.testPreferredChainIds},
hideFromTotalBalance: {self.hideFromTotalBalance}
]""" ]"""
proc nameChanged*(self: WalletAccountItem) {.signal.} proc nameChanged*(self: WalletAccountItem) {.signal.}
@ -198,3 +204,10 @@ QtObject:
QtProperty[string] preferredSharingChainIds: QtProperty[string] preferredSharingChainIds:
read = preferredSharingChainIds read = preferredSharingChainIds
notify = preferredSharingChainIdsChanged 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) self.walletAccountService.fetchDetailsForAddresses(self.uniqueFetchingDetailsId, addresses)
proc addWalletAccount*(self: Controller, createKeystoreFile, doPasswordHashing: bool, name, address, path, publicKey, 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 var password: string
if createKeystoreFile: if createKeystoreFile:
password = self.getPassword() 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 info "cannot create keystore file if provided password is empty", name=name, address=address
return false return false
let err = self.walletAccountService.addWalletAccount(password, doPasswordHashing, name, address, path, publicKey, let err = self.walletAccountService.addWalletAccount(password, doPasswordHashing, name, address, path, publicKey,
keyUid, accountType, colorId, emoji) keyUid, accountType, colorId, emoji, hideFromTotalBalance)
if err.len > 0: if err.len > 0:
info "adding wallet account failed", name=name, address=address info "adding wallet account failed", name=name, address=address
return false return false

View File

@ -599,6 +599,7 @@ proc doAddAccount[T](self: Module[T]) =
keyUid = selectedOrigin.getKeyUid() keyUid = selectedOrigin.getKeyUid()
createKeystoreFile = not selectedOrigin.getMigratedToKeycard() createKeystoreFile = not selectedOrigin.getMigratedToKeycard()
doPasswordHashing = not singletonInstance.userProfile.getIsKeycardUser() doPasswordHashing = not singletonInstance.userProfile.getIsKeycardUser()
hideFromTotalBalance = false
if selectedOrigin.getPairType() == KeyPairType.Profile.int: if selectedOrigin.getPairType() == KeyPairType.Profile.int:
accountType = account_constants.GENERATED accountType = account_constants.GENERATED
@ -616,6 +617,7 @@ proc doAddAccount[T](self: Module[T]) =
addingNewKeyPair = not self.isKeyPairAlreadyAdded(keyUid) addingNewKeyPair = not self.isKeyPairAlreadyAdded(keyUid)
else: else:
accountType = account_constants.WATCH accountType = account_constants.WATCH
hideFromTotalBalance = true
createKeystoreFile = false createKeystoreFile = false
doPasswordHashing = false doPasswordHashing = false
keypairName = "" keypairName = ""
@ -678,7 +680,8 @@ proc doAddAccount[T](self: Module[T]) =
keyUid = keyUid, keyUid = keyUid,
accountType = accountType, accountType = accountType,
colorId = self.view.getSelectedColorId(), colorId = self.view.getSelectedColorId(),
emoji = self.view.getSelectedEmoji()) emoji = self.view.getSelectedEmoji(),
hideFromTotalBalance = hideFromTotalBalance)
if not success: if not success:
error "failed to store account", address=selectedAddrItem.getAddress() 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 self.tmpKeycardUid = keycardUid
info "update keycard uid failed", oldKeycardUid=self.tmpKeycardUid, newKeycardUid=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, proc addNewSeedPhraseKeypair*(self: Controller, seedPhrase, keyUid, keypairName, rootWalletMasterKey: string,
accounts: seq[WalletAccountDto]): bool = accounts: seq[WalletAccountDto]): bool =
let err = self.walletAccountService.addNewSeedPhraseKeypair(seedPhrase, password = "", doPasswordHashing = false, keyUid, 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_BIO* = "bio"
const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?" const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?"
const KEY_IS_SEPOLIA_ENABLED* = "is-sepolia-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" const PROFILE_MIGRATION_NEEDED* = "profile-migration-needed"
# Notifications Settings Values # Notifications Settings Values
@ -138,7 +137,6 @@ type
notificationsSoundsEnabled*: bool notificationsSoundsEnabled*: bool
notificationsVolume*: int notificationsVolume*: int
notificationsMessagePreview*: int notificationsMessagePreview*: int
includeWatchOnlyAccount*: bool
profileMigrationNeeded*: bool profileMigrationNeeded*: bool
isSepoliaEnabled*: bool isSepoliaEnabled*: bool
@ -195,7 +193,6 @@ proc toSettingsDto*(jsonObj: JsonNode): SettingsDto =
discard jsonObj.getProp(KEY_GIF_FAVORITES, result.gifFavorites) discard jsonObj.getProp(KEY_GIF_FAVORITES, result.gifFavorites)
discard jsonObj.getProp(KEY_TEST_NETWORKS_ENABLED, result.testNetworksEnabled) discard jsonObj.getProp(KEY_TEST_NETWORKS_ENABLED, result.testNetworksEnabled)
discard jsonObj.getProp(KEY_IS_SEPOLIA_ENABLED, result.isSepoliaEnabled) 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) discard jsonObj.getProp(PROFILE_MIGRATION_NEEDED, result.profileMigrationNeeded)
var pinnedMailserverObj: JsonNode var pinnedMailserverObj: JsonNode

View File

@ -27,7 +27,6 @@ const SIGNAL_BIO_UPDATED* = "bioUpdated"
const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved" const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved"
const SIGNAL_SOCIAL_LINKS_UPDATED* = "socialLinksUpdated" const SIGNAL_SOCIAL_LINKS_UPDATED* = "socialLinksUpdated"
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated" const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
const SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED* = "includeWatchOnlyAccounts"
const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated" const SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED* = "profileMigrationNeededUpdated"
logScope: logScope:
@ -114,9 +113,6 @@ QtObject:
if settingsField.name == KEY_MNEMONIC: if settingsField.name == KEY_MNEMONIC:
self.settings.mnemonic = "" self.settings.mnemonic = ""
self.events.emit(SIGNAL_MNEMONIC_REMOVED, Args()) 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: if settingsField.name == PROFILE_MIGRATION_NEEDED:
self.settings.profileMigrationNeeded = settingsField.value.getBool self.settings.profileMigrationNeeded = settingsField.value.getBool
self.events.emit(SIGNAL_PROFILE_MIGRATION_NEEDED_UPDATED, SettingsBoolValueArgs(value: self.settings.profileMigrationNeeded)) 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 error "error saving social links", errDescription=data.error
self.storeSocialLinksAndNotify(data) 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 = proc getProfileMigrationNeeded*(self: Service): bool =
self.settings.profileMigrationNeeded self.settings.profileMigrationNeeded

View File

@ -38,6 +38,7 @@ type
position*: int position*: int
prodPreferredChainIDs*: string prodPreferredChainIDs*: string
testPreferredChainIDs*: string testPreferredChainIDs*: string
hideFromTotalBalance*: bool
proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto = proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
result = WalletAccountDto() result = WalletAccountDto()
@ -59,6 +60,7 @@ proc toWalletAccountDto*(jsonObj: JsonNode): WalletAccountDto =
discard jsonObj.getProp("position", result.position) discard jsonObj.getProp("position", result.position)
discard jsonObj.getProp("prodPreferredChainIds", result.prodPreferredChainIds) discard jsonObj.getProp("prodPreferredChainIds", result.prodPreferredChainIds)
discard jsonObj.getProp("testPreferredChainIds", result.testPreferredChainIds) discard jsonObj.getProp("testPreferredChainIds", result.testPreferredChainIds)
discard jsonObj.getProp("hidden", result.hideFromTotalBalance)
result.assetsLoading = true result.assetsLoading = true
result.hasBalanceCache = false result.hasBalanceCache = false
result.hasMarketValuesCache = false result.hasMarketValuesCache = false
@ -81,5 +83,6 @@ proc `$`*(self: WalletAccountDto): string =
removed: {self.removed}, removed: {self.removed},
operable: {self.operable}, operable: {self.operable},
prodPreferredChainIds: {self.prodPreferredChainIds}, 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 ## 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, colorId, emoji: string): string = keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool): 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, colorId, emoji) accountType, colorId, emoji, hideFromTotalBalance)
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,
colorId, emoji) colorId, emoji, hideFromTotalBalance)
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
return 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" error "account's address is not among known addresses: ", address=address, procName="updateWalletAccount"
return false return false
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, 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: 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
return false 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" error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountProdPreferredChains"
return false return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey, 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: if not response.error.isNil:
error "status-go error", procName="updateWalletAccountProdPreferredChains", errCode=response.error.code, errDesription=response.error.message error "status-go error", procName="updateWalletAccountProdPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false 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" error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountTestPreferredChains"
return false return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey, 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: if not response.error.isNil:
error "status-go error", procName="updateWalletAccountTestPreferredChains", errCode=response.error.code, errDesription=response.error.message error "status-go error", procName="updateWalletAccountTestPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false return false
@ -590,6 +590,25 @@ proc updateWalletAccountTestPreferredChains*(self: Service, address, preferredCh
error "error: ", procName="updateWalletAccountTestPreferredChains", errName=e.name, errDesription=e.msg error "error: ", procName="updateWalletAccountTestPreferredChains", errName=e.name, errDesription=e.msg
return false 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) = proc moveAccountFinally*(self: Service, fromPosition: int, toPosition: int) =
var updated = false var updated = false
try: try:
@ -724,12 +743,6 @@ proc handleKeypair(self: Service, keypair: KeypairDto) =
# notify all interested parts about the keypair change # notify all interested parts about the keypair change
self.events.emit(SIGNAL_KEYPAIR_SYNCED, KeypairArgs(keypair: keypair)) 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.} = proc onFetchChainIdForUrl*(self: Service, jsonString: string) {.slot.} =
let response = parseJson(jsonString) let response = parseJson(jsonString)
self.events.emit(SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED, ChainIdForUrlArgs( 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_OPERABILITY_UPDATED* = "walletAccount/operabilityUpdated"
const SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED* = "walletAccount/chainIdForUrlFetched" 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_PREFERRED_SHARING_CHAINS_UPDATED* = "walletAccount/preferredSharingChainsUpdated"
const SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED* = "walletAccount/accountHiddenChanged"
const SIGNAL_KEYPAIR_SYNCED* = "keypairSynced" const SIGNAL_KEYPAIR_SYNCED* = "keypairSynced"
const SIGNAL_KEYPAIR_NAME_CHANGED* = "keypairNameChanged" 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) 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. ## 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].} = RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [ let payload = %* [
password, password,
@ -56,7 +56,7 @@ proc addAccount*(password, name, address, path, publicKey, keyUid, accountType,
"name": name, "name": name,
"emoji": emoji, "emoji": emoji,
"colorId": colorId, "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 #"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 #"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, "name": acc.name,
"emoji": acc.emoji, "emoji": acc.emoji,
"colorId": acc.colorId, "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 #"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 #"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) return core.callPrivateRPC("accounts_addKeypair", payload)
## Adds a new account without creating a Keystore file and notifies paired devices ## 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].} = 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 ## 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, 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].} = RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [ let payload = %* [
{ {
@ -121,8 +121,8 @@ proc updateAccount*(name, address, path: string, publicKey, keyUid, accountType,
"emoji": emoji, "emoji": emoji,
"colorId": colorId, "colorId": colorId,
"prodPreferredChainIds": prodPreferredChainIds, "prodPreferredChainIds": prodPreferredChainIds,
"testPreferredChainIds": testPreferredChainIds "testPreferredChainIds": testPreferredChainIds,
#"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 #"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 #"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, displayDecimals: 4,
stripTrailingZeroes: false}), stripTrailingZeroes: false}),
isAllAccounts: false, isAllAccounts: false,
includeWatchOnly: false,
path: "m/44/60/0/0/34", path: "m/44/60/0/0/34",
preferredSharingChainIds: walletStore.areTestNetworksEnabled ? "5:420:421613": "1:10:42161" preferredSharingChainIds: walletStore.areTestNetworksEnabled ? "5:420:421613": "1:10:42161"
}) })
@ -87,6 +86,9 @@ SplitView {
account: d.dummyOverview account: d.dummyOverview
walletStore: d.walletStore walletStore: d.walletStore
keyPair: d.keyPairModel.data[0].keyPair keyPair: d.keyPairModel.data[0].keyPair
onUpdateWatchAccountHiddenFromTotalBalance: {
console.warn("updateWatchAccountHiddenFromTotalBalance :: address ::", address, "hideFromTotalBalance :: ", hideFromTotalBalance)
}
} }
} }

View File

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

View File

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

View File

@ -18,10 +18,8 @@ Rectangle {
property bool hasPairedDevices property bool hasPairedDevices
property var getNetworkShortNames: function(chainIds){} property var getNetworkShortNames: function(chainIds){}
property string userProfilePublicKey property string userProfilePublicKey
property bool includeWatchOnlyAccount
signal goToAccountView(var account) signal goToAccountView(var account)
signal toggleIncludeWatchOnlyAccount()
signal runExportQrFlow() signal runExportQrFlow()
signal runImportViaQrFlow() signal runImportViaQrFlow()
signal runImportViaSeedPhraseFlow() signal runImportViaSeedPhraseFlow()
@ -98,16 +96,6 @@ Rectangle {
onRunStopUsingKeycardFlow: root.runStopUsingKeycardFlow() 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 model: d.relatedAccounts
delegate: WalletAccountDelegate { delegate: WalletAccountDelegate {
width: ListView.view.width 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 account: model.account
totalCount: ListView.view.count totalCount: ListView.view.count
getNetworkShortNames: root.getNetworkShortNames getNetworkShortNames: root.getNetworkShortNames

View File

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

View File

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

View File

@ -29,6 +29,7 @@ ColumnLayout {
signal runImportMissingKeypairFlow() signal runImportMissingKeypairFlow()
signal runMoveKeypairToKeycardFlow() signal runMoveKeypairToKeycardFlow()
signal runStopUsingKeycardFlow() signal runStopUsingKeycardFlow()
signal updateWatchAccountHiddenFromTotalBalance(string address, bool hideFromTotalBalance)
property var account property var account
property var keyPair property var keyPair
@ -218,6 +219,27 @@ ColumnLayout {
StatusListItem { StatusListItem {
Layout.fillWidth: true 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") title: qsTr("Preferred networks when sharing this address")
color: Theme.palette.transparent color: Theme.palette.transparent
components: [ components: [

View File

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

View File

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

View File

@ -82,31 +82,6 @@ Item {
visible: !overview.isAllAccounts 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 // network filter
NetworkFilter { NetworkFilter {
id: networkFilter id: networkFilter

View File

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

View File

@ -5,6 +5,8 @@ import StatusQ.Popups 0.1
import "../stores" import "../stores"
import utils 1.0
StatusMenu { StatusMenu {
id: root id: root
@ -14,6 +16,7 @@ StatusMenu {
signal deleteAccountClicked() signal deleteAccountClicked()
signal addNewAccountClicked() signal addNewAccountClicked()
signal addWatchOnlyAccountClicked() signal addWatchOnlyAccountClicked()
signal hideFromTotalBalanceClicked(string address, bool hideFromTotalBalance)
width: 204 width: 204
@ -40,6 +43,14 @@ StatusMenu {
onTriggered: { onTriggered: {
root.editAccountClicked() 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 { StatusAction {

View File

@ -115,6 +115,8 @@ Rectangle {
removeAccountConfirmation.accountDerivationPath = account.path removeAccountConfirmation.accountDerivationPath = account.path
removeAccountConfirmation.active = true removeAccountConfirmation.active = true
} }
onHideFromTotalBalanceClicked: RootStore.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
} }
} }
@ -158,7 +160,7 @@ Rectangle {
function onDestroyAddAccountPopup() { function onDestroyAddAccountPopup() {
addAccount.active = false addAccount.active = false
} }
function onFilterChanged(address, includeWatchOnly, allAddresses) { function onFilterChanged(address, allAddresses) {
root.currentAddress = allAddresses ? "" : address root.currentAddress = allAddresses ? "" : address
root.showAllAccounts = allAddresses root.showAllAccounts = allAddresses
} }
@ -269,7 +271,7 @@ Rectangle {
} }
anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined
title: model.name title: model.name
subTitle: LocaleUtils.currencyAmountToLocaleString(model.currencyBalance) subTitle: !model.hideFromTotalBalance ? LocaleUtils.currencyAmountToLocaleString(model.currencyBalance): ""
asset.emoji: !!model.emoji ? model.emoji: "" asset.emoji: !!model.emoji ? model.emoji: ""
asset.color: Utils.getColorForId(model.colorId) asset.color: Utils.getColorForId(model.colorId)
asset.name: !model.emoji ? "filled-account": "" 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) { function onShowToastKeypairRemoved(keypairName: string) {
Global.displayToastMessage( Global.displayToastMessage(
qsTr("“%1” keypair and its derived accounts were successfully removed from all devices").arg(keypairName), 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