Skip to content

Commit

Permalink
(deps) removed useless thiserror dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-valerio committed Nov 11, 2024
1 parent fa4d4cd commit 8c91a87
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ ink_env = { version = "5.0.0" }
contract-transcode = { version = "4.1.1" }
contract-metadata = { version = "4.1.1" }
colored = { version = "2.1.0" }
thiserror = { version = "1.0.63" }
time = { version = "0.3.36" }

[lints.rust]
Expand Down
18 changes: 4 additions & 14 deletions src/contract/selectors/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ use std::{
},
str::FromStr,
};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum SelectorError {
#[error("Invalid hex string")]
InvalidHex(#[from] hex::FromHexError),

#[error("Invalid length for a 4-byte array")]
InvalidLength,
}

#[derive(PartialEq, Clone, Debug, Copy)]
pub struct Selector(pub [u8; 4]);
Expand Down Expand Up @@ -68,7 +58,7 @@ impl From<Selector> for Vec<u8> {
}

impl TryFrom<&str> for Selector {
type Error = SelectorError;
type Error = anyhow::Error;

fn try_from(value: &str) -> Result<Self, Self::Error> {
let value = value.trim_start_matches("0x"); // Remove "0x" if present
Expand All @@ -78,11 +68,11 @@ impl TryFrom<&str> for Selector {
}

impl TryFrom<&[u8]> for Selector {
type Error = SelectorError;
type Error = anyhow::Error;

fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
if value.len() != 4 {
return Err(SelectorError::InvalidLength);
return Err(anyhow::anyhow!("Invalid lenght for selector"));
}
let mut array = [0u8; 4];
array.copy_from_slice(value);
Expand All @@ -91,7 +81,7 @@ impl TryFrom<&[u8]> for Selector {
}

impl TryFrom<Vec<u8>> for Selector {
type Error = SelectorError;
type Error = anyhow::Error;

fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
value.as_slice().try_into()
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/corpus/.tmpKJxozO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
just a random seed
Binary file not shown.

0 comments on commit 8c91a87

Please sign in to comment.