Skip to content

[Dashboard] Feature: Setup payment link UI #7121

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
merged 5 commits into from
May 22, 2025
Merged

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented May 22, 2025

🤖 Generated with Claude Code


PR-Codex overview

This PR focuses on adding support for payment links in the thirdweb library, enhancing payment functionalities across various components and screens.

Detailed summary

  • Introduced paymentLinkId in multiple components and functions.
  • Updated TransferFlow, PayEmbed, TransferConfirmationScreen, and others to handle paymentLinkId.
  • Modified getPaymentLink function to fetch payment link details.
  • Adjusted trend calculation logic in analytics components.
  • Refactored client initialization to use payAppThirdwebClient.

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

Summary by CodeRabbit

  • New Features

    • Introduced a payment processing page enabling users to complete payments with support for payment link details and customizable themes.
    • Added payment link support across buy, sell, transfer, and onramp flows for associating transactions with specific payment links.
    • Embedded payment components now accept optional payment link identifiers for improved tracking and integration.
  • Improvements

    • Centralized and simplified client configuration for payment forms and embeds, enhancing reliability and maintainability.
    • Updated trend calculations and aggregation logic in analytics and transaction cards for more accurate insights.
  • Bug Fixes

    • Enhanced trend calculations to handle datasets with fewer data points.
  • Chores

    • Removed unused analytics domain constants and improved code readability with formatting updates.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
@gregfromstl gregfromstl requested review from a team as code owners May 22, 2025 05:00
Copy link

vercel bot commented May 22, 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 May 22, 2025 5:37am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 5:37am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 5:37am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 5:37am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 5:37am

Copy link
Contributor

graphite-app bot commented May 22, 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.

Copy link

coderabbitai bot commented May 22, 2025

Walkthrough

This update introduces support for payment link tracking and handling across the dashboard and SDK. It adds new APIs and types for fetching payment link data, updates buy/sell/transfer/onramp flows to accept and propagate a paymentLinkId, and refactors client instantiation for payment pages to use a centralized client. Analytics trend calculations are also adjusted.

Changes

Files/Groups Change Summary
apps/dashboard/src/@/api/universal-bridge/links.ts Added PaymentLink type and getPaymentLink async function to fetch payment link data by ID with authentication.
apps/dashboard/src/app/pay/[id]/page.tsx Added new payment processing page component that fetches payment link details, retrieves token metadata, and renders embedded payment UI.
apps/dashboard/src/app/pay/constants.ts Introduced a new module exporting a statically configured Thirdweb client instance payAppThirdwebClient for payment flows.
apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx, apps/dashboard/src/app/pay/components/client/PaymentLinkForm.client.tsx, apps/dashboard/src/app/pay/page.tsx Refactored payment components to use shared payAppThirdwebClient instead of dynamic client creation. Updated props to optionally accept paymentLinkId and made amount optional in embed component. Removed environment-based domain logic.
apps/dashboard/src/constants/urls.ts Removed the THIRDWEB_ANALYTICS_DOMAIN constant and its fallback environment variable.
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TotalSponsoredCard.tsx, apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TransactionsCard.tsx, apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx, apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/page.tsx Modified analytics aggregation and trend calculation logic: trend requires fewer data points, baseline changed from third-to-last to first data point, and "activeUsers" aggregation uses max instead of sum.
apps/dashboard/src/app/nebula-app/(app)/utils/nebulaThirdwebClient.ts Added THIRDWEB_BRIDGE_URL to the domain configuration for non-production environments.
packages/thirdweb/src/bridge/Buy.ts, packages/thirdweb/src/bridge/Sell.ts, packages/thirdweb/src/bridge/Transfer.ts, packages/thirdweb/src/bridge/Onramp.ts Extended prepare functions and options types to accept and forward an optional paymentLinkId parameter in API requests.
packages/thirdweb/src/pay/buyWithCrypto/getQuote.ts, packages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts, packages/thirdweb/src/pay/buyWithFiat/getPostOnRampQuote.ts, packages/thirdweb/src/pay/buyWithFiat/getQuote.ts Extended quote and transfer parameter types and functions to accept and propagate an optional paymentLinkId.
packages/thirdweb/src/react/web/ui/PayEmbed.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx, packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx Added optional paymentLinkId prop to various React components and types, propagating it through buy, swap, and fiat flows to support payment link tracking in UI and API calls.
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts Reformatted numeric literal for readability; no functional change.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PayPage
    participant API
    participant ThirdwebClient
    participant PayPageEmbed

    User->>PayPage: Access /pay/[id] with paymentId
    PayPage->>API: getPaymentLink({ paymentId })
    API-->>PayPage: PaymentLink data
    PayPage->>ThirdwebClient: getContract(token address, chainId)
    ThirdwebClient-->>PayPage: Token metadata
    PayPage->>PayPageEmbed: Render with payment details and paymentLinkId
    PayPageEmbed->>ThirdwebClient: Handle payment flow (with paymentLinkId)
Loading
sequenceDiagram
    participant UIComponent
    participant Buy/Sell/Transfer/Onramp Prepare
    participant Bridge API

    UIComponent->>Buy/Sell/Transfer/Onramp Prepare: prepare({ ..., paymentLinkId })
    Buy/Sell/Transfer/Onramp Prepare->>Bridge API: POST /prepare (includes paymentLinkId)
    Bridge API-->>Buy/Sell/Transfer/Onramp Prepare: Response
    Buy/Sell/Transfer/Onramp Prepare-->>UIComponent: Result
Loading

Suggested reviewers

  • MananTank

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.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 93aa27a and 99f2e72.

📒 Files selected for processing (1)
  • .changeset/tired-rice-kiss.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/tired-rice-kiss.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

🪧 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.
    • 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 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 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 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 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.

@github-actions github-actions bot added Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK labels May 22, 2025
Copy link

@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: 4

🔭 Outside diff range comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/page.tsx (1)

523-529: ⚠️ Potential issue

Inconsistent trend calculation in TotalSponsoredCard function.

While the AppHighlightsCard function has been updated to use the first data point as the baseline for trend calculation and require only 2 data points, the TotalSponsoredCard function still uses the old method (requiring 3 data points and comparing with the third-to-last point).

Update the trend calculation in the TotalSponsoredCard function to match the new pattern for consistency:

trendFn={(data, key) =>
-  data.filter((d) => (d[key] as number) > 0).length >= 3
+  data.filter((d) => (d[key] as number) > 0).length >= 2
    ? ((data[data.length - 2]?.[key] as number) ?? 0) /
-       ((data[data.length - 3]?.[key] as number) ?? 0) -
+       (Math.max(0.0001, (data[0]?.[key] as number) ?? 0.0001)) -
      1
    : undefined
}
🧹 Nitpick comments (5)
apps/dashboard/src/@/api/universal-bridge/links.ts (3)

4-16: Consider typing purchaseData more specifically

The PaymentLink type uses unknown for the purchaseData property. If the structure of this data is known, consider defining a more specific type to improve type safety and developer experience.


18-36: Enhance error handling in getPaymentLink function

The current error handling just throws the raw text response, which might not be user-friendly or provide enough context for debugging.

Consider improving the error handling with more structured errors:

if (!res.ok) {
  const text = await res.text();
-  throw new Error(text);
+  throw new Error(`Failed to fetch payment link (${res.status}): ${text}`);
}

21-27: Consider adding request timeout and retry logic

Network requests can hang or fail, especially in poor network conditions.

Consider adding a timeout and potentially retry logic for the fetch request:

const res = await fetch(`${UB_BASE_URL}/v1/links/${props.paymentId}`, {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "x-secret-key": DASHBOARD_THIRDWEB_SECRET_KEY,
  },
+  signal: AbortSignal.timeout(10000), // 10-second timeout
});
apps/dashboard/src/app/pay/[id]/page.tsx (1)

37-38: Address ESLint disabling comment

The code uses an ESLint disable comment for defineChain, suggesting potential issues with that usage. If possible, consider addressing the underlying issue rather than disabling the lint rule.

apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (1)

28-29: Remove unused clientId prop from component type definition

The clientId prop is defined in the component type definition but isn't used in the component implementation. This might confuse other developers.

  redirectUri?: string;
-  clientId: string;
  theme?: "light" | "dark";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dcd6b99 and a544192.

📒 Files selected for processing (28)
  • apps/dashboard/src/@/api/universal-bridge/links.ts (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TotalSponsoredCard.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TransactionsCard.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/page.tsx (1 hunks)
  • apps/dashboard/src/app/nebula-app/(app)/utils/nebulaThirdwebClient.ts (2 hunks)
  • apps/dashboard/src/app/pay/[id]/page.tsx (1 hunks)
  • apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (2 hunks)
  • apps/dashboard/src/app/pay/components/client/PaymentLinkForm.client.tsx (8 hunks)
  • apps/dashboard/src/app/pay/constants.ts (1 hunks)
  • apps/dashboard/src/app/pay/page.tsx (3 hunks)
  • apps/dashboard/src/constants/urls.ts (0 hunks)
  • packages/thirdweb/src/bridge/Buy.ts (3 hunks)
  • packages/thirdweb/src/bridge/Onramp.ts (4 hunks)
  • packages/thirdweb/src/bridge/Sell.ts (3 hunks)
  • packages/thirdweb/src/bridge/Transfer.ts (3 hunks)
  • packages/thirdweb/src/pay/buyWithCrypto/getQuote.ts (3 hunks)
  • packages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts (2 hunks)
  • packages/thirdweb/src/pay/buyWithFiat/getPostOnRampQuote.ts (3 hunks)
  • packages/thirdweb/src/pay/buyWithFiat/getQuote.ts (2 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx (6 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx (1 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts (1 hunks)
  • packages/thirdweb/src/react/web/ui/PayEmbed.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/dashboard/src/constants/urls.ts
🧰 Additional context used
🧬 Code Graph Analysis (5)
apps/dashboard/src/app/nebula-app/(app)/utils/nebulaThirdwebClient.ts (1)
apps/dashboard/src/constants/urls.ts (1)
  • THIRDWEB_BRIDGE_URL (27-28)
apps/dashboard/src/@/api/universal-bridge/links.ts (2)
apps/dashboard/src/@/api/universal-bridge/constants.ts (1)
  • UB_BASE_URL (1-1)
apps/dashboard/src/@/constants/server-envs.ts (1)
  • DASHBOARD_THIRDWEB_SECRET_KEY (8-9)
apps/dashboard/src/app/pay/page.tsx (1)
apps/dashboard/src/app/pay/constants.ts (1)
  • payAppThirdwebClient (45-45)
apps/dashboard/src/app/pay/constants.ts (2)
apps/dashboard/src/constants/urls.ts (8)
  • THIRDWEB_RPC_DOMAIN (12-13)
  • THIRDWEB_INAPP_WALLET_DOMAIN (8-10)
  • THIRDWEB_PAY_DOMAIN (5-6)
  • THIRDWEB_STORAGE_DOMAIN (15-16)
  • THIRDWEB_SOCIAL_API_DOMAIN (18-19)
  • THIRDWEB_BUNDLER_DOMAIN (21-22)
  • THIRDWEB_INSIGHT_API_DOMAIN (24-25)
  • THIRDWEB_BRIDGE_URL (27-28)
apps/dashboard/src/@/constants/public-envs.ts (2)
  • NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID (1-2)
  • NEXT_PUBLIC_IPFS_GATEWAY_URL (13-15)
apps/dashboard/src/app/pay/components/client/PaymentLinkForm.client.tsx (1)
apps/dashboard/src/app/pay/constants.ts (1)
  • payAppThirdwebClient (45-45)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (49)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TransactionsCard.tsx (1)

122-125: Trend calculation changed to use the first data point as baseline.

The trend calculation now compares the second-to-last data point with the first data point, and requires only 2 data points instead of 3. This changes the trend from showing recent momentum to showing overall change throughout the entire time period.

Consider handling edge cases where the first data point is zero or very small, which could lead to division by zero or exaggerated trend values:

trendFn={(data, key) =>
  data.filter((d) => (d[key] as number) > 0).length >= 2
    ? ((data[data.length - 2]?.[key] as number) ?? 0) /
-       ((data[0]?.[key] as number) ?? 0) -
+       (Math.max(0.0001, (data[0]?.[key] as number) ?? 0.0001)) -
      1
    : undefined
}
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/analytics/page.tsx (2)

323-328: Improved aggregation for active users metric.

The aggregation function now correctly handles the activeUsers metric by returning the maximum value rather than summing, which prevents double-counting users across time periods.


330-333: Trend calculation changed to use the first data point as baseline.

The trend calculation now compares the second-to-last data point with the first data point, and requires only 2 data points instead of 3. This changes the trend from showing recent momentum to showing overall change throughout the entire time period.

Consider handling edge cases where the first data point is zero or very small, which could lead to division by zero or exaggerated trend values:

trendFn={(data, key) =>
  data.filter((d) => (d[key] as number) > 0).length >= 2
    ? ((data[data.length - 2]?.[key] as number) ?? 0) /
-       ((data[0]?.[key] as number) ?? 0) -
+       (Math.max(0.0001, (data[0]?.[key] as number) ?? 0.0001)) -
      1
    : undefined
}
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/_components/TotalSponsoredCard.tsx (1)

121-124: Trend calculation changed to use the first data point as baseline.

The trend calculation now compares the second-to-last data point with the first data point, and requires only 2 data points instead of 3. This changes the trend from showing recent momentum to showing overall change throughout the entire time period.

Consider handling edge cases where the first data point is zero or very small, which could lead to division by zero or exaggerated trend values:

trendFn={(data, key) =>
  data.filter((d) => (d[key] as number) > 0).length >= 2
    ? ((data[data.length - 2]?.[key] as number) ?? 0) /
-       ((data[0]?.[key] as number) ?? 0) -
+       (Math.max(0.0001, (data[0]?.[key] as number) ?? 0.0001)) -
      1
    : undefined
}
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/page.tsx (2)

379-384: Improved aggregation for active users metric.

The aggregation function now correctly handles the activeUsers metric by returning the maximum value rather than summing, which prevents double-counting users across time periods.


386-389: Trend calculation changed to use the first data point as baseline.

The trend calculation now compares the second-to-last data point with the first data point, and requires only 2 data points instead of 3. This changes the trend from showing recent momentum to showing overall change throughout the entire time period.

Consider handling edge cases where the first data point is zero or very small, which could lead to division by zero or exaggerated trend values:

trendFn={(data, key) =>
  data.filter((d) => (d[key] as number) > 0).length >= 2
    ? ((data[data.length - 2]?.[key] as number) ?? 0) /
-       ((data[0]?.[key] as number) ?? 0) -
+       (Math.max(0.0001, (data[0]?.[key] as number) ?? 0.0001)) -
      1
    : undefined
}
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts (1)

39-39: Improved numeric literal readability

The change from 1000000 to 1_000_000 uses numeric separators (introduced in ES2021) to make large numbers more readable without changing their value.

apps/dashboard/src/app/nebula-app/(app)/utils/nebulaThirdwebClient.ts (1)

6-6: Bridge domain configuration added for non-production environments

The addition of THIRDWEB_BRIDGE_URL import and its usage in setThirdwebDomains enables proper integration with bridge services in non-production environments, supporting the payment link functionality.

Also applies to: 31-31

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx (1)

26-26: Payment link tracking support added

The addition of the optional paymentLinkId parameter to TransferFlowProps enables tracking or identification of payment links throughout the transaction flow.

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

148-151: Payment link ID propagation implemented

The new optional paymentLinkId prop has been added to PayEmbedProps and is correctly passed down to the BuyScreen component, enabling end-to-end payment link tracking through the UI component hierarchy.

Also applies to: 373-373

packages/thirdweb/src/pay/buyWithFiat/getQuote.ts (2)

98-102: Properly defined new optional parameter.

The paymentLinkId optional parameter is correctly added with appropriate JSDoc documentation and typing.


329-329: Correctly forwarding paymentLinkId parameter.

The paymentLinkId parameter is properly passed to the prepareOnramp function, ensuring it's included in the onramp preparation process.

packages/thirdweb/src/pay/buyWithCrypto/getQuote.ts (3)

87-90: Properly defined new optional parameter.

The paymentLinkId optional parameter is correctly added with appropriate JSDoc documentation and typing.


211-211: Correctly forwarding paymentLinkId parameter in Buy flow.

The paymentLinkId parameter is properly passed to the Bridge.Buy.prepare function when toAmount is provided.


233-233: Correctly forwarding paymentLinkId parameter in Sell flow.

The paymentLinkId parameter is properly passed to the Bridge.Sell.prepare function when fromAmount is provided.

packages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts (2)

64-67: Properly defined new optional parameter.

The paymentLinkId optional parameter is correctly added with appropriate JSDoc documentation and typing.


135-135: Correctly forwarding paymentLinkId parameter.

The paymentLinkId parameter is properly passed to the Transfer.prepare function, ensuring it's included in the transfer preparation process.

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx (3)

55-55: Properly defined new optional parameter in props interface.

The paymentLinkId parameter is correctly added to the component props interface with appropriate typing.


74-74: Correctly destructuring the new parameter from props.

The paymentLinkId parameter is properly destructured from the component props.


110-110: Correctly passing paymentLinkId to API function.

The paymentLinkId parameter is properly passed to the getBuyWithCryptoTransfer function, ensuring it's included in the transfer request.

packages/thirdweb/src/bridge/Transfer.ts (3)

192-192: Correctly propagates payment link tracking information.

The paymentLinkId parameter is properly added to the destructured options, enabling payment link tracking for transfer operations.


212-212: Parameter correctly included in API request.

The paymentLinkId is properly passed to the backend API in the request body, ensuring consistent tracking through the server-side processing.


259-263: Type definition is properly documented.

The optional paymentLinkId parameter is correctly typed as a string and marked with the @hidden JSDoc tag, indicating this is an internal parameter not meant for regular API documentation.

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

58-58: Component prop correctly defined.

The paymentLinkId prop is properly typed as undefined | string, maintaining type safety while allowing for the optional nature of the parameter.


125-125: Parameter correctly forwarded to quote request.

The paymentLinkId is properly included in the quoteParams object, ensuring it's passed to the useBuyWithCryptoQuote hook for consistent tracking throughout the buy flow.

apps/dashboard/src/app/pay/page.tsx (2)

9-9: Import of centralized client.

The import of payAppThirdwebClient aligns with the effort to standardize client usage in the pay app.


23-23: Improved function naming.

Renaming from RoutesPage to PayPage improves semantic clarity by more accurately reflecting the component's purpose.

packages/thirdweb/src/pay/buyWithFiat/getPostOnRampQuote.ts (3)

25-28: Parameter correctly documented.

The paymentLinkId parameter is properly added to the type definition with appropriate JSDoc documentation, maintaining API consistency.


69-69: Function signature updated.

The function signature is correctly updated to include the new paymentLinkId parameter.


86-86: Parameter correctly forwarded.

The paymentLinkId is properly passed to the underlying getBuyWithCryptoQuote function, ensuring consistent tracking throughout the payment flow.

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx (1)

53-53: Integration of payment link tracking looks good!

The paymentLinkId prop has been correctly added to the component props, properly destructured, and passed to the useBuyWithFiatQuote hook, enabling payment link context tracking in the fiat purchase flow.

Also applies to: 64-64, 104-104

packages/thirdweb/src/bridge/Buy.ts (1)

335-335: Payment link integration in Buy bridge implemented correctly.

The paymentLinkId parameter is properly integrated into the bridge API call for buying assets. The parameter is correctly marked as optional and hidden in the type definition, suggesting it's an internal implementation detail.

Also applies to: 357-357, 407-411

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

86-86: Props interface extension looks good.

The paymentLinkId prop has been properly added to both BuyScreenProps and BuyScreenContentProps interfaces, correctly typed as optional.

Also applies to: 155-155


352-352: Correct prop propagation throughout component hierarchy.

The paymentLinkId prop is properly passed down to all relevant child components (OnRampScreen, TransferFlow, SwapScreenContent, and FiatScreenContent), ensuring consistent payment link tracking throughout the user flow.

Also applies to: 401-401, 537-537, 593-593

packages/thirdweb/src/bridge/Sell.ts (1)

326-326: Payment link integration in Sell bridge implemented correctly.

The paymentLinkId parameter is properly integrated into the bridge API call for selling assets. The parameter is correctly marked as optional and hidden in the type definition, consistent with the implementation in the Buy bridge.

Also applies to: 348-348, 400-403

apps/dashboard/src/app/pay/constants.ts (3)

1-17: LGTM: Comprehensive import of required dependencies

The imports are well-organized, properly grouping related constants and including all necessary utilities for client configuration.


19-43: Well-structured client initialization function

Good implementation of getPayThirdwebClient() with proper environment detection and conditional domain configuration for non-production environments.


45-46: Effective singleton pattern for client instance

Creating the Thirdweb client once and exporting it as a constant ensures consistent client usage across components, reducing redundant client initializations.

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx (2)

74-74: LGTM: Added optional paymentLinkId parameter

Properly extends the component props interface with an optional paymentLinkId parameter.


651-651: LGTM: Correctly passing paymentLinkId to quote function

The paymentLinkId is properly passed to the getBuyWithCryptoQuote function, ensuring it's included in the API request.

apps/dashboard/src/app/pay/components/client/PaymentLinkForm.client.tsx (3)

11-11: Good refactoring: Using centralized client instance

Replaced dynamic client creation with the centralized payAppThirdwebClient. This simplifies the code and ensures consistent client configuration.


90-90: Consistent replacement of client references

All occurrences of the old client variable have been consistently replaced with payAppThirdwebClient.

Also applies to: 103-103, 136-136, 148-148, 196-196, 210-210


125-125: Correctly updated dependency array

The dependency array has been properly updated to remove the client reference, which is no longer a dependency of the callback.

packages/thirdweb/src/bridge/Onramp.ts (4)

54-54: LGTM: Extended interface with paymentLinkId

Properly extends the OnrampApiRequestBody interface with an optional paymentLinkId property.


146-146: LGTM: Added paymentLinkId to destructured options

Correctly extracts the paymentLinkId parameter from the options object.


185-187: LGTM: Properly handling paymentLinkId in request body

Correctly adds the paymentLinkId to the API request body only when it's defined, following the pattern established for other optional parameters.


246-249: LGTM: Well-documented type extension

Good use of JSDoc comment with @hidden tag to indicate this is an internal parameter not meant for public API documentation.

apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (2)

43-47: LGTM: Centralized client usage improves consistency

Good refactoring to use the centralized payAppThirdwebClient for both AutoConnect and PayEmbed components, and properly passing the new paymentLinkId prop to track payment links.


12-22: LGTM: Properly added optional payment link tracking

Good implementation of the optional paymentLinkId prop in both the component interface and type definition. This allows for better tracking of payment links throughout the system.

- Modified PaymentLink type to allow 'amount' to be optional.
- Updated getPaymentLink function to handle undefined amounts correctly.
- Adjusted PayPage and PayPageEmbed components to accommodate changes in amount handling, ensuring proper conversion and default values.
Copy link

changeset-bot bot commented May 22, 2025

🦋 Changeset detected

Latest commit: 99f2e72

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

@vercel vercel bot temporarily deployed to Preview – login May 22, 2025 05:04 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 22, 2025 05:04 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 22, 2025 05:04 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 22, 2025 05:04 Inactive
…Screen props

- Replaced the client initialization in PayPage to use `payAppThirdwebClient` instead of `getClientThirdwebClient`.
- Updated OnRampScreen to accept and utilize `paymentLinkId` prop, enhancing the component's functionality for payment link handling.
Copy link
Contributor

github-actions bot commented May 22, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 56.62 KB (-0.04% 🔽) 1.2 s (-0.04% 🔽) 164 ms (+145.6% 🔺) 1.3 s
thirdweb (cjs) 309.13 KB (-0.08% 🔽) 6.2 s (-0.08% 🔽) 580 ms (+0.33% 🔺) 6.8 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 66 ms (+1409.07% 🔺) 180 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 27 ms (+1020.12% 🔺) 38 ms
thirdweb/react (minimal + tree-shaking) 19.5 KB (0%) 390 ms (0%) 78 ms (+583.19% 🔺) 468 ms

Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 23.33333% with 23 lines in your changes missing coverage. Please review.

Project coverage is 55.58%. Comparing base (a31ac0c) to head (99f2e72).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...act/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx 0.00% 4 Missing ⚠️
packages/thirdweb/src/bridge/Onramp.ts 25.00% 3 Missing ⚠️
...nnectWallet/screens/Buy/fiat/FiatScreenContent.tsx 0.00% 3 Missing ⚠️
...ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx 0.00% 3 Missing ⚠️
...ackages/thirdweb/src/pay/buyWithCrypto/getQuote.ts 0.00% 2 Missing ⚠️
...nnectWallet/screens/Buy/swap/SwapScreenContent.tsx 0.00% 2 Missing ⚠️
...et/screens/Buy/swap/TransferConfirmationScreen.tsx 0.00% 2 Missing ⚠️
...ages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts 0.00% 1 Missing ⚠️
packages/thirdweb/src/pay/buyWithFiat/getQuote.ts 0.00% 1 Missing ⚠️
...tWallet/screens/Buy/swap/useSwapSupportedChains.ts 0.00% 1 Missing ⚠️
... and 1 more

❌ Your patch status has failed because the patch coverage (23.33%) 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    #7121      +/-   ##
==========================================
- Coverage   55.59%   55.58%   -0.02%     
==========================================
  Files         901      902       +1     
  Lines       58121    58162      +41     
  Branches     4068     4086      +18     
==========================================
+ Hits        32315    32329      +14     
- Misses      25701    25731      +30     
+ Partials      105      102       -3     
Flag Coverage Δ
packages 55.58% <23.33%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/bridge/Buy.ts 92.18% <100.00%> (-4.46%) ⬇️
packages/thirdweb/src/bridge/Sell.ts 92.96% <100.00%> (-4.52%) ⬇️
packages/thirdweb/src/bridge/Transfer.ts 93.15% <100.00%> (-3.87%) ⬇️
...ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx 14.81% <ø> (ø)
...ages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts 4.79% <0.00%> (-0.04%) ⬇️
packages/thirdweb/src/pay/buyWithFiat/getQuote.ts 3.92% <0.00%> (-0.03%) ⬇️
...tWallet/screens/Buy/swap/useSwapSupportedChains.ts 5.69% <0.00%> (ø)
packages/thirdweb/src/react/web/ui/PayEmbed.tsx 46.01% <0.00%> (-0.42%) ⬇️
...ackages/thirdweb/src/pay/buyWithCrypto/getQuote.ts 3.09% <0.00%> (-0.03%) ⬇️
...nnectWallet/screens/Buy/swap/SwapScreenContent.tsx 7.95% <0.00%> (+0.36%) ⬆️
... and 5 more

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

- Added import statement for "server-only" in links.ts to ensure server-side rendering compatibility.
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 22, 2025 05:24 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 22, 2025 05:24 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 22, 2025 05:24 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 22, 2025 05:24 Inactive
@gregfromstl gregfromstl requested a review from jnsdls May 22, 2025 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants