MCPcopy Create free account
hub / github.com/base/base / hex

Method hex

acceptance/src/check.rs:778–786  ·  view source on GitHub ↗

Parses a canonical JSON-RPC hexadecimal quantity.

(value: Option<&Value>)

Source from the content-addressed store, hash-verified

776
777 /// Parses a canonical JSON-RPC hexadecimal quantity.
778 pub fn hex(value: Option<&Value>) -> Result<u64> {
779 let text = value.and_then(Value::as_str).ok_or_else(|| eyre!("hex quantity missing"))?;
780 let digits =
781 text.strip_prefix("0x").ok_or_else(|| eyre!("hex quantity lacks 0x prefix"))?;
782 if digits.is_empty() || (digits.len() > 1 && digits.starts_with('0')) {
783 bail!("non-canonical hex quantity");
784 }
785 u64::from_str_radix(digits, 16).map_err(|_| eyre!("invalid hex quantity"))
786 }
787
788 /// Validates and returns a lowercase-or-uppercase 32-byte hash.
789 pub fn hash(value: Option<&Value>) -> Result<String> {

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected