Skip to content

Commit

Permalink
add utils for collectibles
Browse files Browse the repository at this point in the history
  • Loading branch information
BalogunofAfrica committed May 16, 2024
1 parent 67c4366 commit 643ec7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/status_im/contexts/wallet/send/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
{:prefix prefix
:testnet-enabled? testnet-enabled?
:goerli-enabled? goerli-enabled?})
collectible-tx? (contains? #{:collectible-erc-721 :collectible-erc-1155}
(-> db :wallet :ui :send :tx-type))
collectible-tx? (send-utils/is-collectible?
(-> db :wallet :ui :send :tx-type))
collectible (when collectible-tx?
(-> db :wallet :ui :send :collectible))
one-collectible? (when collectible-tx?
Expand Down Expand Up @@ -236,8 +236,8 @@
:collectible
:token-display-name
:amount
(when (contains? #{:collectible-erc-721 :collectible-erc-1155}
transaction-type)
(when (send-utils/is-collectible?
transaction-type)
:tx-type))})))

(rf/reg-event-fx
Expand Down
7 changes: 4 additions & 3 deletions src/status_im/contexts/wallet/send/flow_config.cljs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
(ns status-im.contexts.wallet.send.flow-config)
(ns status-im.contexts.wallet.send.flow-config
(:require
[status-im.contexts.wallet.send.utils :as send-utils]))

(defn- collectible-selected?
[db]
(let [collectible-stored (-> db :wallet :ui :send :collectible)
tx-type (-> db :wallet :ui :send :tx-type)]
(and (some? collectible-stored)
(contains? #{:collectible-erc-721 :collectible-erc-1155}
tx-type))))
(send-utils/is-collectible? tx-type))))

(defn- token-selected?
[db]
Expand Down
6 changes: 6 additions & 0 deletions src/status_im/contexts/wallet/send/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,9 @@
:position-diff position-diff})))
[]
route))

(defn is-collectible?
[tx-type]
(let [tx-set #{:collectible-erc-721 :collectible-erc-1155}]
(contains? tx-set
tx-type)))

0 comments on commit 643ec7b

Please sign in to comment.