-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for "no routes found" on transaction confirmation page #19789
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,6 @@ | |
|
||
route (rf/sub [:wallet/wallet-send-route]) | ||
to-address (rf/sub [:wallet/wallet-send-to-address]) | ||
nav-current-screen-id (rf/sub [:view-id]) | ||
|
||
on-confirm (or default-on-confirm handle-on-confirm) | ||
crypto-decimals (or default-crypto-decimals | ||
|
@@ -115,20 +114,19 @@ | |
token | ||
token-balance)) | ||
fiat-limit (.toFixed (* token-balance conversion-rate) 2) | ||
current-limit #(if @crypto-currency? crypto-limit fiat-limit) | ||
routes-can-be-fetched? (and (= nav-current-screen-id current-screen-id) | ||
(not | ||
(or (empty? (controlled-input/input-value input-state)) | ||
(<= (controlled-input/numeric-value input-state) 0) | ||
(> (controlled-input/numeric-value input-state) | ||
(current-limit))))) | ||
current-limit (if @crypto-currency? crypto-limit fiat-limit) | ||
valid-input? (not (or (string/blank? (controlled-input/input-value | ||
input-state)) | ||
(<= (controlled-input/numeric-value input-state) 0) | ||
(> (controlled-input/numeric-value input-state) | ||
current-limit))) | ||
current-currency (if @crypto-currency? token-symbol fiat-currency) | ||
input-num-value (controlled-input/numeric-value input-state) | ||
confirm-disabled? (or (nil? route) | ||
(empty? route) | ||
(empty? (controlled-input/input-value input-state)) | ||
(string/blank? (controlled-input/input-value input-state)) | ||
(<= input-num-value 0) | ||
(> input-num-value (current-limit))) | ||
(> input-num-value current-limit)) | ||
amount-text (str (controlled-input/input-value input-state) | ||
" " | ||
token-symbol) | ||
|
@@ -167,8 +165,8 @@ | |
#(.remove app-keyboard-listener)))) | ||
(rn/use-effect | ||
(fn [] | ||
(set-input-state #(controlled-input/set-upper-limit % (current-limit)))) | ||
[@crypto-currency?]) | ||
(set-input-state #(controlled-input/set-upper-limit % current-limit))) | ||
[current-limit]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now limit updated correctly. |
||
[rn/view | ||
{:style style/screen | ||
:accessibility-label (str "container" | ||
|
@@ -185,16 +183,17 @@ | |
:error? (controlled-input/input-error input-state) | ||
:networks (seq token-networks) | ||
:title (i18n/label :t/send-limit | ||
{:limit (make-limit-label (current-limit) current-currency)}) | ||
{:limit (make-limit-label current-limit current-currency)}) | ||
:conversion conversion-rate | ||
:show-keyboard? false | ||
:value (controlled-input/input-value input-state) | ||
:on-swap #(reset! crypto-currency? %) | ||
:on-token-press show-select-asset-sheet}] | ||
[routes/view | ||
{:token token | ||
:input-value (controlled-input/input-value input-state) | ||
:routes-can-be-fetched? routes-can-be-fetched?}] | ||
{:token token | ||
:input-value (controlled-input/input-value input-state) | ||
:valid-input? valid-input? | ||
:current-screen-id current-screen-id}] | ||
(when (or loading-routes? (seq route)) | ||
[estimated-fees | ||
{:loading-suggested-routes? loading-routes? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,18 +202,20 @@ | |
:on-press-to-network on-press-to-network}])) | ||
|
||
(defn fetch-routes | ||
[amount routes-can-be-fetched? bounce-duration-ms] | ||
(if routes-can-be-fetched? | ||
[amount valid-input? bounce-duration-ms] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function was the cause of the problem. It was getting too generic condition Now in this function we rely only on input validity. And when the screen is wrong we dont't even call it. |
||
(if valid-input? | ||
(debounce/debounce-and-dispatch | ||
[:wallet/get-suggested-routes {:amount amount}] | ||
bounce-duration-ms) | ||
(rf/dispatch [:wallet/clean-suggested-routes]))) | ||
|
||
(defn view | ||
[{:keys [token theme input-value routes-can-be-fetched? | ||
on-press-to-network]}] | ||
[{:keys [token theme input-value valid-input? | ||
on-press-to-network current-screen-id]}] | ||
|
||
(let [token-symbol (:symbol token) | ||
nav-current-screen-id (rf/sub [:view-id]) | ||
active-screen? (= nav-current-screen-id current-screen-id) | ||
loading-suggested-routes? (rf/sub | ||
[:wallet/wallet-send-loading-suggested-routes?]) | ||
from-values-by-chain (rf/sub | ||
|
@@ -241,12 +243,12 @@ | |
(not-empty routes))] | ||
|
||
(rn/use-effect | ||
#(when (> (count affordable-networks) 0) | ||
(fetch-routes input-value routes-can-be-fetched? 2000)) | ||
[input-value routes-can-be-fetched?]) | ||
#(when (and active-screen? (> (count affordable-networks) 0)) | ||
(fetch-routes input-value valid-input? 2000)) | ||
[input-value valid-input?]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need to react to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, theoretically we can remove it because we know that input validity depends only on input value. But that is kind of knowledge that we have outside of the component. If for some reason the validity rule will change, not having valid-input? as a dependency can cause an error |
||
(rn/use-effect | ||
#(when (> (count affordable-networks) 0) | ||
(fetch-routes input-value routes-can-be-fetched? 0)) | ||
#(when (and active-screen? (> (count affordable-networks) 0)) | ||
(fetch-routes input-value valid-input? 0)) | ||
[disabled-from-chain-ids]) | ||
(if show-routes? | ||
(let [initial-network-links-count (count network-links) | ||
|
@@ -275,7 +277,7 @@ | |
{:from-values-by-chain from-values-by-chain | ||
:to-values-by-chain to-values-by-chain | ||
:theme theme | ||
:fetch-routes #(fetch-routes % routes-can-be-fetched? 2000) | ||
:fetch-routes #(fetch-routes % valid-input? 2000) | ||
:on-press-from-network (fn [chain-id _] | ||
(let [disabled-chain-ids (if (contains? (set | ||
disabled-from-chain-ids) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current limit is no longer a function because it don't need to be