diff --git a/Cargo.toml b/Cargo.toml index 0e9d26a..afb28ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uniswap-sdk-core" -version = "0.25.0" +version = "0.26.0" edition = "2021" authors = ["malik ", "Shuhui Luo "] description = "The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap decentralized exchange" @@ -16,9 +16,10 @@ num-integer = "0.1" num-traits = "0.2" regex = { version = "1.10", optional = true } rustc-hash = "2.0" -thiserror = "1.0" +thiserror = { version = "1.0", optional = true } [features] +std = ["thiserror"] validate_parse_address = ["eth_checksum", "regex"] [lib] diff --git a/src/error.rs b/src/error.rs index ab778d2..bf5d565 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,26 +1,25 @@ -use crate::prelude::*; - /// Represents errors that can occur in the context of currency operations. -#[derive(Debug, Error, Clone, Copy)] +#[derive(Debug, Clone, Copy)] +#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum Error { - /// Triggers when compared Chain Ids do not match - #[error("Chain IDs do not match: {0} and {1}")] + /// Triggers when the compared chain ids do not match + #[cfg_attr(feature = "std", error("Chain IDs do not match: {0} and {1}"))] ChainIdMismatch(u64, u64), - /// Triggers when comapred addresses are the smae - #[error("Addresses are equal")] + /// Triggers when compared addresses are the same + #[cfg_attr(feature = "std", error("Addresses are equal"))] EqualAddresses, /// Triggers when it tries to exceed the max uint - #[error("amount has exceeded MAX_UINT256")] + #[cfg_attr(feature = "std", error("amount has exceeded MAX_UINT256"))] MaxUint, ///Triggers when the Compared values are not equal - #[error("not equal")] + #[cfg_attr(feature = "std", error("not equal"))] NotEqual(), - /// Triggers when The value is inccorrrect - #[error("incorrect")] + /// Triggers when The value is incorrect + #[cfg_attr(feature = "std", error("incorrect"))] Incorrect(), } diff --git a/src/examples/mod.rs b/src/examples/mod.rs index 9e7b267..4b3de48 100644 --- a/src/examples/mod.rs +++ b/src/examples/mod.rs @@ -1,2 +1 @@ -///token example pub mod token_example; diff --git a/src/lib.rs b/src/lib.rs index 4f92ea5..4dab2b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,8 @@ //! //! The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap //! decentralized exchange. -//! #![cfg_attr(not(test), no_std)] +//! +#![cfg_attr(not(any(feature = "std", test)), no_std)] #![warn( missing_copy_implementations, missing_debug_implementations, diff --git a/src/prelude.rs b/src/prelude.rs index fe807f3..870bd49 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -31,4 +31,3 @@ pub use num_bigint::{BigInt, BigUint, ToBigInt, ToBigUint}; pub use num_integer::Integer; pub use num_traits::{Num, ToPrimitive, Zero}; pub use rustc_hash::FxHashMap; -pub use thiserror::Error;