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 (fx/defn register-name
{:events [:ens/register]} {: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)] (let [{:keys [x y]} (ethereum/coordinates public-key)]
(signing/eth-transaction-call (signing/eth-transaction-call
cofx cofx
{:contract (contracts/get-address db :status/snt) {:contract (contracts/get-address db :status/snt)
:method "approveAndCall(address,uint256,bytes)" :method "approveAndCall(address,uint256,bytes)"
:params [contract :params [contract
(money/unit->token 10 18) (money/unit->token amount 18)
(abi-spec/encode "register(bytes32,address,bytes32,bytes32)" (abi-spec/encode "register(bytes32,address,bytes32,bytes32)"
[(ethereum/sha3 username) address x y])] [(ethereum/sha3 username) address x y])]
:on-result [:ens/save-username custom-domain? username] :on-result [:ens/save-username custom-domain? username]
@ -150,9 +150,11 @@
{}))) {})))
(fx/defn on-registration-failure (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]} {:events [:ens/on-registration-failure]}
[{:keys [db]} username] [{:keys [db]} username])
{:db (assoc-state-for db username :registration-failed)})
(fx/defn store-name-detail (fx/defn store-name-detail
{:events [:ens/store-name-detail]} {:events [:ens/store-name-detail]}

View File

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

View File

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