feat(wallet): Hide account switcher in send flow (#20892)
* Fix input amount step skipped while sending a token * Rename events to remove the `wallet` unnecessary suffix * Code style fixes * Fix React warnings: 1. About unique key in `select-address.tabs.view` along with a refactor 2. The deprecated `:keyboard-should-persist-taps` as `true` in `send.select-address.view` * Hide account switcher while sending a collectible * Fix tests
This commit is contained in:
parent
337ec963b7
commit
8f94332d59
|
@ -26,7 +26,8 @@
|
||||||
switcher-type :account-options
|
switcher-type :account-options
|
||||||
type :no-title}}]
|
type :no-title}}]
|
||||||
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||||
networks (rf/sub [:wallet/selected-network-details])]
|
networks (rf/sub [:wallet/selected-network-details])
|
||||||
|
sending-collectible? (rf/sub [:wallet/sending-collectible?])]
|
||||||
[quo/page-nav
|
[quo/page-nav
|
||||||
{:type type
|
{:type type
|
||||||
:icon-name icon-name
|
:icon-name icon-name
|
||||||
|
@ -41,8 +42,9 @@
|
||||||
(not watch-only?))
|
(not watch-only?))
|
||||||
{:icon-name :i/dapps
|
{:icon-name :i/dapps
|
||||||
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})
|
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})
|
||||||
{:content-type :account-switcher
|
(when-not sending-collectible?
|
||||||
:customization-color color
|
{:content-type :account-switcher
|
||||||
:on-press #(on-dapps-press switcher-type)
|
:customization-color color
|
||||||
:emoji emoji
|
:on-press #(on-dapps-press switcher-type)
|
||||||
:type (when watch-only? :watch-only)}]}]))
|
:emoji emoji
|
||||||
|
:type (when watch-only? :watch-only)})]}]))
|
||||||
|
|
|
@ -85,8 +85,9 @@
|
||||||
(rf/reg-event-fx :wallet/close-account-page
|
(rf/reg-event-fx :wallet/close-account-page
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
|
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
|
||||||
(when-not just-completed-transaction?
|
{:db (update db :wallet dissoc :current-viewing-account-address)
|
||||||
{:fx [[:dispatch [:wallet/clear-account-tab]]]}))))
|
:fx [(when-not just-completed-transaction?
|
||||||
|
[:dispatch [:wallet/clear-account-tab]])]})))
|
||||||
|
|
||||||
(defn log-rpc-error
|
(defn log-rpc-error
|
||||||
[_ [{:keys [event params]} error]]
|
[_ [{:keys [event params]} error]]
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
:size 32
|
:size 32
|
||||||
:default-active default-active
|
:default-active default-active
|
||||||
:data data
|
:data data
|
||||||
:on-change #(on-change %)}])
|
:on-change on-change}])
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -263,9 +263,12 @@
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/set-collectible-to-send
|
:wallet/set-collectible-to-send
|
||||||
(fn [{db :db} [{:keys [collectible current-screen start-flow?]}]]
|
(fn [{db :db} [{:keys [collectible current-screen start-flow? entry-point]}]]
|
||||||
(let [viewing-account? (some? (-> db :wallet :current-viewing-account-address))
|
(let [viewing-account? (some? (-> db :wallet :current-viewing-account-address))
|
||||||
entry-point (when-not viewing-account? :wallet-stack)
|
entry-point (cond
|
||||||
|
entry-point entry-point
|
||||||
|
viewing-account? :account-collectible-tab
|
||||||
|
:else :wallet-stack)
|
||||||
collection-data (:collection-data collectible)
|
collection-data (:collection-data collectible)
|
||||||
collectible-data (:collectible-data collectible)
|
collectible-data (:collectible-data collectible)
|
||||||
contract-type (:contract-type collectible)
|
contract-type (:contract-type collectible)
|
||||||
|
@ -702,3 +705,27 @@
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
:start-flow? start-flow?
|
:start-flow? start-flow?
|
||||||
:flow-id flow-id}]]]})))
|
:flow-id flow-id}]]]})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:wallet/transaction-confirmation-navigate-back
|
||||||
|
(fn [{db :db} [{:keys []}]]
|
||||||
|
(let [tx-type (-> db :wallet :ui :send :tx-type)
|
||||||
|
keep-tx-data? (#{:account-collectible-tab :wallet-stack}
|
||||||
|
(-> db :wallet :ui :send :entry-point))]
|
||||||
|
{:db (cond-> db
|
||||||
|
(and (= tx-type :tx/collectible-erc-721) (not keep-tx-data?))
|
||||||
|
(update-in [:wallet :ui :send] dissoc :tx-type :amount :route :suggested-routes)
|
||||||
|
|
||||||
|
(= tx-type :tx/collectible-erc-1155)
|
||||||
|
(update-in [:wallet :ui :send] dissoc :route :suggested-routes))
|
||||||
|
:fx [[:dispatch [:navigate-back]]]})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:wallet/collectible-amount-navigate-back
|
||||||
|
(fn [{db :db} [{:keys []}]]
|
||||||
|
(let [keep-tx-data? (#{:account-collectible-tab :wallet-stack}
|
||||||
|
(-> db :wallet :ui :send :entry-point))]
|
||||||
|
{:db (cond-> db
|
||||||
|
:always (update-in [:wallet :ui :send] dissoc :amount :route)
|
||||||
|
(not keep-tx-data?) (update-in [:wallet :ui :send] dissoc :tx-type))
|
||||||
|
:fx [[:dispatch [:navigate-back]]]})))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
||||||
{:screen-id :screen/wallet.send-input-amount
|
{:screen-id :screen/wallet.send-input-amount
|
||||||
:skip-step? (fn [db]
|
:skip-step? (fn [db]
|
||||||
(send-utils/tx-type-collectible? (get-in db [:wallet :ui :send :tx-type])))}
|
(-> db :wallet :ui :send :tx-type send-utils/tx-type-collectible?))}
|
||||||
{:screen-id :screen/wallet.select-collectible-amount
|
{:screen-id :screen/wallet.select-collectible-amount
|
||||||
:skip-step? (fn [db]
|
:skip-step? (fn [db]
|
||||||
(or (not (collectible-selected? db))
|
(or (not (collectible-selected? db))
|
||||||
|
|
|
@ -98,9 +98,10 @@
|
||||||
:related-chain-id 1
|
:related-chain-id 1
|
||||||
:layer 1}]
|
:layer 1}]
|
||||||
:wallet/wallet-send-enabled-from-chain-ids [1]
|
:wallet/wallet-send-enabled-from-chain-ids [1]
|
||||||
:wallet/wallet-send-amount nil
|
:wallet/send-amount nil
|
||||||
:wallet/wallet-send-tx-type :tx/send
|
:wallet/wallet-send-tx-type :tx/send
|
||||||
:wallet/wallet-send-fee-fiat-formatted "$5,00"
|
:wallet/wallet-send-fee-fiat-formatted "$5,00"
|
||||||
|
:wallet/sending-collectible? false
|
||||||
:wallet/total-amount (money/bignumber "250")})
|
:wallet/total-amount (money/bignumber "250")})
|
||||||
|
|
||||||
(h/describe "Send > input amount screen"
|
(h/describe "Send > input amount screen"
|
||||||
|
|
|
@ -9,6 +9,25 @@
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn other-account-item
|
||||||
|
[{:keys [address color emoji network-preferences-names]
|
||||||
|
account-name :name
|
||||||
|
:as account}]
|
||||||
|
(let [full-address (rf/sub [:wallet/account-address address network-preferences-names])]
|
||||||
|
[quo/account-item
|
||||||
|
{:account-props (assoc account
|
||||||
|
:customization-color color
|
||||||
|
:address full-address
|
||||||
|
:full-address? true)
|
||||||
|
:on-press (fn []
|
||||||
|
(rf/dispatch [:wallet/select-send-address
|
||||||
|
{:address address
|
||||||
|
:recipient {:recipient-type :account
|
||||||
|
:label account-name
|
||||||
|
:customization-color color
|
||||||
|
:emoji emoji}
|
||||||
|
:stack-id :screen/wallet.select-address}]))}]))
|
||||||
|
|
||||||
(defn- my-accounts
|
(defn- my-accounts
|
||||||
[theme]
|
[theme]
|
||||||
(let [other-accounts (rf/sub [:wallet/accounts-without-current-viewing-account])]
|
(let [other-accounts (rf/sub [:wallet/accounts-without-current-viewing-account])]
|
||||||
|
@ -20,22 +39,8 @@
|
||||||
:container-style style/empty-container-style}]
|
:container-style style/empty-container-style}]
|
||||||
[rn/view {:style style/my-accounts-container}
|
[rn/view {:style style/my-accounts-container}
|
||||||
(doall
|
(doall
|
||||||
(for [{:keys [color address] :as account} other-accounts]
|
(for [{:keys [address] :as account} other-accounts]
|
||||||
^{:key (str address)}
|
^{:key (str address)} [other-account-item account]))])))
|
||||||
(let [transformed-address (rf/sub [:wallet/account-address address
|
|
||||||
(:network-preferences-names account)])]
|
|
||||||
[quo/account-item
|
|
||||||
{:account-props (assoc account
|
|
||||||
:customization-color color
|
|
||||||
:address transformed-address
|
|
||||||
:full-address? true)
|
|
||||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
|
||||||
{:address address
|
|
||||||
:recipient {:recipient-type :account
|
|
||||||
:label (:name account)
|
|
||||||
:customization-color (:color account)
|
|
||||||
:emoji (:emoji account)}
|
|
||||||
:stack-id :screen/wallet.select-address}])}])))])))
|
|
||||||
|
|
||||||
(defn- recent-transactions
|
(defn- recent-transactions
|
||||||
[theme]
|
[theme]
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
(let [current-screen-id (rf/sub [:view-id])
|
(let [current-screen-id (rf/sub [:view-id])
|
||||||
scanned-address (rf/sub [:wallet/scanned-address])
|
scanned-address (rf/sub [:wallet/scanned-address])
|
||||||
send-address (rf/sub [:wallet/wallet-send-to-address])
|
send-address (rf/sub [:wallet/wallet-send-to-address])
|
||||||
recipient (rf/sub [:wallet/wallet-send-recipient])
|
recipient (rf/sub [:wallet/send-recipient])
|
||||||
recipient-plain-address? (= send-address recipient)
|
recipient-plain-address? (= send-address recipient)
|
||||||
valid-ens-or-address? (rf/sub [:wallet/valid-ens-or-address?])
|
valid-ens-or-address? (rf/sub [:wallet/valid-ens-or-address?])
|
||||||
contacts (rf/sub [:contacts/active])]
|
contacts (rf/sub [:contacts/active])]
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:content-container-style {:flex 1}
|
{:content-container-style {:flex 1}
|
||||||
:footer-container-padding 0
|
:footer-container-padding 0
|
||||||
:keyboard-should-persist-taps true
|
:keyboard-should-persist-taps :always
|
||||||
:header [account-switcher/view
|
:header [account-switcher/view
|
||||||
{:on-press #(rf/dispatch [:navigate-back])
|
{:on-press #(rf/dispatch [:navigate-back])
|
||||||
:margin-top (safe-area/get-top)
|
:margin-top (safe-area/get-top)
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
:on-collectible-press (fn [{:keys [collectible]}]
|
:on-collectible-press (fn [{:keys [collectible]}]
|
||||||
(rf/dispatch [:wallet/set-collectible-to-send
|
(rf/dispatch [:wallet/set-collectible-to-send
|
||||||
{:collectible collectible
|
{:collectible collectible
|
||||||
:current-screen :screen/wallet.select-asset}]))}]))
|
:current-screen :screen/wallet.select-asset
|
||||||
|
:entry-point :account-send-button}]))}]))
|
||||||
|
|
||||||
(defn- tab-view
|
(defn- tab-view
|
||||||
[search-text selected-tab on-change-text]
|
[search-text selected-tab on-change-text]
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [on-close (rn/use-callback #(rf/dispatch [:navigate-back]))
|
(let [on-close (rn/use-callback
|
||||||
|
#(rf/dispatch [:wallet/collectible-amount-navigate-back]))
|
||||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||||
collectible (:collectible send-transaction-data)
|
collectible (:collectible send-transaction-data)
|
||||||
balance (utils/collectible-balance collectible)
|
balance (utils/collectible-balance collectible)
|
||||||
|
@ -23,8 +24,9 @@
|
||||||
increase-value (rn/use-callback #(set-value controlled-input/increase))
|
increase-value (rn/use-callback #(set-value controlled-input/increase))
|
||||||
decrease-value (rn/use-callback #(set-value controlled-input/decrease))
|
decrease-value (rn/use-callback #(set-value controlled-input/decrease))
|
||||||
delete-character (rn/use-callback #(set-value controlled-input/delete-last))
|
delete-character (rn/use-callback #(set-value controlled-input/delete-last))
|
||||||
add-character (rn/use-callback (fn [c]
|
add-character (rn/use-callback
|
||||||
(set-value #(controlled-input/add-character % c))))]
|
(fn [c]
|
||||||
|
(set-value #(controlled-input/add-character % c))))]
|
||||||
(rn/use-effect
|
(rn/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
(set-value #(controlled-input/set-upper-limit % balance)))
|
(set-value #(controlled-input/set-upper-limit % balance)))
|
||||||
|
|
|
@ -195,7 +195,7 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[_]
|
[_]
|
||||||
(let [on-close #(rf/dispatch [:navigate-back])]
|
(let [on-close #(rf/dispatch [:wallet/transaction-confirmation-navigate-back])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [theme (quo.theme/use-theme)
|
(let [theme (quo.theme/use-theme)
|
||||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet.swap/set-default-slippage
|
(rf/reg-event-fx :wallet.swap/set-default-slippage
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
{:db
|
{:db (assoc-in db [:wallet :ui :swap :max-slippage] constants/default-slippage)}))
|
||||||
(assoc-in db [:wallet :ui :swap :max-slippage] constants/default-slippage)}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet.swap/set-max-slippage
|
(rf/reg-event-fx :wallet.swap/set-max-slippage
|
||||||
(fn [{:keys [db]} [max-slippage]]
|
(fn [{:keys [db]} [max-slippage]]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[status-im.contexts.wallet.common.activity-tab.constants :as constants]
|
[status-im.contexts.wallet.common.activity-tab.constants :as constants]
|
||||||
|
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||||
[utils.number]))
|
[utils.number]))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
:-> :send)
|
:-> :send)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/wallet-send-recipient
|
:wallet/send-recipient
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :recipient)
|
:-> :recipient)
|
||||||
|
|
||||||
|
@ -31,10 +32,20 @@
|
||||||
:-> :just-completed-transaction?)
|
:-> :just-completed-transaction?)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/wallet-send-amount
|
:wallet/send-amount
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :amount)
|
:-> :amount)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/send-tx-type
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :tx-type)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/sending-collectible?
|
||||||
|
:<- [:wallet/send-tx-type]
|
||||||
|
#(send-utils/tx-type-collectible? %))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/send-transaction-progress
|
:wallet/send-transaction-progress
|
||||||
:<- [:wallet/send-transaction-ids]
|
:<- [:wallet/send-transaction-ids]
|
||||||
|
|
Loading…
Reference in New Issue