mirror of
https://github.com/status-im/status-react.git
synced 2025-02-25 17:16:03 +00:00
feat: update transaction confirmation page to support bridging transactions (#18887)
This commit is contained in:
parent
0e9847f2c3
commit
7d55c98e0a
@ -30,8 +30,8 @@
|
|||||||
(defn networks
|
(defn networks
|
||||||
[values theme]
|
[values theme]
|
||||||
(let [{:keys [ethereum optimism arbitrum]} values
|
(let [{:keys [ethereum optimism arbitrum]} values
|
||||||
show-optimism? (pos? optimism)
|
show-optimism? (and optimism (pos? (:amount optimism)))
|
||||||
show-arbitrum? (pos? arbitrum)]
|
show-arbitrum? (and arbitrum (pos? (:amount arbitrum)))]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style style/networks-container
|
{:style style/networks-container
|
||||||
:accessibility-label :networks}
|
:accessibility-label :networks}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
(def ^:private networks
|
(def ^:private networks
|
||||||
{:arbitrum (js/require "../resources/images/networks/Arbitrum.png")
|
{:arbitrum (js/require "../resources/images/networks/Arbitrum.png")
|
||||||
:ethereum (js/require "../resources/images/networks/Ethereum.png")
|
:ethereum (js/require "../resources/images/networks/Ethereum.png")
|
||||||
|
:mainnet (js/require "../resources/images/networks/Ethereum.png")
|
||||||
:gnosis (js/require "../resources/images/networks/Gnosis.png")
|
:gnosis (js/require "../resources/images/networks/Gnosis.png")
|
||||||
:hermez (js/require "../resources/images/networks/Hermez.png")
|
:hermez (js/require "../resources/images/networks/Hermez.png")
|
||||||
:optimism (js/require "../resources/images/networks/Optimism.png")
|
:optimism (js/require "../resources/images/networks/Optimism.png")
|
||||||
|
@ -429,7 +429,11 @@
|
|||||||
(def ^:const optimism-short-name "opt")
|
(def ^:const optimism-short-name "opt")
|
||||||
(def ^:const arbitrum-short-name "arb1")
|
(def ^:const arbitrum-short-name "arb1")
|
||||||
|
|
||||||
(def ^:const mainnet-network-name :ethereum)
|
(def ^:const mainnet-abbreviated-name "Eth.")
|
||||||
|
(def ^:const optimism-abbreviated-name "Opt.")
|
||||||
|
(def ^:const arbitrum-abbreviated-name "Arb1.")
|
||||||
|
|
||||||
|
(def ^:const mainnet-network-name :mainnet)
|
||||||
(def ^:const optimism-network-name :optimism)
|
(def ^:const optimism-network-name :optimism)
|
||||||
(def ^:const arbitrum-network-name :arbitrum)
|
(def ^:const arbitrum-network-name :arbitrum)
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
[]
|
[]
|
||||||
[rn/view {:style style/bridge-send-wrapper}
|
[rn/view {:style style/bridge-send-wrapper}
|
||||||
[input-amount/view
|
[input-amount/view
|
||||||
{:button-one-label (i18n/label :t/confirm-bridge)
|
{:current-screen-id :wallet-bridge-send
|
||||||
|
:button-one-label (i18n/label :t/confirm-bridge)
|
||||||
:button-one-props {:icon-left :i/bridge}
|
:button-one-props {:icon-left :i/bridge}
|
||||||
:on-navigate-back (fn []
|
:on-navigate-back (fn []
|
||||||
(rf/dispatch [:navigate-back-within-stack :wallet-bridge-send]))}]])
|
(rf/dispatch [:navigate-back-within-stack :wallet-bridge-send]))}]])
|
||||||
|
@ -16,3 +16,7 @@
|
|||||||
(let [gas-price (money/bignumber (get gas-fees :gas-price))
|
(let [gas-price (money/bignumber (get gas-fees :gas-price))
|
||||||
total-gas-fee (money/mul gas-amount gas-price)]
|
total-gas-fee (money/mul gas-amount gas-price)]
|
||||||
(money/with-precision (money/div total-gas-fee billion) 10)))))
|
(money/with-precision (money/div total-gas-fee billion) 10)))))
|
||||||
|
|
||||||
|
(defn calculate-full-route-gas-fee
|
||||||
|
[route]
|
||||||
|
(reduce money/add (map calculate-gas-fee route)))
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
(fn [{:keys [db]} [suggested-routes timestamp]]
|
(fn [{:keys [db]} [suggested-routes timestamp]]
|
||||||
(when (= (get-in db [:wallet :ui :send :suggested-routes-call-timestamp]) timestamp)
|
(when (= (get-in db [:wallet :ui :send :suggested-routes-call-timestamp]) timestamp)
|
||||||
(let [suggested-routes-data (cske/transform-keys csk/->kebab-case suggested-routes)
|
(let [suggested-routes-data (cske/transform-keys csk/->kebab-case suggested-routes)
|
||||||
chosen-route (->> suggested-routes-data
|
chosen-route (:best suggested-routes-data)]
|
||||||
:best
|
|
||||||
first)]
|
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:wallet :ui :send :suggested-routes] suggested-routes-data)
|
(assoc-in [:wallet :ui :send :suggested-routes] suggested-routes-data)
|
||||||
(assoc-in [:wallet :ui :send :route] chosen-route)
|
(assoc-in [:wallet :ui :send :route] chosen-route)
|
||||||
@ -99,7 +97,17 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx :wallet/clean-selected-token
|
(rf/reg-event-fx :wallet/clean-selected-token
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
{:db (assoc-in db [:wallet :ui :send :token] nil)}))
|
{:db (update-in db [:wallet :ui :send] dissoc :token :type)}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :wallet/clean-selected-collectible
|
||||||
|
(fn [{:keys [db]}]
|
||||||
|
(let [type (get-in db [:wallet :ui :send :type])]
|
||||||
|
{:db (update-in db
|
||||||
|
[:wallet :ui :send]
|
||||||
|
dissoc
|
||||||
|
:collectible
|
||||||
|
:amount
|
||||||
|
(when (= type :collecible) :type))})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/send-select-collectible
|
(rf/reg-event-fx :wallet/send-select-collectible
|
||||||
(fn [{:keys [db]} [{:keys [collectible stack-id]}]]
|
(fn [{:keys [db]} [{:keys [collectible stack-id]}]]
|
||||||
@ -244,7 +252,7 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx :wallet/send-transaction
|
(rf/reg-event-fx :wallet/send-transaction
|
||||||
(fn [{:keys [db]} [sha3-pwd]]
|
(fn [{:keys [db]} [sha3-pwd]]
|
||||||
(let [route (get-in db [:wallet :ui :send :route])
|
(let [route (first (get-in db [:wallet :ui :send :route]))
|
||||||
from-address (get-in db [:wallet :current-viewing-account-address])
|
from-address (get-in db [:wallet :current-viewing-account-address])
|
||||||
token (get-in db [:wallet :ui :send :token])
|
token (get-in db [:wallet :ui :send :token])
|
||||||
collectible (get-in db [:wallet :ui :send :collectible])
|
collectible (get-in db [:wallet :ui :send :collectible])
|
||||||
|
@ -43,14 +43,14 @@
|
|||||||
:total-balance 100
|
:total-balance 100
|
||||||
:market-values-per-currency {:usd {:price 10}}}
|
:market-values-per-currency {:usd {:price 10}}}
|
||||||
:wallet/wallet-send-loading-suggested-routes? false
|
:wallet/wallet-send-loading-suggested-routes? false
|
||||||
:wallet/wallet-send-route {:from {:chainid 1
|
:wallet/wallet-send-route [{:from {:chainid 1
|
||||||
:native-currency-symbol "ETH"}
|
:native-currency-symbol "ETH"}
|
||||||
:to {:chain-id 1
|
:to {:chain-id 1
|
||||||
:native-currency-symbol "ETH"}
|
:native-currency-symbol "ETH"}
|
||||||
:gas-amount "23487"
|
:gas-amount "23487"
|
||||||
:gas-fees {:base-fee "32.325296406"
|
:gas-fees {:base-fee "32.325296406"
|
||||||
:max-priority-fee-per-gas "0.011000001"
|
:max-priority-fee-per-gas "0.011000001"
|
||||||
:eip1559-enabled true}}
|
:eip1559-enabled true}}]
|
||||||
:wallet/wallet-send-suggested-routes {:candidates []}
|
:wallet/wallet-send-suggested-routes {:candidates []}
|
||||||
:wallet/wallet-send-selected-networks []
|
:wallet/wallet-send-selected-networks []
|
||||||
:navigation/current-screen-id :wallet-send-input-amount
|
:navigation/current-screen-id :wallet-send-input-amount
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
on-navigate-back :on-navigate-back
|
on-navigate-back :on-navigate-back
|
||||||
button-one-label :button-one-label
|
button-one-label :button-one-label
|
||||||
button-one-props :button-one-props
|
button-one-props :button-one-props
|
||||||
|
current-screen-id :current-screen-id
|
||||||
initial-crypto-currency? :initial-crypto-currency?
|
initial-crypto-currency? :initial-crypto-currency?
|
||||||
:or {initial-crypto-currency? true}}]
|
:or {initial-crypto-currency? true}}]
|
||||||
(let [_ (rn/dismiss-keyboard!)
|
(let [_ (rn/dismiss-keyboard!)
|
||||||
@ -172,11 +173,11 @@
|
|||||||
(reagent/flush))))
|
(reagent/flush))))
|
||||||
on-navigate-back on-navigate-back
|
on-navigate-back on-navigate-back
|
||||||
fetch-routes (fn [input-num-value current-limit-amount]
|
fetch-routes (fn [input-num-value current-limit-amount]
|
||||||
(let [current-screen-id (rf/sub [:navigation/current-screen-id])]
|
(let [nav-current-screen-id (rf/sub [:navigation/current-screen-id])]
|
||||||
; this check is to prevent effect being triggered when screen is
|
; this check is to prevent effect being triggered when screen is
|
||||||
; loaded but not being shown to the user (deep in the navigation
|
; loaded but not being shown to the user (deep in the navigation
|
||||||
; stack) and avoid undesired behaviors
|
; stack) and avoid undesired behaviors
|
||||||
(when (= current-screen-id :wallet-send-input-amount)
|
(when (= nav-current-screen-id current-screen-id)
|
||||||
(if-not (or (empty? @input-value)
|
(if-not (or (empty? @input-value)
|
||||||
(<= input-num-value 0)
|
(<= input-num-value 0)
|
||||||
(> input-num-value current-limit-amount))
|
(> input-num-value current-limit-amount))
|
||||||
@ -187,7 +188,7 @@
|
|||||||
handle-on-confirm (fn []
|
handle-on-confirm (fn []
|
||||||
(rf/dispatch [:wallet/send-select-amount
|
(rf/dispatch [:wallet/send-select-amount
|
||||||
{:amount @input-value
|
{:amount @input-value
|
||||||
:stack-id :wallet-send-input-amount}]))
|
:stack-id current-screen-id}]))
|
||||||
selection-change (fn [selection]
|
selection-change (fn [selection]
|
||||||
;; `reagent/flush` is needed to properly propagate the
|
;; `reagent/flush` is needed to properly propagate the
|
||||||
;; input cursor state. Since this is a controlled
|
;; input cursor state. Since this is a controlled
|
||||||
@ -218,6 +219,7 @@
|
|||||||
:currency current-currency})
|
:currency current-currency})
|
||||||
input-num-value (parse-double @input-value)
|
input-num-value (parse-double @input-value)
|
||||||
confirm-disabled? (or (nil? route)
|
confirm-disabled? (or (nil? route)
|
||||||
|
(empty? route)
|
||||||
(empty? @input-value)
|
(empty? @input-value)
|
||||||
(<= input-num-value 0)
|
(<= input-num-value 0)
|
||||||
(> input-num-value current-limit))
|
(> input-num-value current-limit))
|
||||||
@ -226,7 +228,8 @@
|
|||||||
(get-in route [:from :native-currency-symbol]))
|
(get-in route [:from :native-currency-symbol]))
|
||||||
native-token (when native-currency-symbol
|
native-token (when native-currency-symbol
|
||||||
(rf/sub [:wallet/token-by-symbol native-currency-symbol]))
|
(rf/sub [:wallet/token-by-symbol native-currency-symbol]))
|
||||||
fee-in-native-token (when-not confirm-disabled? (send-utils/calculate-gas-fee route))
|
fee-in-native-token (when-not confirm-disabled?
|
||||||
|
(send-utils/calculate-full-route-gas-fee route))
|
||||||
fee-in-crypto-formatted (when fee-in-native-token
|
fee-in-crypto-formatted (when fee-in-native-token
|
||||||
(utils/get-standard-crypto-format native-token
|
(utils/get-standard-crypto-format native-token
|
||||||
fee-in-native-token))
|
fee-in-native-token))
|
||||||
@ -280,7 +283,7 @@
|
|||||||
:token token
|
:token token
|
||||||
:input-value @input-value
|
:input-value @input-value
|
||||||
:fetch-routes #(fetch-routes % current-limit)}]
|
:fetch-routes #(fetch-routes % current-limit)}]
|
||||||
(when (or loading-routes? route)
|
(when (or loading-routes? (seq route))
|
||||||
[estimated-fees
|
[estimated-fees
|
||||||
{:loading-suggested-routes? loading-routes?
|
{:loading-suggested-routes? loading-routes?
|
||||||
:fees fee-formatted
|
:fees fee-formatted
|
||||||
|
@ -131,6 +131,7 @@
|
|||||||
(rf/dispatch [:wallet/clean-scanned-address])
|
(rf/dispatch [:wallet/clean-scanned-address])
|
||||||
(rf/dispatch [:wallet/clean-local-suggestions])
|
(rf/dispatch [:wallet/clean-local-suggestions])
|
||||||
(rf/dispatch [:wallet/clean-selected-token])
|
(rf/dispatch [:wallet/clean-selected-token])
|
||||||
|
(rf/dispatch [:wallet/clean-selected-collectible])
|
||||||
(rf/dispatch [:wallet/clean-send-address])
|
(rf/dispatch [:wallet/clean-send-address])
|
||||||
(rf/dispatch [:wallet/select-address-tab nil])
|
(rf/dispatch [:wallet/select-address-tab nil])
|
||||||
(rf/dispatch [:navigate-back]))
|
(rf/dispatch [:navigate-back]))
|
||||||
|
@ -8,9 +8,11 @@
|
|||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
[]
|
[]
|
||||||
[input-amount/view
|
[input-amount/view
|
||||||
{:button-one-label (i18n/label :t/confirm)
|
{:current-screen-id :wallet-send-input-amount
|
||||||
|
:button-one-label (i18n/label :t/confirm)
|
||||||
:on-navigate-back (fn []
|
:on-navigate-back (fn []
|
||||||
(rf/dispatch [:wallet/clean-selected-token])
|
(rf/dispatch [:wallet/clean-selected-token])
|
||||||
|
(rf/dispatch [:wallet/clean-selected-collectible])
|
||||||
(rf/dispatch [:navigate-back-within-stack :wallet-send-input-amount]))}])
|
(rf/dispatch [:navigate-back-within-stack :wallet-send-input-amount]))}])
|
||||||
|
|
||||||
(def view (quo.theme/with-theme view-internal))
|
(def view (quo.theme/with-theme view-internal))
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
(ns status-im.contexts.wallet.send.transaction-confirmation.view
|
(ns status-im.contexts.wallet.send.transaction-confirmation.view
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
|
[legacy.status-im.utils.hex :as utils.hex]
|
||||||
[legacy.status-im.utils.utils :as utils]
|
[legacy.status-im.utils.utils :as utils]
|
||||||
|
[native-module.core :as native-module]
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.theme :as quo.theme]
|
[quo.theme :as quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
@ -10,11 +12,15 @@
|
|||||||
[status-im.common.standard-authentication.core :as standard-auth]
|
[status-im.common.standard-authentication.core :as standard-auth]
|
||||||
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
|
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
[utils.money :as money]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.security.core :as security]))
|
[utils.security.core :as security]))
|
||||||
|
|
||||||
(defn- transaction-title
|
(defn- transaction-title
|
||||||
[{:keys [token-symbol amount account to-address image-url collectible?]}]
|
[{:keys [token-symbol amount account to-address route to-network image-url transaction-type
|
||||||
|
collectible?]}]
|
||||||
|
(let [to-network-name (:network-name to-network)
|
||||||
|
to-network-color (if (= to-network-name :mainnet) :ethereum to-network-name)]
|
||||||
[rn/view {:style style/content-container}
|
[rn/view {:style style/content-container}
|
||||||
[rn/view {:style {:flex-direction :row}}
|
[rn/view {:style {:flex-direction :row}}
|
||||||
[quo/text
|
[quo/text
|
||||||
@ -22,12 +28,55 @@
|
|||||||
:weight :semi-bold
|
:weight :semi-bold
|
||||||
:style style/title-container
|
:style style/title-container
|
||||||
:accessibility-label :send-label}
|
:accessibility-label :send-label}
|
||||||
(i18n/label :t/send)]
|
(if (= transaction-type :bridge)
|
||||||
|
(i18n/label :t/bridge)
|
||||||
|
(i18n/label :t/send))]
|
||||||
[quo/summary-tag
|
[quo/summary-tag
|
||||||
{:token (if collectible? "" token-symbol)
|
{:token (if collectible? "" token-symbol)
|
||||||
:label (str amount " " token-symbol)
|
:label (str amount " " token-symbol)
|
||||||
:type (if collectible? :collectible :token)
|
:type (if collectible? :collectible :token)
|
||||||
:image-source (if collectible? image-url :eth)}]]
|
:image-source (if collectible? image-url :eth)}]]
|
||||||
|
(if (= transaction-type :bridge)
|
||||||
|
(map-indexed
|
||||||
|
(fn [idx path]
|
||||||
|
(let [from-network (:from path)
|
||||||
|
chain-id (:chain-id from-network)
|
||||||
|
network (rf/sub [:wallet/network-details-by-chain-id
|
||||||
|
chain-id])
|
||||||
|
network-name (:network-name network)
|
||||||
|
network-name-text (name network-name)
|
||||||
|
network-name-capitalized (when (seq network-name-text)
|
||||||
|
(string/capitalize network-name-text))
|
||||||
|
network-color (if (= network-name :mainnet) :ethereum network-name)]
|
||||||
|
[rn/view
|
||||||
|
{:style {:flex-direction :row
|
||||||
|
:margin-top 4}}
|
||||||
|
(if (zero? idx)
|
||||||
|
[:<>
|
||||||
|
[quo/text
|
||||||
|
{:size :heading-1
|
||||||
|
:weight :semi-bold
|
||||||
|
:style style/title-container
|
||||||
|
:accessibility-label :send-label}
|
||||||
|
(i18n/label :t/from)]
|
||||||
|
[quo/summary-tag
|
||||||
|
{:label network-name-capitalized
|
||||||
|
:type :network
|
||||||
|
:image-source (:source network)
|
||||||
|
:customization-color network-color}]]
|
||||||
|
[:<>
|
||||||
|
[quo/text
|
||||||
|
{:size :heading-1
|
||||||
|
:weight :semi-bold
|
||||||
|
:style style/title-container
|
||||||
|
:accessibility-label :send-label}
|
||||||
|
(str (i18n/label :t/and) " ")]
|
||||||
|
[quo/summary-tag
|
||||||
|
{:label network-name-capitalized
|
||||||
|
:type :network
|
||||||
|
:image-source (:source network)
|
||||||
|
:customization-color network-color}]])]))
|
||||||
|
route)
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style {:flex-direction :row
|
{:style {:flex-direction :row
|
||||||
:margin-top 4}}
|
:margin-top 4}}
|
||||||
@ -41,7 +90,7 @@
|
|||||||
{:label (:name account)
|
{:label (:name account)
|
||||||
:type :account
|
:type :account
|
||||||
:emoji (:emoji account)
|
:emoji (:emoji account)
|
||||||
:customization-color (:color account)}]]
|
:customization-color (:color account)}]])
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style {:flex-direction :row
|
{:style {:flex-direction :row
|
||||||
:margin-top 4}}
|
:margin-top 4}}
|
||||||
@ -51,12 +100,60 @@
|
|||||||
:style style/title-container
|
:style style/title-container
|
||||||
:accessibility-label :send-label}
|
:accessibility-label :send-label}
|
||||||
(i18n/label :t/to)]
|
(i18n/label :t/to)]
|
||||||
|
(if (= transaction-type :bridge)
|
||||||
|
[quo/summary-tag
|
||||||
|
{:type :network
|
||||||
|
:image-source (:source to-network)
|
||||||
|
:label (string/capitalize (name (:network-name to-network)))
|
||||||
|
:customization-color to-network-color}]
|
||||||
[quo/summary-tag
|
[quo/summary-tag
|
||||||
{:type :address
|
{:type :address
|
||||||
:label (utils/get-shortened-address to-address)}]]])
|
:label (utils/get-shortened-address to-address)}])]
|
||||||
|
(when (= transaction-type :bridge)
|
||||||
|
[rn/view
|
||||||
|
{:style {:flex-direction :row
|
||||||
|
:margin-top 4}}
|
||||||
|
[quo/text
|
||||||
|
{:size :heading-1
|
||||||
|
:weight :semi-bold
|
||||||
|
:style style/title-container
|
||||||
|
:accessibility-label :send-label}
|
||||||
|
(i18n/label :t/in)]
|
||||||
|
[quo/summary-tag
|
||||||
|
{:label (:name account)
|
||||||
|
:type :account
|
||||||
|
:emoji (:emoji account)
|
||||||
|
:customization-color (:color account)}]])]))
|
||||||
|
|
||||||
(defn- user-summary
|
(defn- user-summary
|
||||||
[{:keys [amount token-symbol account-props theme label accessibility-label summary-type]}]
|
[{:keys [token-symbol token-decimals account-props route to? theme label accessibility-label
|
||||||
|
summary-type]}]
|
||||||
|
(letfn [(merge-sum [a b]
|
||||||
|
(merge-with money/add a b))]
|
||||||
|
(let [network-amounts
|
||||||
|
(reduce (fn [acc path]
|
||||||
|
(let [network (if to? (:to path) (:from path))
|
||||||
|
chain-id (:chain-id network)
|
||||||
|
amount-hex (if to? (:amount-in path) (:amount-out path))
|
||||||
|
amount-units (native-module/hex-to-number
|
||||||
|
(utils.hex/normalize-hex amount-hex))
|
||||||
|
amount (money/with-precision
|
||||||
|
(if (= token-symbol "ETH")
|
||||||
|
(money/wei->ether amount-units)
|
||||||
|
(money/token->unit amount-units
|
||||||
|
token-decimals))
|
||||||
|
6)
|
||||||
|
network-details (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
||||||
|
network-name (:network-name network-details)
|
||||||
|
network-name (if (= network-name :mainnet) :ethereum network-name)]
|
||||||
|
(merge-sum acc {network-name amount})))
|
||||||
|
{}
|
||||||
|
route)
|
||||||
|
network-values
|
||||||
|
(reduce-kv (fn [acc k v]
|
||||||
|
(assoc acc k {:amount v :token-symbol token-symbol}))
|
||||||
|
{}
|
||||||
|
network-amounts)]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style {:padding-horizontal 20
|
{:style {:padding-horizontal 20
|
||||||
:padding-bottom 16}}
|
:padding-bottom 16}}
|
||||||
@ -69,14 +166,14 @@
|
|||||||
[quo/summary-info
|
[quo/summary-info
|
||||||
{:type summary-type
|
{:type summary-type
|
||||||
:networks? true
|
:networks? true
|
||||||
:values {:ethereum {:amount amount
|
:values network-values
|
||||||
:token-symbol token-symbol}}
|
:account-props account-props}]])))
|
||||||
:account-props account-props}]])
|
|
||||||
|
|
||||||
(defn- transaction-details
|
(defn- transaction-details
|
||||||
[{:keys [estimated-time-min max-fees token-symbol amount to-address route theme]}]
|
[{:keys [estimated-time-min max-fees token-symbol amount to-address to-network route transaction-type
|
||||||
|
theme]}]
|
||||||
(let [currency-symbol (rf/sub [:profile/currency-symbol])
|
(let [currency-symbol (rf/sub [:profile/currency-symbol])
|
||||||
route-loaded? (some? route)
|
route-loaded? (and route (seq route))
|
||||||
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])]
|
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style style/details-title-container}
|
{:style style/details-title-container}
|
||||||
@ -129,7 +226,10 @@
|
|||||||
:label :none
|
:label :none
|
||||||
:status :default
|
:status :default
|
||||||
:size :small
|
:size :small
|
||||||
:title (i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)})
|
:title (if (= transaction-type :bridge)
|
||||||
|
(i18n/label :t/bridged-to
|
||||||
|
{:network (:abbreviated-name to-network)})
|
||||||
|
(i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)}))
|
||||||
:subtitle (str amount " " token-symbol)}]]
|
:subtitle (str amount " " token-symbol)}]]
|
||||||
:else
|
:else
|
||||||
[quo/text {:style {:align-self :center}}
|
[quo/text {:style {:align-self :center}}
|
||||||
@ -137,7 +237,10 @@
|
|||||||
|
|
||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
[_]
|
[_]
|
||||||
(let [on-close #(rf/dispatch [:navigate-back-within-stack :wallet-select-asset])]
|
(let [on-close (fn []
|
||||||
|
(rf/dispatch [:navigate-back-within-stack :wallet-transaction-confirmation])
|
||||||
|
(rf/dispatch [:wallet/clean-suggested-routes])
|
||||||
|
(rf/dispatch [:wallet/clean-selected-collectible]))]
|
||||||
(fn [{:keys [theme]}]
|
(fn [{:keys [theme]}]
|
||||||
(let [send-transaction-data (rf/sub [:wallet/wallet-send])
|
(let [send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||||
token (:token send-transaction-data)
|
token (:token send-transaction-data)
|
||||||
@ -151,14 +254,19 @@
|
|||||||
[(:name collectible-data)
|
[(:name collectible-data)
|
||||||
(str (:name collection-data) " #" collectible-id)]))
|
(str (:name collection-data) " #" collectible-id)]))
|
||||||
(:symbol token))
|
(:symbol token))
|
||||||
|
token-decimals (if collectible 0 (:decimals token))
|
||||||
image-url (when collectible (:image-url collectible-data))
|
image-url (when collectible (:image-url collectible-data))
|
||||||
amount (:amount send-transaction-data)
|
amount (:amount send-transaction-data)
|
||||||
route (:route send-transaction-data)
|
route (:route send-transaction-data)
|
||||||
estimated-time-min (:estimated-time route)
|
transaction-type (:type send-transaction-data)
|
||||||
|
estimated-time-min (reduce + (map :estimated-time route))
|
||||||
max-fees "-"
|
max-fees "-"
|
||||||
to-address (:to-address send-transaction-data)
|
to-address (:to-address send-transaction-data)
|
||||||
account (rf/sub [:wallet/current-viewing-account])
|
account (rf/sub [:wallet/current-viewing-account])
|
||||||
account-color (:color account)
|
account-color (:color account)
|
||||||
|
bridge-to-chain-id (:bridge-to-chain-id send-transaction-data)
|
||||||
|
bridge-to-network (when bridge-to-chain-id
|
||||||
|
(rf/sub [:wallet/network-details-by-chain-id bridge-to-chain-id]))
|
||||||
from-account-props {:customization-color account-color
|
from-account-props {:customization-color account-color
|
||||||
:size 32
|
:size 32
|
||||||
:emoji (:emoji account)
|
:emoji (:emoji account)
|
||||||
@ -176,15 +284,13 @@
|
|||||||
:on-press on-close
|
:on-press on-close
|
||||||
:margin-top (safe-area/get-top)
|
:margin-top (safe-area/get-top)
|
||||||
:background :blur
|
:background :blur
|
||||||
:accessibility-label :top-bar
|
:accessibility-label :top-bar}]
|
||||||
:right-side [{:icon-name :i/advanced
|
:footer (when (and route (seq route))
|
||||||
:on-press #(js/alert
|
|
||||||
"to be implemented")
|
|
||||||
:accessibility-label :advanced-options}]}]
|
|
||||||
:footer (when route
|
|
||||||
[standard-auth/slide-button
|
[standard-auth/slide-button
|
||||||
{:size :size-48
|
{:size :size-48
|
||||||
:track-text (i18n/label :t/slide-to-send)
|
:track-text (if (= transaction-type :bridge)
|
||||||
|
(i18n/label :t/slide-to-bridge)
|
||||||
|
(i18n/label :t/slide-to-send))
|
||||||
:container-style {:z-index 2}
|
:container-style {:z-index 2}
|
||||||
:customization-color account-color
|
:customization-color account-color
|
||||||
:on-auth-success #(rf/dispatch
|
:on-auth-success #(rf/dispatch
|
||||||
@ -200,23 +306,34 @@
|
|||||||
:amount amount
|
:amount amount
|
||||||
:account account
|
:account account
|
||||||
:to-address to-address
|
:to-address to-address
|
||||||
|
:route route
|
||||||
|
:to-network bridge-to-network
|
||||||
:image-url image-url
|
:image-url image-url
|
||||||
|
:transaction-type transaction-type
|
||||||
:collectible? (some? collectible)}]
|
:collectible? (some? collectible)}]
|
||||||
[user-summary
|
[user-summary
|
||||||
{:amount amount
|
{:token-symbol token-symbol
|
||||||
:token-symbol token-symbol
|
:token-decimals token-decimals
|
||||||
:summary-type :status-account
|
:summary-type :status-account
|
||||||
:accessibility-label :summary-from-label
|
:accessibility-label :summary-from-label
|
||||||
:label (i18n/label :t/from-capitalized)
|
:label (i18n/label :t/from-capitalized)
|
||||||
|
:route route
|
||||||
|
:to? false
|
||||||
:account-props from-account-props
|
:account-props from-account-props
|
||||||
:theme theme}]
|
:theme theme}]
|
||||||
[user-summary
|
[user-summary
|
||||||
{:amount amount
|
{:token-symbol token-symbol
|
||||||
:token-symbol token-symbol
|
:token-decimals token-decimals
|
||||||
:summary-type :account
|
:summary-type (if (= transaction-type :bridge)
|
||||||
|
:status-account
|
||||||
|
:account)
|
||||||
:accessibility-label :summary-to-label
|
:accessibility-label :summary-to-label
|
||||||
:label (i18n/label :t/to-capitalized)
|
:label (i18n/label :t/to-capitalized)
|
||||||
:account-props user-props
|
:account-props (if (= transaction-type :bridge)
|
||||||
|
from-account-props
|
||||||
|
user-props)
|
||||||
|
:route route
|
||||||
|
:to? true
|
||||||
:theme theme}]
|
:theme theme}]
|
||||||
[transaction-details
|
[transaction-details
|
||||||
{:estimated-time-min estimated-time-min
|
{:estimated-time-min estimated-time-min
|
||||||
@ -224,7 +341,9 @@
|
|||||||
:token-symbol token-symbol
|
:token-symbol token-symbol
|
||||||
:amount amount
|
:amount amount
|
||||||
:to-address to-address
|
:to-address to-address
|
||||||
|
:to-network bridge-to-network
|
||||||
:theme theme
|
:theme theme
|
||||||
:route route}]]]]))))
|
:route route
|
||||||
|
:transaction-type transaction-type}]]]]))))
|
||||||
|
|
||||||
(def view (quo.theme/with-theme view-internal))
|
(def view (quo.theme/with-theme view-internal))
|
||||||
|
@ -18,17 +18,20 @@
|
|||||||
(def mainnet-network-details
|
(def mainnet-network-details
|
||||||
{:source (resources/get-network constants/mainnet-network-name)
|
{:source (resources/get-network constants/mainnet-network-name)
|
||||||
:short-name constants/mainnet-short-name
|
:short-name constants/mainnet-short-name
|
||||||
:network-name constants/mainnet-network-name})
|
:network-name constants/mainnet-network-name
|
||||||
|
:abbreviated-name constants/mainnet-abbreviated-name})
|
||||||
|
|
||||||
(def arbitrum-network-details
|
(def arbitrum-network-details
|
||||||
{:source (resources/get-network constants/arbitrum-network-name)
|
{:source (resources/get-network constants/arbitrum-network-name)
|
||||||
:short-name constants/arbitrum-short-name
|
:short-name constants/arbitrum-short-name
|
||||||
:network-name constants/arbitrum-network-name})
|
:network-name constants/arbitrum-network-name
|
||||||
|
:abbreviated-name constants/arbitrum-abbreviated-name})
|
||||||
|
|
||||||
(def optimism-network-details
|
(def optimism-network-details
|
||||||
{:source (resources/get-network constants/optimism-network-name)
|
{:source (resources/get-network constants/optimism-network-name)
|
||||||
:short-name constants/optimism-short-name
|
:short-name constants/optimism-short-name
|
||||||
:network-name constants/optimism-network-name})
|
:network-name constants/optimism-network-name
|
||||||
|
:abbreviated-name constants/optimism-abbreviated-name})
|
||||||
|
|
||||||
(defn get-network-details
|
(defn get-network-details
|
||||||
[chain-id]
|
[chain-id]
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
(def network-data
|
(def network-data
|
||||||
{:test [{:test? true
|
{:test [{:test? true
|
||||||
:short-name "eth"
|
:short-name "eth"
|
||||||
:network-name :ethereum
|
:network-name :mainnet
|
||||||
|
:abbreviated-name "Eth."
|
||||||
:related-chain-id 1
|
:related-chain-id 1
|
||||||
:chain-id 3
|
:chain-id 3
|
||||||
:layer 1}
|
:layer 1}
|
||||||
@ -41,16 +42,20 @@
|
|||||||
[sub-name]
|
[sub-name]
|
||||||
(testing "returns data with prod"
|
(testing "returns data with prod"
|
||||||
(swap! rf-db/app-db assoc-in [:wallet :networks] network-data)
|
(swap! rf-db/app-db assoc-in [:wallet :networks] network-data)
|
||||||
(is (= [{:network-name :ethereum
|
(is
|
||||||
|
(= [{:network-name :mainnet
|
||||||
:short-name "eth"
|
:short-name "eth"
|
||||||
:chain-id 1
|
:chain-id 1
|
||||||
|
:abbreviated-name "Eth."
|
||||||
:layer 1}
|
:layer 1}
|
||||||
{:network-name :arbitrum
|
{:network-name :arbitrum
|
||||||
:short-name "arb1"
|
:short-name "arb1"
|
||||||
|
:abbreviated-name "Arb1."
|
||||||
:chain-id 42161
|
:chain-id 42161
|
||||||
:layer 2}
|
:layer 2}
|
||||||
{:network-name :optimism
|
{:network-name :optimism
|
||||||
:short-name "opt"
|
:short-name "opt"
|
||||||
|
:abbreviated-name "Opt."
|
||||||
:chain-id 10
|
:chain-id 10
|
||||||
:layer 2}]
|
:layer 2}]
|
||||||
(map #(dissoc % :source :related-chain-id) (rf/sub [sub-name]))))))
|
(map #(dissoc % :source :related-chain-id) (rf/sub [sub-name]))))))
|
||||||
|
@ -88,6 +88,11 @@
|
|||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :suggested-routes)
|
:-> :suggested-routes)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/wallet-bridge-to-chain-id
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :bridge-to-chain-id)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/watch-address-activity-state
|
:wallet/watch-address-activity-state
|
||||||
:<- [:wallet/ui]
|
:<- [:wallet/ui]
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
:color :blue
|
:color :blue
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 0
|
:position 0
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -205,7 +205,7 @@
|
|||||||
:color :purple
|
:color :purple
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 1
|
:position 1
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -269,7 +269,7 @@
|
|||||||
:color :blue
|
:color :blue
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 0
|
:position 0
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -326,7 +326,7 @@
|
|||||||
:color :blue
|
:color :blue
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 0
|
:position 0
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -383,7 +383,7 @@
|
|||||||
:customization-color :blue
|
:customization-color :blue
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 0
|
:position 0
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -406,7 +406,7 @@
|
|||||||
:customization-color :purple
|
:customization-color :purple
|
||||||
:hidden false
|
:hidden false
|
||||||
:prod-preferred-chain-ids #{1 10 42161}
|
:prod-preferred-chain-ids #{1 10 42161}
|
||||||
:network-preferences-names #{:ethereum :arbitrum :optimism}
|
:network-preferences-names #{:mainnet :arbitrum :optimism}
|
||||||
:position 1
|
:position 1
|
||||||
:clock 1698945829328
|
:clock 1698945829328
|
||||||
:created-at 1698928839000
|
:created-at 1698928839000
|
||||||
@ -427,17 +427,20 @@
|
|||||||
(assoc-in [:wallet :networks] network-data)))
|
(assoc-in [:wallet :networks] network-data)))
|
||||||
(is
|
(is
|
||||||
(match? [{:short-name "eth"
|
(match? [{:short-name "eth"
|
||||||
:network-name :ethereum
|
:network-name :mainnet
|
||||||
|
:abbreviated-name "Eth."
|
||||||
:chain-id 1
|
:chain-id 1
|
||||||
:related-chain-id nil
|
:related-chain-id nil
|
||||||
:layer 1}
|
:layer 1}
|
||||||
{:short-name "arb1"
|
{:short-name "arb1"
|
||||||
:network-name :arbitrum
|
:network-name :arbitrum
|
||||||
|
:abbreviated-name "Arb1."
|
||||||
:chain-id 42161
|
:chain-id 42161
|
||||||
:related-chain-id nil
|
:related-chain-id nil
|
||||||
:layer 2}
|
:layer 2}
|
||||||
{:short-name "opt"
|
{:short-name "opt"
|
||||||
:network-name :optimism
|
:network-name :optimism
|
||||||
|
:abbreviated-name "Opt."
|
||||||
:chain-id 10
|
:chain-id 10
|
||||||
:related-chain-id nil
|
:related-chain-id nil
|
||||||
:layer 2}]
|
:layer 2}]
|
||||||
@ -474,11 +477,11 @@
|
|||||||
(= [(-> accounts
|
(= [(-> accounts
|
||||||
(get "0x1")
|
(get "0x1")
|
||||||
(assoc :customization-color :blue)
|
(assoc :customization-color :blue)
|
||||||
(assoc :network-preferences-names #{:ethereum :arbitrum :optimism}))
|
(assoc :network-preferences-names #{:mainnet :arbitrum :optimism}))
|
||||||
(-> accounts
|
(-> accounts
|
||||||
(get "0x2")
|
(get "0x2")
|
||||||
(assoc :customization-color :purple)
|
(assoc :customization-color :purple)
|
||||||
(assoc :network-preferences-names #{:ethereum :arbitrum :optimism}))
|
(assoc :network-preferences-names #{:mainnet :arbitrum :optimism}))
|
||||||
(-> accounts
|
(-> accounts
|
||||||
(get "0x3")
|
(get "0x3")
|
||||||
(assoc :customization-color :magenta)
|
(assoc :customization-color :magenta)
|
||||||
|
@ -2519,5 +2519,7 @@
|
|||||||
"keypair-name": "Keypair name",
|
"keypair-name": "Keypair name",
|
||||||
"keypair-name-description": "Name keypair for your own personal reference",
|
"keypair-name-description": "Name keypair for your own personal reference",
|
||||||
"keypair-name-input-placeholder": "Collectibles account, Old vault....",
|
"keypair-name-input-placeholder": "Collectibles account, Old vault....",
|
||||||
"goerli-testnet-toggle-confirmation": "Are you sure you want to toggle Goerli? This will log you out and you will have to login again."
|
"goerli-testnet-toggle-confirmation": "Are you sure you want to toggle Goerli? This will log you out and you will have to login again.",
|
||||||
|
"bridged-to": "Bridged to {{network}}",
|
||||||
|
"slide-to-bridge": "Slide to bridge"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user