File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
apps/playground-web/src/hooks
packages/thirdweb/src/react/web/ui/Bridge Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ import { useQuery } from "@tanstack/react-query";
44import type { TokenMetadata } from "@/lib/types" ;
55
66async function fetchTokensFromApi ( chainId ?: number ) {
7- const domain = process . env . NEXT_PUBLIC_BRIDGE_URL ;
8- const url = new URL ( `https://${ domain } /v1/tokens` ) ;
7+ const domain = process . env . NEXT_PUBLIC_BRIDGE_URL || "bridge.thirdweb.com" ;
8+ const url = new URL (
9+ `${ domain . includes ( "localhost" ) ? "http" : "https" } ://${ domain } /v1/tokens` ,
10+ ) ;
911
1012 if ( chainId ) {
1113 url . searchParams . append ( "chainId" , String ( chainId ) ) ;
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments