1
+ import { Asset } from '../types'
2
+ import { getAssetEth , getAssetFuel , getAssetWithNetwork , getDefaultChainId } from '../utils/network' ;
3
+ import { assets } from '../index'
4
+ import { CHAIN_IDS } from '../../chains'
5
+
6
+ /**
7
+ * @group node
8
+ */
9
+ describe ( 'Network Utils' , ( ) => {
10
+ test ( 'getDefaultChainId' , async ( ) => {
11
+ expect ( getDefaultChainId ( 'ethereum' ) ) . toBe ( 11155111 ) ;
12
+ expect ( getDefaultChainId ( 'fuel' ) ) . toBe ( 0 ) ;
13
+ } )
14
+
15
+ test ( 'getAssetWithNetwork - Ethereum' , async ( ) => {
16
+ const asset = assets [ 0 ] as Asset
17
+ const assetEth = getAssetWithNetwork ( { asset, networkType : 'ethereum' , chainId : CHAIN_IDS . eth . sepolia } )
18
+ expect ( assetEth ) . toEqual ( {
19
+ type : 'ethereum' ,
20
+ chainId : CHAIN_IDS . eth . sepolia ,
21
+ decimals : 18 ,
22
+ icon : 'eth.svg' ,
23
+ name : 'Ethereum' ,
24
+ symbol : 'ETH'
25
+ } )
26
+ } )
27
+
28
+ test ( 'getAssetWithNetwork - Fuel' , async ( ) => {
29
+ const asset = assets [ 0 ] as Asset
30
+ const assetFuel = getAssetWithNetwork ( { asset, networkType : 'fuel' , chainId : CHAIN_IDS . fuel . beta5 } )
31
+ expect ( assetFuel ) . toEqual ( {
32
+ type : 'fuel' ,
33
+ chainId : CHAIN_IDS . fuel . beta5 ,
34
+ decimals : 9 ,
35
+ assetId : '0x0000000000000000000000000000000000000000000000000000000000000000' ,
36
+ icon : 'eth.svg' ,
37
+ name : 'Ethereum' ,
38
+ symbol : 'ETH'
39
+ } )
40
+ } )
41
+
42
+ test ( 'getAssetWithNetwork - invalid network' , async ( ) => {
43
+ const asset = assets [ 0 ] as Asset
44
+ const assetUndefined = getAssetWithNetwork ( { asset, networkType : 'ethereum' , chainId : 0 } )
45
+ expect ( assetUndefined ) . toBeUndefined ( )
46
+ } )
47
+
48
+ test ( 'getAssetEth' , async ( ) => {
49
+ const asset = assets [ 0 ] as Asset
50
+ const assetEth = getAssetEth ( asset )
51
+ expect ( assetEth ) . toEqual ( {
52
+ type : 'ethereum' ,
53
+ chainId : CHAIN_IDS . eth . sepolia ,
54
+ decimals : 18 ,
55
+ icon : 'eth.svg' ,
56
+ name : 'Ethereum' ,
57
+ symbol : 'ETH' ,
58
+ } )
59
+ } )
60
+
61
+ test ( 'getAssetFuel' , async ( ) => {
62
+ const asset = assets [ 0 ] as Asset
63
+ const assetFuel = getAssetFuel ( asset )
64
+
65
+ expect ( assetFuel ) . toEqual ( {
66
+ type : 'fuel' ,
67
+ chainId : CHAIN_IDS . fuel . beta5 ,
68
+ decimals : 9 ,
69
+ assetId : '0x0000000000000000000000000000000000000000000000000000000000000000' ,
70
+ icon : 'eth.svg' ,
71
+ name : 'Ethereum' ,
72
+ symbol : 'ETH' ,
73
+ } )
74
+ } )
75
+ } )
0 commit comments