-
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.
Static Typing: Transfer resources POC (#364)
Co-authored-by: mobile-build-bot-git <[email protected]>
- Loading branch information
1 parent
48c0ebf
commit 0d0253d
Showing
13 changed files
with
135 additions
and
258 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
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
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
27 changes: 12 additions & 15 deletions
27
src/commonMain/kotlin/exchange.dydx.abacus/processor/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
package exchange.dydx.abacus.processor.squid | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.output.input.SelectionOption | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SquidChainProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"chainName" to "stringKey", | ||
"networkIdentifier" to "stringKey", | ||
"chainId" to "type", | ||
"chainIconURI" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
internal class SquidChainProcessor( | ||
private val parser: ParserProtocol | ||
) { | ||
fun received( | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
): SelectionOption { | ||
return SelectionOption( | ||
stringKey = parser.asString(payload["networkIdentifier"]) ?: parser.asString(payload["chainName"]), | ||
string = parser.asString(payload["networkIdentifier"]) ?: parser.asString(payload["chainName"]), | ||
type = parser.asString(payload["chainId"]) ?: "", | ||
iconUrl = parser.asString(payload["chainIconURI"]), | ||
) | ||
} | ||
} |
29 changes: 13 additions & 16 deletions
29
src/commonMain/kotlin/exchange.dydx.abacus/processor/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
package exchange.dydx.abacus.processor.squid | ||
|
||
import exchange.dydx.abacus.processor.base.BaseProcessor | ||
import exchange.dydx.abacus.output.input.TransferInputChainResource | ||
import exchange.dydx.abacus.protocols.ParserProtocol | ||
|
||
internal class SquidChainResourceProcessor(parser: ParserProtocol) : BaseProcessor(parser) { | ||
private val keyMap = mapOf( | ||
"string" to mapOf( | ||
"chainName" to "chainName", | ||
"rpc" to "rpc", | ||
"networkName" to "networkName", | ||
"chainId" to "chainId", | ||
"chainIconURI" to "iconUrl", | ||
), | ||
) | ||
|
||
override fun received( | ||
existing: Map<String, Any>?, | ||
internal class SquidChainResourceProcessor( | ||
private val parser: ParserProtocol | ||
) { | ||
fun received( | ||
payload: Map<String, Any> | ||
): Map<String, Any> { | ||
return transform(existing, payload, keyMap) | ||
): TransferInputChainResource { | ||
return TransferInputChainResource( | ||
chainName = parser.asString(payload["chainName"]), | ||
rpc = parser.asString(payload["rpc"]), | ||
networkName = parser.asString(payload["networkName"]), | ||
chainId = parser.asInt(payload["chainId"]), | ||
iconUrl = parser.asString(payload["chainIconURI"]), | ||
) | ||
} | ||
} |
Oops, something went wrong.