Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a9ad0ccea | ||
|
|
a8a08c82b0 | ||
|
|
aa28678188 | ||
|
|
67aa733736 | ||
|
|
cee21241d4 | ||
|
|
60ad7c8a29 | ||
|
|
4989c92780 | ||
|
|
c6a63e30b2 | ||
|
|
07005f8ad5 | ||
|
|
3ab345563c | ||
|
|
cef1308b3a | ||
|
|
4b8a612df4 | ||
|
|
e4639c153f | ||
|
|
8597b899bd | ||
|
|
a5c8182461 | ||
|
|
89bb3ea5c3 | ||
|
|
3bb7c308e3 |
@@ -74,7 +74,8 @@
|
||||
;; https://github.com/borkdude/clj-kondo/issues/867
|
||||
:unresolved-symbol {:exclude [PersistentPriorityMap.EMPTY
|
||||
number
|
||||
legacy.status-im.test-helpers/restore-app-db]}
|
||||
legacy.status-im.test-helpers/restore-app-db
|
||||
(cljs.test/is [match-strict?])]}
|
||||
:unresolved-var {:level :error}
|
||||
:unsorted-required-namespaces {:level :error}
|
||||
:unused-alias {:level :warning}
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
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:
|
||||

|
||||

|
||||
|
||||
|
||||
## 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.
|
||||

|
||||
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.
|
||||

|
||||
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 it’s 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 it’s 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
|
||||

|
||||

|
||||
|
||||
|
||||
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.
|
||||
@@ -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).
|
||||
@@ -711,11 +711,11 @@
|
||||
},
|
||||
|
||||
{
|
||||
"path": "nubank/matcher-combinators/3.8.8/matcher-combinators-3.8.8",
|
||||
"path": "nubank/matcher-combinators/3.9.1/matcher-combinators-3.9.1",
|
||||
"host": "https://repo.clojars.org",
|
||||
"jar": {
|
||||
"sha1": "4c94bd510f0c18a20191e46dd6becedebc640bbd",
|
||||
"sha256": "0wpla2hx0s4mda58ndyd8938zmnz1gyhgfr6pzfphy27xfbvsssl"
|
||||
"sha1": "f0830a112cae8ee931a90d9f39214a0ed4d44150",
|
||||
"sha256": "1rjcgqhms84xmnhs7sqcd3b2dpa37mmzgz2yz33yz2rdb9skl96g"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ net/cgrand/macrovich/0.2.1/macrovich-0.2.1.jar
|
||||
net/java/dev/jna/jna/5.12.1/jna-5.12.1.jar
|
||||
nrepl/bencode/1.1.0/bencode-1.1.0.jar
|
||||
nrepl/nrepl/1.0.0/nrepl-1.0.0.jar
|
||||
nubank/matcher-combinators/3.8.8/matcher-combinators-3.8.8.jar
|
||||
nubank/matcher-combinators/3.9.1/matcher-combinators-3.9.1.jar
|
||||
org/apache/ant/ant/1.10.11/ant-1.10.11.jar
|
||||
org/apache/ant/ant-launcher/1.10.11/ant-launcher-1.10.11.jar
|
||||
org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
[cider/piggieback "0.4.1"]
|
||||
[org.slf4j/slf4j-nop "2.0.9"]
|
||||
[re-frisk-remote "1.6.0"]
|
||||
[nubank/matcher-combinators "3.8.8"]
|
||||
[nubank/matcher-combinators "3.9.1"]
|
||||
|
||||
;; Use the same version specified in the Nix dependency.
|
||||
[clj-kondo/clj-kondo "2024.03.13"]
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
legacy.status-im.multiaccounts.logout.core
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
legacy.status-im.multiaccounts.update.core
|
||||
legacy.status-im.network.net-info
|
||||
legacy.status-im.pairing.core
|
||||
legacy.status-im.profile.core
|
||||
legacy.status-im.search.core
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
(ns legacy.status-im.network.net-info
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn change-network-status
|
||||
[{:keys [db] :as cofx} is-connected?]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :network-status (if is-connected? :online :offline))}))
|
||||
|
||||
(rf/defn change-network-type
|
||||
[{:keys [db] :as cofx} network-type expensive?]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :network/type network-type)
|
||||
:network/notify-status-go [network-type expensive?]
|
||||
:dispatch [:mobile-network/on-network-status-change]}))
|
||||
|
||||
(rf/defn handle-network-info-change
|
||||
{:events [::network-info-changed]}
|
||||
[{:keys [db] :as cofx} {:keys [isConnected type details] :as state}]
|
||||
(let [old-network-status (:network-status db)
|
||||
old-network-type (:network/type db)
|
||||
connectivity-status (if isConnected :online :offline)
|
||||
status-changed? (= connectivity-status old-network-status)
|
||||
type-changed? (= type old-network-type)]
|
||||
(log/debug "[net-info]"
|
||||
"old-network-status" old-network-status
|
||||
"old-network-type" old-network-type
|
||||
"connectivity-status" connectivity-status
|
||||
"type" type
|
||||
"details" details)
|
||||
(rf/merge cofx
|
||||
(when-not status-changed?
|
||||
(change-network-status isConnected))
|
||||
(when-not type-changed?
|
||||
(change-network-type type (:is-connection-expensive details))))))
|
||||
|
||||
(defn add-net-info-listener
|
||||
[]
|
||||
(when net-info
|
||||
(.addEventListener ^js net-info
|
||||
#(re-frame/dispatch [::network-info-changed
|
||||
(js->clj % :keywordize-keys true)]))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/listen-to-network-info
|
||||
(fn []
|
||||
(add-net-info-listener)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/notify-status-go
|
||||
(fn [[network-type expensive?]]
|
||||
(native-module/connection-change network-type expensive?)))
|
||||
@@ -4,6 +4,7 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.platform :as utils.platform]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.new-device-sheet.view :as new-device-sheet]
|
||||
[status-im.config :as config]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
@@ -220,6 +221,12 @@
|
||||
:name (:name metadata)
|
||||
:device-type (:deviceType metadata))})
|
||||
|
||||
|
||||
(defn should-show-syncing-pop-up?
|
||||
[db installations]
|
||||
(and (:syncing/pairing-process-initiated? db)
|
||||
(first (filter #(not (get-in db [:pairing/installations (:id %)])) installations))))
|
||||
|
||||
(rf/defn handle-installations
|
||||
[{:keys [db]} installations]
|
||||
{:db (update db
|
||||
@@ -228,7 +235,10 @@
|
||||
(fn [acc {:keys [id] :as i}]
|
||||
(update acc id merge (installation<-rpc i)))
|
||||
%
|
||||
installations))})
|
||||
installations))
|
||||
:fx [(when-let [new-installation (should-show-syncing-pop-up? db installations)]
|
||||
[:dispatch
|
||||
[:show-bottom-sheet {:content (fn [] [new-device-sheet/view (:id new-installation)])}]])]})
|
||||
|
||||
(rf/defn load-installations
|
||||
{:events [:pairing.callback/get-our-installations-success]}
|
||||
@@ -243,6 +253,24 @@
|
||||
{}
|
||||
installations))})
|
||||
|
||||
(rf/defn finish-seed-phrase-fallback-syncing
|
||||
{:events [:pairing/finish-seed-phrase-fallback-syncing]}
|
||||
[{:keys [db]}]
|
||||
{:fx [[:dispatch [:show-bottom-sheet {:content (fn [] [new-device-sheet/view-2])}]]
|
||||
[:json-rpc/call
|
||||
[{:method "wakuext_finishPairingThroughSeedPhraseProcess"
|
||||
:params [{:installationId (:syncing/installation-id db)}]
|
||||
:js-response true
|
||||
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %])}]]]})
|
||||
|
||||
(rf/defn pair-and-sync
|
||||
{:events [:pairing/pair-and-sync]}
|
||||
[cofx installation-id]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wakuext_enableAndSyncInstallation"
|
||||
:params [{:installationId installation-id}]
|
||||
:on-success #(log/debug "successfully synced devices")}]]]})
|
||||
|
||||
(rf/defn enable-installation-success
|
||||
{:events [:pairing.callback/enable-installation-success]}
|
||||
[cofx installation-id]
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
(reg-root-key-sub :visibility-status-updates :visibility-status-updates)
|
||||
(reg-root-key-sub :fleets/custom-fleets :custom-fleets)
|
||||
(reg-root-key-sub :ui/search :ui/search)
|
||||
(reg-root-key-sub :network/type :network/type)
|
||||
(reg-root-key-sub :network-status :network-status)
|
||||
(reg-root-key-sub :peer-stats/count :peer-stats/count)
|
||||
(reg-root-key-sub :peers-summary :peers-summary)
|
||||
(reg-root-key-sub :web3-node-version :web3-node-version)
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
[:app-state
|
||||
:current-chat-id
|
||||
:network
|
||||
:network-status
|
||||
:network/status
|
||||
:peers-summary
|
||||
:sync-state
|
||||
:view-id
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
#js
|
||||
{:getEnforcing {}})
|
||||
|
||||
(def net-info #js {})
|
||||
(def net-info #js {:addEventListener identity})
|
||||
(def react-native-biometrics #js {:default {}})
|
||||
(def react-native-static-safe-area-insets #js {:default {}})
|
||||
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
(oops/ocall wc-utils
|
||||
"buildApprovedNamespaces"
|
||||
(bean/->js {:proposal proposal
|
||||
:supportedNamespaces supported-namespaces})))
|
||||
:supportedNamespaces (clj->js supported-namespaces)})))
|
||||
|
||||
;; Get an error from this list:
|
||||
;; https://github.com/WalletConnect/walletconnect-monorepo/blob/c6e9529418a0c81d4efcc6ac4e61f242a50b56c5/packages/utils/src/errors.ts
|
||||
@@ -51,9 +51,10 @@
|
||||
|
||||
(defn reject-session
|
||||
[{:keys [web3-wallet id reason]}]
|
||||
(.rejectSession web3-wallet
|
||||
(clj->js {:id id
|
||||
:reason reason})))
|
||||
(oops/ocall web3-wallet
|
||||
"rejectSession"
|
||||
(bean/->js {:id id
|
||||
:reason reason})))
|
||||
|
||||
(defn approve-session
|
||||
[{:keys [web3-wallet id approved-namespaces]}]
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
(ns status-im.common.new-device-sheet.style
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(def heading
|
||||
{:padding-left 20
|
||||
:padding-bottom 8})
|
||||
|
||||
(def message
|
||||
{:padding-horizontal 20
|
||||
:padding-top 4})
|
||||
|
||||
(def warning
|
||||
{:margin-horizontal 20
|
||||
:margin-top 10})
|
||||
|
||||
(def drawer-container
|
||||
{:padding-horizontal 13
|
||||
:padding-top 16})
|
||||
|
||||
(def settings-subtext
|
||||
{:color colors/white-opa-70
|
||||
:align-self :center
|
||||
:margin-bottom 12})
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
(ns status-im.common.new-device-sheet.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[status-im.common.new-device-sheet.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- dismiss-keyboard
|
||||
[]
|
||||
(rf/dispatch [:dismiss-keyboard]))
|
||||
|
||||
(defn- hide-bottom-sheet
|
||||
[]
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
|
||||
(defn- pair-and-sync
|
||||
[installation-id]
|
||||
(rf/dispatch [:pairing/pair-and-sync installation-id])
|
||||
(hide-bottom-sheet))
|
||||
|
||||
(defn view
|
||||
[installation-id]
|
||||
(dismiss-keyboard)
|
||||
[:<>
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:size :heading-2
|
||||
:accessibility-label :new-device-sheet-heading
|
||||
:style style/heading}
|
||||
(i18n/label :t/pair-new-device-and-sync)]
|
||||
[quo/text
|
||||
{:weight :regular
|
||||
:size :paragraph-1
|
||||
:accessibility-label :new-device-sheet-message
|
||||
:style style/message}
|
||||
(i18n/label :t/new-device-detected)]
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:size :heading-2
|
||||
:accessibility-label :new-device-installation-id
|
||||
:style style/heading}
|
||||
installation-id]
|
||||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
:blur? true
|
||||
:container-style {:margin-top 12}
|
||||
:button-two-label (i18n/label :t/cancel)
|
||||
:button-two-props {:type :grey
|
||||
:on-press hide-bottom-sheet}
|
||||
:button-one-label (i18n/label :t/pair-and-sync)
|
||||
:button-one-props {:on-press #(pair-and-sync installation-id)}}]])
|
||||
|
||||
(defn view-2
|
||||
[]
|
||||
(let [installation-id (rf/sub [:profile/installation-id])]
|
||||
(dismiss-keyboard)
|
||||
[:<>
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:size :heading-2
|
||||
:accessibility-label :new-device-sheet-heading
|
||||
:style style/heading}
|
||||
(i18n/label :t/pair-new-device-and-sync)]
|
||||
[quo/text
|
||||
{:weight :regular
|
||||
:size :paragraph-1
|
||||
:accessibility-label :new-device-sheet-message
|
||||
:style style/message}
|
||||
(i18n/label :t/check-new-device)]
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:size :heading-2
|
||||
:accessibility-label :new-device-installation-id
|
||||
:style style/heading}
|
||||
installation-id]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:blur? true
|
||||
:container-style {:margin-top 12}
|
||||
:button-one-label (i18n/label :t/close)
|
||||
:button-one-props {:type :grey
|
||||
:on-press hide-bottom-sheet}}]]))
|
||||
@@ -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)
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
(ns status-im.contexts.networks.events
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]
|
||||
[native-module.core :as native-module]
|
||||
[status-im.feature-flags :as ff]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/listen-to-network-info
|
||||
(fn []
|
||||
(when net-info
|
||||
(.addEventListener ^js net-info
|
||||
#(rf/dispatch [:network/on-state-change
|
||||
(js->clj % :keywordize-keys true)])))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-state-change
|
||||
(fn [{:keys [db]} [{:keys [isConnected type details]}]]
|
||||
(let [old-network-status (:network/status db)
|
||||
old-network-type (:network/type db)
|
||||
connectivity-status (if isConnected :online :offline)
|
||||
status-changed? (not= connectivity-status old-network-status)
|
||||
type-changed? (not= type old-network-type)
|
||||
is-connection-expensive? (:is-connection-expensive details)]
|
||||
(log/debug "[net-info]"
|
||||
"old-network-status" old-network-status
|
||||
"old-network-type" old-network-type
|
||||
"connectivity-status" connectivity-status
|
||||
"type" type
|
||||
"details" details)
|
||||
{:fx [(when status-changed?
|
||||
[:dispatch [:network/on-network-status-change isConnected]])
|
||||
(when type-changed?
|
||||
[:dispatch [:network/on-network-type-change type is-connection-expensive?]])]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-type-change
|
||||
(fn [{:keys [db]} [network-type expensive?]]
|
||||
{:db (assoc db :network/type network-type)
|
||||
:fx [[:effects.network/notify-status-go network-type expensive?]
|
||||
[:dispatch [:mobile-network/on-network-status-change]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-status-change
|
||||
(fn [{:keys [db]} [is-connected?]]
|
||||
(let [network-status (if is-connected? :online :offline)]
|
||||
{:db (assoc db :network/status network-status)
|
||||
:fx [(when (ff/enabled? ::ff/wallet.wallet-connect)
|
||||
[:dispatch [:wallet-connect/reload-on-network-change is-connected?]])]})))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/notify-status-go
|
||||
(fn [network-type expensive?]
|
||||
(native-module/connection-change network-type expensive?)))
|
||||
@@ -17,3 +17,17 @@
|
||||
{:events [:onboarding/overlay-dismiss]}
|
||||
[_]
|
||||
{:onboarding/overlay-dismiss-fx nil})
|
||||
|
||||
(re-frame/reg-fx
|
||||
:onboarding/overlay-show-fx
|
||||
(fn []
|
||||
(when-let [blur-show-fn @overlay/blur-show-fn-atom]
|
||||
(blur-show-fn))
|
||||
(when-let [push-animation-fn @profiles/push-animation-fn-atom]
|
||||
(push-animation-fn))))
|
||||
|
||||
(rf/defn overlay-show
|
||||
{:events [:onboarding/overlay-show]}
|
||||
[_]
|
||||
{:onboarding/overlay-show-fx nil})
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -123,25 +125,31 @@
|
||||
mnemonic key-uid]))
|
||||
on-error]})
|
||||
|
||||
;; TODO: clear syncing data if key-uid does not match
|
||||
(rf/defn seed-phrase-validated
|
||||
{:events [:onboarding/seed-phrase-validated]}
|
||||
[{:keys [db]} seed-phrase key-uid]
|
||||
(if (contains? (:profile/profiles-overview db) key-uid)
|
||||
{:effects.utils/show-confirmation
|
||||
{:title (i18n/label :t/multiaccount-exists-title)
|
||||
:content (i18n/label :t/multiaccount-exists-content)
|
||||
:confirm-button-text (i18n/label :t/unlock)
|
||||
:on-accept (fn []
|
||||
(re-frame/dispatch [:pop-to-root :screen/profile.profiles])
|
||||
(re-frame/dispatch
|
||||
[:profile/profile-selected key-uid]))
|
||||
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
|
||||
{:db (assoc-in db [:onboarding/profile :seed-phrase] seed-phrase)
|
||||
:dispatch [:navigate-to-within-stack
|
||||
[:screen/onboarding.create-profile
|
||||
(get db
|
||||
:onboarding/navigated-to-enter-seed-phrase-from-screen
|
||||
:screen/onboarding.new-to-status)]]}))
|
||||
(let [next-screen (if (and (seq (:syncing/key-uid db))
|
||||
(= (:syncing/key-uid db) key-uid))
|
||||
:screen/onboarding.create-profile-password
|
||||
:screen/onboarding.create-profile)]
|
||||
|
||||
(if (contains? (:profile/profiles-overview db) key-uid)
|
||||
{:effects.utils/show-confirmation
|
||||
{:title (i18n/label :t/multiaccount-exists-title)
|
||||
:content (i18n/label :t/multiaccount-exists-content)
|
||||
:confirm-button-text (i18n/label :t/unlock)
|
||||
:on-accept (fn []
|
||||
(re-frame/dispatch [:pop-to-root :screen/profile.profiles])
|
||||
(re-frame/dispatch
|
||||
[:profile/profile-selected key-uid]))
|
||||
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
|
||||
{:db (assoc-in db [:onboarding/profile :seed-phrase] seed-phrase)
|
||||
:dispatch [:navigate-to-within-stack
|
||||
[next-screen
|
||||
(get db
|
||||
:onboarding/navigated-to-enter-seed-phrase-from-screen
|
||||
:screen/onboarding.new-to-status)]]})))
|
||||
|
||||
(rf/defn navigate-to-create-profile
|
||||
{:events [:onboarding/navigate-to-create-profile]}
|
||||
@@ -187,14 +195,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]}]}))
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(def absolute-fill
|
||||
{:position :absolute
|
||||
:top 0
|
||||
:bottom 0
|
||||
:left 0
|
||||
:right 0})
|
||||
|
||||
(defn page-container
|
||||
[in-onboarding?]
|
||||
{:flex 1
|
||||
|
||||
@@ -26,33 +26,62 @@
|
||||
:title-accessibility-label :progress-screen-title
|
||||
:description-accessibility-label :progress-screen-sub-title}])
|
||||
|
||||
(defn navigate-to-enter-seed-phrase
|
||||
[view-id]
|
||||
(if (= view-id :screen/onboarding.syncing-progress-intro)
|
||||
(do
|
||||
(rf/dispatch [:navigate-back-to :screen/onboarding.sync-or-recover-profile])
|
||||
(debounce/debounce-and-dispatch
|
||||
[:onboarding/navigate-to-sign-in-by-seed-phrase :screen/onboarding.sync-or-recover-profile]
|
||||
300))
|
||||
(do
|
||||
(rf/dispatch [:navigate-back])
|
||||
(debounce/debounce-and-dispatch [:onboarding/overlay-show] 100)
|
||||
(debounce/debounce-and-dispatch [:open-modal :screen/onboarding.new-to-status] 200)
|
||||
(debounce/debounce-and-dispatch
|
||||
[:onboarding/navigate-to-sign-in-by-seed-phrase :screen/onboarding.new-to-status]
|
||||
300))))
|
||||
|
||||
(defn try-again-button
|
||||
[profile-color in-onboarding? logged-in?]
|
||||
[quo/button
|
||||
{:on-press (fn []
|
||||
(rf/dispatch [:syncing/clear-states])
|
||||
(cond
|
||||
logged-in? (rf/dispatch [:navigate-back])
|
||||
in-onboarding? (rf/dispatch [:navigate-back-to
|
||||
:screen/onboarding.sign-in-intro])
|
||||
:else (do
|
||||
(rf/dispatch [:navigate-back])
|
||||
(debounce/throttle-and-dispatch
|
||||
[:open-modal
|
||||
:screen/onboarding.sign-in]
|
||||
1000))))
|
||||
:accessibility-label :try-again-later-button
|
||||
:customization-color profile-color
|
||||
:container-style style/try-again-button}
|
||||
(i18n/label :t/try-again)])
|
||||
[profile-color in-onboarding? logged-in? view-id]
|
||||
[rn/view
|
||||
(when-not logged-in?
|
||||
[quo/button
|
||||
{:on-press #(navigate-to-enter-seed-phrase view-id)
|
||||
:accessibility-label :try-seed-phrase-button
|
||||
:customization-color profile-color
|
||||
:container-style style/try-again-button}
|
||||
(i18n/label :t/enter-seed-phrase)])
|
||||
|
||||
|
||||
[quo/button
|
||||
{:on-press (fn []
|
||||
(rf/dispatch [:syncing/clear-states])
|
||||
(cond
|
||||
logged-in? (rf/dispatch [:navigate-back])
|
||||
in-onboarding? (rf/dispatch [:navigate-back-to
|
||||
:screen/onboarding.sign-in-intro])
|
||||
:else (do
|
||||
(rf/dispatch [:navigate-back])
|
||||
(debounce/throttle-and-dispatch
|
||||
[:open-modal
|
||||
:screen/onboarding.sign-in]
|
||||
1000))))
|
||||
:accessibility-label :try-again-later-button
|
||||
:customization-color profile-color
|
||||
:container-style style/try-again-button}
|
||||
(i18n/label :t/try-again)]])
|
||||
|
||||
(defn view
|
||||
[in-onboarding?]
|
||||
(let [pairing-status (rf/sub [:pairing/pairing-status])
|
||||
profile-color (:color (rf/sub [:onboarding/profile]))
|
||||
logged-in? (rf/sub [:multiaccount/logged-in?])]
|
||||
logged-in? (rf/sub [:multiaccount/logged-in?])
|
||||
view-id (rf/sub [:view-id])]
|
||||
[rn/view {:style (style/page-container in-onboarding?)}
|
||||
(when-not in-onboarding? [background/view true])
|
||||
(when-not in-onboarding?
|
||||
[rn/view {:style style/absolute-fill}
|
||||
[background/view true]])
|
||||
[quo/page-nav {:type :no-title :background :blur}]
|
||||
[page-title (pairing-progress pairing-status)]
|
||||
(if config/show-not-implemented-features?
|
||||
@@ -63,7 +92,7 @@
|
||||
[quo/text "[Error here]"]])
|
||||
[rn/view {:flex 1}])
|
||||
(when-not (pairing-progress pairing-status)
|
||||
[try-again-button profile-color in-onboarding? logged-in?])]))
|
||||
[try-again-button profile-color in-onboarding? logged-in? view-id])]))
|
||||
|
||||
(defn view-onboarding
|
||||
[]
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.reanimated :as reanimated]))
|
||||
|
||||
(def absolute-fill
|
||||
{:position :absolute
|
||||
:top 0
|
||||
:bottom 0
|
||||
:left 0
|
||||
:right 0})
|
||||
|
||||
(defn page-container
|
||||
[top]
|
||||
{:flex 1
|
||||
|
||||
@@ -66,7 +66,8 @@
|
||||
translate-x (reanimated/use-shared-value 0)
|
||||
window-width (:width (rn/get-window))]
|
||||
[rn/view {:style (style/page-container top)}
|
||||
[background/view true]
|
||||
[rn/view {:style style/absolute-fill}
|
||||
[background/view true]]
|
||||
[reanimated/view
|
||||
{:style (style/content translate-x)}
|
||||
[page-title]
|
||||
|
||||
@@ -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
|
||||
[]
|
||||
|
||||
@@ -124,6 +124,8 @@
|
||||
:on-success [:profile.login/node-info-fetched]
|
||||
:on-error #(log/error "node-info: failed error" %)}]]
|
||||
[:pairing/get-our-installations]
|
||||
(when (:syncing/installation-id db)
|
||||
[:dispatch [:pairing/finish-seed-phrase-fallback-syncing]])
|
||||
(when-not new-account?
|
||||
[:dispatch [:universal-links/process-stored-event]])]})))
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[status-im.common.emoji-picker.utils :as emoji-picker.utils]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.profile.config :as profile.config]
|
||||
status-im.contexts.profile.recover.effects
|
||||
[utils.re-frame :as rf]
|
||||
@@ -17,11 +18,11 @@
|
||||
(assoc-in [:syncing :login-sha3-password] login-sha3-password))
|
||||
|
||||
:effects.profile/restore-and-login
|
||||
(merge (profile.config/create)
|
||||
{:displayName display-name
|
||||
:mnemonic (security/safe-unmask-data seed-phrase)
|
||||
:password login-sha3-password
|
||||
:imagePath (profile.config/strip-file-prefix image-path)
|
||||
:customizationColor color
|
||||
:emoji (emoji-picker.utils/random-emoji)
|
||||
:fetchBackup true})}))
|
||||
(assoc (profile.config/create)
|
||||
:displayName display-name
|
||||
:mnemonic (security/safe-unmask-data seed-phrase)
|
||||
:password login-sha3-password
|
||||
:imagePath (profile.config/strip-file-prefix image-path)
|
||||
:customizationColor (or color constants/profile-default-color)
|
||||
:emoji (emoji-picker.utils/random-emoji)
|
||||
:fetchBackup true)}))
|
||||
|
||||
+32
-28
@@ -7,6 +7,7 @@
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.validation :as validation]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
@@ -18,20 +19,21 @@
|
||||
|
||||
(defn- validate-input
|
||||
[account-addresses saved-addresses user-input]
|
||||
(cond
|
||||
(string/blank? user-input)
|
||||
nil
|
||||
(let [[_ address-without-prefix] (utils/split-prefix-and-address user-input)]
|
||||
(cond
|
||||
(string/blank? user-input)
|
||||
nil
|
||||
|
||||
(contains? saved-addresses user-input)
|
||||
:existing-saved-address
|
||||
(contains? saved-addresses address-without-prefix)
|
||||
:existing-saved-address
|
||||
|
||||
(contains? account-addresses user-input)
|
||||
:own-account
|
||||
(contains? account-addresses address-without-prefix)
|
||||
:own-account
|
||||
|
||||
(not
|
||||
(or (validation/eth-address? user-input)
|
||||
(validation/ens-name? user-input)))
|
||||
:invalid-address-or-ens))
|
||||
(not
|
||||
(or (validation/eth-address? user-input)
|
||||
(validation/ens-name? user-input)))
|
||||
:invalid-address-or-ens)))
|
||||
|
||||
(defn- address-input
|
||||
[{:keys [input-value on-change-text paste-into-input clear-input]}]
|
||||
@@ -93,8 +95,9 @@
|
||||
|
||||
(defn- existing-saved-address
|
||||
[{:keys [address]}]
|
||||
(let [{:keys [name customization-color chain-short-names ens ens?]}
|
||||
(rf/sub [:wallet/saved-address-by-address address])]
|
||||
(let [[_ address-without-prefix] (utils/split-prefix-and-address address)
|
||||
{:keys [name customization-color chain-short-names ens ens?]}
|
||||
(rf/sub [:wallet/saved-address-by-address address-without-prefix])]
|
||||
[rn/view {:style style/existing-saved-address-container}
|
||||
[quo/text
|
||||
{:size :paragraph-1
|
||||
@@ -105,7 +108,7 @@
|
||||
{:blur? true
|
||||
:active-state? true
|
||||
:user-props {:name name
|
||||
:address (str chain-short-names address)
|
||||
:address (str chain-short-names address-without-prefix)
|
||||
:ens (when ens? ens)
|
||||
:customization-color customization-color
|
||||
:blur? true}
|
||||
@@ -168,20 +171,21 @@
|
||||
(rn/use-mount #(rf/dispatch [:wallet/clear-address-to-save]))
|
||||
[quo/overlay {:type :shell}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:header [quo/page-nav
|
||||
{:type :no-title
|
||||
:icon-name :i/close
|
||||
:behind-overlay? true
|
||||
:on-press navigate-back
|
||||
:margin-top (safe-area/get-top)
|
||||
:accessibility-label :add-address-to-save-page-nav}]
|
||||
:footer (when (= view-id :screen/settings.add-address-to-save)
|
||||
[quo/button
|
||||
{:customization-color profile-color
|
||||
:disabled? button-disabled?
|
||||
:on-press on-press-continue}
|
||||
(i18n/label :t/continue)])}
|
||||
{:footer-container-padding 0
|
||||
:keyboard-should-persist-taps :handled
|
||||
:header [quo/page-nav
|
||||
{:type :no-title
|
||||
:icon-name :i/close
|
||||
:behind-overlay? true
|
||||
:on-press navigate-back
|
||||
:margin-top (safe-area/get-top)
|
||||
:accessibility-label :add-address-to-save-page-nav}]
|
||||
:footer (when (= view-id :screen/settings.add-address-to-save)
|
||||
[quo/button
|
||||
{:customization-color profile-color
|
||||
:disabled? button-disabled?
|
||||
:on-press on-press-continue}
|
||||
(i18n/label :t/continue)])}
|
||||
[quo/page-top
|
||||
{:container-style style/header-container
|
||||
:blur? true
|
||||
|
||||
@@ -105,24 +105,25 @@
|
||||
[ens ens? open-network-preferences address-text])]
|
||||
[quo/overlay {:type :shell}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
|
||||
:header [quo/page-nav
|
||||
{:type :no-title
|
||||
:background :blur
|
||||
:icon-name (if edit? :i/close :i/arrow-left)
|
||||
:on-press navigate-back
|
||||
:margin-top (when-not edit? (safe-area/get-top))
|
||||
:accessibility-label :save-address-page-nav}]
|
||||
:footer [quo/button
|
||||
{:accessibility-label :save-address-button
|
||||
:type :primary
|
||||
:customization-color address-color
|
||||
:disabled? (string/blank? address-label)
|
||||
:on-press on-press-save}
|
||||
(i18n/label :t/save-address)]
|
||||
:customization-color address-color
|
||||
:gradient-cover? true
|
||||
:shell-overlay? true}
|
||||
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
|
||||
:keyboard-should-persist-taps :handled
|
||||
:header [quo/page-nav
|
||||
{:type :no-title
|
||||
:background :blur
|
||||
:icon-name (if edit? :i/close :i/arrow-left)
|
||||
:on-press navigate-back
|
||||
:margin-top (when-not edit? (safe-area/get-top))
|
||||
:accessibility-label :save-address-page-nav}]
|
||||
:footer [quo/button
|
||||
{:accessibility-label :save-address-button
|
||||
:type :primary
|
||||
:customization-color address-color
|
||||
:disabled? (string/blank? address-label)
|
||||
:on-press on-press-save}
|
||||
(i18n/label :t/save-address)]
|
||||
:customization-color address-color
|
||||
:gradient-cover? true
|
||||
:shell-overlay? true}
|
||||
[quo/wallet-user-avatar
|
||||
{:full-name (if (string/blank? address-label)
|
||||
placeholder
|
||||
|
||||
@@ -46,13 +46,29 @@
|
||||
(log/info "[local-pairing] input-connection-string-for-bootstrapping callback"
|
||||
{:response res
|
||||
:event :syncing/input-connection-string-for-bootstrapping})
|
||||
(let [error (when (sync-utils/extract-error res)
|
||||
(str "generic-error: " res))]
|
||||
(when (some? error)
|
||||
(let [response (transforms/json->clj res)
|
||||
installation-id (:installationId response)
|
||||
key-uid (:keyUID response)
|
||||
error (:error response)]
|
||||
(when (seq installation-id)
|
||||
(rf/dispatch [:syncing/set-syncing-installation-id installation-id key-uid]))
|
||||
(when (seq error)
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:type :negative
|
||||
:text error}]))))
|
||||
|
||||
(rf/defn initiate-pairing-process
|
||||
{:events [:syncing/initiate-pairing-process]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc db :syncing/pairing-process-initiated? true)})
|
||||
|
||||
(rf/defn set-syncing-installation-id
|
||||
{:events [:syncing/set-syncing-installation-id]}
|
||||
[{:keys [db]} installation-id key-uid]
|
||||
{:db (assoc db
|
||||
:syncing/key-uid key-uid
|
||||
:syncing/installation-id installation-id)})
|
||||
|
||||
(rf/defn preflight-outbound-check-for-local-pairing
|
||||
{:events [:syncing/preflight-outbound-check]}
|
||||
[_ set-checks-passed]
|
||||
@@ -96,6 +112,7 @@
|
||||
(when (sync-utils/valid-connection-string? response)
|
||||
(on-valid-connection-string response)
|
||||
(rf/dispatch [:syncing/update-role constants/local-pairing-role-sender])
|
||||
(rf/dispatch [:syncing/initiate-pairing-process])
|
||||
(rf/dispatch [:hide-bottom-sheet])))]
|
||||
(when-not (and error (string/blank? error))
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])
|
||||
|
||||
@@ -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}]
|
||||
|
||||
@@ -12,13 +12,16 @@
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-routes-calculation]))
|
||||
[rn/view {:style style/bridge-send-wrapper}
|
||||
[input-amount/view
|
||||
{:current-screen-id :screen/wallet.bridge-input-amount
|
||||
:button-one-label (i18n/label :t/review-bridge)
|
||||
:button-one-props {:icon-left :i/bridge}
|
||||
:on-confirm (fn [amount]
|
||||
(rf/dispatch [:wallet/set-token-amount-to-bridge
|
||||
{:amount amount
|
||||
:stack-id :screen/wallet.bridge-input-amount}]))
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}]])
|
||||
{:current-screen-id :screen/wallet.bridge-input-amount
|
||||
:button-one-label (i18n/label :t/review-bridge)
|
||||
:button-one-props {:icon-left :i/bridge}
|
||||
:enabled-from-chain-ids (rf/sub
|
||||
[:wallet/bridge-from-chain-ids])
|
||||
:from-enabled-networks (rf/sub [:wallet/bridge-from-networks])
|
||||
:on-confirm (fn [amount]
|
||||
(rf/dispatch [:wallet/set-token-amount-to-bridge
|
||||
{:amount amount
|
||||
:stack-id :screen/wallet.bridge-input-amount}]))
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}]])
|
||||
|
||||
@@ -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])}])))])
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
[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]}]
|
||||
@@ -84,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)
|
||||
@@ -104,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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns status-im.contexts.wallet.data-store-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest is testing]]
|
||||
[matcher-combinators.matchers :as matchers]
|
||||
matcher-combinators.test
|
||||
[status-im.contexts.wallet.data-store :as sut]))
|
||||
|
||||
@@ -162,82 +161,73 @@
|
||||
(deftest reconcile-keypairs-test
|
||||
(testing "reconcile-keypairs represents updated key pairs and accounts"
|
||||
(is
|
||||
(match?
|
||||
(matchers/match-with
|
||||
[set? matchers/set-equals
|
||||
map? matchers/equals]
|
||||
{:removed-keypair-ids #{}
|
||||
:removed-account-addresses #{}
|
||||
:updated-accounts-by-address {"1x123" (merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})
|
||||
"1x456" (merge account
|
||||
{:key-uid "0x456"
|
||||
:address "1x456"
|
||||
:operable? false
|
||||
:operable :no})}
|
||||
:updated-keypairs-by-id {"0x123" {:key-uid "0x123"
|
||||
:type :seed
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})]}
|
||||
"0x456" {:key-uid "0x456"
|
||||
:type :key
|
||||
:lowest-operability :no
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x456"
|
||||
:address "1x456"
|
||||
:operable? false
|
||||
:operable :no})]}}})
|
||||
(match-strict?
|
||||
{:removed-keypair-ids #{}
|
||||
:removed-account-addresses #{}
|
||||
:updated-accounts-by-address {"1x123" (merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})
|
||||
"1x456" (merge account
|
||||
{:key-uid "0x456"
|
||||
:address "1x456"
|
||||
:operable? false
|
||||
:operable :no})}
|
||||
:updated-keypairs-by-id {"0x123" {:key-uid "0x123"
|
||||
:type :seed
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})]}
|
||||
"0x456" {:key-uid "0x456"
|
||||
:type :key
|
||||
:lowest-operability :no
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x456"
|
||||
:address "1x456"
|
||||
:operable? false
|
||||
:operable :no})]}}}
|
||||
(sut/reconcile-keypairs [raw-keypair-seed-phrase
|
||||
raw-keypair-private-key]))))
|
||||
(testing "reconcile-keypairs represents removed key pairs and accounts"
|
||||
(is
|
||||
(match?
|
||||
(matchers/match-with
|
||||
[set? matchers/set-equals
|
||||
map? matchers/equals]
|
||||
{:removed-keypair-ids #{"0x456"}
|
||||
:removed-account-addresses #{"1x456"}
|
||||
:updated-accounts-by-address {"1x123" (merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})}
|
||||
:updated-keypairs-by-id {"0x123" {:key-uid "0x123"
|
||||
:type :seed
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})]}}})
|
||||
(match-strict?
|
||||
{:removed-keypair-ids #{"0x456"}
|
||||
:removed-account-addresses #{"1x456"}
|
||||
:updated-accounts-by-address {"1x123" (merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})}
|
||||
:updated-keypairs-by-id {"0x123" {:key-uid "0x123"
|
||||
:type :seed
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x123"
|
||||
:address "1x123"})]}}}
|
||||
(sut/reconcile-keypairs [raw-keypair-seed-phrase
|
||||
(assoc raw-keypair-private-key :removed true)]))))
|
||||
(testing "reconcile-keypairs ignores chat accounts inside updated accounts"
|
||||
(is
|
||||
(match?
|
||||
(matchers/match-with
|
||||
[set? matchers/set-equals
|
||||
map? matchers/equals]
|
||||
{:removed-keypair-ids #{}
|
||||
:removed-account-addresses #{}
|
||||
:updated-accounts-by-address {"2x000" (merge account
|
||||
{:key-uid "0x000"
|
||||
:address "2x000"
|
||||
:chat false
|
||||
:wallet true
|
||||
:default-account? true})}
|
||||
:updated-keypairs-by-id {"0x000" {:key-uid "0x000"
|
||||
:type :profile
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x000"
|
||||
:address "1x000"
|
||||
:chat true
|
||||
:wallet false
|
||||
:default-account? false})
|
||||
(merge account
|
||||
{:key-uid "0x000"
|
||||
:address "2x000"
|
||||
:chat false
|
||||
:wallet true
|
||||
:default-account? true})]}}})
|
||||
(match-strict?
|
||||
{:removed-keypair-ids #{}
|
||||
:removed-account-addresses #{}
|
||||
:updated-accounts-by-address {"2x000" (merge account
|
||||
{:key-uid "0x000"
|
||||
:address "2x000"
|
||||
:chat false
|
||||
:wallet true
|
||||
:default-account? true})}
|
||||
:updated-keypairs-by-id {"0x000" {:key-uid "0x000"
|
||||
:type :profile
|
||||
:lowest-operability :fully
|
||||
:accounts [(merge account
|
||||
{:key-uid "0x000"
|
||||
:address "1x000"
|
||||
:chat true
|
||||
:wallet false
|
||||
:default-account? false})
|
||||
(merge account
|
||||
{:key-uid "0x000"
|
||||
:address "2x000"
|
||||
:chat false
|
||||
:wallet true
|
||||
:default-account? true})]}}}
|
||||
(sut/reconcile-keypairs [raw-keypair-profile])))))
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}]
|
||||
|
||||
@@ -146,6 +146,8 @@
|
||||
button-one-props :button-one-props
|
||||
current-screen-id :current-screen-id
|
||||
initial-crypto-currency? :initial-crypto-currency?
|
||||
enabled-from-chain-ids :enabled-from-chain-ids
|
||||
from-enabled-networks :from-enabled-networks
|
||||
:or {initial-crypto-currency? true}}]
|
||||
(let [_ (rn/dismiss-keyboard!)
|
||||
bottom (safe-area/get-bottom)
|
||||
@@ -164,9 +166,6 @@
|
||||
token-decimals :decimals
|
||||
:as
|
||||
token} (rf/sub [:wallet/wallet-send-token])
|
||||
send-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
||||
enabled-from-chain-ids (rf/sub
|
||||
[:wallet/wallet-send-enabled-from-chain-ids])
|
||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||
{token-balance :total-balance
|
||||
available-balance :available-balance
|
||||
@@ -355,7 +354,7 @@
|
||||
:currency-symbol currency-symbol
|
||||
:crypto-decimals (min token-decimals 6)
|
||||
:error? (controlled-input/input-error input-state)
|
||||
:networks (seq send-enabled-networks)
|
||||
:networks (seq from-enabled-networks)
|
||||
:title (i18n/label
|
||||
:t/send-limit
|
||||
{:limit (if crypto-currency?
|
||||
@@ -429,3 +428,4 @@
|
||||
(set-just-toggled-mode? false)
|
||||
(set-input-state controlled-input/delete-all)
|
||||
(rf/dispatch [:wallet/clean-suggested-routes]))}]]))
|
||||
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -8,9 +8,12 @@
|
||||
(defn view
|
||||
[]
|
||||
[input-amount/view
|
||||
{:current-screen-id :screen/wallet.send-input-amount
|
||||
:button-one-label (i18n/label :t/review-send)
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-from-locked-amounts])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}])
|
||||
{:current-screen-id :screen/wallet.send-input-amount
|
||||
:button-one-label (i18n/label :t/review-send)
|
||||
:enabled-from-chain-ids (rf/sub
|
||||
[:wallet/wallet-send-enabled-from-chain-ids])
|
||||
:from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-from-locked-amounts])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils.networks :as networks]
|
||||
[utils.security.core :as security]
|
||||
[utils.string]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(def method-to-screen
|
||||
@@ -100,7 +102,7 @@
|
||||
networks (get-in db [:wallet :networks (if test-mode? :test :prod)])]
|
||||
(mapv #(-> % :chain-id) networks)))
|
||||
|
||||
(defn add-full-testnet-name
|
||||
(defn- add-full-testnet-name
|
||||
"Updates the `:full-name` key with the full testnet name if using testnet `:chain-id`.\n
|
||||
e.g. `{:full-name \"Mainnet\"}` -> `{:full-name \"Mainnet Sepolia\"`}`"
|
||||
[network]
|
||||
@@ -111,6 +113,12 @@
|
||||
constants/goerli-chain-ids (add-testnet-name constants/goerli-full-name)
|
||||
network)))
|
||||
|
||||
(defn chain-id->network-details
|
||||
[chain-id]
|
||||
(-> chain-id
|
||||
(networks/get-network-details)
|
||||
(add-full-testnet-name)))
|
||||
|
||||
(defn event-should-be-handled?
|
||||
[db {:keys [topic]}]
|
||||
(some #(= topic %)
|
||||
@@ -143,3 +151,23 @@
|
||||
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))))
|
||||
|
||||
@@ -50,11 +50,15 @@
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.wallet-connect/approve-session
|
||||
(fn [{:keys [web3-wallet proposal supported-namespaces on-success on-fail]}]
|
||||
(fn [{:keys [web3-wallet proposal networks accounts on-success on-fail]}]
|
||||
(let [{:keys [params id]} proposal
|
||||
approved-namespaces (wallet-connect/build-approved-namespaces
|
||||
params
|
||||
supported-namespaces)]
|
||||
approved-namespaces (->> {:eip155
|
||||
{:chains networks
|
||||
:accounts accounts
|
||||
:methods constants/wallet-connect-supported-methods
|
||||
:events constants/wallet-connect-supported-events}}
|
||||
(wallet-connect/build-approved-namespaces
|
||||
params))]
|
||||
(-> (wallet-connect/approve-session
|
||||
{:web3-wallet web3-wallet
|
||||
:id id
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/init
|
||||
(fn []
|
||||
{:fx [[:effects.wallet-connect/init
|
||||
{:on-success #(rf/dispatch [:wallet-connect/on-init-success %])
|
||||
:on-fail #(rf/dispatch [:wallet-connect/on-init-fail %])}]]}))
|
||||
(fn [{:keys [db]}]
|
||||
(let [network-status (:network/status db)]
|
||||
(if (= network-status :online)
|
||||
{:fx [[:effects.wallet-connect/init
|
||||
{:on-success #(rf/dispatch [:wallet-connect/on-init-success %])
|
||||
:on-fail #(rf/dispatch [:wallet-connect/on-init-fail %])}]]}
|
||||
;; NOTE: when offline, fetching persistent sessions only
|
||||
{:fx [[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-init-success
|
||||
@@ -25,6 +29,14 @@
|
||||
:fx [[:dispatch [:wallet-connect/register-event-listeners]]
|
||||
[:dispatch [:wallet-connect/fetch-persisted-sessions]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/reload-on-network-change
|
||||
(fn [{:keys [db]} [is-connected?]]
|
||||
(let [logged-in? (-> db :profile/profile boolean)
|
||||
web3-wallet-missing? (-> db :wallet-connect/web3-wallet boolean not)]
|
||||
(when (and is-connected? logged-in? web3-wallet-missing?)
|
||||
{:fx [[:dispatch [:wallet-connect/init]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/register-event-listeners
|
||||
(fn [{:keys [db]}]
|
||||
@@ -77,12 +89,12 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/session-networks-unsupported
|
||||
(fn [_ [proposal]]
|
||||
(fn [{:keys [db]} [proposal]]
|
||||
(let [{:keys [name]} (wallet-connect-core/get-session-dapp-metadata proposal)]
|
||||
{:fx [[:dispatch
|
||||
[:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:theme (:theme db)
|
||||
:text (i18n/label :t/wallet-connect-networks-not-supported {:dapp name})}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
@@ -116,17 +128,20 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/disconnect-dapp
|
||||
(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 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 topic])
|
||||
(when on-success
|
||||
(on-success)))}]]})))
|
||||
(let [web3-wallet (get db :wallet-connect/web3-wallet)
|
||||
network-status (:network/status db)]
|
||||
(if (= network-status :online)
|
||||
{:fx [[:effects.wallet-connect/disconnect
|
||||
{:web3-wallet web3-wallet
|
||||
: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 topic])
|
||||
(when on-success
|
||||
(on-success)))}]]}
|
||||
{:fx [[:dispatch [:wallet-connect/no-internet-toast]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/pair
|
||||
@@ -141,51 +156,57 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/approve-session
|
||||
(fn [{:keys [db]}]
|
||||
(let [web3-wallet (get db :wallet-connect/web3-wallet)
|
||||
current-proposal (get-in db [:wallet-connect/current-proposal :request])
|
||||
session-networks (->> (get-in db [:wallet-connect/current-proposal :session-networks])
|
||||
(map wallet-connect-core/chain-id->eip155)
|
||||
vec)
|
||||
current-address (get-in db [:wallet-connect/current-proposal :address])
|
||||
accounts (-> (partial wallet-connect-core/format-eip155-address current-address)
|
||||
(map session-networks))
|
||||
supported-namespaces (clj->js {:eip155
|
||||
{:chains session-networks
|
||||
:methods constants/wallet-connect-supported-methods
|
||||
:events constants/wallet-connect-supported-events
|
||||
:accounts accounts}})]
|
||||
{:fx [[:effects.wallet-connect/approve-session
|
||||
{:web3-wallet web3-wallet
|
||||
:proposal current-proposal
|
||||
:supported-namespaces supported-namespaces
|
||||
:on-success (fn [approved-session]
|
||||
(log/info "Wallet Connect session approved")
|
||||
(rf/dispatch [:wallet-connect/reset-current-session-proposal])
|
||||
(rf/dispatch [:wallet-connect/persist-session approved-session]))
|
||||
:on-fail (fn [error]
|
||||
(log/error "Wallet Connect session approval failed"
|
||||
{:error error
|
||||
:event :wallet-connect/approve-session})
|
||||
(rf/dispatch
|
||||
[:wallet-connect/reset-current-session-proposal]))}]
|
||||
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]})))
|
||||
(let [web3-wallet (get db :wallet-connect/web3-wallet)
|
||||
current-proposal (get-in db [:wallet-connect/current-proposal :request])
|
||||
session-networks (->> (get-in db [:wallet-connect/current-proposal :session-networks])
|
||||
(map wallet-connect-core/chain-id->eip155)
|
||||
vec)
|
||||
current-address (get-in db [:wallet-connect/current-proposal :address])
|
||||
accounts (-> (partial wallet-connect-core/format-eip155-address current-address)
|
||||
(map session-networks))
|
||||
network-status (:network/status db)]
|
||||
(if (= network-status :online)
|
||||
{:fx [[:effects.wallet-connect/approve-session
|
||||
{:web3-wallet web3-wallet
|
||||
:proposal current-proposal
|
||||
:networks session-networks
|
||||
:accounts accounts
|
||||
:on-success (fn [approved-session]
|
||||
(log/info "Wallet Connect session approved")
|
||||
(rf/dispatch [:wallet-connect/reset-current-session-proposal])
|
||||
(rf/dispatch [:wallet-connect/persist-session approved-session]))
|
||||
:on-fail (fn [error]
|
||||
(log/error "Wallet Connect session approval failed"
|
||||
{:error error
|
||||
:event :wallet-connect/approve-session})
|
||||
(rf/dispatch
|
||||
[:wallet-connect/reset-current-session-proposal]))}]
|
||||
[:dispatch [:dismiss-modal :screen/wallet.wallet-connect-session-proposal]]]}
|
||||
{:fx [[:dispatch [:wallet-connect/no-internet-toast]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-scan-connection
|
||||
(fn [_ [scanned-text]]
|
||||
(let [parsed-uri (wallet-connect/parse-uri scanned-text)
|
||||
(fn [{:keys [db]} [scanned-text]]
|
||||
(let [network-status (:network/status db)
|
||||
parsed-uri (wallet-connect/parse-uri scanned-text)
|
||||
version (:version parsed-uri)
|
||||
valid-wc-uri? (wc-utils/valid-wc-uri? parsed-uri)
|
||||
expired? (-> parsed-uri
|
||||
:expiryTimestamp
|
||||
wc-utils/timestamp-expired?)
|
||||
version-supported? (wc-utils/version-supported? version)]
|
||||
(if (or (not valid-wc-uri?) expired? (not version-supported?))
|
||||
(if (or (not valid-wc-uri?)
|
||||
(not version-supported?)
|
||||
(= network-status :offline)
|
||||
expired?)
|
||||
{:fx [[:dispatch
|
||||
[:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:text (cond (not valid-wc-uri?)
|
||||
:text (cond (= network-status :offline)
|
||||
(i18n/label :t/wallet-connect-no-internet-warning)
|
||||
|
||||
(not valid-wc-uri?)
|
||||
(i18n/label :t/wallet-connect-wrong-qr)
|
||||
|
||||
expired?
|
||||
@@ -236,16 +257,18 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/fetch-persisted-sessions-success
|
||||
(fn [{:keys [db]} [sessions]]
|
||||
(let [sessions' (mapv (fn [{:keys [sessionJson] :as session}]
|
||||
(assoc session
|
||||
:accounts
|
||||
(-> sessionJson
|
||||
types/json->clj
|
||||
:namespaces
|
||||
:eip155
|
||||
:accounts)))
|
||||
sessions)]
|
||||
{:fx [[:dispatch [:wallet-connect/fetch-active-sessions]]]
|
||||
(let [network-status (:network/status db)
|
||||
sessions' (mapv (fn [{:keys [sessionJson] :as session}]
|
||||
(assoc session
|
||||
:accounts
|
||||
(-> sessionJson
|
||||
types/json->clj
|
||||
:namespaces
|
||||
:eip155
|
||||
:accounts)))
|
||||
sessions)]
|
||||
{:fx [(when (= network-status :online)
|
||||
[:dispatch [:wallet-connect/fetch-active-sessions]])]
|
||||
:db (assoc db :wallet-connect/sessions sessions')})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
@@ -256,14 +279,14 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/fetch-persisted-sessions
|
||||
(fn [_ _]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_getWalletConnectActiveSessions"
|
||||
;; This is the activeSince timestamp to avoid expired sessions
|
||||
;; 0 means, return everything
|
||||
:params [0]
|
||||
:on-success [:wallet-connect/fetch-persisted-sessions-success]
|
||||
:on-error [:wallet-connect/fetch-persisted-sessions-fail]}]]]}))
|
||||
(fn [{:keys [now]} _]
|
||||
(let [current-timestamp (quot now 1000)]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_getWalletConnectActiveSessions"
|
||||
;; NOTE: This is the activeSince timestamp to avoid expired sessions
|
||||
:params [current-timestamp]
|
||||
:on-success [:wallet-connect/fetch-persisted-sessions-success]
|
||||
:on-error [:wallet-connect/fetch-persisted-sessions-fail]}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/persist-session
|
||||
@@ -290,3 +313,12 @@
|
||||
:params [topic]
|
||||
:on-success #(log/info "Wallet Connect session disconnected")
|
||||
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/no-internet-toast
|
||||
(fn [{:keys [db]}]
|
||||
{:fx [[:dispatch
|
||||
[:toasts/upsert
|
||||
{:type :negative
|
||||
:theme (:theme db)
|
||||
:text (i18n/label :t/wallet-connect-no-internet-warning)}]]]}))
|
||||
|
||||
@@ -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]
|
||||
@@ -13,23 +14,34 @@
|
||||
(rf/dispatch [:wallet-connect/respond-current-session password]))
|
||||
|
||||
(defn view
|
||||
[{:keys [warning-label slide-button-text disabled?]} & children]
|
||||
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])]
|
||||
[rn/view {:style style/content-container}
|
||||
(into [rn/view
|
||||
{:style style/data-items-container}]
|
||||
children)
|
||||
[rn/view {:style style/auth-container}
|
||||
[standard-authentication/slide-button
|
||||
{:size :size-48
|
||||
:track-text slide-button-text
|
||||
:disabled? disabled?
|
||||
:customization-color customization-color
|
||||
:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/confirm)}]]
|
||||
[rn/view {:style style/warning-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:style {:color colors/neutral-80-opa-70}
|
||||
:weight :medium}
|
||||
warning-label]]]))
|
||||
[{:keys [warning-label slide-button-text error-text]} & children]
|
||||
(let [{:keys [customization-color]} (rf/sub [:wallet-connect/current-request-account-details])
|
||||
offline? (rf/sub [:network/offline?])
|
||||
theme (quo.theme/use-theme)]
|
||||
[:<>
|
||||
(when (or offline? error-text)
|
||||
[quo/alert-banner
|
||||
{:action? false
|
||||
:text (if offline?
|
||||
(i18n/label :t/wallet-connect-no-internet-warning)
|
||||
error-text)}])
|
||||
[rn/view {:style style/content-container}
|
||||
(into [rn/view
|
||||
{:style style/data-items-container}]
|
||||
children)
|
||||
[rn/view {:style style/auth-container}
|
||||
[standard-authentication/slide-button
|
||||
{:size :size-48
|
||||
:track-text slide-button-text
|
||||
:disabled? (or offline? (seq error-text))
|
||||
:customization-color customization-color
|
||||
:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/confirm)}]]
|
||||
[rn/view {:style style/warning-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
: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}
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
[quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:background :blur
|
||||
:on-press #(do (rf/dispatch [:navigate-back])
|
||||
:on-press #(do (rf/dispatch [:wallet-connect/dismiss-request-modal])
|
||||
(rf/dispatch [:wallet-connect/reject-session-request]))
|
||||
:accessibility-label accessibility-label}])
|
||||
|
||||
@@ -33,19 +33,16 @@
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
(when error-state
|
||||
[quo/alert-banner
|
||||
{:action? false
|
||||
:text (i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets))}])
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-sign-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-send)
|
||||
:disabled? error-state}
|
||||
:error-text (when error-state
|
||||
(i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets)))}
|
||||
[quo/data-item
|
||||
{:status :default
|
||||
:card? false
|
||||
|
||||
@@ -32,19 +32,16 @@
|
||||
:dapp dapp
|
||||
:account account}]
|
||||
[data-block/view]]
|
||||
(when error-state
|
||||
[quo/alert-banner
|
||||
{:action? false
|
||||
:text (i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets))}])
|
||||
[footer/view
|
||||
{:warning-label (i18n/label :t/wallet-connect-sign-warning)
|
||||
:slide-button-text (i18n/label :t/slide-to-sign)
|
||||
:disabled? error-state}
|
||||
:error-text (when error-state
|
||||
(i18n/label (condp = error-state
|
||||
:not-enough-assets-to-pay-gas-fees
|
||||
:t/not-enough-assets-to-pay-gas-fees
|
||||
|
||||
:not-enough-assets
|
||||
:t/not-enough-assets)))}
|
||||
[quo/data-item
|
||||
{:status :default
|
||||
:card? false
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
[re-frame.core :as rf]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.wallet-connect.core :as wallet-connect-core]
|
||||
[status-im.contexts.wallet.wallet-connect.signing :as signing]
|
||||
[status-im.contexts.wallet.wallet-connect.transactions :as transactions]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(rf/reg-event-fx
|
||||
@@ -122,15 +124,30 @@
|
||||
:wallet-connect/process-sign-typed
|
||||
(fn [{:keys [db]}]
|
||||
(let [[address raw-data] (wallet-connect-core/get-db-current-request-params db)
|
||||
parsed-data (try (-> raw-data
|
||||
transforms/js-parse
|
||||
parsed-raw-data (transforms/js-parse raw-data)
|
||||
session-chain-id (-> (wallet-connect-core/get-db-current-request-event db)
|
||||
(get-in [:params :chainId])
|
||||
wallet-connect-core/eip155->chain-id)
|
||||
data-chain-id (-> parsed-raw-data
|
||||
transforms/js->clj
|
||||
signing/typed-data-chain-id)
|
||||
parsed-data (try (-> parsed-raw-data
|
||||
(transforms/js-dissoc :types :primaryType)
|
||||
(transforms/js-stringify 2))
|
||||
(catch js/Error _ nil))]
|
||||
(if (nil? parsed-data)
|
||||
(cond
|
||||
(nil? parsed-data)
|
||||
{:fx [[:dispatch
|
||||
[:wallet-connect/on-processing-error
|
||||
(ex-info "Failed to parse JSON typed data" {:data raw-data})]]]}
|
||||
|
||||
(not= session-chain-id data-chain-id)
|
||||
{:fx [[:dispatch
|
||||
[:wallet-connect/wrong-typed-data-chain-id
|
||||
{:expected-chain-id session-chain-id
|
||||
:wrong-chain-id data-chain-id}]]]}
|
||||
|
||||
:else
|
||||
{:db (update-in db
|
||||
[:wallet-connect/current-request]
|
||||
assoc
|
||||
@@ -139,19 +156,39 @@
|
||||
:raw-data raw-data)
|
||||
:fx [[:dispatch [:wallet-connect/show-request-modal]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/wrong-typed-data-chain-id
|
||||
(fn [_ [{:keys [expected-chain-id wrong-chain-id]}]]
|
||||
(let [wrong-network-name (-> wrong-chain-id
|
||||
wallet-connect-core/chain-id->network-details
|
||||
:full-name)
|
||||
expected-network-name (-> expected-chain-id
|
||||
wallet-connect-core/chain-id->network-details
|
||||
:full-name)
|
||||
toast-message (i18n/label :t/wallet-connect-typed-data-wrong-chain-id-warning
|
||||
{:wrong-chain wrong-network-name
|
||||
:expected-chain expected-network-name})]
|
||||
{:fx [[:dispatch
|
||||
[:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:text toast-message}]]
|
||||
[:dispatch
|
||||
[:wallet-connect/on-processing-error
|
||||
(ex-info "Can't proceed signing typed data due to wrong chain-id included in the data"
|
||||
{:expected-chain-id expected-chain-id
|
||||
:wrong-chain-id wrong-chain-id})]]]})))
|
||||
|
||||
;; TODO: we should reject a request if processing fails
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-processing-error
|
||||
(fn [{:keys [db]} [error]]
|
||||
(let [{:keys [address event]} (get db :wallet-connect/current-request)
|
||||
method (wallet-connect-core/get-request-method event)
|
||||
screen (wallet-connect-core/method-to-screen method)]
|
||||
method (wallet-connect-core/get-request-method event)]
|
||||
(log/error "Failed to process Wallet Connect request"
|
||||
{:error error
|
||||
:address address
|
||||
:method method
|
||||
:wallet-connect-event event
|
||||
:event :wallet-connect/on-processing-error})
|
||||
|
||||
{:fx [[:dispatch [:dismiss-modal screen]]
|
||||
[:dispatch [:wallet-connect/reset-current-request]]]})))
|
||||
{:fx [[:dispatch [:wallet-connect/reject-session-request]]]})))
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
:data raw-data
|
||||
:rpc-method rpc-method
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response {:result %}])}]]})))
|
||||
:on-success #(rf/dispatch [:wallet-connect/finish-session-request %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-sign-typed-data
|
||||
@@ -53,7 +53,7 @@
|
||||
:chain-id chain-id
|
||||
:version typed-data-version
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response {:result %}])}]]})))
|
||||
:on-success #(rf/dispatch [:wallet-connect/finish-session-request %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-send-transaction-data
|
||||
@@ -67,7 +67,7 @@
|
||||
:tx-hash tx-hash
|
||||
:tx-args tx-args
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response {:result %}])}]]})))
|
||||
:on-success #(rf/dispatch [:wallet-connect/finish-session-request %])}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/respond-sign-transaction-data
|
||||
@@ -81,15 +81,13 @@
|
||||
:tx-hash tx-hash
|
||||
:tx-params tx-args
|
||||
:on-error #(rf/dispatch [:wallet-connect/on-sign-error %])
|
||||
:on-success #(rf/dispatch [:wallet-connect/send-response {:result %}])}]]})))
|
||||
:on-success #(rf/dispatch [:wallet-connect/finish-session-request %])}]]})))
|
||||
|
||||
;; TODO: should reject if "signing" fails
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/on-sign-error
|
||||
(fn [{:keys [db]} [error]]
|
||||
(let [{:keys [raw-data address event]} (get db :wallet-connect/current-request)
|
||||
method (wallet-connect-core/get-request-method event)
|
||||
screen (wallet-connect-core/method-to-screen method)]
|
||||
method (wallet-connect-core/get-request-method event)]
|
||||
(log/error "Failed to sign Wallet Connect request"
|
||||
{:error error
|
||||
:address address
|
||||
@@ -97,15 +95,14 @@
|
||||
:method method
|
||||
:wallet-connect-event event
|
||||
:event :wallet-connect/on-sign-error})
|
||||
{:fx [[:dispatch [:dismiss-modal screen]]
|
||||
[:dispatch [:wallet-connect/reset-current-request]]]})))
|
||||
{:fx [[:dispatch [:wallet-connect/reject-session-request]]
|
||||
[:dispatch [:wallet-connect/dismiss-request-modal]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/send-response
|
||||
(fn [{:keys [db]} [{:keys [result error]}]]
|
||||
(let [{:keys [id topic] :as event} (get-in db [:wallet-connect/current-request :event])
|
||||
method (wallet-connect-core/get-request-method event)
|
||||
screen (wallet-connect-core/method-to-screen method)
|
||||
web3-wallet (get db :wallet-connect/web3-wallet)]
|
||||
{:fx [[:effects.wallet-connect/respond-session-request
|
||||
{:web3-wallet web3-wallet
|
||||
@@ -119,13 +116,26 @@
|
||||
:method method
|
||||
:event :wallet-connect/send-response
|
||||
:wallet-connect-event event})
|
||||
(rf/dispatch [:dismiss-modal screen])
|
||||
(rf/dispatch [:wallet-connect/reset-current-request]))
|
||||
:on-success (fn []
|
||||
(log/info "Successfully sent Wallet Connect response to dApp")
|
||||
(rf/dispatch [:dismiss-modal screen])
|
||||
(rf/dispatch [:wallet-connect/reset-current-request]))}]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/dismiss-request-modal
|
||||
(fn [{:keys [db]} _]
|
||||
(let [screen (-> db
|
||||
(get-in [:wallet-connect/current-request :event])
|
||||
wallet-connect-core/get-request-method
|
||||
wallet-connect-core/method-to-screen)]
|
||||
{:fx [[:dispatch [:dismiss-modal screen]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/finish-session-request
|
||||
(fn [_ [result]]
|
||||
{:fx [[:dispatch [:wallet-connect/send-response {:result result}]]
|
||||
[:dispatch [:wallet-connect/dismiss-request-modal]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/reject-session-proposal
|
||||
(fn [{:keys [db]} _]
|
||||
@@ -143,6 +153,8 @@
|
||||
;; - Unsupported WC version
|
||||
;; - Invalid params from dapps
|
||||
;; - Unsupported method
|
||||
;; - Failed processing of request
|
||||
;; - Failed "responding" (signing or sending message/transaction)
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/reject-session-request
|
||||
(fn [_ _]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -6,6 +6,20 @@
|
||||
[utils.hex :as hex]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(defn typed-data-chain-id
|
||||
"Returns the `:chain-id` from typed data if it's present and if the EIP712 domain defines it. Without
|
||||
the `:chain-id` in the domain type, it will not be signed as part of the typed-data."
|
||||
[typed-data]
|
||||
(let [chain-id-type? (->> typed-data
|
||||
:types
|
||||
:EIP712Domain
|
||||
(some #(= "chainId" (:name %))))
|
||||
data-chain-id (-> typed-data
|
||||
:domain
|
||||
:chainId)]
|
||||
(when chain-id-type?
|
||||
data-chain-id)))
|
||||
|
||||
(defn eth-sign
|
||||
[password address data]
|
||||
(-> {:data data
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
status-im.contexts.contact.blocking.events
|
||||
status-im.contexts.keycard.effects
|
||||
status-im.contexts.keycard.events
|
||||
status-im.contexts.networks.events
|
||||
status-im.contexts.onboarding.common.overlay.events
|
||||
status-im.contexts.onboarding.events
|
||||
status-im.contexts.profile.events
|
||||
@@ -57,7 +58,7 @@
|
||||
cofx
|
||||
{:db db/app-db
|
||||
:theme/init-theme nil
|
||||
:network/listen-to-network-info nil
|
||||
:effects.network/listen-to-network-info nil
|
||||
:effects.biometric/get-supported-type nil
|
||||
:effects.keycard/register-card-events nil
|
||||
:effects.keycard/check-nfc-enabled nil
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -151,3 +151,9 @@
|
||||
:<- [:toasts]
|
||||
(fn [toasts [_ toast-id & cursor]]
|
||||
(get-in toasts (into [:toasts toast-id] cursor))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:network/offline?
|
||||
:<- [:network/status]
|
||||
(fn [status]
|
||||
(= status :offline)))
|
||||
|
||||
@@ -251,6 +251,11 @@
|
||||
(fn [{:keys [preview-privacy?]}]
|
||||
(boolean preview-privacy?)))
|
||||
|
||||
(re-frame/reg-sub :profile/installation-id
|
||||
:<- [:profile/profile]
|
||||
(fn [{:keys [installation-id]}]
|
||||
installation-id))
|
||||
|
||||
(defn- replace-multiaccount-image-uri
|
||||
[profile ens-names port font-file avatar-opts theme]
|
||||
(let [{:keys [key-uid ens-name? images
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
;;push notifications
|
||||
(reg-root-key-sub :push-notifications/preferences :push-notifications/preferences)
|
||||
|
||||
;;device
|
||||
(reg-root-key-sub :network/status :network/status)
|
||||
(reg-root-key-sub :network/type :network/type)
|
||||
|
||||
;;general
|
||||
(reg-root-key-sub :messenger/started? :messenger/started?)
|
||||
(reg-root-key-sub :animations :animations)
|
||||
|
||||
@@ -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))))
|
||||
|
||||
@@ -61,3 +61,22 @@
|
||||
:wallet/send-token-not-supported-in-receiver-networks?
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :token-not-supported-in-receiver-networks?)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/bridge-from-networks
|
||||
:<- [:wallet/wallet-send]
|
||||
:<- [:wallet/network-details]
|
||||
(fn [[{:keys [bridge-to-chain-id]} networks]]
|
||||
(set (filter (fn [network]
|
||||
(not= (:chain-id network) bridge-to-chain-id))
|
||||
networks))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/bridge-from-chain-ids
|
||||
:<- [:wallet/wallet-send]
|
||||
:<- [:wallet/networks-by-mode]
|
||||
(fn [[{:keys [bridge-to-chain-id]} networks]]
|
||||
(keep (fn [network]
|
||||
(when (not= (:chain-id network) bridge-to-chain-id)
|
||||
(:chain-id network)))
|
||||
networks)))
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as rf]
|
||||
[status-im.contexts.wallet.common.utils :as wallet-utils]
|
||||
[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 +44,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
|
||||
@@ -68,10 +69,7 @@
|
||||
(rf/reg-sub
|
||||
:wallet-connect/current-request-network
|
||||
:<- [:wallet-connect/chain-id]
|
||||
(fn [chain-id]
|
||||
(-> chain-id
|
||||
(networks/get-network-details)
|
||||
(wallet-connect-core/add-full-testnet-name))))
|
||||
wallet-connect-core/chain-id->network-details)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet-connect/transaction-args
|
||||
@@ -168,7 +166,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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
(ns test-helpers.matchers
|
||||
"Internal use. Don't require it directly."
|
||||
(:require
|
||||
[cljs.test :as test]
|
||||
[matcher-combinators.core :as core]
|
||||
[matcher-combinators.matchers :as matchers]
|
||||
[matcher-combinators.parser]
|
||||
[matcher-combinators.result :as result]))
|
||||
|
||||
;; This implementation is identical to `match?`, but wraps the expected value
|
||||
;; with `nested-equals`. This differs from the default `embeds` matcher on maps,
|
||||
;; where extra map keys are considered valid.
|
||||
(defmethod test/assert-expr 'match-strict?
|
||||
[_ msg form]
|
||||
`(let [args# (list ~@(rest form))
|
||||
[matcher# actual#] args#]
|
||||
(cond
|
||||
(not (= 2 (count args#)))
|
||||
(test/do-report
|
||||
{:type :fail
|
||||
:message ~msg
|
||||
:expected (symbol "`match-strict?` expects 2 arguments: a `matcher` and the `actual`")
|
||||
:actual (symbol (str (count args#) " were provided: " '~form))})
|
||||
|
||||
(core/matcher? matcher#)
|
||||
(let [result# (core/match (matchers/nested-equals matcher#) actual#)]
|
||||
(test/do-report
|
||||
(if (core/indicates-match? result#)
|
||||
{:type :pass
|
||||
:message ~msg
|
||||
:expected '~form
|
||||
:actual (list 'match? matcher# actual#)}
|
||||
(with-file+line-info
|
||||
{:type :fail
|
||||
:message ~msg
|
||||
:expected '~form
|
||||
:actual (tagged-for-pretty-printing (list '~'not (list 'match? matcher# actual#))
|
||||
result#)
|
||||
:markup (::result/value result#)}))))
|
||||
|
||||
:else
|
||||
(test/do-report
|
||||
{:type :fail
|
||||
:message ~msg
|
||||
:expected (str "The first argument of `match-strict?` "
|
||||
"needs to be a matcher (implement the match protocol)")
|
||||
:actual '~form}))))
|
||||
@@ -0,0 +1,24 @@
|
||||
(ns test-helpers.matchers
|
||||
"Some vars in this namespace solely exist to support the matchers.clj file."
|
||||
(:require-macros test-helpers.matchers)
|
||||
(:require
|
||||
[cljs.test :as t]
|
||||
[matcher-combinators.parser]
|
||||
[matcher-combinators.printer :as printer]
|
||||
[matcher-combinators.result :as result]))
|
||||
|
||||
(defrecord Mismatch [summary match-result])
|
||||
|
||||
(defn tagged-for-pretty-printing
|
||||
[actual-summary result]
|
||||
(->Mismatch actual-summary result))
|
||||
|
||||
(extend-protocol IPrintWithWriter
|
||||
Mismatch
|
||||
(-pr-writer [this writer _]
|
||||
(-write writer (printer/as-string (-> this :match-result ::result/value)))))
|
||||
|
||||
(defn with-file+line-info
|
||||
[report]
|
||||
(merge (t/file-and-line (js/Error.) 4)
|
||||
report))
|
||||
@@ -6,13 +6,15 @@
|
||||
prefer to use it for more general purpose concepts, such as the re-frame event
|
||||
layer."
|
||||
(:require-macros test-helpers.unit)
|
||||
(:require
|
||||
(:require ;; We must require this namespace to register the custom cljs.test
|
||||
;; directive `match-strict?`.
|
||||
[re-frame.core :as rf]
|
||||
[re-frame.db :as rf-db]
|
||||
[re-frame.events :as rf-events]
|
||||
[re-frame.registrar :as rf-registrar]
|
||||
[re-frame.subs :as rf-subs]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log] ;; We must require this namespace to register the custom cljs.test
|
||||
test-helpers.matchers))
|
||||
|
||||
(defn db
|
||||
"A simple wrapper to get the latest value from the app db."
|
||||
|
||||
@@ -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?://" "")))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.182.37",
|
||||
"commit-sha1": "4a43b2b2bebe45df2100d1a5c5034105d93e50b8",
|
||||
"src-sha256": "0f5mm7lx6s2qcy9xpa9v7piqb60yazi6p677fy105yz7hg731cw6"
|
||||
"version": "feat/enable_sync_fallback",
|
||||
"commit-sha1": "880152abcac69bb7cf29088ce413d2c4e01be412",
|
||||
"src-sha256": "067pj4xx0bph9573sdk57hdhq0xkaaz1zmgkk09d27a5fz2rdm4n"
|
||||
}
|
||||
|
||||
@@ -357,6 +357,7 @@
|
||||
"check-before-syncing-doc-checkbox-2": "Make sure you are logged in on the other device",
|
||||
"check-before-syncing-doc-checkbox-3": "Disable the firewall and VPN on your devices",
|
||||
"check-before-syncing-doc-description": "To sync your devices successfully, make sure to check and complete these steps:",
|
||||
"check-new-device": "A new device has been detected. You can see device ID below and on your other device. Only confirm the request if device ID matches.",
|
||||
"check-on-block-explorer": "Check on block explorer",
|
||||
"check-on-opensea": "Check on opensea",
|
||||
"check-your-account-balance-and-activity": "Check your account balance and activity",
|
||||
@@ -1626,6 +1627,7 @@
|
||||
"new-community-title": "New community",
|
||||
"new-contact": "New contact",
|
||||
"new-contract": "New Contract",
|
||||
"new-device-detected": "A new device has been detected. You can see device ID below and on your other device. Only confirm the request if device ID matches.",
|
||||
"new-favourite": "New favourite",
|
||||
"new-group": "New group",
|
||||
"new-group-chat": "New group chat",
|
||||
@@ -1790,12 +1792,14 @@
|
||||
"page-camera-request-blocked": "camera requests blocked. To enable camera requests go to Settings",
|
||||
"page-would-like-to-use-camera": "would like to use your camera",
|
||||
"pair": "Pair",
|
||||
"pair-and-sync": "Pair and Sync",
|
||||
"pair-card": "Pair to this device",
|
||||
"pair-code": "Pair code",
|
||||
"pair-code-explanation": "Pairs card to a different device (up to 5) to unlock keys and sign transactions with the same Keycard",
|
||||
"pair-code-placeholder": "Pair code...",
|
||||
"pair-device-toast": "Device successfully paired",
|
||||
"pair-devices": "Pair devices",
|
||||
"pair-new-device-and-sync": "Pair new device and sync profile",
|
||||
"pair-this-card": "Pair this card",
|
||||
"pair-this-device": "Advertise device",
|
||||
"pair-this-device-description": "Pair your devices to sync contacts and chats between them",
|
||||
@@ -2632,6 +2636,7 @@
|
||||
"wallet-connect-go-back": "Go back to your browser or dapp",
|
||||
"wallet-connect-label": "WalletConnect",
|
||||
"wallet-connect-networks-not-supported": "{{dapp}} requires an unsupported network.",
|
||||
"wallet-connect-no-internet-warning": "Oops, you have no internet. Try again later!",
|
||||
"wallet-connect-proposal-description": "By connecting you allow {{name}} to retrieve your account address and enable Web3",
|
||||
"wallet-connect-proposal-title": "Would like to connect with your wallet",
|
||||
"wallet-connect-qr-expired": "WalletConnect QR has expired",
|
||||
@@ -2642,6 +2647,7 @@
|
||||
"wallet-connect-sign-transaction-header": "wants you to sign this transaction with",
|
||||
"wallet-connect-sign-transaction-warning": "Sign transactions only if you trust the dApp",
|
||||
"wallet-connect-sign-warning": "Sign only if you trust the dApp",
|
||||
"wallet-connect-typed-data-wrong-chain-id-warning": "Wrong network in the request data. Expected '{{expected-chain}}', but got '{{wrong-chain}}'",
|
||||
"wallet-connect-version-not-supported": "WalletConnect version {{version}} is not supported",
|
||||
"wallet-connect-via": "via",
|
||||
"wallet-connect-wrong-qr": "It’s not a WalletConnect QR",
|
||||
|
||||
Reference in New Issue
Block a user