parent
73f8b4692e
commit
48d3087f81
|
@ -1423,21 +1423,6 @@
|
|||
(fn [cofx [_ field-key value]]
|
||||
(custom-tokens/field-is-edited cofx field-key value)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.custom-token.ui/add-pressed
|
||||
(fn [cofx _]
|
||||
(fx/merge cofx
|
||||
(custom-tokens/add-custom-token)
|
||||
(navigation/navigate-back))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.custom-token.ui/remove-pressed
|
||||
(fn [cofx [_ token navigate-back?]]
|
||||
(fx/merge cofx
|
||||
(custom-tokens/remove-custom-token token)
|
||||
(when navigate-back?
|
||||
(navigation/navigate-back)))))
|
||||
|
||||
;; ethereum subscriptions events
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -181,7 +181,8 @@
|
|||
:on-success resolve
|
||||
:on-error reject})))]))
|
||||
(.then (fn [[accounts custom-tokens]]
|
||||
(callback accounts custom-tokens)))
|
||||
(callback accounts
|
||||
(mapv #(update % :symbol keyword) custom-tokens))))
|
||||
(.catch (fn [error]
|
||||
(log/error "Failed to initialize wallet"))))))
|
||||
|
||||
|
@ -203,7 +204,9 @@
|
|||
(assoc ::notifications/enable nil)
|
||||
(not platform/desktop?)
|
||||
(assoc ::initialize-wallet
|
||||
#(re-frame/dispatch [::initialize-wallet %])))
|
||||
(fn [accounts custom-tokens]
|
||||
(re-frame/dispatch [::initialize-wallet
|
||||
accounts custom-tokens]))))
|
||||
;; NOTE: initializing mailserver depends on user mailserver
|
||||
;; preference which is why we wait for config callback
|
||||
(protocol/initialize-protocol {:default-mailserver true})
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.wallet.core :as wallet]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -165,6 +166,7 @@
|
|||
:error (i18n/label :t/wrong-contract)})}))
|
||||
|
||||
(fx/defn add-custom-token
|
||||
{:events [:wallet.custom-token.ui/add-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [contract name symbol decimals]} (get db :wallet/custom-token-screen)
|
||||
chain-key (ethereum/chain-keyword db)
|
||||
|
@ -174,19 +176,27 @@
|
|||
:symbol symbol
|
||||
:decimals (int decimals)
|
||||
:color (rand-nth colors/chat-colors)}]
|
||||
(fx/merge {:db (assoc-in db [:wallet/all-tokens chain-key contract]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:wallet/all-tokens chain-key contract]
|
||||
(assoc new-token :custom? true))
|
||||
::json-rpc/call [{:method "wallet_addCustomToken"
|
||||
:params [new-token]}]}
|
||||
(wallet/add-custom-token new-token))))
|
||||
:params [new-token]
|
||||
:on-success #()}]}
|
||||
(wallet/add-custom-token new-token)
|
||||
(navigation/navigate-back))))
|
||||
|
||||
(fx/defn remove-custom-token
|
||||
[{:keys [db] :as cofx} {:keys [address] :as token}]
|
||||
{:events [:wallet.custom-token.ui/remove-pressed]}
|
||||
[{:keys [db] :as cofx} {:keys [address] :as token} navigate-back?]
|
||||
(let [chain-key (ethereum/chain-keyword db)]
|
||||
(fx/merge {:db (update-in db [:wallet/all-tokens chain-key] dissoc address)
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:wallet/all-tokens chain-key] dissoc address)
|
||||
::json-rpc/call [{:method "wallet_deleteCustomToken"
|
||||
:params [address]}]}
|
||||
(wallet/remove-custom-token token))))
|
||||
:params [address]
|
||||
:on-success #()}]}
|
||||
(wallet/remove-custom-token token)
|
||||
(when navigate-back?
|
||||
(navigation/navigate-back)))))
|
||||
|
||||
(fx/defn field-is-edited
|
||||
[{:keys [db] :as cofx} field-key value]
|
||||
|
|
Loading…
Reference in New Issue