Compare commits

...
Author SHA1 Message Date
Omar Basem 72aacbd461 en 2024-04-29 10:35:34 +04:00
Omar Basem 7025353f92 lint 2024-04-26 11:38:34 +04:00
Mohamed Javid d107f34873 [WIP] Wallet Activity
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
2024-04-26 11:36:16 +04:00
14 changed files with 141 additions and 20 deletions
+1 -1
View File
@@ -277,7 +277,7 @@ run-android: export ORG_GRADLE_PROJECT_hermesEnabled := false
run-android: ##@run Build Android APK and start it on the device
@scripts/run-android.sh
SIMULATOR=iPhone 13
SIMULATOR=iPhone 15
# TODO: fix IOS_STATUS_GO_TARGETS to be either amd64 or arm64 when RN is upgraded
run-ios: export TARGET := ios
run-ios: export IOS_STATUS_GO_TARGETS := ios/arm64;iossimulator/amd64
+2 -2
View File
@@ -1429,11 +1429,11 @@ SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
BVLinearGradient: 612a04ff38e8480291f3379ee5b5a2c571f03fe0
CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 56e0e498dbb513b96c40bac6284729ba4e62672d
FBReactNativeSpec: 146c741a3f40361f6bc13a4ba284678cbedb5881
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 530710e7949eb12c82670bd09e946becf50a3c2a
glog: cf171f517b828fdde711287b723e348da1ea0fc3
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
+10 -2
View File
@@ -1236,7 +1236,11 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
@@ -1323,7 +1327,11 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
+22
View File
@@ -493,3 +493,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)
@@ -5,7 +5,8 @@
[react-native.core :as rn]
[status-im.common.resources :as resources]
[status-im.contexts.wallet.common.empty-tab.view :as empty-tab]
[utils.i18n :as i18n]))
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn activity-item
[item]
@@ -18,7 +19,10 @@
(defn view
[]
(let [theme (quo.theme/use-theme)
activity-list []]
activity-list []
data (rf/sub [:wallet/activities-for-current-viewing-account])
]
(println "dataxxx" data)
(if (empty? activity-list)
[empty-tab/view
{:title (i18n/label :t/no-activity)
+61
View File
@@ -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]])]})))
@@ -394,6 +397,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]]
@@ -479,3 +496,47 @@
{: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]}]
(println "fetching activitiesxxxx")
(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-success #(println "aaaaa" %)
: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 []}])]))
+5 -1
View File
@@ -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,8 @@
:size 32
:default-active selected-tab
:data tabs-data
:on-change #(set-selected-tab %)}]
:on-change (fn [tab]
(when (= :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))))))
+2 -1
View File
@@ -18,7 +18,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)
+1
View File
@@ -14,6 +14,7 @@
status-im.subs.pairing
status-im.subs.profile
status-im.subs.shell
status-im.subs.wallet.activities
status-im.subs.wallet.collectibles
status-im.subs.wallet.networks
status-im.subs.wallet.saved-addresses
+17
View File
@@ -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)))
+9 -9
View File
@@ -480,7 +480,7 @@
"enter-channel": "Enter channel",
"profile-deleted-title": "Profile deleted",
"profile-deleted-content": "Your profile was successfully deleted",
"profile-deleted-keycard": "You can now restore another keypair on your Keycard",
"profile-deleted-keycard": "You can now restore another key pair on your Keycard",
"deny": "Deny",
"description": "Description",
"dev-mode": "Development mode",
@@ -833,7 +833,7 @@
"keycard-factory-reset-title": "Are you sure you want to perform a factory reset?",
"keycard-factory-reset-text": "Performing this will delete any mnemonic phrase stored on the card. Make sure you have a backup of the mnemonic phrase you've been using with this Keycard.",
"keycard-enter-new-passcode": "Enter new passcode {{step}}/2",
"keycard-has-multiaccount-on-it": "This card is full. Each card can hold one main keypair",
"keycard-has-multiaccount-on-it": "This card is full. Each card can hold one main key pair",
"keycard-onboarding-finishing-header": "Finishing up",
"keycard-onboarding-intro-header": "Store your keys on Keycard",
"keycard-onboarding-intro-text": "Get ready, this might take a few minutes, but it's important to secure your account",
@@ -2372,7 +2372,7 @@
"bridge-to": "Bridge {{name}} to",
"on-device": "On device",
"on-keycard": "On Keycard",
"keypair-title": "{{name}}'s default keypair",
"keypair-title": "{{name}}'s default key pair",
"about": "About",
"no-permissions": "No permissions",
"no-dapps": "No connected dApps",
@@ -2384,7 +2384,7 @@
"colour": "Colour",
"origin": "Origin",
"slide-to-sign": "Slide to sign",
"user-keypair": "{{name}}'s Keypair",
"user-keypair": "{{name}}'s Key pair",
"trip-accounts": "Trip accounts",
"destroy": "Destroy",
"mint": "Mint",
@@ -2464,8 +2464,8 @@
"address-no-activity": "This address has no activity",
"scanning": "Scanning for activity...",
"keypairs": "Keypairs",
"keypairs-accounts-and-addresses": "Keypairs, accounts and addresses",
"keypairs-description": "Select keypair to derive your new account from",
"keypairs-accounts-and-addresses": "Key pairs, accounts and addresses",
"keypairs-description": "Select key pair to derive your new account from",
"confirm-account-origin": "Confirm account origin",
"confirmed-on": "Confirmed on",
"pending-on": "Pending on",
@@ -2487,7 +2487,7 @@
"est-time": "Est. time",
"user-gets": "{{name}} gets",
"slide-to-send": "Slide to send",
"generate-new-keypair": "Generate new keypair",
"generate-new-keypair": "Generate new key pair",
"import-using-phrase": "Import using recovery phrase",
"import-from-keycard": "Import from Keycard",
"import-private-key": "Import private key",
@@ -2520,7 +2520,7 @@
"remove-watched-address-title": "Remove watched address",
"remove-watched-address-desc": "The watched address will be removed from all of your synced devices.",
"remove-account-title": "Remove account",
"remove-account-desc": "The account will be removed from all of your synced devices. Make sure you have a backup of your keypair or recovery phrase and derivation path (if its not default).",
"remove-account-desc": "The account will be removed from all of your synced devices. Make sure you have a backup of your key pair or recovery phrase and derivation path (if its not default).",
"derivation-path-copied": "Derivation path copied",
"remove-account-confirmation": "I have taken note of the derivation path",
"edit-receiver-networks": "Edit receiver networks",
@@ -2545,7 +2545,7 @@
"derivation-path-header": "Derivation path",
"derivation-path-desc": "Derivation paths are the routes your Status Wallet uses to generate addresses from your private key.",
"select-networks": "Select networks",
"generating-keypair": "Generating keypair...",
"generating-keypair": "Generating key pair...",
"keypair-name": "Key pair name",
"keypair-name-description": "Name key pair for your own personal reference",
"keypair-name-input-placeholder": "Collectibles account, Old vault....",