[#10142] Add possibility to select wallet for ENS names
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
9b3fb2ac69
commit
21c9248536
|
@ -15,7 +15,8 @@
|
||||||
[status-im.utils.datetime :as datetime]
|
[status-im.utils.datetime :as datetime]
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[status-im.utils.money :as money]
|
[status-im.utils.money :as money]
|
||||||
[status-im.utils.random :as random]))
|
[status-im.utils.random :as random]
|
||||||
|
[status-im.bottom-sheet.core :as bottom-sheet]))
|
||||||
|
|
||||||
(defn fullname [custom-domain? username]
|
(defn fullname [custom-domain? username]
|
||||||
(if custom-domain?
|
(if custom-domain?
|
||||||
|
@ -165,10 +166,9 @@
|
||||||
(fx/defn register-name
|
(fx/defn register-name
|
||||||
{:events [::register-name-pressed]}
|
{:events [::register-name-pressed]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [custom-domain? username]}
|
(let [{:keys [custom-domain? username address]}
|
||||||
(:ens/registration db)
|
(:ens/registration db)
|
||||||
{:keys [public-key]} (:multiaccount db)
|
{:keys [public-key]} (:multiaccount db)
|
||||||
address (ethereum/default-address db)
|
|
||||||
chain (ethereum/chain-keyword db)
|
chain (ethereum/chain-keyword db)
|
||||||
chain-id (ethereum/chain-id db)
|
chain-id (ethereum/chain-id db)
|
||||||
amount (registration-cost chain-id)
|
amount (registration-cost chain-id)
|
||||||
|
@ -180,6 +180,7 @@
|
||||||
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)"
|
||||||
|
:from address
|
||||||
:params [contract
|
:params [contract
|
||||||
(money/unit->token amount 18)
|
(money/unit->token amount 18)
|
||||||
(abi-spec/encode "register(bytes32,address,bytes32,bytes32)"
|
(abi-spec/encode "register(bytes32,address,bytes32,bytes32)"
|
||||||
|
@ -250,6 +251,13 @@
|
||||||
(update :ens/registration dissoc :username :state)
|
(update :ens/registration dissoc :username :state)
|
||||||
(update-in [:ens/registration :custom-domain?] not))}))
|
(update-in [:ens/registration :custom-domain?] not))}))
|
||||||
|
|
||||||
|
(fx/defn change-address
|
||||||
|
{:events [::change-address]}
|
||||||
|
[{:keys [db] :as cofx} _ {:keys [address]}]
|
||||||
|
(fx/merge cofx
|
||||||
|
{:db (assoc-in db [:ens/registration :address] address)}
|
||||||
|
(bottom-sheet/hide-bottom-sheet)))
|
||||||
|
|
||||||
(fx/defn save-preferred-name
|
(fx/defn save-preferred-name
|
||||||
{:events [::save-preferred-name]}
|
{:events [::save-preferred-name]}
|
||||||
[{:keys [db] :as cofx} name]
|
[{:keys [db] :as cofx} name]
|
||||||
|
|
|
@ -2612,10 +2612,12 @@
|
||||||
:<- [:multiaccount/default-account]
|
:<- [:multiaccount/default-account]
|
||||||
:<- [:multiaccount/public-key]
|
:<- [:multiaccount/public-key]
|
||||||
:<- [:chain-id]
|
:<- [:chain-id]
|
||||||
:<- [:balance-default]
|
:<- [:wallet]
|
||||||
(fn [[{:keys [custom-domain? username]}
|
(fn [[{:keys [custom-domain? username address]}
|
||||||
chain default-account public-key chain-id balance]]
|
chain default-account public-key chain-id wallet]]
|
||||||
{:address (ethereum/normalized-hex (:address default-account))
|
(let [address (or address (ethereum/normalized-hex (:address default-account)))
|
||||||
|
balance (get-in wallet [:accounts address :balance])]
|
||||||
|
{:address address
|
||||||
:username username
|
:username username
|
||||||
:public-key public-key
|
:public-key public-key
|
||||||
:custom-domain? custom-domain?
|
:custom-domain? custom-domain?
|
||||||
|
@ -2623,7 +2625,7 @@
|
||||||
:amount-label (ens-amount-label chain-id)
|
:amount-label (ens-amount-label chain-id)
|
||||||
:sufficient-funds? (money/sufficient-funds?
|
:sufficient-funds? (money/sufficient-funds?
|
||||||
(money/formatted->internal (money/bignumber 10) (ethereum/chain-keyword->snt-symbol chain) 18)
|
(money/formatted->internal (money/bignumber 10) (ethereum/chain-keyword->snt-symbol chain) 18)
|
||||||
(get balance (ethereum/chain-keyword->snt-symbol chain)))}))
|
(get balance (ethereum/chain-keyword->snt-symbol chain)))})))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:ens/confirmation-screen
|
:ens/confirmation-screen
|
||||||
|
|
|
@ -23,7 +23,10 @@
|
||||||
[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]
|
[status-im.ethereum.tokens :as tokens]
|
||||||
[quo.core :as quo])
|
[quo.core :as quo]
|
||||||
|
[status-im.ui.components.chat-icon.screen :as chat-icon]
|
||||||
|
[status-im.utils.utils :as utils]
|
||||||
|
[status-im.ui.screens.wallet.send.sheets :as sheets])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn- link
|
(defn- link
|
||||||
|
@ -261,11 +264,22 @@
|
||||||
"\n"
|
"\n"
|
||||||
(i18n/label :t/ens-understand)]])
|
(i18n/label :t/ens-understand)]])
|
||||||
|
|
||||||
|
(defn render-account [address]
|
||||||
|
(let [account @(re-frame/subscribe [:account-by-address address])]
|
||||||
|
[quo/list-item
|
||||||
|
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||||
|
:title (:name account)
|
||||||
|
:subtitle (utils/get-shortened-checksum-address (:address account))
|
||||||
|
:chevron true
|
||||||
|
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||||
|
{:content (fn [] [sheets/accounts-list :from ::ens/change-address])}])}]))
|
||||||
|
|
||||||
(defn- registration
|
(defn- registration
|
||||||
[checked contract address public-key]
|
[checked contract address public-key]
|
||||||
[react/view {:style {:flex 1 :margin-top 24}}
|
[react/view {:style {:flex 1 :margin-top 24}}
|
||||||
[section {:title (i18n/label :t/wallet-address)
|
[react/text {:style {:color colors/gray :font-size 15 :margin-horizontal 16}}
|
||||||
:content address}]
|
(i18n/label :t/wallet)]
|
||||||
|
[render-account address]
|
||||||
[react/view {:style {:margin-top 14}}
|
[react/view {:style {:margin-top 14}}
|
||||||
[section {:title (i18n/label :t/key)
|
[section {:title (i18n/label :t/key)
|
||||||
:content public-key}]]
|
:content public-key}]]
|
||||||
|
|
Loading…
Reference in New Issue