Skip to content

Commit

Permalink
feat(precompile-utils): implement helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed May 22, 2024
1 parent 91f1c7a commit 8979a49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions precompiles/src/solidity/codec/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ impl<K1, S1, K2, S2> PartialEq<BoundedBytesString<K2, S2>> for BoundedBytesStrin

impl<K, S> Eq for BoundedBytesString<K, S> {}

impl<K, S> Default for BoundedBytesString<K, S> {
fn default() -> Self {
Vec::default().into()
}
}

impl<K, S: Get<u32>> BoundedBytesString<K, S> {
pub fn as_bytes(&self) -> &[u8] {
&self.data
Expand Down
15 changes: 15 additions & 0 deletions precompiles/src/solidity/codec/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,18 @@ impl<T, S> From<BoundedVec<T, S>> for Vec<T> {
value.inner
}
}

impl<T, S> Default for BoundedVec<T, S> {
fn default() -> Self {
Self {
inner: Default::default(),
_phantom: PhantomData,
}
}
}

impl<T, S> BoundedVec<T, S> {
pub fn len(&self) -> usize {
self.inner.len()
}
}

0 comments on commit 8979a49

Please sign in to comment.