-
Notifications
You must be signed in to change notification settings - Fork 991
Expand file tree
/
Copy pathdata.cljs
More file actions
41 lines (38 loc) · 1.33 KB
/
data.cljs
File metadata and controls
41 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(ns status-im.contexts.wallet.tokens.data)
(defn- tokens-by-key
[{:keys [key-fn added-tokens source-name tokens chain-ids]}]
(reduce
(fn [acc {:keys [address chainId decimals name image verified] :as token}]
(if (some #{chainId} chain-ids)
(let [k (key-fn token)]
(assoc acc
k
{:key k
:name name
:symbol (:symbol token)
:sources (if-let [added-token (get added-tokens k)]
(conj (:sources added-token) source-name)
[source-name])
:chain-id chainId
:address address
:decimals decimals
:image image
:type (if (= name "native") :native :erc20)
:community-id (get-in token [:communityData :id])
:verified? verified}))
acc))
{}
tokens))
(defn tokens-by-address
[props]
(tokens-by-key (assoc props
:key-fn
(fn [{:keys [chainId address]}]
(str chainId "-" address)))))
(defn tokens-by-name
[props]
(tokens-by-key
(assoc props
:key-fn
(fn [{:keys [chainId name]}]
(str chainId "-" name)))))