I’ve read in the docs somewhere that with the new v1 encoding, there’s an option of implementing custom encoding for structs. If none is available, the default is used. I’m getting the error: Trait “AbiDecode” is not implemented for type “CustomStruct”. where CustomStruct is a two-field struct. Unsure why the compiler is failing to decode this passed around functions, but how can I implement AbiDecode for this struct?
Hi @Nazeeh21 unfortunately, the solution above is for the Rust SDK. The error in question I’ve raised above pertains to the Sway compiler being unable to compile the code itself with the following error:
Trait “AbiDecode” is not implemented for type “CustomStruct”
The struct itself has some trait implementations for From, core::ops::Eq, core::ops::Ord and some struct public methods that operate on the field data in the structs.
The error happens during a cross-contract call.
// Contract A
fn some_call() -> (u64, CustomStruct, u64, bool) {
...
}
// Contract B
fn call_contract_a() {
let (one, _, three, four) = contr_a.some_call(); // doesn't error out
// errors out at compile time because we "actually" want the value of "CustomStruct"
let (one, two, three, four) = contr_a.some_call();
}
I can confirm this wasn’t an issue at v0.49.3, the previous forc version I’d use. Upgrading to v0.60.0 changed that.