-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor Global Token & Balance State #170
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
Conversation
- Updated token structure to include contractId, id, symbol, decimals, balance, and isStakingToken properties. - Modified createWalletActions to fetch and filter tokens more efficiently, ensuring only valid tokens are processed. - Enhanced fetchTokenInfo to return a complete token object with updated properties. - Adjusted various strategy files to accommodate the new token structure, ensuring contractId is set where applicable. - Updated UI components and stories to reflect the new token structure, ensuring consistency across the application.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the global token and balance state by introducing new metadata fields, unifying token storage, and updating components and stories to use the centralized appStore.tokens.
- Added comprehensive Token metadata (
contractId,id,symbol,decimals,balance,isStakingToken) and updated type definitions. - Refactored state actions (
getAllTokens,fetchTokenInfo) to return and populateToken[], and removed legacyallTokens. - Updated UI components, hooks, and story files to consume
appStore.tokensinstead of local or outdated token sources.
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ui/src/Earn/Modals/ClaimAllModal.stories.tsx | Added missing Token fields (id, contractId, etc.) to mockToken |
| packages/ui/src/Earn/Modals/BondModal.tsx | Switched to appStore.tokens and updated effect deps |
| packages/ui/src/Earn/Modals/BondModal.stories.tsx | Added contractId to mock strategy assets |
| packages/ui/src/Earn/EarnPage.tsx | Populated contractId in mock EarnPage strategies |
| packages/ui/src/Dashboard/WalletBalanceTable/WalletBalanceTable.stories.tsx | Added contractId to test tokens, extra import |
| packages/ui/src/Dashboard/AssetInfoModal/AssetInfoModal.stories.tsx | Replaced address with contractId in story data |
| packages/ui/src/AnchorServices/AnchorServices.stories.tsx | Added contractId to anchor sample assets |
| packages/types/src/state/wallet.ts | Updated WalletActions to use Token, removed allTokens |
| packages/types/src/general/token.ts | Extended Token interface with new metadata fields |
| packages/strategies/src/phoenix/strategies/xlm-usdc.liquidity.ts | Populated assets from _tokenX metadata, default decimals |
| packages/strategies/src/phoenix/strategies/xlm-pho.liquidity.ts | Same metadata enhancements for XLM-PHO strategy |
| packages/strategies/src/phoenix/strategies/pho-usdc.liquidity.ts | Same metadata enhancements for PHO-USDC strategy |
| packages/state/src/state/wallet/actions.ts | Refactored wallet actions to use new Token type and cleanup |
| packages/core/hooks/useContractTransaction.tsx | Triggered appStore.getAllTokens() on transaction success/restore |
| packages/core/app/swap/page.tsx | Removed local tokens state, consume appStore.tokens and added loading UI |
| packages/core/app/pools/page.tsx | Single-run fetchPool effect, replaced store with appStore |
| packages/core/app/pools/[poolAddress]/page.tsx | Deduped appStore declarations; updated icon, contractId usage |
| packages/core/app/page.tsx | Replaced local allTokens with appStore.tokens for balances |
| packages/core/app/layout.tsx | Ensures initial getAllTokens() on mount |
| packages/core/app/earn/page.tsx | Removed local Token definition, imported shared Token |
Comments suppressed due to low confidence (4)
packages/ui/src/Dashboard/AssetInfoModal/AssetInfoModal.stories.tsx:287
- The contractId for the PHO asset appears to be a copy of the first asset's address. Use the correct PHO contract address to ensure accurate data in the story.
contractId: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
packages/types/src/state/wallet.ts:4
- The
StateTokentype is no longer used byWalletActions. Consider removing this unused type to reduce maintenance overhead.
export type StateToken = {
packages/types/src/general/token.ts:7
- [nitpick] Having both
contractId(required) and optional aliasidonTokenmay lead to confusion. Consider consolidating to a single identifier to simplify the API.
contractId: string; // Contract address/ID for the token
packages/ui/src/Dashboard/WalletBalanceTable/WalletBalanceTable.stories.tsx:5
- The imported symbol 'contract' is never used. Consider removing this unused import to clean up the code.
import { contract } from "@stellar/stellar-sdk";
packages/ui/src/Dashboard/WalletBalanceTable/WalletBalanceTable.stories.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…e.stories.tsx Co-authored-by: Copilot <[email protected]>
No description provided.