Skip to content

Conversation

@jmg-duarte
Copy link
Contributor

Description

Migrate get_orders_by_tx endpoint to alloy

Changes

  • Migrates the endpoint types to alloy
  • Refactors were applicable

How to test

Existing tests

@jmg-duarte jmg-duarte requested a review from a team as a code owner November 7, 2025 12:56
Copy link
Contributor

@m-sz m-sz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

.await
.unwrap();
assert_eq!(result.0, H256::from_str(hash_str).unwrap().0);
assert_eq!(result.0, B256::from_str(hash_str).unwrap().0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alloy's from_str calls from_hex

Making use of hex::decode_to_array

Creates an instance of type Self from the given hex string, or fails with a custom error type.

Both, upper and lower case characters are valid and can even be mixed (e.g. f9b4ca, F9B4CA and f9B4Ca are all valid strings).

H256 from_str:

/// Creates a hash type instance from the given string.
///
/// # Note
///
/// The given input string is interpreted in big endian.
///
/// # Errors
///
/// - When encountering invalid non hex-digits
/// - Upon empty string input or invalid input length in general
fn from_str(input: &str) -> $crate::core_::result::Result<$name, $crate::rustc_hex::FromHexError> {
	let input = input.strip_prefix("0x").unwrap_or(input);
	let mut iter = $crate::rustc_hex::FromHexIter::new(input);
	let mut result = Self::zero();
	for byte in result.as_mut() {
		*byte = iter.next().ok_or(Self::Err::InvalidHexLength)??;
	}
	if iter.next().is_some() {
		return Err(Self::Err::InvalidHexLength)
	}
	Ok(result)
}

Both methods strip the prefix and seem to work the same.

Base automatically changed from jmgd/alloy/native-price to main November 10, 2025 12:01
@jmg-duarte jmg-duarte added this pull request to the merge queue Nov 10, 2025
Merged via the queue into main with commit 031c49c Nov 10, 2025
16 checks passed
@jmg-duarte jmg-duarte deleted the jmgd/alloy/get_orders_by_tx branch November 10, 2025 12:18
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants