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

feat: Show Staked ETH position in mobile homepage along with other tokens #4879

Conversation

nickewansmith
Copy link
Contributor

@nickewansmith nickewansmith commented Oct 31, 2024

Explanation

What is the current state of things and why does it need to change?

  • Currently the metamask-mobile app using the assets-controllers to get information about account token balances. We need to be able to support getting a new type of asset on mainnet and holesky chains, Staked Ethereum, which is not a token but represents the amount of ETH staked using our products.

What is the solution your changes offer and how does it work?

  • We update the AssetContractController with a new method, getStakedBalanceForChain, which gets staked ethereum balances per account from the Stakewise vault contract. We update the AccountTrackerController with options to includeStakedAssets and to add a getStakedBalanceForChain method.
  • We bind AssetContractController.getStakedBalanceForChain to getStakedBalanceForChain option property in metamask-mobile code and then set includeStakingAssets option to the boolean feature flag for ETH Staking on Mobile.
  • We use the AccountTrackerController state in mobile to update the account balance and now, if enabled the stakedBalance as well.

Are there any changes whose purpose might not obvious to those unfamiliar with the domain?

  • We don't want to show stakedBalance if not on a supported network, and so return undefined vs defaulting to zero hex. If there is an error and we are on a supported network, we want to default to zero hex.

If your primary goal was to update one package but you found you had to update another one along the way, why did you do so?

  • There is 1 package affected

If you had to upgrade a dependency, why did you do so?

  • No need to update dependency

References

Are there any issues that this pull request is tied to?

Are there other links that reviewers should consult to understand these changes better?

Are there client or consumer pull requests to adopt any breaking changes?

  • No

Changelog

@metamask/assets-controllers

ADDED: AssetsContractController.getStakedBalanceForChain method to get staked ethereum balance for an address
ADDED: AccountTrackerController options includeStakedEthereum and getStakedBalanceForChain for turning on staked balance functionality and providing a method to do so

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@nickewansmith nickewansmith force-pushed the STAKE-817-fe-show-staked-eth-position-in-homepage-along-with-other-tokens branch from 359007a to 4d90470 Compare October 31, 2024 05:50
@nickewansmith nickewansmith marked this pull request as ready for review October 31, 2024 05:54
@nickewansmith nickewansmith requested a review from a team as a code owner October 31, 2024 05:54
Copy link

@amitabh94 amitabh94 left a comment

Choose a reason for hiding this comment

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

Just some questions but overall LGTM!

@nickewansmith nickewansmith force-pushed the STAKE-817-fe-show-staked-eth-position-in-homepage-along-with-other-tokens branch from d6c3ee7 to a60a14b Compare October 31, 2024 17:37
…troller

- add SupportedStakedBalanceNetworks enum to assetsUtils.ts
- add AssetsContractController->getStakedBalanceForChain to support stakewise contract balance calls
- add ability to includeStakedAssets in AccountTrackerController class options which returns staked balances along with native balance on refresh/sync
@nickewansmith nickewansmith force-pushed the STAKE-817-fe-show-staked-eth-position-in-homepage-along-with-other-tokens branch from b3a6d75 to 7eeffae Compare November 1, 2024 21:58
@nickewansmith nickewansmith changed the title STAKE-817 Show Staked ETH position in mobile homepage along with other tokens feat: Show Staked ETH position in mobile homepage along with other tokens Nov 1, 2024
Copy link

@amitabh94 amitabh94 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@bergeron bergeron left a comment

Choose a reason for hiding this comment

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

Approving to unblock staking features in the short term. We'll likely want to revisit this and optimize it via account API or multicalls in the future.

@nickewansmith nickewansmith merged commit f5ad522 into main Nov 4, 2024
120 checks passed
@nickewansmith nickewansmith deleted the STAKE-817-fe-show-staked-eth-position-in-homepage-along-with-other-tokens branch November 4, 2024 23:01
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.

3 participants