Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Feb 23, 2024
1 parent 1e8bf18 commit 9c2173e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions shared/src/models/lookup/contenthash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use ethers_core::{
types::H256,
};
use hex_literal::hex;
use tracing::info;

use super::ENSLookupError;

Expand All @@ -25,9 +24,22 @@ pub async fn decode(data: &[u8]) -> Result<String, ENSLookupError> {
return Err(ENSLookupError::AbiDecodeError);
};

let contenthash = hex::encode(contenthash);
let proto_code = contenthash[0];
let value = &contenthash[1..];

Ok(contenthash)
match proto_code {
0xe3 => {
// ipfs
Ok(format!("ipfs://{value:?}"))
},
0xe4 => {
// swarm
Err(ENSLookupError::Unsupported("Swarm contenthash is not supported".to_string()))
},
_ => {
Err(ENSLookupError::Unsupported("Contenthash of this protoCode is not supported".to_string()))
}
}
}

#[cfg(test)]
Expand Down

0 comments on commit 9c2173e

Please sign in to comment.