Skip to content

Commit

Permalink
progress on bridge refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
briansztamfater committed Nov 22, 2024
1 parent 3226095 commit 0410a4f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 341 deletions.
3 changes: 1 addition & 2 deletions src/status_im/contexts/wallet/bridge/bridge_to/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
(assoc account-token
:networks (:networks token)
:supported-networks (:supported-networks token)))
bridge-to-title (i18n/label :t/bridge-to
{:name (string/upper-case (str token-symbol))})]
bridge-to-title (i18n/label :t/select-network-to-receive)]

(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))

Expand Down
29 changes: 22 additions & 7 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
[utils.number]
[utils.re-frame :as rf]
[utils.security.core :as security]
[utils.transforms :as transforms]))
[utils.transforms :as transforms]
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]))

(rf/reg-event-fx :wallet/show-account-created-toast
(fn [{:keys [db]} [address]]
Expand Down Expand Up @@ -327,19 +328,33 @@
(rf/reg-event-fx :wallet/get-keypairs get-keypairs)

(rf/reg-event-fx :wallet/bridge-select-token
(fn [{:keys [db]} [{:keys [token token-symbol stack-id start-flow?]}]]
(fn [{:keys [db]} [{:keys [token token-symbol stack-id network start-flow?] :as params}]]
(let [missing-recipient? (-> db :wallet :ui :send :to-address nil?)
to-address (-> db :wallet :current-viewing-account-address)]
{:db (cond-> db
:always (assoc-in [:wallet :ui :send :tx-type] :tx/bridge)
token (assoc-in [:wallet :ui :send :token] token)
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
network (assoc-in [:wallet :ui :send :network] network)
missing-recipient? (assoc-in [:wallet :ui :send :to-address] to-address))
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-bridge-flow}]]]})))
:fx (if (some? network)
[[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-bridge-flow}]]]
[[:dispatch [:wallet/switch-current-viewing-account to-address]]
[:dispatch
[:show-bottom-sheet
{:content (fn []
[network-selection/view
{:token-symbol (or token-symbol (:symbol token))
:source :send
:on-select-network (fn [network]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch
[:wallet/select-from-account
(assoc params :network network)]))}])}]]])})))

(rf/reg-event-fx :wallet/start-bridge
(fn [{:keys [db]}]
Expand Down
8 changes: 6 additions & 2 deletions src/status_im/contexts/wallet/send/input_amount/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require
[clojure.string :as string]
[quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
Expand All @@ -13,6 +12,7 @@
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.send.input-amount.estimated-fees :as estimated-fees]
[status-im.contexts.wallet.send.input-amount.style :as style]
[status-im.contexts.wallet.send.routes.view :as routes]
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
[status-im.setup.hot-reload :as hot-reload]
[utils.debounce :as debounce]
Expand Down Expand Up @@ -119,6 +119,7 @@
(string/upper-case constants/mainnet-short-name)
[(:chain-id network)]])
suggested-routes (rf/sub [:wallet/wallet-send-suggested-routes])
tx-type (rf/sub [:wallet/wallet-send-tx-type])
[crypto-currency?
set-crypto-currency] (rn/use-state initial-crypto-currency?)
[input-state set-input-state] (rn/use-state controlled-input/init-state)
Expand Down Expand Up @@ -266,7 +267,10 @@
(controlled-input/upper-limit-bn
input-state)))})
:status (when (controlled-input/input-error input-state) :error)}]}]
[rn/view {:style {:flex 1}}]
(if (= tx-type :tx/bridge)
[routes/view
{:token token-by-symbol}]
[rn/view {:style {:flex 1}}])
(when not-enough-asset?
[not-enough-asset])
(when (or (and (not no-routes-found?) (or loading-routes? route))
Expand Down
16 changes: 0 additions & 16 deletions src/status_im/contexts/wallet/send/routes/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,3 @@
:top margin-top}
inverted?
(assoc :transform [{:scaleY -1}])))

(def disclaimer
{:margin-horizontal 20
:margin-top 20
:margin-bottom 8})

(def input-container
{:margin-top 8
:margin-bottom 12})

(defn keyboard-container
[bottom]
{:padding-bottom bottom})

(def error-box
{:margin-horizontal 20})
Loading

0 comments on commit 0410a4f

Please sign in to comment.