From 3750b9933ecc8bfdadb2a39e1be1b801e82a6cc8 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Wed, 3 Apr 2024 14:47:52 +0100 Subject: [PATCH] chore: supress UnreachableCode check in keycard_popup/controller.nim (#14254) --- .../keycard_popup/controller.nim | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/app/modules/shared_modules/keycard_popup/controller.nim b/src/app/modules/shared_modules/keycard_popup/controller.nim index e2d68712d3..efaec6bc7e 100644 --- a/src/app/modules/shared_modules/keycard_popup/controller.nim +++ b/src/app/modules/shared_modules/keycard_popup/controller.nim @@ -107,27 +107,7 @@ proc newController*(delegate: io_interface.AccessInterface, ## Forward declaration: proc finishFlowTermination(self: Controller) - -proc serviceApplicable[T](service: T): bool = - if not service.isNil: - return true - when (service is keycard_service.Service): - error "KeycardService is mandatory for using shared keycard popup module" - return - var serviceName = "" - when (service is wallet_account_service.Service): - serviceName = "WalletAccountService" - when (service is privacy_service.Service): - serviceName = "PrivacyService" - when (service is settings_service.Service): - serviceName = "SettingsService" - when (service is network_service.Service): - serviceName = "NetworkService" - when (service is accounts_service.Service): - serviceName = "AccountsService" - when (service is keychain_service.Service): - serviceName = "KeychainService" - debug "service is not set, check the context shared keycard popup module is used", service=serviceName +proc serviceApplicable[T](service: T): bool proc disconnectKeycardReponseSignal(self: Controller) = self.events.disconnect(self.connectionKeycardResponse) @@ -855,3 +835,29 @@ proc getTotalCurrencyBalance*(self: Controller, address: string, chainIds: seq[i proc parseCurrencyValueByTokensKey*(self: Controller, tokensKey: string, amountInt: UInt256): float64 = return self.walletAccountService.parseCurrencyValueByTokensKey(tokensKey, amountInt) + +# Keep this function at the end of the file. +# There's a bug in Nim: https://github.com/nim-lang/Nim/issues/23002 +# that blocks us from enabling back the warning pragma. + +{.warning[UnreachableCode]: off.} +proc serviceApplicable[T](service: T): bool = + if not service.isNil: + return true + when (service is keycard_service.Service): + error "KeycardService is mandatory for using shared keycard popup module" + return + var serviceName = "" + when (service is wallet_account_service.Service): + serviceName = "WalletAccountService" + when (service is privacy_service.Service): + serviceName = "PrivacyService" + when (service is settings_service.Service): + serviceName = "SettingsService" + when (service is network_service.Service): + serviceName = "NetworkService" + when (service is accounts_service.Service): + serviceName = "AccountsService" + when (service is keychain_service.Service): + serviceName = "KeychainService" + debug "service is not set, check the context shared keycard popup module is used", service=serviceName