From d1f04a4dc577ae9375ebf64a4e7e311a13a5ccfd Mon Sep 17 00:00:00 2001 From: Wodann Date: Thu, 2 Mar 2023 15:07:24 -0800 Subject: [PATCH] feat: add API to retrieve unpadded bytecode --- crates/primitives/src/bytecode.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index 334c5f1cd7..68d8fd8089 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -99,6 +99,15 @@ impl Bytecode { &self.bytecode } + pub fn original_bytes(&self) -> Bytes { + match self.state { + BytecodeState::Raw => self.bytecode.clone(), + BytecodeState::Checked { len } | BytecodeState::Analysed { len, .. } => { + self.bytecode.slice(0..len) + } + } + } + pub fn hash(&self) -> B256 { self.hash }