Skip to content

Commit 1a8f2da

Browse files
committed
Add transfer_to function
Taken from [here](solana-foundation/anchor#2552)
1 parent 838a7a0 commit 1a8f2da

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • programs/autocrat_v0/src

programs/autocrat_v0/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@ pub mod autocrat_v0 {
422422

423423
Ok(())
424424
}
425+
426+
pub fn transfer_to(ctx: Context<TransferTo>, lamports: u64) -> Result<()> {
427+
**ctx.accounts.dao_treasury.to_account_info().try_borrow_mut_lamports()? -= lamports;
428+
**ctx.accounts.lamport_receiver.to_account_info().try_borrow_mut_lamports()? += lamports;
429+
430+
Ok(())
431+
}
425432
}
426433

427434
#[derive(Accounts)]
@@ -514,6 +521,14 @@ pub struct Auth<'info> {
514521
pub dao_treasury: Signer<'info>,
515522
}
516523

524+
#[derive(Accounts)]
525+
pub struct TransferTo<'info> {
526+
#[account(mut)]
527+
pub dao_treasury: Signer<'info>,
528+
/// CHECK: no r/w, just lamport add
529+
pub lamport_receiver: UncheckedAccount<'info>,
530+
}
531+
517532
impl From<&ProposalInstruction> for Instruction {
518533
fn from(ix: &ProposalInstruction) -> Self {
519534
Self {

0 commit comments

Comments
 (0)