-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(wallet)_: Send flow from saved address and QR scanner #21899
Open
smohamedjavid
wants to merge
1
commit into
develop
Choose a base branch
from
fix/general-send-flow
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−50
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,71 +4,78 @@ | |
[quo.core :as quo] | ||
[react-native.core :as rn] | ||
[react-native.safe-area :as safe-area] | ||
[status-im.common.events-helper :as events-helper] | ||
[status-im.common.floating-button-page.view :as floating-button-page] | ||
[status-im.contexts.wallet.collectible.utils :as collectible-utils] | ||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher] | ||
[status-im.contexts.wallet.send.from.style :as style] | ||
[status-im.setup.hot-reload :as hot-reload] | ||
[utils.i18n :as i18n] | ||
[utils.money :as money] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn- on-account-press | ||
[address network-details collectible-tx?] | ||
[address network-details no-tx-type? collectible-tx?] | ||
(rf/dispatch [:wallet/select-from-account | ||
{:address address | ||
:network-details network-details | ||
:stack-id :screen/wallet.select-from | ||
:start-flow? (not collectible-tx?)}])) | ||
:start-flow? (not (or no-tx-type? collectible-tx?))}])) | ||
|
||
(defn- on-close | ||
[] | ||
(rf/dispatch [:wallet/clean-selected-collectible {:ignore-entry-point? true}]) | ||
(rf/dispatch [:wallet/clean-current-viewing-account])) | ||
|
||
(defn- render-fn | ||
[item _ _ {:keys [network-details collectible-tx? collectible]}] | ||
[item _ _ {:keys [no-tx-type? network-details collectible-tx? collectible]}] | ||
(let [account-address (:address item) | ||
balance (if collectible-tx? | ||
(collectible-utils/collectible-balance collectible account-address) | ||
(string/replace-first (:asset-pay-balance item) "<" "")) | ||
balance (cond | ||
no-tx-type? 0 | ||
collectible-tx? (collectible-utils/collectible-balance collectible | ||
account-address) | ||
:else (string/replace-first (:asset-pay-balance item) "<" "")) | ||
has-balance? (money/above-zero? balance) | ||
asset-symbol (if collectible-tx? "" (:asset-pay-symbol item)) | ||
asset-value (if collectible-tx? (str balance) (:asset-pay-balance item))] | ||
[quo/account-item | ||
{:type (if has-balance? :tag :default) | ||
:on-press #(on-account-press account-address network-details collectible-tx?) | ||
:state (if has-balance? :default :disabled) | ||
:token-props {:symbol asset-symbol | ||
:value asset-value} | ||
:on-press #(on-account-press account-address network-details no-tx-type? collectible-tx?) | ||
:state (if (or has-balance? no-tx-type?) :default :disabled) | ||
:token-props (when-not no-tx-type? | ||
{:symbol asset-symbol | ||
:value asset-value}) | ||
:account-props item}])) | ||
|
||
(defn view | ||
[] | ||
(let [collectible-tx? (rf/sub [:wallet/send-tx-type-collectible?]) | ||
(let [no-tx-type? (nil? (rf/sub [:wallet/wallet-send-tx-type])) | ||
collectible-tx? (rf/sub [:wallet/send-tx-type-collectible?]) | ||
token-symbol (rf/sub [:wallet/send-token-symbol]) | ||
token (rf/sub [:wallet/token-by-symbol-from-first-available-account-with-balance | ||
token-symbol]) | ||
collectible (rf/sub [:wallet/wallet-send-collectible]) | ||
accounts (if collectible-tx? | ||
accounts (if (or no-tx-type? collectible-tx?) | ||
(rf/sub [:wallet/operable-accounts]) | ||
(rf/sub [:wallet/accounts-with-balances token])) | ||
network-details (rf/sub [:wallet/network-details])] | ||
(hot-reload/use-safe-unmount on-close) | ||
[floating-button-page/view | ||
{:footer-container-padding 0 | ||
:header [account-switcher/view | ||
{:on-press #(rf/dispatch [:navigate-back]) | ||
:margin-top (safe-area/get-top) | ||
:switcher-type :select-account}]} | ||
:header [quo/page-nav | ||
{:type :no-title | ||
:icon-name :i/close | ||
:on-press events-helper/navigate-back | ||
:margin-top (safe-area/get-top) | ||
:background :blur}]} | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need account switcher on the from page |
||
[quo/page-top | ||
{:title (i18n/label :t/from-label) | ||
:title-accessibility-label :title-label}] | ||
[rn/flat-list | ||
{:style style/accounts-list | ||
:content-container-style style/accounts-list-container | ||
:data accounts | ||
:render-data {:network-details network-details | ||
:render-data {:no-tx-type? no-tx-type? | ||
:network-details network-details | ||
:collectible-tx? collectible-tx? | ||
:collectible collectible} | ||
:render-fn render-fn | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We clean the send data before user goes into the flow. This ensure no data from any other flows is left and also to prevent any bugs.