diff --git a/build.gradle.kts b/build.gradle.kts index 284f54ec9..313915197 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.8.90" +version = "1.8.91" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt index 21b3f9c46..c9d6fa873 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt @@ -4,10 +4,17 @@ import exchange.dydx.abacus.output.input.SelectionOption import exchange.dydx.abacus.output.input.TransferInputChainResource import exchange.dydx.abacus.output.input.TransferInputTokenResource +enum class ChainType(val rawValue: String) { + EVM("evm"), + COSMOS("cosmos"), + SVM("svm"), +} + interface IRouterProcessor { var tokens: List? var chains: List? var exchangeDestinationChainId: String? + var selectedChainType: ChainType? fun receivedEvmSwapVenues( existing: Map?, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt index 52d0d593a..a29b4af54 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt @@ -4,11 +4,11 @@ import exchange.dydx.abacus.output.input.SelectionOption import exchange.dydx.abacus.output.input.TransferInputChainResource import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.processor.router.ChainType import exchange.dydx.abacus.processor.router.IRouterProcessor import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.state.internalstate.InternalTransferInputState import exchange.dydx.abacus.state.manager.CctpConfig.cctpChainIds -import exchange.dydx.abacus.utils.ALLOWED_CHAIN_TYPES import exchange.dydx.abacus.utils.ETHEREUM_CHAIN_ID import exchange.dydx.abacus.utils.NATIVE_TOKEN_DEFAULT_ADDRESS import exchange.dydx.abacus.utils.mutable @@ -29,6 +29,13 @@ internal class SkipProcessor( var skipTokens: Map>>>? = null override var exchangeDestinationChainId: String? = null + override var selectedChainType: ChainType? = ChainType.EVM + set(value) { + if (field != value) { + field = value + internalState.chains = chainOptions() + } + } override fun receivedV2SdkInfo( existing: Map?, @@ -319,7 +326,7 @@ internal class SkipProcessor( this.chains?.let { for (chain in it) { parser.asNativeMap(chain)?.let { chain -> - if (parser.asString(chain.get("chain_type")) in ALLOWED_CHAIN_TYPES) { + if (parser.asString(chain.get("chain_type")) == selectedChainType?.rawValue) { options.add(chainProcessor.received(chain)) } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/squid/SquidProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/squid/SquidProcessor.kt index fd57136a2..f6dce3bbc 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/squid/SquidProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/squid/SquidProcessor.kt @@ -4,6 +4,7 @@ import exchange.dydx.abacus.output.input.SelectionOption import exchange.dydx.abacus.output.input.TransferInputChainResource import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.processor.router.ChainType import exchange.dydx.abacus.processor.router.IRouterProcessor import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.state.internalstate.InternalTransferInputState @@ -18,6 +19,7 @@ internal class SquidProcessor( override var chains: List? = null override var tokens: List? = null override var exchangeDestinationChainId: String? = null + override var selectedChainType: ChainType? = ChainType.EVM override fun receivedEvmSwapVenues(existing: Map?, payload: Map) { throw NotImplementedError("receivedEvmSwapVenues is not implemented in SquidProcessor!") diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt index 387eb6c69..31038ab1c 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/manager/StateManagerAdaptorV2.kt @@ -283,6 +283,7 @@ internal class StateManagerAdaptorV2( } set(value) { accounts.cosmosWalletConnected = value + onboarding.cosmosWalletConnected = value } internal var sourceAddress: String? diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt index 88a8832c6..0440f3822 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt @@ -4,6 +4,7 @@ import RpcConfigsProcessor import com.ionspin.kotlin.bignum.decimal.BigDecimal import exchange.dydx.abacus.output.PerpetualState import exchange.dydx.abacus.output.input.TransferType +import exchange.dydx.abacus.processor.router.ChainType import exchange.dydx.abacus.processor.router.skip.SkipRoutePayloadProcessor import exchange.dydx.abacus.protocols.ThreadingType import exchange.dydx.abacus.protocols.TransactionCallback @@ -89,6 +90,16 @@ internal class OnboardingSupervisor( analyticsUtils: AnalyticsUtils, private val configs: OnboardingConfigs, ) : NetworkSupervisor(stateMachine, helper, analyticsUtils) { + + var cosmosWalletConnected: Boolean? = false + set(value) { + if (field != value) { + field = value + stateMachine.routerProcessor.selectedChainType = + if (value == true) ChainType.COSMOS else ChainType.EVM + } + } + override fun didSetReadyToConnect(readyToConnect: Boolean) { super.didSetReadyToConnect(readyToConnect) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/utils/Constants.kt b/src/commonMain/kotlin/exchange.dydx.abacus/utils/Constants.kt index 1525aaaca..54f672614 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/utils/Constants.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/utils/Constants.kt @@ -21,7 +21,6 @@ internal const val CONDITIONAL_ORDER_FLAGS = 32 // Asset Constants internal const val NATIVE_TOKEN_DEFAULT_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" internal const val ETHEREUM_CHAIN_ID = "1" -internal val ALLOWED_CHAIN_TYPES = listOf("evm", "svm") // Polling durations internal const val GEO_POLLING_DURATION_SECONDS = 600.0 diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt index 3e0683e9a..8368ed00e 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt @@ -228,7 +228,6 @@ class SkipProcessorTests { val expectedChains = listOf( SelectionOption(stringKey = "Arbitrum", string = "Arbitrum", type = "42161", iconUrl = "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png"), SelectionOption(stringKey = "Ethereum", string = "Ethereum", type = "1", iconUrl = "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"), - SelectionOption(type = "solana", string = "Solana", stringKey = "Solana", iconUrl = "https://raw.githubusercontent.com/skip-mev/skip-go-registry/main/chains/solana/logo.svg"), ) val expectedChainResources = mapOf( "1" to TransferInputChainResource( diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 54a209996..98dd0d8b3 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.8.90' + spec.version = '1.8.91' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''