-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wallet: activity items (#19847) --------- Co-authored-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
- Loading branch information
1 parent
de29c6f
commit 9187ec2
Showing
17 changed files
with
230 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/status_im/contexts/wallet/common/activity_tab/constants.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
(ns status-im.contexts.wallet.common.activity-tab.constants) | ||
|
||
|
||
(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-confirmed 2) | ||
(def ^:const wallet-activity-status-finalised 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) | ||
|
||
(def ^:const wallet-activity-id->name | ||
{wallet-activity-type-send :send | ||
wallet-activity-type-receive :receive | ||
wallet-activity-type-buy :buy | ||
wallet-activity-type-swap :swap | ||
wallet-activity-type-bridge :bridge | ||
wallet-activity-type-contract-deployment :contract-deployment | ||
wallet-activity-type-mint :mint}) | ||
|
||
(def ^:const wallet-activity-status->name | ||
{wallet-activity-status-failed :failed | ||
wallet-activity-status-pending :pending | ||
wallet-activity-status-confirmed :confirmed | ||
wallet-activity-status-finalised :finalised}) | ||
|
||
(def ^:const second-tag-prefix | ||
{wallet-activity-type-send :t/from | ||
wallet-activity-type-receive :t/from | ||
wallet-activity-type-buy :t/on | ||
wallet-activity-type-swap :t/to | ||
wallet-activity-type-bridge :t/from | ||
wallet-activity-type-contract-deployment :t/via | ||
wallet-activity-type-mint :t/at}) | ||
|
||
(def ^:const third-tag-prefix | ||
{wallet-activity-type-send :t/to | ||
wallet-activity-type-receive :t/to | ||
wallet-activity-type-buy :t/to | ||
wallet-activity-type-swap :t/on | ||
wallet-activity-type-bridge :t/to | ||
wallet-activity-type-contract-deployment :t/on | ||
wallet-activity-type-mint :t/via}) | ||
|
||
(def ^:const fourth-tag-prefix | ||
{wallet-activity-type-send :t/via | ||
wallet-activity-type-receive :t/via | ||
wallet-activity-type-buy :t/via | ||
wallet-activity-type-swap :t/via | ||
wallet-activity-type-bridge :t/in}) | ||
|
65 changes: 54 additions & 11 deletions
65
src/status_im/contexts/wallet/common/activity_tab/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,73 @@ | ||
(ns status-im.contexts.wallet.common.activity-tab.view | ||
(:require | ||
[legacy.status-im.utils.hex :as utils.hex] | ||
[native-module.core :as native-module] | ||
[quo.core :as quo] | ||
[quo.foundations.resources :as quo.resources] | ||
[quo.theme] | ||
[react-native.core :as rn] | ||
[status-im.common.resources :as resources] | ||
[status-im.contexts.shell.jump-to.constants :as jump-to.constants] | ||
[status-im.contexts.wallet.common.activity-tab.constants :as constants] | ||
[status-im.contexts.wallet.common.empty-tab.view :as empty-tab] | ||
[utils.i18n :as i18n])) | ||
[utils.datetime :as datetime] | ||
[utils.ethereum.chain :as chain] | ||
[utils.i18n :as i18n] | ||
[utils.money :as money] | ||
[utils.re-frame :as rf])) | ||
|
||
(def precision 6) | ||
|
||
(defn activity-item | ||
[item] | ||
[:<> | ||
[quo/divider-date (:date item)] | ||
[quo/wallet-activity | ||
(merge {:on-press #(js/alert "Item pressed")} | ||
item)]]) | ||
[{:keys [activity-type activity-status timestamp symbol-out symbol-in token-in token-out amount-in | ||
amount-out sender recipient]}] | ||
(let [chain-id (or (:chain-id token-in) (:chain-id token-out)) | ||
amount-in-units (native-module/hex-to-number | ||
(utils.hex/normalize-hex amount-in)) | ||
amount-in-value (money/with-precision | ||
(money/wei->ether amount-in-units) | ||
precision) | ||
amount-out-units (native-module/hex-to-number | ||
(utils.hex/normalize-hex amount-out)) | ||
amount-out-value (money/with-precision | ||
(money/wei->ether amount-out-units) | ||
precision) | ||
relative-date (datetime/timestamp->relative (* timestamp 1000)) | ||
receiving-activity? (= activity-type constants/wallet-activity-type-receive)] | ||
[quo/wallet-activity | ||
{:transaction (constants/wallet-activity-id->name activity-type) | ||
:timestamp relative-date | ||
:status (constants/wallet-activity-status->name activity-status) | ||
:counter 1 | ||
:first-tag {:size 24 | ||
:type :token | ||
:token (or symbol-out symbol-in) | ||
:amount (if receiving-activity? amount-in-value amount-out-value)} | ||
:second-tag-prefix (constants/second-tag-prefix activity-type) | ||
:second-tag {:type :address | ||
:address (if receiving-activity? recipient sender)} | ||
:third-tag-prefix (constants/third-tag-prefix activity-type) | ||
:third-tag {:type :address | ||
:address (if receiving-activity? sender recipient)} | ||
:fourth-tag-prefix (constants/fourth-tag-prefix activity-type) | ||
:fourth-tag {:size 24 | ||
:type :network | ||
:network-logo (quo.resources/get-network (chain/chain-id->chain-keyword | ||
chain-id)) | ||
:network-name (chain/chain-id->chain-name chain-id)} | ||
:blur? false}])) | ||
|
||
(defn view | ||
[] | ||
(let [theme (quo.theme/use-theme) | ||
activity-list []] | ||
activity-list (rf/sub [:wallet/activities-for-current-viewing-account])] | ||
(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}]))) | ||
{:data activity-list | ||
:style {:flex 1} | ||
:content-container-style {:padding-bottom jump-to.constants/floating-shell-button-height} | ||
:render-fn activity-item}]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.