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

Refactor useMainProcess #324

Merged
merged 45 commits into from
Dec 31, 2024
Merged

Conversation

Sharqiewicz
Copy link
Contributor

@Sharqiewicz Sharqiewicz commented Dec 12, 2024

PR 🦈 🟢


Overview

Introduce Zustand for feature-state management.

State management in the app:

Global State = React Context + Zustand
Feature State = Zustand
Server State = Tanstack/react-query

Purpose

Currently, the app suffers from disorganized, logic and state management are entangled in a single large file, along with event listeners for multiple features. This makes introducing changes or even testing the code extremely challenging.

Changes

Introduce offrampStore for offramp feature related state (types are defined within /types/offramp.ts)
Introduce useOfframpAdvancement custom hook for advancement of offramp phase
Introduce useOfframpEvents custom hook for offramp events related logic
Refactor useMainProcess custom hook

gianfra-t and others added 19 commits August 21, 2024 11:32
…-24-09-18

Release polygon prototype 24 09 18
Push latest vortex changes to production.
Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 81dca9f
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/676ea1863fd33e0008074864
😎 Deploy Preview https://deploy-preview-324--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

yarn.lock changes

Click to toggle table visibility
Name Status Previous Current
zustand UPDATED 5.0.0 5.0.2

@ebma ebma mentioned this pull request Dec 13, 2024
2 tasks
@Sharqiewicz
Copy link
Contributor Author

@pendulum-chain/devs Ready for review ✅

setEvents((prevEvents) => [...prevEvents, { value: message, status }]);
};

const trackOfframpingEvent = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we could move this to useEventsContext? Especially since we remove the addEvent thingy. This useOfframpEvents is a bit intermediary.
If it's too much trouble then no need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gianfra-t I think we should keep the logic in a custom hook and in the Events Context keep only state-related code. The Event Context file is actually quite big right now

src/pages/swap/index.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@gianfra-t gianfra-t left a comment

Choose a reason for hiding this comment

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

I really like the new library and refactor 💪. I think we still could get rid of so many hook states especially those regarding sep24 which are all over the place, like setAnchorSessionParams which for example has useSEP24Cleanup in a separate hook. But that for later otherwise the PR will grow a lot.

@Sharqiewicz
Copy link
Contributor Author

@gianfra-t Do we merge it to staging?

@gianfra-t
Copy link
Contributor

I haven't tested lately on this PR, but if it is working, let's go!

@Sharqiewicz
Copy link
Contributor Author

@gianfra-t Could you approve 🙏 🟢

Copy link
Contributor

@gianfra-t gianfra-t left a comment

Choose a reason for hiding this comment

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

I thought I did before!

@Sharqiewicz Sharqiewicz merged commit d1f215b into polygon-prototype-staging Dec 31, 2024
5 checks passed
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.

4 participants