From 36fa19a690d4ea4df43a1151d54be70246e0b388 Mon Sep 17 00:00:00 2001 From: Antonio Bello Date: Fri, 6 Dec 2024 01:12:57 +0100 Subject: [PATCH] 631 Add feature toggle for storage alert feature (#637) https://github.com/Outblock/FRW-iOS/issues/631 --- FRW/Services/Manager/Config/RemoteConfig.swift | 6 +++++- FRW/Services/Manager/TransactionManager.swift | 4 +++- FRW/UI/Component/InsufficientStorageToastView.swift | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/FRW/Services/Manager/Config/RemoteConfig.swift b/FRW/Services/Manager/Config/RemoteConfig.swift index 212e71bb..1290f7a0 100644 --- a/FRW/Services/Manager/Config/RemoteConfig.swift +++ b/FRW/Services/Manager/Config/RemoteConfig.swift @@ -46,6 +46,8 @@ extension RemoteConfigManager { case browser case nftTransfer = "nft_transfer" case hideBrowser = "hide_browser" + case insufficientBalance = "insufficient_balance" + case insufficientStorage = "insufficient_storage" } let freeGas: Bool @@ -56,6 +58,8 @@ extension RemoteConfigManager { let browser: Bool? let nftTransfer: Bool? let hideBrowser: Bool? + let insufficientBalance: Bool? + let insufficientStorage: Bool? } // MARK: - Payer @@ -205,7 +209,7 @@ extension RemoteConfigManager { return true case .insufficientStorage: // TODO: [AB] Not very elegant adding a dependency here, but implementing in a different way would probably require major refactoring - return WalletManager.shared.isStorageInsufficient + return WalletManager.shared.isStorageInsufficient && RemoteConfigManager.shared.config?.features.insufficientStorage ?? true default: return false } diff --git a/FRW/Services/Manager/TransactionManager.swift b/FRW/Services/Manager/TransactionManager.swift index 91a58b24..be41a1bb 100644 --- a/FRW/Services/Manager/TransactionManager.swift +++ b/FRW/Services/Manager/TransactionManager.swift @@ -266,7 +266,9 @@ extension TransactionManager { switch result.errorCode { case .storageCapacityExceeded: - AlertViewController.showInsufficientStorageError(minimumBalance: WalletManager.shared.minimumStorageBalance.doubleValue) + if RemoteConfigManager.shared.config?.features.insufficientStorage ?? true { + AlertViewController.showInsufficientStorageError(minimumBalance: WalletManager.shared.minimumStorageBalance.doubleValue) + } default: break } diff --git a/FRW/UI/Component/InsufficientStorageToastView.swift b/FRW/UI/Component/InsufficientStorageToastView.swift index 536b025b..7085fa14 100644 --- a/FRW/UI/Component/InsufficientStorageToastView.swift +++ b/FRW/UI/Component/InsufficientStorageToastView.swift @@ -23,7 +23,11 @@ protocol InsufficientStorageToastViewModel: ObservableObject { } extension InsufficientStorageToastViewModel { - var showInsufficientFundsToast: Bool { self.variant != nil } + private var isInsufficientStorageEnabled: Bool { RemoteConfigManager.shared.config?.features.insufficientStorage ?? true } + + var showInsufficientFundsToast: Bool { + self.isInsufficientStorageEnabled && self.variant != nil + } func insufficientStorageCheckForMove(token: TokenType, from fromWallet: Contact.WalletType?, to toWallet: Contact.WalletType?) -> InsufficientStorageFailure? { insufficientStorageCheck(amount: 0, token: token, from: fromWallet, to: toWallet) @@ -42,6 +46,8 @@ extension InsufficientStorageToastViewModel { } private func insufficientStorageCheck(amount: Decimal, token: TokenType, from fromWallet: Contact.WalletType?, to toWallet: Contact.WalletType?) -> InsufficientStorageFailure? { + guard self.isInsufficientStorageEnabled == true else { return .none } + let wm = WalletManager.shared guard wm.isStorageInsufficient == false else { return .some(.beforeTransfer)