diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a3a60add1..ed8c7f4b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/crates/primitives/src/sol/bytes.rs b/crates/primitives/src/sol/bytes.rs index 3aedb3d4fa..25ef62f4b5 100644 --- a/crates/primitives/src/sol/bytes.rs +++ b/crates/primitives/src/sol/bytes.rs @@ -187,6 +187,18 @@ impl From for FixedBytes<1> { } } +impl From> for [u8; N] { + fn from(value: FixedBytes) -> Self { + value.0 + } +} + +impl From> for u8 { + fn from(value: FixedBytes<1>) -> Self { + value.0[0] + } +} + impl Deref for FixedBytes { type Target = [u8; N]; @@ -323,6 +335,12 @@ impl From> for DynBytes { } } +impl From for Vec { + fn from(value: DynBytes) -> Self { + value.0 + } +} + impl Deref for DynBytes { type Target = [u8]; @@ -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 { @@ -419,6 +437,12 @@ impl<'a> From<&'a [u8]> for ByteSlice<'a> { } } +impl<'a> From> for &'a [u8] { + fn from(value: ByteSlice<'a>) -> Self { + value.0 + } +} + impl Deref for ByteSlice<'_> { type Target = [u8];