converted to KMP sample
This commit is contained in:
1 parent
f91e3fcb66
commit
b0bc2e1744
16 files changed
+86
-430
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.mp_logger.Log
|
||||
import net.sergeych.ugdx.UGClient
|
||||
|
||||
// The actual application code, which is called from
|
||||
// the main function if the corresponding platform
|
||||
fun commonMain() {
|
||||
|
||||
// It is simetimes interesting to see what happens under the hood.
|
||||
// uncomment out this string to reduce debug noise:
|
||||
//Log.connectConsole(Log.Level.DEBUG)
|
||||
|
||||
// united gold API is coroutine-based; this way it can effectively
|
||||
// run ell on single-thread platforms like JS aor WasmJS, but it comes
|
||||
// with the cost of running it in a coroutine:
|
||||
runBlocking {
|
||||
// API uses heavy cryptography, see https://gitea.sergeych.net/sergeych/crypto2
|
||||
// it needs early asynchronous initialization (again to work well with JS and WasmJS):
|
||||
initCrypto()
|
||||
|
||||
// now the crypto is ready and we can start using API
|
||||
// create a client connection using WebSocket to the dev server
|
||||
val client = UGClient("wss://dev.unitedgold.io/kp")
|
||||
|
||||
// enumerate all trading paris
|
||||
println("-------- trading pairs --------")
|
||||
for( tradingPair in client.tradingPairs() ) {
|
||||
// label is short text like "UBIT/USDX"
|
||||
// them we output longer token names:
|
||||
println("${tradingPair.label}: ${tradingPair.base.name} / ${tradingPair.quote.name}")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.unitedgold.samples.console
|
||||
|
||||
import commonMain
|
||||
|
||||
fun main() {
|
||||
commonMain()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
commonMain()
|
||||
}
|
||||
Reference in new issue
Block a user