Skip to content

Conversation

@kien-ngo
Copy link
Contributor

@kien-ngo kien-ngo commented Nov 22, 2024

Problem solved

Short description of the bug fixed or feature added


PR-Codex overview

This PR introduces new headless components in the thirdweb package, specifically ChainProvider, ChainIcon, and ChainName, along with their respective props and functionalities. It also includes tests for these components to ensure proper rendering and data handling.

Detailed summary

  • Added ChainProvider, ChainIcon, and ChainName components.
  • Defined props for TokenIcon, ChainProvider, ChainIcon, and ChainName.
  • Implemented tests for TokenSymbol, ChainProvider, TokenProvider, ChainName, and ChainIcon components.
  • Updated documentation for new components in apps/portal/src/app/react/v5/components/onchain/page.mdx.

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

@vercel
Copy link

vercel bot commented Nov 22, 2024

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 Nov 25, 2024 10:51am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 10:51am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 10:51am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 10:51am

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: d1845f3

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

This PR includes changesets to release 1 package
Name Type
thirdweb Minor

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

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 22, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

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

@kien-ngo kien-ngo changed the title update [SDK] Chain headless components Nov 22, 2024
Copy link
Contributor Author

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

@kien-ngo kien-ngo marked this pull request as ready for review November 22, 2024 15:45
@kien-ngo kien-ngo force-pushed the kien/headless-chain-components branch from 64d6599 to 3a120f7 Compare November 22, 2024 15:45
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Nov 22, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 44.97 KB (0%) 900 ms (0%) 3 s (-2.7% 🔽) 3.9 s
thirdweb (cjs) 105.01 KB (0%) 2.2 s (0%) 6.6 s (+8.94% 🔺) 8.7 s
thirdweb (minimal + tree-shaking) 5.6 KB (0%) 113 ms (0%) 147 ms (+15.28% 🔺) 259 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 90 ms (+103.32% 🔺) 100 ms
thirdweb/react (minimal + tree-shaking) 18.38 KB (0%) 368 ms (0%) 578 ms (-13.63% 🔽) 946 ms

@codecov
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 70.90909% with 16 lines in your changes missing coverage. Please review.

Project coverage is 43.84%. Comparing base (dfc824d) to head (d1845f3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../thirdweb/src/react/web/ui/prebuilt/Chain/name.tsx 68.57% 11 Missing ⚠️
...rdweb/src/react/web/ui/prebuilt/Chain/provider.tsx 75.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5495      +/-   ##
==========================================
+ Coverage   43.81%   43.84%   +0.02%     
==========================================
  Files        1075     1081       +6     
  Lines       55991    56186     +195     
  Branches     3908     3929      +21     
==========================================
+ Hits        24534    24635     +101     
- Misses      30774    30868      +94     
  Partials      683      683              
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from dfc824d
packages 38.60% <70.90%> (+0.05%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...rdweb/src/react/web/ui/prebuilt/Chain/provider.tsx 75.00% <75.00%> (ø)
.../thirdweb/src/react/web/ui/prebuilt/Chain/name.tsx 68.57% <68.57%> (ø)

... and 4 files with indirect coverage changes

---- 🚨 Try these New Features:

export interface ChainIconProps
extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> {
/**
* While marked as "optional", you should pass a ThirdwebClient to this prop
Copy link
Member

Choose a reason for hiding this comment

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

Why make this optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to make it mandatory

if (!cid) {
throw new Error(`Failed to resolve IPFS CID from ${possibleUrl}`);
}
return `https://ipfs.io/ipfs/${cid}`;
Copy link
Member

Choose a reason for hiding this comment

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

Would not hardcode this. Keep it consistent with the rest of the SDK. If you want ipfs, you need a client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

...restProps
}: ChainNameProps) {
const { chain } = useChainContext();
const nameQuery = useQuery({
Copy link
Member

Choose a reason for hiding this comment

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

How come we're not using our existing chain hooks here? Otherwise it's not sharing the cache with the rest of the sdk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got a couple of reasons:

  • getChainMetadata is already catched (using withCache)
  • I need to add extra logic to the queryFn, using useChainMetadata wouldn't give me what I want (and users won't be able to customize it)

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 25, 2024

Merge activity

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces headless components related to blockchain chain management in the `thirdweb` library, including `ChainProvider`, `ChainIcon`, and `ChainName`. It also adds tests for these components and updates documentation to reflect their usage.

### Detailed summary
- Added headless components: `ChainProvider`, `ChainIcon`, `ChainName`.
- Introduced `TokenIconProps` interface.
- Updated `react.ts` to export new components and their props.
- Added documentation for `ChainProvider`, `ChainIcon`, and `ChainName` in `page.mdx`.
- Implemented tests for `TokenSymbol`, `ChainProvider`, `TokenProvider`, `ChainName`.
- Enhanced `ChainProvider` and `ChainIcon` components with new props and functionalities.
- Updated `ChainName` component to support custom name resolvers and formatting functions.

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

<!-- end pr-codex -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages Portal Involves changes to the Portal (docs) codebase. SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants