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: starknet API add lints #1853

Merged
merged 1 commit into from
Nov 8, 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
3 changes: 3 additions & 0 deletions crates/starknet_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ rstest.workspace = true

[package.metadata.cargo-machete]
ignored = ["strum"]

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/starknet_api/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl Nonce {
}
}

/// The selector of an [EntryPoint](`crate::deprecated_contract_class::EntryPoint`).
/// The selector of an [EntryPoint](`crate::state::EntryPoint`).
#[derive(
Debug, Copy, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord,
)]
Expand Down
10 changes: 5 additions & 5 deletions crates/starknet_api/src/deprecated_contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub struct TypedParameter {
pub r#type: String,
}

/// The offset of an [EntryPoint](`crate::deprecated_contract_class::EntryPoint`).
/// The offset of an [EntryPoint](`crate::state::EntryPoint`).
#[derive(
Debug, Copy, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord,
)]
Expand All @@ -212,10 +212,10 @@ impl TryFrom<String> for EntryPointOffset {

pub fn number_or_string<'de, D: Deserializer<'de>>(deserializer: D) -> Result<usize, D::Error> {
let usize_value = match Value::deserialize(deserializer)? {
Value::Number(number) => {
number.as_u64().ok_or(DeserializationError::custom("Cannot cast number to usize."))?
as usize
}
Value::Number(number) => number
.as_u64()
.and_then(|num_u64| usize::try_from(num_u64).ok())
.ok_or(DeserializationError::custom("Cannot cast number to usize."))?,
Value::String(s) => hex_string_try_into_usize(&s).map_err(DeserializationError::custom)?,
_ => return Err(DeserializationError::custom("Cannot cast value into usize.")),
};
Expand Down
Loading