From ca1872b74607619ddbacf810630afaf442e870b7 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:31:58 -0500 Subject: [PATCH] Parse restrictedLocales (#766) --- build.gradle.kts | 2 +- .../state/manager/Environment.kt | 3 +++ .../v2/manager/AsyncAbacusStateManagerV2.kt | 5 +++++ .../state/v2/supervisor/Configs.kt | 20 +++---------------- .../app/manager/v2/V4ForegroundCycleTests.kt | 7 +++++-- .../app/manager/v2/V4TransactionTests.kt | 2 +- .../tests/payloads/AbacusMockData.kt | 2 ++ v4_abacus.podspec | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 00d9e6c97..8c46f33fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.13.40" +version = "1.13.41" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt index 17fd06eae..2394eaabe 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/Environment.kt @@ -446,6 +446,7 @@ class V4Environment( val tokens: IMap, governance: EnvironmentGovernance?, featureFlags: EnvironmentFeatureFlags, + val restrictedLocales: IList ) : Environment( id, name, @@ -471,6 +472,7 @@ class V4Environment( linksData: Map?, walletsData: Map?, governanceData: Map?, + restrictedLocales: IList, ): V4Environment? { val name = parser.asString(data["name"]) val ethereumChainId = parser.asString(data["ethereumChainId"]) ?: return null @@ -521,6 +523,7 @@ class V4Environment( tokens = tokens, governance = governance, featureFlags = featureFlags, + restrictedLocales = restrictedLocales, ) } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt index bee8d3c1b..5b94d819d 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/AsyncAbacusStateManagerV2.kt @@ -59,6 +59,7 @@ import exchange.dydx.abacus.utils.UIImplementations import kollections.JsExport import kollections.iListOf import kollections.iMutableListOf +import kollections.toIList import me.tatarka.inject.annotations.Inject @JsExport @@ -390,6 +391,9 @@ class AsyncAbacusStateManagerV2( val linksData = parser.asNativeMap(items?.get("links")) val walletsData = parser.asNativeMap(items?.get("wallets")) val governanceData = parser.asNativeMap(items?.get("governance")) + val restrictedLocales = parser.asList(items?.get("restrictedLocales"))?.mapNotNull { + parser.asString(it) + }?.toIList() ?: iListOf() if (items != null) { val environmentsData = parser.asMap(items["environments"]) ?: return false @@ -407,6 +411,7 @@ class AsyncAbacusStateManagerV2( linksData = parser.asNativeMap(linksData?.get(dydxChainId)), walletsData = parser.asNativeMap(walletsData?.get(dydxChainId)), governanceData = parser.asNativeMap(governanceData?.get(dydxChainId)), + restrictedLocales = restrictedLocales, ) ?: continue parsedEnvironments[environment.id] = environment } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt index 39d7473f1..5bca1a44d 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt @@ -226,15 +226,6 @@ data class AppConfigsV2( ) { companion object { val forApp = AppConfigsV2( - systemConfigs = SystemConfigs.forApp, - marketConfigs = MarketsConfigs.forApp, - accountConfigs = AccountConfigs.forApp, - onboardingConfigs = OnboardingConfigs.forApp, - vaultConfigs = VaultConfigs.forApp, - loadRemote = true, - triggerOrderToast = true, - ) - val forAppWithIsolatedMargins = AppConfigsV2( systemConfigs = SystemConfigs.forApp, marketConfigs = MarketsConfigs.forApp, accountConfigs = AccountConfigs.forAppWithIsolatedMargins, @@ -243,16 +234,11 @@ data class AppConfigsV2( loadRemote = true, triggerOrderToast = true, ) - val forAppDebug = AppConfigsV2( - systemConfigs = SystemConfigs.forApp, - marketConfigs = MarketsConfigs.forApp, - accountConfigs = AccountConfigs.forAppWithIsolatedMargins, - onboardingConfigs = OnboardingConfigs.forApp, - vaultConfigs = VaultConfigs.forApp, + + val forAppDebug = forApp.copy( loadRemote = false, - enableLogger = true, - triggerOrderToast = true, ) + val forWeb = AppConfigsV2( systemConfigs = SystemConfigs.forApp, marketConfigs = MarketsConfigs.forWeb, diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt index cbf863ebc..c0d3eea2f 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt @@ -9,6 +9,7 @@ import exchange.dydx.abacus.payload.BaseTests import exchange.dydx.abacus.state.manager.setAddresses import exchange.dydx.abacus.state.v2.manager.AsyncAbacusStateManagerV2 import exchange.dydx.abacus.state.v2.manager.StateManagerAdaptorV2 +import exchange.dydx.abacus.state.v2.supervisor.AccountConfigs import exchange.dydx.abacus.state.v2.supervisor.AppConfigsV2 import exchange.dydx.abacus.tests.payloads.AbacusMockData import exchange.dydx.abacus.utils.values @@ -51,9 +52,11 @@ class V4ForegroundCycleTests : NetworkTests() { deploymentUri = "https://api.examples.com", deployment = "DEV", appConfigs = if (forIsolatedMargins) { - AppConfigsV2.forAppWithIsolatedMargins - } else { AppConfigsV2.forApp + } else { + AppConfigsV2.forApp.copy( + accountConfigs = AccountConfigs.forApp, + ) }, ioImplementations = ioImplementations, uiImplementations = uiImplementations, diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt index 2e00cf28d..96d08bf69 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt @@ -72,7 +72,7 @@ class V4TransactionTests : NetworkTests() { stateManager = AsyncAbacusStateManagerV2( "https://api.examples.com", "DEV", - AppConfigsV2.forAppWithIsolatedMargins, + AppConfigsV2.forApp, ioImplementations, uiImplementations, TestState(), diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt index dfef1808e..63041e5aa 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/tests/payloads/AbacusMockData.kt @@ -13,6 +13,7 @@ import exchange.dydx.abacus.state.manager.WalletConnectV2 import exchange.dydx.abacus.state.manager.WalletConnection import exchange.dydx.abacus.state.manager.WalletSegue import kollections.JsExport +import kollections.iListOf import kollections.toIMap @JsExport @@ -134,5 +135,6 @@ class AbacusMockData { isSlTpLimitOrdersEnabled = true, cctpWithdrawalOnly = true, ), + restrictedLocales = iListOf(), ) } diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 27b1fb737..5eaf13381 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.13.40' + spec.version = '1.13.41' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''