From 46f58b16162b1a00fad9416b60ac4ac7cec5840a Mon Sep 17 00:00:00 2001 From: Rui Date: Tue, 11 Jun 2024 11:48:08 -0700 Subject: [PATCH] MOB-544 Add preference setting for gas payment type --- .../FieldSettingsViewPresenter.swift | 12 +++- .../dydxPresenters.xcodeproj/project.pbxproj | 20 ++++++ .../_Features/routing_swiftui.json | 3 + .../dydxPresenters/_Features/settings.json | 8 +++ .../_Features/settings_debug.json | 8 +++ .../_Features/settings_gas_token.json | 26 +++++++ .../Workers/dydxGasTokenWorker.swift | 26 +++++++ .../_v4/GlobalWorkers/dydxGlobalWorkers.swift | 3 +- .../_v4/KeyValueStoreProtocolStore+Ext.swift | 6 ++ .../dydxProfileBalancesViewPresenter.swift | 6 +- .../GasToken/dydxGasTokenViewBuilder.swift | 70 +++++++++++++++++++ .../SettingsLandingViewPresenter.swift | 46 +++++++++--- ...xTransferInputCtaButtonViewPresenter.swift | 2 +- .../dydxTransferOutViewPresenter.swift | 6 +- .../dydxStateManager/AbacusStateManager.swift | 6 +- .../dydxStateManager/Models+Ext.swift | 10 +++ 16 files changed, 237 insertions(+), 21 deletions(-) create mode 100644 dydx/dydxPresenters/dydxPresenters/_Features/settings_gas_token.json create mode 100644 dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxGasTokenWorker.swift create mode 100644 dydx/dydxPresenters/dydxPresenters/_v4/Profile/GasToken/dydxGasTokenViewBuilder.swift diff --git a/PlatformUIJedio/PlatformUIJedio/Presenters/FieldSettingsViewPresenter.swift b/PlatformUIJedio/PlatformUIJedio/Presenters/FieldSettingsViewPresenter.swift index f4756e568..0155b804b 100644 --- a/PlatformUIJedio/PlatformUIJedio/Presenters/FieldSettingsViewPresenter.swift +++ b/PlatformUIJedio/PlatformUIJedio/Presenters/FieldSettingsViewPresenter.swift @@ -33,8 +33,8 @@ open class FieldSettingsViewPresenter: BaseSettingsViewPresenter { listModel.width = UIScreen.main.bounds.width - 16 let options: [[String: Any]]? = fieldInput?.options listModel.items = (options ?? []).compactMap { option in - guard let text = parser.asString(option["text"]), - let value = parser.asString(option["value"]) else { + guard let text = textForOption(option: option), + let value = valueForOption(option: option) else { return nil } @@ -63,6 +63,14 @@ open class FieldSettingsViewPresenter: BaseSettingsViewPresenter { open func onOptionSelected(option: [String: Any], changed: Bool) { } + + open func textForOption(option: [String: Any]) -> String? { + parser.asString(option["text"]) + } + + open func valueForOption(option: [String: Any]) -> String? { + parser.asString(option["value"]) + } private func findInput(fieldName: String) -> FieldInput? { for fieldList in fieldLists ?? [] { diff --git a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj index 3fe004551..443ce7f26 100644 --- a/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj +++ b/dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj @@ -117,6 +117,9 @@ 02E7B3B129D79A4400D6626D /* v4-native-client.js in Resources */ = {isa = PBXBuildFile; fileRef = 02E7B38729D79A4400D6626D /* v4-native-client.js */; }; 02E90C5A29D62719004E2311 /* dydxFeatureFlagsViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02E90C5929D62719004E2311 /* dydxFeatureFlagsViewBuilder.swift */; }; 02EF485629F732C600C97746 /* dydxFavoriteStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02EF485529F732C600C97746 /* dydxFavoriteStore.swift */; }; + 02F543B22C17ABBB000924E4 /* dydxGasTokenViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F543B12C17ABBB000924E4 /* dydxGasTokenViewBuilder.swift */; }; + 02F543B42C17AD6A000924E4 /* settings_gas_token.json in Resources */ = {isa = PBXBuildFile; fileRef = 02F543B32C17AD6A000924E4 /* settings_gas_token.json */; }; + 02F543B62C17B792000924E4 /* dydxGasTokenWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F543B52C17B792000924E4 /* dydxGasTokenWorker.swift */; }; 02F6E71F2A8293270018F00C /* dydxProfileFeesViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F6E71E2A8293270018F00C /* dydxProfileFeesViewPresenter.swift */; }; 02F700FE29EA0FD9004DEB5E /* dydxReceiptPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F700FD29EA0FD9004DEB5E /* dydxReceiptPresenter.swift */; }; 02F7010029EA165F004DEB5E /* dydxTransferReceiptViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F700FF29EA165F004DEB5E /* dydxTransferReceiptViewPresenter.swift */; }; @@ -498,6 +501,9 @@ 02E7DD9128CFB30000727949 /* dydxStateManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = dydxStateManager.xcodeproj; path = ../dydxStateManager/dydxStateManager.xcodeproj; sourceTree = ""; }; 02E90C5929D62719004E2311 /* dydxFeatureFlagsViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxFeatureFlagsViewBuilder.swift; sourceTree = ""; }; 02EF485529F732C600C97746 /* dydxFavoriteStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxFavoriteStore.swift; sourceTree = ""; }; + 02F543B12C17ABBB000924E4 /* dydxGasTokenViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxGasTokenViewBuilder.swift; sourceTree = ""; }; + 02F543B32C17AD6A000924E4 /* settings_gas_token.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = settings_gas_token.json; sourceTree = ""; }; + 02F543B52C17B792000924E4 /* dydxGasTokenWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxGasTokenWorker.swift; sourceTree = ""; }; 02F6E71E2A8293270018F00C /* dydxProfileFeesViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxProfileFeesViewPresenter.swift; sourceTree = ""; }; 02F700FD29EA0FD9004DEB5E /* dydxReceiptPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxReceiptPresenter.swift; sourceTree = ""; }; 02F700FF29EA165F004DEB5E /* dydxTransferReceiptViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTransferReceiptViewPresenter.swift; sourceTree = ""; }; @@ -930,6 +936,7 @@ 0258BA1E299294A90098E1BE /* Profile */ = { isa = PBXGroup; children = ( + 02F543B02C17AAD7000924E4 /* GasToken */, 278EA5622BB61094007A0E17 /* Notifications */, 277E90052B1EA093005CCBCB /* TradingRewards */, 02B27A3B2AE8BC6B00A995EC /* Help */, @@ -976,6 +983,7 @@ isa = PBXGroup; children = ( 64487FFE2AA248340068DD87 /* dydxAlertsWorker.swift */, + 02F543B52C17B792000924E4 /* dydxGasTokenWorker.swift */, 020EB696299D36AD00E8026B /* dydxApiStatusWorker.swift */, 02B6CE742A7087A700C5F088 /* dydxTransferSubaccountWorker.swift */, 27351D442AC4A67900E4A563 /* dydxRestrictionsWorker.swift */, @@ -1275,6 +1283,7 @@ 02E7B37C29D79A4400D6626D /* settings_notifications.json */, 0295392629FB28B7009026E3 /* settings_theme.json */, 2741E3632A68787A000FA190 /* settings_direction_color_preference.json */, + 02F543B32C17AD6A000924E4 /* settings_gas_token.json */, 0279656929D795E7004DEB20 /* routing_swiftui.json */, 0279655B29D795E7004DEB20 /* tabs_v4.json */, 02E7B38729D79A4400D6626D /* v4-native-client.js */, @@ -1302,6 +1311,14 @@ path = FeatureFlags; sourceTree = ""; }; + 02F543B02C17AAD7000924E4 /* GasToken */ = { + isa = PBXGroup; + children = ( + 02F543B12C17ABBB000924E4 /* dydxGasTokenViewBuilder.swift */, + ); + path = GasToken; + sourceTree = ""; + }; 02F958152A1BDEEF00828F9A /* KeyExport */ = { isa = PBXGroup; children = ( @@ -1807,6 +1824,7 @@ 02E7B3A729D79A4400D6626D /* debug_default.json in Resources */, 02E7B39929D79A4400D6626D /* test.js in Resources */, 02E7B39A29D79A4400D6626D /* settings.json in Resources */, + 02F543B42C17AD6A000924E4 /* settings_gas_token.json in Resources */, 0279656A29D795E8004DEB20 /* tabs_v4.json in Resources */, 02E7B3A629D79A4400D6626D /* settings_notifications.json in Resources */, 02E7B39C29D79A4400D6626D /* debug.json in Resources */, @@ -1970,6 +1988,7 @@ 02860A9F29C15E760079E644 /* dydxOnboardScanViewBuilder.swift in Sources */, 277E90332B1FAE9A005CCBCB /* dydxRewardsHelpViewPresenter.swift in Sources */, 02FAFA5C29D4E08E001A0903 /* dydxDebugViewBuilder.swift in Sources */, + 02F543B22C17ABBB000924E4 /* dydxGasTokenViewBuilder.swift in Sources */, 02F700FE29EA0FD9004DEB5E /* dydxReceiptPresenter.swift in Sources */, 027E1EF829CA27CD0098666F /* dydxSettingsLandingViewBuilder.swift in Sources */, 020DBF1E29E092C00068AAA6 /* dydxTransferDepositViewPresenter.swift in Sources */, @@ -1978,6 +1997,7 @@ 021B68B12AD9B86600C5C3BF /* dydxSecurityViewPresenter.swift in Sources */, 024B43A229812DC700E35D54 /* dydxValidationViewPresenter.swift in Sources */, 024B44D42982D24A00E35D54 /* dydxTradeStatusViewBuilder.swift in Sources */, + 02F543B62C17B792000924E4 /* dydxGasTokenWorker.swift in Sources */, 0279DE792BEC472600F9ECF8 /* dydxAdjustMarginInputViewBuilder.swift in Sources */, 6496DC3E295E122B00174CE7 /* dydxTradeInputViewBuilder.swift in Sources */, 64A4DB9529664803008D8E20 /* dydxTradeInputEditPresenter.swift in Sources */, diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json index 6ab6eeadd..2ed8e4ee4 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/routing_swiftui.json @@ -280,6 +280,9 @@ "/settings/direction_color_preference":{ "destination":"dydxPresenters.dydxDirectionColorPreferenceViewBuilder" }, + "/settings/gas_token":{ + "destination":"dydxPresenters.dydxGasTokenViewBuilder" + }, "/settings/status": { "destination":"dydxPresenters.dydxSystemStatusBuilder" }, diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/settings.json b/dydx/dydxPresenters/dydxPresenters/_Features/settings.json index fbaf45c9b..503beff7b 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/settings.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/settings.json @@ -41,6 +41,14 @@ "text" : "/settings/direction_color_preference" } }, + { + "title" : { + "text" : "APP.GENERAL.PAY_GAS_WITH" + }, + "link" : { + "text" : "/settings/gas_token" + } + }, { "title" : { "text" : "APP.HELP_MODAL.PROVIDE_FEEDBACK" diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/settings_debug.json b/dydx/dydxPresenters/dydxPresenters/_Features/settings_debug.json index a20711b01..821b95284 100644 --- a/dydx/dydxPresenters/dydxPresenters/_Features/settings_debug.json +++ b/dydx/dydxPresenters/dydxPresenters/_Features/settings_debug.json @@ -65,6 +65,14 @@ "text" : "/settings/direction_color_preference" } }, + { + "title" : { + "text" : "APP.GENERAL.PAY_GAS_WITH" + }, + "link" : { + "text" : "/settings/gas_token" + } + }, { "title" : { "text" : "Debug Theme Viewer" diff --git a/dydx/dydxPresenters/dydxPresenters/_Features/settings_gas_token.json b/dydx/dydxPresenters/dydxPresenters/_Features/settings_gas_token.json new file mode 100644 index 000000000..0c987267e --- /dev/null +++ b/dydx/dydxPresenters/dydxPresenters/_Features/settings_gas_token.json @@ -0,0 +1,26 @@ +[ + { + "input":"1", + "fields":[ + { + "title":{ + "text":"APP.GENERAL.PAY_GAS_WITH" + }, + "field":{ + "field":"gas_token", + "type":"text", + "options":[ + { + "text":"USDC", + "value":"USDC" + }, + { + "text":"NATIVE", + "value":"NATIVE" + } + ] + } + } + ] + } +] diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxGasTokenWorker.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxGasTokenWorker.swift new file mode 100644 index 000000000..3a91e4df6 --- /dev/null +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxGasTokenWorker.swift @@ -0,0 +1,26 @@ +// +// dydxGasTokenWorker.swift +// dydxPresenters +// +// Created by Rui Huang on 10/06/2024. +// + +import Abacus +import Combine +import dydxStateManager +import ParticlesKit +import RoutingKit +import Utilities + +public final class dydxGasTokenWorker: BaseWorker { + + public override func start() { + super.start() + + // set the gas token to the user preference + if let tokenName = SettingsStore.shared?.gasToken, + let token = GasToken.from(tokenName: tokenName) { + AbacusStateManager.shared.setGasToken(token: token) + } + } +} diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/dydxGlobalWorkers.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/dydxGlobalWorkers.swift index b98e74dba..9a8e3ea46 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/dydxGlobalWorkers.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/dydxGlobalWorkers.swift @@ -17,7 +17,8 @@ public final class dydxGlobalWorkers: BaseWorker { dydxRestrictionsWorker(), dydxCarteraConfigWorker(), dydxUpdateWorker(), - dydxRatingsWorker() + dydxRatingsWorker(), + dydxGasTokenWorker() ] override public func start() { diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/KeyValueStoreProtocolStore+Ext.swift b/dydx/dydxPresenters/dydxPresenters/_v4/KeyValueStoreProtocolStore+Ext.swift index 349a08861..51ace937b 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/KeyValueStoreProtocolStore+Ext.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/KeyValueStoreProtocolStore+Ext.swift @@ -14,6 +14,7 @@ public enum dydxSettingsStoreKey: String, CaseIterable { case v4Theme = "v4_theme" case directionColorPreference = "direction_color_preference" case shouldDisplayInAppNotifications = "should_display_in_app_notifications" + case gasToken = "gas_token" public var defaultValue: Any? { switch self { @@ -21,6 +22,7 @@ public enum dydxSettingsStoreKey: String, CaseIterable { case .v4Theme: return dydxThemeType.classicDark.rawValue case .directionColorPreference: return "green_is_up" case .shouldDisplayInAppNotifications: return true + case .gasToken: return "USDC" } } } @@ -50,4 +52,8 @@ extension KeyValueStoreProtocol { ?? dydxSettingsStoreKey.shouldDisplayInAppNotifications.defaultValue as? Bool ?? true } + + var gasToken: String? { + SettingsStore.shared?.value(forKey: dydxSettingsStoreKey.gasToken.rawValue) as? String ?? "USDC" + } } diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileBalancesViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileBalancesViewPresenter.swift index 02429e782..b8745117a 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileBalancesViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileBalancesViewPresenter.swift @@ -33,11 +33,11 @@ public class dydxProfileBalancesViewPresenter: HostedViewPresenter() -> T? { + let presenter = dydxGasTokenViewPresenter() + let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() + let viewController = SettingsViewController(presenter: presenter, view: view, configuration: .default) + viewController.requestPath = "/settings/gas_token" + return viewController as? T + } +} + +private class dydxGasTokenViewPresenter: FieldSettingsViewPresenter { + init() { + super.init(definitionFile: "settings_gas_token.json", fieldName: "gas_token", keyValueStore: SettingsStore.shared) + + let header = SettingHeaderViewModel() + header.text = DataLocalizer.localize(path: "APP.GENERAL.PAY_GAS_WITH") + header.dismissAction = { + Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss"), animated: true, completion: nil) + } + viewModel?.headerViewModel = header + } + + override func onOptionSelected(option: [String: Any], changed: Bool) { + if changed, let value = option["value"] as? String { + if let token = GasToken.from(tokenName: value) { + AbacusStateManager.shared.setGasToken(token: token) + Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss"), animated: true, completion: nil) + } else { + ErrorLogging.shared?.e(tag: "dydxGasTokenViewPresenter", + message: "Invalid token: \(value)") + } + } + } + + override func textForOption(option: [String: Any]) -> String? { + GasTokenOptionTransformer().textForOption(option: option) ?? super.textForOption(option: option) + } +} + +class GasTokenOptionTransformer: SettingsOptionTransformProtocol { + func textForOption(option: [String: Any]) -> String? { + switch option["value"] as? String { + case "USDC": + return AbacusStateManager.shared.environment?.usdcTokenInfo?.name + case "NATIVE": + return AbacusStateManager.shared.environment?.nativeTokenInfo?.name + default: + return nil + } + } +} diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift index 9d9174503..2e7331043 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Profile/Settings/SettingsLandingViewPresenter.swift @@ -15,6 +15,21 @@ import PlatformUIJedio import JedioKit import dydxStateManager +protocol SettingsOptionTransformProtocol { + func textForOption(option: [String: Any]) -> String? + func valueForOption(option: [String: Any]) -> String? +} + +extension SettingsOptionTransformProtocol { + func textForOption(option: [String: Any]) -> String? { + nil + } + + func valueForOption(option: [String: Any]) -> String? { + nil + } +} + class SettingsLandingViewPresenter: SettingsViewPresenter { private enum DeepLink: String { @@ -23,6 +38,7 @@ class SettingsLandingViewPresenter: SettingsViewPresenter { case env = "/settings/env" case colorPreference = "/settings/direction_color_preference" case notifications = "/settings/notifications" + case gas_token = "/settings/gas_token" var settingsStoreKey: String { switch self { @@ -31,32 +47,42 @@ class SettingsLandingViewPresenter: SettingsViewPresenter { case .env: return "AbacusStateManager.EnvState" case .colorPreference: return dydxSettingsStoreKey.directionColorPreference.rawValue case .notifications: return dydxSettingsStoreKey.shouldDisplayInAppNotifications.rawValue + case .gas_token: return dydxSettingsStoreKey.gasToken.rawValue } } var localizerKeyLookup: [String: String]? { switch self { - // extracting the localizer key lookup from the definition file reduces sources of truth for the key value mapping - case .language: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_language.json") - case .theme: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_theme.json") - // this one is hardcoded for now, there is no field input definition file for environment selection yet - case .env: return nil - case .colorPreference: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_direction_color_preference.json") - case .notifications: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "notifications.json") + // extracting the localizer key lookup from the definition file reduces sources of truth for the key value mapping + case .language: + return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_language.json") + case .theme: + return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_theme.json") + // this one is hardcoded for now, there is no field input definition file for environment selection yet + case .env: + return nil + case .colorPreference: + return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_direction_color_preference.json") + case .notifications: + return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "notifications.json") + case .gas_token: + return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_gas_token.json", + transformer: GasTokenOptionTransformer()) } } } /// given a field input definition file, this will extract the dictionary of text/value pairs from the first field options list - private static func extractLocalizerKeyLookup(fromDefinitionFile definitionFile: String ) -> [String: String] { + private static func extractLocalizerKeyLookup(fromDefinitionFile definitionFile: String, + transformer: SettingsOptionTransformProtocol? = nil) -> [String: String] { let languageFieldsEntity = newFieldsEntity(forDefinitionFile: definitionFile) let fieldsListInteractor = languageFieldsEntity.list?.list?.first as? FieldListInteractor let field = fieldsListInteractor?.list?.first as? FieldInput var dictionary = [String: String]() field?.options?.forEach({ option in - guard let key = option["value"] as? String else { return } - guard let value = option["text"] as? String else { return } + guard let key = transformer?.valueForOption(option: option) ?? option["value"] as? String else { return } + guard let value = transformer?.textForOption(option: option) ?? option["text"] as? String else { return } dictionary[key] = value }) return dictionary diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift index c92e465f7..56d0a0eb4 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift @@ -272,7 +272,7 @@ class dydxTransferInputCtaButtonViewPresenter: HostedViewPresenter GasToken? { + switch tokenName { + case "USDC": return GasToken.usdc + case "NATIVE": return GasToken.native + default: return nil + } + } +}