From 842dbbbd8d96f10d839e9e9129b713c08628308e Mon Sep 17 00:00:00 2001 From: Brian Sztamfater Date: Wed, 8 May 2024 08:59:01 -0300 Subject: [PATCH] feat: add feature flag for swaps (#19920) Signed-off-by: Brian Sztamfater --- src/quo/components/buttons/wallet_ctas/view.cljs | 9 ++++++++- .../contexts/preview/quo/buttons/wallet_ctas.cljs | 3 ++- src/status_im/contexts/wallet/account/view.cljs | 2 ++ src/status_im/contexts/wallet/swap/events.cljs | 10 ++++++++++ src/status_im/events.cljs | 1 + src/status_im/feature_flags.cljs | 1 + 6 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/status_im/contexts/wallet/swap/events.cljs diff --git a/src/quo/components/buttons/wallet_ctas/view.cljs b/src/quo/components/buttons/wallet_ctas/view.cljs index d75938e626..4e2b07ec54 100644 --- a/src/quo/components/buttons/wallet_ctas/view.cljs +++ b/src/quo/components/buttons/wallet_ctas/view.cljs @@ -24,7 +24,7 @@ :color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} text]]) (defn view - [{:keys [buy-action send-action receive-action bridge-action container-style]}] + [{:keys [buy-action send-action receive-action bridge-action swap-action container-style]}] (let [theme (quo.theme/use-theme)] [rn/view {:style container-style} [rn/view {:style style/inner-container} @@ -46,6 +46,13 @@ :on-press receive-action :theme theme :accessibility-label :receive}] + (when swap-action + [action-button + {:icon :i/swap + :text (i18n/label :t/swap) + :on-press swap-action + :theme theme + :accessibility-label :swap}]) [action-button {:icon :i/bridge :text (i18n/label :t/bridge) diff --git a/src/status_im/contexts/preview/quo/buttons/wallet_ctas.cljs b/src/status_im/contexts/preview/quo/buttons/wallet_ctas.cljs index 01beb42f1b..159acbcbfa 100644 --- a/src/status_im/contexts/preview/quo/buttons/wallet_ctas.cljs +++ b/src/status_im/contexts/preview/quo/buttons/wallet_ctas.cljs @@ -14,4 +14,5 @@ :buy-action #(js/alert "Buy button pressed") :send-action #(js/alert "Send button pressed") :receive-action #(js/alert "Receive button pressed") - :bridge-action #(js/alert "Bridge button pressed")}]]) + :bridge-action #(js/alert "Bridge button pressed") + :swap-action #(js/alert "Swap button pressed")}]]) diff --git a/src/status_im/contexts/wallet/account/view.cljs b/src/status_im/contexts/wallet/account/view.cljs index 3953a87619..f1c732b403 100644 --- a/src/status_im/contexts/wallet/account/view.cljs +++ b/src/status_im/contexts/wallet/account/view.cljs @@ -51,6 +51,8 @@ {:status :receive}]) :buy-action #(rf/dispatch [:show-bottom-sheet {:content buy-token/view}]) + :swap-action (when (ff/enabled? ::ff/wallet.swap) + #(rf/dispatch [:wallet/start-swap])) :bridge-action #(rf/dispatch [:wallet/start-bridge])}]) [quo/tabs {:style style/tabs diff --git a/src/status_im/contexts/wallet/swap/events.cljs b/src/status_im/contexts/wallet/swap/events.cljs new file mode 100644 index 0000000000..851936db6b --- /dev/null +++ b/src/status_im/contexts/wallet/swap/events.cljs @@ -0,0 +1,10 @@ +(ns status-im.contexts.wallet.swap.events + (:require [re-frame.core :as rf])) + +(rf/reg-event-fx :wallet/start-swap + (fn [{:keys [_db]}] + {:fx [[:dispatch + [:toasts/upsert + {:id :swap-error + :type :negative + :text "Swap is under construction"}]]]})) diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index c0986e2343..a897316b17 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -39,6 +39,7 @@ status-im.contexts.wallet.events status-im.contexts.wallet.send.events status-im.contexts.wallet.signals + status-im.contexts.wallet.swap.events [status-im.db :as db] status-im.navigation.effects status-im.navigation.events diff --git a/src/status_im/feature_flags.cljs b/src/status_im/feature_flags.cljs index c8bd3252ba..0820104257 100644 --- a/src/status_im/feature_flags.cljs +++ b/src/status_im/feature_flags.cljs @@ -20,6 +20,7 @@ ::wallet.graph (enabled-in-env? :FLAG_GRAPH_ENABLED) ::wallet.import-private-key (enabled-in-env? :FLAG_IMPORT_PRIVATE_KEY_ENABLED) ::wallet.long-press-watch-only-asset (enabled-in-env? :FLAG_LONG_PRESS_WATCH_ONLY_ASSET_ENABLED) + ::wallet.swap (enabled-in-env? :FLAG_SWAP_ENABLED) ::wallet.wallet-connect (enabled-in-env? :FLAG_WALLET_CONNECT_ENABLED)})) (defn feature-flags [] @feature-flags-config)