rwa-kyc-hook-api 0.2.0

Token-2022 KYC Transfer Hook for RWA primary issuance on x402
Documentation
use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
use steel::*;

use crate::state::{Config, IssuerConfig, KycRecord, MintConfig};

pub trait HookAccountInfoValidation {
    fn is_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError>;
    fn is_kyc_record(&self, program_id: &Pubkey) -> Result<&Self, ProgramError>;
    fn is_mint_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError>;
    fn is_issuer_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError>;
}

impl HookAccountInfoValidation for AccountInfo<'_> {
    fn is_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError> {
        self.is_type::<Config>(program_id)
    }

    fn is_kyc_record(&self, program_id: &Pubkey) -> Result<&Self, ProgramError> {
        self.is_type::<KycRecord>(program_id)
    }

    fn is_mint_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError> {
        self.is_type::<MintConfig>(program_id)
    }

    fn is_issuer_config(&self, program_id: &Pubkey) -> Result<&Self, ProgramError> {
        self.is_type::<IssuerConfig>(program_id)
    }
}