diff --git a/src/app/modules/main/wallet_section/account_tokens/module.nim b/src/app/modules/main/wallet_section/account_tokens/module.nim index 729c86bc6d..3b0d1f254c 100644 --- a/src/app/modules/main/wallet_section/account_tokens/module.nim +++ b/src/app/modules/main/wallet_section/account_tokens/module.nim @@ -49,10 +49,10 @@ method load*(self: Module) = singletonInstance.engine.setRootContextProperty("walletSectionAccountTokens", newQVariant(self.view)) # these connections should be part of the controller's init method - self.events.on("walletAccount/currencyUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args): self.switchAccount(self.currentAccountIndex) - self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args): self.switchAccount(self.currentAccountIndex) self.controller.init() diff --git a/src/app/modules/main/wallet_section/accounts/module.nim b/src/app/modules/main/wallet_section/accounts/module.nim index 7deb1b3251..5fc6c98242 100644 --- a/src/app/modules/main/wallet_section/accounts/module.nim +++ b/src/app/modules/main/wallet_section/accounts/module.nim @@ -71,19 +71,19 @@ method load*(self: Module) = singletonInstance.engine.setRootContextProperty("walletSectionAccounts", newQVariant(self.view)) # these connections should be part of the controller's init method - self.events.on("walletAccount/accountSaved") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_SAVED) do(e:Args): self.refreshWalletAccounts() - self.events.on("walletAccount/accountDeleted") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args): self.refreshWalletAccounts() - self.events.on("walletAccount/currencyUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args): self.refreshWalletAccounts() - self.events.on("walletAccount/walletAccountUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args): self.refreshWalletAccounts() - self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args): self.refreshWalletAccounts() self.controller.init() diff --git a/src/app/modules/main/wallet_section/current_account/module.nim b/src/app/modules/main/wallet_section/current_account/module.nim index 771c4dec29..59a7f96635 100644 --- a/src/app/modules/main/wallet_section/current_account/module.nim +++ b/src/app/modules/main/wallet_section/current_account/module.nim @@ -38,13 +38,13 @@ method load*(self: Module) = singletonInstance.engine.setRootContextProperty("walletSectionCurrent", newQVariant(self.view)) # these connections should be part of the controller's init method - self.events.on("walletAccount/walletAccountUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args): self.switchAccount(self.currentAccountIndex) - self.events.on("walletAccount/currencyUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args): self.switchAccount(self.currentAccountIndex) - self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args): self.switchAccount(self.currentAccountIndex) self.controller.init() diff --git a/src/app/modules/main/wallet_section/module.nim b/src/app/modules/main/wallet_section/module.nim index 35f50c820e..f5095d3cff 100644 --- a/src/app/modules/main/wallet_section/module.nim +++ b/src/app/modules/main/wallet_section/module.nim @@ -90,13 +90,13 @@ method setTotalCurrencyBalance*[T](self: Module[T]) = method load*[T](self: Module[T]) = singletonInstance.engine.setRootContextProperty("walletSection", newQVariant(self.view)) - self.events.on("walletAccount/accountSaved") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_SAVED) do(e:Args): self.setTotalCurrencyBalance() - self.events.on("walletAccount/accountDeleted") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args): self.setTotalCurrencyBalance() - self.events.on("walletAccount/currencyUpdated") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args): self.setTotalCurrencyBalance() - self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args): + self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args): self.setTotalCurrencyBalance() self.controller.init() diff --git a/src/app_service/service/wallet_account/service.nim b/src/app_service/service/wallet_account/service.nim index f0a245d383..758e6dac03 100644 --- a/src/app_service/service/wallet_account/service.nim +++ b/src/app_service/service/wallet_account/service.nim @@ -19,6 +19,12 @@ export service_interface logScope: topics = "wallet-account-service" +const SIGNAL_WALLET_ACCOUNT_SAVED* = "walletAccount/accountSaved" +const SIGNAL_WALLET_ACCOUNT_DELETED* = "walletAccount/accountDeleted" +const SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED* = "walletAccount/currencyUpdated" +const SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED* = "walletAccount/tokenVisibilityUpdated" +const SIGNAL_WALLET_ACCOUNT_UPDATED* = "walletAccount/walletAccountUpdated" + var priceCache {.threadvar.}: Table[string, float64] balanceCache {.threadvar.}: Table[string, float64] @@ -216,7 +222,7 @@ method addNewAccountToLocalStore(self: Service) = let balances = self.fetchBalances(@[newAccount.address]) newAccount.tokens = self.buildTokens(newAccount, prices, balances{newAccount.address}) self.accounts[newAccount.address] = newAccount - self.events.emit("walletAccount/accountSaved", AccountSaved(account: newAccount)) + self.events.emit(SIGNAL_WALLET_ACCOUNT_SAVED, AccountSaved(account: newAccount)) method generateNewAccount*(self: Service, password: string, accountName: string, color: string): string = try: @@ -272,17 +278,17 @@ method deleteAccount*(self: Service, address: string) = let accountDeleted = self.accounts[address] self.accounts.del(address) - self.events.emit("walletAccount/accountDeleted", AccountDeleted(account: accountDeleted)) + self.events.emit(SIGNAL_WALLET_ACCOUNT_DELETED, AccountDeleted(account: accountDeleted)) method updateCurrency*(self: Service, newCurrency: string) = discard self.settingsService.saveCurrency(newCurrency) self.refreshBalances() - self.events.emit("walletAccount/currencyUpdated", CurrencyUpdated()) + self.events.emit(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED, CurrencyUpdated()) method toggleTokenVisible*(self: Service, symbol: string) = self.tokenService.toggleVisible(symbol) self.refreshBalances() - self.events.emit("walletAccount/tokenVisibilityToggled", TokenVisibilityToggled()) + self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED, TokenVisibilityToggled()) method updateWalletAccount*(self: Service, address: string, accountName: string, color: string) = let account = self.accounts[address] @@ -296,4 +302,4 @@ method updateWalletAccount*(self: Service, address: string, accountName: string, account.name = accountName account.color = color - self.events.emit("walletAccount/walletAccountUpdated", WalletAccountUpdated(account: account)) \ No newline at end of file + self.events.emit(SIGNAL_WALLET_ACCOUNT_UPDATED, WalletAccountUpdated(account: account)) \ No newline at end of file