lib.rs 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use anchor_lang::prelude::*;
  2. declare_id!("id1Bui1dFeatures111111111111111111111111111");
  3. #[program]
  4. pub mod idl_build_features {
  5. use super::*;
  6. pub fn full_path(
  7. ctx: Context<FullPath>,
  8. my_struct: MyStruct,
  9. some_module_my_struct: some_module::MyStruct,
  10. ) -> Result<()> {
  11. ctx.accounts.account.my_struct = my_struct;
  12. ctx.accounts.account.some_module_my_struct = some_module_my_struct;
  13. Ok(())
  14. }
  15. }
  16. #[derive(Accounts)]
  17. pub struct FullPath<'info> {
  18. #[account(zero)]
  19. pub account: Account<'info, FullPathAccount>,
  20. }
  21. #[account]
  22. pub struct FullPathAccount {
  23. pub my_struct: MyStruct,
  24. pub some_module_my_struct: some_module::MyStruct,
  25. }
  26. mod some_module {
  27. use super::*;
  28. #[derive(AnchorSerialize, AnchorDeserialize, Clone)]
  29. pub struct MyStruct {
  30. pub data: u8,
  31. }
  32. }
  33. #[derive(AnchorSerialize, AnchorDeserialize, Clone)]
  34. pub struct MyStruct {
  35. pub u8: u8,
  36. pub u16: u16,
  37. pub u32: u32,
  38. pub u64: u64,
  39. }