-
Notifications
You must be signed in to change notification settings - Fork 557
Feature: Adds onramp webhook schema to sdk #7450
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
Feature: Adds onramp webhook schema to sdk #7450
Conversation
🦋 Changeset detectedLatest commit: fa5e13b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe webhook payload validation schema was refactored to use a new reusable Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Webhook
participant Validator
Client->>Webhook: Send payload (string), headers, secret
Webhook->>Validator: Validate payload using webhookSchema
Validator-->>Webhook: Return parsed and validated WebhookPayload
Webhook-->>Client: Return Promise<WebhookPayload>
Possibly related PRs
Suggested reviewers
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
There was a problem hiding this 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
🧹 Nitpick comments (2)
packages/thirdweb/src/bridge/Webhook.ts (2)
5-10
: Simplify zod schema definitions by removing redundantz.check()
.The current usage of
z.check(z.refine(...))
is redundant. Thez.refine()
method already provides the same validation functionality.-const hexSchema = z - .string() - .check(z.refine(isHex, { message: "Invalid hex string" })); -const addressSchema = z - .string() - .check(z.refine(isAddress, { message: "Invalid address" })); +const hexSchema = z + .string() + .refine(isHex, { message: "Invalid hex string" }); +const addressSchema = z + .string() + .refine(isAddress, { message: "Invalid address" });
186-186
: Remove redundantsatisfies
operator.The
satisfies
operator is redundant since the function already has an explicit return type annotation. The TypeScript compiler will ensure type safety without it.- return parsedPayload satisfies WebhookPayload; + return parsedPayload;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/thirdweb/src/bridge/Webhook.ts
(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.@(ts|tsx)`: Accept a typed 'props' object and export a named function (e.g...
**/*.@(ts|tsx)
: Accept a typed 'props' object and export a named function (e.g., export function MyComponent()).
Combine class names via 'cn', expose 'className' prop if useful.
Reuse core UI primitives; avoid re-implementing buttons, cards, modals.
Local state or effects live inside; data fetching happens in hooks.
Merge class names with 'cn' from '@/lib/utils' to keep conditional logic readable.
Stick to design-tokens: background ('bg-card'), borders ('border-border'), muted text ('text-muted-foreground') etc.
Use the 'container' class with a 'max-w-7xl' cap for page width consistency.
Spacing utilities ('px-', 'py-', 'gap-*') are preferred over custom margins.
Responsive helpers follow mobile-first ('max-sm', 'md', 'lg', 'xl').
Never hard-code colors – always go through Tailwind variables.
Tailwind CSS is the styling system – avoid inline styles or CSS modules.
Prefix files with 'import "server-only";' so they never end up in the client bundle (for server-only code).
📄 Source: CodeRabbit Inference Engine (.cursor/rules/dashboard.mdc)
List of files the instruction was applied to:
packages/thirdweb/src/bridge/Webhook.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: AmineAfia
PR: thirdweb-dev/js#7173
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/WebhooksTable.tsx:59-73
Timestamp: 2025-05-27T21:57:09.248Z
Learning: In the webhooks functionality, form validation prevents users from reaching test webhook functionality without entering a valid URL, ensuring data integrity before testing operations.
packages/thirdweb/src/bridge/Webhook.ts (1)
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
🧬 Code Graph Analysis (1)
packages/thirdweb/src/bridge/Webhook.ts (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/schema.ts (1)
addressSchema
(25-35)packages/thirdweb/src/bridge/index.ts (1)
WebhookPayload
(21-21)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Lint Packages
- GitHub Check: Unit Tests
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/thirdweb/src/bridge/Webhook.ts (4)
11-19
: LGTM! Well-structured reusable token schema.The
tokenSchema
provides good type safety and reusability across both onchain and onramp webhooks. The field types are appropriate and consistent.
21-55
: LGTM! Proper discriminated union structure for onchain webhooks.The discriminated union on
version
provides excellent type safety. The schema correctly:
- Separates version 1 (deprecated) from version 2 (current)
- Uses the reusable
tokenSchema
for token fields- Includes appropriate
type: "ONCHAIN"
literals for discrimination
83-86
: LGTM! Excellent use of discriminated union for webhook types.The top-level discrimination on
type
field provides clear separation between "ONCHAIN" and "ONRAMP" webhooks, enabling proper type narrowing in consuming code.
121-121
: Good addition of explicit return type.The explicit
Promise<WebhookPayload>
return type improves API clarity and ensures type safety for consumers of this function.
size-limit report 📦
|
6c911b6
to
56a220c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7450 +/- ##
==========================================
+ Coverage 51.92% 51.94% +0.01%
==========================================
Files 947 947
Lines 63875 63899 +24
Branches 4214 4216 +2
==========================================
+ Hits 33166 33190 +24
Misses 30603 30603
Partials 106 106
🚀 New features to boost your workflow:
|
Merge activity
|
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on adding onramp webhook parsing functionality to the `Universal Bridge` in the `thirdweb` package, along with updates to existing tests to accommodate new payload structures. ### Detailed summary - Added onramp webhook parsing for `Universal Bridge`. - Updated `chainId` and `transactionHash` values in tests. - Modified the structure of `validWebhook` and `validPayload` in `Webhook.test.ts`. - Changed `destinationAmount` and `originAmount` types to `bigint`. - Introduced `onchainWebhookSchema` and `onrampWebhookSchema` in `Webhook.ts`. - Updated `webhookSchema` to include `onchain` and `onramp` transaction types. - Enhanced the `parse` function to return a `WebhookPayload` that satisfies the new schema. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced webhook parsing to support onramp webhooks for the Universal Bridge. * **Refactor** * Improved validation and structure of webhook payloads for clearer distinction between onchain and onramp types. * Updated numeric fields to ensure correct data types and improved payload handling. * **Documentation** * Added a changeset file describing the new onramp webhook parsing capability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
90db465
to
fa5e13b
Compare
PR-Codex overview
This PR focuses on adding onramp webhook parsing for the Universal Bridge in the
thirdweb
package, along with updates to existing tests and schema definitions.Detailed summary
Status.test.ts
with newchainId
andtransactionHash
.Webhook.test.ts
to usebigint
for amounts and added new payload validation.Webhook.ts
with new schemas for onramp transactions.Summary by CodeRabbit
New Features
Refactor
Documentation