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";
4
4
import type { TokenMetadata } from "@/lib/types" ;
5
5
6
6
async 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
+ ) ;
9
11
10
12
if ( chainId ) {
11
13
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) {
312
312
props . client ,
313
313
NATIVE_TOKEN_ADDRESS ,
314
314
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
+ }
316
327
return {
317
328
data : {
318
329
destinationToken : ETH ,
You can’t perform that action at this time.
0 commit comments