multiporject structure
more comments and docs
This commit is contained in:
		
							parent
							
								
									72ff574e59
								
							
						
					
					
						commit
						f91e3fcb66
					
				
							
								
								
									
										7
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
# unitedgold.io samples directory
 | 
			
		||||
 | 
			
		||||
This project will contain samples of API usage for the [UnitedGold](https://dev.unitedgold.io) project.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- [jvm_console](jvm_console) simple JVM console application
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								jvm_console/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								jvm_console/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
# unitedgold.io JVM console sample
 | 
			
		||||
 | 
			
		||||
This project will contain samples of API usage for the [UnitedGold](https://dev.unitedgold.io) project.
 | 
			
		||||
 | 
			
		||||
This sample shows how to configure and connect APU library, create connection to the server and perform most basic operations.
 | 
			
		||||
@ -7,23 +7,31 @@ version = "1.0-SNAPSHOT"
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    mavenCentral()
 | 
			
		||||
 | 
			
		||||
    // 3 custom repositories for unitedgold.io components:
 | 
			
		||||
    maven("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
 | 
			
		||||
    maven("https://maven.universablockchain.com")
 | 
			
		||||
    maven("https://gitea.sergeych.net/api/packages/YoungBlood/maven")
 | 
			
		||||
    mavenLocal()
 | 
			
		||||
    // end of unitedgold.io required repositories
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
val apiVersion = "0.0.1-SNAPSHOT"
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    // The API library
 | 
			
		||||
    implementation("io.unitedgold.api:shared:$apiVersion")
 | 
			
		||||
 | 
			
		||||
    // To silence logback error messages of "not being configured",
 | 
			
		||||
    // this is Ktor client issue (we use ktor client in API)
 | 
			
		||||
    implementation("ch.qos.logback:logback-classic:1.5.18")
 | 
			
		||||
 | 
			
		||||
    testImplementation(kotlin("test"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
tasks.test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
kotlin {
 | 
			
		||||
    jvmToolchain(17)
 | 
			
		||||
}
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
plugins {
 | 
			
		||||
    id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
 | 
			
		||||
}
 | 
			
		||||
rootProject.name = "unitedgold_sample_console_jvm"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,14 +4,25 @@ import kotlinx.coroutines.runBlocking
 | 
			
		||||
import net.sergeych.crypto2.initCrypto
 | 
			
		||||
import net.sergeych.ugdx.UGClient
 | 
			
		||||
 | 
			
		||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
 | 
			
		||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
 | 
			
		||||
fun main() {
 | 
			
		||||
 | 
			
		||||
    // 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 currencies
 | 
			
		||||
        for( cp in client.currencyPairs() ) {
 | 
			
		||||
            println(cp)
 | 
			
		||||
            // label is short text like "UBIT/USDX"
 | 
			
		||||
            // them we output longer token names:
 | 
			
		||||
            println("${cp.label}: ${cp.base.name} / ${cp.quote.name}")
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,2 +1,3 @@
 | 
			
		||||
rootProject.name = "unitedgold_samples"
 | 
			
		||||
 | 
			
		||||
include(":jvm_console")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user