-
Notifications
You must be signed in to change notification settings - Fork 8
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
refactor - getContract for evm #621
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for wallet-develop-mainnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for wallet-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
ezra-sg
reviewed
Oct 9, 2023
ezra-sg
approved these changes
Oct 9, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice work!
donnyquixotic
approved these changes
Oct 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #598
Description
This PR includes a refactoring solution for the problem described in #598. Now we have only one function
getContract
in the Contract Store which would use the Indexer or the Hyperion to retrieve the contract's metadata to create the contract instance and finally cache the metadata in the localStorage to avoid future fetchings for the same immutable data.Technical detail
The new structure of variables now takes into account the different possible networks to store the contracts separately.
telos-wallet/src/antelope/stores/contract.ts
Lines 54 to 63 in 8c0e47d
The saveCache and loadCache functions perform the job of remembering locally all metadata to quickly recreate contract instances and speed up future loadings.
telos-wallet/src/antelope/stores/contract.ts
Lines 79 to 86 in 8c0e47d
telos-wallet/src/antelope/stores/contract.ts
Lines 99 to 106 in 8c0e47d
Finally, the getContract function now is divided into three parts:
1 - It asserts the structure exists for the network
telos-wallet/src/antelope/stores/contract.ts
Lines 155 to 162 in 8c0e47d
2 - then tries to retrieve data from the cache (to skip fetchings)
telos-wallet/src/antelope/stores/contract.ts
Lines 164 to 181 in 8c0e47d
3 - It takes into account the health of the Indexer before using it and falls back into a Hyperion-based solution if the first one fails.
telos-wallet/src/antelope/stores/contract.ts
Lines 185 to 197 in 8c0e47d
Test scenarios
Checklist: