Skip to content

Conversation

@gregfromstl
Copy link
Contributor

@gregfromstl gregfromstl commented Sep 2, 2025


PR-Codex overview

This PR introduces a country code option to various payment widgets in the thirdweb package, enhancing the payment processing functionality by allowing the specification of the user's ISO 3166 alpha-2 country code.

Detailed summary

  • Added country property to payment widgets and related components.
  • Updated PaymentSelection, TransactionModal, BuyWidget, CheckoutWidget, FiatProviderSelection, and BridgeOrchestrator to accept and utilize country.
  • Added documentation comments for country in multiple files explaining its purpose.

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

Summary by CodeRabbit

  • New Features

    • Added optional country code (ISO 3166-1 alpha-2) to Buy, Checkout, Transaction widgets and pay modal; used to tailor onramp provider support and fiat quotes. Country is propagated through payment and fiat provider selection and defaults to "US" when not provided.
  • Documentation

    • Updated stories to include country defaults for examples.
  • Chores

    • Added changeset for a patch release.

@gregfromstl gregfromstl requested review from a team as code owners September 2, 2025 23:23
@changeset-bot
Copy link

changeset-bot bot commented Sep 2, 2025

🦋 Changeset detected

Latest commit: f3eac3f

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

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

@vercel
Copy link

vercel bot commented Sep 2, 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 Sep 2, 2025 11:55pm
nebula Ready Ready Preview Comment Sep 2, 2025 11:55pm
thirdweb_playground Canceled Canceled Sep 2, 2025 11:55pm
thirdweb-www Ready Ready Preview Comment Sep 2, 2025 11:55pm
wallet-ui Ready Ready Preview Comment Sep 2, 2025 11:55pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds an optional country (ISO 3166 alpha-2) parameter across buy/checkout/transaction flows, threading it from widgets and transaction modal through BridgeOrchestrator to PaymentSelection and FiatProviderSelection, into the fiat quote hook and onramp preparation. Types, props, and stories updated; no control-flow changes beyond propagation.

Changes

Cohort / File(s) Summary
Changeset
.changeset/purple-foxes-wear.md
Adds patch release note documenting new country code option for payment widgets.
Core hooks (fiat quotes & tx config)
packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts, packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts
Adds optional country?: string to params/config; passes it into onramp quote preparation.
Web transaction hook
packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx
Forwards payModal?.country to TransactionModal via country prop.
Bridge orchestrator & widgets
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx, packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx, packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
Adds optional country prop on widgets; BridgeOrchestrator accepts/destructures country (defaults to "US") and forwards it to PaymentSelection.
Payment selection flow
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx, packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
Adds country prop; PaymentSelection passes country to FiatProviderSelection; FiatProviderSelection includes country when fetching quotes.
Transaction modal integration
packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx
Extends ModalProps with optional country; forwards to BridgeOrchestrator.
Stories
packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx, packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
Adds country: "US" to default story args.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App/Caller
  participant Widget as Buy/Checkout/TransactionWidget
  participant TxModal as TransactionModal
  participant Orchestrator as BridgeOrchestrator
  participant PaySel as PaymentSelection
  participant FiatSel as FiatProviderSelection
  participant Hook as useBuyWithFiatQuotesForProviders
  participant Onramp as prepareOnramp

  App->>Widget: render({ country? })
  Widget->>Orchestrator: render({ country })
  Note right of Orchestrator: defaults to "US" if undefined
  Orchestrator->>PaySel: render({ country })
  PaySel->>FiatSel: render({ country })
  FiatSel->>Hook: useBuyWithFiatQuotesForProviders({ country, ... })
  Hook->>Onramp: prepareOnramp({ country, ... })
  Onramp-->>Hook: quotes (country-aware)
  Hook-->>FiatSel: quotes
  FiatSel-->>PaySel: render options
  PaySel-->>Orchestrator: selection UI
  Orchestrator-->>Widget: proceed flow

  App->>TxModal: render({ country? })  Note over App,TxModal: via useSendTransaction
  TxModal->>Orchestrator: render({ country })
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/country-code

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 2, 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.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Sep 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.01 KB (0%) 1.3 s (0%) 200 ms (+148.6% 🔺) 1.5 s
thirdweb (cjs) 357.32 KB (0%) 7.2 s (0%) 678 ms (+14.96% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 72 ms (+1731.39% 🔺) 186 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 81 ms (+1881.29% 🔺) 91 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 78 ms (+404.37% 🔺) 461 ms

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (1)

171-175: Bug: currency fallback should be "USD", not "US"

Passing "US" breaks currency formatting; use the ISO 4217 code.

-                        {formatCurrencyAmount(
-                          currency || "US",
-                          quote.currencyAmount,
-                        )}
+                        {formatCurrencyAmount(
+                          currency || "USD",
+                          quote.currencyAmount,
+                        )}
🧹 Nitpick comments (17)
.changeset/purple-foxes-wear.md (1)

5-5: Clarify the note to specify ISO 3166-1 alpha-2 and scope.

Small copy tweak to reduce ambiguity.

-Adds `country` code option to payment widgets
+Adds optional ISO 3166-1 alpha-2 `country` code to payment widgets and onramp flows
packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts (3)

36-39: Typo: duplicated word “country”.

- * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
+ * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.

99-101: Stabilize queryKey and include country explicitly (avoid objects/clients in keys).

Current key uses the whole params object, which likely includes non-serializable fields (e.g., client) and can churn caches. Recommend enumerating primitives and adding country.

-      queryKey: ["onramp-prepare", provider, params],
+      queryKey: [
+        "onramp-prepare",
+        provider,
+        params?.chainId ?? null,
+        params?.tokenAddress ?? null,
+        params?.receiver ?? null,
+        params?.amount ?? null,
+        params?.currency ?? "USD",
+        params?.country?.toUpperCase?.() ?? null,
+      ],

88-97: Normalize country to uppercase before sending.

Prevents cache misses and provider mismatches due to casing.

-        return prepareOnramp({
+        const normalizedCountry = params.country?.toUpperCase();
+        return prepareOnramp({
           amount: amountWei,
           chainId: params.chainId,
           client: params.client,
           currency: params.currency || "USD",
           onramp: provider,
           receiver: params.receiver,
           tokenAddress: params.tokenAddress,
-          country: params.country,
+          country: normalizedCountry,
         });
packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts (2)

93-97: Typo: duplicated word “country”. Also consider adding an example snippet.

Fix wording; optionally add a brief example under the main type doc showing payModal: { country: "GB" }.

-      /**
-       * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
-       */
+      /**
+       * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.
+       */

93-97: Unify on a shared CountryCode type across the package.

If you have a shared types barrel, prefer type CountryCode = Uppercase<string> (or a literal union if available) and reuse it in all surfaces.

-      country?: string;
+      country?: CountryCode;

Additional (outside this file):

// e.g., packages/thirdweb/src/types.ts
export type CountryCode = Uppercase<string>;
packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx (1)

35-36: Good default for Storybook; consider exposing as a control.

Add country to argTypes so reviewers can toggle examples (e.g., "GB", "CA").

   tags: ["autodocs"],
   title: "Bridge/PaymentSelection",
 } satisfies Meta<typeof PaymentSelectionWithTheme>;

Add under argTypes:

   argTypes: {
+    country: {
+      control: "text",
+      description: "ISO 3166-1 alpha-2 country code used for fiat providers",
+    },
packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx (1)

45-45: Add Storybook control/docs for country

Expose the new prop via argTypes for discoverability and quick testing.

   argTypes: {
     onCancel: { action: "flow cancelled" },
     onComplete: { action: "flow completed" },
     onError: { action: "error occurred" },
+    country: {
+      control: "text",
+      description: "ISO 3166-1 alpha-2 country code (e.g., 'US') used for onramp availability",
+    },
     presetOptions: {
       control: "object",
       description: "Quick buy options",
     },
packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx (1)

36-36: Document the new public prop

Add a short TSDoc so consumers understand intent.

   onTxSent: (data: WaitForReceiptOptions) => void;
   modalMode: "buy" | "deposit";
-  country?: string;
+  /** ISO 3166-1 alpha-2 country code used to determine onramp availability. */
+  country?: string;
packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (1)

196-198: Fix doc typo; consider a shared CountryCode type

Remove duplicated word and, optionally, standardize on a shared CountryCode alias across widgets/hooks for consistency.

-  /** The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support. */
+  /** The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support. */
   country?: string;
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)

187-191: Fix doc typo; align wording with TransactionWidget

Minor copy fix for clarity and consistency.

-  /**
-   * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
-   */
+  /**
+   * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.
+   */
   country?: string;
packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)

196-200: Fix TSDoc wording for country prop

Nit: duplicate word and spec name. Use “ISO 3166-1 alpha-2” and remove the repetition.

   /**
-   * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
+   * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.
    */
   country?: string;
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3)

128-132: Make prop optional and align docs with default

Current type requires the key but allows undefined; callers conceptually treat it as optional. Also fix the spec name and mention the default to avoid surprises.

   /**
-   * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
+   * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.
+   * @default "US"
    */
-  country: string | undefined;
+  country?: string;

156-157: Reconsider defaulting to "US" at this layer

Defaulting here forces "US" even when upstream intentionally passes undefined to allow downstream inference. Either:

  • keep the default but document clearly (see prior comment), or
  • remove this default and apply defaulting at the first consumer that truly requires a value (e.g., the fiat quotes/onramp prep), which preserves “unspecified” semantics across the tree.

If you keep it, also normalize to uppercase at usage.

-export function BridgeOrchestrator({
+export function BridgeOrchestrator({
   client,
   uiOptions,
   receiverAddress,
   onComplete,
   onError,
   onCancel,
   connectOptions,
   connectLocale,
   purchaseData,
   paymentLinkId,
   presetOptions,
   paymentMethods = ["crypto", "card"],
   showThirdwebBranding = true,
   supportedTokens,
-  country = "US",
+  country = "US",
 }: BridgeOrchestratorProps) {

If opting for downstream defaulting instead:

-  supportedTokens,
-  country = "US",
+  supportedTokens,
+  country,
 }: BridgeOrchestratorProps) {

328-329: Normalize country to uppercase before passing downstream

Ensure consistent formatting for provider matching.

-            country={country}
+            country={country?.toUpperCase()}
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (2)

94-98: Make prop optional and fix TSDoc wording

Mirror BridgeOrchestrator’s prop shape and fix duplicate word/spec name.

   /**
-   * The user's ISO 3166 alpha-2 country country code. This is used to determine onramp provider support.
+   * The user's ISO 3166-1 alpha-2 country code. Used to determine onramp provider support.
    */
-  country: string | undefined;
+  country?: string;

305-315: Pass-through to FiatProviderSelection looks correct

country is forwarded to fiat selection; consider upstream normalization to keep this layer simple.

If upstream normalization is not added, normalize here instead:

-          <FiatProviderSelection
-            country={country}
+          <FiatProviderSelection
+            country={country?.toUpperCase()}
             client={client}
             onProviderSelected={handleOnrampProviderSelected}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 4b319c3 and 3747e9c.

📒 Files selected for processing (13)
  • .changeset/purple-foxes-wear.md (1 hunks)
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts (2 hunks)
  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts (1 hunks)
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx (2 hunks)
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/purple-foxes-wear.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
**/*.stories.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

For new UI components, add Storybook stories (*.stories.tsx) alongside the code

Files:

  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (10)
packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts (1)

96-97: LGTM: threads country to prepareOnramp.

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts (1)

49-99: Public API expanded ⇒ ensure minor bump in .changeset.

Adding country?: string to the exported SendTransactionPayModalConfig is a public API change. Align the changeset to minor (see .changeset/purple-foxes-wear.md).

packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx (2)

140-140: LGTM: country is correctly forwarded to TransactionModal.


139-167: Verify country prop forwarding and avoid implicit “US” default
Confirm that TransactionModal accepts an optional country?: string prop and that BridgeOrchestrator does not inject or fallback to "US" when no country is provided.

packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx (1)

118-121: LGTM: country forwarded to BridgeOrchestrator

Prop is correctly threaded into the orchestrator.

packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (1)

447-449: LGTM: country plumbed through to BridgeOrchestrator

Forwarding is correct and preserves optionality.

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (1)

439-441: LGTM: country forwarded to BridgeOrchestrator

Wiring looks good.

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (1)

31-31: LGTM: country threaded into quotes hook

Prop added, destructured, and passed to useBuyWithFiatQuotesForProviders as intended.

Also applies to: 63-64, 75-76

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (1)

407-409: Prop forwarding looks good

country is correctly threaded into BridgeOrchestrator.

If BridgeOrchestrator defaults undefined to "US", confirm that this is intentional and won’t override any “auto-detect/infer-later” behavior in downstream hooks.

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (1)

123-124: LGTM: prop threaded into component

Destructuring country is consistent with upstream.

@codecov
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.52%. Comparing base (4b319c3) to head (f3eac3f).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...web/src/react/web/ui/Bridge/BridgeOrchestrator.tsx 0.00% 2 Missing ⚠️
...Bridge/payment-selection/FiatProviderSelection.tsx 0.00% 2 Missing ⚠️
...b/ui/Bridge/payment-selection/PaymentSelection.tsx 0.00% 2 Missing ⚠️
...core/hooks/pay/useBuyWithFiatQuotesForProviders.ts 0.00% 1 Missing ⚠️
...react/web/hooks/transaction/useSendTransaction.tsx 0.00% 1 Missing ⚠️
...ges/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx 0.00% 1 Missing ⚠️
...eact/web/ui/TransactionButton/TransactionModal.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7966   +/-   ##
=======================================
  Coverage   56.52%   56.52%           
=======================================
  Files         904      904           
  Lines       58623    58633   +10     
  Branches     4146     4147    +1     
=======================================
+ Hits        33138    33144    +6     
- Misses      25380    25383    +3     
- Partials      105      106    +1     
Flag Coverage Δ
packages 56.52% <0.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...react/core/hooks/transaction/useSendTransaction.ts 11.04% <ø> (ø)
...core/hooks/pay/useBuyWithFiatQuotesForProviders.ts 12.50% <0.00%> (-0.33%) ⬇️
...react/web/hooks/transaction/useSendTransaction.tsx 36.20% <0.00%> (-0.64%) ⬇️
...ges/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx 9.03% <0.00%> (-0.06%) ⬇️
...eact/web/ui/TransactionButton/TransactionModal.tsx 14.70% <0.00%> (-0.15%) ⬇️
...web/src/react/web/ui/Bridge/BridgeOrchestrator.tsx 6.96% <0.00%> (-0.06%) ⬇️
...Bridge/payment-selection/FiatProviderSelection.tsx 21.47% <0.00%> (-0.27%) ⬇️
...b/ui/Bridge/payment-selection/PaymentSelection.tsx 7.53% <0.00%> (-0.08%) ⬇️

... and 2 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.

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (1)

171-174: Currency code bug: use "USD", not "US"

formatCurrencyAmount likely expects ISO 4217 (e.g., “USD”). “US” will misformat or fail.

-                        {formatCurrencyAmount(
-                          currency || "US",
-                          quote.currencyAmount,
-                        )}
+                        {formatCurrencyAmount(
+                          currency || "USD",
+                          quote.currencyAmount,
+                        )}
🧹 Nitpick comments (4)
packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (3)

187-191: Normalize and type-hint the country code

Consider normalizing to uppercase and tightening the type to reduce downstream ambiguity and mismatches with providers expecting “US”, “GB”, etc.

   /**
    * The user's ISO 3166 alpha-2 country code. This is used to determine onramp provider support.
    */
-  country?: string;
+  country?: string; // e.g. "US", "GB"
+  // Tip: normalize to uppercase at callsite to avoid case issues

Optional follow-up (outside this hunk): create a shared alias to reuse across widgets.

// packages/thirdweb/src/types/country.ts
/** ISO 3166 alpha-2 uppercase country code, e.g. "US" */
export type CountryCode = string;

439-441: Pass an uppercased, sanitized country code

Uppercasing here avoids edge cases from “us”, “gb”, etc., while preserving BridgeOrchestrator’s default “US”.

-      <BridgeOrchestrator
-        country={props.country}
+      <BridgeOrchestrator
+        country={props.country?.toUpperCase()}

410-411: Narrow the queryKey to avoid unnecessary refetches when unrelated props (like country) change

bridgeDataQuery does not depend on country; stringifying the whole props object causes avoidable refetches and cache misses.

-    queryKey: ["bridgeData", stringify(props)],
+    queryKey: [
+      "bridgeData",
+      props.chain.id,
+      checksumAddress(props.tokenAddress ?? NATIVE_TOKEN_ADDRESS),
+      props.amount,
+      props.currency ?? "USD",
+      props.title,
+      props.description,
+      props.image,
+      props.buttonLabel,
+    ],
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (1)

75-76: Optional: Uppercase country for consistent provider queries

The hook’s queryKey already includes the full params object (including country), so changing country invalidates cached quotes. To avoid mismatches between lowercase/uppercase codes, consider:

- country,
+ country: country?.toUpperCase(),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 3747e9c and f3eac3f.

📒 Files selected for processing (13)
  • .changeset/purple-foxes-wear.md (1 hunks)
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts (2 hunks)
  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts (1 hunks)
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx (2 hunks)
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx (1 hunks)
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/purple-foxes-wear.md
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx
  • packages/thirdweb/src/stories/Bridge/BridgeOrchestrator.stories.tsx
  • packages/thirdweb/src/react/web/hooks/transaction/useSendTransaction.tsx
  • packages/thirdweb/src/stories/Bridge/PaymentSelection.stories.tsx
  • packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts
  • packages/thirdweb/src/react/web/ui/TransactionButton/TransactionModal.tsx
  • packages/thirdweb/src/react/core/hooks/pay/useBuyWithFiatQuotesForProviders.ts
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx (2)

31-32: Prop addition looks good

Shape and optionality are correct for threading country through selection.


63-64: Destructuring is fine; rely on upstream default

BridgeOrchestrator sets a default “US”, so passing through undefined here is acceptable.

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.

2 participants