metaplex-foundation / shank

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

[feat]: support account padding #17

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

In order to ensure accounts stay the same size even if more fields are added to the data struct, that data is padded.

Shank should allow this to be expressed via a padding field similar to this:

pub struct MyData {
  pub count: u8,
  pub owner: Pubkey,
  #[padding]
  pub _padding_placeholder: [u8;36]
}

The struct that is included with the IDL for that account will include that field. It would be nice to mark it as optional or padding so that code generators can treat it differently. Existing code generators like solita wouldn't have to be updated at this point since they will just include that field with the deserialized account data (zero filled) and SDK clients just have to know not to use it. However this could be made explicit, i.e. via a comment or special naming once these fields are specially marked.

austbot commented 2 years ago

how is this going?

thlorenz commented 2 years ago

Haven't put any work into it yet. We need to prioritize features we need.