WIP
This commit is contained in:
parent
88b97d1151
commit
fa68ce464a
|
@ -32,13 +32,31 @@
|
||||||
{:event :wallet/fetch-activities-for-current-account
|
{:event :wallet/fetch-activities-for-current-account
|
||||||
:params request-params}]}]]]})))
|
:params request-params}]}]]]})))
|
||||||
|
|
||||||
|
(def activity-transaction-id (comp hash :transaction))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/activity-filtering-for-current-account-done
|
:wallet/activity-filtering-for-current-account-done
|
||||||
(fn [{:keys [db]} [{:keys [message]}]]
|
(fn [{:keys [db]} [{:keys [message]}]]
|
||||||
(let [address (-> db :wallet :current-viewing-account-address)
|
(let [address (-> db :wallet :current-viewing-account-address)
|
||||||
activities (->> message
|
activities (->> message
|
||||||
(transforms/json->clj)
|
(transforms/json->clj)
|
||||||
(:activities)
|
(:activities)
|
||||||
(cske/transform-keys transforms/->kebab-case-keyword))
|
(cske/transform-keys transforms/->kebab-case-keyword))
|
||||||
sorted-activities (sort :timestamp activities)]
|
activities-indexed (zipmap (map activity-transaction-id activities)
|
||||||
{:db (assoc-in db [:wallet :activities address] sorted-activities)})))
|
activities)]
|
||||||
|
{:db (assoc-in db [:wallet :activities address] activities-indexed)})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:wallet/activities-filtering-entries-updated
|
||||||
|
(fn [{:keys [db]} [{:keys [message]}]]
|
||||||
|
(def --m message)
|
||||||
|
(let [address (-> db :wallet :current-viewing-account-address)
|
||||||
|
activities (->> message
|
||||||
|
(transforms/json->clj)
|
||||||
|
(cske/transform-keys transforms/->kebab-case-keyword))
|
||||||
|
activities-indexed (zipmap (map activity-transaction-id activities)
|
||||||
|
activities)]
|
||||||
|
{:db (update-in db [:wallet :activities address]
|
||||||
|
(fn [old-activities]
|
||||||
|
(merge-with merge old-activities activities-indexed)))}
|
||||||
|
)))
|
||||||
|
|
|
@ -32,10 +32,35 @@
|
||||||
:network-logo network-logo}
|
:network-logo network-logo}
|
||||||
:blur? false}])
|
:blur? false}])
|
||||||
|
|
||||||
|
(defn mint-activity
|
||||||
|
[{:keys [transaction relative-date status recipient network-name
|
||||||
|
network-logo nft-name nft-url]}]
|
||||||
|
[quo/wallet-activity
|
||||||
|
{:transaction transaction
|
||||||
|
:timestamp relative-date
|
||||||
|
:status status
|
||||||
|
:counter 1 ;; TODO: is this the amount in?
|
||||||
|
:first-tag {:size 24
|
||||||
|
:type :collectible
|
||||||
|
:collectible nft-url
|
||||||
|
:collectible-name nft-name
|
||||||
|
:collectible-number 500}
|
||||||
|
:second-tag-prefix :t/at
|
||||||
|
:second-tag {:type :address :address recipient}
|
||||||
|
:third-tag-prefix :t/to
|
||||||
|
:third-tag {:type :address :address recipient}
|
||||||
|
:fourth-tag-prefix :t/via
|
||||||
|
:fourth-tag {:size 24
|
||||||
|
:type :network
|
||||||
|
:network-name network-name
|
||||||
|
:network-logo network-logo}
|
||||||
|
:blur? false}])
|
||||||
|
|
||||||
(defn activity-item
|
(defn activity-item
|
||||||
[{:keys [transaction] :as activity}]
|
[{:keys [transaction] :as activity}]
|
||||||
(case transaction
|
(case transaction
|
||||||
(:send :receive) [send-and-receive-activity activity]
|
(:send :receive) [send-and-receive-activity activity]
|
||||||
|
;:mint [mint-activity activity]
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
|
|
|
@ -41,4 +41,7 @@
|
||||||
[[:dispatch
|
[[:dispatch
|
||||||
[:wallet/activity-filtering-for-current-account-done
|
[:wallet/activity-filtering-for-current-account-done
|
||||||
(transforms/js->clj event-js)]]]}
|
(transforms/js->clj event-js)]]]}
|
||||||
|
"wallet-activity-filtering-entries-updated" {:fx [[:dispatch
|
||||||
|
[:wallet/activities-filtering-entries-updated
|
||||||
|
(transforms/js->clj event-js)]]]}
|
||||||
(log/debug ::unknown-wallet-event :type event-type)))))
|
(log/debug ::unknown-wallet-event :type event-type)))))
|
||||||
|
|
|
@ -45,6 +45,17 @@
|
||||||
:network-name network-name
|
:network-name network-name
|
||||||
:network-logo (quo.resources/get-network network-name))))
|
:network-logo (quo.resources/get-network network-name))))
|
||||||
|
|
||||||
|
(defn- process-mint-activity
|
||||||
|
[{:keys [symbol-in amount-in chain-id-in]} activity chain-id->network-name]
|
||||||
|
(let [network-name (chain-id->network-name chain-id-in)]
|
||||||
|
(assoc activity
|
||||||
|
:transaction :mint
|
||||||
|
;:token symbol-in
|
||||||
|
;:amount (activity-amount amount-in)
|
||||||
|
:network-name network-name
|
||||||
|
:network-logo (quo.resources/get-network network-name)
|
||||||
|
)))
|
||||||
|
|
||||||
(defn- process-activity-by-type
|
(defn- process-activity-by-type
|
||||||
[chain-id->network-name
|
[chain-id->network-name
|
||||||
{:keys [activity-type activity-status timestamp sender recipient] :as data}]
|
{:keys [activity-type activity-status timestamp sender recipient] :as data}]
|
||||||
|
@ -60,6 +71,9 @@
|
||||||
constants/wallet-activity-type-receive
|
constants/wallet-activity-type-receive
|
||||||
(process-receive-activity data activity chain-id->network-name)
|
(process-receive-activity data activity chain-id->network-name)
|
||||||
|
|
||||||
|
#_#_constants/wallet-activity-type-mint
|
||||||
|
(process-mint-activity data activity chain-id->network-name)
|
||||||
|
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
|
@ -69,9 +83,11 @@
|
||||||
:<- [:wallet/network-details]
|
:<- [:wallet/network-details]
|
||||||
(fn [[activities current-viewing-account-address network-details]]
|
(fn [[activities current-viewing-account-address network-details]]
|
||||||
(let [chain-id->network-name (update-vals (group-by :chain-id network-details)
|
(let [chain-id->network-name (update-vals (group-by :chain-id network-details)
|
||||||
(comp :network-name first))]
|
(comp :network-name first))
|
||||||
(->> current-viewing-account-address
|
address-activities (->> (get activities current-viewing-account-address)
|
||||||
(get activities)
|
(vals)
|
||||||
|
(sort :timestamp))]
|
||||||
|
(->> address-activities
|
||||||
(keep #(process-activity-by-type chain-id->network-name %))
|
(keep #(process-activity-by-type chain-id->network-name %))
|
||||||
(group-by (fn [{:keys [timestamp]}]
|
(group-by (fn [{:keys [timestamp]}]
|
||||||
(datetime/timestamp->relative-short-date (* timestamp 1000))))
|
(datetime/timestamp->relative-short-date (* timestamp 1000))))
|
||||||
|
|
|
@ -44,8 +44,9 @@
|
||||||
:<- [:wallet/all-activities]
|
:<- [:wallet/all-activities]
|
||||||
:<- [:wallet/current-viewing-account-address]
|
:<- [:wallet/current-viewing-account-address]
|
||||||
(fn [[all-activities current-viewing-account-address]]
|
(fn [[all-activities current-viewing-account-address]]
|
||||||
(let [address-activity (get all-activities current-viewing-account-address)]
|
(let [address-activity (vals (get all-activities current-viewing-account-address))]
|
||||||
(->> address-activity
|
(->> address-activity
|
||||||
|
(sort :timestamp)
|
||||||
(keep (fn [{:keys [activity-type recipient]}]
|
(keep (fn [{:keys [activity-type recipient]}]
|
||||||
(when (= constants/wallet-activity-type-send activity-type)
|
(when (= constants/wallet-activity-type-send activity-type)
|
||||||
recipient)))
|
recipient)))
|
||||||
|
|
Loading…
Reference in New Issue