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