Skip to content

Commit

Permalink
Add FF settings to load custom deployment URL (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored and mike-dydx committed Aug 20, 2024
1 parent 6445aa6 commit 9110419
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down
8 changes: 2 additions & 6 deletions dydx/dydxFormatter/dydxFormatter/_Utils/dydxFeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -32,7 +28,7 @@ public enum dydxBoolFeatureFlag: String, CaseIterable {
}

public enum dydxStringFeatureFlag: String {
case v4_theme
case deployment_url

private static let obj = NSObject()

Expand Down
216 changes: 7 additions & 209 deletions dydx/dydxPresenters/dydxPresenters/_Features/features.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -155,62 +33,6 @@
]
}
},
{
"title":{
"text":"Enable Leagues"
},
"field":{
"field":"leagues_enabled",
"type":"bool",
"optional":true,
"options" : [
{
"text": "yes",
"value" : "1"
},
{
"text": "no",
"value" : "<null>"
}
]
}
},
{
"title":{
"text":"Enable Combined Markets Graph"
},
"field":{
"field":"combined_markets_graph_enabled",
"type":"bool",
"optional":true,
"options" : [
{
"text": "yes",
"value" : "1"
},
{
"text": "no",
"value" : "<null>"
}
]
}
}
]
},
{
"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"
Expand Down Expand Up @@ -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"
}
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 7 additions & 3 deletions dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -143,7 +147,7 @@ public final class AbacusStateManager: NSObject {
}

return AsyncAbacusStateManager(
deploymentUri: deploymentUri + "/",
deploymentUri: deploymentUri,
deployment: deployment,
appConfigs: appConfigs,
ioImplementations: IOImplementations.shared,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9110419

Please sign in to comment.