11use {
2+ alloy:: primitives:: Address ,
23 anyhow:: Result ,
3- ethcontract:: H160 ,
44 prometheus:: IntCounterVec ,
55 reqwest:: { Client , Url } ,
66 serde:: Deserialize ,
@@ -18,12 +18,12 @@ pub struct TokenListConfiguration {
1818 pub chain_id : u64 ,
1919 pub client : Client ,
2020 pub update_interval : Duration ,
21- pub hardcoded : Vec < H160 > ,
21+ pub hardcoded : Vec < Address > ,
2222}
2323
2424impl TokenListConfiguration {
2525 #[ instrument( skip_all) ]
26- async fn get_external_list ( & self ) -> Result < HashSet < H160 > > {
26+ async fn get_external_list ( & self ) -> Result < HashSet < Address > > {
2727 let model: TokenListModel = if let Some ( url) = & self . url {
2828 self . client . get ( url. clone ( ) ) . send ( ) . await ?. json ( ) . await ?
2929 } else {
@@ -32,7 +32,7 @@ impl TokenListConfiguration {
3232 Ok ( self . get_list ( model. tokens ) )
3333 }
3434
35- fn get_list ( & self , tokens : Vec < TokenModel > ) -> HashSet < H160 > {
35+ fn get_list ( & self , tokens : Vec < TokenModel > ) -> HashSet < Address > {
3636 tokens
3737 . into_iter ( )
3838 . filter ( |token| token. chain_id == self . chain_id )
@@ -43,7 +43,7 @@ impl TokenListConfiguration {
4343}
4444#[ derive( Clone , Debug , Default ) ]
4545pub struct AutoUpdatingTokenList {
46- tokens : Arc < RwLock < HashSet < H160 > > > ,
46+ tokens : Arc < RwLock < HashSet < Address > > > ,
4747}
4848
4949impl AutoUpdatingTokenList {
@@ -91,17 +91,17 @@ impl AutoUpdatingTokenList {
9191 Self { tokens }
9292 }
9393
94- pub fn new ( tokens : HashSet < H160 > ) -> Self {
94+ pub fn new ( tokens : HashSet < Address > ) -> Self {
9595 Self {
9696 tokens : Arc :: new ( RwLock :: new ( tokens) ) ,
9797 }
9898 }
9999
100- pub fn contains ( & self , address : & H160 ) -> bool {
100+ pub fn contains ( & self , address : & Address ) -> bool {
101101 self . tokens . read ( ) . unwrap ( ) . contains ( address)
102102 }
103103
104- pub fn all ( & self ) -> HashSet < H160 > {
104+ pub fn all ( & self ) -> HashSet < Address > {
105105 self . tokens . read ( ) . unwrap ( ) . clone ( )
106106 }
107107}
@@ -118,7 +118,7 @@ struct TokenListModel {
118118#[ serde( rename_all = "camelCase" ) ]
119119struct TokenModel {
120120 chain_id : u64 ,
121- address : H160 ,
121+ address : Address ,
122122}
123123
124124#[ derive( prometheus_metric_storage:: MetricStorage , Clone , Debug ) ]
@@ -130,7 +130,7 @@ struct Metrics {
130130
131131#[ cfg( test) ]
132132pub mod tests {
133- use { super :: * , ethrpc :: alloy:: conversions :: IntoLegacy } ;
133+ use { super :: * , alloy:: primitives :: address } ;
134134
135135 // https://github.com/Uniswap/token-lists/blob/master/test/schema/example.tokenlist.json
136136 const EXAMPLE_LIST : & str = r#"
@@ -194,11 +194,11 @@ pub mod tests {
194194 tokens: vec![
195195 TokenModel {
196196 chain_id: 1 ,
197- address: testlib:: tokens:: USDC . into_legacy ( ) ,
197+ address: testlib:: tokens:: USDC ,
198198 } ,
199199 TokenModel {
200200 chain_id: 4 ,
201- address: addr !( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ,
201+ address: address !( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ,
202202 }
203203 ]
204204 }
@@ -217,9 +217,9 @@ pub mod tests {
217217 } ;
218218 let tokens = config. get_list ( list. tokens ) ;
219219 let instance = AutoUpdatingTokenList :: new ( tokens) ;
220- assert ! ( instance. contains( & testlib:: tokens:: USDC . into_legacy ( ) ) ) ;
220+ assert ! ( instance. contains( & testlib:: tokens:: USDC ) ) ;
221221 // Chain ID 4
222- assert ! ( !instance. contains( & addr !( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ) , ) ;
222+ assert ! ( !instance. contains( & address !( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ) ) ;
223223 }
224224
225225 #[ ignore]
@@ -234,13 +234,13 @@ pub mod tests {
234234 hardcoded : Default :: default ( ) ,
235235 } ;
236236 let tokens = config. get_external_list ( ) . await . unwrap ( ) ;
237- assert ! ( tokens. contains( & testlib:: tokens:: USDC . into_legacy ( ) ) ) ;
238- let gc_token = addr ! ( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ;
237+ assert ! ( tokens. contains( & testlib:: tokens:: USDC ) ) ;
238+ let gc_token = address ! ( "39AA39c021dfbaE8faC545936693aC917d5E7563" ) ;
239239 assert ! ( !tokens. contains( & gc_token) ) ;
240240
241241 config. chain_id = 4 ;
242242 let tokens = config. get_list ( list. tokens ) ;
243- assert ! ( !tokens. contains( & testlib:: tokens:: USDC . into_legacy ( ) ) ) ;
243+ assert ! ( !tokens. contains( & testlib:: tokens:: USDC ) ) ;
244244 assert ! ( tokens. contains( & gc_token) ) ;
245245 }
246246}
0 commit comments