Skip to content

Instantly share code, notes, and snippets.

@Danlowe95
Danlowe95 / gist:8ae5767a95e8321c255e2b1345f351fb
Last active April 6, 2022 16:07
Bug in program.account.<account>.fetch() when account contains a field that is an array of Option<CustomStruct>, and CustomStruct contains Optionals.

Update

Gist #2 below provides a more concise explanation of what I believe is going wrong and causing decoding to fail. I am leaving gist #1 up, but would recommend readers to read Gist #2 first to get a better understanding of the problem.

Problem

Breaking code:

    let primaryStruct = await program.account.primaryStruct.fetch(stateAccount);

The error: