diff --git a/crates/shepherd-sdk/src/cow/app_data.rs b/crates/shepherd-sdk/src/cow/app_data.rs index 29aed1c4..1406d9d7 100644 --- a/crates/shepherd-sdk/src/cow/app_data.rs +++ b/crates/shepherd-sdk/src/cow/app_data.rs @@ -80,16 +80,12 @@ pub fn resolve_app_data( }) } +/// Lowercase `0x`-prefixed hex of a 32-byte appData hash. Delegates +/// to [`alloy_primitives::hex::encode`] (alloy is already a direct +/// dependency of this crate) per mfw78's PR #8 guidance against +/// carrying our own hex formatters. fn encode_hex(bytes: &[u8; 32]) -> String { - const HEX: &[u8; 16] = b"0123456789abcdef"; - let mut out = String::with_capacity(2 + 64); - out.push('0'); - out.push('x'); - for b in bytes { - out.push(HEX[(b >> 4) as usize] as char); - out.push(HEX[(b & 0xf) as usize] as char); - } - out + format!("0x{}", alloy_primitives::hex::encode(bytes)) } /// Parse the orderbook's `/api/v1/app_data/{hash}` response shape: diff --git a/modules/twap-monitor/src/strategy.rs b/modules/twap-monitor/src/strategy.rs index dacd393b..77b030b5 100644 --- a/modules/twap-monitor/src/strategy.rs +++ b/modules/twap-monitor/src/strategy.rs @@ -233,16 +233,11 @@ fn outcome_label(o: &PollOutcome) -> &'static str { /// Render the first 8 bytes of an `appData` hash as `0x12345678…` /// for log lines. Full 32-byte hex is too noisy for an INFO log; /// 8 bytes is unique enough to grep against the orderbook. +/// +/// Delegates to [`alloy_primitives::hex::encode`] per mfw78's PR #8 +/// guidance against carrying our own hex formatters. fn hex_short(bytes: &[u8; 32]) -> String { - const HEX: &[u8; 16] = b"0123456789abcdef"; - let mut out = String::with_capacity(2 + 16 + 1); - out.push_str("0x"); - for b in &bytes[..8] { - out.push(HEX[(b >> 4) as usize] as char); - out.push(HEX[(b & 0xf) as usize] as char); - } - out.push('…'); - out + format!("0x{}…", alloy_primitives::hex::encode(&bytes[..8])) } fn watch_key(owner: &Address, params_hash: &B256) -> String {