Skip to content

[Dashboard] Fix: Purchase Data #7225

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 6 commits into from
May 30, 2025
Merged

[Dashboard] Fix: Purchase Data #7225

merged 6 commits into from
May 30, 2025

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented May 30, 2025


PR-Codex overview

This PR focuses on updating the handling of purchaseData across various components and types in the application, ensuring it is correctly defined and utilized.

Detailed summary

  • Updated purchaseData to be undefined in apps/dashboard/src/app/pay/page.tsx.
  • Passed paymentLink.purchaseData in apps/dashboard/src/app/pay/[id]/page.tsx.
  • Changed purchaseData type to Record<string, unknown> | undefined in apps/dashboard/src/@/api/universal-bridge/links.ts.
  • Modified purchaseData to be optional in packages/thirdweb/src/bridge/Webhook.ts.
  • Adjusted transactions format in packages/thirdweb/src/bridge/Webhook.test.ts to include chainId.
  • Added purchaseData as a parameter in apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx.

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

Summary by CodeRabbit

  • New Features
    • Enhanced payment page to support passing additional purchase-related data during checkout.
  • Bug Fixes
    • Improved handling and typing of purchase data in payment links to ensure better data consistency.

@gregfromstl gregfromstl requested review from a team as code owners May 30, 2025 15:38
Copy link

changeset-bot bot commented May 30, 2025

🦋 Changeset detected

Latest commit: ea2ad78

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

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

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

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

Copy link

vercel bot commented May 30, 2025

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:32pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) May 30, 2025 4:32pm
login ⬜️ Skipped (Inspect) May 30, 2025 4:32pm
thirdweb_playground ⬜️ Skipped (Inspect) May 30, 2025 4:32pm
wallet-ui ⬜️ Skipped (Inspect) May 30, 2025 4:32pm

Copy link
Contributor

coderabbitai bot commented May 30, 2025

"""

Walkthrough

The changes refine the typing of the purchaseData property across the payment link API, dashboard components, and the webhook schema. The purchaseData is now typed as an optional record of string keys to unknown values and is passed as a prop through the payment page components without altering control flow.

Changes

File(s) Change Summary
apps/dashboard/src/app/pay/[id]/page.tsx Passes purchaseData from paymentLink to PayPageEmbed as a new prop.
apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx Changes purchaseData prop type to `Record<string, unknown>
apps/dashboard/src/@/api/universal-bridge/links.ts Updates PaymentLink type: purchaseData changed from unknown to `Record<string, unknown>
packages/thirdweb/src/bridge/Webhook.ts Modifies webhook v2 schema: transactions changed to array of objects with chainId and transactionHash; purchaseData made optional with refined type.
packages/thirdweb/src/bridge/Webhook.test.ts Updates test payload: transactions changed to array of objects with chainId and transactionHash.
apps/dashboard/src/app/pay/page.tsx Adds purchaseData prop with undefined to PayPageEmbed in PayPage.
.changeset/dirty-cougars-teach.md Adds patch update for thirdweb package fixing purchaseData usage in payment links.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PayPage
    participant PayPageEmbed
    participant PayEmbed

    User->>PayPage: Access payment link (with purchaseData)
    PayPage->>PayPageEmbed: Render with purchaseData prop
    PayPageEmbed->>PayEmbed: Pass purchaseData in payOptions
Loading

Suggested reviewers

  • jnsdls
  • 0xFirekeeper
    """

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

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

Copy link
Contributor

graphite-app bot commented May 30, 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 the Dashboard Involves changes to the Dashboard. label May 30, 2025
Copy link

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.62%. Comparing base (926dad4) to head (7eed960).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7225   +/-   ##
=======================================
  Coverage   55.62%   55.62%           
=======================================
  Files         908      908           
  Lines       58570    58570           
  Branches     4133     4133           
=======================================
  Hits        32577    32577           
  Misses      25886    25886           
  Partials      107      107           
Flag Coverage Δ
packages 55.62% <ø> (ø)
🚀 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: 2

🧹 Nitpick comments (1)
apps/dashboard/src/app/pay/[id]/page.tsx (1)

68-68: Add error handling for purchaseData access.

Consider adding error handling to gracefully handle cases where paymentLink.purchaseData might be undefined or contain unexpected data types.

-      purchaseData={paymentLink.purchaseData}
+      purchaseData={paymentLink.purchaseData ?? undefined}

Alternatively, add validation:

+  // Validate purchaseData
+  const purchaseData = paymentLink.purchaseData && 
+    typeof paymentLink.purchaseData === 'object' 
+    ? paymentLink.purchaseData 
+    : undefined;
+
   return (
     <PayPageEmbed
       // ... other props
-      purchaseData={paymentLink.purchaseData}
+      purchaseData={purchaseData}
     />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 926dad4 and 916d108.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/pay/[id]/page.tsx (1 hunks)
  • apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • 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: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (1)

55-55: Inconsistency with AI summary - verify placement of purchaseData.

The AI summary states that purchaseData is forwarded into payOptions.metadata, but the implementation adds it directly to payOptions. Please verify this is the intended behavior and ensure it aligns with the PayEmbed component's expected interface.

#!/bin/bash
# Description: Verify PayEmbed component interface and purchaseData usage
# Expected: Find PayEmbed component definition and its payOptions interface

ast-grep --pattern $'interface $_ {
  $$$
  purchaseData$_
  $$$
}'

# Also search for PayEmbed component usage patterns
rg -A 10 -B 5 "PayEmbed.*payOptions"

Likely an incorrect or invalid review comment.

apps/dashboard/src/app/pay/[id]/page.tsx (1)

68-68:

✅ Verification successful

Verify paymentLink.purchaseData property exists in the data model.

Ensure that the purchaseData property is properly defined in the paymentLink object's type definition and that the API response includes this field.


🏁 Script executed:

#!/bin/bash
# Description: Verify paymentLink type definition includes purchaseData
# Expected: Find interface/type definitions for paymentLink

ast-grep --pattern $'interface $_ {
  $$$
  purchaseData$_
  $$$
}'

ast-grep --pattern $'type $_ = {
  $$$
  purchaseData$_
  $$$
}'

# Search for getPaymentLink function return type
rg -A 20 "getPaymentLink.*=>"

Length of output: 166


🏁 Script executed:

#!/bin/bash
# Locate any type or interface definitions for PaymentLink
rg -n "export (interface|type) PaymentLink"

# Search for all occurrences of 'purchaseData' to see where it’s referenced or defined
rg -n "purchaseData"

Length of output: 11919


paymentLink.purchaseData property is defined and mapped correctly

  • apps/dashboard/src/@/api/universal-bridge/links.ts defines the PaymentLink type with purchaseData: unknown
  • The API response maps data.purchaseData into this field

No changes required.

@@ -16,6 +16,7 @@ export function PayPageEmbed({
image,
redirectUri,
theme,
purchaseData,
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider more specific typing for purchaseData.

The unknown | undefined type is very broad and could lead to type safety issues downstream. Consider defining a more specific interface or using a generic type parameter to provide better type safety and developer experience.

-  purchaseData: unknown | undefined;
+  purchaseData?: Record<string, unknown>;

Or define a specific interface:

interface PurchaseData {
  orderId?: string;
  customFields?: Record<string, unknown>;
  // other expected fields...
}

Also applies to: 31-31

🤖 Prompt for AI Agents
In apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx at lines
19 and 31, the purchaseData prop is typed as unknown | undefined, which is too
broad and unsafe. Define a specific TypeScript interface describing the expected
structure of purchaseData, including fields like orderId and customFields, and
update the typing of purchaseData to use this interface for improved type safety
and clarity.

Copy link
Contributor

github-actions bot commented May 30, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.14 KB (-0.01% 🔽) 1.3 s (-0.01% 🔽) 259 ms (+120.48% 🔺) 1.6 s
thirdweb (cjs) 344.83 KB (-0.01% 🔽) 6.9 s (-0.01% 🔽) 880 ms (-9.02% 🔽) 7.8 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 47 ms (+399.25% 🔺) 161 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 29 ms (+1152.68% 🔺) 39 ms
thirdweb/react (minimal + tree-shaking) 19.52 KB (0%) 391 ms (0%) 87 ms (+405.02% 🔺) 478 ms

…nt.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: greg <[email protected]>
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 30, 2025 15:49 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 30, 2025 15:49 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 30, 2025 15:49 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 30, 2025 15:49 Inactive
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

♻️ Duplicate comments (1)
apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (1)

19-19: Address the typing issue from previous review.

The purchaseData prop is still typed as unknown | undefined, which was flagged in the previous review as too broad and unsafe. This should be addressed with more specific typing.

Also applies to: 31-31

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 916d108 and 7eed960.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx

[error] 56-56: expected : but instead found sanitizedPurchaseData

Remove sanitizedPurchaseData

(parse)


[error] 58-58: expected , but instead found ;

Remove ;

(parse)


[error] 56-58: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)

…roved type safety

- Updated the purchaseData type in PayPageEmbed component and PaymentLink type to use Record<string, unknown> | undefined for better clarity.
- Modified webhook schema to make purchaseData optional, enhancing flexibility in handling webhook data.
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7eed960 and 4e46698.

📒 Files selected for processing (3)
  • apps/dashboard/src/@/api/universal-bridge/links.ts (1 hunks)
  • apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx (3 hunks)
  • packages/thirdweb/src/bridge/Webhook.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/@/api/universal-bridge/links.ts (1)

18-18: LGTM! Type refinement improves API clarity.

The type change from unknown to Record<string, unknown> | undefined provides better type safety and makes the API more predictable while maintaining backward compatibility.

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

57-57:

❓ Verification inconclusive

Breaking change: purchaseData is now optional.

The purchaseData field has been changed from required to optional. While this aligns with the type refinements in other components, it's a breaking change for webhook consumers that expect this field to always be present.

Verify that webhook consumers handle the optional purchaseData appropriately:


🏁 Script executed:

#!/bin/bash
# Description: Search for webhook purchaseData usage to ensure optional handling
# Expected: Find code that accesses purchaseData to verify it handles undefined values

# Search for purchaseData usage in webhook processing
rg -A 5 -B 5 "purchaseData" --type ts --type js

# Look for direct property access that might not handle undefined
rg "\.purchaseData\." --type ts --type js

Length of output: 69757


Verify external webhook consumers handle optional purchaseData

The Webhook schema in packages/thirdweb/src/bridge/Webhook.ts (around line 57) has been updated to make purchaseData optional:

- purchaseData: z.record(z.string(), z.unknown()),
+ purchaseData: z.optional(z.record(z.string(), z.unknown())),

Internal code search shows no direct property access (e.g. purchaseData.foo) in this repo—everything passes purchaseData through as an opaque object. However, this is a breaking change for external webhook integrations: data.purchaseData may now be undefined instead of an empty object.

Please:

  • Update the CHANGELOG/release notes to call out this breaking change.
  • Bump the major version per semver to signal downstream impact.
  • Ensure all external consumers of parse(...) handle data.purchaseData === undefined (e.g. use data.purchaseData || {}).
  • (Optional) Add a Webhook test case for a payload missing purchaseData to guard against regressions.

@gregfromstl gregfromstl added the merge-queue Adds the pull request to Graphite's merge queue. label May 30, 2025
Copy link
Member Author

gregfromstl commented May 30, 2025

Merge activity

  • May 30, 4:10 PM UTC: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 30, 4:49 PM UTC: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.

@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 30, 2025 16:22 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 30, 2025 16:22 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 30, 2025 16:22 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 30, 2025 16:22 Inactive
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

🔭 Outside diff range comments (3)
packages/thirdweb/src/bridge/Webhook.test.ts (3)

314-332: 🛠️ Refactor suggestion

Add validation tests for the new transaction object structure.

The existing test only validates that transactions is an array, but doesn't test the internal structure of transaction objects (chainId and transactionHash validation).

Add this test after the existing "invalid transactions array" test:

+    it("should throw error for invalid transaction object structure", async () => {
+      const invalidPayload = {
+        version: 2,
+        data: {
+          ...validPayload.data,
+          transactions: [
+            {
+              chainId: "invalid", // should be number
+              transactionHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
+            },
+          ],
+        },
+      };
+      const payloadString = JSON.stringify(invalidPayload);
+      const signature = await generateSignature(testTimestamp, payloadString);
+      const headers = {
+        "x-payload-signature": signature,
+        "x-timestamp": testTimestamp,
+      };
+
+      await expect(
+        parse(payloadString, headers, secret),
+      ).rejects.toHaveProperty("name", "$ZodError");
+    });
+
+    it("should throw error for invalid transaction hash format", async () => {
+      const invalidPayload = {
+        version: 2,
+        data: {
+          ...validPayload.data,
+          transactions: [
+            {
+              chainId: 1,
+              transactionHash: "invalid-hash", // should be valid hex
+            },
+          ],
+        },
+      };
+      const payloadString = JSON.stringify(invalidPayload);
+      const signature = await generateSignature(testTimestamp, payloadString);
+      const headers = {
+        "x-payload-signature": signature,
+        "x-timestamp": testTimestamp,
+      };
+
+      await expect(
+        parse(payloadString, headers, secret),
+      ).rejects.toHaveProperty("name", "$ZodError");
+    });

354-372: 🛠️ Refactor suggestion

Add test case for undefined purchaseData.

The current test only checks for null values, but should also test the undefined case since purchaseData is now optional.

Add this test case to properly validate the optional nature of purchaseData:

+    it("should accept undefined purchaseData", async () => {
+      const validPayloadWithoutPurchaseData = {
+        version: 2,
+        data: {
+          ...validPayload.data,
+        },
+      };
+      delete validPayloadWithoutPurchaseData.data.purchaseData;
+      
+      const payloadString = JSON.stringify(validPayloadWithoutPurchaseData);
+      const signature = await generateSignature(testTimestamp, payloadString);
+      const headers = {
+        "x-payload-signature": signature,
+        "x-timestamp": testTimestamp,
+      };
+
+      const result = await parse(payloadString, headers, secret);
+      expect(result).toEqual(validPayloadWithoutPurchaseData);
+    });

66-66: 💡 Verification agent

🧩 Analysis chain

Verify purchaseData validation with the new optional type.

The test uses an empty object for purchaseData, but should also test the undefined case since the field is now optional.

Run this script to verify the webhook schema supports both object and undefined values for purchaseData:


🏁 Script executed:

#!/bin/bash
# Description: Check the webhook schema definition for purchaseData field
# Expected: purchaseData should be defined as optional with Record<string, unknown> type

rg -A 10 -B 5 "purchaseData.*:" packages/thirdweb/src/bridge/Webhook.ts

Length of output: 400


Add test case for undefined purchaseData

We’ve confirmed in packages/thirdweb/src/bridge/Webhook.ts that the schema declares

purchaseData: z.optional(z.record(z.string(), z.unknown())),

so payloads must accept both an object and undefined. The existing test only covers {}. Please update packages/thirdweb/src/bridge/Webhook.test.ts to include a case where purchaseData is omitted or explicitly undefined:

• File: packages/thirdweb/src/bridge/Webhook.test.ts
• Around line 66 (inside the webhook-schema test suite), add:

 describe("webhook schema", () => {
   it("validates payload with empty purchaseData", () => {
     // existing test…
   });

+  it("validates payload when purchaseData is undefined", () => {
+    const payload = {
+      // …all required fields except purchaseData
+    } as any;
+    expect(() => webhookSchema.parse(payload)).not.toThrow();
+  });
 });

This ensures both the empty‐object and undefined scenarios are explicitly tested.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 73f0d2f and ea2ad78.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/pay/page.tsx (1 hunks)
  • packages/thirdweb/src/bridge/Webhook.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/dashboard/src/app/pay/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)

Comment on lines 54 to 63
transactions: [
"0x1234567890123456789012345678901234567890",
"0x1234567890123456789012345678901234567890",
{
chainId: 1,
transactionHash: "0x1234567890123456789012345678901234567890",
},
{
chainId: 1,
transactionHash: "0x1234567890123456789012345678901234567890",
},
],
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix transaction hash format and improve test data diversity.

The transaction hashes in the test data appear to be using address format (42 characters) instead of transaction hash format (66 characters). Additionally, both transaction objects use identical values, which reduces test effectiveness.

Apply this diff to fix the transaction hash format and add diversity:

       transactions: [
         {
           chainId: 1,
-          transactionHash: "0x1234567890123456789012345678901234567890",
+          transactionHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
         },
         {
-          chainId: 1,
-          transactionHash: "0x1234567890123456789012345678901234567890",
+          chainId: 137,
+          transactionHash: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
         },
       ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
transactions: [
"0x1234567890123456789012345678901234567890",
"0x1234567890123456789012345678901234567890",
{
chainId: 1,
transactionHash: "0x1234567890123456789012345678901234567890",
},
{
chainId: 1,
transactionHash: "0x1234567890123456789012345678901234567890",
},
],
transactions: [
{
chainId: 1,
transactionHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
},
{
chainId: 137,
transactionHash: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
},
],
🤖 Prompt for AI Agents
In packages/thirdweb/src/bridge/Webhook.test.ts around lines 54 to 63, the
transactionHash values are incorrectly formatted as 42-character addresses
instead of 66-character transaction hashes, and both transactions have identical
data. Update each transactionHash to a valid 66-character hash string and ensure
the two transactions have distinct values to improve test coverage and accuracy.

@gregfromstl gregfromstl merged commit 3edbe28 into main May 30, 2025
20 of 21 checks passed
@gregfromstl gregfromstl deleted the greg/fix-purchase-data branch May 30, 2025 16:45
@joaquim-verges joaquim-verges mentioned this pull request May 30, 2025
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. merge-queue Adds the pull request to Graphite's merge queue. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant