mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
pay fee
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use ore_api::{prelude::*, sdk::program_log};
|
||||
use solana_program::rent::Rent;
|
||||
use steel::*;
|
||||
|
||||
/// Commit to a block.
|
||||
@@ -91,6 +92,15 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
||||
permit.fee = fee;
|
||||
permit.seed = args.seed;
|
||||
|
||||
// Send lamports to permit account to pay for fee.
|
||||
if permit.fee > 0 {
|
||||
let rent_exempt_balance = Rent::get()?.minimum_balance(size_of::<Permit>());
|
||||
let surplus_balance = permit_info.lamports().saturating_sub(rent_exempt_balance);
|
||||
let total_fees = permit.commitment * permit.fee;
|
||||
let required_fees = total_fees.saturating_sub(surplus_balance);
|
||||
permit_info.collect(required_fees, signer_info)?;
|
||||
}
|
||||
|
||||
// Transfer hash tokens.
|
||||
transfer(
|
||||
signer_info,
|
||||
|
||||
Reference in New Issue
Block a user