Skip to content

Commit 5de0790

Browse files
authored
Clean up all other processors (#804)
1 parent 360f43f commit 5de0790

File tree

54 files changed

+169
-3312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+169
-3312
lines changed

src/commonMain/kotlin/exchange.dydx.abacus/processor/assets/AssetProcessor.kt

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import exchange.dydx.abacus.output.AssetResources
55
import exchange.dydx.abacus.processor.base.BaseProcessor
66
import exchange.dydx.abacus.protocols.LocalizerProtocol
77
import exchange.dydx.abacus.protocols.ParserProtocol
8-
import exchange.dydx.abacus.utils.mutable
9-
import exchange.dydx.abacus.utils.safeSet
108
import indexer.models.configs.ConfigsAssetMetadata
119

1210
internal interface AssetMetadataProcessorProtocol {
@@ -20,23 +18,6 @@ internal class AssetMetadataProcessor(
2018
parser: ParserProtocol,
2119
private val localizer: LocalizerProtocol?
2220
) : BaseProcessor(parser), AssetMetadataProcessorProtocol {
23-
private val assetConfigurationsResourcesKeyMap = mapOf(
24-
"string" to mapOf(
25-
"website" to "websiteLink",
26-
"technical_doc" to "whitepaperLink",
27-
"cmc" to "coinMarketCapsLink",
28-
),
29-
)
30-
31-
private val assetConfigurationsKeyMap = mapOf(
32-
"string" to mapOf(
33-
"name" to "name",
34-
),
35-
"strings" to mapOf(
36-
"sector_tags" to "tags",
37-
),
38-
)
39-
4021
override fun process(
4122
assetId: String,
4223
payload: ConfigsAssetMetadata,
@@ -63,35 +44,4 @@ internal class AssetMetadataProcessor(
6344
),
6445
)
6546
}
66-
67-
override fun received(
68-
existing: Map<String, Any>?,
69-
payload: Map<String, Any>
70-
): Map<String, Any>? {
71-
return existing
72-
}
73-
74-
internal fun receivedConfigurations(
75-
assetId: String,
76-
asset: Map<String, Any>?,
77-
payload: Map<String, Any>,
78-
): Map<String, Any> {
79-
val received = transform(asset, payload, assetConfigurationsKeyMap)
80-
val urls = payload["urls"] as Map<String, String?>
81-
val resources = transform(
82-
parser.asNativeMap(asset?.get("resources")),
83-
urls,
84-
assetConfigurationsResourcesKeyMap,
85-
).mutable()
86-
val imageUrl = payload["logo"]
87-
val primaryDescriptionKey = "__ASSETS.$assetId.PRIMARY"
88-
val secondaryDescriptionKey = "__ASSETS.$assetId.SECONDARY"
89-
resources.safeSet("imageUrl", imageUrl)
90-
resources.safeSet("primaryDescriptionKey", primaryDescriptionKey)
91-
resources.safeSet("secondaryDescriptionKey", secondaryDescriptionKey)
92-
received["id"] = assetId
93-
received["resources"] = resources
94-
95-
return received
96-
}
9747
}

src/commonMain/kotlin/exchange.dydx.abacus/processor/assets/AssetsProcessor.kt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package exchange.dydx.abacus.processor.assets
22

33
import exchange.dydx.abacus.output.Asset
44
import exchange.dydx.abacus.processor.base.BaseProcessor
5-
import exchange.dydx.abacus.processor.utils.MarketId
65
import exchange.dydx.abacus.protocols.LocalizerProtocol
76
import exchange.dydx.abacus.protocols.ParserProtocol
8-
import exchange.dydx.abacus.utils.mutable
97
import indexer.models.configs.ConfigsAssetMetadata
108

119
internal class AssetsProcessor(
@@ -33,27 +31,4 @@ internal class AssetsProcessor(
3331

3432
return existing
3533
}
36-
37-
internal fun receivedConfigurations(
38-
existing: Map<String, Any>?,
39-
payload: Map<String, Any>,
40-
): Map<String, Any> {
41-
val assets = existing?.mutable() ?: mutableMapOf<String, Any>()
42-
for ((key, data) in payload) {
43-
val assetId = MarketId.getAssetId(key)
44-
if (assetId != null) {
45-
val marketPayload = parser.asNativeMap(data)
46-
if (marketPayload != null) {
47-
val receivedAsset =
48-
assetMetadataProcessor.receivedConfigurations(
49-
assetId = assetId,
50-
asset = parser.asNativeMap(existing?.get(assetId)),
51-
payload = marketPayload,
52-
)
53-
assets[assetId] = receivedAsset
54-
}
55-
}
56-
}
57-
return assets
58-
}
5934
}

src/commonMain/kotlin/exchange.dydx.abacus/processor/configs/ConfigsProcessor.kt

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import exchange.dydx.abacus.processor.base.BaseProcessorProtocol
66
import exchange.dydx.abacus.protocols.LocalizerProtocol
77
import exchange.dydx.abacus.protocols.ParserProtocol
88
import exchange.dydx.abacus.state.internalstate.InternalConfigsState
9-
import exchange.dydx.abacus.utils.mutable
10-
import exchange.dydx.abacus.utils.safeSet
119
import indexer.models.chain.OnChainEquityTiersResponse
1210
import indexer.models.chain.OnChainFeeTiersResponse
1311
import indexer.models.chain.OnChainWithdrawalAndTransferGatingStatusResponse
@@ -42,10 +40,6 @@ internal class ConfigsProcessor(
4240
private val feeTiersProcessor: FeeTiersProcessorProtocol = FeeTiersProcessor(parser, localier),
4341
private val withdrawalCapacityProcessor: WithdrawalCapacityProcessorProtocol = WithdrawalCapacityProcessor(parser)
4442
) : BaseProcessor(parser), ConfigsProcessorProtocol {
45-
// Deprecated
46-
private val feeDiscountsProcessor = FeeDiscountsProcessor(parser)
47-
private val networkConfigsProcessor = NetworkConfigsProcessor(parser)
48-
private val withdrawalGatingProcessor = WithdrawalGatingProcessor(parser)
4943

5044
override fun processOnChainEquityTiers(
5145
existing: InternalConfigsState,
@@ -55,25 +49,6 @@ internal class ConfigsProcessor(
5549
return existing
5650
}
5751

58-
internal fun receivedOnChainEquityTiersDeprecated(
59-
existing: Map<String, Any>?,
60-
payload: Map<String, Any>
61-
): Map<String, Any>? {
62-
val modified = existing?.mutable() ?: mutableMapOf()
63-
val map = parser.asNativeMap(payload) as Map<String, List<Any>>?
64-
modified.safeSet("equityTiers", map)
65-
66-
return receivedObject(existing, "equityTiers", modified) { existing, payload ->
67-
val map = parser.asNativeMap(payload) as Map<String, Map<String, List<Any>>>?
68-
if (map != null) {
69-
val equityTiersProcessor = equityTiersProcessor as EquityTiersProcessor
70-
equityTiersProcessor.receivedDeprecated(map)
71-
} else {
72-
null
73-
}
74-
}
75-
}
76-
7752
override fun processOnChainFeeTiers(
7853
existing: InternalConfigsState,
7954
payload: OnChainFeeTiersResponse?,
@@ -82,51 +57,6 @@ internal class ConfigsProcessor(
8257
return existing
8358
}
8459

85-
internal fun receivedOnChainFeeTiersDeprecated(
86-
existing: Map<String, Any>?,
87-
payload: List<Any>
88-
): Map<String, Any>? {
89-
return receivedObject(existing, "feeTiers", payload) { existing, payload ->
90-
val list = parser.asNativeList(payload)
91-
if (list != null) {
92-
val feeTiersProcessor = feeTiersProcessor as FeeTiersProcessor
93-
feeTiersProcessor.receivedDeprecated(list)
94-
} else {
95-
null
96-
}
97-
}
98-
}
99-
100-
// Not used
101-
internal fun receivedFeeDiscounts(
102-
existing: Map<String, Any>?,
103-
payload: List<Any>
104-
): Map<String, Any>? {
105-
return receivedObject(existing, "feeDiscounts", payload) { existing, payload ->
106-
val list = parser.asNativeList(payload)
107-
if (list != null) {
108-
feeDiscountsProcessor.received(list)
109-
} else {
110-
null
111-
}
112-
}
113-
}
114-
115-
// Not used
116-
internal fun receivedNetworkConfigs(
117-
existing: Map<String, Any>?,
118-
payload: Map<String, Any>
119-
): Map<String, Any>? {
120-
return receivedObject(existing, "network", payload) { existing, payload ->
121-
val map = parser.asNativeMap(payload)
122-
if (map != null) {
123-
networkConfigsProcessor.received(parser.asNativeMap(existing), map)
124-
} else {
125-
null
126-
}
127-
}
128-
}
129-
13060
override fun processWithdrawalGating(
13161
existing: InternalConfigsState,
13262
payload: OnChainWithdrawalAndTransferGatingStatusResponse?
@@ -137,40 +67,11 @@ internal class ConfigsProcessor(
13767
return existing
13868
}
13969

140-
internal fun receivedWithdrawalGatingDeprecated(
141-
existing: Map<String, Any>?,
142-
payload: Map<String, Any>
143-
): Map<String, Any>? {
144-
return receivedObject(existing, "withdrawalGating", payload) { existing, payload ->
145-
val map = parser.asNativeMap(payload)
146-
if (map != null) {
147-
withdrawalGatingProcessor.received(parser.asNativeMap(existing), map)
148-
} else {
149-
null
150-
}
151-
}
152-
}
153-
15470
override fun processWithdrawalCapacity(
15571
existing: InternalConfigsState,
15672
payload: OnChainWithdrawalCapacityResponse?
15773
): InternalConfigsState {
15874
existing.withdrawalCapacity = withdrawalCapacityProcessor.process(payload)
15975
return existing
16076
}
161-
162-
internal fun receivedWithdrawalCapacityDeprecated(
163-
existing: Map<String, Any>?,
164-
payload: Map<String, Any>
165-
): Map<String, Any>? {
166-
return receivedObject(existing, "withdrawalCapacity", payload) { existing, payload ->
167-
val map = parser.asNativeMap(payload)
168-
if (map != null) {
169-
val withdrawalCapacityProcessor = withdrawalCapacityProcessor as WithdrawalCapacityProcessor
170-
withdrawalCapacityProcessor.received(parser.asNativeMap(existing), map)
171-
} else {
172-
null
173-
}
174-
}
175-
}
17677
}

src/commonMain/kotlin/exchange.dydx.abacus/processor/configs/EquityTierProcessor.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/commonMain/kotlin/exchange.dydx.abacus/processor/configs/EquityTiersProcessor.kt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ internal interface EquityTiersProcessorProtocol {
1919
internal class EquityTiersProcessor(
2020
parser: ParserProtocol
2121
) : BaseProcessor(parser), EquityTiersProcessorProtocol {
22-
private val itemProcessor = EquityTierProcessor(parser = parser)
23-
2422
override fun process(
2523
payload: OnChainEquityTiersResponse?
2624
): EquityTiers? {
@@ -72,37 +70,4 @@ internal class EquityTiersProcessor(
7270
null
7371
}
7472
}
75-
76-
internal fun receivedDeprecated(
77-
payload: Map<String, Map<String, List<Any>>>?
78-
): Map<String, Any>? {
79-
if (payload == null) return null
80-
val equityTiers = parser.asNativeMap(payload["equityTiers"])
81-
val modified = mutableMapOf<String, MutableList<Any>>(
82-
"shortTermOrderEquityTiers" to mutableListOf(),
83-
"statefulOrderEquityTiers" to mutableListOf(),
84-
)
85-
86-
parser.asNativeList(equityTiers?.get("shortTermOrderEquityTiers"))?.let { shortTermOrderEquityTiers ->
87-
for (item in shortTermOrderEquityTiers) {
88-
parser.asNativeMap(item)?.let { it ->
89-
itemProcessor.received(null, it)?.let { received ->
90-
modified["shortTermOrderEquityTiers"]?.add(received)
91-
}
92-
}
93-
}
94-
}
95-
96-
parser.asNativeList(equityTiers?.get("statefulOrderEquityTiers"))?.let { statefulOrderEquityTiers ->
97-
for (item in statefulOrderEquityTiers) {
98-
parser.asNativeMap(item)?.let { it ->
99-
itemProcessor.received(null, it)?.let { received ->
100-
modified["statefulOrderEquityTiers"]?.add(received)
101-
}
102-
}
103-
}
104-
}
105-
106-
return modified
107-
}
10873
}

src/commonMain/kotlin/exchange.dydx.abacus/processor/configs/FeeDiscountProcessor.kt

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/commonMain/kotlin/exchange.dydx.abacus/processor/configs/FeeDiscountsProcessor.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)