mirror of
https://github.com/status-im/status-react.git
synced 2025-01-23 01:09:49 +00:00
Disable Register button if not enough SNT for ENS name
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
804932e654
commit
dfb8420353
@ -11,6 +11,8 @@
|
||||
:decimals 18
|
||||
:icon {:source (js/require "../resources/images/tokens/default-native.png")}})))
|
||||
|
||||
(def snt-icon-source (js/require "../resources/images/tokens/mainnet/SNT.png"))
|
||||
|
||||
(def all-native-currencies
|
||||
(ethereum.macros/resolve-native-currency-icons
|
||||
{:mainnet {:name "Ether"
|
||||
|
@ -1986,14 +1986,18 @@
|
||||
:<- [:multiaccount/default-account]
|
||||
:<- [:multiaccount/public-key]
|
||||
:<- [:chain-id]
|
||||
:<- [:balance-default]
|
||||
(fn [[{:keys [custom-domain? username]}
|
||||
registrar default-account public-key chain-id]]
|
||||
registrar default-account public-key chain-id balance]]
|
||||
{:address (ethereum/normalized-hex (:address default-account))
|
||||
:username username
|
||||
:public-key public-key
|
||||
:custom-domain? custom-domain?
|
||||
:contract registrar
|
||||
:amount-label (ens-amount-label chain-id)}))
|
||||
:amount-label (ens-amount-label chain-id)
|
||||
:sufficient-funds? (money/sufficient-funds?
|
||||
(money/formatted->internal (money/bignumber 10) :SNT 18)
|
||||
(get balance :SNT))}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:ens/confirmation-screen
|
||||
|
@ -24,7 +24,9 @@
|
||||
[status-im.ui.screens.chat.photos :as photos]
|
||||
[status-im.ui.screens.profile.components.views :as profile.components]
|
||||
[status-im.utils.debounce :as debounce]
|
||||
[clojure.string :as string])
|
||||
[clojure.string :as string]
|
||||
[status-im.ethereum.tokens :as tokens]
|
||||
[quo.core :as quo])
|
||||
(:require-macros [status-im.utils.views :as views]))
|
||||
|
||||
(defn- button
|
||||
@ -276,28 +278,26 @@
|
||||
"\n"
|
||||
(i18n/label :t/ens-understand)]])
|
||||
|
||||
(defn- registration-bottom-bar
|
||||
[checked? amount-label]
|
||||
[react/view {:style {:height 60
|
||||
:border-top-width 1
|
||||
:border-top-color colors/gray-lighter}}
|
||||
[react/view {:style {:margin-horizontal 16
|
||||
(defn- registration-bottom-bar [checked? amount-label sufficient-funds?]
|
||||
[react/view {:style {:border-top-width 1
|
||||
:border-top-color colors/gray-lighter
|
||||
:padding-horizontal 16
|
||||
:padding-vertical 8
|
||||
:flex-direction :row
|
||||
:justify-content :space-between}}
|
||||
[react/view {:flex-direction :row}
|
||||
[react/view {:style {:margin-top 12 :margin-right 8}}
|
||||
[components.common/logo
|
||||
{:size 36
|
||||
:icon-size 16}]]
|
||||
[react/view {:flex-direction :column :margin-vertical 8}
|
||||
[react/view {:flex-direction :row :align-items :center}
|
||||
[react/image {:source tokens/snt-icon-source
|
||||
:style {:width 36 :height 36}}]
|
||||
[react/view {:flex-direction :column :margin 8}
|
||||
[react/text {:style {:font-size 15}}
|
||||
amount-label]
|
||||
[react/text {:style {:color colors/gray :font-size 15}}
|
||||
(i18n/label :t/ens-deposit)]]]
|
||||
[button {:disabled? (not @checked?)
|
||||
:label-style (when (not @checked?) {:color colors/gray})
|
||||
[quo/button {:disabled (or (not @checked?) (not sufficient-funds?))
|
||||
:on-press #(debounce/dispatch-and-chill [::ens/register-name-pressed] 2000)}
|
||||
(i18n/label :t/ens-register)]]])
|
||||
(if sufficient-funds?
|
||||
(i18n/label :t/ens-register)
|
||||
(i18n/label :t/not-enough-snt))]])
|
||||
|
||||
(defn- registration
|
||||
[checked contract address public-key]
|
||||
@ -311,7 +311,7 @@
|
||||
|
||||
(views/defview checkout []
|
||||
(views/letsubs [{:keys [username address custom-domain? public-key
|
||||
contract amount-label]}
|
||||
contract amount-label sufficient-funds?]}
|
||||
[:ens/checkout-screen]]
|
||||
(let [checked? (reagent/atom false)]
|
||||
[react/keyboard-avoiding-view {:flex 1}
|
||||
@ -340,7 +340,7 @@
|
||||
(domain-label custom-domain?)]
|
||||
[react/view {:flex 1 :min-width 24}]]]
|
||||
[registration checked? contract address public-key]]
|
||||
[registration-bottom-bar checked? amount-label]])))
|
||||
[registration-bottom-bar checked? amount-label sufficient-funds?]])))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; CONFIRMATION SCREEN
|
||||
|
@ -1154,5 +1154,6 @@
|
||||
"sign-anyway" : "Sign anyway",
|
||||
"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"
|
||||
"set-custom-fee" : "Set custom fee",
|
||||
"not-enough-snt": "Not enough SNT"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user