-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6e3bf5
commit 08fa36f
Showing
11 changed files
with
117 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
module-system/module-implementations/sov-evm/src/receipt.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::codec::{StateKeyCodec, StateValueCodec}; | ||
|
||
/// A [`StateCodec`] that uses [`borsh`] for all keys and values. | ||
#[derive(Debug, Default, PartialEq, Eq, Clone, borsh::BorshDeserialize, borsh::BorshSerialize)] | ||
pub struct BorshCodec; | ||
|
||
impl<K> StateKeyCodec<K> for BorshCodec | ||
where | ||
K: borsh::BorshSerialize + borsh::BorshDeserialize, | ||
{ | ||
type KeyError = std::io::Error; | ||
|
||
fn encode_key(&self, key: &K) -> Vec<u8> { | ||
key.try_to_vec().expect("Failed to serialize key") | ||
} | ||
|
||
fn try_decode_key(&self, bytes: &[u8]) -> Result<K, Self::KeyError> { | ||
K::try_from_slice(bytes) | ||
} | ||
} | ||
|
||
impl<V> StateValueCodec<V> for BorshCodec | ||
where | ||
V: borsh::BorshSerialize + borsh::BorshDeserialize, | ||
{ | ||
type ValueError = std::io::Error; | ||
|
||
fn encode_value(&self, value: &V) -> Vec<u8> { | ||
value.try_to_vec().expect("Failed to serialize value") | ||
} | ||
|
||
fn try_decode_value(&self, bytes: &[u8]) -> Result<V, Self::ValueError> { | ||
V::try_from_slice(bytes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::codec::StateValueCodec; | ||
|
||
/// A [`StateCodec`] that uses [`bcs`] for all keys and values. | ||
#[derive(Debug, Default, PartialEq, Eq, Clone)] | ||
pub struct BcsCodec; | ||
|
||
impl<V> StateValueCodec<V> for BcsCodec | ||
where | ||
V: serde::Serialize + for<'a> serde::Deserialize<'a>, | ||
{ | ||
type Error = bcs::Error; | ||
|
||
fn encode_value(&self, value: &V) -> Vec<u8> { | ||
bcs::to_bytes(value).expect("Failed to serialize key") | ||
} | ||
|
||
fn try_decode_value(&self, bytes: &[u8]) -> Result<V, Self::Error> { | ||
bcs::from_bytes(bytes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::codec::StateValueCodec; | ||
|
||
/// A [`StateValueCodec`] that uses [`borsh`] for all values. | ||
#[derive(Debug, Default, PartialEq, Eq, Clone, borsh::BorshDeserialize, borsh::BorshSerialize)] | ||
pub struct BorshCodec; | ||
|
||
impl<V> StateValueCodec<V> for BorshCodec | ||
where | ||
V: borsh::BorshSerialize + borsh::BorshDeserialize, | ||
{ | ||
type Error = std::io::Error; | ||
|
||
fn encode_value(&self, value: &V) -> Vec<u8> { | ||
value.try_to_vec().expect("Failed to serialize value") | ||
} | ||
|
||
fn try_decode_value(&self, bytes: &[u8]) -> Result<V, Self::Error> { | ||
V::try_from_slice(bytes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters