Skip to content

Commit

Permalink
remove thiserror from solana-derivation-path (#3086)
Browse files Browse the repository at this point in the history
* remove thiserror from solana-derivation-path

* fix excessively qualified path
  • Loading branch information
kevinheavey authored Oct 11, 2024
1 parent 8e83183 commit df22c2e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sdk/derivation-path/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = { workspace = true }
[dependencies]
derivation-path = { workspace = true }
qstring = { workspace = true }
thiserror = { workspace = true }
uriparse = { workspace = true }

[dev-dependencies]
Expand Down
29 changes: 23 additions & 6 deletions sdk/derivation-path/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,32 @@ use {
fmt,
str::FromStr,
},
thiserror::Error,
uriparse::URIReference,
};

const ACCOUNT_INDEX: usize = 2;
const CHANGE_INDEX: usize = 3;

/// Derivation path error.
#[derive(Error, Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DerivationPathError {
#[error("invalid derivation path: {0}")]
InvalidDerivationPath(String),
#[error("infallible")]
Infallible,
}

impl std::error::Error for DerivationPathError {}

impl fmt::Display for DerivationPathError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DerivationPathError::InvalidDerivationPath(p) => {
write!(f, "invalid derivation path: {p}",)
}
DerivationPathError::Infallible => f.write_str("infallible"),
}
}
}

impl From<Infallible> for DerivationPathError {
fn from(_: Infallible) -> Self {
Self::Infallible
Expand Down Expand Up @@ -211,10 +221,17 @@ impl<'a> IntoIterator for &'a DerivationPath {
const QUERY_KEY_FULL_PATH: &str = "full-path";
const QUERY_KEY_KEY: &str = "key";

#[derive(Clone, Debug, Error, PartialEq, Eq)]
#[error("invalid query key `{0}`")]
#[derive(Clone, Debug, PartialEq, Eq)]
struct QueryKeyError(String);

impl std::error::Error for QueryKeyError {}

impl fmt::Display for QueryKeyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "invalid query key `{}`", self.0)
}
}

enum QueryKey {
FullPath,
Key,
Expand Down

0 comments on commit df22c2e

Please sign in to comment.