feat: Start bridge from asset drawer (#19860)
feat: Start bridge from asset drawer (#19860)
This commit is contained in:
parent
842dbbbd8d
commit
604eaccbbf
|
@ -33,12 +33,11 @@
|
||||||
{:type :wallet-networks
|
{:type :wallet-networks
|
||||||
:on-press #(rf/dispatch [:wallet/close-account-page])}]
|
:on-press #(rf/dispatch [:wallet/close-account-page])}]
|
||||||
[quo/account-overview
|
[quo/account-overview
|
||||||
{:container-style style/account-overview
|
{:current-value formatted-balance
|
||||||
:current-value formatted-balance
|
|
||||||
:account-name name
|
:account-name name
|
||||||
:account (if watch-only? :watched-address :default)
|
:account (if watch-only? :watched-address :default)
|
||||||
:customization-color color}]
|
: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?)
|
(when (not watch-only?)
|
||||||
[quo/wallet-ctas
|
[quo/wallet-ctas
|
||||||
{:container-style style/cta-buttons
|
{:container-style style/cta-buttons
|
||||||
|
@ -46,14 +45,18 @@
|
||||||
(rf/dispatch [:wallet/clean-send-data])
|
(rf/dispatch [:wallet/clean-send-data])
|
||||||
(rf/dispatch [:wallet/wizard-navigate-forward
|
(rf/dispatch [:wallet/wizard-navigate-forward
|
||||||
{:start-flow? true
|
{:start-flow? true
|
||||||
:flow-id :wallet-flow}]))
|
:flow-id :wallet-send-flow}]))
|
||||||
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
|
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
|
||||||
{:status :receive}])
|
{:status :receive}])
|
||||||
:buy-action #(rf/dispatch [:show-bottom-sheet
|
:buy-action #(rf/dispatch [:show-bottom-sheet
|
||||||
{:content buy-token/view}])
|
{: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)
|
:swap-action (when (ff/enabled? ::ff/wallet.swap)
|
||||||
#(rf/dispatch [:wallet/start-swap]))
|
#(rf/dispatch [:wallet/start-swap]))}])
|
||||||
:bridge-action #(rf/dispatch [:wallet/start-bridge])}])
|
|
||||||
[quo/tabs
|
[quo/tabs
|
||||||
{:style style/tabs
|
{:style style/tabs
|
||||||
:size 32
|
: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}])})
|
:on-press #(rf/dispatch [:open-modal :screen/wallet.share-address {:status :receive}])})
|
||||||
|
|
||||||
(defn- action-bridge
|
(defn- action-bridge
|
||||||
[]
|
[token-data]
|
||||||
{:icon :i/bridge
|
{:icon :i/bridge
|
||||||
:accessibility-label :bridge
|
:accessibility-label :bridge
|
||||||
:label (i18n/label :t/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
|
(defn- action-manage-tokens
|
||||||
[watch-only?]
|
[watch-only?]
|
||||||
|
@ -66,7 +68,7 @@
|
||||||
(not watch-only?) (concat [(action-buy)
|
(not watch-only?) (concat [(action-buy)
|
||||||
(action-send token-data)
|
(action-send token-data)
|
||||||
(action-receive)
|
(action-receive)
|
||||||
(action-bridge)]))]]))
|
(action-bridge token-data)]))]]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[item _ _ {:keys [watch-only?]}]
|
[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
|
(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]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- wizard-find-next-screen
|
(defn- wizard-find-next-screen
|
||||||
[db flow-id current-screen]
|
[db flow-id current-screen]
|
||||||
(let [flow-config (case flow-id
|
(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)]
|
nil)]
|
||||||
(first (filter (fn [{:keys [skip-step? screen-id]}]
|
(first (filter (fn [{:keys [skip-step? screen-id]}]
|
||||||
(and (not= screen-id current-screen)
|
(and (not= screen-id current-screen)
|
||||||
|
|
|
@ -247,8 +247,13 @@
|
||||||
(let [to-address (get-in db [:wallet :current-viewing-account-address])]
|
(let [to-address (get-in db [:wallet :current-viewing-account-address])]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:wallet :ui :send :token] token)
|
(assoc-in [:wallet :ui :send :token] token)
|
||||||
(assoc-in [:wallet :ui :send :to-address] to-address))
|
(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 :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
|
(rf/reg-event-fx :wallet/start-bridge
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
|
@ -258,7 +263,10 @@
|
||||||
(rf/reg-event-fx :wallet/select-bridge-network
|
(rf/reg-event-fx :wallet/select-bridge-network
|
||||||
(fn [{:keys [db]} [{:keys [network-chain-id stack-id]}]]
|
(fn [{:keys [db]} [{:keys [network-chain-id stack-id]}]]
|
||||||
{:db (assoc-in db [:wallet :ui :send :bridge-to-chain-id] network-chain-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
|
(rf/reg-event-fx
|
||||||
:wallet/get-ethereum-chains
|
:wallet/get-ethereum-chains
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:flow-id :wallet-flow}]]]})))
|
:flow-id :wallet-send-flow}]]]})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/update-receiver-networks
|
:wallet/update-receiver-networks
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:flow-id :wallet-flow}]]]}))
|
:flow-id :wallet-send-flow}]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/edit-token-to-send
|
:wallet/edit-token-to-send
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:flow-id :wallet-flow}]]]}))
|
:flow-id :wallet-send-flow}]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/disable-from-networks
|
(rf/reg-event-fx :wallet/disable-from-networks
|
||||||
(fn [{:keys [db]} [chain-ids]]
|
(fn [{:keys [db]} [chain-ids]]
|
||||||
|
@ -339,7 +339,7 @@
|
||||||
:fx [[:dispatch
|
:fx [[:dispatch
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen :screen/wallet.transaction-confirmation
|
{:current-screen :screen/wallet.transaction-confirmation
|
||||||
:flow-id :wallet-flow}]]]})))
|
:flow-id :wallet-send-flow}]]]})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/close-transaction-progress-page
|
(rf/reg-event-fx :wallet/close-transaction-progress-page
|
||||||
(fn [_]
|
(fn [_]
|
||||||
|
@ -509,4 +509,4 @@
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:flow-id :wallet-flow}]]]}))
|
:flow-id :wallet-send-flow}]]]}))
|
||||||
|
|
|
@ -392,7 +392,8 @@
|
||||||
:component wallet-bridge-select-asset/view}
|
:component wallet-bridge-select-asset/view}
|
||||||
|
|
||||||
{:name :screen/wallet.bridge-to
|
{:name :screen/wallet.bridge-to
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}
|
||||||
|
:modalPresentationStyle :overCurrentContext}
|
||||||
:component wallet-bridge-to/view}
|
:component wallet-bridge-to/view}
|
||||||
|
|
||||||
{:name :screen/wallet.bridge-input-amount
|
{:name :screen/wallet.bridge-input-amount
|
||||||
|
|
Loading…
Reference in New Issue