move custom tokens to a separate table
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
0e25aa2f2a
commit
6a800b211d
|
@ -69,6 +69,9 @@
|
|||
"status_chats" {}
|
||||
"wallet_getTransfers" {}
|
||||
"wallet_getTokensBalances" {}
|
||||
"wallet_getCustomTokens" {}
|
||||
"wallet_addCustomToken" {}
|
||||
"wallet_deleteCustomToken" {}
|
||||
"browsers_getBrowsers" {}
|
||||
"browsers_addBrowser" {}
|
||||
"browsers_deleteBrowser" {}
|
||||
|
|
|
@ -60,9 +60,11 @@
|
|||
(fn [[account-data hashed-password]]
|
||||
(status/login account-data hashed-password)))
|
||||
|
||||
(fx/defn initialize-wallet [cofx]
|
||||
(fx/defn initialize-wallet
|
||||
{:events [::initialize-wallet]}
|
||||
[cofx custom-tokens]
|
||||
(fx/merge cofx
|
||||
(wallet/initialize-tokens)
|
||||
(wallet/initialize-tokens custom-tokens)
|
||||
(wallet/update-balances nil)
|
||||
(wallet/update-prices)
|
||||
(transactions/initialize)))
|
||||
|
@ -161,7 +163,11 @@
|
|||
multiaccount))}
|
||||
(and platform/android?
|
||||
notifications-enabled?)
|
||||
(assoc ::notifications/enable nil))
|
||||
(assoc ::notifications/enable nil)
|
||||
(not platform/desktop?)
|
||||
(assoc ::json-rpc/call
|
||||
[{:method "wallet_getCustomTokens"
|
||||
:on-success #(re-frame/dispatch [::initialize-wallet %])}]))
|
||||
;; NOTE: initializing mailserver depends on user mailserver
|
||||
;; preference which is why we wait for config callback
|
||||
(protocol/initialize-protocol {:default-mailserver true})
|
||||
|
@ -171,9 +177,7 @@
|
|||
(contact/initialize-contacts)
|
||||
(stickers/init-stickers-packs)
|
||||
(mobile-network/on-network-status-change)
|
||||
(chaos-mode/check-chaos-mode)
|
||||
(when-not platform/desktop?
|
||||
(initialize-wallet)))))
|
||||
(chaos-mode/check-chaos-mode))))
|
||||
|
||||
(defn get-new-auth-method [auth-method save-password?]
|
||||
(if save-password?
|
||||
|
@ -249,7 +253,7 @@
|
|||
:default-mailserver true})
|
||||
(chaos-mode/check-chaos-mode)
|
||||
(when-not platform/desktop?
|
||||
(initialize-wallet)))))
|
||||
(initialize-wallet nil)))))
|
||||
|
||||
(defn- keycard-setup? [cofx]
|
||||
(boolean (get-in cofx [:db :hardwallet :flow])))
|
||||
|
@ -408,4 +412,3 @@
|
|||
(popover/show-popover {:view :secure-with-biometric})
|
||||
(when-not (= previous-auth-method keychain/auth-method-none)
|
||||
(popover/show-popover {:view :disable-password-saving})))))))
|
||||
|
||||
|
|
|
@ -197,10 +197,18 @@
|
|||
(set/difference (set visible-token-symbols)
|
||||
(set (map :symbol (tokens/nfts-for all-tokens chain)))))
|
||||
|
||||
(defn rpc->token [tokens]
|
||||
(reduce (fn [acc {:keys [address] :as token}]
|
||||
(assoc acc
|
||||
address
|
||||
(assoc token :custom? true)))
|
||||
{}
|
||||
tokens))
|
||||
|
||||
(fx/defn initialize-tokens
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [custom-tokens (get-in db [:multiaccount :settings :wallet :custom-tokens])
|
||||
chain (ethereum/chain-keyword db)
|
||||
[{:keys [db] :as cofx} custom-tokens]
|
||||
(let [chain (ethereum/chain-keyword db)
|
||||
custom-tokens {chain (rpc->token custom-tokens)}
|
||||
;;TODO why do we need all tokens ? chain can be changed only through relogin
|
||||
all-tokens (merge-with
|
||||
merge
|
||||
|
|
|
@ -171,18 +171,20 @@
|
|||
new-token {:address contract
|
||||
:name name
|
||||
:symbol symbol
|
||||
:custom? true
|
||||
:decimals (int decimals)
|
||||
:color (rand-nth colors/chat-colors)}]
|
||||
(fx/merge (assoc-in cofx
|
||||
[:db :wallet/all-tokens chain-key contract]
|
||||
new-token)
|
||||
(fx/merge {: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))))
|
||||
|
||||
(fx/defn remove-custom-token
|
||||
[{:keys [db] :as cofx} {:keys [address] :as token}]
|
||||
(let [chain-key (ethereum/chain-keyword db)]
|
||||
(fx/merge (update-in cofx [:db :wallet/all-tokens chain-key] dissoc address)
|
||||
(fx/merge {:db (update-in db [:wallet/all-tokens chain-key] dissoc address)
|
||||
::json-rpc/call [{:method "wallet_deleteCustomToken"
|
||||
:params [address]}]}
|
||||
(wallet/remove-custom-token token))))
|
||||
|
||||
(fx/defn field-is-edited
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.38.0",
|
||||
"commit-sha1": "baa0767c263fa25fdd8d90a42d13f1f1fffce804",
|
||||
"src-sha256": "0m7baga353vyjqb8zlzd22w68kkm24baq8059a89xdv57ln35axi"
|
||||
"version": "v0.0.2.experimental.tokens",
|
||||
"commit-sha1": "0571f561f0e526a996408be96f649c9e17c47c01",
|
||||
"src-sha256": "1skk9mbjrnbs7jy3nlag9gbn9wlig50piafvbilrg01flcalc3i3"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue