neptune_common/
astroport.rs

1use crate::{
2    asset::{AssetAmount, AssetInfo},
3    error::CommonError,
4};
5
6impl From<AssetInfo> for astroport::asset::AssetInfo {
7    fn from(value: AssetInfo) -> Self {
8        match value {
9            AssetInfo::Token { contract_addr } => astroport::asset::AssetInfo::Token { contract_addr },
10            AssetInfo::NativeToken { denom } => astroport::asset::AssetInfo::NativeToken { denom },
11        }
12    }
13}
14
15impl TryFrom<AssetAmount> for astroport::asset::Asset {
16    type Error = CommonError;
17
18    fn try_from(value: AssetAmount) -> Result<Self, Self::Error> {
19        Ok(Self { info: value.info.into(), amount: value.amount.try_into()? })
20    }
21}