-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: skip processor base [OTE-345] (#387)
Co-authored-by: mobile-build-bot-git <[email protected]>
- Loading branch information
1 parent
33be706
commit f62aca4
Showing
18 changed files
with
237 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/commonMain/kotlin/exchange.dydx.abacus/processor/router/SharedRouterProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package exchange.dydx.abacus.processor.router | ||
|
||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
class SharedRouterProcessor(val parser: ParserProtocol) |
22 changes: 22 additions & 0 deletions
22
src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipChainProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package exchange.dydx.abacus.processor.router.skip | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SkipChainProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"chain_name" to "stringKey", | ||
"networkIdentifier" to "stringKey", | ||
"chain_id" to "type", | ||
"logo_uri" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ommonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipChainResourceProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package exchange.dydx.abacus.processor.router.skip | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SkipChainResourceProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"chain_name" to "chainName", | ||
"rpc" to "rpc", | ||
"networkName" to "networkName", | ||
"chain_id" to "chainId", | ||
"logo_uri" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package exchange.dydx.abacus.processor.router.skip | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.processor.router.IRouterProcessor | ||
import exchange.dydx.abacus.processor.router.SharedRouterProcessor | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
import exchange.dydx.abacus.utils.safeSet | ||
|
||
@Suppress("NotImplementedDeclaration") | ||
internal class SkipProcessor(parser: ParserProtocol) : BaseProcessor(parser), IRouterProcessor { | ||
override var chains: List<Any>? = null | ||
|
||
// possibly want to use a different variable so we aren't stuck with this bad type | ||
// actual type of the tokens payload is Map<str, Map<str, List<Map<str, Any>>>> | ||
override var tokens: List<Any>? = null | ||
override var exchangeDestinationChainId: String? = null | ||
val sharedRouterProcessor = SharedRouterProcessor(parser) | ||
|
||
override fun receivedV2SdkInfo( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedV2SdkInfo is not implemented in SkipProcessor!") | ||
} | ||
override fun receivedChains( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedChains is not implemented in SkipProcessor!") | ||
} | ||
override fun receivedTokens( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedTokens is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun receivedRoute( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any>, | ||
requestId: String?, | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedRoute is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun receivedRouteV2( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any>, | ||
requestId: String? | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedRouteV2 is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun usdcAmount(data: Map<String, Any>): Double? { | ||
throw NotImplementedError("usdcAmount is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun receivedStatus( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any>, | ||
transactionId: String?, | ||
): Map<String, Any>? { | ||
throw NotImplementedError("receivedStatus is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun updateTokensDefaults(modified: MutableMap<String, Any>, selectedChainId: String?) { | ||
val tokenOptions = tokenOptions(selectedChainId) | ||
modified.safeSet("transfer.depositOptions.assets", tokenOptions) | ||
modified.safeSet("transfer.withdrawalOptions.assets", tokenOptions) | ||
modified.safeSet("transfer.token", defaultTokenAddress(selectedChainId)) | ||
modified.safeSet("transfer.resources.tokenResources", tokenResources(selectedChainId)) | ||
} | ||
|
||
override fun defaultChainId(): String? { | ||
throw NotImplementedError("defaultChainId is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun selectedTokenSymbol(tokenAddress: String?): String? { | ||
throw NotImplementedError("selectedTokenSymbol is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun selectedTokenDecimals(tokenAddress: String?): String? { | ||
throw NotImplementedError("selectedTokenDecimals is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun filteredTokens(chainId: String?): List<Any>? { | ||
throw NotImplementedError("filteredTokens is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun defaultTokenAddress(chainId: String?): String? { | ||
throw NotImplementedError("defaultTokenAddress is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun chainResources(chainId: String?): Map<String, Any>? { | ||
throw NotImplementedError("chainResources is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun tokenResources(chainId: String?): Map<String, Any>? { | ||
throw NotImplementedError("tokenResources is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun chainOptions(): List<Any> { | ||
throw NotImplementedError("chainOptions is not implemented in SkipProcessor!") | ||
} | ||
|
||
override fun tokenOptions(chainId: String?): List<Any> { | ||
throw NotImplementedError("tokenOptions is not implemented in SkipProcessor!") | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/commonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipTokenProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package exchange.dydx.abacus.processor.router.skip | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SkipTokenProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"name" to "stringKey", | ||
"denom" to "type", | ||
"logo_uri" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ommonMain/kotlin/exchange.dydx.abacus/processor/router/skip/SkipTokenResourceProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package exchange.dydx.abacus.processor.router.skip | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SkipTokenResourceProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"name" to "name", | ||
"denom" to "address", | ||
"symbol" to "symbol", | ||
"decimals" to "decimals", | ||
"logo_uri" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...us/processor/squid/SquidChainProcessor.kt → ...essor/router/squid/SquidChainProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ssor/squid/SquidChainResourceProcessor.kt → ...uter/squid/SquidChainResourceProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.