@@ -21,7 +21,7 @@ pub struct Data {
2121 pub thumbnail : Option < Thumbnail > ,
2222}
2323
24- pub async fn fetch_uri ( uri : String ) -> Result < Data , UriError > {
24+ pub async fn fetch_uri ( uri : String , testnet : bool ) -> Result < Data , UriError > {
2525 let response = reqwest:: get ( & uri) . await ?;
2626
2727 let mime_type = match response. headers ( ) . get ( CONTENT_TYPE ) {
@@ -49,7 +49,7 @@ pub async fn fetch_uri(uri: String) -> Result<Data, UriError> {
4949 hasher. update ( & blob) ;
5050 let hash = Bytes32 :: new ( hasher. finalize ( ) ) ;
5151
52- let mut thumbnail = match mintgarden_thumbnail ( hash) . await {
52+ let mut thumbnail = match mintgarden_thumbnail ( hash, testnet ) . await {
5353 Ok ( thumbnail) => thumbnail,
5454 Err ( error) => {
5555 debug ! ( "Failed to fetch MintGarden thumbnail for {uri}: {error}" ) ;
@@ -91,11 +91,11 @@ pub async fn fetch_uri(uri: String) -> Result<Data, UriError> {
9191 } )
9292}
9393
94- pub async fn fetch_uris_without_hash ( uris : Vec < String > ) -> Result < Data , UriError > {
94+ pub async fn fetch_uris_without_hash ( uris : Vec < String > , testnet : bool ) -> Result < Data , UriError > {
9595 let mut futures = FuturesUnordered :: new ( ) ;
9696
9797 for uri in uris {
98- futures. push ( fetch_uri ( uri) ) ;
98+ futures. push ( fetch_uri ( uri, testnet ) ) ;
9999 }
100100
101101 let mut data = None ;
@@ -128,11 +128,11 @@ pub async fn fetch_uris_without_hash(uris: Vec<String>) -> Result<Data, UriError
128128 data. ok_or ( UriError :: NoUris )
129129}
130130
131- pub async fn fetch_uris_with_hash ( uris : Vec < String > , hash : Bytes32 ) -> Option < Data > {
131+ pub async fn fetch_uris_with_hash ( uris : Vec < String > , hash : Bytes32 , testnet : bool ) -> Option < Data > {
132132 let mut futures = FuturesUnordered :: new ( ) ;
133133
134134 for uri in uris {
135- futures. push ( async move { ( uri. clone ( ) , fetch_uri ( uri) . await ) } ) ;
135+ futures. push ( async move { ( uri. clone ( ) , fetch_uri ( uri, testnet ) . await ) } ) ;
136136 }
137137
138138 while let Some ( ( uri, result) ) = futures. next ( ) . await {
@@ -151,8 +151,14 @@ pub async fn fetch_uris_with_hash(uris: Vec<String>, hash: Bytes32) -> Option<Da
151151 None
152152}
153153
154- pub async fn mintgarden_thumbnail ( data_hash : Bytes32 ) -> Result < Option < Thumbnail > , UriError > {
155- let url = format ! ( "https://assets.mainnet.mintgarden.io/thumbnails/{data_hash}_512.webp" ) ;
154+ pub async fn mintgarden_thumbnail (
155+ data_hash : Bytes32 ,
156+ testnet : bool ,
157+ ) -> Result < Option < Thumbnail > , UriError > {
158+ let url = format ! (
159+ "https://assets.{}.mintgarden.io/thumbnails/{data_hash}_512.webp" ,
160+ if testnet { "testnet" } else { "mainnet" }
161+ ) ;
156162
157163 let response = reqwest:: get ( & url) . await ?;
158164
0 commit comments