Skip to content

Commit

Permalink
chore(metadata-url): Update assetId and get metadataService from env.…
Browse files Browse the repository at this point in the history
…json (#715)
  • Loading branch information
jaredvu authored Oct 17, 2024
1 parent 3e73b6f commit 0796110
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 93 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.12.31"
version = "1.13.0"

repositories {
google()
Expand Down
107 changes: 48 additions & 59 deletions integration/iOS/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/commonMain/kotlin/exchange.dydx.abacus/output/Asset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,16 @@ data class Asset(
}
}
}

@JsExport
@Serializable
enum class AssetTags(val rawValue: String) {
MEMES("memes"),
AI("ai-big-data"),
GAMING("gaming"),
RWA("real-world-assets"),
DEPIN("depin"),
LAYER1("layer-1"),
LAYER2("layer-2"),
DEFI("defi"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal class AssetMetadataProcessor(
assetId: String,
payload: ConfigsAssetMetadata,
): Asset {
val imageUrl = "https://mainnet-metadata-service-logos.s3.ap-northeast-1.amazonaws.com/$assetId.png"
val imageUrl = payload.logo
val primaryDescriptionKey = "__ASSETS.$assetId.PRIMARY"
val secondaryDescriptionKey = "__ASSETS.$assetId.SECONDARY"
val primaryDescription = localizer?.localize(primaryDescriptionKey)
Expand Down Expand Up @@ -172,7 +172,7 @@ internal class AssetMetadataProcessor(
urls,
assetConfigurationsResourcesKeyMap,
).mutable()
val imageUrl = "https://mainnet-metadata-service-logos.s3.ap-northeast-1.amazonaws.com/$assetId.png"
val imageUrl = payload["logo"]
val primaryDescriptionKey = "__ASSETS.$assetId.PRIMARY"
val secondaryDescriptionKey = "__ASSETS.$assetId.SECONDARY"
resources.safeSet("imageUrl", imageUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ internal object MarketId {
internal fun getAssetId(
marketId: String,
): String? {
val displayId = getDisplayId(marketId)
val elements = displayId.split("-")
val baseAssetLongForm = elements.first()
val baseAssetElements = baseAssetLongForm.split(",")
val elements = marketId.split("-")

return if (baseAssetElements.isNotEmpty()) {
baseAssetElements.first()
return if (elements.isNotEmpty()) {
elements.first()
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ data class EnvironmentEndpoints(
val faucet: String?,
val squid: String?,
val skip: String?,
val metadataService: String?,
val nobleValidator: String?,
val geo: String?,
) {
Expand All @@ -51,6 +52,7 @@ data class EnvironmentEndpoints(
val faucet = parser.asString(data["faucet"])
val squid = parser.asString(data["0xsquid"])
val skip = parser.asString(data["skip"])
val metadataService = parser.asString(data["metadataService"])
val nobleValidator = parser.asString(data["nobleValidator"])
val geo = parser.asString(data["geo"])
return EnvironmentEndpoints(
Expand All @@ -59,6 +61,7 @@ data class EnvironmentEndpoints(
faucet = faucet,
squid = squid,
skip = skip,
metadataService = metadataService,
nobleValidator = nobleValidator,
geo = geo,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class V4StateManagerConfigs(
"status":"/v1/status"
},
"configs":{
"markets":"/configs/markets.json",
"assets": "https://66iv2m87ol.execute-api.ap-northeast-1.amazonaws.com/mainnet/metadata-service/v1/info"
"markets":"/configs/markets.json"
},
"launchIncentive":{
"graphql":"/query/ccar-perpetuals",
Expand Down Expand Up @@ -179,4 +178,9 @@ class V4StateManagerConfigs(
val path = launchIncentivePath(type) ?: return null
return "$api$path"
}

fun metadataServiceInfo(): String? {
val metadataServiceUrl = environment.endpoints.metadataService ?: return null
return "$metadataServiceUrl/info"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal class SystemSupervisor(
private fun retrieveMarketConfigs() {
if (stateMachine.metadataService) {
val oldState = stateMachine.state
val url = helper.configs.configsUrl("assets")
val url = helper.configs.metadataServiceInfo()
if (url != null) {
helper.post(url, null, null) { _, response, httpCode, _ ->
if (helper.success(httpCode) && response != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class MarketIdUtilsTests {
fun getAssetIdLong() {
val marketId = "AART,raydium,F3nefJBcejYbtdREjui1T9DPh5dBgpkKq7u2GAAMXs5B-USD"
val assetId = MarketId.getAssetId(marketId)
assertEquals("AART", assetId)
assertEquals("AART,raydium,F3nefJBcejYbtdREjui1T9DPh5dBgpkKq7u2GAAMXs5B", assetId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AbacusMockData {
faucet = null,
squid = null,
skip = null,
metadataService = null,
nobleValidator = null,
geo = null,
),
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.12.31'
spec.version = '1.13.0'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit 0796110

Please sign in to comment.