Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Oct 26, 2025


PR-Codex overview

This PR focuses on fixing the network comparison logic in the thirdweb library by updating the way network values are compared.

Detailed summary

  • Updated the comparison of network values in the packages/thirdweb/src/x402/common.ts file.
  • Changed the comparison from value.network === decodedPayment.network to networkToChainId(value.network) === networkToChainId(decodedPayment.network).

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

Summary by CodeRabbit

Bug Fixes

  • Fixed network comparison logic to ensure consistent matching regardless of how networks are represented, improving compatibility when using diff libraries.

@vercel
Copy link

vercel bot commented Oct 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Oct 26, 2025 7:56am
nebula Ready Ready Preview Comment Oct 26, 2025 7:56am
thirdweb_playground Ready Ready Preview Comment Oct 26, 2025 7:56am
thirdweb-www Ready Ready Preview Comment Oct 26, 2025 7:56am
wallet-ui Ready Ready Preview Comment Oct 26, 2025 7:56am

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2025

🦋 Changeset detected

Latest commit: 2fc5974

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

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp 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

@joaquim-verges joaquim-verges marked this pull request as ready for review October 26, 2025 07:43
@joaquim-verges joaquim-verges requested review from a team as code owners October 26, 2025 07:43
Copy link
Member Author


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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Patch release metadata added and a network comparison in payment decoding changed to compare normalized chain IDs via networkToChainId() instead of raw network strings.

Changes

Cohort / File(s) Change Summary
Changeset metadata
\.changeset/plain-maps-draw.md
Added new changeset entry declaring a patch release for the thirdweb scope with note: "Fix network comparison when using diff libraries."
Network comparison fix
packages/thirdweb/src/x402/common.ts
Replaced direct equality (value.network === decodedPayment.network) with normalized comparison using networkToChainId(value.network) === networkToChainId(decodedPayment.network) to handle differing network representations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Decoder as decodePaymentRequest()
  participant Value as selectedPaymentRequirements.value
  participant Decoded as decodedPayment

  rect rgba(0,128,0,0.06)
    Note over Decoder,Value: Previous check (string equality)
    Decoder->>Value: compare value.network === decodedPayment.network
    alt equal
      Decoder-->>Decoder: match
    else not equal (different representations)
      Decoder-->>Decoder: no match (false negative)
    end
  end

  rect rgba(0,64,128,0.06)
    Note over Decoder,Value: New check (normalized chain IDs)
    Decoder->>Value: networkToChainId(value.network)
    Decoder->>Decoded: networkToChainId(decodedPayment.network)
    alt same chain id
      Decoder-->>Decoder: match (correct)
    else different chain id
      Decoder-->>Decoder: no match
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review focus: networkToChainId() correctness and edge cases for supported network representations.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _X402_Fix_network_comparison_in_decodePaymentRequest

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2412a69 and 2fc5974.

📒 Files selected for processing (2)
  • .changeset/plain-maps-draw.md (1 hunks)
  • packages/thirdweb/src/x402/common.ts (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the SDK Involves changes to the thirdweb SDK label Oct 26, 2025
@joaquim-verges joaquim-verges force-pushed the _X402_Fix_network_comparison_in_decodePaymentRequest branch from 59145bc to 2fc5974 Compare October 26, 2025 07:43
@joaquim-verges joaquim-verges merged commit ae3a122 into main Oct 26, 2025
14 of 19 checks passed
@joaquim-verges joaquim-verges deleted the _X402_Fix_network_comparison_in_decodePaymentRequest branch October 26, 2025 07:44
@joaquim-verges joaquim-verges mentioned this pull request Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.90%. Comparing base (bfd3be7) to head (2fc5974).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8313      +/-   ##
==========================================
- Coverage   54.90%   54.90%   -0.01%     
==========================================
  Files         919      919              
  Lines       60687    60697      +10     
  Branches     4135     4130       -5     
==========================================
+ Hits        33319    33323       +4     
- Misses      27267    27272       +5     
- Partials      101      102       +1     
Flag Coverage Δ
packages 54.90% <ø> (-0.01%) ⬇️
see 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.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.55 KB (0%) 1.3 s (0%) 264 ms (+43.32% 🔺) 1.6 s
thirdweb (cjs) 366.18 KB (0%) 7.4 s (0%) 1.8 s (+1.98% 🔺) 9.2 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 96 ms (+1223.06% 🔺) 210 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 75 ms (+1104.93% 🔺) 85 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (+0.19% 🔺) 383 ms (+0.19% 🔺) 59 ms (+519.06% 🔺) 441 ms

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