fix start from general wallet screen

This commit is contained in:
Brian Sztamfater 2024-11-23 21:35:29 -03:00
parent 0410a4f030
commit f2bdcfb927
No known key found for this signature in database
GPG Key ID: 59EB921E0706B48F
8 changed files with 80 additions and 109 deletions

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.wallet.bridge.bridge-to.view (ns status-im.contexts.wallet.bridge.bridge-to.view
(:require (:require
[clojure.string :as string]
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.resources :as quo.resources] [quo.foundations.resources :as quo.resources]
[quo.theme] [quo.theme]
@ -59,7 +58,7 @@
[rn/view [rn/view
[account-switcher/view [account-switcher/view
{:on-press #(rf/dispatch [:navigate-back]) {:on-press #(rf/dispatch [:dismiss-modal])
:icon-name :i/arrow-left :icon-name :i/arrow-left
:accessibility-label :top-bar :accessibility-label :top-bar
:switcher-type :select-account}] :switcher-type :select-account}]

View File

@ -1,9 +1,7 @@
(ns status-im.contexts.wallet.bridge.flow-config) (ns status-im.contexts.wallet.bridge.flow-config)
(def steps (def steps
[{:screen-id :screen/wallet.select-from [{:screen-id :screen/wallet.bridge-select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
{:screen-id :screen/wallet.bridge-select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))} :skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
{:screen-id :screen/wallet.bridge-to {:screen-id :screen/wallet.bridge-to
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))} :skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}

View File

@ -10,11 +10,13 @@
[status-im.contexts.settings.wallet.effects] [status-im.contexts.settings.wallet.effects]
[status-im.contexts.settings.wallet.events] [status-im.contexts.settings.wallet.events]
[status-im.contexts.wallet.common.activity-tab.events] [status-im.contexts.wallet.common.activity-tab.events]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.external-links :as external-links] [status-im.contexts.wallet.common.utils.external-links :as external-links]
[status-im.contexts.wallet.common.utils.networks :as network-utils] [status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.data-store :as data-store] [status-im.contexts.wallet.data-store :as data-store]
[status-im.contexts.wallet.db :as db] [status-im.contexts.wallet.db :as db]
[status-im.contexts.wallet.item-types :as item-types] [status-im.contexts.wallet.item-types :as item-types]
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
[status-im.contexts.wallet.tokens.events] [status-im.contexts.wallet.tokens.events]
[status-im.feature-flags :as ff] [status-im.feature-flags :as ff]
[taoensso.timbre :as log] [taoensso.timbre :as log]
@ -25,8 +27,7 @@
[utils.number] [utils.number]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[utils.security.core :as security] [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 (rf/reg-event-fx :wallet/show-account-created-toast
(fn [{:keys [db]} [address]] (fn [{:keys [db]} [address]]
@ -329,32 +330,39 @@
(rf/reg-event-fx :wallet/bridge-select-token (rf/reg-event-fx :wallet/bridge-select-token
(fn [{:keys [db]} [{:keys [token token-symbol stack-id network start-flow?] :as params}]] (fn [{:keys [db]} [{:keys [token token-symbol stack-id network start-flow?] :as params}]]
(let [missing-recipient? (-> db :wallet :ui :send :to-address nil?) (let [{:keys [wallet]} db
to-address (-> db :wallet :current-viewing-account-address)] missing-recipient? (-> db :wallet :ui :send :to-address nil?)
to-address (-> db :wallet :current-viewing-account-address)
multi-account-balance? (-> (utils/get-accounts-with-token-balance (:accounts wallet)
token)
(count)
(> 1))]
{:db (cond-> db {:db (cond-> db
:always (assoc-in [:wallet :ui :send :tx-type] :tx/bridge) :always (assoc-in [:wallet :ui :send :tx-type] :tx/bridge)
token (assoc-in [:wallet :ui :send :token] token) token (assoc-in [:wallet :ui :send :token] token)
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol) token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
network (assoc-in [:wallet :ui :send :network] network) network (assoc-in [:wallet :ui :send :network] network)
missing-recipient? (assoc-in [:wallet :ui :send :to-address] to-address)) missing-recipient? (assoc-in [:wallet :ui :send :to-address] to-address))
:fx (if (some? network) :fx (if multi-account-balance?
[[:dispatch [[:dispatch [:open-modal :screen/wallet.select-from]]]
[:wallet/wizard-navigate-forward (if (some? network)
{:current-screen stack-id [[:dispatch
:start-flow? start-flow? [:wallet/wizard-navigate-forward
:flow-id :wallet-bridge-flow}]]] {:current-screen stack-id
[[:dispatch [:wallet/switch-current-viewing-account to-address]] :start-flow? start-flow?
[:dispatch :flow-id :wallet-bridge-flow}]]]
[:show-bottom-sheet [[:dispatch [:wallet/switch-current-viewing-account to-address]]
{:content (fn [] [:dispatch
[network-selection/view [:show-bottom-sheet
{:token-symbol (or token-symbol (:symbol token)) {:content (fn []
:source :send [network-selection/view
:on-select-network (fn [network] {:token-symbol (or token-symbol (:symbol token))
(rf/dispatch [:hide-bottom-sheet]) :source :send
(rf/dispatch :on-select-network (fn [network]
[:wallet/select-from-account (rf/dispatch [:hide-bottom-sheet])
(assoc params :network network)]))}])}]]])}))) (rf/dispatch
[:wallet/select-from-account
(assoc params :network network)]))}])}]]]))})))
(rf/reg-event-fx :wallet/start-bridge (rf/reg-event-fx :wallet/start-bridge
(fn [{:keys [db]}] (fn [{:keys [db]}]

View File

@ -9,13 +9,13 @@
[status-im.contexts.wallet.common.wizard.utils :as wizard-utils] [status-im.contexts.wallet.common.wizard.utils :as wizard-utils]
[status-im.contexts.wallet.data-store :as data-store] [status-im.contexts.wallet.data-store :as data-store]
[status-im.contexts.wallet.send.utils :as send-utils] [status-im.contexts.wallet.send.utils :as send-utils]
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.address :as address] [utils.address :as address]
[utils.hex :as utils.hex] [utils.hex :as utils.hex]
[utils.money :as utils.money] [utils.money :as utils.money]
[utils.number] [utils.number]
[utils.re-frame :as rf] [utils.re-frame :as rf]))
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]))
(rf/reg-event-fx :wallet/clean-send-data (rf/reg-event-fx :wallet/clean-send-data
(fn [{:keys [db]}] (fn [{:keys [db]}]
@ -152,7 +152,7 @@
(rf/reg-event-fx (rf/reg-event-fx
:wallet/select-send-address :wallet/select-send-address
(fn [{:keys [db]} [{:keys [address recipient stack-id start-flow?]}]] (fn [{:keys [db]} [{:keys [address recipient stack-id start-flow?]}]]
(let [[to-address] (utils/split-prefix-and-address address) (let [[_ to-address] (utils/split-prefix-and-address address)
collectible-tx? (send-utils/tx-type-collectible? collectible-tx? (send-utils/tx-type-collectible?
(-> db :wallet :ui :send :tx-type)) (-> db :wallet :ui :send :tx-type))
collectible (when collectible-tx? collectible (when collectible-tx?
@ -184,10 +184,7 @@
;; `token` is a map extracted from the sender, but in the wallet home page we don't know the ;; `token` is a map extracted from the sender, but in the wallet home page we don't know the
;; sender yet, so we only provide the `token-symbol`, later in ;; sender yet, so we only provide the `token-symbol`, later in
;; `:wallet/select-from-account` the `token` key will be set. ;; `:wallet/select-from-account` the `token` key will be set.
(let [{:keys [networks]} token (let [{:keys [wallet]} db
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
token-networks-ids (map :chain-id networks)
unsupported-token? (not-any? (set receiver-networks) token-networks-ids)
unique-owner (when (= (count owners) 1) unique-owner (when (= (count owners) 1)
(first owners)) (first owners))
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens]) unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
@ -195,6 +192,10 @@
(when (and token-symbol unique-owner) (when (and token-symbol unique-owner)
(some #(when (= (:symbol %) token-symbol) %) (some #(when (= (:symbol %) token-symbol) %)
unique-owner-tokens))) unique-owner-tokens)))
multi-account-balance? (-> (utils/get-accounts-with-token-balance (:accounts wallet)
token)
(count)
(> 1))
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?]) test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
network-details (-> (get-in db network-details (-> (get-in db
[:wallet :networks (if test-networks-enabled? :test :prod)]) [:wallet :networks (if test-networks-enabled? :test :prod)])
@ -202,7 +203,6 @@
next-screen (:screen-id (wizard-utils/wizard-find-next-screen db next-screen (:screen-id (wizard-utils/wizard-find-next-screen db
:wallet-send-flow :wallet-send-flow
stack-id))] stack-id))]
(println next-screen "432432342")
(when (or token-data token-symbol) (when (or token-data token-symbol)
{:db (cond-> db {:db (cond-> db
network (update-in [:wallet :ui :send] network (update-in [:wallet :ui :send]
@ -217,32 +217,35 @@
(network-utils/network-list (network-utils/network-list
token-data token-data
network-details)) network-details))
:token-display-name (:symbol token-data))) :token-display-name (:symbol token-data)
:token-symbol (:symbol token-data)))
unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner) unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner)
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point)) entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
:fx (if (or (= next-screen :screen/wallet.select-from) (some? network)) :fx (if multi-account-balance?
[[:dispatch [:wallet/stop-and-clean-suggested-routes]] [[:dispatch [:open-modal :screen/wallet.select-from]]]
[:dispatch (if (or (= next-screen :screen/wallet.select-from) (some? network))
;; ^:flush-dom allows us to make sure the re-frame DB state is always synced [[:dispatch [:wallet/stop-and-clean-suggested-routes]]
;; before the navigation occurs, so the new screen is always rendered with [:dispatch
;; the DB state set by this event. By adding the metadata we are omitting ;; ^:flush-dom allows us to make sure the re-frame DB state is always synced
;; a 1-frame blink when the screen is mounted. ;; before the navigation occurs, so the new screen is always rendered with
^:flush-dom ;; the DB state set by this event. By adding the metadata we are omitting
[:wallet/wizard-navigate-forward ;; a 1-frame blink when the screen is mounted.
{:current-screen stack-id ^:flush-dom
:start-flow? start-flow? [:wallet/wizard-navigate-forward
:flow-id :wallet-send-flow}]]] {:current-screen stack-id
[[:dispatch :start-flow? start-flow?
[:show-bottom-sheet :flow-id :wallet-send-flow}]]]
{:content (fn [] [[:dispatch
[network-selection/view [:show-bottom-sheet
{:token-symbol (or token-symbol (:symbol token-data)) {:content (fn []
:source :send [network-selection/view
:on-select-network (fn [network] {:token-symbol (or token-symbol (:symbol token-data))
(rf/dispatch [:hide-bottom-sheet]) :source :send
(rf/dispatch :on-select-network (fn [network]
[:wallet/set-token-to-send (rf/dispatch [:hide-bottom-sheet])
(assoc params :network network)]))}])}]]])})))) (rf/dispatch
[:wallet/set-token-to-send
(assoc params :network network)]))}])}]]]))}))))
(rf/reg-event-fx (rf/reg-event-fx
:wallet/edit-token-to-send :wallet/edit-token-to-send
@ -688,8 +691,9 @@
:networks (network-utils/network-list-with-positive-balance :networks (network-utils/network-list-with-positive-balance
token token
network-details) network-details)
:supported-networks (network-utils/network-list token :supported-networks (network-utils/network-list
network-details) token
network-details)
:total-balance (utils/calculate-total-token-balance token)))) :total-balance (utils/calculate-total-token-balance token))))
bridge-tx? (= tx-type :tx/bridge) bridge-tx? (= tx-type :tx/bridge)
flow-id (if bridge-tx? flow-id (if bridge-tx?
@ -706,10 +710,12 @@
{:current-screen stack-id {:current-screen stack-id
:start-flow? start-flow? :start-flow? start-flow?
:flow-id flow-id}]]] :flow-id flow-id}]]]
[[:dispatch [:wallet/switch-current-viewing-account address]] [[:dispatch [:dismiss-modal :screen/wallet.select-from]]
[:dispatch [:wallet/switch-current-viewing-account address]]
[:dispatch [:dispatch
[:show-bottom-sheet [:show-bottom-sheet
{:content (fn [] {:content (fn []
(println (or token-symbol (:symbol token)) token "fdsfdsfsdfsd")
[network-selection/view [network-selection/view
{:token-symbol (or token-symbol (:symbol token)) {:token-symbol (or token-symbol (:symbol token))
:source :send :source :send

View File

@ -14,9 +14,7 @@
(-> db :wallet :ui :send :token some?)) (-> db :wallet :ui :send :token some?))
(def steps (def steps
[{:screen-id :screen/wallet.select-from [{:screen-id :screen/wallet.select-address
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
{:screen-id :screen/wallet.select-address
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))} :skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))}
{:screen-id :screen/wallet.select-asset {:screen-id :screen/wallet.select-asset
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))} :skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}

View File

@ -15,7 +15,8 @@
(rf/dispatch [:wallet/select-from-account (rf/dispatch [:wallet/select-from-account
{:address address {:address address
:network-details network-details :network-details network-details
:stack-id :screen/wallet.select-from}])) :stack-id :screen/wallet.select-from
:start-flow? true}]))
(defn- on-close (defn- on-close
[] []

View File

@ -6,43 +6,7 @@
[status-im.common.not-implemented :as not-implemented] [status-im.common.not-implemented :as not-implemented]
[status-im.contexts.wallet.send.input-amount.style :as style] [status-im.contexts.wallet.send.input-amount.style :as style]
[status-im.feature-flags :as ff] [status-im.feature-flags :as ff]
[utils.i18n :as i18n] [utils.i18n :as i18n]))
[utils.re-frame :as rf]))
(defn- bonder-fee-info-sheet
[]
[:<>
[quo/drawer-top
{:title (i18n/label :t/understanding-bonder-fees-title)}]
[rn/view {:style {:padding-horizontal 20}}
[quo/text
{:weight :regular
:size :paragraph-2}
(i18n/label :t/understanding-bonder-fees-description)]]])
(defn- show-bonder-fee-info
[]
(rf/dispatch
[:show-bottom-sheet {:content bonder-fee-info-sheet}]))
(defn- received-amount
[{:keys [loading-routes?]}]
(let [amount (rf/sub [:wallet/send-total-amount-formatted])
tx-type (rf/sub [:wallet/wallet-send-tx-type])
{:keys [full-name]} (rf/sub [:wallet/bridge-to-network-details])]
[quo/data-item
(cond-> {:container-style style/amount-data-item
:status (if loading-routes? :loading :default)
:size :small
:title (i18n/label :t/recipient-gets)
:subtitle amount}
(= tx-type :tx/bridge)
(assoc
:title-icon :i/info
:title (i18n/label :t/bridged-to
{:network full-name})
:on-press show-bonder-fee-info))]))
(defn view (defn view
[{:keys [loading-routes? fees]}] [{:keys [loading-routes? fees]}]

View File

@ -1204,10 +1204,7 @@
"include": "Include", "include": "Include",
"incoming": "Incoming", "incoming": "Incoming",
"incoming-transaction": "Incoming transaction", "incoming-transaction": "Incoming transaction",
"incorrect-code": [ "incorrect-code": ["str", "Sorry the code was incorrect, please enter it again"],
"str",
"Sorry the code was incorrect, please enter it again"
],
"incorrect-private-key": "This is not the private key for this key pair", "incorrect-private-key": "This is not the private key for this key pair",
"increase-gas": "Increase Gas", "increase-gas": "Increase Gas",
"information-you-input-and-send": "Information you input and send", "information-you-input-and-send": "Information you input and send",
@ -2257,6 +2254,7 @@
"select-chat": "Select chat to start messaging", "select-chat": "Select chat to start messaging",
"select-network": "Select network", "select-network": "Select network",
"select-network-for-buying": "Select network for buying", "select-network-for-buying": "Select network for buying",
"select-network-to-receive": "Select network to receive",
"select-networks": "Select networks", "select-networks": "Select networks",
"select-new-location-for-keys": "Select a new location to save your private key(s)", "select-new-location-for-keys": "Select a new location to save your private key(s)",
"select-token-to-receive": "Select token to receive", "select-token-to-receive": "Select token to receive",
@ -2938,6 +2936,5 @@
"your-recovery-phrase": "Your seed phrase", "your-recovery-phrase": "Your seed phrase",
"your-recovery-phrase-description": "This is your seed phrase. You use it to prove that this is your wallet. You only get to see it once! Write it on paper and keep it in a secure place. You will need it if you lose or reinstall your wallet.", "your-recovery-phrase-description": "This is your seed phrase. You use it to prove that this is your wallet. You only get to see it once! Write it on paper and keep it in a secure place. You will need it if you lose or reinstall your wallet.",
"your-tip-limit": "Your tip limit", "your-tip-limit": "Your tip limit",
"youre-on-mobile-network": "Youre on mobile network", "youre-on-mobile-network": "Youre on mobile network"
"select-network-to-receive": "Select network to receive"
} }