Skip to content
Closed
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
14 changes: 5 additions & 9 deletions crates/shepherd-sdk/src/cow/app_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,12 @@ pub fn resolve_app_data<H: CowApiHost + ?Sized>(
})
}

/// 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:
Expand Down
13 changes: 4 additions & 9 deletions modules/twap-monitor/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down