@@ -53,6 +53,7 @@ pub enum Chain {
53
53
LOCAL ,
54
54
IOTEX ,
55
55
SCROLL ,
56
+ VANA ,
56
57
}
57
58
58
59
pub trait PriceOracle : Debug {
@@ -87,6 +88,7 @@ impl FromStr for Chain {
87
88
"local" => Ok ( Self :: LOCAL ) ,
88
89
"iotex" => Ok ( Self :: IOTEX ) ,
89
90
"scroll" => Ok ( Self :: SCROLL ) ,
91
+ "vana" => Ok ( Self :: VANA ) ,
90
92
_ => Err ( ( ) ) ,
91
93
}
92
94
}
@@ -152,6 +154,7 @@ impl Chain {
152
154
59144 => Self :: LINEA ,
153
155
4689 => Self :: IOTEX ,
154
156
534352 => Self :: SCROLL ,
157
+ 1480 => Self :: VANA ,
155
158
31337 => Self :: LOCAL ,
156
159
_ => return Err ( anyhow ! ( "Unknown chain id: {}" , chain_id) ) ,
157
160
} )
@@ -179,6 +182,7 @@ impl Chain {
179
182
Chain :: LINEA => 59144 ,
180
183
Chain :: IOTEX => 4689 ,
181
184
Chain :: SCROLL => 534352 ,
185
+ Chain :: VANA => 1480 ,
182
186
Chain :: LOCAL => 31337 ,
183
187
}
184
188
}
@@ -206,6 +210,7 @@ impl Chain {
206
210
Chain :: LOCAL => "local" ,
207
211
Chain :: IOTEX => "iotex" ,
208
212
Chain :: SCROLL => "scroll" ,
213
+ Chain :: VANA => "vana" ,
209
214
}
210
215
. to_string ( )
211
216
}
@@ -235,6 +240,7 @@ impl Chain {
235
240
Chain :: LINEA => "https://rpc.ankr.com/linea" ,
236
241
Chain :: IOTEX => "https://rpc.ankr.com/iotex" ,
237
242
Chain :: SCROLL => "https://rpc.ankr.com/scroll" ,
243
+ Chain :: VANA => "https://rpc.vana.org" ,
238
244
Chain :: LOCAL => "http://localhost:8545" ,
239
245
}
240
246
. to_string ( )
@@ -263,6 +269,7 @@ impl Chain {
263
269
Chain :: LOCAL => "http://localhost:8080/abi/" ,
264
270
Chain :: IOTEX => "https://babel-api.mainnet.IoTeX.io" ,
265
271
Chain :: SCROLL => "https://api.scrollscan.com/api" ,
272
+ Chain :: VANA => "https://api.vanascan.io/api/v2" ,
266
273
}
267
274
. to_string ( )
268
275
}
@@ -393,6 +400,7 @@ impl ChainConfig for OnChainConfig {
393
400
"eth" | "arbitrum" | "scroll" => return pegged_token. get ( "WETH" ) . unwrap ( ) . to_string ( ) ,
394
401
"bsc" => return pegged_token. get ( "WBNB" ) . unwrap ( ) . to_string ( ) ,
395
402
"polygon" => return pegged_token. get ( "WMATIC" ) . unwrap ( ) . to_string ( ) ,
403
+ "vana" => return pegged_token. get ( "WVANA" ) . unwrap ( ) . to_string ( ) ,
396
404
"local" => return pegged_token. get ( "ZERO" ) . unwrap ( ) . to_string ( ) ,
397
405
// "mumbai" => panic!("Not supported"),
398
406
_ => {
@@ -461,6 +469,14 @@ impl ChainConfig for OnChainConfig {
461
469
. iter ( )
462
470
. map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) )
463
471
. collect ( ) ,
472
+ "vana" => [
473
+ ( "WETH" , "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590" ) ,
474
+ ( "USDC.e" , "0xF1815bd50389c46847f0Bda824eC8da914045D14" ) ,
475
+ ( "WVANA" , "0x00EDdD9621Fb08436d0331c149D1690909a5906d" ) ,
476
+ ]
477
+ . iter ( )
478
+ . map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) )
479
+ . collect ( ) ,
464
480
"local" => [ ( "ZERO" , "0x0000000000000000000000000000000000000000" ) ]
465
481
. iter ( )
466
482
. map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) )
@@ -698,6 +714,10 @@ impl OnChainConfig {
698
714
}
699
715
700
716
pub fn fetch_abi_uncached ( & self , address : EVMAddress ) -> Option < String > {
717
+ if self . chain_name == "vana" {
718
+ return self . fetch_vana_abi_uncached ( address) ;
719
+ }
720
+
701
721
#[ cfg( feature = "no_etherscan" ) ]
702
722
{
703
723
return None ;
@@ -740,6 +760,28 @@ impl OnChainConfig {
740
760
}
741
761
}
742
762
763
+ fn fetch_vana_abi_uncached ( & self , address : EVMAddress ) -> Option < String > {
764
+ let endpoint = format ! ( "{}/smart-contracts/{:?}" , self . etherscan_base, address) ;
765
+
766
+ // info!(">> {}", endpoint);
767
+ match self . get ( endpoint. clone ( ) ) {
768
+ Some ( resp) => match serde_json:: from_str :: < Value > ( & resp) {
769
+ Ok ( json) => {
770
+ // info!("<< {}", json);
771
+ json. get ( "abi" ) . map ( |abi| abi. to_string ( ) )
772
+ }
773
+ Err ( _) => {
774
+ error ! ( "Failed to parse JSON response from Vana API" ) ;
775
+ None
776
+ }
777
+ } ,
778
+ None => {
779
+ error ! ( "Failed to fetch ABI from Vana API: {}" , endpoint) ;
780
+ None
781
+ }
782
+ }
783
+ }
784
+
743
785
pub fn fetch_abi ( & mut self , address : EVMAddress ) -> Option < String > {
744
786
if self . abi_cache . contains_key ( & address) {
745
787
return self . abi_cache . get ( & address) . unwrap ( ) . clone ( ) ;
0 commit comments