-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet)_: Activity - clean up, moved to new session rpc and adde…
…d bridge, swap and approval types status-im/status-go@906c50b...27f2b93 Signed-off-by: Mohamed Javid <[email protected]>
- Loading branch information
1 parent
60911a1
commit ffd3d65
Showing
22 changed files
with
605 additions
and
440 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
104 changes: 104 additions & 0 deletions
104
src/status_im/contexts/wallet/common/activity_tab/activity_types/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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
(ns status-im.contexts.wallet.common.activity-tab.activity-types.view | ||
(:require [quo.core :as quo] | ||
[status-im.contexts.wallet.common.activity-tab.options.view :as activity-options] | ||
[utils.re-frame :as rf])) | ||
|
||
;; Common helpers | ||
(defn- open-options | ||
[transactions] | ||
(rf/dispatch | ||
[:show-bottom-sheet | ||
{:content #(activity-options/view (first transactions))}])) | ||
|
||
(defn- common-activity-props | ||
[{:keys [tx-type relative-date status transactions]}] | ||
{:transaction tx-type | ||
:timestamp relative-date | ||
:status status | ||
:blur? false | ||
:on-press-options #(open-options transactions)}) | ||
|
||
(defn- network-tag | ||
[{:keys [network-name network-logo]}] | ||
{:type :network | ||
:network-name network-name | ||
:network-logo network-logo}) | ||
|
||
(defn- collectible-tag | ||
[{:keys [nft-url nft-name amount token-id]}] | ||
{:type :collectible | ||
:collectible nft-url | ||
:collectible-name (if (> amount 1) | ||
(str amount " " nft-name) | ||
nft-name) | ||
:collectible-number (when (not= token-id "0") | ||
token-id)}) | ||
|
||
(defn- token-tag | ||
[{:keys [token amount]}] | ||
{:type :token | ||
:token token | ||
:amount amount}) | ||
|
||
;; Activity type views | ||
(defn send-activity | ||
[{:keys [symbol-out amount-out token-id sender-tag recipient-tag network-name-out network-logo-out] | ||
:as activity-data}] | ||
(let [base-props (common-activity-props activity-data) | ||
first-tag (if token-id | ||
(collectible-tag activity-data) | ||
(token-tag {:token symbol-out :amount amount-out}))] | ||
[quo/wallet-activity | ||
(assoc base-props | ||
:first-tag first-tag | ||
:second-tag-prefix :t/from | ||
:second-tag sender-tag | ||
:third-tag-prefix :t/to | ||
:third-tag recipient-tag | ||
:fourth-tag-prefix :t/on | ||
:fourth-tag (network-tag {:network-name network-name-out | ||
:network-logo network-logo-out}))])) | ||
|
||
(defn bridge-activity | ||
[{:keys [symbol-out amount-out network-name-out network-logo-out network-name-in network-logo-in | ||
sender-tag] | ||
:as activity-data}] | ||
[quo/wallet-activity | ||
(assoc (common-activity-props activity-data) | ||
:first-tag (token-tag {:token symbol-out :amount amount-out}) | ||
:second-tag-prefix :t/from | ||
:second-tag (network-tag {:network-name network-name-out | ||
:network-logo network-logo-out}) | ||
:third-tag-prefix :t/to | ||
:third-tag (network-tag {:network-name network-name-in | ||
:network-logo network-logo-in}) | ||
:fourth-tag-prefix :t/in | ||
:fourth-tag sender-tag)]) | ||
|
||
(defn swap-activity | ||
[{:keys [symbol-out amount-out symbol-in amount-in sender-tag network-name-out network-logo-out] | ||
:as activity-data}] | ||
[quo/wallet-activity | ||
(assoc (common-activity-props activity-data) | ||
:first-tag (token-tag {:token symbol-out :amount amount-out}) | ||
:second-tag-prefix :t/to | ||
:second-tag (token-tag {:token symbol-in :amount amount-in}) | ||
:third-tag-prefix :t/in | ||
:third-tag sender-tag | ||
:fourth-tag-prefix :t/on | ||
:fourth-tag (network-tag {:network-name network-name-out | ||
:network-logo network-logo-out}))]) | ||
|
||
(defn approval-activity | ||
[{:keys [symbol-out amount-out sender-tag spender-tag network-name-out network-logo-out] | ||
:as activity-data}] | ||
[quo/wallet-activity | ||
(assoc (common-activity-props activity-data) | ||
:first-tag (token-tag {:token symbol-out :amount amount-out}) | ||
:second-tag-prefix :t/in | ||
:second-tag sender-tag | ||
:third-tag-prefix :t/for | ||
:third-tag spender-tag | ||
:fourth-tag-prefix :t/on | ||
:fourth-tag (network-tag {:network-name network-name-out | ||
:network-logo network-logo-out}))]) |
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.