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 PooledStaking slice for managing staking state #12363

Merged
merged 7 commits into from
Nov 26, 2024

Conversation

amitabh94
Copy link
Contributor

@amitabh94 amitabh94 commented Nov 20, 2024

Description

This PR refactors the staking-related state management by introducing a staking redux slice. This change improves state management consistency, reduces duplicate state, and makes the data flow more predictable across the staking feature.

  • Created new PooledStaking slice to manage staking-related state
  • Refactored hooks to use Redux store instead of local state:
    • usePooledStakes
    • useStakingEligibility
    • useVaultData
    • useStakingEarnings
  • Moved hasStakedPositions from usePooledStakes to useStakingEarnings to avoid prop drilling
  • Updated tests to reflect new state management pattern

Related issues

Fixes: STAKE-870

Manual testing steps

  1. Perform an unstake transaction
  2. Navigate to Eth details page while the transaction is still processing
  3. You will now see the unstaking banner pop up when transaction is completed without navigating away and coming back to the details page

Screenshots/Recordings

Before

Staking_without_redux.mp4

After

Staking_using_redux.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.

This commit adds a new file, PooledStaking.ts, which contains the implementation of the PooledStaking slice. The slice manages the staking state related to pooled stakes, exchange rates, vault data, eligibility, loading status, and errors. It also includes actions and selectors for setting and retrieving the staking data.
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 the Run Smoke E2E Triggers smoke e2e on Bitrise label Nov 20, 2024
Copy link
Contributor

github-actions bot commented Nov 20, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: c910e77
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a241c65b-45ff-4d5b-9f6e-eae0fdf069de

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 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Nov 20, 2024
Copy link
Contributor

github-actions bot commented Nov 20, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 98523ba
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/cbd212bb-fd40-46e3-a4ab-f897ba842f5c

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 marked this pull request as ready for review November 20, 2024 22:40
@amitabh94 amitabh94 requested review from a team as code owners November 20, 2024 22:40
@amitabh94 amitabh94 enabled auto-merge November 20, 2024 22:40
Copy link
Contributor

@Matt561 Matt561 left a comment

Choose a reason for hiding this comment

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

Left some question for my own learning but otherwise looks good! 💯

app/core/redux/slices/staking/index.ts Show resolved Hide resolved
app/core/redux/slices/staking/index.ts Show resolved Hide resolved
app/core/redux/slices/staking/index.ts Show resolved Hide resolved
Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

LGTM!

@amitabh94 amitabh94 added this pull request to the merge queue Nov 26, 2024
Merged via the queue into main with commit 39536b5 Nov 26, 2024
55 checks passed
@amitabh94 amitabh94 deleted the STAKE-870-staking-slice branch November 26, 2024 20:09
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2024
@metamaskbot metamaskbot added the release-7.37.0 Issue or pull request that will be included in release 7.37.0 label Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.37.0 Issue or pull request that will be included in release 7.37.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-stake
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants