metaplex-foundation / shank

Extracts IDL from Solana Rust contracts
https://docs.rs/crate/shank_macro/latest
116 stars 23 forks source link

[feat]: calculate data sizes for accounts statically and expose them to the user #18

Open thlorenz opened 2 years ago

thlorenz commented 2 years ago

The exact implementation details for this need to be worked out, but the main idea is that any BorshDeserialize, BorshSerialize or ShankAccount struct will have a byte_size() method added via an impl derive.

This will avoid hard coded consts which need to be manually updated each time a struct is changed.

The task is easy for fixed sized structs with fixed sized fields, but once Option, Vec and strings are included the developer will need to annotate that field in order to allow calculating the max length.