use serde::Deserialize;
use crate::client::http::{ApiError, Call, Transport, read};
use crate::utils::AccountIndex;
use crate::utils::ids::whole;
#[derive(Deserialize)]
struct TransferFeeInfo {
#[serde(deserialize_with = "whole")]
transfer_fee_usdc: u64,
}
#[derive(Deserialize)]
struct WithdrawalDelay {
#[serde(deserialize_with = "whole")]
seconds: u64,
}
#[must_use]
pub fn transfer_fee_call(account: AccountIndex, to: Option<AccountIndex>) -> Call {
Call::get("transferFeeInfo").field("account_index", account).maybe("to_account_index", to).authed()
}
pub async fn transfer_fee(
transport: &impl Transport,
account: AccountIndex,
to: Option<AccountIndex>,
) -> Result<u64, ApiError> {
Ok(read::<TransferFeeInfo>(transport, transfer_fee_call(account, to)).await?.transfer_fee_usdc)
}
#[must_use]
pub fn withdrawal_delay_call() -> Call {
Call::get("withdrawalDelay")
}
pub async fn withdrawal_delay(transport: &impl Transport) -> Result<u64, ApiError> {
Ok(read::<WithdrawalDelay>(transport, withdrawal_delay_call()).await?.seconds)
}
#[cfg(test)]
#[path = "tests/fees.rs"]
mod tests;