Skip to content

Commit

Permalink
feat: Start bridge from asset drawer (#19860)
Browse files Browse the repository at this point in the history
feat: Start bridge from asset drawer (#19860)
  • Loading branch information
OmarBasem authored May 8, 2024
1 parent 842dbbb commit 604eacc
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 42 deletions.
15 changes: 9 additions & 6 deletions src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,30 @@
{: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
:send-action (fn []
(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 (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]))
:bridge-action #(rf/dispatch [:wallet/start-bridge])}])
#(rf/dispatch [:wallet/start-swap]))}])
[quo/tabs
{:style style/tabs
:size 32
Expand Down
11 changes: 11 additions & 0 deletions src/status_im/contexts/wallet/bridge/flow_config.cljs
Original file line number Diff line number Diff line change
@@ -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}])
8 changes: 5 additions & 3 deletions src/status_im/contexts/wallet/common/token_value/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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?]
Expand Down Expand Up @@ -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?]}]
Expand Down
22 changes: 0 additions & 22 deletions src/status_im/contexts/wallet/common/wizard.cljs

This file was deleted.

6 changes: 4 additions & 2 deletions src/status_im/contexts/wallet/common/wizard/events.cljs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
14 changes: 11 additions & 3 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}]
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/status_im/contexts/wallet/send/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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 [_]
Expand Down Expand Up @@ -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}]]]}))
3 changes: 2 additions & 1 deletion src/status_im/navigation/screens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 604eacc

Please sign in to comment.