lib.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. use bolt_lang::anchor_lang::*;
  2. use bolt_lang::*;
  3. use component_small::Small;
  4. declare_id!("4Um2d8SvyfWyLLtfu2iJMFhM77DdjjyQusEy7K3VhPkd");
  5. #[system]
  6. pub mod escrow_funding {
  7. pub fn execute(ctx: Context<Components>, args: Args) -> Result<Components> {
  8. let receiver = ctx.accounts.receiver.to_account_info();
  9. let sender = ctx.sender()?.clone();
  10. let system_program = ctx.system_program()?.clone();
  11. let cpi_accounts = system_program::Transfer {
  12. from: sender,
  13. to: receiver,
  14. };
  15. let cpi_ctx = CpiContext::new(system_program, cpi_accounts);
  16. system_program::transfer(cpi_ctx, args.amount)?;
  17. Ok(ctx.accounts)
  18. }
  19. #[system_input]
  20. pub struct Components {
  21. pub receiver: Small,
  22. }
  23. #[arguments]
  24. pub struct Args {
  25. amount: u64,
  26. }
  27. #[extra_accounts]
  28. pub struct ExtraAccounts {
  29. #[account(mut)]
  30. pub sender: AccountInfo,
  31. #[account(address = bolt_lang::solana_program::system_program::id())]
  32. pub system_program: AccountInfo,
  33. }
  34. }