This is within my smart contract's module:

        // THIS IS BEING USED: use ink::prelude::vec::Vec;
        pub fn test_encoding(&mut self) -> Result<u32, ZeitDAOError> {
            let mut x: Vec<u8> = scale::Encode::encode(&RuntimeCall::TestCall);

            // There is an error here
            match <u32 as scale::Decode>::decode(&mut x) {
                Ok(value) => Ok(value),
                Err(_) => Err(ZeitDAOError::ErrorDecodingProposalData)

There is a compiler error when passing in &mut x to the decode function:

the trait bound `Vec<u8>: Input` is not satisfied
the following other types implement trait `Input`:
  AppendZerosInput<'a, T>
  &'a [u8]

I assume this is because the ink Vec is not the typical library's Vec? I'm unsure how otherwise to use the decoding method, or if there is a method at all. Or do I misunderstand how Decode::decode works?

Thank you!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.