Skip to content

Commit

Permalink
Allow cosmos chains deposit/withdrawls if Keplr is the connected wall…
Browse files Browse the repository at this point in the history
…et [OTE-685] (#567)

Co-authored-by: mobile-build-bot-git <[email protected]>
  • Loading branch information
rosepuppy and mobile-build-bot authored Aug 19, 2024
1 parent 2cbba7e commit d9cedc2
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.8.90"
version = "1.8.91"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any>?
var chains: List<Any>?
var exchangeDestinationChainId: String?
var selectedChainType: ChainType?

fun receivedEvmSwapVenues(
existing: Map<String, Any>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +29,13 @@ internal class SkipProcessor(

var skipTokens: Map<String, Map<String, List<Map<String, Any>>>>? = 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<String, Any>?,
Expand Down Expand Up @@ -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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +19,7 @@ internal class SquidProcessor(
override var chains: List<Any>? = null
override var tokens: List<Any>? = null
override var exchangeDestinationChainId: String? = null
override var selectedChainType: ChainType? = ChainType.EVM

override fun receivedEvmSwapVenues(existing: Map<String, Any>?, payload: Map<String, Any>) {
throw NotImplementedError("receivedEvmSwapVenues is not implemented in SquidProcessor!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ internal class StateManagerAdaptorV2(
}
set(value) {
accounts.cosmosWalletConnected = value
onboarding.cosmosWalletConnected = value
}

internal var sourceAddress: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand Down

0 comments on commit d9cedc2

Please sign in to comment.