Skip to content

Commit 0ee2ec7

Browse files
committed
Fetch collectible details
1 parent 7153e4d commit 0ee2ec7

File tree

8 files changed

+87
-18
lines changed

8 files changed

+87
-18
lines changed

Diff for: 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)))

Diff for: src/status_im/multiaccounts/login/core.cljs

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
(clj->js {:title "Unencrypted database"
3434
:url uri})))))]}))
3535

36+
37+
(comment
38+
39+
(native-module/sha3 "***")
40+
41+
)
42+
3643
(rf/defn import-db-submitted
3744
{:events [:multiaccounts.login.ui/import-db-submitted]}
3845
[{:keys [db]}]

Diff for: 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

Diff for: 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

Diff for: 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]

Diff for: 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]))}])}])))

Diff for: src/status_im2/contexts/wallet/events.cljs

+41
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@
223223

224224
(rf/reg-event-fx :wallet/clear-stored-collectibles clear-stored-collectibles)
225225

226+
(defn store-last-collectible-details
227+
[{:keys [db]} [collectible]]
228+
{:db (assoc-in db
229+
[:wallet :last-collectible-details]
230+
collectible)})
231+
232+
(rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details)
233+
234+
(defn clear-stored-last-collectible-details
235+
[{:keys [db]}]
236+
{:db (update db :wallet dissoc :last-collectible-details)})
237+
238+
(rf/reg-event-fx :wallet/clear-stored-last-collectible-details clear-stored-last-collectible-details)
239+
226240
(rf/reg-event-fx
227241
:wallet/request-collectibles
228242
(fn [{:keys [db]} [{:keys [start-at-index new-request?]}]]
@@ -259,6 +273,33 @@
259273
[:wallet/request-collectibles
260274
{:start-at-index start-at-index}]])]})))
261275

276+
(rf/reg-event-fx :wallet/get-collectible-details
277+
(fn [_ [collectible-id]]
278+
(let [request-id 0
279+
collectible-id-converted (cske/transform-keys csk/->PascalCaseKeyword collectible-id)
280+
request-params [request-id [collectible-id-converted]]]
281+
{:json-rpc/call [{:method "wallet_getCollectiblesDetailsAsync"
282+
:params request-params
283+
:on-error (fn [error]
284+
(log/error "failed to request collectible"
285+
{:event :wallet/get-collectible-details
286+
:error error
287+
:params request-params}))}]})))
288+
289+
(rf/reg-event-fx :wallet/get-collectible-details-done
290+
(fn [_ [{:keys [message]}]]
291+
(let [response (cske/transform-keys csk/->kebab-case-keyword
292+
(types/json->clj message))
293+
{:keys [collectibles]} response
294+
collectible (first collectibles)]
295+
(log/info "=== RECEIVED: " collectible)
296+
(if collectible
297+
{:fx
298+
[[:dispatch [:wallet/store-last-collectible-details collectible]]]}
299+
(log/error "failed to get collectible details"
300+
{:event :wallet/get-collectible-details-done
301+
:response response})))))
302+
262303
(rf/reg-event-fx :wallet/fetch-address-suggestions
263304
(fn [{:keys [db]} [address]]
264305
{:db (assoc db

Diff for: 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)