WIP
This commit is contained in:
parent
88b97d1151
commit
fa68ce464a
|
@ -32,13 +32,31 @@
|
|||
{:event :wallet/fetch-activities-for-current-account
|
||||
:params request-params}]}]]]})))
|
||||
|
||||
(def activity-transaction-id (comp hash :transaction))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/activity-filtering-for-current-account-done
|
||||
(fn [{:keys [db]} [{:keys [message]}]]
|
||||
(let [address (-> db :wallet :current-viewing-account-address)
|
||||
activities (->> message
|
||||
(transforms/json->clj)
|
||||
(:activities)
|
||||
(cske/transform-keys transforms/->kebab-case-keyword))
|
||||
sorted-activities (sort :timestamp activities)]
|
||||
{:db (assoc-in db [:wallet :activities address] sorted-activities)})))
|
||||
(let [address (-> db :wallet :current-viewing-account-address)
|
||||
activities (->> message
|
||||
(transforms/json->clj)
|
||||
(:activities)
|
||||
(cske/transform-keys transforms/->kebab-case-keyword))
|
||||
activities-indexed (zipmap (map activity-transaction-id 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}
|
||||
: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
|
||||
[{:keys [transaction] :as activity}]
|
||||
(case transaction
|
||||
(:send :receive) [send-and-receive-activity activity]
|
||||
;:mint [mint-activity activity]
|
||||
nil))
|
||||
|
||||
(defn view
|
||||
|
|
|
@ -41,4 +41,7 @@
|
|||
[[:dispatch
|
||||
[:wallet/activity-filtering-for-current-account-done
|
||||
(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)))))
|
||||
|
|
|
@ -45,6 +45,17 @@
|
|||
:network-name 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
|
||||
[chain-id->network-name
|
||||
{:keys [activity-type activity-status timestamp sender recipient] :as data}]
|
||||
|
@ -60,6 +71,9 @@
|
|||
constants/wallet-activity-type-receive
|
||||
(process-receive-activity data activity chain-id->network-name)
|
||||
|
||||
#_#_constants/wallet-activity-type-mint
|
||||
(process-mint-activity data activity chain-id->network-name)
|
||||
|
||||
nil)))
|
||||
|
||||
(rf/reg-sub
|
||||
|
@ -69,9 +83,11 @@
|
|||
:<- [:wallet/network-details]
|
||||
(fn [[activities current-viewing-account-address network-details]]
|
||||
(let [chain-id->network-name (update-vals (group-by :chain-id network-details)
|
||||
(comp :network-name first))]
|
||||
(->> current-viewing-account-address
|
||||
(get activities)
|
||||
(comp :network-name first))
|
||||
address-activities (->> (get activities current-viewing-account-address)
|
||||
(vals)
|
||||
(sort :timestamp))]
|
||||
(->> address-activities
|
||||
(keep #(process-activity-by-type chain-id->network-name %))
|
||||
(group-by (fn [{:keys [timestamp]}]
|
||||
(datetime/timestamp->relative-short-date (* timestamp 1000))))
|
||||
|
|
|
@ -44,8 +44,9 @@
|
|||
:<- [:wallet/all-activities]
|
||||
:<- [:wallet/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
|
||||
(sort :timestamp)
|
||||
(keep (fn [{:keys [activity-type recipient]}]
|
||||
(when (= constants/wallet-activity-type-send activity-type)
|
||||
recipient)))
|
||||
|
|
Loading…
Reference in New Issue