mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-14 02:35:54 +00:00
fix 9792
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
73f8b4692e
commit
48d3087f81
@ -1423,21 +1423,6 @@
|
|||||||
(fn [cofx [_ field-key value]]
|
(fn [cofx [_ field-key value]]
|
||||||
(custom-tokens/field-is-edited 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
|
;; ethereum subscriptions events
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
@ -181,7 +181,8 @@
|
|||||||
:on-success resolve
|
:on-success resolve
|
||||||
:on-error reject})))]))
|
:on-error reject})))]))
|
||||||
(.then (fn [[accounts custom-tokens]]
|
(.then (fn [[accounts custom-tokens]]
|
||||||
(callback accounts custom-tokens)))
|
(callback accounts
|
||||||
|
(mapv #(update % :symbol keyword) custom-tokens))))
|
||||||
(.catch (fn [error]
|
(.catch (fn [error]
|
||||||
(log/error "Failed to initialize wallet"))))))
|
(log/error "Failed to initialize wallet"))))))
|
||||||
|
|
||||||
@ -203,7 +204,9 @@
|
|||||||
(assoc ::notifications/enable nil)
|
(assoc ::notifications/enable nil)
|
||||||
(not platform/desktop?)
|
(not platform/desktop?)
|
||||||
(assoc ::initialize-wallet
|
(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
|
;; NOTE: initializing mailserver depends on user mailserver
|
||||||
;; preference which is why we wait for config callback
|
;; preference which is why we wait for config callback
|
||||||
(protocol/initialize-protocol {:default-mailserver true})
|
(protocol/initialize-protocol {:default-mailserver true})
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
[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.wallet.core :as wallet]
|
[status-im.wallet.core :as wallet]
|
||||||
|
[status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.multiaccounts.update.core :as multiaccounts.update]))
|
[status-im.multiaccounts.update.core :as multiaccounts.update]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
@ -165,6 +166,7 @@
|
|||||||
:error (i18n/label :t/wrong-contract)})}))
|
:error (i18n/label :t/wrong-contract)})}))
|
||||||
|
|
||||||
(fx/defn add-custom-token
|
(fx/defn add-custom-token
|
||||||
|
{:events [:wallet.custom-token.ui/add-pressed]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [contract name symbol decimals]} (get db :wallet/custom-token-screen)
|
(let [{:keys [contract name symbol decimals]} (get db :wallet/custom-token-screen)
|
||||||
chain-key (ethereum/chain-keyword db)
|
chain-key (ethereum/chain-keyword db)
|
||||||
@ -174,19 +176,27 @@
|
|||||||
:symbol symbol
|
:symbol symbol
|
||||||
:decimals (int decimals)
|
:decimals (int decimals)
|
||||||
:color (rand-nth colors/chat-colors)}]
|
: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))
|
(assoc new-token :custom? true))
|
||||||
::json-rpc/call [{:method "wallet_addCustomToken"
|
::json-rpc/call [{:method "wallet_addCustomToken"
|
||||||
:params [new-token]}]}
|
:params [new-token]
|
||||||
(wallet/add-custom-token new-token))))
|
:on-success #()}]}
|
||||||
|
(wallet/add-custom-token new-token)
|
||||||
|
(navigation/navigate-back))))
|
||||||
|
|
||||||
(fx/defn remove-custom-token
|
(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)]
|
(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"
|
::json-rpc/call [{:method "wallet_deleteCustomToken"
|
||||||
:params [address]}]}
|
:params [address]
|
||||||
(wallet/remove-custom-token token))))
|
:on-success #()}]}
|
||||||
|
(wallet/remove-custom-token token)
|
||||||
|
(when navigate-back?
|
||||||
|
(navigation/navigate-back)))))
|
||||||
|
|
||||||
(fx/defn field-is-edited
|
(fx/defn field-is-edited
|
||||||
[{:keys [db] :as cofx} field-key value]
|
[{:keys [db] :as cofx} field-key value]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user