Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` ‒ [2675](https://github.com/use-ink/ink/pull/2675)
- Refactor `AbiEncodeWith::encode_to_slice` - [#2676](https://github.com/use-ink/ink/pull/2676)
- Refactor `ArgumentList` encoding and abstractions - [#2678](https://github.com/use-ink/ink/pull/2678)
- More flexible `SolEncode` implementation for `ByteSlice` - [#2681](https://github.com/use-ink/ink/pull/2681)

### Fixed
- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656)
Expand Down
26 changes: 25 additions & 1 deletion crates/primitives/src/sol/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ impl From<u8> for FixedBytes<1> {
}
}

impl<const N: usize> From<FixedBytes<N>> for [u8; N] {
fn from(value: FixedBytes<N>) -> Self {
value.0
}
}

impl From<FixedBytes<1>> for u8 {
fn from(value: FixedBytes<1>) -> Self {
value.0[0]
}
}

impl<const N: usize> Deref for FixedBytes<N> {
type Target = [u8; N];

Expand Down Expand Up @@ -323,6 +335,12 @@ impl From<Box<[u8]>> for DynBytes {
}
}

impl From<DynBytes> for Vec<u8> {
fn from(value: DynBytes) -> Self {
value.0
}
}

impl Deref for DynBytes {
type Target = [u8];

Expand Down Expand Up @@ -404,7 +422,7 @@ impl SolTokenType for ByteSlice<'_> {
impl crate::sol::types::private::Sealed for ByteSlice<'_> {}

// Implements `SolEncode` for `ByteSlice`.
impl<'a> SolEncode<'a> for ByteSlice<'a> {
impl<'a> SolEncode<'a> for ByteSlice<'_> {
type SolType = &'a ByteSlice<'a>;

fn to_sol_type(&'a self) -> Self::SolType {
Expand All @@ -419,6 +437,12 @@ impl<'a> From<&'a [u8]> for ByteSlice<'a> {
}
}

impl<'a> From<ByteSlice<'a>> for &'a [u8] {
fn from(value: ByteSlice<'a>) -> Self {
value.0
}
}

impl Deref for ByteSlice<'_> {
type Target = [u8];

Expand Down
Loading