mod bank;
mod config;
mod escrow;
mod payment;
pub use bank::*;
pub use config::*;
pub use escrow::*;
pub use payment::*;
use steel::*;
use crate::consts::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum EscrowAccount {
Bank = 100,
Config = 101,
Escrow = 102,
Payment = 103,
}
pub fn bank_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[BANK], &crate::id())
}
pub fn config_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[CONFIG], &crate::id())
}
pub fn escrow_pda(mint: Pubkey, bank: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[ESCROW, mint.as_ref(), bank.as_ref()], &crate::id())
}
pub fn payment_pda(payment_uid: &str, bank: Pubkey) -> (Pubkey, u8) {
let mut uid_bytes = [0u8; 32];
let uid_str = payment_uid.replace('-', ""); let uid_bytes_str = uid_str.as_bytes();
let len = uid_bytes_str.len().min(32);
uid_bytes[..len].copy_from_slice(&uid_bytes_str[..len]);
Pubkey::find_program_address(&[PAYMENT, &uid_bytes, bank.as_ref()], &crate::id())
}
pub fn sol_storage_pda(mint: Pubkey, bank: Pubkey, escrow: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[SOL_STORAGE, mint.as_ref(), bank.as_ref(), escrow.as_ref()],
&crate::id(),
)
}