From 8700ec77f5fc04a067f868e8bea565a1f92eaa2b Mon Sep 17 00:00:00 2001 From: Goran Jovic Date: Fri, 17 Nov 2017 16:03:28 +0100 Subject: [PATCH] issue #1951 - added a hardcoded snt entry under asset list - hidden behind ERC20_ENABLED flag --- .env | 1 + .env.jenkins | 1 + .env.prod | 1 + src/status_im/ui/screens/wallet/main/views.cljs | 16 +++++++++++++--- src/status_im/utils/config.cljs | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.env b/.env index dec88eec0b..58b1c7c667 100644 --- a/.env +++ b/.env @@ -4,4 +4,5 @@ DEBUG_LOGS_ENABLED=1 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 +ERC20_ENABLED=1 LOG_LEVEL=debug diff --git a/.env.jenkins b/.env.jenkins index a70e32ee71..e5f2211668 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -4,4 +4,5 @@ DEBUG_LOGS_ENABLED=1 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_NETWORKS_ENABLED=1 +ERC20_ENABLED=1 LOG_LEVEL=debug diff --git a/.env.prod b/.env.prod index db98088ee9..a1307a3d15 100644 --- a/.env.prod +++ b/.env.prod @@ -4,4 +4,5 @@ DEBUG_LOGS_ENABLED=0 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=0 MAINNET_NETWORKS_ENABLED=0 +ERC20_ENABLED=0 LOG_LEVEL=info diff --git a/src/status_im/ui/screens/wallet/main/views.cljs b/src/status_im/ui/screens/wallet/main/views.cljs index 206159d50f..ea4ba3c1b7 100644 --- a/src/status_im/ui/screens/wallet/main/views.cljs +++ b/src/status_im/ui/screens/wallet/main/views.cljs @@ -88,9 +88,12 @@ [btn/button {:disabled? true :style (button.styles/button-bar :last) :text-style styles/main-button-text} (i18n/label :t/wallet-exchange)]]]]) +;; TODO(goranjovic): snt is temporarily given the same logo that eth uses to minimize the changes +;; while ERC20 is mocked and hidden behind a flag. (defn- token->image [id] (case id - "eth" {:source (:ethereum resources/assets) :style (styles/asset-border components.styles/color-gray-transparent-light)})) + "eth" {:source (:ethereum resources/assets) :style (styles/asset-border components.styles/color-gray-transparent-light)} + "snt" {:source (:ethereum resources/assets) :style (styles/asset-border components.styles/color-blue)})) (defn add-asset [] [list/touchable-item show-not-implemented! @@ -131,11 +134,18 @@ [add-asset])) (defn asset-section [balance prices-loading? balance-loading?] - (let [assets [{:id "eth" :currency :eth :amount balance}]] + (let [assets (concat [{:id "eth" :currency :eth :amount balance}] + (if config/erc20-enabled? + [{:id "snt" :currency :snt :amount 5000000000000000000000}]))] [react/view {:style styles/asset-section} [react/text {:style styles/asset-section-title} (i18n/label :t/wallet-assets)] [list/flat-list - {:data (conj assets {}) ;; Extra map triggers rendering for add-asset + {:data (concat assets [{}]) ;; Extra map triggers rendering for add-asset + ;; TODO(goranjovic): Refactor + ;; the order where new element is inserted + ;; with `conj` depends on the underlying collection type. + ;; whereas `concat` like here guarantees that empty element + ;; will be inserted in the end. :render-fn render-asset :on-refresh #(rf/dispatch [:update-wallet]) :refreshing (boolean (or prices-loading? balance-loading?))}]])) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index bad27f0978..894425a59e 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -16,11 +16,13 @@ ;; TESTFAIRY_ENABLED - indefinite ;; STUB_STATUS_GO - indefinite ;; NOTIFICATIONS_WIP_ENABLED - in 0.9.12 release, remove in develop if all goes well +;; ERC20_ENABLED - until idea #3 is merged, remove in develop when ready (def testfairy-enabled? (enabled? (get-config :TESTFAIRY_ENABLED))) (def notifications-wip-enabled? (enabled? (get-config :NOTIFICATIONS_WIP_ENABLED 0))) (def stub-status-go? (enabled? (get-config :STUB_STATUS_GO 0))) (def mainnet-networks-enabled? (enabled? (get-config :MAINNET_NETWORKS_ENABLED 0))) +(def erc20-enabled? (enabled? (get-config :ERC20_ENABLED 0))) (def log-level (-> (get-config :LOG_LEVEL "error") string/lower-case