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: fetch chain configs from config service #596

Merged
merged 2 commits into from
Jun 9, 2024

Conversation

schmanu
Copy link
Collaborator

@schmanu schmanu commented Jun 8, 2024

Resolves #595

What this PR changes

  • Loads chainConfig from config service
  • Uses the static list as a fallback in case the service is not reachable
  • Refactors balance fetching using useSwr

Todos

  • Fix tests
  • Write new test

@@ -33,18 +33,16 @@ export const DrainSafeDialog = ({
isOpen: boolean;
onClose: () => void;
assetBalance: AssetBalance;
nftBalance: NFTBalance;
nftBalance: NFTBalance["results"];
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure I understand this notation. Is the balance type the declared as whatever type the results field is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It refers to the type of the results field of the NFTBalance type.

Comment on lines +11 to +12
import assetBalanceReducer from "./slices/assetBalanceSlice";
import collectiblesReducer from "./slices/collectiblesSlice";
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not so sure I understand these slices and reducers. Could you tell me a bit about them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is how redux organises it's state. You can store global state in so called slices. We could in theory also put it all into one big slice but like this it is more maintainable and readable.

And Redux is used to store global state. This is to avoid having to drill down the whole app's state through props into all child components who need it.
For instance the balances are needed by different components:

  • The component that generates the "Drain" CSV content
  • The donation dialog to offer tokens from the user's balance
  • The Editor parser to check if the user's balance is high enough for the transfers
  • ...

That's why we store it in a global redux state so that all those components can easily retrieve it through selectors.

@bh2smith
Copy link
Owner

bh2smith commented Jun 9, 2024

Everything looks really great! This is a really cool change. I added just a couple questions/comments inline. I'm a bit confused by these slices and reducers...

@schmanu schmanu merged commit 101cee1 into main Jun 9, 2024
2 checks passed
@schmanu schmanu deleted the feat/fetch-chain-configs branch June 9, 2024 16:22
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.

Fetch chain configs from service
2 participants