Skip to content

Commit 097e16b

Browse files
committed
dapp warning, dapp feature toggle
1 parent d24eac1 commit 097e16b

24 files changed

+149
-15
lines changed

fearless.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,7 @@
20682068
F83EA1F4ECE14C390C0B287F /* StakingUnbondSetupInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D101339CC1292531CC4DB0AC /* StakingUnbondSetupInteractor.swift */; };
20692069
F865D752EBD2363E971BE267 /* MainNftContainerAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E69C4F66805399A3DB4ED8 /* MainNftContainerAssembly.swift */; };
20702070
F952CDC56E85FA82DDEBE5D3 /* FeatureToggleListRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4EE06DBE885C0467D8929FE /* FeatureToggleListRouter.swift */; };
2071+
FA0025882D68503E00B84297 /* FeatureToggleConfigSyncComplete.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA0025872D68503700B84297 /* FeatureToggleConfigSyncComplete.swift */; };
20712072
FA00488F282CC7710032FF49 /* SelectValidatorsStartFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA00488E282CC7710032FF49 /* SelectValidatorsStartFlow.swift */; };
20722073
FA004891282CCA400032FF49 /* SelectValidatorsStartParachainStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA004890282CCA400032FF49 /* SelectValidatorsStartParachainStrategy.swift */; };
20732074
FA004893282CCA520032FF49 /* SelectValidatorsStartRelaychainStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA004892282CCA520032FF49 /* SelectValidatorsStartRelaychainStrategy.swift */; };
@@ -5374,6 +5375,7 @@
53745375
F829E7F8B39EE7D977001510 /* ControllerAccountProtocols.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ControllerAccountProtocols.swift; sourceTree = "<group>"; };
53755376
F9416E68AE4D5613E9434226 /* StakingPoolCreateConfirmViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = StakingPoolCreateConfirmViewController.swift; sourceTree = "<group>"; };
53765377
F9B5FD28F2B9A0B0D8ED3607 /* PolkaswapSwapConfirmationInteractor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PolkaswapSwapConfirmationInteractor.swift; sourceTree = "<group>"; };
5378+
FA0025872D68503700B84297 /* FeatureToggleConfigSyncComplete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureToggleConfigSyncComplete.swift; sourceTree = "<group>"; };
53775379
FA00488E282CC7710032FF49 /* SelectValidatorsStartFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectValidatorsStartFlow.swift; sourceTree = "<group>"; };
53785380
FA004890282CCA400032FF49 /* SelectValidatorsStartParachainStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectValidatorsStartParachainStrategy.swift; sourceTree = "<group>"; };
53795381
FA004892282CCA520032FF49 /* SelectValidatorsStartRelaychainStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectValidatorsStartRelaychainStrategy.swift; sourceTree = "<group>"; };
@@ -11436,6 +11438,7 @@
1143611438
84EBC54824F660A700459D15 /* Events */ = {
1143711439
isa = PBXGroup;
1143811440
children = (
11441+
FA0025872D68503700B84297 /* FeatureToggleConfigSyncComplete.swift */,
1143911442
FA46449D2D49E13E00E21668 /* SelectedCurrencyChanged.swift */,
1144011443
071606C32C7C6C2400C1DF75 /* PricesUpdated.swift */,
1144111444
0701B9CC2C78FF7900DCD395 /* AccountScoreSettingsChanged.swift */,
@@ -18927,6 +18930,7 @@
1892718930
84DED3F726662CF200A153BB /* TitleValueSelectionControl.swift in Sources */,
1892818931
FAADC1BC2926597400DA9903 /* ScanQRRouter.swift in Sources */,
1892918932
076D9D6629507B39002762E3 /* PolkaswapSettingsFactory.swift in Sources */,
18933+
FA0025882D68503E00B84297 /* FeatureToggleConfigSyncComplete.swift in Sources */,
1893018934
07B018D328C714B300E05510 /* ScamServiceOperationFactory.swift in Sources */,
1893118935
07E346D4288E616E00A8FAEC /* WalletBalanceBuilder.swift in Sources */,
1893218936
84F30EA125FD3EE700039D09 /* ChildSubscriptionFactory.swift in Sources */,

fearless/ApplicationLayer/Services/FeatureToggle/FeatureToggleConfig.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import Foundation
33
struct FeatureToggleConfig: Decodable {
44
let pendulumCaseEnabled: Bool?
55
let nftEnabled: Bool?
6+
let dappEnabled: Bool?
67

78
static var defaultConfig: FeatureToggleConfig {
8-
FeatureToggleConfig(pendulumCaseEnabled: false, nftEnabled: true)
9+
FeatureToggleConfig(pendulumCaseEnabled: false, nftEnabled: true, dappEnabled: true)
910
}
1011
}

fearless/ApplicationLayer/Services/FeatureToggle/FeatureToggleService.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22
import SSFNetwork
33
import RobinHood
44
import SSFUtils
5+
import SoraKeystore
56

67
enum FeatureToggleServiceError: Error {
78
case urlBroken
@@ -19,17 +20,23 @@ final class FeatureToggleProvider {
1920

2021
private let networkOperationFactory: NetworkOperationFactoryProtocol
2122
private let operationQueue: OperationQueue
22-
23+
private let settingsManager: SettingsManagerProtocol
24+
private let eventCenter: EventCenterProtocol
25+
2326
private(set) var snapshot: FeatureToggleConfig?
2427
private(set) var pendingRequests: [PendingRequest] = []
2528

2629
init(
2730
networkOperationFactory: NetworkOperationFactoryProtocol,
28-
operationQueue: OperationQueue
31+
operationQueue: OperationQueue,
32+
settingsManager: SettingsManagerProtocol,
33+
eventCenter: EventCenterProtocol
2934
) {
3035
self.networkOperationFactory = networkOperationFactory
3136
self.operationQueue = operationQueue
32-
37+
self.settingsManager = settingsManager
38+
self.eventCenter = eventCenter
39+
3340
do {
3441
try setup()
3542
} catch {
@@ -58,6 +65,10 @@ final class FeatureToggleProvider {
5865
let request = PendingRequest(resultClosure: closure, queue: queue)
5966

6067
if let snapshot = snapshot {
68+
settingsManager.dappEnabled = snapshot.dappEnabled.or(FeatureToggleConfig.defaultConfig.dappEnabled ?? true)
69+
70+
eventCenter.notify(with: FeatureToggleConfigSyncComplete(config: snapshot))
71+
6172
deliver(snapshot: snapshot, to: request)
6273
} else {
6374
pendingRequests.append(request)

fearless/Common/EventCenter/EventVisitor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ protocol EventVisitorProtocol: AnyObject {
3131
func processPricesUpdated()
3232
func processSelectedCurrencyChanged(event: SelectedCurrencyChangedEvent)
3333
func processTonConnectEstablished()
34+
func processFeatureToggleConfigSyncComplete(event: FeatureToggleConfigSyncComplete)
3435
}
3536

3637
extension EventVisitorProtocol {
@@ -64,4 +65,5 @@ extension EventVisitorProtocol {
6465
func processPricesUpdated() {}
6566
func processSelectedCurrencyChanged(event: SelectedCurrencyChangedEvent) {}
6667
func processTonConnectEstablished() {}
68+
func processFeatureToggleConfigSyncComplete(event: FeatureToggleConfigSyncComplete) {}
6769
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Foundation
2+
import SSFModels
3+
4+
struct FeatureToggleConfigSyncComplete: EventProtocol {
5+
let config: FeatureToggleConfig
6+
7+
func accept(visitor: EventVisitorProtocol) {
8+
visitor.processFeatureToggleConfigSyncComplete(event: self)
9+
}
10+
}

fearless/Common/Extension/SettingsExtension.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum SettingsKey: String {
1616
case shouldPlayAssetManagementAnimateKey
1717
case accountScoreEnabled
1818
case shouldShowAddWalletBanner
19+
case dappEnabled
1920
}
2021

2122
extension SettingsManagerProtocol {
@@ -103,4 +104,14 @@ extension SettingsManagerProtocol {
103104
set(value: newValue, for: SettingsKey.shouldShowAddWalletBanner.rawValue)
104105
}
105106
}
107+
108+
var dappEnabled: Bool {
109+
get {
110+
bool(for: SettingsKey.dappEnabled.rawValue) ?? true
111+
}
112+
113+
set {
114+
set(value: newValue, for: SettingsKey.dappEnabled.rawValue)
115+
}
116+
}
106117
}

fearless/Modules/DappBrowser/DappBrowserPresenter.swift

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,36 @@ extension DappBrowserPresenter: DappBrowserViewOutput {
132132
}
133133

134134
func didSelect(dapp: TonDapp) {
135-
router.showDapp(from: view, dapp: dapp, wallet: wallet, moduleOutput: self)
135+
let confirmAction = SheetAlertPresentableAction(title: R.string.localizable.commonConfirm(preferredLanguages: selectedLocale.rLanguages), style: .pinkBackgroundWhiteText ,handler: { [weak self] in
136+
guard let self else {
137+
return
138+
}
139+
140+
self.router.showDapp(
141+
from: self.view,
142+
dapp: dapp,
143+
wallet: self.wallet,
144+
moduleOutput: self
145+
)
146+
})
147+
148+
let termsAction = SheetAlertPresentableAction(title: R.string.localizable.aboutTermsAndConditions(preferredLanguages: selectedLocale.rLanguages), style: .grayBackgroundPinkText, handler: { [weak self] in
149+
guard let self, let view = self.view else {
150+
return
151+
}
152+
153+
self.router.showWeb(url: ApplicationConfig.shared.termsURL, from: view, style: .modal)
154+
})
155+
156+
let declineAction = SheetAlertPresentableAction(title: R.string.localizable.commonDecline(preferredLanguages: selectedLocale.rLanguages), style: .grayBackgroundWhiteText)
157+
158+
router.present(
159+
message: R.string.localizable.webThirdPartyWarningDescription(preferredLanguages: selectedLocale.rLanguages),
160+
title: R.string.localizable.webThirdPartyWarningTitle(preferredLanguages: selectedLocale.rLanguages),
161+
closeAction: nil,
162+
from: view,
163+
actions: [confirmAction, declineAction, termsAction]
164+
)
136165
}
137166

138167
func didTapOnWalletSelectButton() {

fearless/Modules/DappBrowser/DappBrowserProtocols.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ typealias DappBrowserModuleCreationResult = (
55
input: DappBrowserModuleInput
66
)
77

8-
protocol DappBrowserRouterInput: AccountManagementPresentable {
8+
protocol DappBrowserRouterInput: AccountManagementPresentable, SheetAlertPresentable, WebPresentable {
99
func showWalletManagment(
1010
from view: ControllerBackedProtocol?,
1111
moduleOutput: WalletsManagmentModuleOutput?

fearless/Modules/DappBrowserList/DappBrowserListPresenter.swift

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,34 @@ final class DappBrowserListPresenter {
5858
// MARK: - DappBrowserListViewOutput
5959
extension DappBrowserListPresenter: DappBrowserListViewOutput {
6060
func didSelect(dapp: TonDapp) {
61-
router.showDapp(
61+
let confirmAction = SheetAlertPresentableAction(title: R.string.localizable.commonConfirm(preferredLanguages: selectedLocale.rLanguages), style: .pinkBackgroundWhiteText ,handler: { [weak self] in
62+
guard let self else {
63+
return
64+
}
65+
66+
self.router.showDapp(
67+
from: self.view,
68+
dapp: dapp,
69+
wallet: self.wallet
70+
)
71+
})
72+
73+
let termsAction = SheetAlertPresentableAction(title: R.string.localizable.aboutTermsAndConditions(preferredLanguages: selectedLocale.rLanguages), style: .grayBackgroundPinkText, handler: { [weak self] in
74+
guard let self, let view = self.view else {
75+
return
76+
}
77+
78+
self.router.showWeb(url: ApplicationConfig.shared.termsURL, from: view, style: .modal)
79+
})
80+
81+
let declineAction = SheetAlertPresentableAction(title: R.string.localizable.commonDecline(preferredLanguages: selectedLocale.rLanguages), style: .grayBackgroundWhiteText)
82+
83+
router.present(
84+
message: R.string.localizable.webThirdPartyWarningDescription(preferredLanguages: selectedLocale.rLanguages),
85+
title: R.string.localizable.webThirdPartyWarningTitle(preferredLanguages: selectedLocale.rLanguages),
86+
closeAction: nil,
6287
from: view,
63-
dapp: dapp,
64-
wallet: wallet
88+
actions: [confirmAction, declineAction, termsAction]
6589
)
6690
}
6791

fearless/Modules/DappBrowserList/DappBrowserListProtocols.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ typealias DappBrowserListModuleCreationResult = (
55
input: DappBrowserListModuleInput
66
)
77

8-
protocol DappBrowserListRouterInput: PresentDismissable {
8+
protocol DappBrowserListRouterInput: PresentDismissable, SheetAlertPresentable, WebPresentable {
99
func showDapp(
1010
from view: ControllerBackedProtocol?,
1111
dapp: TonDapp,

0 commit comments

Comments
 (0)