mirror of
https://github.com/status-im/status-react.git
synced 2025-02-02 14:14:39 +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
|
:decimals 18
|
||||||
:icon {:source (js/require "../resources/images/tokens/default-native.png")}})))
|
: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
|
(def all-native-currencies
|
||||||
(ethereum.macros/resolve-native-currency-icons
|
(ethereum.macros/resolve-native-currency-icons
|
||||||
{:mainnet {:name "Ether"
|
{:mainnet {:name "Ether"
|
||||||
|
@ -1986,14 +1986,18 @@
|
|||||||
:<- [:multiaccount/default-account]
|
:<- [:multiaccount/default-account]
|
||||||
:<- [:multiaccount/public-key]
|
:<- [:multiaccount/public-key]
|
||||||
:<- [:chain-id]
|
:<- [:chain-id]
|
||||||
|
:<- [:balance-default]
|
||||||
(fn [[{:keys [custom-domain? username]}
|
(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))
|
{:address (ethereum/normalized-hex (:address default-account))
|
||||||
:username username
|
:username username
|
||||||
:public-key public-key
|
:public-key public-key
|
||||||
:custom-domain? custom-domain?
|
:custom-domain? custom-domain?
|
||||||
:contract registrar
|
: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
|
(re-frame/reg-sub
|
||||||
:ens/confirmation-screen
|
:ens/confirmation-screen
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
[status-im.ui.screens.chat.photos :as photos]
|
[status-im.ui.screens.chat.photos :as photos]
|
||||||
[status-im.ui.screens.profile.components.views :as profile.components]
|
[status-im.ui.screens.profile.components.views :as profile.components]
|
||||||
[status-im.utils.debounce :as debounce]
|
[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]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn- button
|
(defn- button
|
||||||
@ -276,28 +278,26 @@
|
|||||||
"\n"
|
"\n"
|
||||||
(i18n/label :t/ens-understand)]])
|
(i18n/label :t/ens-understand)]])
|
||||||
|
|
||||||
(defn- registration-bottom-bar
|
(defn- registration-bottom-bar [checked? amount-label sufficient-funds?]
|
||||||
[checked? amount-label]
|
[react/view {:style {:border-top-width 1
|
||||||
[react/view {:style {:height 60
|
:border-top-color colors/gray-lighter
|
||||||
:border-top-width 1
|
:padding-horizontal 16
|
||||||
:border-top-color colors/gray-lighter}}
|
:padding-vertical 8
|
||||||
[react/view {:style {:margin-horizontal 16
|
:flex-direction :row
|
||||||
:flex-direction :row
|
:justify-content :space-between}}
|
||||||
:justify-content :space-between}}
|
[react/view {:flex-direction :row :align-items :center}
|
||||||
[react/view {:flex-direction :row}
|
[react/image {:source tokens/snt-icon-source
|
||||||
[react/view {:style {:margin-top 12 :margin-right 8}}
|
:style {:width 36 :height 36}}]
|
||||||
[components.common/logo
|
[react/view {:flex-direction :column :margin 8}
|
||||||
{:size 36
|
[react/text {:style {:font-size 15}}
|
||||||
:icon-size 16}]]
|
amount-label]
|
||||||
[react/view {:flex-direction :column :margin-vertical 8}
|
[react/text {:style {:color colors/gray :font-size 15}}
|
||||||
[react/text {:style {:font-size 15}}
|
(i18n/label :t/ens-deposit)]]]
|
||||||
amount-label]
|
[quo/button {:disabled (or (not @checked?) (not sufficient-funds?))
|
||||||
[react/text {:style {:color colors/gray :font-size 15}}
|
:on-press #(debounce/dispatch-and-chill [::ens/register-name-pressed] 2000)}
|
||||||
(i18n/label :t/ens-deposit)]]]
|
(if sufficient-funds?
|
||||||
[button {:disabled? (not @checked?)
|
(i18n/label :t/ens-register)
|
||||||
:label-style (when (not @checked?) {:color colors/gray})
|
(i18n/label :t/not-enough-snt))]])
|
||||||
:on-press #(debounce/dispatch-and-chill [::ens/register-name-pressed] 2000)}
|
|
||||||
(i18n/label :t/ens-register)]]])
|
|
||||||
|
|
||||||
(defn- registration
|
(defn- registration
|
||||||
[checked contract address public-key]
|
[checked contract address public-key]
|
||||||
@ -311,7 +311,7 @@
|
|||||||
|
|
||||||
(views/defview checkout []
|
(views/defview checkout []
|
||||||
(views/letsubs [{:keys [username address custom-domain? public-key
|
(views/letsubs [{:keys [username address custom-domain? public-key
|
||||||
contract amount-label]}
|
contract amount-label sufficient-funds?]}
|
||||||
[:ens/checkout-screen]]
|
[:ens/checkout-screen]]
|
||||||
(let [checked? (reagent/atom false)]
|
(let [checked? (reagent/atom false)]
|
||||||
[react/keyboard-avoiding-view {:flex 1}
|
[react/keyboard-avoiding-view {:flex 1}
|
||||||
@ -340,7 +340,7 @@
|
|||||||
(domain-label custom-domain?)]
|
(domain-label custom-domain?)]
|
||||||
[react/view {:flex 1 :min-width 24}]]]
|
[react/view {:flex 1 :min-width 24}]]]
|
||||||
[registration checked? contract address public-key]]
|
[registration checked? contract address public-key]]
|
||||||
[registration-bottom-bar checked? amount-label]])))
|
[registration-bottom-bar checked? amount-label sufficient-funds?]])))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; CONFIRMATION SCREEN
|
;;; CONFIRMATION SCREEN
|
||||||
|
@ -1154,5 +1154,6 @@
|
|||||||
"sign-anyway" : "Sign anyway",
|
"sign-anyway" : "Sign anyway",
|
||||||
"tx-fail-description1" : "This transaction is likely to fail. Sign at your own risk using custom network fee.",
|
"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.",
|
"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