Contracts: Translate .wat fixtures to rust (#2654)

- Translate all pallet-contracts fixtures from `wat` to Rust files.
- Fix read_sandbox_memory_as to not use MaxEncodedLen as this could
break if used with types with a non-fixed encoded len.

---------

Co-authored-by: alvicsam <alvicsam@gmail.com>
Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: command-bot <>
This commit is contained in:
authored and GitHub committed 2024-01-12 20:10:54 +00:00
1 parent c421b87978
commit bd80dcf685
101 files changed
+2352 -2602

No files matched your search

@@ -583,9 +583,8 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
ptr: u32,
) -> Result<D, DispatchError> {
let ptr = ptr as usize;
let mut bound_checked = memory
.get(ptr..ptr + D::max_encoded_len() as usize)
.ok_or_else(|| Error::<E::T>::OutOfBounds)?;
let mut bound_checked = memory.get(ptr..).ok_or_else(|| Error::<E::T>::OutOfBounds)?;
let decoded = D::decode_with_depth_limit(MAX_DECODE_NESTING, &mut bound_checked)
.map_err(|_| DispatchError::from(Error::<E::T>::DecodingFailed))?;
Ok(decoded)