From 722392b17bf91a7d4e533eb834793d117c677e5e Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 29 Jan 2025 18:20:22 +0100 Subject: [PATCH] fix: range logic, set `end=start` if end not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call data in the extrinsic could be empty, such as https://polkadot.subscan.io/extrinsic/24413043-3 in such a scenario, the range would beĀ  `start..0` which would panic if start is bigger 0. --- src/decoding/extrinsic_decoder.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/decoding/extrinsic_decoder.rs b/src/decoding/extrinsic_decoder.rs index 17cc1b2..56e55a1 100644 --- a/src/decoding/extrinsic_decoder.rs +++ b/src/decoding/extrinsic_decoder.rs @@ -222,7 +222,7 @@ impl<'info, TypeId> Extrinsic<'info, TypeId> { .call_data() .map(|a| a.range.end as usize) .max() - .unwrap_or(0); + .unwrap_or(start); Range { start, end } } @@ -235,7 +235,7 @@ impl<'info, TypeId> Extrinsic<'info, TypeId> { .call_data() .map(|a| a.range.end as usize) .max() - .unwrap_or(0); + .unwrap_or(start); Range { start, end } } @@ -374,7 +374,11 @@ impl<'info, TypeId> ExtrinsicExtensions<'info, TypeId> { .map(|a| a.range.start as usize) .min() .unwrap_or(0); - let end = self.iter().map(|a| a.range.end as usize).max().unwrap_or(0); + let end = self + .iter() + .map(|a| a.range.end as usize) + .max() + .unwrap_or(start); Range { start, end } }