Skip to content

Commit

Permalink
Make thiserror an optional dependency
Browse files Browse the repository at this point in the history
The `thiserror` crate has been made an optional dependency in order to support both `std` and `no_std` environments. This change is reflected in the `Cargo.toml` and related Rust files. The SDK version has been updated as a result.
  • Loading branch information
shuhuiluo committed Jul 9, 2024
1 parent 1962b6f commit 96d8b3c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniswap-sdk-core"
version = "0.25.0"
version = "0.26.0"
edition = "2021"
authors = ["malik <[email protected]>", "Shuhui Luo <twitter.com/aureliano_law>"]
description = "The Uniswap SDK Core in Rust provides essential functionality for interacting with the Uniswap decentralized exchange"
Expand All @@ -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]
Expand Down
21 changes: 10 additions & 11 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -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(),
}

Expand Down
1 change: 0 additions & 1 deletion src/examples/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
///token example
pub mod token_example;
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 96d8b3c

Please sign in to comment.