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

Fix DeFi Positions fetching and transforming #2718

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

adamgall
Copy link
Member

@adamgall adamgall commented Feb 6, 2025

Closes https://linear.app/decent-labs/issue/ENG-196/moralis-defi-positions-api-is-currently-broken

  • Update Moralis API to support non-paginated endpoints
  • Enhance DefiResponse transformer to map Moralis response to a more structured format
  • Add fetchMoralisDefi helper function for DeFi-specific API calls
  • Improve type definitions for DeFi-related responses

- Update Moralis API to support non-paginated endpoints
- Enhance DefiResponse transformer to map Moralis response to a more structured format
- Add fetchMoralisDefi helper function for DeFi-specific API calls
- Improve type definitions for DeFi-related responses
Copy link

linear bot commented Feb 6, 2025

@adamgall adamgall changed the title Refactor Moralis API and DeFi balance transformer Fix DeFi Positions fetching and transforming Feb 6, 2025
Copy link

cloudflare-workers-and-pages bot commented Feb 7, 2025

Deploying decent-interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90f91f9
Status: ✅  Deploy successful!
Preview URL: https://c31ffba8.decent-interface.pages.dev
Branch Preview URL: https://eng-196-defi-positions-fix.decent-interface.pages.dev

View logs

Copy link
Contributor

@DarksightKellar DarksightKellar left a comment

Choose a reason for hiding this comment

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

Nice. Thanks!

// Handle paginated vs non-paginated responses
if (isPaginated) {
const paginatedData = data as MoralisResponse<T>;
if (!paginatedData || !paginatedData.result) break;
Copy link
Contributor

Choose a reason for hiding this comment

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

In case something weird happens like Moralis changing their API for whatever reason, an error log here before the break would be helpful for faster bug ID'ing. Cz this shouldn't ever happen ideally right?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct. updated.

…efi function

- Remove redundant fetchMoralisDefi helper function
- Update balances endpoint to use fetchMoralis directly with isPaginated flag
- Streamline Moralis API calls for DeFi positions
- Add robust error logging for Moralis API requests
- Implement page count limit to prevent infinite pagination
- Enhance error handling for unexpected API response structures
- Add console warnings and errors for better debugging
Copy link
Contributor

@Da-Colon Da-Colon left a comment

Choose a reason for hiding this comment

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

SIck. honestly didn't realize that section existed there. Tested and reviewed

@adamgall adamgall merged commit 58f363a into develop Feb 7, 2025
4 checks passed
@adamgall adamgall deleted the ENG-196_defi-positions-fix branch February 7, 2025 15:59
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.

3 participants