Skip to content

Commit 0c943d6

Browse files
committed
Display collectible info
1 parent 3c297bf commit 0c943d6

File tree

7 files changed

+79
-18
lines changed

7 files changed

+79
-18
lines changed

src/status_im/ethereum/subscriptions.cljs

+3
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,7 @@
8282
"wallet-owned-collectibles-filtering-done" {:fx [[:dispatch
8383
[:wallet/owned-collectibles-filtering-done
8484
event]]]}
85+
"wallet-get-collectibles-details-done" {:fx [[:dispatch
86+
[:wallet/get-collectible-details-done
87+
event]]]}
8588
(log/warn ::unknown-wallet-event :type type :event event)))

src/status_im2/contexts/profile/config.cljs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
(defn login
1010
[]
11-
{;; Temporary fix until https://github.com/status-im/status-go/issues/3024 is
12-
;; resolved
11+
{;; Temporary fix until https://github.com/status-im/status-go/issues/3024 is resolved
1312
:wakuV2Nameserver "8.8.8.8"
1413
:openseaAPIKey config/opensea-api-key
1514
:poktToken config/POKT_TOKEN

src/status_im2/contexts/wallet/collectible/style.cljs

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
{:margin-top 100
55
:margin-bottom 34})
66

7-
(def preview
7+
(def preview-container
88
{:margin-horizontal 8
99
:margin-top 12})
1010

11+
(def preview
12+
{:width "100%"
13+
:aspect-ratio 1
14+
:border-radius 16})
15+
1116
(def header
1217
{:margin-horizontal 20
1318
:margin-top 16
@@ -17,6 +22,9 @@
1722
{:flex-direction :row
1823
:margin-top 6})
1924

25+
(def collection-avatar-container
26+
{:margin-right 8})
27+
2028
(def buttons-container
2129
{:flex-direction :row
2230
:align-items :stretch

src/status_im2/contexts/wallet/collectible/view.cljs

+14-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
[react-native.core :as rn]
55
[status-im2.common.scroll-page.view :as scroll-page]
66
[status-im2.contexts.wallet.collectible.style :as style]
7-
[status-im2.contexts.wallet.common.temp :as temp]
8-
[utils.i18n :as i18n]))
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
99

1010
(defn header
11-
[{:keys [name description collection-image]}]
11+
[{:keys [name description collection-image-url]}]
1212
[rn/view {:style style/header}
1313
[quo/text
1414
{:weight :semi-bold
1515
:size :heading-1} name]
16-
[rn/view style/collection-container
17-
[quo/collection-avatar {:image collection-image}]
16+
[rn/view {:style style/collection-container}
17+
[rn/view {:style style/collection-avatar-container}
18+
[quo/collection-avatar {:image collection-image-url}]]
1819
[quo/text
1920
{:weight :semi-bold
2021
:size :paragraph-1}
@@ -103,7 +104,8 @@
103104

104105
(defn view
105106
[]
106-
(let [{:keys [name description image traits] :as props} temp/collectible-details]
107+
(let [collectible-details (rf/sub [:wallet/last-collectible-details])
108+
{:keys [name description preview-url traits]} collectible-details]
107109
[scroll-page/scroll-page
108110
{:navigate-back? true
109111
:height 148
@@ -112,12 +114,13 @@
112114
:description description
113115
:right-side [{:icon-name :i/options
114116
:on-press #(js/alert "pressed")}]
115-
:picture image}}
117+
:picture preview-url}}
116118
[rn/view {:style style/container}
117-
[rn/image
118-
{:source image
119-
:style style/preview}]
120-
[header props]
119+
[rn/view {:style style/preview-container}
120+
[rn/image
121+
{:source preview-url
122+
:style style/preview}]]
123+
[header collectible-details]
121124
[cta-buttons]
122125
[tabs]
123126
[info]

src/status_im2/contexts/wallet/common/collectibles_tab/view.cljs

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
:style {:flex 1}
2020
:content-container-style {:align-items :center}
2121
:num-columns 2
22-
:render-fn (fn [{:keys [preview-url]}]
22+
:render-fn (fn [{:keys [preview-url id]}]
2323
[quo/collectible
2424
{:images [preview-url]
25-
:on-press #(rf/dispatch
26-
[:navigate-to
27-
:wallet-collectible])}])}])))
25+
:on-press (fn []
26+
(rf/dispatch [:wallet/get-collectible-details id])
27+
(rf/dispatch
28+
[:navigate-to
29+
:wallet-collectible]))}])}])))

src/status_im2/contexts/wallet/events.cljs

+40
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@
199199

200200
(rf/reg-event-fx :wallet/clear-stored-collectibles clear-stored-collectibles)
201201

202+
(defn store-last-collectible-details
203+
[{:keys [db]} [collectible]]
204+
{:db (assoc-in db
205+
[:wallet :last-collectible-details]
206+
collectible)})
207+
208+
(rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details)
209+
210+
(defn clear-stored-last-collectible-details
211+
[{:keys [db]}]
212+
{:db (update db :wallet dissoc :last-collectible-details)})
213+
214+
(rf/reg-event-fx :wallet/clear-stored-last-collectible-details clear-stored-last-collectible-details)
215+
202216
(rf/reg-event-fx :wallet/request-collectibles
203217
(fn [{:keys [db]} [{:keys [start-at-index new-request?]}]]
204218
(let [request-id 0
@@ -234,6 +248,32 @@
234248
[:wallet/request-collectibles
235249
{:start-at-index start-at-index}]])]})))
236250

251+
(rf/reg-event-fx :wallet/get-collectible-details
252+
(fn [_ [collectible-id]]
253+
(let [request-id 0
254+
collectible-id-converted (cske/transform-keys csk/->PascalCaseKeyword collectible-id)
255+
request-params [request-id [collectible-id-converted]]]
256+
{:json-rpc/call [{:method "wallet_getCollectiblesDetailsAsync"
257+
:params request-params
258+
:on-error (fn [error]
259+
(log/error "failed to request collectible"
260+
{:event :wallet/get-collectible-details
261+
:error error
262+
:params request-params}))}]})))
263+
264+
(rf/reg-event-fx :wallet/get-collectible-details-done
265+
(fn [_ [{:keys [message]}]]
266+
(let [response (cske/transform-keys csk/->kebab-case-keyword
267+
(types/json->clj message))
268+
{:keys [collectibles]} response
269+
collectible (first collectibles)]
270+
(if collectible
271+
{:fx
272+
[[:dispatch [:wallet/store-last-collectible-details collectible]]]}
273+
(log/error "failed to get collectible details"
274+
{:event :wallet/get-collectible-details-done
275+
:response response})))))
276+
237277
(rf/reg-event-fx :wallet/fetch-address-suggestions
238278
(fn [{:keys [db]} [address]]
239279
{:db (assoc db

src/status_im2/subs/wallet/collectibles.cljs

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@
1818
(assoc collectible :preview-url (preview-url collectible)))
1919
(:collectibles wallet))))
2020

21+
(re-frame/reg-sub
22+
:wallet/last-collectible-details
23+
:<- [:wallet]
24+
(fn [wallet]
25+
(let [last-collectible (:last-collectible-details wallet)]
26+
(assoc last-collectible :preview-url (preview-url last-collectible)))))

0 commit comments

Comments
 (0)