[WIP] Wallet Activity
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
parent
f708cdcf50
commit
30efa275c3
|
@ -492,3 +492,25 @@
|
|||
(def ^:const status-hostname "status.app")
|
||||
|
||||
(def ^:const community-joined-notification-type "communityJoined")
|
||||
|
||||
(def ^:const wallet-activity-error-code-success 1)
|
||||
(def ^:const wallet-activity-error-code-task-canceled 2)
|
||||
(def ^:const wallet-activity-error-code-failed 3)
|
||||
|
||||
(def ^:const wallet-activity-type-send 0)
|
||||
(def ^:const wallet-activity-type-receive 1)
|
||||
(def ^:const wallet-activity-type-buy 2)
|
||||
(def ^:const wallet-activity-type-swap 3)
|
||||
(def ^:const wallet-activity-type-bridge 4)
|
||||
(def ^:const wallet-activity-type-contract-deployment 5)
|
||||
(def ^:const wallet-activity-type-mint 6)
|
||||
|
||||
(def ^:const wallet-activity-status-failed 0)
|
||||
(def ^:const wallet-activity-status-pending 1)
|
||||
(def ^:const wallet-activity-status-complete 2)
|
||||
(def ^:const wallet-activity-status-finalized 3)
|
||||
|
||||
(def ^:const wallet-activity-token-type-native 0)
|
||||
(def ^:const wallet-activity-token-type-erc-20 1)
|
||||
(def ^:const wallet-activity-token-type-erc-721 2)
|
||||
(def ^:const wallet-activity-token-type-erc-1155 3)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
[options-drawer/view
|
||||
{:name (:name collectible-details)
|
||||
:image (:uri preview-url)}])}]))}]
|
||||
:activity [activity/view]
|
||||
:activity [activity/view {:activities []}]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
|
|
|
@ -16,16 +16,15 @@
|
|||
item)]])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [theme]}]
|
||||
(let [activity-list []]
|
||||
(if (empty? activity-list)
|
||||
[empty-tab/view
|
||||
{:title (i18n/label :t/no-activity)
|
||||
:description (i18n/label :t/empty-tab-description)
|
||||
:image (resources/get-themed-image :no-activity theme)}]
|
||||
[rn/flat-list
|
||||
{:data activity-list
|
||||
:style {:flex 1}
|
||||
:render-fn activity-item}])))
|
||||
[{:keys [theme activity-list]}]
|
||||
(if (empty? activity-list)
|
||||
[empty-tab/view
|
||||
{:title (i18n/label :t/no-activity)
|
||||
:description (i18n/label :t/empty-tab-description)
|
||||
:image (resources/get-themed-image :no-activity theme)}]
|
||||
[rn/flat-list
|
||||
{:data activity-list
|
||||
:style {:flex 1}
|
||||
:render-fn activity-item}]))
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.contexts.wallet.events
|
||||
(:require
|
||||
[camel-snake-kebab.extras :as cske]
|
||||
[clojure.string :as string]
|
||||
[react-native.background-timer :as background-timer]
|
||||
[react-native.platform :as platform]
|
||||
|
@ -10,6 +11,7 @@
|
|||
[status-im.contexts.wallet.item-types :as item-types]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.collection]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.ethereum.eip.eip55 :as eip55]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.number]
|
||||
|
@ -63,6 +65,7 @@
|
|||
(utils.collection/index-by :address (data-store/rpc->accounts wallet-accounts)))
|
||||
:fx [[:dispatch [:wallet/get-wallet-token]]
|
||||
[:dispatch [:wallet/request-collectibles-for-all-accounts {:new-request? true}]]
|
||||
[:dispatch [:wallet/check-recent-history]]
|
||||
(when new-account?
|
||||
[:dispatch [:wallet/navigate-to-new-account navigate-to-account]])]})))
|
||||
|
||||
|
@ -392,6 +395,20 @@
|
|||
{:error %
|
||||
:event :wallet/start-wallet})}]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/check-recent-history
|
||||
(fn [{:keys [db]}]
|
||||
(let [addresses (->> (get-in db [:wallet :accounts])
|
||||
vals
|
||||
(map :address))
|
||||
chain-ids (chain/chain-ids db)]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_checkRecentHistoryForChainIDs"
|
||||
:params [chain-ids addresses]
|
||||
:on-error #(log/info "failed to check recent history"
|
||||
{:error %
|
||||
:event :wallet/check-recent-history})}]]]})))
|
||||
|
||||
(rf/reg-event-fx :wallet/initialize
|
||||
(fn []
|
||||
{:fx [[:dispatch [:wallet/start-wallet]]
|
||||
|
@ -477,3 +494,45 @@
|
|||
{:db (update-in db [:wallet :ui :network-filter :selected-networks] update-fn network-name)})))
|
||||
|
||||
(rf/reg-event-fx :wallet/update-selected-networks update-selected-networks)
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/fetch-activities
|
||||
(fn [{:keys [db]}]
|
||||
(let [addresses (->> (get-in db [:wallet :accounts])
|
||||
vals
|
||||
(map :address))
|
||||
chain-ids (chain/chain-ids db)
|
||||
request-id 0
|
||||
filters {:period {:startTimestamp 0
|
||||
:endTimestamp 0}
|
||||
:types []
|
||||
:statuses []
|
||||
:counterpartyAddresses []
|
||||
:assets []
|
||||
:collectibles []
|
||||
:filterOutAssets false
|
||||
:filterOutCollectibles false}
|
||||
offset 0
|
||||
limit 20
|
||||
request-params [request-id
|
||||
addresses
|
||||
chain-ids
|
||||
filters
|
||||
offset
|
||||
limit]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{;; This method is deprecated and will be replaced by
|
||||
;; "wallet_startActivityFilterSession"
|
||||
:method "wallet_filterActivityAsync"
|
||||
:params request-params
|
||||
:on-error #(log/info "failed to fetch activities"
|
||||
{:error %
|
||||
:event :wallet/fetch-activities})}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/activity-filtering-done
|
||||
(fn [{:keys [db]} [{:keys [message]}]]
|
||||
(let [{:keys [activities]} (transforms/json->clj message)
|
||||
activities (cske/transform-keys transforms/->kebab-case-keyword activities)
|
||||
sorted-activities (sort :timestamp activities)]
|
||||
{:db (assoc-in db [:wallet :activities] sorted-activities)})))
|
||||
|
|
|
@ -34,4 +34,4 @@
|
|||
:on-end-reached request-collectibles
|
||||
:on-collectible-press (fn [{:keys [id]}]
|
||||
(rf/dispatch [:wallet/get-collectible-details id]))}]
|
||||
[activity/view])]))
|
||||
[activity/view {:activities []}])]))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[status-im.contexts.wallet.home.style :as style]
|
||||
[status-im.contexts.wallet.home.tabs.view :as tabs]
|
||||
[status-im.contexts.wallet.sheets.network-filter.view :as network-filter]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -76,5 +77,9 @@
|
|||
:size 32
|
||||
:default-active selected-tab
|
||||
:data tabs-data
|
||||
:on-change #(set-selected-tab %)}]
|
||||
:on-change (fn [tab]
|
||||
(when (and (ff/enabled? ::ff/wallet.activities)
|
||||
(= :activity tab))
|
||||
(rf/dispatch [:wallet/fetch-activities]))
|
||||
(set-selected-tab tab))}]
|
||||
[tabs/view {:selected-tab selected-tab}]]))
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
"wallet-blockchain-status-changed" {:fx [[:dispatch
|
||||
[:wallet/blockchain-status-changed
|
||||
(transforms/js->clj event-js)]]]}
|
||||
"wallet-activity-filtering-done" {:fx [[:dispatch
|
||||
[:wallet/activity-filtering-done
|
||||
(transforms/js->clj event-js)]]]}
|
||||
(log/debug ::unknown-wallet-event
|
||||
:type event-type
|
||||
:event (transforms/js->clj event-js))))))
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)
|
||||
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
|
||||
::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)
|
||||
::wallet.contacts (enabled-in-env? :FLAG_CONTACTS_ENABLED)}))
|
||||
::wallet.contacts (enabled-in-env? :FLAG_CONTACTS_ENABLED)
|
||||
::wallet.activities (enabled-in-env? :FLAG_WALLET_ACTIVITY_ENABLED)}))
|
||||
|
||||
(defn feature-flags [] @feature-flags-config)
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
(ns status-im.subs.wallet.activities
|
||||
(:require [re-frame.core :as rf]))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/all-activities
|
||||
:<- [:wallet]
|
||||
:-> :activities)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/activities-for-current-viewing-account
|
||||
:<- [:wallet/all-activities]
|
||||
:<- [:wallet/current-viewing-account-address]
|
||||
(fn [[activities current-viewing-account-address]]
|
||||
(filter (fn [{:keys [sender recipient]}]
|
||||
(or (= sender current-viewing-account-address)
|
||||
(= recipient current-viewing-account-address)))
|
||||
activities)))
|
Loading…
Reference in New Issue