shank
shank copied to clipboard
shank/solita doesn't handle zero sized structs
With:
#[derive(BorshDeserialize)]
struct MyEmptyStruct {}
shank runs fine, but the resulting idl contains
{
"name": "MyEmptyStruct",
"type": {
"kind": "struct",
"fields": []
}
}
causing solita to crash with
AssertionError [ERR_ASSERTION]: Rendering struct for MyEmptyStruct should have at least 1 field
On the other hand, with:
#[derive(BorshDeserialize)]
struct MyEmptyStruct;
shank crashes with
failed to parse fields make sure they are all named
Which is fine if shank/solita doesn't intend to support zero-sized structs but it attempts to do every single struct that impl BorshSerialize
even if its not pub
or part of the solana program instruction interface.
but it attempts to do every single struct that impl BorshSerialize
nevermind i lied, it only does it for structs where BorshSerialize
is auto-derived (#[derive(BorshSerialize)]
). My current workaround is to implement BorshSerialize
manually for the zero-sized struct (which is just a no-op anw)