[#6802] Expose a query allowing to access supported ERC20 tokens

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-11-23 16:52:30 +01:00 committed by Julien Eluard
parent 3c04982616
commit ac7c20ac45
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
1 changed files with 15 additions and 2 deletions

View File

@ -16,7 +16,9 @@
[status-im.ui.screens.navigation :as navigation] [status-im.ui.screens.navigation :as navigation]
[status-im.utils.handlers :as handlers] [status-im.utils.handlers :as handlers]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
status-im.extensions.ethereum)) status-im.extensions.ethereum
[status-im.utils.ethereum.tokens :as tokens]
[status-im.utils.ethereum.core :as ethereum]))
(re-frame/reg-fx (re-frame/reg-fx
::alert ::alert
@ -41,6 +43,16 @@
(fn [_ [_ _ {:keys [value]}]] (fn [_ [_ _ {:keys [value]}]]
value)) value))
(re-frame/reg-sub
:extensions.wallet/tokens
:<- [:wallet/all-tokens]
:<- [:network]
(fn [[all-tokens network] [_ _ {filter-vector :filter}]]
(let [tokens (tokens/sorted-tokens-for all-tokens (ethereum/network->chain-keyword network))]
(if (= :all (first filter-vector))
tokens
(filter #((set filter-vector) (:symbol %)) tokens)))))
(re-frame/reg-sub (re-frame/reg-sub
:store/get :store/get
(fn [db [_ {id :id} {:keys [key]}]] (fn [db [_ {id :id} {:keys [key]}]]
@ -225,7 +237,8 @@
'transaction-status {:value transactions/transaction-status :properties {:outgoing :string :tx-hash :string}}} 'transaction-status {:value transactions/transaction-status :properties {:outgoing :string :tx-hash :string}}}
:queries {'identity {:value :extensions/identity :arguments {:value :map}} :queries {'identity {:value :extensions/identity :arguments {:value :map}}
'store/get {:value :store/get :arguments {:key :string}} 'store/get {:value :store/get :arguments {:key :string}}
'wallet/collectibles {:value :get-collectible-token :arguments {:token :string :symbol :string}}} 'wallet/collectibles {:value :get-collectible-token :arguments {:token :string :symbol :string}}
'wallet/tokens {:value :extensions.wallet/tokens :arguments {:filter :vector}}}
:events {'alert :events {'alert
{:permissions [:read] {:permissions [:read]
:value :alert :value :alert