initialize.rs 548 B

1234567891011121314151617
  1. use lever_api::prelude::*;
  2. use steel::*;
  3. pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
  4. // Load accounts.
  5. let [signer_info, power_info, system_program] = accounts else {
  6. return Err(ProgramError::NotEnoughAccountKeys);
  7. };
  8. signer_info.is_signer()?;
  9. power_info.is_empty()?.is_writable()?;
  10. system_program.is_program(&system_program::ID)?;
  11. // Initialize power.
  12. create_account::<PowerStatus>(power_info, system_program, signer_info, &lever_api::ID, &[])?;
  13. Ok(())
  14. }