-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
feat: add earn controller package #5210
Conversation
This addition enhances the MetaMask ecosystem by providing a dedicated controller for earning functionalities.
…and testing scripts
This commit significantly improves the test suite for EarnController by: - Adding detailed tests for constructor initialization - Implementing mock implementations for SDK and API services - Covering SDK initialization and network change scenarios - Testing data fetching and error handling methods - Verifying subscription handlers for network and account changes
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring: Next stepsTake a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with |
@SocketSecurity ignore npm/@metamask/[email protected] This package is already being used in the mobile codebase adn is dedicated library for earn products |
This commit enhances the EarnController by: - Splitting data fetching into separate try-catch blocks for more granular error handling - Improving SDK initialization error logging - Updating method names for clarity (fetchAndUpdateStakingData -> refreshPooledStakingData) - Adding additional test cases for error scenarios and edge cases - Ensuring default state is always initialized for pooled staking
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.
LGTM! I'm excited to start using this 😄
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.
Hello! Since this is a new controller I wanted to make sure this controller follows the same or similar standards that we have for other controllers. It looks pretty good! I had some tips on better ways to write tests, I spotted a dependency that might not be in the right place, and I noticed a few things in the controller that you might want to take a closer look at. Let me know what you think.
f92fe00
to
f8272ba
Compare
This commit enhances the EarnController by: - Splitting data fetching methods into separate functions for better modularity - Implementing a more robust error handling approach in refreshPooledStakingData - Updating test suite to match new implementation - Improving network state change detection - Simplifying SDK initialization and network change logic
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.
LGTM
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.
Just one more question.
"baseUrl": "./", | ||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
"skipLibCheck": true |
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.
Hmm, I just noticed this. Generally we do not turn this setting on because it means that this package is not being fully type-checked. Any issues that we would discover with dependencies are being suppressed here and we are likely to run into them again with clients.
Is there a reason why we are doing this?
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.
Good catch! I believe I was looking at accounts-controller while trying to align the initial setup of these files.
I have removed it now and we might want to remove this check from some other controllers as well in a future PR.
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.
LGTM! Thanks for your patience in responding to my feedback!
This PR adds the new earn controller that will support both existing products like Pooled staking and upcoming products like stablecoin lending .
This is the first version of the controller and currently initailizes the stake-sdk and implements functions to fetch staking data and update state.
References
Related to STAKE-896
Changelog
@metamask/earn-controller
EarnController
package for managing DeFi earning opportunities@metamask/stake-sdk
Checklist