gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Circuit API: GET /config.


From: gnunet
Subject: [libeufin] branch master updated: Circuit API: GET /config.
Date: Thu, 22 Dec 2022 15:49:17 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new f23ba0cc Circuit API: GET /config.
f23ba0cc is described below

commit f23ba0cc186099898dbbca0bca44bd6130312f95
Author: MS <ms@taler.net>
AuthorDate: Thu Dec 22 15:48:51 2022 +0100

    Circuit API: GET /config.
---
 nexus/src/test/kotlin/CircuitApiTest.kt            | 20 ++++++++++++++
 .../kotlin/tech/libeufin/sandbox/CircuitApi.kt     | 32 ++++++++++++++++++++++
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  |  6 +++-
 3 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/nexus/src/test/kotlin/CircuitApiTest.kt 
b/nexus/src/test/kotlin/CircuitApiTest.kt
new file mode 100644
index 00000000..5cadfcd0
--- /dev/null
+++ b/nexus/src/test/kotlin/CircuitApiTest.kt
@@ -0,0 +1,20 @@
+import io.ktor.client.features.*
+import io.ktor.client.features.get
+import io.ktor.client.request.*
+import io.ktor.server.testing.*
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import tech.libeufin.sandbox.sandboxApp
+
+class CircuitApiTest {
+    // Get /config
+    @Test
+    fun config() {
+        withTestApplication(sandboxApp) {
+            runBlocking {
+                val r: String = 
client.get("/demobanks/default/circuit-api/config")
+                println(r)
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
new file mode 100644
index 00000000..0becab7b
--- /dev/null
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
@@ -0,0 +1,32 @@
+package tech.libeufin.sandbox
+
+import io.ktor.application.*
+import io.ktor.response.*
+import io.ktor.routing.*
+
+// CIRCUIT API TYPES
+
+// Configuration response:
+class ConfigResp(
+    val name: String = "circuit",
+    val version: String = SANDBOX_VERSION,
+    val ratios_and_fees: RatioAndFees
+)
+
+// After fixing #7527, the values held by this
+// type must be read from the configuration.
+class RatioAndFees(
+    val buy_at_ratio: Float = 1F,
+    val sell_at_ratio: Float = 0.05F,
+    val buy_in_fee: Float = 0F,
+    val sell_out_fee: Float = 0F
+)
+
+fun circuitApi(circuitRoute: Route) {
+    circuitRoute.get("/config") {
+        call.respond(ConfigResp(
+            ratios_and_fees = RatioAndFees()
+        ))
+        return@get
+    }
+}
\ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 447aa0b5..1bf9f73d 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -66,6 +66,7 @@ import javax.xml.bind.JAXBContext
 import kotlin.system.exitProcess
 
 val logger: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
+const val SANDBOX_VERSION = "0:0:0"
 const val SANDBOX_DB_ENV_VAR_NAME = "LIBEUFIN_SANDBOX_DB_CONNECTION"
 private val adminPassword: String? = 
System.getenv("LIBEUFIN_SANDBOX_ADMIN_PASSWORD")
 var WITH_AUTH = true // Needed by helpers too, hence not making it private.
@@ -1136,7 +1137,7 @@ val sandboxApp: Application.() -> Unit = {
                     val demobank = ensureDemobank(call)
                     call.respond(SandboxConfig(
                         name = "taler-bank-integration",
-                        version = "0:0:0",
+                        version = SANDBOX_VERSION,
                         currency = demobank.currency
                     ))
                     return@get
@@ -1204,6 +1205,9 @@ val sandboxApp: Application.() -> Unit = {
                     return@get
                 }
             }
+            route("/circuit-api") {
+                circuitApi(this)
+            }
             // Talk to Web UI.
             route("/access-api") {
                 post("/accounts/{account_name}/transactions") {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]