Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userAssetsStore refactor #6015

Merged
merged 20 commits into from
Sep 10, 2024
Merged

userAssetsStore refactor #6015

merged 20 commits into from
Sep 10, 2024

Conversation

benisgold
Copy link
Member

@benisgold benisgold commented Aug 19, 2024

Fixes APP-####

What changed (plus any additional context for devs)

Context

The current implementation of userAssetsStore only caches assets for 1 wallet at a time. This means every time the user switches wallets, this computationally heavy code is executed. This currently isn't that much of a problem, because userAssetsStore is only used within swaps and the user can't switch wallets within the swaps flow.

Problem

This ticket requires userAssetsStore to be used everywhere in the app, which would cause the above issues to become much more evident. For example, when the user switches wallets there would be a delay while waiting for the selected wallet's assets to appear on the WalletScreen.

Solution

The solution implemented in this PR refactors the singular userAssetsStore into a framework for creating & caching multiple per-wallet stores. See createUserAssetsStore, useUserAssetsStore, getOrCreateStore, storeManager in src/state/assets/userAssets.ts.

There is now a store called storeManager (private to userAssets.ts) that stores & persists all these per-wallet userAssetStores. The individual userAssetStores can be accessed externally by passing in the wallet address as the first param to userAssetsStore.getState(), userAssetsStore.setState() and useUserAssetsStore(). All other params that you would normally pass in to these functions can still be passed in after.

Screen recordings / screenshots

What to test

Swaps
TF coming

@benisgold benisgold changed the title user assets refactor User assets refactor Aug 20, 2024
@benisgold benisgold changed the title User assets refactor userAssetsStore refactor Aug 20, 2024
@benisgold benisgold marked this pull request as ready for review August 20, 2024 15:03
@benisgold benisgold requested review from jinchung and walmat August 20, 2024 15:07
@benisgold benisgold marked this pull request as draft August 20, 2024 16:42
@benisgold benisgold marked this pull request as ready for review August 20, 2024 20:30
Copy link
Contributor

@walmat walmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smol changes needed i think in order for it to pass e2e

Copy link
Contributor

@walmat walmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved once CI passes. Do we need a migration strategy?

@jinchung jinchung removed their request for review August 27, 2024 17:28
@brunobar79
Copy link
Member

Launch in simulator or device for ff5c0c1

@brunobar79
Copy link
Member

Launch in simulator or device for c6ef129

@benisgold benisgold merged commit 503723b into develop Sep 10, 2024
7 of 8 checks passed
@benisgold benisgold deleted the @benisgold/user-assets-refactor branch September 10, 2024 15:32
greg-schrammel pushed a commit that referenced this pull request Sep 11, 2024
* done

* change userAssetsStoreCache type

* mid refactor

* refactor

* dont cast to Address

* more

* more

* rm address param

* fix caching

* select address

* comments

* hardhat

* lint
walmat added a commit that referenced this pull request Sep 13, 2024
* add degen native asset

* remove NATIVE_ASSETS_MAP_PER_CHAIN

* remove Address castings

* bump iOS and Android version to v1.9.38 (#6081)

* Fix e2e flakiness / errors (#6084)

* fix

* test

* revert

* @walmat related fixes

* @walmat related fixes

* okay disabling the test again, the experimental flag didnt fix it

* okay disabling the test again, the experimental flag didnt fix it

* fix disabled NFTs in testing and rely on remote config for prod

* .

* add 60 min timeout (#6090)

* fix tophat triggers (#6089)

* Fix url creation for stale balance param (#6091)

* fix wrong id (#6078)

* change to id

* also fix clicks

* Add rc-push script (#6088)

* add rc-push script

* source .env

* Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#6072)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fixes opacity on mwp sign txn sheet (#6083)

* change opacity on mwp route source too

* switch to includes

* update env (#6077)

* fix missing dapp metadata for eth actions (#6086)

* fix missing dapp metadata for eth actions

* use isHandshakeAction helper function

* Update src/components/MobileWalletProtocolListener.tsx

Co-authored-by: Bruno Barbieri <[email protected]>

---------

Co-authored-by: Bruno Barbieri <[email protected]>

* Revert "Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows …" (#6095)

This reverts commit 431459a.

* Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#6072)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Revert "Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows …" (#6095)

This reverts commit 431459a.

* Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#6072)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Revert "Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows …" (#6095)

This reverts commit 431459a.

* fix: send (#6093)

* fix

* lint

* userAssetsStore refactor (#6015)

* done

* change userAssetsStoreCache type

* mid refactor

* refactor

* dont cast to Address

* more

* more

* rm address param

* fix caching

* select address

* comments

* hardhat

* lint

* Fix wrong messages during MWP Flow (#6094)

* add logging for pkey errors

* fix keychain error handling

* checksum address before keychain lookup

* remove invalid chainId param from tx

* Update src/keychain/index.ts

* Update src/keychain/index.ts

Co-authored-by: Jin <[email protected]>

* Explicitly return UserCanceled error for code strings 10 and 13

* Remove returning -3 explicit error code

* Use enum values instead of primitives for error codes for readability

---------

Co-authored-by: Jin <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Ibrahim Taveras <[email protected]>
Co-authored-by: brdy <[email protected]>
Co-authored-by: Bruno Barbieri <[email protected]>
Co-authored-by: Jin <[email protected]>
Co-authored-by: Matthew Wall <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Esteban Miño <[email protected]>
Co-authored-by: Ben Goldberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants