Skip to content

Commit c82c978

Browse files
committed
fix: adds fallback to BuyWidget when native ETH isn't supported
1 parent 592bf6f commit c82c978

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,18 @@ export function BuyWidget(props: BuyWidgetProps) {
312312
props.client,
313313
NATIVE_TOKEN_ADDRESS,
314314
props.chain.id,
315-
);
315+
).catch((err) => {
316+
err.message.includes("not supported")
317+
? undefined
318+
: Promise.reject(err);
319+
});
320+
if (!ETH) {
321+
return {
322+
chain: props.chain,
323+
tokenAddress: props.tokenAddress || NATIVE_TOKEN_ADDRESS,
324+
type: "unsupported_token",
325+
};
326+
}
316327
return {
317328
data: {
318329
destinationToken: ETH,

0 commit comments

Comments
 (0)