fix(wallet): inverted values of receiver and sender when displaying bridging routes (#20893)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
7c6f2bf878
commit
745e5d75fb
|
@ -100,7 +100,8 @@
|
||||||
:wallet/wallet-send-enabled-from-chain-ids [1]
|
:wallet/wallet-send-enabled-from-chain-ids [1]
|
||||||
:wallet/wallet-send-amount nil
|
:wallet/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/total-amount (money/bignumber "250")})
|
||||||
|
|
||||||
(h/describe "Send > input amount screen"
|
(h/describe "Send > input amount screen"
|
||||||
(h/setup-restorable-re-frame)
|
(h/setup-restorable-re-frame)
|
||||||
|
|
|
@ -221,9 +221,9 @@
|
||||||
(number/remove-trailing-zeroes
|
(number/remove-trailing-zeroes
|
||||||
(.toFixed (/ input-amount conversion-rate)
|
(.toFixed (/ input-amount conversion-rate)
|
||||||
crypto-decimals)))
|
crypto-decimals)))
|
||||||
send-amount (rf/sub [:wallet/wallet-send-amount])
|
total-amount-receiver (rf/sub [:wallet/total-amount true])
|
||||||
amount-text (str (number/remove-trailing-zeroes
|
amount-text (str (number/remove-trailing-zeroes
|
||||||
(.toFixed (js/parseFloat send-amount)
|
(.toFixed total-amount-receiver
|
||||||
(min token-decimals 6)))
|
(min token-decimals 6)))
|
||||||
" "
|
" "
|
||||||
token-symbol)
|
token-symbol)
|
||||||
|
|
|
@ -225,6 +225,7 @@
|
||||||
bridge-to-chain-id]))
|
bridge-to-chain-id]))
|
||||||
loading-suggested-routes? (rf/sub
|
loading-suggested-routes? (rf/sub
|
||||||
[:wallet/wallet-send-loading-suggested-routes?])
|
[:wallet/wallet-send-loading-suggested-routes?])
|
||||||
|
total-amount-receiver (rf/sub [:wallet/total-amount true])
|
||||||
from-account-props {:customization-color account-color
|
from-account-props {:customization-color account-color
|
||||||
:size 32
|
:size 32
|
||||||
:emoji (:emoji account)
|
:emoji (:emoji account)
|
||||||
|
@ -249,8 +250,8 @@
|
||||||
[transaction-details
|
[transaction-details
|
||||||
{:estimated-time-min estimated-time-min
|
{:estimated-time-min estimated-time-min
|
||||||
:max-fees fee-formatted
|
:max-fees fee-formatted
|
||||||
:token-display-name token-display-name
|
:token-display-name token-symbol
|
||||||
:amount amount
|
:amount total-amount-receiver
|
||||||
:to-network bridge-to-network
|
:to-network bridge-to-network
|
||||||
:theme theme
|
:theme theme
|
||||||
:route route
|
:route route
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
[{:keys [route token-decimals native-token? receiver?]}]
|
[{:keys [route token-decimals native-token? receiver?]}]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc path]
|
(fn [acc path]
|
||||||
(let [amount-hex (if receiver? (:amount-in path) (:amount-out path))
|
(let [amount-hex (if receiver? (:amount-out path) (:amount-in path))
|
||||||
amount-units (native-module/hex-to-number
|
amount-units (native-module/hex-to-number
|
||||||
(utils.hex/normalize-hex amount-hex))
|
(utils.hex/normalize-hex amount-hex))
|
||||||
amount (money/with-precision
|
amount (money/with-precision
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
|
|
||||||
(deftest network-amounts-by-chain-test
|
(deftest network-amounts-by-chain-test
|
||||||
(testing "Correctly calculates network amounts for transaction with native token"
|
(testing "Correctly calculates network amounts for transaction with native token"
|
||||||
(let [route [{:amount-in "0xde0b6b3a7640000"
|
(let [route [{:amount-out "0xde0b6b3a7640000"
|
||||||
:to {:chain-id 1}}
|
:to {:chain-id 1}}
|
||||||
{:amount-in "0xde0b6b3a7640000"
|
{:amount-out "0xde0b6b3a7640000"
|
||||||
:to {:chain-id 10}}]
|
:to {:chain-id 10}}]
|
||||||
token-decimals 18
|
token-decimals 18
|
||||||
native-token? true
|
native-token? true
|
||||||
receiver? true
|
receiver? true
|
||||||
|
@ -50,10 +50,10 @@
|
||||||
|
|
||||||
(testing
|
(testing
|
||||||
"Correctly calculates network amounts for transaction with native token and multiple routes to same chain-id"
|
"Correctly calculates network amounts for transaction with native token and multiple routes to same chain-id"
|
||||||
(let [route [{:amount-in "0xde0b6b3a7640000"
|
(let [route [{:amount-out "0xde0b6b3a7640000"
|
||||||
:to {:chain-id 1}}
|
:to {:chain-id 1}}
|
||||||
{:amount-in "0xde0b6b3a7640000"
|
{:amount-out "0xde0b6b3a7640000"
|
||||||
:to {:chain-id 1}}]
|
:to {:chain-id 1}}]
|
||||||
token-decimals 18
|
token-decimals 18
|
||||||
native-token? true
|
native-token? true
|
||||||
receiver? true
|
receiver? true
|
||||||
|
@ -66,10 +66,10 @@
|
||||||
(is (money/equal-to (get result chain-id) exp-value)))))
|
(is (money/equal-to (get result chain-id) exp-value)))))
|
||||||
|
|
||||||
(testing "Correctly calculates network amounts for transaction with non-native token"
|
(testing "Correctly calculates network amounts for transaction with non-native token"
|
||||||
(let [route [{:amount-out "0x1e8480"
|
(let [route [{:amount-in "0x1e8480"
|
||||||
:from {:chain-id 1}}
|
:from {:chain-id 1}}
|
||||||
{:amount-out "0x1e8480"
|
{:amount-in "0x1e8480"
|
||||||
:from {:chain-id 10}}]
|
:from {:chain-id 10}}]
|
||||||
token-decimals 6
|
token-decimals 6
|
||||||
native-token? false
|
native-token? false
|
||||||
receiver? false
|
receiver? false
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns status-im.subs.wallet.networks
|
(ns status-im.subs.wallet.networks
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]))
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
|
[utils.money :as money]))
|
||||||
|
|
||||||
(def max-network-prefixes 2)
|
(def max-network-prefixes 2)
|
||||||
|
|
||||||
|
@ -80,3 +81,16 @@
|
||||||
{:amount amount :token-symbol token-symbol})))
|
{:amount amount :token-symbol token-symbol})))
|
||||||
{}
|
{}
|
||||||
network-values))))
|
network-values))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:wallet/total-amount
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
(fn [{:keys [from-values-by-chain to-values-by-chain]} [_ to-values?]]
|
||||||
|
(let [network-values (if to-values? to-values-by-chain from-values-by-chain)]
|
||||||
|
(reduce
|
||||||
|
(fn [acc amount]
|
||||||
|
(if (money/bignumber? amount)
|
||||||
|
(money/add acc amount)
|
||||||
|
acc))
|
||||||
|
(money/bignumber 0)
|
||||||
|
(vals network-values)))))
|
||||||
|
|
Loading…
Reference in New Issue