Skip to content

Commit d970cd0

Browse files
feat: add missing lambda storage slot
Signed-off-by: Ivaylo Nikolov <[email protected]>
1 parent 3be327d commit d970cd0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/hooks/lambda_storage_slot.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use hedera_proto::services;
2+
3+
use crate::{
4+
FromProtobuf,
5+
ToProtobuf,
6+
};
7+
8+
/// A slot in the storage of a lambda EVM hook.
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
pub struct LambdaStorageSlot {
11+
/// The key of the slot.
12+
pub key: Vec<u8>,
13+
14+
/// The value of the slot.
15+
pub value: Vec<u8>,
16+
}
17+
18+
impl LambdaStorageSlot {
19+
/// Create a new `LambdaStorageSlot`.
20+
pub fn new(key: Vec<u8>, value: Vec<u8>) -> Self {
21+
Self { key, value }
22+
}
23+
24+
/// Get the key.
25+
pub fn get_key(&self) -> &[u8] {
26+
&self.key
27+
}
28+
29+
/// Get the value.
30+
pub fn get_value(&self) -> &[u8] {
31+
&self.value
32+
}
33+
34+
/// Set the value.
35+
pub fn set_value(&mut self, value: Vec<u8>) {
36+
self.value = value;
37+
}
38+
39+
/// Set the key.
40+
pub fn set_key(&mut self, key: Vec<u8>) {
41+
self.key = key;
42+
}
43+
}
44+
45+
impl ToProtobuf for LambdaStorageSlot {
46+
type Protobuf = services::LambdaStorageSlot;
47+
48+
fn to_protobuf(&self) -> Self::Protobuf {
49+
services::LambdaStorageSlot { key: self.key.clone(), value: self.value.clone() }
50+
}
51+
}
52+
53+
impl FromProtobuf<services::LambdaStorageSlot> for LambdaStorageSlot {
54+
fn from_protobuf(pb: services::LambdaStorageSlot) -> crate::Result<Self> {
55+
Ok(Self { key: pb.key, value: pb.value })
56+
}
57+
}

0 commit comments

Comments
 (0)