Skip to content

Commit

Permalink
The collectibles are not supported on Optimism and Arbitrum #18507 (#…
Browse files Browse the repository at this point in the history
…18562)

* add chain id to the request

* add tests

* fix lint issues

* remove OPENSEA_API_KEY

* move subscription to a helper method for chain-ids
  • Loading branch information
mmilad75 authored Jan 24, 2024
1 parent d20f10c commit ed74631
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/status_im/contexts/wallet/events/collectibles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(:require [camel-snake-kebab.core :as csk]
[camel-snake-kebab.extras :as cske]
[clojure.string :as string]
[re-frame.core :as rf]
[taoensso.timbre :as log]
[utils.ethereum.chain :as chain]
[utils.re-frame :as rf]
[utils.transforms :as types]))

(def collectible-data-types
Expand Down Expand Up @@ -66,8 +66,9 @@
data-type (collectible-data-types :header)
fetch-criteria {:fetch-type (fetch-type :fetch-if-not-cached)
:max-cache-age-seconds max-cache-age-seconds}
chain-ids (chain/chain-ids db)
request-params [request-id
[(chain/chain-id db)]
chain-ids
(keys (get-in db [:wallet :accounts]))
collectibles-filter
start-at-index
Expand Down
3 changes: 3 additions & 0 deletions src/status_im/subs/wallet/networks_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
:short-name "eth"
:network-name :ethereum
:related-chain-id 1
:chain-id 3
:layer 1}
{:test? true
:short-name "arb1"
:related-chain-id 42161
:chain-id 4
:layer 2}
{:test? true
:short-name "opt"
:related-chain-id 10
:chain-id 5
:layer 2}]
:prod [{:test? false
:short-name "eth"
Expand Down
7 changes: 7 additions & 0 deletions src/utils/ethereum/chain.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@
(defn chain-id
[db]
(network->chain-id (get-current-network db)))

(defn chain-ids
[db]
(let [test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
networks (get-in db [:wallet :networks])
env-networks (get networks (if test-networks-enabled? :test :prod))]
(map :chain-id env-networks)))
14 changes: 14 additions & 0 deletions src/utils/ethereum/chain_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
[cljs.test :refer-macros [deftest is]]
[utils.ethereum.chain :as chain]))

(defn chain-ids-db
[test-networks-enabled?]
{:profile/profile {:test-networks-enabled? test-networks-enabled?}
:wallet {:networks {:test [{:chain-id 3}
{:chain-id 4}
{:chain-id 5}]
:prod [{:chain-id 1}
{:chain-id 42161}
{:chain-id 10}]}}})

(deftest chain-id->chain-keyword
(is (= (chain/chain-id->chain-keyword 1) :mainnet))
(is (= (chain/chain-id->chain-keyword 5) :goerli))
(is (= (chain/chain-id->chain-keyword 5777) :custom)))

(deftest chain-ids
(is (= (chain/chain-ids (chain-ids-db false)) [1 42161 10]))
(is (= (chain/chain-ids (chain-ids-db true)) [3 4 5])))

0 comments on commit ed74631

Please sign in to comment.