Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dependencies and refactor error handling #7

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ edition = "2021"
[dependencies]
alloy-primitives = "0.8"
alloy-sol-types = "0.8"
derive_more = "1.0.0"
#derive_more = "1.0.0"
shuhuiluo marked this conversation as resolved.
Show resolved Hide resolved
rustc-hash = "2.0.0"
thiserror = { version = "1.0", optional = true }
uniswap-sdk-core = "3.0.0"
uniswap-v3-sdk = "2.4.0"
thiserror = { version = "2", default-features = false }
uniswap-sdk-core = "3.1.0"
uniswap-v3-sdk = "2.5.0"

[dev-dependencies]
once_cell = "1.20.2"

[features]
default = []
std = ["thiserror", "uniswap-sdk-core/std", "uniswap-v3-sdk/std"]
std = ["thiserror/std", "uniswap-sdk-core/std", "uniswap-v3-sdk/std"]
26 changes: 13 additions & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
#![allow(clippy::missing_inline_in_public_items)]

#[cfg(doc)]
use crate::prelude::*;

use alloy_sol_types::Error as SolError;
use derive_more::From;
use uniswap_sdk_core::error::Error as CoreError;
use uniswap_v3_sdk::error::Error as V3Error;

#[derive(Debug, From)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Thrown when an error occurs in the core library.
#[cfg_attr(feature = "std", error("{0}"))]
Core(#[cfg_attr(not(feature = "std"), from)] CoreError),
#[error("{0}")]
Core(#[from] CoreError),

/// Thrown when an error occurs in the v3 library.
#[cfg_attr(feature = "std", error("{0}"))]
V3(#[cfg_attr(not(feature = "std"), from)] V3Error),
#[error("{0}")]
V3(#[from] V3Error),

/// Thrown when an error occurs in the sol types library.
#[cfg_attr(feature = "std", error("{0}"))]
Sol(#[cfg_attr(not(feature = "std"), from)] SolError),
#[error("{0}")]
Sol(#[from] SolError),

/// Thrown when the action is not supported.
#[cfg_attr(feature = "std", error("Unsupported action {0}"))]
#[error("Unsupported action {0}")]
InvalidAction(u8),

/// Thrown when the currency passed to [`get_path_currency`] is not one of the pool's
/// currencies.
#[cfg_attr(feature = "std", error("Invalid currency"))]
#[error("Invalid currency")]
InvalidCurrency,

/// Thrown when trying to simulate a swap with an unsupported hook.
#[cfg_attr(feature = "std", error("Unsupported hook"))]
#[error("Unsupported hook")]
UnsupportedHook,

#[cfg_attr(feature = "std", error("Insufficient liquidity"))]
#[error("Insufficient liquidity")]
InsufficientLiquidity,
shuhuiluo marked this conversation as resolved.
Show resolved Hide resolved
}