Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
742df08899 | ||
|
|
23c2ddce34 | ||
|
|
8e5a21f2c2 |
@@ -6,9 +6,8 @@
|
||||
(merge
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:height 50
|
||||
:padding-horizontal 20
|
||||
:padding-vertical 12}
|
||||
:padding-vertical 16}
|
||||
container-style))
|
||||
|
||||
(def content-container
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
:padding-left 4
|
||||
:padding-right 10
|
||||
:flex-direction :row
|
||||
:flex-shrink 1
|
||||
:border-radius (if (#{:account :collectible} type) 10 16)
|
||||
:background-color (colors/resolve-color customization-color theme 10)})
|
||||
|
||||
(defn label
|
||||
[type theme]
|
||||
{:color (colors/theme-colors colors/neutral-100 colors/white theme)
|
||||
:flex-shrink 1
|
||||
:flex-grow 1
|
||||
:margin-left (if (= type :address) 6 4)})
|
||||
|
||||
(def collectible-image
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
[left-view props]
|
||||
[text/text
|
||||
{:style (style/label type theme)
|
||||
:ellipsize-mode :tail
|
||||
:weight :semi-bold
|
||||
:number-of-lines 1
|
||||
:size :heading-1}
|
||||
|
||||
@@ -509,9 +509,8 @@
|
||||
(def ^:const wallet-transaction-estimation
|
||||
{:unknown 0
|
||||
:less-than-one-minute 1
|
||||
:less-than-three-minutes 2
|
||||
:less-than-five-minutes 3
|
||||
:more-than-five-minutes 4})
|
||||
:less-than-three-minutes 3
|
||||
:less-than-five-minutes 5})
|
||||
|
||||
(def ^:const wallet-connect-transaction-refresh-interval-ms 10000)
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@
|
||||
:amount-out (:amount-out new-path)
|
||||
:approval-contract-address (:approval-contract-address new-path)
|
||||
:approval-required (:approval-required new-path)
|
||||
:estimated-time (:estimated-time new-path)
|
||||
:estimated-time (:tx-estimated-time new-path)
|
||||
:to (:to-chain new-path)
|
||||
:approval-amount-required (:approval-amount-required new-path)
|
||||
;; :cost () ;; tbd not used on desktop
|
||||
|
||||
@@ -31,68 +31,73 @@
|
||||
[:dispatch [:wallet/clean-suggested-routes]]]}))
|
||||
|
||||
(defn- add-not-enough-assets-data
|
||||
[send-data chosen-route]
|
||||
[send-data chosen-route to-network-amounts-by-chain]
|
||||
(-> send-data
|
||||
(assoc :route chosen-route
|
||||
:loading-suggested-routes? false
|
||||
:suggested-routes {:best []}
|
||||
:enough-assets? false)
|
||||
:enough-assets? false
|
||||
:to-values-by-chain to-network-amounts-by-chain)
|
||||
(update :sender-network-values send-utils/reset-loading-network-amounts-to-zero)
|
||||
(update :receiver-network-values send-utils/reset-loading-network-amounts-to-zero)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/suggested-routes-success
|
||||
(fn [{:keys [db]} [suggested-routes-data enough-assets?]]
|
||||
(if-not enough-assets?
|
||||
{:db (update-in db [:wallet :ui :send] add-not-enough-assets-data (:best suggested-routes-data))}
|
||||
(let [chosen-route (:best suggested-routes-data)
|
||||
{:keys [token collectible token-display-name
|
||||
receiver-network-values
|
||||
sender-network-values tx-type]} (get-in db [:wallet :ui :send])
|
||||
token-decimals (if collectible 0 (:decimals token))
|
||||
native-token? (and token (= token-display-name "ETH"))
|
||||
routes-available? (pos? (count chosen-route))
|
||||
from-network-amounts-by-chain (send-utils/network-amounts-by-chain
|
||||
{:route chosen-route
|
||||
:token-decimals token-decimals
|
||||
:native-token? native-token?
|
||||
:receiver? false})
|
||||
to-network-amounts-by-chain (send-utils/network-amounts-by-chain
|
||||
{:route chosen-route
|
||||
:token-decimals token-decimals
|
||||
:native-token? native-token?
|
||||
:receiver? true})
|
||||
sender-possible-chain-ids (map :chain-id sender-network-values)
|
||||
sender-network-values (if routes-available?
|
||||
(send-utils/network-amounts
|
||||
(if (= tx-type :tx/bridge)
|
||||
from-network-amounts-by-chain
|
||||
(send-utils/add-zero-values-to-network-values
|
||||
from-network-amounts-by-chain
|
||||
sender-possible-chain-ids)))
|
||||
(send-utils/reset-loading-network-amounts-to-zero
|
||||
sender-network-values))
|
||||
receiver-network-values (if routes-available?
|
||||
(send-utils/network-amounts
|
||||
to-network-amounts-by-chain)
|
||||
(send-utils/reset-loading-network-amounts-to-zero
|
||||
receiver-network-values))
|
||||
network-links (when routes-available?
|
||||
(send-utils/network-links chosen-route
|
||||
sender-network-values
|
||||
receiver-network-values))]
|
||||
(let [chosen-route (:best suggested-routes-data)
|
||||
{:keys [token collectible token-display-name
|
||||
receiver-network-values
|
||||
sender-network-values tx-type]} (get-in db [:wallet :ui :send])
|
||||
token-decimals (if collectible 0 (:decimals token))
|
||||
native-token? (and token (= token-display-name "ETH"))
|
||||
to-network-amounts-by-chain (send-utils/network-amounts-by-chain
|
||||
{:route chosen-route
|
||||
:token-decimals token-decimals
|
||||
:native-token? native-token?
|
||||
:receiver? true})]
|
||||
(if-not enough-assets?
|
||||
{:db (update-in db
|
||||
[:wallet :ui :send]
|
||||
assoc
|
||||
:suggested-routes suggested-routes-data
|
||||
:route chosen-route
|
||||
:from-values-by-chain from-network-amounts-by-chain
|
||||
:to-values-by-chain to-network-amounts-by-chain
|
||||
:sender-network-values sender-network-values
|
||||
:receiver-network-values receiver-network-values
|
||||
:network-links network-links
|
||||
:loading-suggested-routes? false
|
||||
:enough-assets? true)}))))
|
||||
add-not-enough-assets-data
|
||||
chosen-route
|
||||
to-network-amounts-by-chain)}
|
||||
(let [routes-available? (pos? (count chosen-route))
|
||||
from-network-amounts-by-chain (send-utils/network-amounts-by-chain
|
||||
{:route chosen-route
|
||||
:token-decimals token-decimals
|
||||
:native-token? native-token?
|
||||
:receiver? false})
|
||||
sender-possible-chain-ids (map :chain-id sender-network-values)
|
||||
sender-network-values (if routes-available?
|
||||
(send-utils/network-amounts
|
||||
(if (= tx-type :tx/bridge)
|
||||
from-network-amounts-by-chain
|
||||
(send-utils/add-zero-values-to-network-values
|
||||
from-network-amounts-by-chain
|
||||
sender-possible-chain-ids)))
|
||||
(send-utils/reset-loading-network-amounts-to-zero
|
||||
sender-network-values))
|
||||
receiver-network-values (if routes-available?
|
||||
(send-utils/network-amounts
|
||||
to-network-amounts-by-chain)
|
||||
(send-utils/reset-loading-network-amounts-to-zero
|
||||
receiver-network-values))
|
||||
network-links (when routes-available?
|
||||
(send-utils/network-links chosen-route
|
||||
sender-network-values
|
||||
receiver-network-values))]
|
||||
{:db (update-in db
|
||||
[:wallet :ui :send]
|
||||
assoc
|
||||
:suggested-routes suggested-routes-data
|
||||
:route chosen-route
|
||||
:from-values-by-chain from-network-amounts-by-chain
|
||||
:to-values-by-chain to-network-amounts-by-chain
|
||||
:sender-network-values sender-network-values
|
||||
:receiver-network-values receiver-network-values
|
||||
:network-links network-links
|
||||
:loading-suggested-routes? false
|
||||
:enough-assets? true)})))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/suggested-routes-error
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
@@ -13,6 +14,7 @@
|
||||
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
|
||||
[status-im.contexts.wallet.send.transaction-settings.view :as transaction-settings]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||
[status-im.feature-flags :as ff]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
@@ -171,56 +173,80 @@
|
||||
:network-props network}]])))
|
||||
|
||||
(defn- data-item
|
||||
[{:keys [title subtitle]}]
|
||||
[{:keys [title subtitle subtitle-color loading?]}]
|
||||
[quo/data-item
|
||||
{:container-style style/detail-item
|
||||
:blur? false
|
||||
:card? false
|
||||
:status :default
|
||||
:status (if loading? :loading :default)
|
||||
:size :small
|
||||
:title title
|
||||
:subtitle subtitle}])
|
||||
:subtitle subtitle
|
||||
:subtitle-color subtitle-color}])
|
||||
|
||||
(defn- error-banner
|
||||
[]
|
||||
(let [enough-assets? (rf/sub [:wallet/send-enough-assets?])
|
||||
no-routes-found? (rf/sub [:wallet/no-routes-found?])]
|
||||
(cond
|
||||
no-routes-found?
|
||||
[quo/alert-banner
|
||||
{:text (i18n/label :t/no-routes-found-confirmation)
|
||||
:text-number-of-lines 2}]
|
||||
|
||||
(not enough-assets?)
|
||||
[quo/alert-banner
|
||||
{:action? true
|
||||
:text (i18n/label :t/not-enough-assets-to-pay-gas-fees)
|
||||
:button-text (i18n/label :t/add-eth)
|
||||
:on-button-press #(rf/dispatch [:show-bottom-sheet
|
||||
{:content buy-token/view}])}]
|
||||
|
||||
:else nil)))
|
||||
(defn- transaction-details
|
||||
[{:keys [estimated-time-min max-fees to-network
|
||||
transaction-type route-loaded?]}]
|
||||
(let [loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||
(let [theme (quo.theme/use-theme)
|
||||
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||
enough-assets? (rf/sub [:wallet/send-enough-assets?])
|
||||
no-routes-found? (rf/sub [:wallet/no-routes-found?])
|
||||
loading? (or loading-suggested-routes? no-routes-found?)
|
||||
amount (rf/sub [:wallet/send-total-amount-formatted])]
|
||||
[rn/view
|
||||
{:style (style/details-container
|
||||
{:loading-suggested-routes? loading-suggested-routes?
|
||||
:route-loaded? route-loaded?})}
|
||||
(cond
|
||||
loading-suggested-routes?
|
||||
[rn/activity-indicator {:style {:flex 1}}]
|
||||
route-loaded?
|
||||
[:<>
|
||||
[quo/button
|
||||
{:icon-only? true
|
||||
:type :outline
|
||||
:size 32
|
||||
:inner-style {:opacity 1}
|
||||
:accessibility-label :advanced-button
|
||||
:container-style {:margin-right 8}
|
||||
:on-press #(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content transaction-settings/settings-sheet}])}
|
||||
:i/advanced]
|
||||
[data-item
|
||||
{:title (i18n/label :t/est-time)
|
||||
:subtitle (i18n/label :t/time-in-mins {:minutes (str estimated-time-min)})}]
|
||||
[data-item
|
||||
{:title (i18n/label :t/max-fees)
|
||||
:subtitle max-fees}]
|
||||
[data-item
|
||||
{:title (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/bridged-to
|
||||
{:network (:abbreviated-name to-network)})
|
||||
(i18n/label :t/recipient-gets))
|
||||
:subtitle amount}]]
|
||||
:else
|
||||
[quo/text {:style {:align-self :center}}
|
||||
(i18n/label :t/no-routes-found-confirmation)])]))
|
||||
[quo/button
|
||||
{:icon-only? true
|
||||
:type :outline
|
||||
:size 32
|
||||
:inner-style {:opacity 1}
|
||||
:accessibility-label :advanced-button
|
||||
:container-style {:margin-right 8}
|
||||
:on-press #(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content transaction-settings/settings-sheet}])}
|
||||
:i/advanced]
|
||||
[data-item
|
||||
{:title (i18n/label :t/est-time)
|
||||
:loading? loading?
|
||||
:subtitle (i18n/label :t/time-in-mins
|
||||
{:minutes (utils/estimated-time-format estimated-time-min)})}]
|
||||
[data-item
|
||||
{:title (i18n/label :t/max-fees)
|
||||
:loading? loading?
|
||||
:subtitle max-fees
|
||||
:subtitle-color (when-not enough-assets?
|
||||
(colors/theme-colors colors/danger-50
|
||||
colors/danger-60
|
||||
theme))}]
|
||||
[data-item
|
||||
{:title (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/bridged-to
|
||||
{:network (:abbreviated-name to-network)})
|
||||
(i18n/label :t/recipient-gets))
|
||||
:loading? loading?
|
||||
:subtitle amount}]]))
|
||||
|
||||
(defn view
|
||||
[_]
|
||||
@@ -256,6 +282,8 @@
|
||||
user-props {:full-name to-address
|
||||
:address (utils/get-shortened-address
|
||||
to-address)}
|
||||
enough-assets? (rf/sub [:wallet/send-enough-assets?])
|
||||
no-routes-found? (rf/sub [:wallet/no-routes-found?])
|
||||
biometric-auth? (= (rf/sub [:auth-method]) constants/auth-method-biometric)
|
||||
biometric-type (rf/sub [:biometrics/supported-type])]
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-route-data-for-collectible-tx]))
|
||||
@@ -272,28 +300,33 @@
|
||||
:margin-top (safe-area/get-top)
|
||||
:background :blur
|
||||
:accessibility-label :top-bar}]
|
||||
:footer [:<>
|
||||
[transaction-details
|
||||
{:estimated-time-min estimated-time-min
|
||||
:max-fees fee-formatted
|
||||
:to-network bridge-to-network
|
||||
:theme theme
|
||||
:route route
|
||||
:transaction-type transaction-type
|
||||
:route-loaded? (and route (seq route))}]
|
||||
(when (and (not loading-suggested-routes?) route (seq route))
|
||||
[quo/slide-button
|
||||
{:size :size-48
|
||||
:track-text (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/slide-to-bridge)
|
||||
(i18n/label :t/slide-to-send))
|
||||
:container-style {:z-index 2}
|
||||
:customization-color account-color
|
||||
:track-icon (if biometric-auth?
|
||||
(biometric/get-icon-by-type biometric-type)
|
||||
:password)
|
||||
:on-complete #(rf/dispatch
|
||||
[:wallet.send/auth-slider-completed])}])]
|
||||
:blur-options {:padding-horizontal 0}
|
||||
:footer [rn/view
|
||||
[error-banner]
|
||||
[rn/view {:style {:padding-horizontal 20}}
|
||||
[transaction-details
|
||||
{:estimated-time-min estimated-time-min
|
||||
:max-fees fee-formatted
|
||||
:to-network bridge-to-network
|
||||
:theme theme
|
||||
:route route
|
||||
:transaction-type transaction-type
|
||||
:route-loaded? (and route (seq route))}]
|
||||
[quo/slide-button
|
||||
{:size :size-48
|
||||
:track-text (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/slide-to-bridge)
|
||||
(i18n/label :t/slide-to-send))
|
||||
:container-style {:z-index 2}
|
||||
:disabled? (or (not enough-assets?)
|
||||
loading-suggested-routes?
|
||||
no-routes-found?)
|
||||
:customization-color account-color
|
||||
:track-icon (if biometric-auth?
|
||||
(biometric/get-icon-by-type biometric-type)
|
||||
:password)
|
||||
:on-complete #(rf/dispatch
|
||||
[:wallet.send/auth-slider-completed])}]]]
|
||||
:gradient-cover? true
|
||||
:customization-color (:color account)}
|
||||
[rn/view
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
(when estimated-time
|
||||
[data-item
|
||||
{:title (i18n/label :t/est-time)
|
||||
:subtitle (i18n/label :t/time-in-mins {:minutes (str estimated-time)})
|
||||
:subtitle (i18n/label :t/time-in-mins {:minutes (utils/estimated-time-format estimated-time)})
|
||||
:loading? loading-swap-proposal?}])
|
||||
[data-item
|
||||
{:title (i18n/label :t/max-fees)
|
||||
|
||||
@@ -242,3 +242,16 @@
|
||||
:<- [:wallet/tx-settings-fee-mode-user]
|
||||
(fn [[route value-set-by-user]]
|
||||
(or value-set-by-user (:tx-fee-mode (first route)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/send-enough-assets?
|
||||
:<- [:wallet/wallet-send]
|
||||
(fn [{:keys [enough-assets?]}]
|
||||
(if (nil? enough-assets?) true enough-assets?)))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/no-routes-found?
|
||||
:<- [:wallet/wallet-send-loading-suggested-routes?]
|
||||
:<- [:wallet/send-route]
|
||||
(fn [[loading? route]]
|
||||
(and (empty? route) (not loading?))))
|
||||
|
||||
Reference in New Issue
Block a user