File tree Expand file tree Collapse file tree 4 files changed +34
-44
lines changed Expand file tree Collapse file tree 4 files changed +34
-44
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11"use server" ;
22import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs" ;
3+ import { getAuthToken } from "app/(app)/api/lib/getAuthToken" ;
34import { UB_BASE_URL } from "./constants" ;
45
56export type TokenMetadata = {
@@ -37,3 +38,31 @@ export async function getUniversalBridgeTokens(props: {
3738 const json = await res . json ( ) ;
3839 return json . data as Array < TokenMetadata > ;
3940}
41+
42+ export async function addUniversalBridgeTokenRoute ( props : {
43+ chainId ?: number ;
44+ tokenAddress ?: string ;
45+ } ) {
46+ const authToken = await getAuthToken ( ) ;
47+ const url = new URL ( `${ UB_BASE_URL } /v1/tokens` ) ;
48+
49+ const res = await fetch ( url . toString ( ) , {
50+ method : "POST" ,
51+ headers : {
52+ "Content-Type" : "application/json" ,
53+ Authorization : `Bearer ${ authToken } ` ,
54+ } as Record < string , string > ,
55+ body : JSON . stringify ( {
56+ chainId : props . chainId ,
57+ tokenAddress : props . tokenAddress ,
58+ } ) ,
59+ } ) ;
60+
61+ if ( ! res . ok ) {
62+ const text = await res . text ( ) ;
63+ throw new Error ( text ) ;
64+ }
65+
66+ const json = await res . json ( ) ;
67+ return json . data as Array < TokenMetadata > ;
68+ }
Original file line number Diff line number Diff line change 11"use client" ;
2- import { addUniversalBridgeTokenRoute } from "@/api/universal-bridge/addRoute " ; // Adjust the import path
2+ import { addUniversalBridgeTokenRoute } from "@/api/universal-bridge/tokens " ; // Adjust the import path
33import { RouteDiscoveryCard } from "@/components/blocks/RouteDiscoveryCard" ;
44import {
55 Form ,
Original file line number Diff line number Diff line change 1+ import { isAddress } from "thirdweb" ;
12import { RE_DOMAIN } from "utils/regex" ;
23import { validStrList } from "utils/validations" ;
34import { z } from "zod" ;
@@ -129,7 +130,9 @@ export const routeDiscoveryValidationSchema = z.object({
129130 . string ( {
130131 required_error : "Token address is required" ,
131132 } )
132- . regex ( / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / , "Invalid contract address format" ) ,
133+ . refine ( ( value ) => isAddress ( value ) , {
134+ message : "Invalid Ethereum address format" ,
135+ } ) ,
133136} ) ;
134137export type RouteDiscoveryValidationSchema = z . infer <
135138 typeof routeDiscoveryValidationSchema
You can’t perform that action at this time.
0 commit comments