[#10105] Add set max to Send transaction
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
7f4476b253
commit
24114f7fe8
|
@ -14,7 +14,7 @@
|
|||
"eth_getBalance"
|
||||
{:on-result money/bignumber}
|
||||
"eth_estimateGas"
|
||||
{:on-result #(money/bignumber (int (* % 1.2)))}
|
||||
{:on-result #(money/bignumber (if (= (int %) 21000) % (int (* % 1.2))))}
|
||||
"eth_gasPrice"
|
||||
{:on-result money/bignumber}
|
||||
"eth_getBlockByHash"
|
||||
|
|
|
@ -370,77 +370,73 @@
|
|||
"Formats an amount of a currency based on the currency pattern
|
||||
If currency-symbol? is false, the currency symbol is excluded from the
|
||||
formatting"
|
||||
([value currency-code]
|
||||
(format-currency value currency-code true))
|
||||
([value currency-code currency-symbol?]
|
||||
(.addTier2Support ^js goog.i18n.currency)
|
||||
(let [currency-code-to-nfs-map {"ZAR" ^js goog.i18n.NumberFormatSymbols_af
|
||||
"ETB" ^js goog.i18n.NumberFormatSymbols_am
|
||||
"EGP" ^js goog.i18n.NumberFormatSymbols_ar
|
||||
"DZD" ^js goog.i18n.NumberFormatSymbols_ar_DZ
|
||||
"AZN" ^js goog.i18n.NumberFormatSymbols_az
|
||||
"BYN" ^js goog.i18n.NumberFormatSymbols_be
|
||||
"BGN" ^js goog.i18n.NumberFormatSymbols_bg
|
||||
"BDT" ^js goog.i18n.NumberFormatSymbols_bn
|
||||
"EUR" ^js goog.i18n.NumberFormatSymbols_br
|
||||
"BAM" ^js goog.i18n.NumberFormatSymbols_bs
|
||||
"USD" ^js goog.i18n.NumberFormatSymbols_en
|
||||
"CZK" ^js goog.i18n.NumberFormatSymbols_cs
|
||||
"GBP" ^js goog.i18n.NumberFormatSymbols_cy
|
||||
"DKK" ^js goog.i18n.NumberFormatSymbols_da
|
||||
"CHF" ^js goog.i18n.NumberFormatSymbols_de_CH
|
||||
"AUD" ^js goog.i18n.NumberFormatSymbols_en_AU
|
||||
"CAD" ^js goog.i18n.NumberFormatSymbols_en_CA
|
||||
"INR" ^js goog.i18n.NumberFormatSymbols_en_IN
|
||||
"SGD" ^js goog.i18n.NumberFormatSymbols_en_SG
|
||||
"MXN" ^js goog.i18n.NumberFormatSymbols_es_419
|
||||
"IRR" ^js goog.i18n.NumberFormatSymbols_fa
|
||||
"PHP" ^js goog.i18n.NumberFormatSymbols_fil
|
||||
"ILS" ^js goog.i18n.NumberFormatSymbols_he
|
||||
"HRK" ^js goog.i18n.NumberFormatSymbols_hr
|
||||
"HUF" ^js goog.i18n.NumberFormatSymbols_hu
|
||||
"AMD" ^js goog.i18n.NumberFormatSymbols_hy
|
||||
"IDR" ^js goog.i18n.NumberFormatSymbols_id
|
||||
"ISK" ^js goog.i18n.NumberFormatSymbols_is
|
||||
"JPY" ^js goog.i18n.NumberFormatSymbols_ja
|
||||
"GEL" ^js goog.i18n.NumberFormatSymbols_ka
|
||||
"KZT" ^js goog.i18n.NumberFormatSymbols_kk
|
||||
"KHR" ^js goog.i18n.NumberFormatSymbols_km
|
||||
"KRW" ^js goog.i18n.NumberFormatSymbols_ko
|
||||
"KGS" ^js goog.i18n.NumberFormatSymbols_ky
|
||||
"CDF" ^js goog.i18n.NumberFormatSymbols_ln
|
||||
"LAK" ^js goog.i18n.NumberFormatSymbols_lo
|
||||
"MKD" ^js goog.i18n.NumberFormatSymbols_mk
|
||||
"MNT" ^js goog.i18n.NumberFormatSymbols_mn
|
||||
"MDL" ^js goog.i18n.NumberFormatSymbols_mo
|
||||
"MYR" ^js goog.i18n.NumberFormatSymbols_ms
|
||||
"MMK" ^js goog.i18n.NumberFormatSymbols_my
|
||||
"NOK" ^js goog.i18n.NumberFormatSymbols_nb
|
||||
"NPR" ^js goog.i18n.NumberFormatSymbols_ne
|
||||
"PLN" ^js goog.i18n.NumberFormatSymbols_pl
|
||||
"BRL" ^js goog.i18n.NumberFormatSymbols_pt
|
||||
"RON" ^js goog.i18n.NumberFormatSymbols_ro
|
||||
"RUB" ^js goog.i18n.NumberFormatSymbols_ru
|
||||
"RSD" ^js goog.i18n.NumberFormatSymbols_sh
|
||||
"LKR" ^js goog.i18n.NumberFormatSymbols_si
|
||||
"ALL" ^js goog.i18n.NumberFormatSymbols_sq
|
||||
"SEK" ^js goog.i18n.NumberFormatSymbols_sv
|
||||
"TZS" ^js goog.i18n.NumberFormatSymbols_sw
|
||||
"THB" ^js goog.i18n.NumberFormatSymbols_th
|
||||
"TRY" ^js goog.i18n.NumberFormatSymbols_tr
|
||||
"UAH" ^js goog.i18n.NumberFormatSymbols_uk
|
||||
"PKR" ^js goog.i18n.NumberFormatSymbols_ur
|
||||
"UZS" ^js goog.i18n.NumberFormatSymbols_uz
|
||||
"VND" ^js goog.i18n.NumberFormatSymbols_vi
|
||||
"CNY" ^js goog.i18n.NumberFormatSymbols_zh
|
||||
"HKD" ^js goog.i18n.NumberFormatSymbols_zh_HK
|
||||
"TWD" ^js goog.i18n.NumberFormatSymbols_zh_TW}
|
||||
nfs (or (get currency-code-to-nfs-map currency-code)
|
||||
^js goog.i18n.NumberFormatSymbols_en)]
|
||||
(.format
|
||||
^js (new ^js goog.i18n.NumberFormat
|
||||
(let [pattern (.-CURRENCY_PATTERN ^js nfs)]
|
||||
(if currency-symbol?
|
||||
pattern
|
||||
(string/replace pattern #"\s*¤\s*" ""))))
|
||||
value))))
|
||||
[value currency-code]
|
||||
(.addTier2Support ^js goog.i18n.currency)
|
||||
(let [currency-code-to-nfs-map {"ZAR" ^js goog.i18n.NumberFormatSymbols_af
|
||||
"ETB" ^js goog.i18n.NumberFormatSymbols_am
|
||||
"EGP" ^js goog.i18n.NumberFormatSymbols_ar
|
||||
"DZD" ^js goog.i18n.NumberFormatSymbols_ar_DZ
|
||||
"AZN" ^js goog.i18n.NumberFormatSymbols_az
|
||||
"BYN" ^js goog.i18n.NumberFormatSymbols_be
|
||||
"BGN" ^js goog.i18n.NumberFormatSymbols_bg
|
||||
"BDT" ^js goog.i18n.NumberFormatSymbols_bn
|
||||
"EUR" ^js goog.i18n.NumberFormatSymbols_br
|
||||
"BAM" ^js goog.i18n.NumberFormatSymbols_bs
|
||||
"USD" ^js goog.i18n.NumberFormatSymbols_en
|
||||
"CZK" ^js goog.i18n.NumberFormatSymbols_cs
|
||||
"GBP" ^js goog.i18n.NumberFormatSymbols_cy
|
||||
"DKK" ^js goog.i18n.NumberFormatSymbols_da
|
||||
"CHF" ^js goog.i18n.NumberFormatSymbols_de_CH
|
||||
"AUD" ^js goog.i18n.NumberFormatSymbols_en_AU
|
||||
"CAD" ^js goog.i18n.NumberFormatSymbols_en_CA
|
||||
"INR" ^js goog.i18n.NumberFormatSymbols_en_IN
|
||||
"SGD" ^js goog.i18n.NumberFormatSymbols_en_SG
|
||||
"MXN" ^js goog.i18n.NumberFormatSymbols_es_419
|
||||
"IRR" ^js goog.i18n.NumberFormatSymbols_fa
|
||||
"PHP" ^js goog.i18n.NumberFormatSymbols_fil
|
||||
"ILS" ^js goog.i18n.NumberFormatSymbols_he
|
||||
"HRK" ^js goog.i18n.NumberFormatSymbols_hr
|
||||
"HUF" ^js goog.i18n.NumberFormatSymbols_hu
|
||||
"AMD" ^js goog.i18n.NumberFormatSymbols_hy
|
||||
"IDR" ^js goog.i18n.NumberFormatSymbols_id
|
||||
"ISK" ^js goog.i18n.NumberFormatSymbols_is
|
||||
"JPY" ^js goog.i18n.NumberFormatSymbols_ja
|
||||
"GEL" ^js goog.i18n.NumberFormatSymbols_ka
|
||||
"KZT" ^js goog.i18n.NumberFormatSymbols_kk
|
||||
"KHR" ^js goog.i18n.NumberFormatSymbols_km
|
||||
"KRW" ^js goog.i18n.NumberFormatSymbols_ko
|
||||
"KGS" ^js goog.i18n.NumberFormatSymbols_ky
|
||||
"CDF" ^js goog.i18n.NumberFormatSymbols_ln
|
||||
"LAK" ^js goog.i18n.NumberFormatSymbols_lo
|
||||
"MKD" ^js goog.i18n.NumberFormatSymbols_mk
|
||||
"MNT" ^js goog.i18n.NumberFormatSymbols_mn
|
||||
"MDL" ^js goog.i18n.NumberFormatSymbols_mo
|
||||
"MYR" ^js goog.i18n.NumberFormatSymbols_ms
|
||||
"MMK" ^js goog.i18n.NumberFormatSymbols_my
|
||||
"NOK" ^js goog.i18n.NumberFormatSymbols_nb
|
||||
"NPR" ^js goog.i18n.NumberFormatSymbols_ne
|
||||
"PLN" ^js goog.i18n.NumberFormatSymbols_pl
|
||||
"BRL" ^js goog.i18n.NumberFormatSymbols_pt
|
||||
"RON" ^js goog.i18n.NumberFormatSymbols_ro
|
||||
"RUB" ^js goog.i18n.NumberFormatSymbols_ru
|
||||
"RSD" ^js goog.i18n.NumberFormatSymbols_sh
|
||||
"LKR" ^js goog.i18n.NumberFormatSymbols_si
|
||||
"ALL" ^js goog.i18n.NumberFormatSymbols_sq
|
||||
"SEK" ^js goog.i18n.NumberFormatSymbols_sv
|
||||
"TZS" ^js goog.i18n.NumberFormatSymbols_sw
|
||||
"THB" ^js goog.i18n.NumberFormatSymbols_th
|
||||
"TRY" ^js goog.i18n.NumberFormatSymbols_tr
|
||||
"UAH" ^js goog.i18n.NumberFormatSymbols_uk
|
||||
"PKR" ^js goog.i18n.NumberFormatSymbols_ur
|
||||
"UZS" ^js goog.i18n.NumberFormatSymbols_uz
|
||||
"VND" ^js goog.i18n.NumberFormatSymbols_vi
|
||||
"CNY" ^js goog.i18n.NumberFormatSymbols_zh
|
||||
"HKD" ^js goog.i18n.NumberFormatSymbols_zh_HK
|
||||
"TWD" ^js goog.i18n.NumberFormatSymbols_zh_TW}
|
||||
nfs (or (get currency-code-to-nfs-map currency-code)
|
||||
^js goog.i18n.NumberFormatSymbols_en)]
|
||||
(.format
|
||||
^js (new ^js goog.i18n.NumberFormat
|
||||
(let [pattern (.-CURRENCY_PATTERN ^js nfs)]
|
||||
(string/replace pattern #"\s*¤\s*" "")))
|
||||
value)))
|
|
@ -207,7 +207,7 @@
|
|||
(prices/update-prices)
|
||||
#(when-not gas
|
||||
{:db (assoc-in (:db %) [:signing/edit-fee :gas-loading?] true)
|
||||
:signing/update-estimated-gas {:obj tx-obj
|
||||
:signing/update-estimated-gas {:obj (dissoc tx-obj :gasPrice)
|
||||
:success-event :signing/update-estimated-gas-success
|
||||
:error-event :signing/update-estimated-gas-error}})
|
||||
#(when-not gasPrice
|
||||
|
|
|
@ -1077,7 +1077,7 @@
|
|||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str
|
||||
(i18n/format-currency (:code currency) false))
|
||||
(i18n/format-currency (:code currency)))
|
||||
"0"))
|
||||
"...")))
|
||||
|
||||
|
@ -1096,7 +1096,7 @@
|
|||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str
|
||||
(i18n/format-currency (:code currency) false))
|
||||
(i18n/format-currency (:code currency)))
|
||||
"0"))
|
||||
"...")))
|
||||
|
||||
|
@ -1182,7 +1182,7 @@
|
|||
(money/crypto->fiat price)
|
||||
(money/with-precision 2)
|
||||
str
|
||||
(i18n/format-currency (:code currency) false)))))))
|
||||
(i18n/format-currency (:code currency))))))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/visible-assets-with-values
|
||||
|
|
|
@ -326,7 +326,8 @@
|
|||
" • "]
|
||||
(if prices-loading?
|
||||
[react/small-loading-indicator]
|
||||
[react/text {:style {:color colors/black}} (i18n/format-currency converted-value (:code wallet-currency))])
|
||||
[react/text {:style {:color colors/black}}
|
||||
(i18n/format-currency converted-value (:code wallet-currency))])
|
||||
[react/text {:style {:color colors/gray}} (str " " (:code wallet-currency))]]]}]))
|
||||
|
||||
(views/defview fee-item [prices wallet-currency fee-display-symbol fee gas-error gas-error-state prices-loading?]
|
||||
|
@ -353,7 +354,8 @@
|
|||
" • "]
|
||||
(if prices-loading?
|
||||
[react/small-loading-indicator]
|
||||
[react/text {:style {:color colors/black}} (i18n/format-currency converted-fee-value (:code wallet-currency))])
|
||||
[react/text {:style {:color colors/black}}
|
||||
(i18n/format-currency converted-fee-value (:code wallet-currency))])
|
||||
[react/text {:style {:color colors/gray}} (str " " (:code wallet-currency))]]
|
||||
:chevron]))
|
||||
:on-press #(re-frame/dispatch
|
||||
|
|
|
@ -12,4 +12,15 @@
|
|||
:align-items :center
|
||||
:justify-content :space-between
|
||||
:padding-top (when-not small-screen? 16)
|
||||
:padding-left 16})
|
||||
:padding-left 16})
|
||||
|
||||
(def set-max-button
|
||||
{:height 35
|
||||
:border-radius 40
|
||||
:background-color colors/blue-light
|
||||
:margin-horizontal 12
|
||||
:align-self :flex-start
|
||||
:margin-bottom 12
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
:padding-horizontal 12})
|
|
@ -18,37 +18,34 @@
|
|||
[status-im.ui.screens.wallet.send.sheets :as sheets]
|
||||
[status-im.ui.screens.wallet.components.views :as components]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.ui.components.button :as button]
|
||||
[status-im.ethereum.core :as ethereum]))
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.utils.money :as money]))
|
||||
|
||||
(defn header [{:keys [label small-screen? on-cancel]}]
|
||||
(defn header [{:keys [label small-screen?]}]
|
||||
[react/view (styles/header small-screen?)
|
||||
[react/view {:flex 1}
|
||||
[react/text {:style (merge {:typography :title-bold} (when small-screen? {:font-size 15}))}
|
||||
(i18n/label (or label :t/send-transaction))]]
|
||||
[button/button {:type :secondary
|
||||
:container-style {:padding-horizontal 24}
|
||||
:label (i18n/label :t/cancel)
|
||||
:on-press on-cancel}]])
|
||||
(i18n/label (or label :t/send-transaction))]]])
|
||||
|
||||
(defn asset-selector [{:keys [request? token from]}]
|
||||
(defn asset-selector [{:keys [request? token from]} window-width]
|
||||
(let [{:keys [name icon color]} token]
|
||||
[react/touchable-highlight
|
||||
{:style {:flex 1}
|
||||
:on-press (when-not request? #(do
|
||||
(re-frame/dispatch [:dismiss-keyboard])
|
||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (fn [] [sheets/assets (:address from)])
|
||||
:content-height 300}])))}
|
||||
{:on-press (when-not request?
|
||||
#(do
|
||||
(re-frame/dispatch [:dismiss-keyboard])
|
||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||
{:content (fn [] [sheets/assets (:address from)])
|
||||
:content-height 300}])))}
|
||||
[react/view {:style {:flex-direction :row
|
||||
:align-items :center
|
||||
:flex 1 :margin-left 16}
|
||||
:margin-left 16}
|
||||
:accessibility-label :choose-asset-button}
|
||||
(if icon
|
||||
[list/item-image (assoc icon :style {:background-color colors/gray-lighter
|
||||
:border-radius 50} :image-style {:width 32 :height 32})]
|
||||
[chat-icon/custom-icon-view-list name color 32])
|
||||
[react/text {:style {:margin-left 8 :flex-shrink 0.5}
|
||||
[react/text {:style {:margin-left 8
|
||||
:max-width (/ window-width 4)}
|
||||
:number-of-lines 2}
|
||||
(wallet.utils/display-symbol token)]
|
||||
(when-not request?
|
||||
|
@ -58,9 +55,10 @@
|
|||
[list-item/list-item
|
||||
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||
:title (:name account)
|
||||
:subtitle (str (wallet.utils/format-amount amount decimals)
|
||||
" "
|
||||
(wallet.utils/display-symbol token))
|
||||
:subtitle (when token
|
||||
(str (wallet.utils/format-amount amount decimals)
|
||||
" "
|
||||
(wallet.utils/display-symbol token)))
|
||||
:accessories [:chevron]
|
||||
:on-press #(do
|
||||
(re-frame/dispatch [:dismiss-keyboard])
|
||||
|
@ -70,40 +68,56 @@
|
|||
|
||||
(defn render-contact [contact from-chat?]
|
||||
(if from-chat?
|
||||
[list-item/list-item {:title (multiaccounts/displayed-name contact)
|
||||
[list-item/list-item {:title (multiaccounts/displayed-name contact)
|
||||
:subtitle (:address contact)
|
||||
:icon (multiaccounts/displayed-photo contact)}]
|
||||
:icon (multiaccounts/displayed-photo contact)}]
|
||||
[list-item/list-item
|
||||
{:title (utils/get-shortened-checksum-address
|
||||
(if (string? contact) contact (:address contact)))
|
||||
:subtitle (when-not contact (i18n/label :t/wallet-choose-recipient))
|
||||
{:title (utils/get-shortened-checksum-address
|
||||
(if (string? contact) contact (:address contact)))
|
||||
:subtitle (when-not contact (i18n/label :t/wallet-choose-recipient))
|
||||
:accessibility-label :choose-recipient-button
|
||||
:on-press #(do
|
||||
(re-frame/dispatch [:dismiss-keyboard])
|
||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||
{:content sheets/choose-recipient
|
||||
:content-height 200}]))
|
||||
:accessories [:chevron]}]))
|
||||
:on-press #(do
|
||||
(re-frame/dispatch [:dismiss-keyboard])
|
||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||
{:content sheets/choose-recipient
|
||||
:content-height 200}]))
|
||||
:accessories [:chevron]}]))
|
||||
|
||||
(defn set-max [token]
|
||||
[react/touchable-highlight
|
||||
{:on-press
|
||||
#(when token
|
||||
(re-frame/dispatch [:wallet.send/set-max-amount token]))}
|
||||
[react/view {:style styles/set-max-button}
|
||||
[react/text {:style {:color colors/blue}} (i18n/label :t/set-max)]]])
|
||||
|
||||
(defn fiat-value [amount {:keys [symbol]} prices wallet-currency]
|
||||
(when-let [price (get-in prices [(keyword symbol) (keyword (:code wallet-currency)) :price])]
|
||||
(let [norm-amount (js/parseFloat (money/normalize amount))
|
||||
amount (if (js/isNaN norm-amount) 0 norm-amount)]
|
||||
[react/text {:style {:color colors/gray :margin-left 16 :margin-bottom 8
|
||||
:font-size 15 :line-height 22}}
|
||||
(str (i18n/format-currency (* amount price) (:code wallet-currency)) " " (:code wallet-currency))])))
|
||||
|
||||
(views/defview sheet [_]
|
||||
(views/letsubs [{:keys [amount-error amount-text
|
||||
request?
|
||||
from token to sign-enabled? from-chat?] :as tx}
|
||||
[:wallet.send/prepare-transaction-with-balance]
|
||||
prices [:prices]
|
||||
wallet-currency [:wallet/currency]
|
||||
window-height [:dimensions/window-height]
|
||||
window-width [:dimensions/window-width]
|
||||
keyboard-height [:keyboard-height]]
|
||||
(let [small-screen? (< (- window-height keyboard-height) 450)
|
||||
to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))]
|
||||
[react/view {:style (styles/sheet small-screen?)}
|
||||
[header {:small-screen? small-screen?
|
||||
:on-cancel #(re-frame/dispatch [:wallet/cancel-transaction-command])}]
|
||||
[react/view {:flex-direction :row :padding-horizontal 24 :align-items :center
|
||||
:flex 1
|
||||
:margin-vertical (if small-screen? 8 16)}
|
||||
[react/view {:flex-direction :row :padding-horizontal 16 :align-items :center
|
||||
:margin-top 12 :margin-bottom 4}
|
||||
[react/text-input
|
||||
{:style {:font-size (if small-screen? 24 38)
|
||||
:color (if amount-error colors/red colors/black)
|
||||
:flex-shrink 1}
|
||||
:max-width (- (* (/ window-width 4) 3) 106)
|
||||
:color (if amount-error colors/red colors/black)}
|
||||
:keyboard-type :decimal-pad
|
||||
:auto-capitalize :words
|
||||
:accessibility-label :amount-input
|
||||
|
@ -112,13 +126,16 @@
|
|||
:auto-focus true
|
||||
:on-change-text #(re-frame/dispatch [:wallet.send/set-amount-text %])
|
||||
:placeholder "0.0 "}]
|
||||
[asset-selector tx]
|
||||
[asset-selector tx window-width]
|
||||
(when amount-error
|
||||
[tooltip/tooltip (if from
|
||||
amount-error
|
||||
(i18n/label :t/select-account-first))
|
||||
{:bottom-value 2
|
||||
:font-size 12}])]
|
||||
[fiat-value amount-text token prices wallet-currency]
|
||||
(when-not (or request? from-chat?)
|
||||
[set-max token])
|
||||
[components/separator]
|
||||
(when-not small-screen?
|
||||
[list-item/list-item {:type :section-header :title :t/from}])
|
||||
|
@ -135,7 +152,11 @@
|
|||
[react/view {:flex 1}
|
||||
[render-contact to from-chat?]]]
|
||||
[toolbar/toolbar
|
||||
{:center
|
||||
{:left
|
||||
{:label :t/cancel
|
||||
:type :secondary
|
||||
:on-press #(re-frame/dispatch [:wallet/cancel-transaction-command])}
|
||||
:right
|
||||
{:label (if (and (not request?) from-chat? (not to-norm)) :t/wallet-send :t/next)
|
||||
:accessibility-label :send-transaction-bottom-sheet
|
||||
:disabled? (not sign-enabled?)
|
||||
|
@ -152,17 +173,19 @@
|
|||
(views/letsubs [{:keys [amount-error amount-text from token sign-enabled?] :as tx}
|
||||
[:wallet.request/prepare-transaction-with-balance]
|
||||
window-height [:dimensions/window-height]
|
||||
window-width [:dimensions/window-width]
|
||||
prices [:prices]
|
||||
wallet-currency [:wallet/currency]
|
||||
keyboard-height [:keyboard-height]]
|
||||
(let [small-screen? (< (- window-height keyboard-height) 450)]
|
||||
[react/view {:style (styles/sheet small-screen?)}
|
||||
[header {:small-screen? small-screen?
|
||||
:label :t/request-transaction
|
||||
:on-cancel #(re-frame/dispatch [:wallet/cancel-transaction-command])}]
|
||||
[react/view {:flex-direction :row :padding-horizontal 24 :align-items :center
|
||||
:label :t/request-transaction}]
|
||||
[react/view {:flex-direction :row :padding-horizontal 24 :align-items :center
|
||||
:margin-vertical (if small-screen? 8 16)}
|
||||
[react/text-input
|
||||
{:style {:font-size (if small-screen? 24 38)
|
||||
:color (when amount-error colors/red)
|
||||
{:style {:font-size (if small-screen? 24 38)
|
||||
:color (when amount-error colors/red)
|
||||
:flex-shrink 1}
|
||||
:keyboard-type :decimal-pad
|
||||
:auto-capitalize :words
|
||||
|
@ -171,10 +194,11 @@
|
|||
:auto-focus true
|
||||
:on-change-text #(re-frame/dispatch [:wallet.request/set-amount-text %])
|
||||
:placeholder "0.0 "}]
|
||||
[asset-selector tx]
|
||||
[asset-selector tx window-width]
|
||||
(when amount-error
|
||||
[tooltip/tooltip amount-error {:bottom-value 2
|
||||
:font-size 12}])]
|
||||
[fiat-value amount-text token prices wallet-currency]
|
||||
[components/separator]
|
||||
(when-not small-screen?
|
||||
[list-item/list-item {:type :section-header :title :t/to}])
|
||||
|
@ -184,7 +208,11 @@
|
|||
[react/view {:flex 1}
|
||||
[render-account from token :wallet.request/set-field]]]
|
||||
[toolbar/toolbar
|
||||
{:center
|
||||
{:left
|
||||
{:label :t/cancel
|
||||
:type :secondary
|
||||
:on-press #(re-frame/dispatch [:wallet/cancel-transaction-command])}
|
||||
:right
|
||||
{:label :t/wallet-request
|
||||
:accessibility-label :request-transaction-bottom-sheet
|
||||
:disabled? (not sign-enabled?)
|
||||
|
@ -197,9 +225,8 @@
|
|||
(let [small-screen? (< (- window-height keyboard-height) 450)]
|
||||
[react/view {:style (styles/sheet small-screen?)}
|
||||
[header {:small-screen? small-screen?
|
||||
:label :t/select-account
|
||||
:on-cancel #(re-frame/dispatch [:set :commands/select-account nil])}]
|
||||
[react/view {:flex-direction :row :padding-horizontal 24 :align-items :center
|
||||
:label :t/select-account}]
|
||||
[react/view {:flex-direction :row :padding-horizontal 24 :align-items :center
|
||||
:margin-vertical (if small-screen? 8 16)}]
|
||||
(when-not small-screen?
|
||||
[list-item/list-item {:type :section-header :title :t/from}])
|
||||
|
@ -209,8 +236,12 @@
|
|||
[react/view {:flex 1}
|
||||
[render-account from nil ::commands/set-selected-account]]]
|
||||
[toolbar/toolbar
|
||||
{:center
|
||||
{:label :t/select
|
||||
{:left
|
||||
{:label :t/cancel
|
||||
:type :secondary
|
||||
:on-press #(re-frame/dispatch [:set :commands/select-account nil])}
|
||||
:right
|
||||
{:label :t/share
|
||||
:accessibility-label :select-account-bottom-sheet
|
||||
:disabled? (nil? from)
|
||||
:on-press #(re-frame/dispatch
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
[status-im.ethereum.ens :as ens]
|
||||
[status-im.ethereum.stateofus :as stateofus]
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.wallet.prices :as prices]))
|
||||
[status-im.wallet.prices :as prices]
|
||||
[status-im.wallet.utils :as wallet.utils]))
|
||||
|
||||
(defn get-balance
|
||||
[{:keys [address on-success on-error]}]
|
||||
|
@ -305,6 +306,24 @@
|
|||
[{:keys [db]} amount]
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :amount-text] amount)})
|
||||
|
||||
(fx/defn wallet-send-gas-price-success
|
||||
{:events [:wallet.send/update-gas-price-success]}
|
||||
[{db :db} price]
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :gasPrice] price)})
|
||||
|
||||
(fx/defn set-max-amount
|
||||
{:events [:wallet.send/set-max-amount]}
|
||||
[{:keys [db]} {:keys [amount decimals symbol]}]
|
||||
(let [^js gas (money/bignumber 21000)
|
||||
^js gasPrice (get-in db [:wallet/prepare-transaction :gasPrice])
|
||||
^js fee (when gasPrice (.times gas gasPrice))
|
||||
amount-text (if (= :ETH symbol)
|
||||
(when (and fee (money/sufficient-funds? fee amount))
|
||||
(str (wallet.utils/format-amount (.minus amount fee) decimals)))
|
||||
(str (wallet.utils/format-amount amount decimals)))]
|
||||
(when amount-text
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :amount-text] amount-text)})))
|
||||
|
||||
(fx/defn set-and-validate-request-amount
|
||||
{:events [:wallet.request/set-amount-text]}
|
||||
[{:keys [db]} amount]
|
||||
|
@ -466,7 +485,8 @@
|
|||
(fx/defn on-recipient-address-resolved
|
||||
{:events [::recipient-address-resolved]}
|
||||
[{:keys [db]} address]
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :to :address] address)})
|
||||
{:db (assoc-in db [:wallet/prepare-transaction :to :address] address)
|
||||
:signing/update-gas-price {:success-event :wallet.send/update-gas-price-success}})
|
||||
|
||||
(fx/defn prepare-transaction-from-chat
|
||||
{:events [:wallet/prepare-transaction-from-chat]}
|
||||
|
@ -515,7 +535,8 @@
|
|||
{:from account
|
||||
:to nil
|
||||
:symbol :ETH
|
||||
:from-chat? false})})
|
||||
:from-chat? false})
|
||||
:signing/update-gas-price {:success-event :wallet.send/update-gas-price-success}})
|
||||
|
||||
(fx/defn cancel-transaction-command
|
||||
{:events [:wallet/cancel-transaction-command]}
|
||||
|
|
|
@ -1156,5 +1156,6 @@
|
|||
"tx-fail-description1" : "This transaction is likely to fail. Sign at your own risk using custom network fee.",
|
||||
"tx-fail-description2" : "This transaction is likely to fail. Set a custom network fee to sign at your own risk.",
|
||||
"set-custom-fee" : "Set custom fee",
|
||||
"not-enough-snt": "Not enough SNT"
|
||||
"not-enough-snt": "Not enough SNT",
|
||||
"set-max": "Set max"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue