11package exchange.dydx.abacus.output
22
3- import exchange.dydx.abacus.protocols.LocalizerProtocol
4- import exchange.dydx.abacus.protocols.ParserProtocol
53import exchange.dydx.abacus.utils.IList
6- import exchange.dydx.abacus.utils.Logger
74import kollections.JsExport
85import kotlinx.serialization.Serializable
96
@@ -18,51 +15,7 @@ data class AssetResources(
1815 val secondaryDescription : String? ,
1916 val primaryDescriptionKey : String? ,
2017 val secondaryDescriptionKey : String?
21- ) {
22- companion object {
23- internal fun create (
24- existing : AssetResources ? ,
25- parser : ParserProtocol ,
26- data : Map <* , * >? ,
27- localizer : LocalizerProtocol ? ,
28- ): AssetResources ? {
29- data?.let {
30- val websiteLink = parser.asString(data[" websiteLink" ])
31- val whitepaperLink = parser.asString(data[" whitepaperLink" ])
32- val coinMarketCapsLink = parser.asString(data[" coinMarketCapsLink" ])
33- val imageUrl = parser.asString(data[" imageUrl" ])
34- val primaryDescriptionKey = parser.asString(data[" primaryDescriptionKey" ])
35- val secondaryDescriptionKey = parser.asString(data[" secondaryDescriptionKey" ])
36- return if (existing?.websiteLink != websiteLink ||
37- existing?.whitepaperLink != whitepaperLink ||
38- existing?.coinMarketCapsLink != coinMarketCapsLink ||
39- existing?.imageUrl != imageUrl ||
40- existing?.primaryDescriptionKey != primaryDescriptionKey ||
41- existing?.secondaryDescriptionKey != secondaryDescriptionKey
42- ) {
43- val primaryDescription =
44- if (primaryDescriptionKey != null ) localizer?.localize(primaryDescriptionKey) else null
45- val secondaryDescription =
46- if (secondaryDescriptionKey != null ) localizer?.localize(secondaryDescriptionKey) else null
47- AssetResources (
48- websiteLink,
49- whitepaperLink,
50- coinMarketCapsLink,
51- imageUrl,
52- primaryDescription,
53- secondaryDescription,
54- primaryDescriptionKey,
55- secondaryDescriptionKey,
56- )
57- } else {
58- existing
59- }
60- }
61- Logger .d { " Asset Resources not valid" }
62- return null
63- }
64- }
65- }
18+ )
6619
6720@JsExport
6821@Serializable
@@ -72,42 +25,6 @@ data class Asset(
7225 val tags : IList <String >? ,
7326 val resources : AssetResources ?
7427) {
75- companion object {
76- internal fun create (
77- existing : Asset ? ,
78- parser : ParserProtocol ,
79- data : Map <* , * >? ,
80- localizer : LocalizerProtocol ? ,
81- ): Asset ? {
82- data?.let {
83- val id = parser.asString(data[" id" ])
84- val resourcesData = parser.asMap(data[" resources" ])
85- if (id != null ) {
86- val resources = AssetResources .create(
87- existing?.resources,
88- parser,
89- resourcesData,
90- localizer,
91- )
92- val name = parser.asString(data[" name" ])
93- val tags = parser.asStrings(data[" tags" ])
94-
95- return if (existing?.id != id ||
96- existing.name != name ||
97- existing.tags != tags ||
98- existing.resources != = resources
99- ) {
100- Asset (id, name, tags, resources)
101- } else {
102- existing
103- }
104- }
105- }
106- Logger .d { " Asset not valid" }
107- return null
108- }
109- }
110-
11128 val displayableAssetId: String get() {
11229 return id.split(" ," ).firstOrNull() ? : " "
11330 }
0 commit comments