Compare commits

..
Author SHA1 Message Date
alwx 823a683dab Attempt to fix "Undefined is not a function" when declining connection request 2024-07-24 10:32:50 +02:00
Icaro Motta cef1308b3a chore(tests): Allow test-watch-for-repl target to run while the app is running (#20827)
Fix a long standing problem where we can't run in parallel the make target
run-clojure and test-watch-for-repl, or in other words, we can't run tests via
the REPL while the app is running.

Details:

I found out that shadow-cljs fails to build because it does not expand the
environment variables SHADOW_OUTPUT_TO and SHADOW_NS_REGEXP if and only if the
run-clojure target was executed.

This is the top of the stacktrace, and it happens because it doesn't know where
to output the test build because the env var wasn't expanded:

    [build] NullPointerException:
    [build]         shadow.build.node/configure (node.clj:59)
    [build]         shadow.build.node/configure (node.clj:45)
    [build]         shadow.build.targets.node-script/configure (node_script.clj:37)

The solution is to pass the option --config-merge to shadow-cljs and override
both :ns-regexp and :output-to because CLI args override options from env vars
in shadow-cljs.
2024-07-24 00:18:27 -03:00
Icaro Motta 4b8a612df4 chore(docs): Document some of our existing testing practices (#20691)
Document some of our current testing practices in hopes of helping reduce
friction in PRs and communication in general. In theory, nothing in the text
should be a surprise because these are things we have been discussing over many
months (some things for almost 1.5 years) and are already present in the code.
2024-07-23 23:45:14 -03:00
Ulises Manuel e4639c153f feat(wallet): Skip From page while sending an asset only owned by one account (#20773)
- Update tests

- Omit from page while sending a token in home page

- Hide send and bridge option for not owned tokens

- Fix subscription to return accounts owning an asset
2024-07-23 16:08:33 -06:00
Alexander 8597b899bd Remove dApps tab from Wallet (#20818) 2024-07-23 18:57:27 +03:00
John Ngei a5c8182461 fix onboarding navigation to enable notification screen and blur issues (#20725) 2024-07-23 15:18:43 +02:00
mmilad75 89bb3ea5c3 Watch-only collectibles should not be included on the main wallet page by default #20735 (#20761) 2024-07-23 14:45:02 +02:00
Shivek Khurana 3bb7c308e3 🦁 Fix issues with missing dapp images and dapp names (#20811)
* 🦁 Beast mode

* 🗑️ Remove `prn` calls

* 🌎 Add utils to remove http:// prefix

* ⏭️ Extracted name and avatar computation

* 🧹 Cleanup

* ✏️ Fix lint and remove REPL flow

*  Remove broken test

* 🖊️ Fix lint
2024-07-23 17:04:03 +05:30
Parvesh Monu 1a4987478c fix UI elements are misplaced on the 'Sign in by syncing' screen when adding a new profile (#20837) 2024-07-23 16:09:04 +05:30
Parvesh Monu 540094c229 fix Missing 'Mark as read' option on community channels (#20838) 2024-07-22 22:55:50 +05:30
Alexander 08b65cbcb7 Proper handling of disconnection, both from the dapp itself and from the list of connected dapps (#20817) 2024-07-22 15:20:52 +02:00
AlexanderandLungu Cristian d623cc8444 Only show the Wallet Connect requests for the logged in user (#20815)
Co-authored-by: Lungu Cristian <lungucristian95@gmail.com>
2024-07-22 14:57:45 +02:00
Brian Sztamfater 4b7c906df2 feat(swap): set spending cap screen (#20727)
Signed-off-by: Brian Sztamfater <brian@status.im>
2024-07-22 08:50:29 -03:00
Omar Basem 3b446963ef fix: assets sort order on bridge and assets screen (#20813)
* fix: assets sort order on bridge and assets screen (#20813)
2024-07-22 14:16:40 +04:00
64 changed files with 1025 additions and 386 deletions
+5 -1
View File
@@ -353,13 +353,17 @@ test: export SHADOW_NS_REGEXP := .*-test$$
test: ##@test Run all Clojure tests
test: _test-clojure
# Note: we need to override the :output-to and :ns-regexp options because
# shadow-cljs has a bug where it will not read from the env vars to expand the
# configuration when the shadow-cljs mobile target is already running.
test-watch-for-repl: export TARGET := default
test-watch-for-repl: export SHADOW_OUTPUT_TO := target/test/test.js
test-watch-for-repl: export SHADOW_NS_REGEXP := .*-test$$
test-watch-for-repl: ##@test Watch all Clojure tests and support REPL connections
rm -f "$$SHADOW_OUTPUT_TO" && \
yarn install && shadow-cljs compile mocks && \
concurrently --kill-others --prefix-colors 'auto' --names 'build,repl' \
'yarn shadow-cljs watch test --verbose' \
"yarn shadow-cljs watch test --verbose --config-merge '{:output-to \"$(SHADOW_OUTPUT_TO)\" :ns-regexp \"$(SHADOW_NS_REGEXP)\"}'" \
"until [ -f $$SHADOW_OUTPUT_TO ] ; do sleep 1 ; done ; node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO --repl"
test-unit: export SHADOW_OUTPUT_TO := target/unit_test/test.js
+27 -51
View File
@@ -1,67 +1,43 @@
## Getting Started
[Starting Guide](starting-guide.md)
[IDE Setup](ide-setup.md)
## Getting Started
- [Starting Guide](starting-guide.md)
- [IDE Setup](ide-setup.md)
## Development Process
[Coding guidelines](new-guidelines.md)
[UI components coding guidelines](ui-guidelines.md)
[Release Checklist](release-checklist.md)
[Release Guide](release-guide.md)
[Merging PR process](merging-pr-process.md)
[PR Review Policy](pr-review-policy.md)
[Working on PR together with QA team](pipeline_process.md)
[Debugging](debugging.md)
[Patching](patching.md)
[Creating a pixel perfect UI](pixel-perfection.md)
[Contributing to status-go](status-go-changes.md)
[Malli schemas (recorded demo)](https://www.youtube.com/watch?v=SlRio70aYVI) ([slides](files/forging-code-with-schemas-sep-2023-slides.pdf))
- [Coding guidelines](new-guidelines.md)
- [UI components coding guidelines](ui-guidelines.md)
- [Release Checklist](release-checklist.md)
- [Release Guide](release-guide.md)
- [Merging PR process](merging-pr-process.md)
- [PR Review Policy](pr-review-policy.md)
- [Working on PR together with QA team](pipeline_process.md)
- [Debugging](debugging.md)
- [Patching](patching.md)
- [Creating a pixel perfect UI](pixel-perfection.md)
- [Contributing to status-go](status-go-changes.md)
- [Malli schemas (recorded demo)](https://www.youtube.com/watch?v=SlRio70aYVI) ([slides](files/forging-code-with-schemas-sep-2023-slides.pdf))
## Testing
[How to run local tests](testing.md)
[End-to-end tests (e2e) overview](how-to-launch-e2e.md)
[Component tests (jest) overview](component-tests-overview.md)
- [Overview](tests/tests-overview.md)
- [How to run local tests](tests/how-to-run-local-tests.md)
- [End-to-end tests (e2e) overview](tests/how-to-launch-e2e.md)
- [Component tests (jest) overview](tests/component-tests-overview.md)
## Project details
[status-go introduction (recorded meeting)](https://drive.google.com/file/d/1B7TljmTZ8fHkqJH8ChU1Cp4FGDFM03gq/view)
[re-frame usage (recorded meeting)](https://drive.google.com/file/d/1qv_E0CEGzQpu_zGXD0gCTU5EvhC2k8Jy/view)
[status app functionality demo](https://drive.google.com/file/u/0/d/1PmwsMLTLDNNIdv5_6wvMOwoj2PfT50c6/view)
- [status-go introduction (recorded meeting)](https://drive.google.com/file/d/1B7TljmTZ8fHkqJH8ChU1Cp4FGDFM03gq/view)
- [re-frame usage (recorded meeting)](https://drive.google.com/file/d/1qv_E0CEGzQpu_zGXD0gCTU5EvhC2k8Jy/view)
- [status app functionality demo](https://drive.google.com/file/u/0/d/1PmwsMLTLDNNIdv5_6wvMOwoj2PfT50c6/view)
## Misc
[Importing icons from Figma into project](export-icons.md)
[Updating Status APK builds for the F-Droid Android application catalogue](fdroid.md)
[Troubleshooting for known errors](troubleshooting.md)
- [Importing icons from Figma into project](export-icons.md)
- [Updating Status APK builds for the F-Droid Android application catalogue](fdroid.md)
- [Troubleshooting for known errors](troubleshooting.md)
## Outdated:
[Old guidelines](codebase-structure-and-guidelines.md)
[Post mortem analysis](post-mortem.md)
- [Old guidelines](codebase-structure-and-guidelines.md)
- [Post mortem analysis](post-mortem.md)
+9 -9
View File
@@ -32,9 +32,9 @@ Ready for testing, a PR should meet the following criteria:
### E2E tests and analyzing the results
The PR **MUST** be moved to the E2E column when it is ready for testing (**mandatory for all PRs**).
That will also trigger e2e tests run. QAs are monitoring PRs from E2E column and take it into test.
That will also trigger e2e tests run. QAs are monitoring PRs from E2E column and take it into test.
This step cannot be skipped. So, at least one comment from the `status-im-auto` bot with results is a prerequisite for moving forward.
Information on how to analyze tests can be found [here](https://github.com/status-im/status-mobile/blob/develop/doc/how-to-launch-e2e.md).
Information on how to analyze tests can be found [here](https://github.com/status-im/status-mobile/blob/develop/doc/tests/how-to-launch-e2e.md).
Tests might be flaky, as they depend on infrastructure - SauceLabs and Waku.
If there are `Failed tests` and you are not sure about the reason, you can always ping the mobile QAs for help (preferably in PRs by `@status-im/mobile-qa`).
@@ -46,14 +46,14 @@ Please, respect this rule.**
### Adding `skip-manual-qa`
**Do not hesitate to use a `skip-manual-qa`** if you're sure that it is a simple flow and you checked it.
**Do not hesitate to use a `skip-manual-qa`** if you're sure that it is a simple flow and you checked it.
- Please ask another team member before adding the `skip-manual-qa` label (PR/Status community/DMs) so that there's a second opinion.
- The PR MUST have a proper reasoning why manual QA is skipped.
- The PR MUST include the steps of testing that has been done by the developer prior to moving it forward.
**NOTE:** Make sure that QAs are OK with that;
Before merging PRs, please make sure that information is added about how you tested the PRs, that e2s have been passed and their results have been reviewed.
Before merging PRs, please make sure that information is added about how you tested the PRs, that e2s have been passed and their results have been reviewed.
The QA team appreciates your help!
@@ -72,7 +72,7 @@ The QA team appreciates your help!
- QA engineer picks up one of PRs with the ```request-manual-qa``` label, drags the item to the ```IN TESTING``` column and assigns it to themselves.
- During testing, QA will add comments describing the issues found, and also review automation tests results.
Usually found issues are numbered as "Issue 1, Issue 2", etc.
When the first round of testing is completed and all issues for this stage are found, the QA can add the ```Tested - Issues``` label and drag the card to the ```CONTRIBUTOR``` column. These two actions are optional.
When the first round of testing is completed and all issues for this stage are found, the QA can add the ```Tested - Issues``` label and drag the card to the ```CONTRIBUTOR``` column. These two actions are optional.
**IMPORTANT NOTE:** when the issues are fixed, developer **MUST** notify the QA that it is ready to be re-tested again by mention them in the PR.
@@ -86,7 +86,7 @@ After that the developer merges PR into develop.
_**How do I know if a design review is needed?**_
There are three cases here depending on the changes in the PR:
1. **Functional PRs with UI changes:** after the ```Tested - OK``` label is added, the QA moves the PR to the ```Design review``` column + mentions ```@Francesca-G``` in comments.
1. **Functional PRs with UI changes:** after the ```Tested - OK``` label is added, the QA moves the PR to the ```Design review``` column + mentions ```@Francesca-G``` in comments.
2. **Component PRs:** once the PR has received a review from developers and e2e tests results, it can be moved directly to the ```Design review``` column by the developer (manual testing step can be skipped) + the developer mentions ```@Francesca-G``` in comments.
3. **Functional PRs changes in which are not related to UI (e.g. a crash fix):** skip the ```Design review``` step (the PR should only be manually tested by QA).
@@ -99,7 +99,7 @@ There are three possible scenarios when the design review is completed:
**Notes:**
- If your PR has a long story and started from `develop` branch several days ago, please rebase it to current develop before adding label
- if PR can be tested by developer (in case of small changes) and/or developer is sure that the changes made cannot introduce a regression, then PR can be merged without manual testing. Also, currently, PRs are not manually tested if the changes relate only the design (creation of components, etc.) and do not affect the functionality (see `skip-manual-qa` label)
---
---
#### Why my PR is in `Contributor` column?
PR can be moved to this column by the ```status-github-bot``` or by QA engineer with label `Tested-issues` or if one of the requirements for manual QA was not met.
@@ -120,6 +120,6 @@ In the second case - after fixing of all found issues, the developer should ping
6. In case of manual testing - the label ```Tested - OK``` from QA
7. In case of design review - the approval from the designer
You can merge your PR into develop - some useful clues you can find [here](https://notes.status.im/setup-e2e#3-Merging-PR)
You can merge your PR into develop - some useful clues you can find [here](https://notes.status.im/setup-e2e#3-Merging-PR)
HAPPY DEVELOPMENT! :tada:
HAPPY DEVELOPMENT! :tada:
@@ -8,7 +8,7 @@ As a part of CI for Status mobile app and in order to ensure there are no regres
- Automated tests written on Python 3.9 and pytest.
- Appium (server) and Selenium WebDriver (protocol) are the base of test automation framework.
TestRail is a test case management system tool where we have test cases.
TestRail is a test case management system tool where we have test cases.
Each of the test case gets a priority (Critical/High/Medium)
@@ -20,21 +20,21 @@ For now we support e2e for Android only.
Whenever we need to push set of test scripts we create 16 parallel sessions (max, but depending on amount of cases that are included in job) and each thread: 1) uploads Android .apk file to SauceLabs -> 2) runs through the test steps -> 3) receives results whether test failed on particular step or succeeded with no errors -> 3) Parse test results and push them as a Github comment (if the suite ran against respective PR) and into TestRail.
We push **whole automation test suite (currently 155, amount is changing)** against each nightly build (if the nightly builds job succeeded). Results of the test run are saved in TestRail.
And also we push set of autotests whenever PR with successful builds got moved in to `E2E Tests` column from [Pipeline for QA dashboard ](https://github.com/status-im/status-react/projects/7).
And also we push set of autotests whenever PR with successful builds got moved in to `E2E Tests` column from [Pipeline for QA dashboard ](https://github.com/status-im/status-react/projects/7).
In that case we save results in TestRail as well and push a comment with test results in a respective PR.
For example: https://github.com/status-im/status-react/pull/9147#issuecomment-540008770
![](images/how-to-launch-e2e/how-to-launch-e2e-1.png)
![](../images/how-to-launch-e2e/how-to-launch-e2e-1.png)
The test_send_stt_from_wallet opens link in TestRail https://ethstatus.testrail.net/index.php?/tests/view/890885 where performed steps could be found
List of all runs performed by test jobs could be found here https://ethstatus.testrail.net/index.php?/runs/overview/14
List of all runs performed by test jobs could be found here https://ethstatus.testrail.net/index.php?/runs/overview/14
**For credentials for TestRail to see results ping Chu in DM**:
Opening any test run navigates you to list of test cases with results:
![](images/how-to-launch-e2e/how-to-launch-e2e-2.png)
![](../images/how-to-launch-e2e/how-to-launch-e2e-2.png)
## What about launching e2e manually
@@ -53,12 +53,12 @@ Params to specify:
- test_marks: tests by priorities (by default: `critical or high or medium`, which corresponds the whole suite; to launch the same suite as in PRs, use `critical or high`)
- testrail_case_id: here is the list of test cases which you may find in test rail (4-digit value)
For easier access you can hit `Rerun tests` in GH comment and testrail_case_id/ apk_name/ pr_id will be filled automatically. For making sure that tests are being rerun on most recent e2e build it is recommended to paste link to the last e2e build in apk_name field. The list of PR builds can be found in Jenkins Builds block on PR page.
![](images/how-to-launch-e2e/how-to-launch-e2e-3.png)
For easier access you can hit `Rerun tests` in GH comment and testrail_case_id/ apk_name/ pr_id will be filled automatically. For making sure that tests are being rerun on most recent e2e build it is recommended to paste link to the last e2e build in apk_name field. The list of PR builds can be found in Jenkins Builds block on PR page.
![](../images/how-to-launch-e2e/how-to-launch-e2e-3.png)
And then hit Build.
Once the job starts it picks up specified tests, runs them against provided apk and sends results to pull request.
Even we have 16 parallel sessions for testing its a time consuming operation (whole test suite we have automated at the moment takes ~140 minutes to finish).
Even we have 16 parallel sessions for testing its a time consuming operation (whole test suite we have automated at the moment takes ~140 minutes to finish).
So for PRs we pick only set of `critical or high` (you can also use this in TEST_MARKS param for job)
tests (otherwise some PRs could wait their turn of the scheduled Jenkins job till the next day).
@@ -78,9 +78,9 @@ Several examples of when test fails to succeed:
- **Valid issue in the automated test scripts** - that's what we're looking for
Example: here is the test results https://github.com/status-im/status-react/pull/13015#issuecomment-1016495043 where one test failed.
Example: here is the test results https://github.com/status-im/status-react/pull/13015#issuecomment-1016495043 where one test failed.
1. Open the test in TestRail and open session recorded for this test in SauceLabs
![](images/how-to-launch-e2e/how-to-launch-e2e-4.png)
![](../images/how-to-launch-e2e/how-to-launch-e2e-4.png)
In TestRail you may find all the steps performed by the test.
@@ -98,6 +98,6 @@ Not all features of the app could be covered by e2e at the moment:
## Brief flow for test to be automated
Whenever there is a need to have a new test:
1) Create a test scenario in TestRail.
1) Create a test scenario in TestRail.
2) If certain item could be checked in scope of existing test case we update existing one (otherwise we may have thousands of test cases which is overkill to manage in TestRail as well as in automated test scripts). And also complex autotests increase probability to not catch regressions by stopping test execution (due to valid bug or changed feature) keeping the rest test steps uncovered. So here we need to balance when it makes sense to update existing test case with more checks.
3) Then we create test script based on the test case, ensure test passes for the build and pushing the changes to repo.
+167
View File
@@ -0,0 +1,167 @@
# Tests
## Introduction
This document provides a general overview of the types of tests we use and when
to use them. It is not meant to be a tutorial or a detailed documentation about
testing in software development.
## Types of tests
Tests in `status-mobile` are comprised of:
- Unit tests
- Subscription tests
- Event tests
- Tests for various utilities
- [Component tests](./component-tests-overview.md)
- Integration/contract tests
- [End-to-end tests](./how-to-launch-e2e.md)
We apply the [test
pyramid](https://en.wikipedia.org/wiki/Test_automation#Testing_at_different_levels)
strategy, which means we want the majority of tests at the bottom of the
pyramid. Those should be fast and deterministic and support REPL-Driven
development (RDD). Slightly above them, we have component tests, then
integration/contract tests and finally end-to-end tests. The closer to the top
of the pyramid, the more valuable a test can be, but also more difficult to
pinpoint why it failed and harder to make it dependable.
*Note*: there are literally dozens of [types of
tests](https://en.wikipedia.org/wiki/Software_testing), each with its strengths
and weaknesses.
We tend not to stub or mock implementations in our tests, which means our tests
are [sociable](https://martinfowler.com/bliki/UnitTest.html).
## What to test?
The UI is driven by global & local state changes caused by events. Global state
is managed by re-frame and local state by Reagent atoms or React hooks. Except
for component and end-to-end tests, we test only non-UI code in `status-mobile`.
Given that the UI is greatly derived from global state, by guaranteeing the
state is correct we can prevent bugs and, more importantly, reduce the [cost of
change](https://www.pmi.org/disciplined-agile/agile/costofchange).
We strive to minimize the amount of _business logic_ in views (UI code). We
achieve this by moving capabilities to status-go and also by adhering to
re-frame's architecture.
Whenever appropriate (see section `When to test?`), we _may_ test:
- Re-frame events.
- Re-frame subscriptions.
- Utility functions.
- User journeys through integration/contract tests.
Interestingly, we don't test re-frame _effects_ in isolation.
### What are status-mobile integration and contract tests?
The mobile _integration tests_ can be used to "simulate" user interactions and
make actual calls to status-go via the RPC layer and actually receive signals.
We can also use these tests to verify the app-db and multiple subscriptions are
correct. We use the word _simulate_ because there is no UI. Basically, any flow
that can be driven by re-frame events is possible to automatically test. There
is no way to change or inspect local state managed by React.
A _contract test_ has the same capabilities as an integration test, but we want
to draw the line that they should focus more on a particupar RPC endpoint or
signal, and not on a user journey (e.g. create a wallet account). In the future,
we may consider running them automatically in status-go.
**Note:** integration tests and contract tests are currently overlapping in
their responsibilities and still require a clearer distinction.
## When to test?
(Automated) tests basically exist to support rapid software changes, but not
every piece of code should be tested. The following are general recommendations,
not rules.
- What would be the consequences to the user of a bug in the implementation you
are working on?
- Can a QA exercise all the branches in the code you changed? Not surprisingly,
usually QAs can't test many code paths (it may be nearly impossible), and
because PRs are not often tested by reviewers, many PRs can get into `develop`
without the necessary quality assurance.
- How costly was it for you to verify a function/event/etc was correct? Now
consider that this cost will be dispersed to every developer who needs to
change the implementation if there are no tests.
- Check the number of conditionals, and if they nest as well. Every conditional
may require two different assertions, and the number of assertions can grow
exponentially.
- How complicated are the arguments to the function? If they contain nested maps
or data that went through a few transformations, it may be tricky to decipher
what they are, unless you are familiar with the code. A test would be able to
capture the data, however complex they are.
### When to unit-test subscriptions?
Only test [layer-3
subscriptions](https://day8.github.io/re-frame/subscriptions/#the-four-layers),
i.e. don't bother testing extractor subscriptions (check the related
[guideline](https://github.com/status-im/status-mobile/blob/7774c4eac16fdee950a17bf5d07630c45a980f41/doc/new-guidelines.md#subscription-tests)).
Some layer-3 subscriptions can still be straightforward and may not be worth
testing.
- Check the number of _inputs_ to the sub (from the graph). The higher this
number, the greater the chance the subscription can break if any of the
input's implementation changes.
**Note**: if a tested subscription changes inadvertently, even if its own tests
still pass, other subscriptions that depend on it and have tests may still fail.
This is why we don't directly test the subscription handler, but instead, use
the macro `test-helpers.unit/deftest-sub`.
### When to unit-test events?
A good hint is to ask if you and other CCs need to rely on re-frisk, UI, REPL,
or FlowStorm to understand the event. If the answer is yes or probably, then a
test would be prudent.
- Many events only receive arguments and pass them along without much or any
transformation to an RPC call. These are straightforward and usually don't
need tests ([example](https://github.com/status-im/status-mobile/blob/7774c4eac16fdee950a17bf5d07630c45a980f41/src/status_im/contexts/contact/blocking/events.cljs#L79-L85)).
- Overall, every event basically returns two effects at most, `:fx` and/or
`:db`. Usually, the complicated part lies in the computation to return the new
app-db. If the event doesn't perform transformations in the app-db or just
does a trivial `assoc`, for example, it may not be worth testing.
For reference, the re-frame author particularly [suggests testing events and
subscriptions](https://github.com/day8/re-frame/blob/09e2d7132c479aa43f2a64164e54e42bf8511902/docs/Testing.md#what-to-test).
### When to unit-test utility functions?
Most utility functions in `status-mobile` are pure and can be readily and
cheaply tested.
- If the utility is used in an event/subscription and if the event/subscription
has tests, you may prefer to test the event/subscription and not the utility,
or the other way around sometimes.
- If the utility is tricky to verify, such as functions manipulating time, write
tests ([example](https://github.com/status-im/status-mobile/blob/7774c4eac16fdee950a17bf5d07630c45a980f41/src/utils/datetime.cljs#L1)).
- Utilities can be particularly hard to verify by QAs because they can be lower
level and require very particular inputs. In such cases, consider writing
tests.
### When to write integration/contract tests?
- You want to make real calls to status-go because you think the unit tests are
not enough (test pyramid strategy).
- You constantly need to retest the same things on the UI, sometimes over
multiple screens.
- The flow is too important to rely only on manual QA, which can't always be
done due to resource limits, so an integration/contract test fills this gap.
- You want to rely less on end-to-end tests, which can be more unreliable and
slower to change.
- You want automatic verifications for some area of the mobile app whenever
status-go is upgraded.
**Note**: the feedback cycle to write integration tests is longer than unit
tests because they are slower and harder to debug. Using the REPL with them is
difficult due to their stateful nature.
### When to test Quo components?
This is covered in [quo/README.md#component-tests](https://github.com/status-im/status-mobile/blob/7774c4eac16fdee950a17bf5d07630c45a980f41/src/quo/README.md#component-tests).
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@@ -28,6 +28,7 @@
{:type :spending-cap
:label "Spending Cap"
:button-label "Edit"
:button-icon :i/options
:on-button-press on-button-press
:avatar-props {:image "image"}}])
(h/fire-event :press (h/get-by-text "Edit"))
@@ -107,7 +107,7 @@
:style (style/description blur? theme)}
description])]
(when (= type :account) [tiny-tag/view {:label tag-label}])
(when (= type :spending-cap)
(when (and (= type :spending-cap) button-icon)
[button/button
{:type :outline
:size 24
@@ -47,3 +47,12 @@
(defn style-text-value
[theme]
{:color (colors/theme-colors colors/neutral-50 colors/white theme)})
(def initials-avatar-container
{:width 32
:height 32})
(def image-avatar
{:width 32
:height 32
:border-radius 32})
+10 -3
View File
@@ -1,5 +1,6 @@
(ns quo.components.list-items.dapp.view
(:require
[quo.components.avatars.user-avatar.view :as user-avatar]
[quo.components.list-items.dapp.style :as style]
[quo.components.markdown.text :as text]
[quo.theme :as quo.theme]
@@ -20,9 +21,15 @@
:on-press-in on-press-in
:on-press-out on-press-out}
[rn/view {:style style/container-info}
[fast-image/fast-image
{:source (:avatar dapp)
:style {:width 32 :height 32}}]
(if (:avatar dapp)
[fast-image/fast-image
{:source (:avatar dapp)
:style style/image-avatar}]
[rn/view {:style style/initials-avatar-container}
[user-avatar/initials-avatar
{:full-name (:name dapp)
:size :small
:customization-color (:customization-color dapp)}]])
[rn/view {:style style/user-info}
[text/text
{:weight :semi-bold
+1
View File
@@ -43,6 +43,7 @@
:gnosis (js/require "../resources/images/networks/Gnosis.png")
:hermez (js/require "../resources/images/networks/Hermez.png")
:optimism (js/require "../resources/images/networks/Optimism.png")
:paraswap (js/require "../resources/images/networks/Paraswap.png")
:polygon (js/require "../resources/images/networks/Polygon.png")
:scroll (js/require "../resources/images/networks/Scroll.png")
:taiko (js/require "../resources/images/networks/Taiko.png")
+7 -6
View File
@@ -62,16 +62,17 @@
(bean/->js {:id id
:namespaces approved-namespaces})))
(defn disconnect-session
[{:keys [web3-wallet reason topic]}]
(oops/ocall web3-wallet
"disconnectSession"
(bean/->js {:topic topic
:reason reason})))
(defn get-active-sessions
[web3-wallet]
(oops/ocall web3-wallet "getActiveSessions"))
(defn core-pairing-disconnnect
[web3-wallet topic]
(oops/ocall web3-wallet
"core.pairing.disconnect"
(bean/->js {:topic topic})))
(defn core-pairing-pair
[web3-wallet url]
(oops/ocall web3-wallet
@@ -48,7 +48,7 @@
set-animating-true #(reset! animating? true)
set-animating-false (fn [ms]
(js/setTimeout #(reset! animating? false) ms))]
(fn [{:keys [content skip-background? on-dismiss]}]
(fn [{:keys [content skip-background?]}]
(let [theme (quo.theme/use-theme)
{:keys [top] :as insets} (safe-area/get-insets)
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
@@ -63,10 +63,6 @@
(reanimated/animate opacity 0 300)
(rf/dispatch [:navigate-back])
true)
dismiss (fn []
(when on-dismiss
(on-dismiss))
(close))
reset-open-sheet (fn []
(reanimated/animate translate-y 0 300)
(reanimated/animate opacity 1 300)
@@ -87,7 +83,7 @@
:opacity opacity
:scroll-enabled? scroll-enabled?
:curr-scroll curr-scroll
:close dismiss
:close close
:reset-open-sheet reset-open-sheet
:set-animating-true set-animating-true})}
[reanimated/view {:style (style/main-view translate-y theme)}
+7 -1
View File
@@ -290,9 +290,12 @@
(def ^:const wallet-connect-session-request-event "session_request")
(def ^:const wallet-connect-session-delete-event "session_delete")
(def ^:const wallet-connect-user-rejected-error-key "USER_REJECTED")
(def ^:const wallet-connect-user-disconnected-reason-key "USER_DISCONNECTED")
(def ^:const transaction-pending-type-wallet-connect-transfer "WalletConnectTransfer")
(def ^:const token-sort-priority {"SNT" 1 "STT" 1 "ETH" 2 "DAI" 3})
(def ^:const dapp-permission-contact-code "contact-code")
(def ^:const dapp-permission-web3 "web3")
(def ^:const dapp-permission-qr-code "qr-code")
@@ -577,5 +580,8 @@
(def ^:const max-recommended-slippage 5)
(def ^:const max-slippage-decimal-places 2)
(def ^:const swap-default-provider
{:name "Paraswap"
{:name :paraswap
:full-name "Paraswap"
:color :blue
:contract-address "0xdef171fe48cf0115b1d80b88dc8eab59176fee57"
:terms-and-conditions-url "https://files.paraswap.io/tos_v4.pdf"})
@@ -262,7 +262,7 @@
can-edit-addresses? (rf/sub [:communities/can-edit-shared-addresses? id])
wallet-accounts (rf/sub [:wallet/operable-accounts-without-watched-accounts])
wallet-accounts (rf/sub [:wallet/operable-accounts])
joined (rf/sub [:communities/community-joined id])
unmodified-addresses-to-reveal (rf/sub [:communities/addresses-to-reveal id])
[addresses-to-reveal set-addresses-to-reveal] (rn/use-state unmodified-addresses-to-reveal)
@@ -47,12 +47,11 @@
:label (i18n/label :t/view-token-gating)}))
(defn- action-mark-as-read
[]
(when config/show-not-implemented-features?
{:icon :i/mark-as-read
:accessibility-label :chat-mark-as-read
:on-press not-implemented/alert
:label (i18n/label :t/mark-as-read)}))
[chat-id]
{:icon :i/mark-as-read
:accessibility-label :chat-mark-as-read
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])
:label (i18n/label :t/mark-as-read)})
(defn- action-toggle-muted
[id muted? muted-till chat-type]
@@ -130,7 +129,7 @@
(and (not inside-chat?) (not locked?))
[quo/action-drawer
[[(when-not hide-view-members? (action-view-members-and-details community-id chat-id))
(action-mark-as-read)
(action-mark-as-read chat-id)
(action-toggle-muted chat-id muted muted-till chat-type)
(action-notification-settings)
(action-pinned-messages chat-id)
@@ -143,7 +142,7 @@
[[(action-view-members-and-details community-id chat-id)
(when token-gated?
(action-token-requirements))
(action-mark-as-read)
(action-mark-as-read chat-id)
(action-toggle-muted chat-id muted muted-till chat-type)
(action-notification-settings)
(when config/fetch-messages-enabled?
@@ -38,7 +38,7 @@
(rf/dispatch [:push-notifications/switch true])
(rf/dispatch [:navigate-to-within-stack
[:screen/onboarding.welcome
:screen/onboarding.enable-notifications]]))
:screen/onboarding.generating-keys]]))
:type :primary
:icon-left :i/notifications
:accessibility-label :enable-notifications-button
@@ -52,7 +52,7 @@
nil)
(rf/dispatch [:navigate-to-within-stack
[:screen/onboarding.welcome
:screen/onboarding.enable-notifications]]))
:screen/onboarding.generating-keys]]))
:accessibility-label :enable-notifications-later-button
:type :grey
:background :blur
+3 -12
View File
@@ -73,7 +73,9 @@
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]
:dispatch-later [{:ms constants/onboarding-generating-keys-animation-duration-ms
:dispatch [:init-root :screen/onboarding.enable-notifications]}]
:dispatch [:navigate-to-within-stack
[:screen/onboarding.enable-notifications
:screen/onboarding.generating-keys]]}]
:db (-> db
(dissoc :profile/login)
(dissoc :auth-method)
@@ -187,14 +189,3 @@
{:key-uid key-uid
:error %})}))))
(rf/defn navigate-to-identifiers
{:events [:onboarding/navigate-to-identifiers]}
[{:keys [db]}]
(if (:onboarding/generated-keys? db)
{:dispatch [:navigate-to-within-stack
[:screen/onboarding.identifiers
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]}
{:dispatch-later [{:ms constants/onboarding-generating-keys-navigation-retry-ms
:dispatch [:onboarding/navigate-to-identifiers]}]}))
@@ -13,14 +13,17 @@
:value "Default"}
{:key :active
:value "Active"}]}
{:key :action
{:key :dapp
:type :select
:options [{:key :none
:value "None"}
{:key :icon
:value "Icon"}]}
{:key :blur?
:type :boolean}])
:options [{:value "With icon"
:key {:avatar (resources/get-dapp :coingecko)
:name "Coingecko"
:value "coingecko.com"}}
{:value "Without icon"
:key {:avatar nil
:name "Coingecko"
:value "coingecko.com"
:customization-color :blue}}]}])
(defn preview
[]
@@ -346,7 +346,8 @@
#(reset! camera-permission-granted? %)
#(reset! camera-permission-granted? false)))))
[:<>
background
[rn/view {:style style/absolute-fill}
background]
(when camera-ready-to-scan?
[render-camera
{:torch-mode torch-mode
@@ -1,18 +0,0 @@
(ns status-im.contexts.wallet.account.tabs.dapps.style
(:require
[quo.foundations.colors :as colors]))
(def dapps-container
{:padding-horizontal 20
:padding-vertical 8})
(defn dapps-list
[theme]
{:border-radius 16
:border-width 1
:border-color (colors/theme-colors colors/neutral-10 colors/neutral-80 theme)})
(defn separator
[theme]
{:height 1
:background-color (colors/theme-colors colors/neutral-10 colors/neutral-80 theme)})
@@ -1,37 +0,0 @@
(ns status-im.contexts.wallet.account.tabs.dapps.view
(:require
[quo.core :as quo]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[status-im.common.resources :as resources]
[status-im.contexts.wallet.account.tabs.dapps.style :as style]
[status-im.contexts.wallet.common.empty-tab.view :as empty-tab]
[utils.i18n :as i18n]))
(defn dapp-options
[]
[quo/action-drawer
[[{:icon :i/browser
:accessibility-label :visit-dapp
:label (i18n/label :t/visit-dapp)}
{:icon :i/disconnect
:accessibility-label :disconnect-dapp
:label (i18n/label :t/disconnect-dapp)
:add-divider? true
:danger? true}]]])
(defn view
[]
(let [theme (quo.theme/use-theme)
dapps-list []]
(if (empty? dapps-list)
[empty-tab/view
{:title (i18n/label :t/no-dapps)
:description (i18n/label :t/no-dapps-description)
:image (resources/get-themed-image :no-dapps theme)}]
[rn/view {:style style/dapps-container}
[rn/flat-list
{:data dapps-list
:style (style/dapps-list theme)
:render-fn (fn [item] [quo/dapp item])
:separator [rn/view {:style (style/separator theme)}]}]])))
@@ -3,7 +3,6 @@
[react-native.core :as rn]
[status-im.contexts.wallet.account.tabs.about.view :as about]
[status-im.contexts.wallet.account.tabs.assets.view :as assets]
[status-im.contexts.wallet.account.tabs.dapps.view :as dapps]
[status-im.contexts.wallet.collectible.options.view :as options-drawer]
[status-im.contexts.wallet.common.activity-tab.view :as activity]
[status-im.contexts.wallet.common.collectibles-tab.view :as collectibles]
@@ -45,5 +44,4 @@
{:title (i18n/label :t/no-permissions)
:description (i18n/label :t/no-collectibles-description)
:placeholder? true}]
:dapps [dapps/view]
[about/view])]))
@@ -13,13 +13,11 @@
(def first-tab-id :assets)
(defn tabs-data
[watch-only?]
(cond-> [{:id :assets :label (i18n/label :t/assets) :accessibility-label :assets-tab}
{:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab}
{:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab}]
(not watch-only?) (conj {:id :dapps :label (i18n/label :t/dapps) :accessibility-label :dapps})
:always (conj {:id :about :label (i18n/label :t/about) :accessibility-label :about})))
(def tabs-data
[{:id :assets :label (i18n/label :t/assets) :accessibility-label :assets-tab}
{:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab}
{:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab}
{:id :about :label (i18n/label :t/about) :accessibility-label :about}])
(defn- change-tab [id] (rf/dispatch [:wallet/select-account-tab id]))
@@ -69,7 +67,7 @@
{:style style/tabs
:size 32
:active-tab-id selected-tab
:data (tabs-data watch-only?)
:data tabs-data
:on-change change-tab
:scrollable? true
:scroll-on-press? true}]
@@ -28,17 +28,6 @@
(log/debug "unsupported collectible file type:" (or collectible-type "Unknown type"))
false)))
(defn total-owned-collectible
([ownership]
(total-owned-collectible ownership false))
([ownership address]
(reduce (fn [acc item]
(if (or (not address) (= (:address item) address))
(+ acc (js/parseInt (:balance item)))
acc))
0
ownership)))
(defn collectible-owned-counter
[total]
(when (> total 1) (str "x" total)))
@@ -160,6 +160,9 @@
collectible-owner (rf/sub [:wallet/collectible-details-owner collectible])
aspect-ratio (rf/sub [:wallet/collectible-aspect-ratio])
gradient-color (rf/sub [:wallet/collectible-gradient-color])
total-owned (rf/sub [:wallet/total-owned-collectible
(:ownership collectible)
(:address collectible-owner)])
{:keys [id
preview-url
collection-data
@@ -182,10 +185,7 @@
:image-height 300
:id token-id
:header collectible-name
:description collection-name}
total-owned (utils/total-owned-collectible
(:ownership collectible)
(:address collectible-owner))]
:description collection-name}]
[rn/view {:style style/container}
[rn/view
[gradient-layer preview-uri]
@@ -7,7 +7,8 @@
[status-im.contexts.wallet.collectible.utils :as utils]
[status-im.contexts.wallet.common.collectibles-tab.style :as style]
[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- collectible-item
[{:keys [preview-url collection-data collectible-data total-owned on-press on-long-press]
@@ -61,15 +62,16 @@
;; TODO: https://github.com/status-im/status-mobile/issues/20137
;; 1. If possible, move `collectibles-data` calculation to a subscription
;; 2. Optimization: do not recalculate all the collectibles, process only the new ones
(let [collectibles-data (map-indexed (fn [index {:keys [ownership] :as collectible}]
(assoc collectible
:total-owned (utils/total-owned-collectible
ownership
current-account-address)
:on-long-press on-collectible-long-press
:on-press on-collectible-press
:collectible-index index))
collectibles)]
(let [collectibles-data (map-indexed
(fn [index {:keys [ownership] :as collectible}]
(let [total-owned (rf/sub [:wallet/total-owned-collectible ownership
current-account-address])]
(assoc collectible
:total-owned total-owned
:on-long-press on-collectible-long-press
:on-press on-collectible-press
:collectible-index index)))
collectibles)]
[rn/flat-list
{:data collectibles-data
:style {:flex 1}
@@ -16,14 +16,14 @@
:right-icon :i/external})
(defn- action-send
[send-params]
[send-params entry-point]
{:icon :i/send
:accessibility-label :send
:label (i18n/label :t/send)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/set-token-to-send send-params]))})
(rf/dispatch [:wallet/set-token-to-send send-params entry-point]))})
(defn- action-receive
[selected-account?]
@@ -66,36 +66,41 @@
:on-press #(js/alert "to be implemented")})
(defn token-value-drawer
[token watch-only?]
[token watch-only? entry-point]
(let [token-symbol (:token token)
token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered
token-symbol]))
selected-account? (rf/sub [:wallet/current-viewing-account-address])
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
send-or-bridge-params (if selected-account?
{:token token-data
:stack-id :screen/wallet.accounts
:start-flow? true}
:start-flow? true
:owners token-owners}
{:token-symbol token-symbol
:stack-id :wallet-stack
:start-flow? true})]
:start-flow? true
:owners token-owners})]
[quo/action-drawer
[(cond->> [(when (ff/enabled? ::ff/wallet.assets-modal-manage-tokens)
(action-manage-tokens watch-only?))
(when (ff/enabled? ::ff/wallet.assets-modal-hide)
(action-hide))]
(not watch-only?) (concat [(action-buy)
(action-send send-or-bridge-params)
(when (seq token-owners)
(action-send send-or-bridge-params entry-point))
(action-receive selected-account?)
(when (ff/enabled? ::ff/wallet.swap) (action-swap))
(action-bridge send-or-bridge-params)]))]]))
(when (seq (seq token-owners))
(action-bridge send-or-bridge-params))]))]]))
(defn view
[item _ _ {:keys [watch-only?]}]
[item _ _ {:keys [watch-only? entry-point]}]
[quo/token-value
(cond-> item
(or (not watch-only?) (ff/enabled? ::ff/wallet.long-press-watch-only-asset))
(assoc :on-long-press
#(rf/dispatch
[:show-bottom-sheet
{:content (fn [] [token-value-drawer item watch-only?])
{:content (fn [] [token-value-drawer item watch-only? entry-point])
:selected-item (fn [] [quo/token-value item])}])))])
@@ -307,10 +307,14 @@
:color color
:currency currency
:currency-symbol currency-symbol}))
calculated-tokens (map calculate-token tokens)
token-priority {"SNT" 1 "STT" 1 "ETH" 2 "DAI" 3}]
calculated-tokens (map calculate-token tokens)]
(sort-by (fn [token]
(let [fiat-value (get-in token [:values :fiat-unformatted-value])
priority (get token-priority (:token token) 999)]
priority (get constants/token-sort-priority (:token token) ##Inf)]
[(- fiat-value) priority]))
calculated-tokens)))
(defn sort-tokens
[tokens]
(let [priority #(get constants/token-sort-priority (:symbol %) ##Inf)]
(sort-by (juxt (comp - :balance) priority) tokens)))
@@ -149,5 +149,14 @@
expected-order ["DAI" "ETH" "SNT"]]
(is (= expected-order sorted-tokens))))))))
(deftest sort-tokens-test
(testing "sort-tokens function"
(let [mock-tokens [{:symbol "ETH" :balance 5}
{:symbol "DAI" :balance 10}
{:symbol "SNT" :balance 1}]
sorted-tokens (map :symbol (utils/sort-tokens mock-tokens))
expected-order ["DAI" "ETH" "SNT"]]
(is (= expected-order sorted-tokens)))))
@@ -9,30 +9,31 @@
[status-im.common.resources :as resources]
[status-im.contexts.wallet.connected-dapps.disconnect-dapp.view :as disconnect-dapp]
[status-im.contexts.wallet.connected-dapps.style :as style]
[status-im.contexts.wallet.wallet-connect.core :as core]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
[utils.re-frame :as rf]
[utils.string]))
(defn- on-disconnect
[wallet-account {:keys [name topic pairing-topic]}]
[wallet-account {:keys [name topic]}]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch
[:wallet-connect/disconnect-dapp
{:topic topic
:pairing-topic pairing-topic
:on-success (fn []
(rf/dispatch [:toasts/upsert
{:id :dapp-disconnect-success
:type :positive
:text (i18n/label :t/disconnect-dapp-success
{:dapp name
:account (:name wallet-account)})}]))
:on-fail (fn []
(rf/dispatch [:toasts/upsert
{:id :dapp-disconnect-failure
:type :negative
:text (i18n/label :t/disconnect-dapp-fail
{:dapp name
:account (:name wallet-account)})}]))}]))
{:topic topic
:on-success (fn []
(rf/dispatch [:toasts/upsert
{:id :dapp-disconnect-success
:type :positive
:text (i18n/label :t/disconnect-dapp-success
{:dapp name
:account (:name wallet-account)})}]))
:on-fail (fn []
(rf/dispatch [:toasts/upsert
{:id :dapp-disconnect-failure
:type :negative
:text (i18n/label :t/disconnect-dapp-fail
{:dapp name
:account (:name wallet-account)})}]))}]))
(defn- on-dapp-disconnect-press
[wallet-account dapp]
@@ -85,7 +86,8 @@
{:keys [color] :as wallet-account} (rf/sub [:wallet/current-viewing-account])
sessions (rf/sub
[:wallet-connect/sessions-for-current-account])
theme (quo.theme/use-theme)]
theme (quo.theme/use-theme)
customization-color (rf/sub [:profile/customization-color])]
[rn/view {:flex 1}
[header
{:title (i18n/label :t/connected-dapps)
@@ -105,11 +107,13 @@
:content-container-style (style/dapps-list theme)
:render-fn (fn [{:keys [topic pairingTopic name url iconUrl]}]
[quo/dapp
{:dapp {:avatar iconUrl
:name name
:value url
:topic topic
:pairing-topic pairingTopic}
{:dapp {:avatar (core/compute-dapp-icon-path iconUrl
url)
:name (core/compute-dapp-name name url)
:value url
:topic topic
:pairing-topic pairingTopic
:customization-color customization-color}
:accessibility-label (str "dapp-" topic)
:state :default
:action :icon
+15 -4
View File
@@ -65,10 +65,21 @@
{:db (assoc-in db [:wallet :current-viewing-account-address] address)}))
(rf/reg-event-fx :wallet/clean-current-viewing-account
(fn [{:keys [db]}]
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
(when-not just-completed-transaction?
{:db (update db :wallet dissoc :current-viewing-account-address)}))))
(fn [{:keys [db]} [ignore-just-completed-transaction?]]
(let [{:keys [entry-point just-completed-transaction?]} (-> db :wallet :ui :send)
entry-point-wallet-home? (= entry-point :wallet-stack)]
{:db (cond-> db
(and (not entry-point)
(not ignore-just-completed-transaction?)
(not just-completed-transaction?))
(update :wallet dissoc :current-viewing-account-address)
entry-point-wallet-home?
(update-in [:wallet :ui :send] dissoc :entry-point)
(and entry-point-wallet-home?
(not just-completed-transaction?))
(update :wallet dissoc :current-viewing-account-address))})))
(rf/reg-event-fx :wallet/close-account-page
(fn [{:keys [db]}]
@@ -18,4 +18,5 @@
[rn/flat-list
{:render-fn token-value/view
:data tokens
:render-data {:entry-point :wallet-stack}
:content-container-style style/list-container}])))
@@ -21,7 +21,7 @@
(defn view
[{:keys [selected-tab]}]
(let [collectible-list (rf/sub [:wallet/all-collectibles-list-in-selected-networks])
(let [collectible-list (rf/sub [:wallet/owned-collectibles-list-in-selected-networks])
request-collectibles #(rf/dispatch
[:wallet/request-collectibles-for-all-accounts {}])]
[rn/view {:style style/container}
+40 -20
View File
@@ -193,25 +193,35 @@
(rf/reg-event-fx
:wallet/set-token-to-send
(fn [{:keys [db]} [{:keys [token-symbol token stack-id start-flow?]}]]
(fn [{:keys [db]} [{:keys [token-symbol token stack-id start-flow? owners]} entry-point]]
;; `token` is a map extracted from the sender, but in the wallet home page we don't know the
;; sender yet, so we only provide the `token-symbol`, later in
;; `:wallet/select-from-account` the `token` key will be set.
(let [{token-networks :networks} token
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
token-networks-ids (mapv #(:chain-id %) token-networks)
token-not-supported-in-receiver-networks? (not-any? (set receiver-networks)
token-networks-ids)]
(when (or token token-symbol)
(let [{:keys [networks]} token
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
token-networks-ids (map :chain-id networks)
unsupported-token? (not-any? (set receiver-networks) token-networks-ids)
unique-owner (when (= (count owners) 1)
(first owners))
unique-owner-tokens (get-in db [:wallet :accounts unique-owner :tokens])
token-data (or token
(when (and token-symbol unique-owner)
(some #(when (= (:symbol %) token-symbol) %)
unique-owner-tokens)))]
(when (or token-data token-symbol)
{:db (cond-> db
:always (update-in [:wallet :ui :send] dissoc :collectible)
:always (assoc-in
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
token-not-supported-in-receiver-networks?)
token (assoc-in [:wallet :ui :send :token] token)
token (assoc-in [:wallet :ui :send :token-display-name]
(:symbol token))
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
:always (update-in [:wallet :ui :send]
#(-> %
(dissoc :collectible)
(assoc :token-not-supported-in-receiver-networks?
unsupported-token?)))
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol)
token-data (update-in [:wallet :ui :send]
#(assoc %
:token token-data
:token-display-name (:symbol token-data)))
unique-owner (assoc-in [:wallet :current-viewing-account-address] unique-owner)
entry-point (assoc-in [:wallet :ui :send :entry-point] entry-point))
:fx [[:dispatch [:wallet/clean-suggested-routes]]
[:dispatch
[:wallet/wizard-navigate-forward
@@ -225,9 +235,9 @@
(let [{token-networks :networks
token-symbol :symbol} token
receiver-networks (get-in db [:wallet :ui :send :receiver-networks])
token-networks-ids (mapv #(:chain-id %) token-networks)
token-not-supported-in-receiver-networks? (not (some (set receiver-networks)
token-networks-ids))]
token-networks-ids (map :chain-id token-networks)
token-not-supported-in-receiver-networks? (not-any? (set receiver-networks)
token-networks-ids)]
{:db (-> db
(assoc-in [:wallet :ui :send :token] token)
(assoc-in [:wallet :ui :send :token-display-name] token-symbol)
@@ -256,7 +266,9 @@
(rf/reg-event-fx
:wallet/set-collectible-to-send
(fn [{db :db} [{:keys [collectible current-screen start-flow?]}]]
(let [collection-data (:collection-data collectible)
(let [viewing-account? (some? (-> db :wallet :current-viewing-account-address))
entry-point (when-not viewing-account? :wallet-stack)
collection-data (:collection-data collectible)
collectible-data (:collectible-data collectible)
contract-type (:contract-type collectible)
tx-type (if (= contract-type constants/wallet-contract-type-erc-1155)
@@ -271,6 +283,7 @@
collectible
(str (:name collection-data) " #" collectible-id))
owner-address (-> collectible :ownership first :address)
collectible-tx (-> db
(update-in [:wallet :ui :send] dissoc :token)
(assoc-in [:wallet :ui :send :collectible] collectible)
@@ -278,7 +291,14 @@
(assoc-in [:wallet :ui :send :tx-type] tx-type))
recipient-set? (-> db :wallet :ui :send :recipient)]
{:db (cond-> collectible-tx
one-collectible? (assoc-in [:wallet :ui :send :amount] 1))
:always
(assoc-in [:wallet :ui :send :entry-point] entry-point)
(not viewing-account?)
(assoc-in [:wallet :current-viewing-account-address] owner-address)
one-collectible?
(assoc-in [:wallet :ui :send :amount] 1))
:fx [(when (and one-collectible? recipient-set?)
[:dispatch [:wallet/get-suggested-routes {:amount 1}]])
[:dispatch
@@ -42,7 +42,6 @@
{:on-press #(rf/dispatch [:navigate-back])
:margin-top (safe-area/get-top)
:switcher-type :select-account}]}
[quo/page-top
{:title (i18n/label :t/from-label)
:title-accessibility-label :title-label}]
@@ -177,7 +177,9 @@
(rf/dispatch [:wallet/clean-selected-collectible])
(rf/dispatch [:wallet/clean-send-address])
(rf/dispatch [:wallet/clean-disabled-from-networks])
(rf/dispatch [:wallet/select-address-tab nil]))
(rf/dispatch [:wallet/select-address-tab nil])
(rf/dispatch [:wallet/clean-current-viewing-account
:ignore-just-complete-transaction]))
on-change-tab #(rf/dispatch [:wallet/select-address-tab %])
input-value (reagent/atom "")
input-focused? (reagent/atom false)]
@@ -20,7 +20,7 @@
(defn view
[]
(let [selected-account-address (rf/sub [:wallet/current-viewing-account-address])
accounts (rf/sub [:wallet/operable-accounts-without-watched-accounts])]
accounts (rf/sub [:wallet/operable-accounts])]
[:<>
[quo/drawer-top {:title (i18n/label :t/select-account)}]
[gesture/flat-list
@@ -0,0 +1,40 @@
(ns status-im.contexts.wallet.swap.set-spending-cap.style
(:require [quo.foundations.colors :as colors]))
(def container
{:flex 1
:margin-top -20})
(def detail-item
{:flex 1
:height 36
:background-color :transparent})
(def content-container
{:padding-top 12
:padding-horizontal 20
:padding-bottom 32})
(def title-container
{:margin-horizontal 4})
(def title-line-with-margin-top
{:flex-direction :row
:margin-top 4})
(def details-container
{:flex-direction :row
:justify-content :space-between
:height 52
:padding-top 7
:padding-horizontal 1
:margin-bottom 8})
(def summary-section-container
{:padding-horizontal 20
:padding-bottom 16})
(defn section-label
[theme]
{:margin-bottom 8
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
@@ -0,0 +1,253 @@
(ns status-im.contexts.wallet.swap.set-spending-cap.view
(:require
[quo.core :as quo]
[quo.foundations.resources :as resources]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.common.standard-authentication.core :as standard-auth]
[status-im.contexts.wallet.common.utils.external-links :as external-links]
[status-im.contexts.wallet.swap.set-spending-cap.style :as style]
[utils.address :as address-utils]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn- swap-title
[{:keys [pay-token-symbol pay-amount account provider]}]
[rn/view {:style style/content-container}
[rn/view {:style {:flex-direction :row}}
[quo/text
{:size :heading-1
:weight :semi-bold
:style style/title-container
:accessibility-label :set-spending-cap-of}
(i18n/label :t/set-spending-cap-of)]]
[rn/view {:style style/title-line-with-margin-top}
[quo/summary-tag
{:token pay-token-symbol
:label (str pay-amount " " pay-token-symbol)
:type :token}]
[quo/text
{:size :heading-1
:weight :semi-bold
:style style/title-container
:accessibility-label :for}
(i18n/label :t/for)]]
[rn/view {:style style/title-line-with-margin-top}
[quo/summary-tag
{:label (:full-name provider)
:type :network
:image-source (resources/get-network (:name provider))
:customization-color (:color provider)}]
[quo/text
{:size :heading-1
:weight :semi-bold
:style style/title-container
:accessibility-label :on}
(i18n/label :t/on)]]
[rn/view {:style style/title-line-with-margin-top}
[quo/summary-tag
{:label (:name account)
:type :account
:emoji (:emoji account)
:customization-color (:color account)}]]])
(defn- spending-cap-section
[{:keys [theme amount token-symbol]}]
[rn/view {:style style/summary-section-container}
[quo/text
{:size :paragraph-2
:weight :medium
:style (style/section-label theme)
:accessibility-label :spending-cap-label}
(i18n/label :t/spending-cap)]
[quo/approval-info
{:type :spending-cap
:unlimited-icon? false
:label (str amount " " token-symbol)
:avatar-props {:token token-symbol}}]])
(defn- account-section
[{:keys [theme account pay-token-symbol pay-token-amount]}]
[rn/view {:style style/summary-section-container}
[quo/text
{:size :paragraph-2
:weight :medium
:style (style/section-label theme)
:accessibility-label :account-label}
(i18n/label :t/account)]
[quo/approval-info
{:type :account
:unlimited-icon? false
:label (:name account)
:description (address-utils/get-short-wallet-address (:address account))
:tag-label (str pay-token-amount " " pay-token-symbol)
:avatar-props {:emoji (:emoji account)
:customization-color (:color account)}}]])
(defn- on-option-press
[{:keys [chain-id contract-address]}]
(rf/dispatch
[:show-bottom-sheet
{:content (fn []
[quo/action-drawer
[[{:icon :i/link
:accessibility-label :view-on-etherscan
:on-press (fn []
(rf/dispatch
[:wallet/navigate-to-chain-explorer-from-bottom-sheet
(external-links/get-explorer-url-by-chain-id chain-id)
contract-address]))
:label (i18n/label :t/view-on-eth)
:right-icon :i/external}]]])}]))
(defn- token-section
[{:keys [theme token-address token-symbol network-chain-id]}]
[rn/view {:style style/summary-section-container}
[quo/text
{:size :paragraph-2
:weight :medium
:style (style/section-label theme)
:accessibility-label :token-label}
(i18n/label :t/token)]
[quo/approval-info
{:type :token-contract
:option-icon :i/options
:on-option-press #(on-option-press {:chain-id network-chain-id
:contract-address token-address})
:unlimited-icon? false
:label token-symbol
:description (address-utils/get-short-wallet-address token-address)
:avatar-props {:token token-symbol}}]])
(defn- spender-contract-section
[{:keys [theme provider network-chain-id]}]
[rn/view {:style style/summary-section-container}
[quo/text
{:size :paragraph-2
:weight :medium
:style (style/section-label theme)
:accessibility-label :spender-contract-label}
(i18n/label :t/spender-contract)]
[quo/approval-info
{:type :token-contract
:option-icon :i/options
:on-option-press #(on-option-press {:chain-id network-chain-id
:contract-address (:contract-address provider)})
:unlimited-icon? false
:label (:full-name provider)
:description (address-utils/get-short-wallet-address (:contract-address provider))
:avatar-props {:image (resources/get-network (:name provider))}}]])
(defn- data-item
[{:keys [network-image title subtitle size loading?]}]
[quo/data-item
{:container-style style/detail-item
:blur? false
:card? false
:network-image network-image
:subtitle-type (if network-image :network :default)
:status (if loading? :loading :default)
:title title
:subtitle subtitle
:size size}])
(defn- transaction-details
[{:keys [estimated-time-min max-fees network loading-fees?]}]
[rn/view {:style style/details-container}
[:<>
[data-item
{:title (i18n/label :t/network)
:subtitle (:full-name network)
:network-image (:source network)}]
[data-item
{:title (i18n/label :t/est-time)
:subtitle (i18n/label :t/time-in-mins {:minutes (str estimated-time-min)})}]
[data-item
{:title (i18n/label :t/max-fees)
:subtitle max-fees
:loading? loading-fees?
:size :small}]]])
(defn footer
[{:keys [estimated-time-min native-currency-symbol network theme account-color loading-fees?]}]
(let [native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token])
on-auth-success (rn/use-callback #(js/alert "Not implemented yet"))]
[rn/view {:style {:margin-bottom -10}}
[transaction-details
{:estimated-time-min estimated-time-min
:max-fees fee-formatted
:network network
:loading-fees? loading-fees?
:theme theme}]
[standard-auth/slide-button
{:size :size-48
:track-text (i18n/label :t/slide-to-swap)
:container-style {:z-index 2}
:customization-color account-color
:disabled? loading-fees?
:on-auth-success on-auth-success
:auth-button-label (i18n/label :t/confirm)}]]))
(defn view
[]
(let [theme (quo.theme/use-theme)
swap-transaction-data (rf/sub [:wallet/swap])
{:keys [asset-to-pay network pay-amount
providers swap-proposal
loading-fees?]} swap-transaction-data
estimated-time-min (:estimated-time swap-proposal)
pay-token-symbol (:symbol asset-to-pay)
pay-token-address (:address asset-to-pay)
native-currency-symbol (get-in swap-proposal [:from :native-currency-symbol])
account (rf/sub [:wallet/current-viewing-account])
account-color (:color account)
provider (first providers)]
[rn/view {:style style/container}
[floating-button-page/view
{:footer-container-padding 0
:header [quo/page-nav
{:icon-name :i/close
:on-press navigation/navigate-back
:margin-top 8
:background :blur
:accessibility-label :top-bar}]
:footer [footer
{:estimated-time-min estimated-time-min
:native-currency-symbol native-currency-symbol
:network network
:account-color account-color
:provider provider
:loading-fees? loading-fees?
:theme theme}]
:gradient-cover? true
:customization-color account-color}
[:<>
[swap-title
{:pay-token-symbol pay-token-symbol
:pay-amount pay-amount
:account account
:provider provider}]
[spending-cap-section
{:token-symbol pay-token-symbol
:amount pay-amount
:theme theme}]
[account-section
{:account account
:pay-token-symbol pay-token-symbol
:pay-token-amount pay-amount
:theme theme}]
[token-section
{:token-symbol pay-token-symbol
:token-address pay-token-address
:network-chain-id (:chain-id network)
:theme theme}]
[spender-contract-section
{:provider provider
:network-chain-id (:chain-id network)
:theme theme}]]]]))
@@ -16,4 +16,7 @@
[quo/button
{:on-press #(rf/dispatch [:navigate-to-within-stack
[:screen/wallet.swap-confirmation :screen/wallet.swap-propasal]])}
"Swap confirmation"]]))
"Swap confirmation"]
[quo/button
{:on-press #(rf/dispatch [:open-modal :screen/wallet.swap-set-spending-cap])}
"Set spending cap"]]))
@@ -4,6 +4,7 @@
[native-module.core :as native-module]
[status-im.constants :as constants]
[utils.security.core :as security]
[utils.string]
[utils.transforms :as transforms]))
(def method-to-screen
@@ -127,3 +128,39 @@
:url (get-in session [:peer :metadata :url])
:accounts (get-in session [:namespaces :eip155 :accounts])
:disconnected false})
(defn filter-operable-accounts
[accounts]
(filter #(and (:operable? %)
(not (:watch-only? %)))
accounts))
(defn filter-sessions-for-account-addresses
[account-addresses sessions]
(filter (fn [{:keys [accounts]}]
(some (fn [account]
(some (fn [account-address]
(clojure.string/includes? account account-address))
account-addresses))
accounts))
sessions))
(defn compute-dapp-name
"Sometimes dapps have no name or an empty name. Return url as name in that case"
[name url]
(if (seq name)
name
(when (seq url)
(-> url
utils.string/remove-trailing-slash
utils.string/remove-http-prefix
string/capitalize))))
(defn compute-dapp-icon-path
"Some dapps have icons with relative paths, make paths absolute in those cases, send nil if icon is missing"
[icon-path url]
(when (and (seq icon-path)
(seq url))
(if (string/starts-with? icon-path "http")
icon-path
(str (utils.string/remove-trailing-slash url) icon-path))))
@@ -41,8 +41,10 @@
(rf/reg-fx
:effects.wallet-connect/disconnect
(fn [{:keys [web3-wallet topic on-success on-fail]}]
(-> (wallet-connect/core-pairing-disconnnect web3-wallet topic)
(fn [{:keys [web3-wallet topic reason on-success on-fail]}]
(-> (wallet-connect/disconnect-session {:web3-wallet web3-wallet
:topic topic
:reason reason})
(promesa/then on-success)
(promesa/catch on-fail))))
@@ -55,9 +55,7 @@
(log/info "Received Wallet Connect session proposal: " {:id (:id proposal)})
(let [accounts (get-in db [:wallet :accounts])
current-viewing-address (get-in db [:wallet :current-viewing-account-address])
available-accounts (filter #(and (:operable? %)
(not (:watch-only? %)))
(vals accounts))
available-accounts (wallet-connect-core/filter-operable-accounts (vals accounts))
networks (wallet-connect-core/get-networks-by-mode db)
session-networks (wallet-connect-core/proposal-networks-intersection proposal
networks)
@@ -117,14 +115,16 @@
(rf/reg-event-fx
:wallet-connect/disconnect-dapp
(fn [{:keys [db]} [{:keys [pairing-topic on-success on-fail]}]]
(fn [{:keys [db]} [{:keys [topic on-success on-fail]}]]
(let [web3-wallet (get db :wallet-connect/web3-wallet)]
{:fx [[:effects.wallet-connect/disconnect
{:web3-wallet web3-wallet
:topic pairing-topic
:topic topic
:reason (wallet-connect/get-sdk-error
constants/wallet-connect-user-disconnected-reason-key)
:on-fail on-fail
:on-success (fn []
(rf/dispatch [:wallet-connect/disconnect-session pairing-topic])
(rf/dispatch [:wallet-connect/disconnect-session topic])
(when on-success
(on-success)))}]]})))
@@ -204,15 +204,23 @@
:wallet-connect/fetch-active-sessions-success
(fn [{:keys [db now]} [sessions]]
(let [persisted-sessions (:wallet-connect/sessions db)
account-addresses (->> (get-in db [:wallet :accounts])
vals
wallet-connect-core/filter-operable-accounts
(map :address))
sessions (->> (js->clj sessions :keywordize-keys true)
vals
(map wallet-connect-core/sdk-session->db-session))
expired-sessions (remove
(fn [{:keys [expiry]}]
(> expiry (/ now 1000)))
(map wallet-connect-core/sdk-session->db-session)
(wallet-connect-core/filter-sessions-for-account-addresses
account-addresses))
session-topics (set (map :topic sessions))
expired-sessions (filter
(fn [{:keys [expiry topic]}]
(or (< expiry (/ now 1000))
(not (contains? session-topics topic))))
persisted-sessions)]
{:fx (mapv (fn [{:keys [pairingTopic]}]
[:wallet-connect/disconnect-session pairingTopic])
{:fx (mapv (fn [{:keys [topic]}]
[:dispatch [:wallet-connect/disconnect-session topic]])
expired-sessions)
:db (assoc db :wallet-connect/sessions sessions)})))
@@ -270,15 +278,15 @@
(rf/reg-event-fx
:wallet-connect/disconnect-session
(fn [{:keys [db]} [pairing-topic]]
(fn [{:keys [db]} [topic]]
{:db (update db
:wallet-connect/sessions
(fn [sessions]
(->> sessions
(remove #(= (:pairingTopic %) pairing-topic))
(remove #(= (:topic %) topic))
(into []))))
:fx [[:json-rpc/call
[{:method "wallet_disconnectWalletConnectSession"
:params [pairing-topic]
:params [topic]
:on-success #(log/info "Wallet Connect session disconnected")
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]}))
@@ -1,6 +1,7 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.footer.view
(:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[status-im.common.standard-authentication.core :as standard-authentication]
[status-im.contexts.wallet.wallet-connect.modals.common.footer.style :as style]
@@ -14,7 +15,8 @@
(defn view
[{:keys [warning-label slide-button-text disabled?]} & children]
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])]
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])
theme (quo.theme/use-theme)]
[rn/view {:style style/content-container}
(into [rn/view
{:style style/data-items-container}]
@@ -30,6 +32,8 @@
[rn/view {:style style/warning-container}
[quo/text
{:size :paragraph-2
:style {:color colors/neutral-80-opa-70}
:style {:color (if (= theme :dark)
colors/white-opa-70
colors/neutral-80-opa-70)}
:weight :medium}
warning-label]]]))
@@ -1,7 +1,10 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style]))
(:require
[quo.core :as quo]
[react-native.core :as rn]
[status-im.contexts.wallet.wallet-connect.core :as core]
[status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style]
[utils.string]))
(defn view
[{:keys [label dapp account]}]
@@ -10,12 +13,13 @@
[quo/text
{:size :heading-1
:weight :semi-bold}
(let [{:keys [name iconUrl]} dapp]
(let [{:keys [name iconUrl url]} dapp
image-source (core/compute-dapp-icon-path iconUrl url)]
[rn/view {:style style/header-dapp-name}
[quo/summary-tag
{:type :dapp
:label name
:image-source iconUrl}]])
:image-source image-source}]])
(str " " label " ")
(let [{:keys [emoji customization-color name]} account]
[rn/view {:style style/header-account-name}
@@ -131,12 +131,13 @@
(fn [{:keys [db]} _]
(let [web3-wallet (get db :wallet-connect/web3-wallet)
current-proposal (get-in db [:wallet-connect/current-proposal :request])]
{:fx [[:effects.wallet-connect/reject-session-proposal
{:db (dissoc db :wallet-connect/current-proposal)
:fx [[:effects.wallet-connect/reject-session-proposal
{:web3-wallet web3-wallet
:proposal current-proposal
:on-success #(log/info "Wallet Connect session proposal rejected")
:on-error #(log/error "Wallet Connect unable to reject session proposal")}]
[:dispatch [:wallet-connect/reset-current-session-proposal]]]})))
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]})))
;; NOTE: Currently we only reject a session if the user rejected it
;; But this needs to be solidified to ensure other cases:
@@ -5,14 +5,15 @@
{:padding-horizontal 20
:padding-top 12})
(def approval-note-container
(defn approval-note-container
[theme]
{:margin-horizontal 20
:padding-horizontal 16
:padding-vertical 12
:border-radius 16
:border-width 1
:border-color colors/neutral-10
:background-color colors/neutral-2_5})
:border-color (colors/theme-colors colors/neutral-10 colors/black-opa-30 theme)
:background-color (colors/theme-colors colors/neutral-2_5 colors/black-opa-30 theme)})
(def approval-note-title
{:color colors/neutral-50
@@ -6,21 +6,27 @@
[quo.theme]
[react-native.core :as rn]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
[status-im.contexts.wallet.wallet-connect.session-proposal.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
[utils.re-frame :as rf]
[utils.string]))
(defn- dapp-metadata
[]
(let [proposer (rf/sub [:wallet-connect/session-proposer])
{:keys [icons name url]} (:metadata proposer)]
{:keys [icons name url]} (:metadata proposer)
first-icon (first icons)
dapp-name (wallet-connect-core/compute-dapp-name name url)
profile-picture (wallet-connect-core/compute-dapp-icon-path first-icon url)]
[:<>
[rn/view {:style style/dapp-avatar}
[quo/user-avatar
{:profile-picture (first icons)
:size :big}]]
{:profile-picture profile-picture
:size :big
:full-name dapp-name}]]
[quo/page-top
{:title name
{:title dapp-name
:description :context-tag
:context-tag {:type :icon
:size 32
@@ -31,8 +37,9 @@
[]
(let [dapp-name (rf/sub [:wallet-connect/session-proposer-name])
labels [(i18n/label :t/check-your-account-balance-and-activity)
(i18n/label :t/request-txns-and-message-signing)]]
[rn/view {:style style/approval-note-container}
(i18n/label :t/request-txns-and-message-signing)]
theme (quo.theme/use-theme)]
[rn/view {:style (style/approval-note-container theme)}
[quo/text
{:style style/approval-note-title
:weight :regular
@@ -46,7 +53,8 @@
{:color colors/neutral-40}]
[quo/text
{:weight :regular
:size :paragraph-2}
:size :paragraph-2
:color colors/neutral-40}
label]])
labels)]))
@@ -62,7 +70,7 @@
(defn- accounts-list
[]
(let [accounts (rf/sub [:wallet/operable-accounts-without-watched-accounts])
(let [accounts (rf/sub [:wallet/operable-accounts])
selected-address (rf/sub [:wallet-connect/current-proposal-address])]
[rn/view {:style style/account-switcher-list}
(for [{:keys [address] :as account} accounts]
@@ -141,7 +149,6 @@
:button-two-props {:type :grey
:accessibility-label :wc-deny-connection
:on-press (fn []
(rf/dispatch [:navigate-back])
(rf/dispatch
[:wallet-connect/reject-session-proposal]))}
:button-one-label (i18n/label :t/connect)
-9
View File
@@ -37,15 +37,6 @@
:id :screen/profile.profiles
:options (options/dark-root-options)}}]}}}
:screen/onboarding.enable-notifications
{:root {:stack {:children [{:component {:name :screen/onboarding.enable-notifications
:id :screen/onboarding.enable-notifications
:options (options/dark-root-options)}}]}}}
:screen/onboarding.welcome
{:root {:stack {:children [{:component {:name :screen/onboarding.welcome
:id :screen/onboarding.welcome
:options (options/dark-root-options)}}]}}}
:screen/onboarding.syncing-results
{:root {:stack {:children [{:component {:name :screen/onboarding.syncing-results
:id :screen/onboarding.syncing-results
+17 -12
View File
@@ -2,7 +2,6 @@
(:require
[legacy.status-im.ui.screens.screens :as old-screens]
[quo.foundations.colors :as colors]
[re-frame.core :as rf]
[status-im.common.emoji-picker.view :as emoji-picker]
[status-im.common.enter-seed-phrase.view :as enter-seed-phrase]
[status-im.common.lightbox.view :as lightbox]
@@ -119,6 +118,7 @@
[status-im.contexts.wallet.send.transaction-confirmation.view :as wallet-transaction-confirmation]
[status-im.contexts.wallet.send.transaction-progress.view :as wallet-transaction-progress]
[status-im.contexts.wallet.swap.select-asset-to-pay.view :as wallet-swap-select-asset-to-pay]
[status-im.contexts.wallet.swap.set-spending-cap.view :as wallet-swap-set-spending-cap]
[status-im.contexts.wallet.swap.swap-confirmation.view :as wallet-swap-confirmation]
[status-im.contexts.wallet.swap.swap-proposal.view :as wallet-swap-propasal]
[status-im.contexts.wallet.wallet-connect.modals.send-transaction.view :as
@@ -348,11 +348,15 @@
:component enter-seed-phrase/view}
{:name :screen/onboarding.enable-notifications
:options {:theme :dark
:layout options/onboarding-transparent-layout
:animations (merge
transitions/new-to-status-modal-animations
transitions/push-animations-for-transparent-background)}
:options {:theme :dark
:layout options/onboarding-transparent-layout
:animations (merge
transitions/new-to-status-modal-animations
transitions/push-animations-for-transparent-background)
:popGesture false
:modalPresentationStyle :overCurrentContext
:hardwareBackButton {:dismissModalOnPress false
:popStackOnPress false}}
:component enable-notifications/view}
{:name :screen/onboarding.identifiers
@@ -527,6 +531,10 @@
:options {:modalPresentationStyle :overCurrentContext}
:component wallet-swap-confirmation/view}
{:name :screen/wallet.swap-set-spending-cap
:options {:sheet? true}
:component wallet-swap-set-spending-cap/view}
{:name :scan-profile-qr-code
:options (merge
options/dark-screen
@@ -540,18 +548,15 @@
;; Wallet Connect
{:name :screen/wallet-connect.sign-message
:options {:sheet? true
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
:options {:sheet? true}
:component wallet-connect-sign-message/view}
{:name :screen/wallet-connect.sign-transaction
:options {:sheet? true
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
:options {:sheet? true}
:component wallet-connect-sign-transaction/view}
{:name :screen/wallet-connect.send-transaction
:options {:sheet? true
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
:options {:sheet? true}
:component wallet-connect-send-transaction/view}
{:name :screen/wallet.connected-dapps
+16 -17
View File
@@ -57,22 +57,22 @@
[screen-key]
(reagent.core/reactify-component
(fn []
(let [screen-details (get (if js/goog.DEBUG
(get-screens)
screens)
(keyword screen-key))
qualified-screen-details (get (if js/goog.DEBUG
(get-screens)
screens)
(keyword "screen" screen-key))
{:keys [component options]} (or qualified-screen-details screen-details)
(let [screen-details (get (if js/goog.DEBUG
(get-screens)
screens)
(keyword screen-key))
qualified-screen-details (get (if js/goog.DEBUG
(get-screens)
screens)
(keyword "screen" screen-key))
{:keys [component options]} (or qualified-screen-details screen-details)
{:keys [insets sheet? theme
skip-background? on-dismiss-sheet]} options
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
background-color (or (get-in options [:layout :backgroundColor])
(when sheet? :transparent))
app-theme (rf/sub [:theme])
theme (or theme app-theme)]
skip-background?]} options
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
background-color (or (get-in options [:layout :backgroundColor])
(when sheet? :transparent))
app-theme (rf/sub [:theme])
theme (or theme app-theme)]
^{:key (str "root" screen-key @reloader/cnt)}
[quo.theme/provider theme
[rn/view
@@ -83,8 +83,7 @@
:alert-banners-top-margin alert-banners-top-margin))}
[inactive]
(if sheet?
[bottom-sheet-screen/view
{:content component :skip-background? skip-background? :on-dismiss on-dismiss-sheet}]
[bottom-sheet-screen/view {:content component :skip-background? skip-background?}]
[component])]
(when js/goog.DEBUG
[:<>
@@ -53,7 +53,7 @@
(re-frame/reg-sub :communities/accounts-to-reveal
(fn [[_ community-id]]
[(re-frame/subscribe [:wallet/operable-accounts-without-watched-accounts])
[(re-frame/subscribe [:wallet/operable-accounts])
(re-frame/subscribe [:communities/addresses-to-reveal community-id])])
(fn [[accounts addresses] _]
(filter #(contains? addresses (:address %))
@@ -61,7 +61,7 @@
(re-frame/reg-sub :communities/airdrop-account
(fn [[_ community-id]]
[(re-frame/subscribe [:wallet/operable-accounts-without-watched-accounts])
[(re-frame/subscribe [:wallet/operable-accounts])
(re-frame/subscribe [:communities/airdrop-address community-id])])
(fn [[accounts airdrop-address] _]
(->> accounts
+21 -7
View File
@@ -55,13 +55,13 @@
(filter-collectibles-in-chains collectibles chain-ids)))
(re-frame/reg-sub
:wallet/all-collectibles-list
:<- [:wallet]
(fn [{:keys [accounts]}]
:wallet/owned-collectibles-list
:<- [:wallet/accounts-without-watched-accounts]
(fn [accounts]
(let [max-collectibles (->> accounts
(map (comp count :collectibles val))
(map (comp count :collectibles))
(apply max))
all-collectibles (map (fn [[_address {:keys [collectibles]}]]
all-collectibles (map (fn [{:keys [collectibles]}]
(let [amount-to-add (- max-collectibles (count collectibles))
empty-collectibles (repeat amount-to-add nil)]
(reduce conj collectibles empty-collectibles)))
@@ -72,8 +72,8 @@
(add-collectibles-preview-url)))))
(re-frame/reg-sub
:wallet/all-collectibles-list-in-selected-networks
:<- [:wallet/all-collectibles-list]
:wallet/owned-collectibles-list-in-selected-networks
:<- [:wallet/owned-collectibles-list]
:<- [:wallet/selected-networks->chain-ids]
(fn [[all-collectibles chain-ids]]
(filter-collectibles-in-chains all-collectibles chain-ids)))
@@ -123,3 +123,17 @@
%)
accounts))))
(re-frame/reg-sub
:wallet/total-owned-collectible
:<- [:wallet/accounts-without-watched-accounts]
(fn [accounts [_ ownership address]]
(let [addresses (map :address accounts)]
(reduce (fn [acc item]
(if (or
(and (not address)
(contains? (set addresses) (:address item)))
(= (:address item) address))
(+ acc (js/parseInt (:balance item)))
acc))
0
ownership))))
+41 -14
View File
@@ -134,10 +134,12 @@
(:chain-id %))))
(map :chain-id)
set)]
(assoc token
:networks (network-utils/network-list token networks)
:available-balance (utils/calculate-total-token-balance token)
:total-balance (utils/calculate-total-token-balance token enabled-from-chain-ids)))))
(some-> token
(assoc :networks (network-utils/network-list token networks)
:available-balance (utils/calculate-total-token-balance token)
:total-balance (utils/calculate-total-token-balance
token
enabled-from-chain-ids))))))
(rf/reg-sub
:wallet/wallet-send-token-symbol
@@ -416,7 +418,7 @@
:total-balance (utils/calculate-total-token-balance token
chain-ids)))
(:tokens account))
sorted-tokens (sort-by :name compare tokens)]
sorted-tokens (utils/sort-tokens tokens)]
(if query
(let [query-string (string/lower-case query)]
(filter #(or (string/starts-with? (string/lower-case (:name %)) query-string)
@@ -464,22 +466,47 @@
keep-operable-accounts)
(rf/reg-sub
:wallet/operable-accounts-without-watched-accounts
:wallet/operable-accounts
:<- [:wallet/accounts-without-watched-accounts]
keep-operable-accounts)
(rf/reg-sub
:wallet/operable-addresses-tokens-with-positive-balance
:<- [:wallet/operable-accounts]
(fn [accounts]
(let [positive-balance-in-any-chain? (fn [{:keys [balances-per-chain]}]
(->> balances-per-chain
(map (comp :raw-balance val))
(some pos?)))]
(as-> accounts $
(group-by :address $)
(update-vals $ #(filter positive-balance-in-any-chain? (:tokens (first %))))))))
(rf/reg-sub
:wallet/accounts-with-current-asset
:<- [:wallet/operable-accounts-without-watched-accounts]
:<- [:wallet/operable-accounts]
:<- [:wallet/operable-addresses-tokens-with-positive-balance]
:<- [:wallet/wallet-send-token-symbol]
:<- [:wallet/wallet-send-token]
(fn [[accounts token-symbol token]]
(let [asset-symbol (or token-symbol (:symbol token))]
(if asset-symbol
(filter (fn [account]
(some #(= (:symbol %) asset-symbol) (:tokens account)))
accounts)
accounts))))
(fn [[accounts addresses-tokens token-symbol token]]
(if-let [asset-symbol (or token-symbol (:symbol token))]
(let [addresses-with-asset (as-> addresses-tokens $
(update-vals $ #(set (map :symbol %)))
(keep (fn [[address token-symbols]]
(when (token-symbols asset-symbol) address))
$)
(set $))]
(filter #(addresses-with-asset (:address %)) accounts))
accounts)))
(rf/reg-sub
:wallet/operable-addresses-with-token-symbol
:<- [:wallet/operable-addresses-tokens-with-positive-balance]
(fn [addresses-tokens [_ token-symbol]]
(keep (fn [[address tokens]]
(some #(when (= (:symbol %) token-symbol) address)
tokens))
addresses-tokens)))
(rf/reg-sub
:wallet/account-tab
@@ -5,7 +5,8 @@
[status-im.contexts.wallet.common.utils.networks :as networks]
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
[status-im.contexts.wallet.wallet-connect.transactions :as transactions]
[utils.money :as money]))
[utils.money :as money]
[utils.string]))
(rf/reg-sub
:wallet-connect/current-request-address
@@ -44,7 +45,8 @@
(let [dapp-url (get-in request [:event :verifyContext :verified :origin])]
(->> sessions
(filter (fn [session]
(= dapp-url (get session :url))))
(= (utils.string/remove-trailing-slash dapp-url)
(utils.string/remove-trailing-slash (get session :url)))))
(first)))))
(rf/reg-sub
@@ -168,7 +170,8 @@
:wallet-connect/session-proposer-name
:<- [:wallet-connect/session-proposer]
(fn [proposer]
(-> proposer :metadata :name)))
(let [{:keys [name url]} (-> proposer :metadata)]
(wallet-connect-core/compute-dapp-name name url))))
(rf/reg-sub
:wallet-connect/session-proposal-network-details
@@ -42,6 +42,41 @@
:origin "https://lab.web3modal.com"
:isScam false}}}})
(def sample-session-empty-name
{:session-proposal
{:id 1716798889093634
:params
{:id 1716798889093634
:pairingTopic "9b18e1348817a548bbc97f9b4a09278f4fdf7c984e4a61ddf461bd1f57710d33"
:expiryTimestamp 1716799189
:requiredNamespaces {}
:optionalNamespaces {:eip155
{:chains ["eip155:1" "eip155:42161" "eip155:137" "eip155:43114" "eip155:56"
"eip155:10" "eip155:100"
"eip155:324" "eip155:7777777" "eip155:8453" "eip155:42220"
"eip155:1313161554" "eip155:11155111" "eip155:11155420"]
:methods ["personal_sign" "eth_accounts" "eth_requestAccounts"
"eth_sendRawTransaction" "eth_sendTransaction"
"eth_sign" "eth_signTransaction" "eth_signTypedData"
"eth_signTypedData_v3" "eth_signTypedData_v4"
"wallet_addEthereumChain" "wallet_getCallsStatus"
"wallet_getCapabilities" "wallet_getPermissions"
"wallet_registerOnboarding" "wallet_requestPermissions"
"wallet_scanQRCode" "wallet_sendCalls"
"wallet_showCallsStatus" "wallet_switchEthereumChain"
"wallet_watchAsset"]
:events ["chainChanged" "accountsChanged"]}}
:relays [{:protocol "irn"}]
:proposer {:publicKey "cddea055b8974d93380e6c7e72110145506c06524047866f8034f3db0990137a"
:metadata {:name ""
:description "Web3Modal Laboratory"
:url "https://lab.web3modal.com"
:icons ["https://avatars.githubusercontent.com/u/37784886"]}}}
:verifyContext {:verified {:verifyUrl "https://verify.walletconnect.com"
:validation "VALID"
:origin "https://lab.web3modal.com"
:isScam false}}}})
(h/deftest-sub :wallet-connect/session-proposer
[sub-name]
(testing "Return the session proposer public key and metadata"
+22 -8
View File
@@ -13,16 +13,22 @@
{:before #(reset! rf-db/app-db {})})
(def ^:private accounts-with-tokens
{:0x1 {:tokens [{:symbol "ETH"} {:symbol "SNT"}]
{:0x1 {:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
:operable :fully}
:0x2 {:tokens [{:symbol "SNT"}]
:operable :fully
:address "0x1"}
:0x2 {:tokens [{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "200"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
:operable :partially}})
:operable :partially
:address "0x2"}})
(def tokens-0x1
[{:decimals 1
@@ -495,11 +501,15 @@
(assoc-in [:wallet :ui :send :token-symbol] "ETH")))
(let [result (rf/sub [sub-name])]
(is (match? result
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
:operable :fully}]))))
:operable :fully
:address "0x1"}]))))
(testing "returns the accounts list with the current asset using token"
(swap! rf-db/app-db
@@ -508,11 +518,15 @@
(assoc-in [:wallet :ui :send :token] {:symbol "ETH"})))
(let [result (rf/sub [sub-name])]
(is (match? result
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
:operable :fully}]))))
:operable :fully
:address "0x1"}]))))
(testing
"returns the full accounts list with the current asset using token-symbol if each account has the asset"
+15
View File
@@ -73,3 +73,18 @@
(defn contains-special-character?
[s]
(re-find #"[^a-zA-Z0-9\s]" s))
(defn remove-trailing-slash
"Given a URL, checks if it has a trailing slash and removes it.
Returns the URL as-is if there is no trailing slash."
[url]
(if (and (string? url) (string/ends-with? url "/"))
(subs url 0 (dec (count url)))
url))
(defn remove-http-prefix
"Given a URL, removes the 'http://' or 'https://' prefix if present.
Returns the URL without the prefix."
[url]
(when (string? url)
(string/replace url #"^https?://" "")))
+22
View File
@@ -18,3 +18,25 @@
"AB" "a b" 2
"ABC" "a b c d" 3
"ABC" " a b c d" 3))
(deftest remove-trailing-slash-test
(are [expected input]
(= expected (utils.string/remove-trailing-slash input))
"http://example.com" "http://example.com/"
"http://example.com" "http://example.com"
"http://example.com/path" "http://example.com/path/"
"http://example.com/path" "http://example.com/path"
"" ""
nil nil))
(deftest remove-http-prefix-test
(are [expected input]
(= expected (utils.string/remove-http-prefix input))
"example.com" "http://example.com"
"example.com" "https://example.com"
"example.com" "example.com"
"example.com/path" "http://example.com/path"
"example.com/path" "https://example.com/path"
"example.com/path" "example.com/path"
"" ""
nil nil))
+5
View File
@@ -18,6 +18,7 @@
"accepted": "Accepted",
"access-existing-keys": "Access existing keys",
"access-key": "Access key",
"account": "Account",
"account-added": "Account added",
"account-color": "Account color",
"account-content": "You can compare accounts in Status to bank accounts. Like a bank account, an account typically has an address and a balance; You use this account to transact on Ethereum. You can have multiple accounts in your wallet. All accessed by unlocking Status.",
@@ -1016,6 +1017,7 @@
"fleet-settings": "Fleet settings",
"follow": "Follow",
"follow-your-interests": "Jump into a public chat and meet new people",
"for": "for",
"for-airdrops": "For airdrops",
"forgot-password": "Forgot password?",
"forgot-your-password-info-create-new-password": "Create a new password",
@@ -2189,6 +2191,7 @@
"set-dapp-access-permissions": "Set DApp access permissions",
"set-max": "Set max",
"set-nickname-toast": "You have renamed {{primary-name}} as {{nickname}}",
"set-spending-cap-of": "Set spending cap of",
"set-up-sync": "Set up sync",
"settings": "Settings",
"setup-group-chat": "Setup group chat",
@@ -2285,6 +2288,8 @@
"specify-network-id": "Specify network id",
"specify-server-public-key": "Enter server public key",
"specify-symbol": "Specify a symbol",
"spender-contract": "Spender contract",
"spending-cap": "Spending cap",
"start-chat": "Start chat",
"start-conversation": "Start conversation",
"start-group-chat": "Start group chat",