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: add live staking data with geo-blocking support #11891

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

amitabh94
Copy link
Contributor

@amitabh94 amitabh94 commented Oct 19, 2024

Description

This PR replaces mock staking data with actual staking positions for users and integrates the Staking SDK. It also implements geo-blocking based on user location and displays real vault data.

Changes made:

  • Integrated the Staking SDK to fetch and display actual user staking positions
  • Implemented geo-blocking to restrict access based on region
  • Updated the UI to display live vault data

Additional Context:

  • Replaced mock data that was previously used in staking-related views
  • Users will now see their actual staking positions within the app
  • Geo-blocking ensures compliance with regional restrictions
  • Vault data is dynamically fetched and displayed in real-time

Related issues

Fixes: STAKE 785, STAKE 806

Manual testing steps

  1. Enable the staking feature flag in js.env locally.
  2. Log in as a user with staking positions and verify that the staking section shows live data.
  3. Access the staking feature from a geo-blocked region to verify the geo-blocking functionality.
  4. Ensure that vault data is correctly displayed based on the user’s chain and staking status.

Screenshots/Recordings

Live.Staking.Data.mp4

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@amitabh94 amitabh94 added team-stake Run Smoke E2E Triggers smoke e2e on Bitrise labels Oct 19, 2024
@amitabh94 amitabh94 changed the base branch from STAKE-785--fe-integrate-staking-eligibility to main October 19, 2024 22:56
Copy link

socket-security bot commented Oct 19, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/stake-sdk@0.2.13 network 0 165 kB metamaskbot
npm/follow-redirects@1.15.9 network 0 29.9 kB rubenverborgh
npm/form-data@4.0.1 filesystem, network 0 31.4 kB ljharb

🚮 Removed packages: npm/@metamask/stake-sdk@0.2.11

View full report↗︎

Copy link

socket-security bot commented Oct 19, 2024

👍 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: npm/follow-redirects@1.15.9, npm/form-data@4.0.1, npm/@metamask/stake-sdk@0.2.13

View full report↗︎

Next steps

Take a deeper look at the dependency

Take 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 package

If 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 risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

@amitabh94 amitabh94 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Oct 21, 2024
Copy link
Contributor

github-actions bot commented Oct 21, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: e408753
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/3911f571-61e5-4288-99b6-dee3ffa0af92

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@amitabh94 amitabh94 changed the title feat: integrate staking SDK for user positions, geo-blocking, and vault data feat: integrate staking sdk for user positions, geo-blocking, and reward data Oct 21, 2024
@amitabh94 amitabh94 changed the title feat: integrate staking sdk for user positions, geo-blocking, and reward data feat: integrate staking sdk for user positions, geo-blocking and reward data Oct 21, 2024
@amitabh94
Copy link
Contributor Author

@SocketSecurity ignore-all

@metamask/Stake-sdk uses fetch to communicate with staking backend api service

@amitabh94 amitabh94 marked this pull request as ready for review October 21, 2024 03:00
@amitabh94 amitabh94 requested review from a team as code owners October 21, 2024 03:00
@amitabh94 amitabh94 changed the title feat: integrate staking sdk for user positions, geo-blocking and reward data feat: enable live staking positions, geo-blocking, and real-time vault data display Oct 21, 2024
@amitabh94 amitabh94 changed the title feat: enable live staking positions, geo-blocking, and real-time vault data display feat: enable live staking positions, geo-blocking and real-time vault data display Oct 21, 2024
@amitabh94 amitabh94 changed the title feat: enable live staking positions, geo-blocking and real-time vault data display feat: add live staking data and geo-blocking functionality Oct 21, 2024
@amitabh94 amitabh94 changed the title feat: add live staking data and geo-blocking functionality feat: add live staking data and enable geo-blocking Oct 21, 2024
@amitabh94 amitabh94 changed the title feat: add live staking data and enable geo-blocking feat: add live staking data with geo-blocking support Oct 21, 2024
@amitabh94 amitabh94 force-pushed the STAKE-806--fe-integrate-stake-and-vault-data branch from 9c06569 to e408753 Compare October 21, 2024 04:50
@siibars siibars mentioned this pull request Oct 21, 2024
7 tasks
siibars added a commit that referenced this pull request Oct 21, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
PR from [this
one](#11891) onto a uat
branch so that we can create a QA release from it.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes: stake-806

## **Manual testing steps**

1. When merged get the apk built from the test/mobile-staking-uat branch
and test it on your device.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: Amitabh Aggarwal <aggarwal.amitabh@gmail.com>
This commit adds a new hook called useStakingEarnings to calculate staking earnings. The hook utilizes the useVaultData, useBalance, and usePooledStakes hooks to fetch necessary data and perform calculations. It calculates the lifetime rewards in ETH and fiat, as well as the estimated annual earnings in ETH and fiat.
@amitabh94 amitabh94 force-pushed the STAKE-806--fe-integrate-stake-and-vault-data branch from 577ae6b to 57dc357 Compare October 21, 2024 16:09
@amitabh94 amitabh94 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Oct 21, 2024
Copy link
Contributor

github-actions bot commented Oct 21, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 57dc357
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/cc30739c-3bb3-467d-a6ab-2e37c5ebe9b0

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Copy link

sonarcloud bot commented Oct 21, 2024

@Matt561 Matt561 self-requested a review October 21, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run Smoke E2E Triggers smoke e2e on Bitrise team-stake
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

3 participants