Skip to content

Commit 56a220c

Browse files
committed
BREAKING: Coerce ub webhook amounts into bigints
1 parent 3e28271 commit 56a220c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/thirdweb/src/bridge/Webhook.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ const tokenSchema = z.object({
2121
const onchainWebhookSchema = z.discriminatedUnion("version", [
2222
z.object({
2323
data: z.object({}),
24-
type: z.literal("ONCHAIN"),
24+
topic: z.literal("pay.onchain-transaction"),
2525
version: z.literal(1),
2626
}),
2727
z.object({
2828
data: z.object({
2929
action: z.enum(["TRANSFER", "BUY", "SELL"]),
3030
clientId: z.string(),
31-
destinationAmount: z.string(),
31+
destinationAmount: z.coerce.bigint(),
3232
destinationToken: tokenSchema,
3333
developerFeeBps: z.coerce.number(),
3434
developerFeeRecipient: addressSchema,
35-
originAmount: z.string(),
35+
originAmount: z.coerce.bigint(),
3636
originToken: tokenSchema,
3737
paymentId: z.string(),
3838
// only exists when the payment was triggered from a developer specified payment link
@@ -49,20 +49,20 @@ const onchainWebhookSchema = z.discriminatedUnion("version", [
4949
),
5050
type: z.string(),
5151
}),
52-
type: z.literal("ONCHAIN"),
52+
topic: z.literal("pay.onchain-transaction"),
5353
version: z.literal(2),
5454
}),
5555
]);
5656

5757
const onrampWebhookSchema = z.discriminatedUnion("version", [
5858
z.object({
5959
data: z.object({}),
60-
type: z.literal("ONRAMP"),
60+
topic: z.literal("pay.onramp-transaction"),
6161
version: z.literal(1),
6262
}),
6363
z.object({
6464
data: z.object({
65-
amount: z.string(),
65+
amount: z.coerce.bigint(),
6666
currency: z.string(),
6767
currencyAmount: z.number(),
6868
id: z.string(),
@@ -75,7 +75,7 @@ const onrampWebhookSchema = z.discriminatedUnion("version", [
7575
token: tokenSchema,
7676
transactionHash: z.optional(hexSchema),
7777
}),
78-
type: z.literal("ONRAMP"),
78+
topic: z.literal("pay.onramp-transaction"),
7979
version: z.literal(2),
8080
}),
8181
]);

0 commit comments

Comments
 (0)