From c0857a3a4ec46b03a8daf178baf2102f303981db Mon Sep 17 00:00:00 2001 From: timi-y Date: Fri, 13 Dec 2024 18:05:59 +0800 Subject: [PATCH] feat: add transient storage methods for the execute context Signed-off-by: timi-y --- bindings/rust/evmc-vm/src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bindings/rust/evmc-vm/src/lib.rs b/bindings/rust/evmc-vm/src/lib.rs index c2d94b7a9..b48386e9f 100644 --- a/bindings/rust/evmc-vm/src/lib.rs +++ b/bindings/rust/evmc-vm/src/lib.rs @@ -419,6 +419,31 @@ impl<'a> ExecutionContext<'a> { ) } } + + /// Read from a transient storage key. + pub fn get_transient_storage(&self, address: &Address, key: &Bytes32) -> Bytes32 { + unsafe { + assert!((*self.host).get_transient_storage.is_some()); + (*self.host).get_transient_storage.unwrap()( + self.context, + address as *const Address, + key as *const Bytes32, + ) + } + } + + /// Set value of a transient storage key. + pub fn set_transient_storage(&mut self, address: &Address, key: &Bytes32, value: &Bytes32) { + unsafe { + assert!((*self.host).set_transient_storage.is_some()); + (*self.host).set_transient_storage.unwrap()( + self.context, + address as *const Address, + key as *const Bytes32, + value as *const Bytes32, + ) + } + } } impl From for ExecutionResult {