From ad2e396ef146cbf6f67992d0f7e6a651c562b0e3 Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Sun, 21 May 2017 11:07:19 +0300 Subject: [PATCH] Mainnet support * show "Mainnet" instead of "Testnet" on github issue comments and web UI if commiteth.onTestnet system property is truthy --- README.md | 2 +- resources/templates/home.html | 1 + src/clj/commiteth/github/core.clj | 14 ++++++++++---- src/clj/commiteth/routes/home.clj | 4 +++- src/cljs/commiteth/config.cljs | 4 ++++ src/cljs/commiteth/core.cljs | 4 +++- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c0200f1..6656e04 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Allows you to set bounties for Github issues, paid out in Ether. More information: http://wiki.status.im/proposals/commiteth/ -Live alpha version (uses Ropsten testnet): +Live alpha version: https://commiteth.com diff --git a/resources/templates/home.html b/resources/templates/home.html index af1fba1..d70cd40 100644 --- a/resources/templates/home.html +++ b/resources/templates/home.html @@ -34,6 +34,7 @@ user = null; } var commitethVersion = "{{commiteth-version}}"; + var onTestnet = "{{on-testnet?}}"; {% style "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.min.css" %} diff --git a/src/clj/commiteth/github/core.clj b/src/clj/commiteth/github/core.clj index 387f190..7e7a68c 100644 --- a/src/clj/commiteth/github/core.clj +++ b/src/clj/commiteth/github/core.clj @@ -17,7 +17,7 @@ (:import [java.util UUID])) (def ^:dynamic url "https://api.github.com/") - +(defonce ^:const on-testnet? (System/getProperty "commiteth.onTestnet")) (defn server-address [] (:server-address env)) (defn client-id [] (:github-client-id env)) (defn client-secret [] (:github-client-secret env)) @@ -183,6 +183,12 @@ [owner repo issue-number] (md-image "Contract deploying" (str (server-address) "/img/deploying_contract.png"))) +(defn network-text [] + (str "Network: " (if on-testnet? + "Testnet" + "Mainnet") + "\n")) + (defn generate-open-comment [owner repo issue-number contract-address balance balance-str] (let [image-url (md-image "QR Code" (get-qr-url owner repo issue-number balance)) @@ -191,7 +197,7 @@ (format (str "Current balance: %s\n" "Contract address: %s\n" "%s\n" - "Network: Testnet\n" + (network-text) "To claim this bounty sign up at %s") balance-str contract-address image-url site-url))) @@ -200,7 +206,7 @@ [contract-address balance-str winner-login] (format (str "Balance: %s\n" "Contract address: %s\n" - "Network: Testnet\n" + (network-text) "Status: pending maintainer confirmation\n" "Winner: %s\n") balance-str contract-address winner-login)) @@ -209,7 +215,7 @@ [contract-address balance-str payee-login] (format (str "Balance: %s\n" "Contract address: %s\n" - "Network: Testnet\n" + (network-text) "Paid to: %s\n") balance-str contract-address payee-login)) diff --git a/src/clj/commiteth/routes/home.clj b/src/clj/commiteth/routes/home.clj index b2c1613..266328d 100644 --- a/src/clj/commiteth/routes/home.clj +++ b/src/clj/commiteth/routes/home.clj @@ -8,6 +8,7 @@ [clojure.java.io :as io])) (defonce ^:const version (System/getProperty "commiteth.version")) +(defonce ^:const on-testnet? (System/getProperty "commiteth.onTestnet")) (defn home-page [{user-id :id login :login @@ -19,7 +20,8 @@ :admin-token admin-token :authorize-url (github/signup-authorize-url) :authorize-url-admin (github/admin-authorize-url) - :commiteth-version version})) + :commiteth-version version + :on-testnet? on-testnet?})) (defroutes home-routes (GET "/" {{user :identity} :session} diff --git a/src/cljs/commiteth/config.cljs b/src/cljs/commiteth/config.cljs index 4719435..1059401 100644 --- a/src/cljs/commiteth/config.cljs +++ b/src/cljs/commiteth/config.cljs @@ -2,3 +2,7 @@ (def debug? ^boolean js/goog.DEBUG) + +(defn on-testnet? [] + (not (or (empty? js/onTestnet) + (= "false" js/onTestnet)))) diff --git a/src/cljs/commiteth/core.cljs b/src/cljs/commiteth/core.cljs index d56079b..ffb4fab 100644 --- a/src/cljs/commiteth/core.cljs +++ b/src/cljs/commiteth/core.cljs @@ -101,7 +101,9 @@ (when-not @user [:div.ui.text.content [:div.ui.divider.hidden] - [:h2.ui.header "Commit ETH (Testnet)"] + [:h2.ui.header (if (config/on-testnet?) + "Commit ETH (Testnet)" + "Commit ETH")] [:h2.ui.subheader "Earn ETH by committing to open source projects"] [:div.ui.divider.hidden]]) [tabs]]])))