@@ -7,9 +7,10 @@ import {
77 parseEther ,
88 toHex ,
99} from "viem" ;
10- import { Network } from "near-safe" ;
10+ import { CHAIN_INFO } from "./constants" ;
11+ import { getChainById } from "./chain" ;
1112
12- type NativeAsset = {
13+ type WrappedAsset = {
1314 address : Address ;
1415 symbol : string ;
1516 scanUrl : string ;
@@ -19,7 +20,7 @@ type NativeAsset = {
1920export function validateWethInput ( params : URLSearchParams ) : {
2021 chainId : number ;
2122 amount : bigint ;
22- nativeAsset : NativeAsset ;
23+ nativeAsset : WrappedAsset ;
2324} {
2425 const chainIdStr = params . get ( "chainId" ) ;
2526 const amountStr = params . get ( "amount" ) ;
@@ -78,18 +79,16 @@ export const wrapMetaTransaction = (
7879 } ;
7980} ;
8081
81- export function getNativeAsset ( chainId : number ) : NativeAsset {
82- const network = Network . fromChainId ( chainId ) ;
83- const wethAddress = network . nativeCurrency . wrappedAddress ;
82+ export function getNativeAsset ( chainId : number ) : WrappedAsset {
83+ const wethAddress = CHAIN_INFO [ chainId ] ;
8484 if ( ! wethAddress ) {
85- throw new Error (
86- `Couldn't find wrapped address for Network ${ network . name } (chainId=${ chainId } )` ,
87- ) ;
85+ throw new Error ( `Couldn't find wrapped address for chainId=${ chainId } ` ) ;
8886 }
87+ const chain = getChainById ( chainId ) ;
8988 return {
9089 address : getAddress ( wethAddress ) ,
91- symbol : network . nativeCurrency . symbol ,
92- scanUrl : `${ network . scanUrl } /address/${ wethAddress } ` ,
93- decimals : network . nativeCurrency . decimals ,
90+ symbol : chain . nativeCurrency . symbol ,
91+ scanUrl : `${ chain . blockExplorers ?. default . url } /address/${ wethAddress } ` ,
92+ decimals : chain . nativeCurrency . decimals ,
9493 } ;
9594}
0 commit comments