Skip to content

Commit

Permalink
Add parsing for wallet connect modal wallet list (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Dec 19, 2024
1 parent bdd0680 commit 4cb1ef9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 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.13.42"
version = "1.13.43"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package exchange.dydx.abacus.state.manager

import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.abacus.protocols.ParserProtocol
import exchange.dydx.abacus.protocols.asTypedList
import exchange.dydx.abacus.utils.IList
import exchange.dydx.abacus.utils.IMap
import exchange.dydx.abacus.utils.ServerTime
Expand Down Expand Up @@ -263,14 +264,33 @@ data class WalletConnectV1(
@JsExport
data class WalletConnectV2(
val projectId: String,
val wallets: WalletConnectV2Wallets?
) {
companion object {
fun parse(
data: Map<String, Any>?,
parser: ParserProtocol,
): WalletConnectV2? {
val projectId = parser.asString(data?.get("projectId")) ?: return null
return WalletConnectV2(projectId)
val wallets = WalletConnectV2Wallets.parse(parser.asMap(data?.get("wallets")), parser)
return WalletConnectV2(projectId, wallets)
}
}
}

@JsExport
data class WalletConnectV2Wallets(
val ios: IList<String>?,
val android: IList<String>?
) {
companion object {
fun parse(
data: Map<String, Any>?,
parser: ParserProtocol,
): WalletConnectV2Wallets? {
val ios = parser.asTypedList<String>(data?.get("ios"))?.toIList()
val android = parser.asTypedList<String>(data?.get("android"))?.toIList()
return WalletConnectV2Wallets(ios, android)
}
}
}
Expand Down Expand Up @@ -345,11 +365,11 @@ data class WalletConnection(
val signTypedDataDomainName = parser.asString(data?.get("signTypedDataDomainName"))
return if (walletConnect != null || walletSegue != null) {
WalletConnection(
walletConnect,
walletSegue,
"$deploymentUri$images",
signTypedDataAction,
signTypedDataDomainName,
walletConnect = walletConnect,
walletSegue = walletSegue,
images = "$deploymentUri$images",
signTypedDataAction = signTypedDataAction,
signTypedDataDomainName = signTypedDataDomainName,
)
} else {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,24 @@ class AbacusMockData {
tradingRewardsLearnMore = "https://docs.dydx.exchange/concepts-trading/rewards_fees_and_parameters",
),
walletConnection = WalletConnection(
WalletConnect(
walletConnect = WalletConnect(
WalletConnectClient(
"test",
"test",
"test",
name = "test",
description = "test",
iconUrl = "test",
),
WalletConnectV1(
"test",
bridgeUrl = "test",
),
WalletConnectV2(
"test",
projectId = "test",
wallets = null,
),
),
WalletSegue("callback"),
"/images/",
"test",
"test",
walletSegue = WalletSegue("callback"),
images = "/images/",
signTypedDataAction = "test",
signTypedDataDomainName = "test",
),
apps = null,
tokens = mapOf(
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.13.42'
spec.version = '1.13.43'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit 4cb1ef9

Please sign in to comment.