From ca60e4ca081050f1c234dea1535cb6f8abfdae8e Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Tue, 17 May 2022 11:58:00 -0400 Subject: [PATCH] Accept truncated subgraph IDs --- src/prelude/bytes.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/prelude/bytes.rs b/src/prelude/bytes.rs index ffec1a78..d8703092 100644 --- a/src/prelude/bytes.rs +++ b/src/prelude/bytes.rs @@ -84,9 +84,10 @@ impl FromStr for SubgraphID { // Attempt to decode v2 format: base58 of sha256 hash let mut hash = [0u8; 32]; let len = bs58::decode(s).into(&mut hash).ok()?; - if len != hash.len() { + if len > hash.len() { return None; } + hash.rotate_right(32 - len); Some(hash) } if let Some(v2) = parse_v2(s) {