Compare commits

..
Author SHA1 Message Date
Omar Basem 3537522796 lint 2024-05-08 17:18:29 +04:00
Icaro Motta a6574856d8 Optimize opening of Settings screens 2024-05-08 09:59:52 -03:00
Omar Basem 604eaccbbf feat: Start bridge from asset drawer (#19860)
feat: Start bridge from asset drawer (#19860)
2024-05-08 16:31:38 +04:00
Brian Sztamfater 842dbbbd8d feat: add feature flag for swaps (#19920)
Signed-off-by: Brian Sztamfater <brian@status.im>
2024-05-08 08:59:01 -03:00
17 changed files with 86 additions and 59 deletions
@@ -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)
+9
View File
@@ -199,6 +199,15 @@
[handler deps]
(react/useMemo handler (get-js-deps deps)))
(defn delay-render
[content]
(let [[render? set-render] (use-state false)]
(use-mount
(fn []
(reagent/next-tick #(set-render true))))
(when render?
content)))
(def layout-animation (.-LayoutAnimation ^js react-native))
(def configure-next (.-configureNext ^js layout-animation))
@@ -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")}]])
@@ -15,12 +15,12 @@
(defn- settings-item-view
[data]
[rf/delay-render
(rn/delay-render
[quo/category
{:list-type :settings
:container-style {:padding-bottom 12}
:blur? true
:data data}]])
:data data}]))
(defn scroll-handler
[event scroll-y]
@@ -29,9 +29,9 @@
(defn- footer
[{:keys [bottom]} logout-press]
[rf/delay-render
(rn/delay-render
[rn/view {:style (style/footer-container bottom)}
[quo/logout-button {:on-press logout-press}]]])
[quo/logout-button {:on-press logout-press}]]))
(defn- get-item-layout
[_ index]
@@ -33,12 +33,11 @@
{:type :wallet-networks
:on-press #(rf/dispatch [:wallet/close-account-page])}]
[quo/account-overview
{:container-style style/account-overview
:current-value formatted-balance
{:current-value formatted-balance
:account-name name
:account (if watch-only? :watched-address :default)
:customization-color color}]
(when (ff/enabled? ::ff/wallet.graph) [quo/wallet-graph {:time-frame :empty}])
[quo/wallet-graph {:time-frame :empty}]
(when (not watch-only?)
[quo/wallet-ctas
{:container-style style/cta-buttons
@@ -46,12 +45,18 @@
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-flow}]))
:flow-id :wallet-send-flow}]))
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
{:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-token/view}])
:bridge-action #(rf/dispatch [:wallet/start-bridge])}])
:bridge-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-bridge-flow}]))
:swap-action (when (ff/enabled? ::ff/wallet.swap)
#(rf/dispatch [:wallet/start-swap]))}])
[quo/tabs
{:style style/tabs
:size 32
@@ -0,0 +1,11 @@
(ns status-im.contexts.wallet.bridge.flow-config)
(def steps
[{:screen-id :screen/wallet.bridge-select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
{:screen-id :screen/wallet.bridge-to
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}
{:screen-id :screen/wallet.bridge-input-amount
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :amount])))}
{:screen-id :screen/wallet.transaction-confirmation}
{:screen-id :screen/wallet.transaction-progress}])
@@ -34,11 +34,13 @@
:on-press #(rf/dispatch [:open-modal :screen/wallet.share-address {:status :receive}])})
(defn- action-bridge
[]
[token-data]
{:icon :i/bridge
:accessibility-label :bridge
:label (i18n/label :t/bridge)
:on-press #(js/alert "to be implemented")})
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet/bridge-select-token {:token token-data}]))})
(defn- action-manage-tokens
[watch-only?]
@@ -66,7 +68,7 @@
(not watch-only?) (concat [(action-buy)
(action-send token-data)
(action-receive)
(action-bridge)]))]]))
(action-bridge token-data)]))]]))
(defn view
[item _ _ {:keys [watch-only?]}]
@@ -1,22 +0,0 @@
(ns status-im.contexts.wallet.common.wizard
(:require [status-im.contexts.wallet.send.flow-config :as wallet-flow]
[utils.re-frame :as rf]))
(defn- wizard-find-next-screen
[db flow-id current-screen]
(let [flow-config (case flow-id
:wallet-flow wallet-flow/steps
nil)]
(first (filter (fn [{:keys [skip-step? screen-id]}]
(and (not= screen-id current-screen)
(not (and (fn? skip-step?) (skip-step? db)))))
flow-config))))
(rf/reg-event-fx
:wallet/wizard-navigate-forward
(fn [{:keys [db]} [{:keys [current-screen flow-id start-flow?]}]]
(let [next-screen (wizard-find-next-screen db flow-id current-screen)]
{:fx [[:dispatch
(if start-flow?
[:open-modal (:screen-id next-screen)]
[:navigate-to-within-stack [(:screen-id next-screen) current-screen]])]]})))
@@ -1,11 +1,13 @@
(ns status-im.contexts.wallet.common.wizard.events
(:require [status-im.contexts.wallet.send.flow-config :as wallet-flow]
(:require [status-im.contexts.wallet.bridge.flow-config :as wallet-bridge-flow]
[status-im.contexts.wallet.send.flow-config :as wallet-send-flow]
[utils.re-frame :as rf]))
(defn- wizard-find-next-screen
[db flow-id current-screen]
(let [flow-config (case flow-id
:wallet-flow wallet-flow/steps
:wallet-send-flow wallet-send-flow/steps
:wallet-bridge-flow wallet-bridge-flow/steps
nil)]
(first (filter (fn [{:keys [skip-step? screen-id]}]
(and (not= screen-id current-screen)
+11 -3
View File
@@ -247,8 +247,13 @@
(let [to-address (get-in db [:wallet :current-viewing-account-address])]
{:db (-> db
(assoc-in [:wallet :ui :send :token] token)
(assoc-in [:wallet :ui :send :to-address] to-address))
:fx [[:dispatch [:navigate-to-within-stack [:screen/wallet.bridge-to stack-id]]]]})))
(assoc-in [:wallet :ui :send :to-address] to-address)
(assoc-in [:wallet :ui :send :tx-type] :bridge))
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? true
:flow-id :wallet-bridge-flow}]]]})))
(rf/reg-event-fx :wallet/start-bridge
(fn [{:keys [db]}]
@@ -258,7 +263,10 @@
(rf/reg-event-fx :wallet/select-bridge-network
(fn [{:keys [db]} [{:keys [network-chain-id stack-id]}]]
{:db (assoc-in db [:wallet :ui :send :bridge-to-chain-id] network-chain-id)
:fx [[:dispatch [:navigate-to-within-stack [:screen/wallet.bridge-input-amount stack-id]]]]}))
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:flow-id :wallet-bridge-flow}]]]}))
(rf/reg-event-fx
:wallet/get-ethereum-chains
@@ -146,7 +146,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-flow}]]]})))
:flow-id :wallet-send-flow}]]]})))
(rf/reg-event-fx
:wallet/update-receiver-networks
@@ -174,7 +174,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-flow}]]]}))
:flow-id :wallet-send-flow}]]]}))
(rf/reg-event-fx
:wallet/edit-token-to-send
@@ -236,7 +236,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-flow}]]]}))
:flow-id :wallet-send-flow}]]]}))
(rf/reg-event-fx :wallet/disable-from-networks
(fn [{:keys [db]} [chain-ids]]
@@ -339,7 +339,7 @@
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen :screen/wallet.transaction-confirmation
:flow-id :wallet-flow}]]]})))
:flow-id :wallet-send-flow}]]]})))
(rf/reg-event-fx :wallet/close-transaction-progress-page
(fn [_]
@@ -509,4 +509,4 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-flow}]]]}))
:flow-id :wallet-send-flow}]]]}))
@@ -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"}]]]}))
+1
View File
@@ -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
+1
View File
@@ -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)
+2 -1
View File
@@ -392,7 +392,8 @@
:component wallet-bridge-select-asset/view}
{:name :screen/wallet.bridge-to
:options {:insets {:top? true}}
:options {:insets {:top? true}
:modalPresentationStyle :overCurrentContext}
:component wallet-bridge-to/view}
{:name :screen/wallet.bridge-input-amount
-9
View File
@@ -4,7 +4,6 @@
[re-frame.core :as re-frame]
[re-frame.interceptor :as interceptor]
[re-frame.interop :as rf.interop]
[reagent.core :as reagent]
[taoensso.timbre :as log]
[utils.datetime :as datetime])
(:refer-clojure :exclude [merge reduce]))
@@ -80,14 +79,6 @@
(swap! handler-nesting-level dec)
res))
(defn delay-render
[_]
(let [render? (reagent/atom false)]
(js/setTimeout #(reset! render? true) 0)
(fn [content]
(when @render?
content))))
(def sub (comp deref re-frame/subscribe))
(def dispatch re-frame/dispatch)
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "test-pr-new-release",
"commit-sha1": "0122a3237b62c89c2f65c55de0d837a1a16a88b4",
"src-sha256": "1kpgf74x416qxxsid976bhp59qh8yhmp2whd2zq0zqb8yn5iswp8"
"version": "v0.179.13",
"commit-sha1": "f3f48654f54aebbb4949129f930fef648d8da8f9",
"src-sha256": "09gcr6fgx6v4qdp83w0n2ynnlvwjqid477jgpqjk57l5wfrv2raq"
}