Skip to content

Commit

Permalink
use env endpoint for geo
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy committed May 2, 2024
1 parent 9574f29 commit aea9d52
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ data class EnvironmentEndpoints(
val faucet: String?,
val squid: String?,
val nobleValidator: String?,
val geo: String?,
) {
companion object {
fun parse(
Expand All @@ -47,7 +48,8 @@ data class EnvironmentEndpoints(
val faucet = parser.asString(data["faucet"])
val squid = parser.asString(data["0xsquid"])
val nobleValidator = parser.asString(data["nobleValidator"])
return EnvironmentEndpoints(indexers, validators, faucet, squid, nobleValidator)
val geo = parser.asString(data["geo"])
return EnvironmentEndpoints(indexers, validators, faucet, squid, nobleValidator, geo)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class V4StateManagerAdaptor(
return configs.publicApiUrl("screen")
}

override fun geoUrl(): String {
return "https://api.dydx.exchange/v4/geo"
override fun geoUrl(): String? {
return environment.endpoints.geo
}

override fun complianceScreenUrl(address: String): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,25 +446,27 @@ internal class StateManagerAdaptorV2(
}

private fun fetchGeo() {
val url = "https://api.dydx.exchange/v4/geo"
networkHelper.get(
url,
null,
null,
callback = { _, response, httpCode, _ ->
geo = if (networkHelper.success(httpCode) && response != null) {
val payload = networkHelper.parser.decodeJsonObject(response)?.toIMap()
if (payload != null) {
val country = networkHelper.parser.asString(networkHelper.parser.value(payload, "geo.country"))
country
val url = environment.endpoints.geo
if (url != null) {
networkHelper.get(
url,
null,
null,
callback = { _, response, httpCode, _ ->
geo = if (networkHelper.success(httpCode) && response != null) {
val payload = networkHelper.parser.decodeJsonObject(response)?.toIMap()
if (payload != null) {
val country = networkHelper.parser.asString(networkHelper.parser.value(payload, "geo.country"))
country
} else {
null
}
} else {
null
}
} else {
null
}
},
)
},
)
}
}

internal fun trade(data: String?, type: TradeInputField?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class AbacusMockData {
null,
null,
null,
null
),
null,
WalletConnection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class EnvironmentsMock {
"validators":[
"https://validator.v4staging.dydx.exchange"
],
"0xsquid":"https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app"
"0xsquid":"https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app",
"geo": "https://api.dydx.exchange/v4/geo"
},
"featureFlags":{
"reduceOnlySupported":true,
Expand Down Expand Up @@ -117,7 +118,8 @@ class EnvironmentsMock {
"https://test-dydx.kingnodes.com/"
],
"0xsquid":"https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app",
"faucet":"https://faucet.v4testnet.dydx.exchange"
"faucet":"https://faucet.v4testnet.dydx.exchange",
"geo": "https://api.dydx.exchange/v4/geo"
},
"featureFlags":{
"reduceOnlySupported":false,
Expand Down

0 comments on commit aea9d52

Please sign in to comment.