fix ens registration on ropsten

ropsten is 50STT
also fixed cancellation of transaction
This commit is contained in:
yenda 2019-08-24 17:43:18 +02:00
parent 84c04949aa
commit bf50811f25
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
3 changed files with 28 additions and 14 deletions

View File

@ -64,14 +64,14 @@
(fx/defn register-name
{:events [:ens/register]}
[{:keys [db] :as cofx} {:keys [contract custom-domain? username address public-key]}]
[{:keys [db] :as cofx} {:keys [amount contract custom-domain? username address public-key]}]
(let [{:keys [x y]} (ethereum/coordinates public-key)]
(signing/eth-transaction-call
cofx
{:contract (contracts/get-address db :status/snt)
:method "approveAndCall(address,uint256,bytes)"
:params [contract
(money/unit->token 10 18)
(money/unit->token amount 18)
(abi-spec/encode "register(bytes32,address,bytes32,bytes32)"
[(ethereum/sha3 username) address x y])]
:on-result [:ens/save-username custom-domain? username]
@ -150,9 +150,11 @@
{})))
(fx/defn on-registration-failure
"TODO not sure there is actually anything to do here
it should only be called if the user cancels the signing
Actual registration failure has not been implemented properly"
{:events [:ens/on-registration-failure]}
[{:keys [db]} username]
{:db (assoc-state-for db username :registration-failed)})
[{:keys [db]} username])
(fx/defn store-name-detail
{:events [:ens/store-name-detail]}

View File

@ -1770,14 +1770,26 @@
:<- [:ens/registration]
:<- [:ens.stateofus/registrar]
:<- [:multiaccount]
(fn [[{:keys [custom-domain? username-candidate registering?] :as ens} registrar {:keys [accounts public-key]}]]
{:state (get-in ens [:states username-candidate])
:registering? registering?
:username username-candidate
:custom-domain? (or custom-domain? false)
:contract registrar
:address (:address (ethereum/get-default-account accounts))
:public-key public-key}))
:<- [:chain-id]
(fn [[{:keys [custom-domain? username-candidate registering?] :as ens}
registrar {:keys [accounts public-key]} chain-id]]
(let [amount (case chain-id
3 50
1 10
0)
amount-label (str amount (case chain-id
3 " STT"
1 " SNT"
""))]
{:state (get-in ens [:states username-candidate])
:registering? registering?
:username username-candidate
:custom-domain? (or custom-domain? false)
:contract registrar
:address (:address (ethereum/get-default-account accounts))
:public-key public-key
:amount amount
:amount-label amount-label})))
(re-frame/reg-sub
:ens.name/screen

View File

@ -290,7 +290,7 @@
[react/text
(i18n/label :t/ens-understand)]]])
(defn- registration-bottom-bar [{:keys [checked] :as props}]
(defn- registration-bottom-bar [{:keys [checked amount-label] :as props}]
[react/view {:style {:height 60
:background-color colors/white
:border-top-width 1
@ -305,7 +305,7 @@
:icon-size 16}]]
[react/view {:flex-direction :column :margin-vertical 8}
[react/text {:style {:font-size 15}}
(i18n/label :t/ens-10-SNT)]
amount-label]
[react/text {:style {:color colors/gray :font-size 15}}
(i18n/label :t/ens-deposit)]]]
[button {:disabled? (not @checked)