gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Currency option.


From: gnunet
Subject: [libeufin] branch master updated: Currency option.
Date: Wed, 04 May 2022 11:52:53 +0200

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 a4055896 Currency option.
a4055896 is described below

commit a4055896afb9672b1b5505877f255b8c0380aa99
Author: ms <ms@taler.net>
AuthorDate: Wed May 4 11:50:41 2022 +0200

    Currency option.
    
    Do not transparently create the default demobank.
    
    The Sandbox needs one to be created manually _before_
    being launched.
---
 .../main/kotlin/tech/libeufin/sandbox/Helpers.kt   |  2 +-
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 27 +++++++++++++---------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
index b02307f9..53df73fd 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -373,7 +373,7 @@ private fun ensureDemobank(name: String): 
DemobankConfigEntity {
     }
 }
 
-fun getSandboxConfig(name: String?): DemobankConfigEntity? {
+fun getDemobank(name: String?): DemobankConfigEntity? {
     return transaction {
         if (name == null) {
             DemobankConfigEntity.all().firstOrNull()
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 2cae0f34..a06e8c51 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -131,7 +131,7 @@ class Config : CliktCommand("Insert one configuration into 
the database") {
         }
     }
 
-    private val nameOption by argument(
+    private val nameArgument by argument(
         "NAME", help = "Name of this configuration"
     )
     private val currencyOption by option("--currency").default("EUR")
@@ -141,6 +141,10 @@ class Config : CliktCommand("Insert one configuration into 
the database") {
         "--allow-registrations",
         help = "(default: true)" /* mentioning here as help message did not.  
*/
     ).flag(default = true)
+    private val withSignupBonusOption by option(
+        "--with-signup-bonus",
+        help = "Award new customers with 100 units of currency!"
+    ).flag("--without-signup-bonus", default = false)
 
     override fun run() {
         val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)
@@ -148,10 +152,10 @@ class Config : CliktCommand("Insert one configuration 
into the database") {
             dbCreateTables(dbConnString)
             transaction {
                 val checkExist = DemobankConfigEntity.find {
-                    DemobankConfigsTable.name eq nameOption
+                    DemobankConfigsTable.name eq nameArgument
                 }.firstOrNull()
                 if (checkExist != null) {
-                    println("Error, demobank ${nameOption} exists already, not 
overriding it.")
+                    println("Error, demobank ${nameArgument} exists already, 
not overriding it.")
                     exitProcess(1)
                 }
                 val demoBank = DemobankConfigEntity.new {
@@ -159,7 +163,8 @@ class Config : CliktCommand("Insert one configuration into 
the database") {
                     bankDebtLimit = bankDebtLimitOption
                     usersDebtLimit = usersDebtLimitOption
                     allowRegistrations = allowRegistrationsOption
-                    name = nameOption
+                    name = nameArgument
+                    this.withSignupBonus = withSignupBonusOption
                 }
                 BankAccountEntity.new {
                     iban = getIban()
@@ -284,7 +289,6 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
             helpFormatter = CliktHelpFormatter(showDefaultValues = true)
         }
     }
-
     private val auth by option(
         "--auth",
         help = "Disable authentication."
@@ -295,11 +299,6 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
         help = "Bind the Sandbox to the Unix domain socket at PATH.  
Overrides" +
                 " --port, when both are given", metavar = "PATH"
     )
-    private val withSignupBonus by option(
-        "--with-signup-bonus",
-        help = "Award new customers with 100 units of currency!"
-    ).flag("--without-signup-bonus", default = false)
-
     override fun run() {
         WITH_AUTH = auth
         setLogLevel(logLevel)
@@ -309,7 +308,13 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
             exitProcess(1)
         }
         execThrowableOrTerminate { 
dbCreateTables(getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME)) }
-        maybeCreateDefaultDemobank(withSignupBonus)
+        // Refuse to operate without a 'default' demobank.
+        val demobank = getDemobank("default")
+        if (demobank == null) {
+            println("Sandbox cannot operate without a 'default' demobank.")
+            println("Please make one with the 'libeufin-cli config' command.")
+            exitProcess(1)
+        }
         if (withUnixSocket != null) {
             startServer(
                 withUnixSocket ?: throw Exception("Could not use the Unix 
domain socket path value!"),

-- 
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]