From 162c6dbf89fd6c37980393f2f654e68d5d007875 Mon Sep 17 00:00:00 2001 From: Brian Sztamfater Date: Wed, 10 Jan 2024 12:49:45 -0300 Subject: [PATCH] fix: route not found when attempting to transfer assets to additional eth account (#18325) Signed-off-by: Brian Sztamfater --- src/status_im/contexts/wallet/events.cljs | 4 ++++ src/status_im/contexts/wallet/send/events.cljs | 18 ++++++++++++------ .../wallet/send/select_address/tabs/view.cljs | 7 +++---- .../wallet/send/select_address/view.cljs | 4 +++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 639a8053f1..101857a13f 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -301,6 +301,10 @@ (background-timer/clear-timeout current-timeout) {:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)}))) +(rf/reg-event-fx :wallet/clean-account-selection + (fn [{:keys [db]}] + {:db (update-in db [:wallet :ui :send] dissoc :send-account-address)})) + (rf/reg-event-fx :wallet/get-address-details-success (fn [{:keys [db]} [{:keys [hasActivity]}]] {:db (assoc-in db diff --git a/src/status_im/contexts/wallet/send/events.cljs b/src/status_im/contexts/wallet/send/events.cljs index 3b7c1b1a56..d0ae295967 100644 --- a/src/status_im/contexts/wallet/send/events.cljs +++ b/src/status_im/contexts/wallet/send/events.cljs @@ -14,10 +14,6 @@ {:db (assoc-in db [:wallet :ui :send :select-address-tab] tab)})) -(rf/reg-event-fx :wallet/select-send-account-address - (fn [{:keys [db]} [address]] - {:db (assoc db [:wallet :ui :send :send-account-address] address)})) - (rf/reg-event-fx :wallet/suggested-routes-success (fn [{:keys [db]} [suggested-routes timestamp]] (when (= (get-in db [:wallet :ui :send :suggested-routes-call-timestamp]) timestamp) @@ -44,9 +40,18 @@ (update-in [:wallet :ui :send] dissoc :route) (update-in [:wallet :ui :send] dissoc :loading-suggested-routes?))})) +(rf/reg-event-fx :wallet/select-send-account-address + (fn [{:keys [db]} [{:keys [address stack-id]}]] + {:db (-> db + (assoc-in [:wallet :ui :send :send-account-address] address) + (update-in [:wallet :ui :send] dissoc :to-address)) + :fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]})) + (rf/reg-event-fx :wallet/select-send-address (fn [{:keys [db]} [{:keys [address stack-id]}]] - {:db (assoc-in db [:wallet :ui :send :to-address] address) + {:db (-> db + (assoc-in [:wallet :ui :send :to-address] address) + (update-in [:wallet :ui :send] dissoc :send-account-address)) :fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]})) (rf/reg-event-fx :wallet/send-select-token @@ -63,7 +68,8 @@ (fn [{:keys [db now]} [amount]] (let [wallet-address (get-in db [:wallet :current-viewing-account-address]) token (get-in db [:wallet :ui :send :token]) - to-address (get-in db [:wallet :ui :send :to-address]) + account-address (get-in db [:wallet :ui :send :send-account-address]) + to-address (or account-address (get-in db [:wallet :ui :send :to-address])) token-decimal (:decimals token) token-id (:symbol token) network-preferences [] diff --git a/src/status_im/contexts/wallet/send/select_address/tabs/view.cljs b/src/status_im/contexts/wallet/send/select_address/tabs/view.cljs index ef3aa7a54d..c8251eeb0b 100644 --- a/src/status_im/contexts/wallet/send/select_address/tabs/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/tabs/view.cljs @@ -12,10 +12,9 @@ [{:keys [color address] :as account}] [quo/account-item {:account-props (assoc account :customization-color color) - :on-press (fn [] - (rf/dispatch [:wallet/select-send-account-address address]) - (rf/dispatch [:navigate-to-within-stack - [:wallet-select-asset :wallet-select-address]]))}]) + :on-press #(rf/dispatch [:wallet/select-send-account-address + {:address address + :stack-id :wallet-select-address}])}]) (defn my-accounts [theme] diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index e49abdc5f7..b6d334574b 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -117,6 +117,7 @@ (let [on-close (fn [] (rf/dispatch [:wallet/clean-scanned-address]) (rf/dispatch [:wallet/clean-local-suggestions]) + (rf/dispatch [:wallet/clean-account-selection]) (rf/dispatch [:wallet/select-address-tab nil]) (rf/dispatch [:navigate-back])) on-change-tab #(rf/dispatch [:wallet/select-address-tab %]) @@ -128,7 +129,8 @@ (rn/use-effect (fn [] (fn [] (rf/dispatch [:wallet/clean-scanned-address]) - (rf/dispatch [:wallet/clean-local-suggestions])))) + (rf/dispatch [:wallet/clean-local-suggestions]) + (rf/dispatch [:wallet/clean-account-selection])))) [floating-button-page/view {:header [account-switcher/view {:on-press on-close