Skip to content

Commit 5277edd

Browse files
committed
[SDK] Fix: Webhook Schema (#7151)
<!-- ## 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 updating the `Webhook` schema in the `thirdweb` package to enhance the structure of `originToken` and `destinationToken` by replacing simple address strings with detailed objects containing additional properties. ### Detailed summary - Updated `originToken` and `destinationToken` to be objects with properties: - `chainId` - `address` - `name` - `symbol` - `decimals` - `priceUsd` - `iconUri` - Adjusted the test file to reflect these changes with appropriate object structures. > ✨ 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 - **Bug Fixes** - Enhanced webhook support to include detailed token information such as chain ID, name, symbol, decimals, price, and icon for origin and destination tokens. - **Tests** - Updated test data to match the new detailed token structure in webhook payloads. - **Chores** - Added a changeset to document this patch update. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 6c180b5 commit 5277edd

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

.changeset/purple-wasps-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix Webhook schema type

packages/thirdweb/src/bridge/Webhook.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,25 @@ describe("parseIncomingWebhook", () => {
2828
clientId: "client123",
2929
action: "TRANSFER",
3030
status: "COMPLETED",
31-
originToken: "0x1234567890123456789012345678901234567890" as const,
31+
originToken: {
32+
chainId: 1,
33+
address: "0x1234567890123456789012345678901234567890" as const,
34+
name: "Token",
35+
symbol: "TKN",
36+
decimals: 18,
37+
priceUsd: 1.0,
38+
iconUri: "https://example.com/icon.png",
39+
},
3240
originAmount: "1.0",
33-
destinationToken: "0x1234567890123456789012345678901234567890",
41+
destinationToken: {
42+
chainId: 1,
43+
address: "0x1234567890123456789012345678901234567890" as const,
44+
name: "Token",
45+
symbol: "TKN",
46+
decimals: 18,
47+
priceUsd: 1.0,
48+
iconUri: "https://example.com/icon.png",
49+
},
3450
destinationAmount: "1.0",
3551
sender: "0x1234567890123456789012345678901234567890",
3652
receiver: "0x1234567890123456789012345678901234567890",

packages/thirdweb/src/bridge/Webhook.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,25 @@ const webhookSchema = z.union([
2323
clientId: z.string(),
2424
action: z.enum(["TRANSFER", "BUY", "SELL"]),
2525
status: z.enum(["PENDING", "FAILED", "COMPLETED"]),
26-
originToken: addressSchema,
26+
originToken: z.object({
27+
chainId: z.coerce.number(),
28+
address: addressSchema,
29+
name: z.string(),
30+
symbol: z.string(),
31+
decimals: z.coerce.number(),
32+
priceUsd: z.coerce.number(),
33+
iconUri: z.optional(z.string()),
34+
}),
2735
originAmount: z.string(),
28-
destinationToken: addressSchema,
36+
destinationToken: z.object({
37+
chainId: z.coerce.number(),
38+
address: addressSchema,
39+
name: z.string(),
40+
symbol: z.string(),
41+
decimals: z.coerce.number(),
42+
priceUsd: z.coerce.number(),
43+
iconUri: z.optional(z.string()),
44+
}),
2945
destinationAmount: z.string(),
3046
sender: addressSchema,
3147
receiver: addressSchema,

0 commit comments

Comments
 (0)