algokit_transact_ffi/transactions/
asset_freeze.rsuse crate::*;
#[ffi_record]
pub struct AssetFreezeTransactionFields {
asset_id: u64,
freeze_target: String,
frozen: bool,
}
impl From<algokit_transact::AssetFreezeTransactionFields> for AssetFreezeTransactionFields {
fn from(tx: algokit_transact::AssetFreezeTransactionFields) -> Self {
Self {
asset_id: tx.asset_id,
freeze_target: tx.freeze_target.to_string(),
frozen: tx.frozen,
}
}
}
impl TryFrom<Transaction> for algokit_transact::AssetFreezeTransactionFields {
type Error = AlgoKitTransactError;
fn try_from(tx: Transaction) -> Result<Self, Self::Error> {
if tx.transaction_type != TransactionType::AssetFreeze || tx.asset_freeze.is_none() {
return Err(Self::Error::DecodingError {
message: "Asset Freeze data missing".to_string(),
});
}
let data = tx.clone().asset_freeze.unwrap();
let header: algokit_transact::TransactionHeader = tx.try_into()?;
Ok(Self {
header,
asset_id: data.asset_id,
freeze_target: data.freeze_target.parse()?,
frozen: data.frozen,
})
}
}