Skip to content

[SDK] Include native tokens in Insight.getOwnedTokens #7243

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

Merged

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented May 31, 2025


PR-Codex overview

This PR focuses on including native tokens in the Insight.getOwnedTokens functionality, updating type definitions and query options accordingly.

Detailed summary

  • Changed token fetching from GetV1TokensErc20ByOwnerAddress to GetV1Tokens.
  • Updated OwnedToken type to use GetV1TokensResponse.
  • Modified query options to include owner_address, chain_id, and include_native.
  • Implemented pagination logic for fetching owned tokens.
  • Adjusted error handling and logging for fetching balances.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Native tokens are now included when retrieving owned tokens, providing a more complete token list.
  • Bug Fixes

    • Improved balance fetching logic to avoid redundant calls for tokens already retrieved, including native tokens.
    • Tokens with zero balance are now excluded from the displayed balances for clearer insights.
    • Enhanced error handling and pagination in token fetching for better reliability and performance.

Copy link

vercel bot commented May 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2025 3:29am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2025 3:29am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2025 3:29am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2025 3:29am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2025 3:29am

Copy link

changeset-bot bot commented May 31, 2025

🦋 Changeset detected

Latest commit: 5856cf0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 31, 2025

## Walkthrough

The changes update the `getOwnedTokens` function in the "thirdweb" component to use a new API endpoint that includes native tokens in its results. Corresponding adjustments are made to the function's parameters and its usage in the wallet balance-fetching logic to ensure native tokens are handled consistently.

## Changes

| File(s)                                                                                      | Change Summary                                                                                                                |
|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| .changeset/shaky-seals-cheer.md                                                             | Documents the patch update for including native tokens in `Insight.getOwnedTokens`.                                           |
| packages/thirdweb/src/insight/get-tokens.ts                                                 | Refactors `getOwnedTokens` to use the new `/v1/tokens` endpoint, updates types, parameters, and query options accordingly.    |
| packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx | Implements pagination in `getOwnedTokens` calls, filters tokens with zero balance, and adjusts fallback logic to skip insight-enabled chains entirely. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant UI
    participant fetchBalancesForWallet
    participant getOwnedTokens
    participant InsightAPI

    UI->>fetchBalancesForWallet: Request wallet balances
    fetchBalancesForWallet->>getOwnedTokens: Call with { ownerAddress, chains, queryOptions }
    getOwnedTokens->>InsightAPI: GET /v1/tokens (includes native tokens)
    InsightAPI-->>getOwnedTokens: Return token list (including native tokens)
    getOwnedTokens-->>fetchBalancesForWallet: Return tokens
    fetchBalancesForWallet-->>UI: Return balances (native + ERC-20)

Possibly related PRs

  • thirdweb-dev/js#7170: Updates getOwnedTokens to use the new /v1/tokens API endpoint, directly related to the changes in API usage and token retrieval logic.

Suggested reviewers

  • catalyst17
  • MananTank

<!-- walkthrough_end -->

<!-- This is an auto-generated comment: resource warnings by coderabbit.ai -->

> [!WARNING]
> ## Review ran into problems
> 
> <details>
> <summary>🔥 Problems</summary>
> 
> Errors were encountered while retrieving linked issues.
> 
> <details>
> <summary>Errors (1)</summary>
> 
> * TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
> 
> </details>
> 
> </details>

<!-- end of auto-generated comment: resource warnings by coderabbit.ai -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 8380a59e9e830b691e592c050d117868eb49cdb9 and 5856cf01ba15cb3aed39059e3614a961f800b780.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `packages/thirdweb/src/insight/get-tokens.ts` (3 hunks)
* `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* packages/thirdweb/src/insight/get-tokens.ts

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx (2)</summary><blockquote>

<details>
<summary>packages/thirdweb/src/insight/get-tokens.ts (1)</summary>

* `getOwnedTokens` (25-77)

</details>
<details>
<summary>packages/thirdweb/src/react/web/ui/ConnectWallet/screens/nativeToken.ts (1)</summary>

* `isNativeToken` (15-25)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (8)</summary>

* GitHub Check: Unit Tests
* GitHub Check: E2E Tests (pnpm, esbuild)
* GitHub Check: E2E Tests (pnpm, webpack)
* GitHub Check: Build Packages
* GitHub Check: Size
* GitHub Check: E2E Tests (pnpm, vite)
* GitHub Check: Lint Packages
* GitHub Check: Analyze (javascript)

</details>

<details>
<summary>🔇 Additional comments (5)</summary><blockquote>

<details>
<summary>packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx (5)</summary>

`144-168`: **LGTM! Solid pagination implementation with proper error handling.**

The pagination logic correctly handles batching Insight API calls with appropriate error handling. The implementation properly accumulates results and breaks when no more data is available.

---

`174-174`: **Good addition of balance filtering.**

Adding the `b.value > 0n` condition ensures only tokens with positive balances are included, which aligns with the user experience expectation of not showing empty balances.

---

`210-212`: **Excellent simplification of chain skipping logic.**

The change to skip all insight-enabled chains (instead of just ERC-20 tokens) is correct since the Insight API now handles both native and ERC-20 tokens comprehensively.

---

`221-221`: **Good simplification of duplicate detection.**

Removing the native token condition makes sense since Insight now handles all token types, so the duplicate check can be simplified to just verify if the token was already fetched.

---

`249-249`: **Helpful clarification in error message.**

Specifying "RPC balance" in the error message improves debugging by clearly distinguishing between Insight API failures and RPC failures.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAbQBlABEAaQBdSABJDAYvbCVIDGpJDwIAazJkeCwsxHgiWE1SXAB5AHdyWmh8coxEaMg5SGxESkghfDQg+GYwKQpSZAAKW0gzAHYAJgAWAGYASnRp5AJIMlhMBhLYDwADGrqGjSa2jq6exBvIADNsbPF8LAnKo5PIeQriKRhboVFBYdTIfwOLy4RAaGDXRjnDALWESfBeSHYbi0IrYsIYm5fEi4BiwABCaC8F2kADF8BQAOqMyK4T4/P7wAFQ9C0ehoBQYWjqQWA86hAFeeTcYbXGSM5nIVrqWDoSASRnBSBEfzUUa4LGQABelHwkEWNwEGn1uQ8ekgAAYMDc9mj3JAbs92nQ3hU+b8xDKUMhmIp4F94FETsNbgBxakANQAjCHeolqGhPlVEDQ0PR8F9/WncFmc4gAKIUBgbd102QvSgAQVFiMQedwBe+7O+1NpVSIUJ6kBJ/bRXal/0KPlkABpybclF80N5cABFYIuZrcBcfdD+EVCYY0ehA7K5fLcZxoNg0CjIBy09DIG74IMUAD6pa0D2NyrjctLaBgf7wLQIHoJK/rAneJB/uCxSfCMoQ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ABOEgAANh2HhJ2AEDWAEB2AAFYBAth3QAAOL4DYEgdEjYAQJQHYBEuEpVZsHYBgCkhgHEgQHEyEn4nEnYHE90NAdE2E2Elk90AQOE6EzMQk6EjYBgd0dE90WgTMTMNYHEuEnEpVLYaEhgWgAQaEpktBSAdEnE9EuEhgL4d0TMHiTMdEhgNEtAOgHYaEsU2EskzMLYNAaEuEzML4Nk3kmUvvFBAwH4hBdQf4wEkgWSYEugP8DBL4oAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=thirdweb-dev/js&utm_content=7243):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels May 31, 2025
Copy link
Member Author

joaquim-verges commented May 31, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/thirdweb/src/insight/get-tokens.ts (1)

12-12: Update function documentation to reflect native token inclusion.

The comment still states "Get ERC20 tokens owned by an address" but the function now also returns native tokens. Please update the documentation to be more accurate.

-/**
- * Get ERC20 tokens owned by an address
+/**
+ * Get tokens (ERC20 and native) owned by an address
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f10fbc8 and 9e63e63.

📒 Files selected for processing (3)
  • .changeset/shaky-seals-cheer.md (1 hunks)
  • packages/thirdweb/src/insight/get-tokens.ts (3 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/thirdweb/src/insight/get-tokens.ts (2)
packages/insight/src/client/types.gen.ts (1)
  • GetV1TokensData (2199-2238)
packages/insight/src/client/sdk.gen.ts (1)
  • getV1Tokens (553-570)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (7)
packages/thirdweb/src/insight/get-tokens.ts (4)

29-32: Well-structured type definition for query options.

The type definition correctly omits the conflicting parameters that are now handled internally, maintaining a clean API surface while allowing additional query customization.


35-35: API endpoint change aligns with objectives.

The switch from getV1TokensErc20ByOwnerAddress to getV1Tokens correctly implements the change to include native tokens as described in the PR objectives.


52-58: Excellent implementation of native token inclusion.

The default query options correctly include include_native: "true" to enable native token fetching by default, which is the core objective of this PR. The parameter structure is well-organized and maintains backward compatibility.


60-67: API call structure correctly updated.

The change from path-based to query-based parameters aligns with the new endpoint structure. All parameters are now properly passed through the query object.

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx (2)

148-150: Appropriate limit addition for token fetching.

Adding a limit of 100 tokens is a reasonable performance optimization that prevents potential issues with wallets containing many tokens while still covering most practical use cases.


200-200: Logic correctly updated for native token inclusion.

The removal of && !isNative from the condition is correct since native tokens are now included in the insight API results. This prevents duplicate balance fetching for native tokens that were already retrieved via the insight endpoint.

.changeset/shaky-seals-cheer.md (1)

1-6: Clear and appropriate changeset documentation.

The changeset correctly identifies this as a patch-level change and provides a concise description of the functionality enhancement.

Copy link
Contributor

github-actions bot commented May 31, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.21 KB (-0.04% 🔽) 1.3 s (-0.04% 🔽) 241 ms (+125.5% 🔺) 1.5 s
thirdweb (cjs) 345.12 KB (-0.07% 🔽) 7 s (-0.07% 🔽) 871 ms (-6.17% 🔽) 7.8 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 50 ms (+581.02% 🔺) 164 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 47 ms (+1653.79% 🔺) 57 ms
thirdweb/react (minimal + tree-shaking) 19.54 KB (0%) 391 ms (0%) 80 ms (+323.44% 🔺) 471 ms

Copy link

codecov bot commented May 31, 2025

Codecov Report

Attention: Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.

Project coverage is 55.55%. Comparing base (38627d3) to head (5856cf0).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...Wallet/screens/Buy/swap/fetchBalancesForWallet.tsx 0.00% 28 Missing ⚠️
packages/thirdweb/src/insight/get-tokens.ts 0.00% 6 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7243      +/-   ##
==========================================
- Coverage   55.62%   55.55%   -0.07%     
==========================================
  Files         908      908              
  Lines       58586    58571      -15     
  Branches     4138     4131       -7     
==========================================
- Hits        32589    32540      -49     
- Misses      25891    25927      +36     
+ Partials      106      104       -2     
Flag Coverage Δ
packages 55.55% <0.00%> (-0.07%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/insight/get-tokens.ts 0.00% <0.00%> (ø)
...Wallet/screens/Buy/swap/fetchBalancesForWallet.tsx 5.66% <0.00%> (-0.59%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joaquim-verges joaquim-verges merged commit 283dc28 into main Jun 1, 2025
24 of 25 checks passed
@joaquim-verges joaquim-verges deleted the _SDK_Include_native_tokens_in_Insight.getOwnedTokens branch June 1, 2025 08:31
@joaquim-verges joaquim-verges mentioned this pull request Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant