From 842a815077bd19f6aeea1ea4837c52416045fea1 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:54:49 -0800 Subject: [PATCH] Add FF settings to load custom deployment URL (#21) --- .../Input/FieldInputTextsInputView.swift | 9 +- .../_Utils/dydxFeatureFlag.swift | 8 +- .../dydxPresenters/_Features/features.json | 216 +----------------- .../Workers/dydxCarteraConfigWorker.swift | 3 +- .../dydxStateManager/AbacusStateManager.swift | 10 +- .../AbacusWebSocketImp.swift | 4 + 6 files changed, 29 insertions(+), 221 deletions(-) diff --git a/PlatformUIJedio/PlatformUIJedio/Views/Components/Input/FieldInputTextsInputView.swift b/PlatformUIJedio/PlatformUIJedio/Views/Components/Input/FieldInputTextsInputView.swift index 53805074..ed921e9b 100644 --- a/PlatformUIJedio/PlatformUIJedio/Views/Components/Input/FieldInputTextsInputView.swift +++ b/PlatformUIJedio/PlatformUIJedio/Views/Components/Input/FieldInputTextsInputView.swift @@ -44,11 +44,16 @@ public class FieldInputTextsInputViewModel: FieldInputBaseViewModel { Spacer() PlatformInputModel(value: self.inputBinding, currentValue: self.input?.value as? String, - keyboardType: .default) + keyboardType: .default, + onEditingChanged: { [weak self] focused in + if (focused == false) { + self?.valueChanged?(self?.input?.value) + } + }) .createView(parentStyle: style) .padding(.vertical, 2) .padding(.horizontal, 8) - .themeColor(background: .layer0) + .themeColor(background: .layer5) } .padding() ) diff --git a/dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift b/dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift index d4254b91..2298caa7 100644 --- a/dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift +++ b/dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift @@ -12,11 +12,7 @@ import Utilities public enum dydxBoolFeatureFlag: String, CaseIterable { case push_notification case full_story - case magic_link - case fixed_gas_estimate - case deposit_feature - case withdrawal_feature - case transfer_out_feature + case force_mainnet private static let obj = NSObject() @@ -32,7 +28,7 @@ public enum dydxBoolFeatureFlag: String, CaseIterable { } public enum dydxStringFeatureFlag: String { - case v4_theme + case deployment_url private static let obj = NSObject() diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/features.json b/dydx/dydxPresenters/dydxPresenters/_Features/features.json index 8282d37d..05ce3746 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/features.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/features.json @@ -1,148 +1,26 @@ [ { - "title":"Under Construction", - "input":"1", - "fields":[ - { - "title":{ - "text":"Deposit" - }, - "field":{ - "field":"deposit_feature", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] - } - }, - { - "title":{ - "text":"Withdrawal" - }, - "field":{ - "field":"withdrawal_feature", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] - } - }, - { - "title":{ - "text":"TransferOut" - }, - "field":{ - "field":"transfer_out_feature", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] - } - } - ] - }, - { - "title":"Restrictions and Compliances", - "input":"1", - "fields":[ - { - "title":{ - "text":"Compliance Enabled" - }, - "field":{ - "field":"compliance_enabled", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] - } - } - ] - }, - { - "title":"AB Testing", + "title":"Dev Testing", "input":"1", "fields":[ { "title":{ - "text":"Skip onboarding check" + "text":"Deployment Config" }, "field":{ - "field":"skip_onboarding_check", + "field":"deployment_url", "optional":true, - "type" : "bool", - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] - } - }, - { - "title":{ - "text":"Fixed Gas Estimate" - }, - "field":{ - "field":"fixed_gas_estimate", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "0" - } - ] + "type" : "text" } }, { "title":{ - "text":"Requires Username" + "text":"Force Mainnet" }, "field":{ - "field":"username_required", - "type":"bool", + "field":"force_mainnet", "optional":true, + "type" : "text", "options" : [ { "text": "yes", @@ -155,62 +33,6 @@ ] } }, - { - "title":{ - "text":"Enable Leagues" - }, - "field":{ - "field":"leagues_enabled", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "" - } - ] - } - }, - { - "title":{ - "text":"Enable Combined Markets Graph" - }, - "field":{ - "field":"combined_markets_graph_enabled", - "type":"bool", - "optional":true, - "options" : [ - { - "text": "yes", - "value" : "1" - }, - { - "text": "no", - "value" : "" - } - ] - } - } - ] - }, - { - "title":"Dev Testing", - "input":"1", - "fields":[ - { - "title":{ - "text":"Wallet Connect Bridge Server" - }, - "field":{ - "field":"walletconnect_bridge_url", - "optional":true, - "type" : "text" - } - }, { "title":{ "text":"Push Notification" @@ -250,30 +72,6 @@ } ] } - }, - { - "title":{ - "text":"V4 Theme" - }, - "field":{ - "field":"v4_theme", - "optional":true, - "type" : "text", - "options" : [ - { - "text": "Dark", - "value" : "dark" - }, - { - "text": "Light", - "value" : "light" - }, - { - "text": "System", - "value" : "system" - } - ] - } } ] } diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxCarteraConfigWorker.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxCarteraConfigWorker.swift index b6710bdb..7ab1899d 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxCarteraConfigWorker.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxCarteraConfigWorker.swift @@ -72,7 +72,8 @@ extension WalletConnectV2Config { extension WalletSegueConfig { init?(environment: V4Environment) { - guard let callbackUrl = environment.walletConnection?.walletSegue?.callbackUrl else { + guard let callbackUrl = environment.walletConnection?.walletSegue?.callbackUrl, + let _ = URL(string: callbackUrl) else { return nil } diff --git a/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift b/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift index 503d720f..ad781b75 100644 --- a/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift +++ b/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift @@ -9,11 +9,12 @@ import Abacus import Combine import Utilities import ParticlesKit +import dydxFormatter public final class AbacusStateManager: NSObject { public static let shared = AbacusStateManager() - public let deploymentUri = (CredientialConfig.shared.key(for: "webAppUrl"))! + public let deploymentUri = dydxStringFeatureFlag.deployment_url.string ?? (CredientialConfig.shared.key(for: "webAppUrl"))! public var isMainNet: Bool { asyncStateManager.environment?.isMainNet ?? false @@ -128,7 +129,10 @@ public final class AbacusStateManager: NSObject { let deployment: String let appConfigs: AppConfigs - if DebugEnabled.enabled { + if dydxBoolFeatureFlag.force_mainnet.isEnabled { + deployment = "MAINNET" + appConfigs = AppConfigs.companion.forApp + } else if DebugEnabled.enabled { // For debugging only deployment = "DEV" #if DEBUG @@ -143,7 +147,7 @@ public final class AbacusStateManager: NSObject { } return AsyncAbacusStateManager( - deploymentUri: deploymentUri + "/", + deploymentUri: deploymentUri, deployment: deployment, appConfigs: appConfigs, ioImplementations: IOImplementations.shared, diff --git a/dydx/dydxStateManager/dydxStateManager/Protocol Implementations/AbacusWebSocketImp.swift b/dydx/dydxStateManager/dydxStateManager/Protocol Implementations/AbacusWebSocketImp.swift index 10277fa6..363adecf 100644 --- a/dydx/dydxStateManager/dydxStateManager/Protocol Implementations/AbacusWebSocketImp.swift +++ b/dydx/dydxStateManager/dydxStateManager/Protocol Implementations/AbacusWebSocketImp.swift @@ -27,6 +27,10 @@ final public class AbacusWebSocketImp: NSObject, Abacus.WebSocketProtocol { } public func connect(url: String, connected: @escaping (KotlinBoolean) -> Void, received: @escaping (String) -> Void) { + guard url.starts(with: "ws") else { + return + } + self.url = url self.connected = connected self.received = received