File tree Expand file tree Collapse file tree 6 files changed +47
-44
lines changed Expand file tree Collapse file tree 6 files changed +47
-44
lines changed Original file line number Diff line number Diff line change 1+ import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "@/constants/public-envs" ;
2+ import { UB_BASE_URL } from "./constants" ;
3+ import type { TokenMetadata } from "./types" ;
4+
5+ export async function getUniversalBridgeTokens ( props : {
6+ chainId ?: number ;
7+ address ?: string ;
8+ } ) {
9+ const url = new URL ( `${ UB_BASE_URL } /v1/tokens` ) ;
10+
11+ if ( props . chainId ) {
12+ url . searchParams . append ( "chainId" , String ( props . chainId ) ) ;
13+ }
14+ if ( props . address ) {
15+ url . searchParams . append ( "tokenAddress" , props . address ) ;
16+ }
17+ url . searchParams . append ( "limit" , "1000" ) ;
18+ url . searchParams . append ( "includePrices" , "false" ) ;
19+
20+ const res = await fetch ( url . toString ( ) , {
21+ headers : {
22+ "Content-Type" : "application/json" ,
23+ "x-client-id" : NEXT_PUBLIC_DASHBOARD_CLIENT_ID ,
24+ } as Record < string , string > ,
25+ method : "GET" ,
26+ } ) ;
27+
28+ if ( ! res . ok ) {
29+ const text = await res . text ( ) ;
30+ throw new Error ( text ) ;
31+ }
32+
33+ const json = await res . json ( ) ;
34+ return json . data as Array < TokenMetadata > ;
35+ }
Original file line number Diff line number Diff line change 11"use server" ;
22import type { ProjectResponse } from "@thirdweb-dev/service-utils" ;
33import { getAuthToken } from "@/api/auth-token" ;
4- import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs" ;
54import { UB_BASE_URL } from "./constants" ;
6-
7- export type TokenMetadata = {
8- name : string ;
9- symbol : string ;
10- address : string ;
11- decimals : number ;
12- chainId : number ;
13- iconUri ?: string ;
14- } ;
15-
16- export async function getUniversalBridgeTokens ( props : {
17- chainId ?: number ;
18- address ?: string ;
19- } ) {
20- const url = new URL ( `${ UB_BASE_URL } /v1/tokens` ) ;
21-
22- if ( props . chainId ) {
23- url . searchParams . append ( "chainId" , String ( props . chainId ) ) ;
24- }
25- if ( props . address ) {
26- url . searchParams . append ( "tokenAddress" , props . address ) ;
27- }
28- url . searchParams . append ( "limit" , "1000" ) ;
29-
30- const res = await fetch ( url . toString ( ) , {
31- headers : {
32- "Content-Type" : "application/json" ,
33- "x-secret-key" : DASHBOARD_THIRDWEB_SECRET_KEY ,
34- } as Record < string , string > ,
35- method : "GET" ,
36- } ) ;
37-
38- if ( ! res . ok ) {
39- const text = await res . text ( ) ;
40- throw new Error ( text ) ;
41- }
42-
43- const json = await res . json ( ) ;
44- return json . data as Array < TokenMetadata > ;
45- }
5+ import type { TokenMetadata } from "./types" ;
466
477export async function addUniversalBridgeTokenRoute ( props : {
488 chainId : number ;
Original file line number Diff line number Diff line change 1+ export type TokenMetadata = {
2+ name : string ;
3+ symbol : string ;
4+ address : string ;
5+ decimals : number ;
6+ chainId : number ;
7+ iconUri ?: string ;
8+ } ;
Original file line number Diff line number Diff line change 55 type ThirdwebClient ,
66} from "thirdweb" ;
77import { shortenAddress } from "thirdweb/utils" ;
8- import type { TokenMetadata } from "@/api/universal-bridge/tokens " ;
8+ import type { TokenMetadata } from "@/api/universal-bridge/types " ;
99import { Img } from "@/components/blocks/Img" ;
1010import { SelectWithSearch } from "@/components/blocks/select-with-search" ;
1111import { Badge } from "@/components/ui/badge" ;
Original file line number Diff line number Diff line change 11import { useQuery } from "@tanstack/react-query" ;
2- import { getUniversalBridgeTokens } from "@/api/universal-bridge/tokens " ;
2+ import { getUniversalBridgeTokens } from "@/api/universal-bridge/token-list " ;
33
44export function useTokensData ( {
55 chainId,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { checksumAddress } from "thirdweb/utils";
1111import z from "zod" ;
1212import { reportPaymentLinkCreated } from "@/analytics/report" ;
1313import { createPaymentLink } from "@/api/universal-bridge/developer" ;
14- import { getUniversalBridgeTokens } from "@/api/universal-bridge/tokens " ;
14+ import { getUniversalBridgeTokens } from "@/api/universal-bridge/token-list " ;
1515import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors" ;
1616import { TokenSelector } from "@/components/blocks/TokenSelector" ;
1717import { Button } from "@/components/ui/button" ;
You can’t perform that action at this time.
0 commit comments