Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

631 Add feature toggle for storage alert feature #637

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion FRW/Services/Manager/Config/RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,6 +58,8 @@ extension RemoteConfigManager {
let browser: Bool?
let nftTransfer: Bool?
let hideBrowser: Bool?
let insufficientBalance: Bool?
let insufficientStorage: Bool?
}

// MARK: - Payer
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion FRW/Services/Manager/TransactionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 7 additions & 1 deletion FRW/UI/Component/InsufficientStorageToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down