@@ -7,9 +7,10 @@ import {
7
7
parseEther ,
8
8
toHex ,
9
9
} from "viem" ;
10
- import { Network } from "near-safe" ;
10
+ import { CHAIN_INFO } from "./constants" ;
11
+ import { getChainById } from "./chain" ;
11
12
12
- type NativeAsset = {
13
+ type WrappedAsset = {
13
14
address : Address ;
14
15
symbol : string ;
15
16
scanUrl : string ;
@@ -19,7 +20,7 @@ type NativeAsset = {
19
20
export function validateWethInput ( params : URLSearchParams ) : {
20
21
chainId : number ;
21
22
amount : bigint ;
22
- nativeAsset : NativeAsset ;
23
+ nativeAsset : WrappedAsset ;
23
24
} {
24
25
const chainIdStr = params . get ( "chainId" ) ;
25
26
const amountStr = params . get ( "amount" ) ;
@@ -78,18 +79,16 @@ export const wrapMetaTransaction = (
78
79
} ;
79
80
} ;
80
81
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 ] ;
84
84
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 } ` ) ;
88
86
}
87
+ const chain = getChainById ( chainId ) ;
89
88
return {
90
89
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 ,
94
93
} ;
95
94
}
0 commit comments