sdk.rs 718 B

123456789101112131415161718192021222324
  1. use steel::*;
  2. use crate::prelude::*;
  3. pub fn set_favorites(signer: Pubkey, number: u64, color: &str, hobbies: Vec<&str>) -> Instruction {
  4. let color_bytes: [u8; 32] = string_to_bytes32_padded(color).unwrap();
  5. let hobbies_bytes = strings_to_bytes32_array_padded(hobbies).unwrap();
  6. Instruction {
  7. program_id: crate::ID,
  8. accounts: vec![
  9. AccountMeta::new(signer, true),
  10. AccountMeta::new(favorites_pda().0, false),
  11. AccountMeta::new_readonly(system_program::ID, false),
  12. ],
  13. data: SetFavorites {
  14. number: number.to_le_bytes(),
  15. color: color_bytes,
  16. hobbies: hobbies_bytes,
  17. }
  18. .to_bytes(),
  19. }
  20. }