1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::bid_escrow::events::{CSPRTransfer, TransferReason};
use odra::contract_env::{self_address, transfer_tokens};
use odra::prelude::string::ToString;
use odra::types::{event::OdraEvent, Address, Balance};

/// Withdraws CSPR from the contract and emits a corresponding event.
pub fn withdraw(to: &Address, amount: Balance, reason: TransferReason) {
    transfer_tokens(to, amount);

    CSPRTransfer {
        from: self_address(),
        to: *to,
        amount,
        reason: reason.to_string(),
    }
    .emit();
}