mars-protocol / cw-asset

A unified representation of various types of Cosmos fungible assets, and helper functions for interacting with them

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `AssetInfo` or `AssetInfoUnchecked` as `KeyDeserialize::Output` for `AssetInfoKey`

y-pakorn opened this issue · comments

We can use AssetInfo or AssetInfoUnchecked as KeyDeserialize::Output for AssetInfoKey here to avoid unnecessary casting step.

impl KeyDeserialize for AssetInfoKey {
    type Output = Self;

    #[inline(always)]
    fn from_vec(value: Vec<u8>) -> StdResult<Self::Output> {
        Ok(Self(value))
    }
}
impl KeyDeserialize for AssetInfoKey {
    type Output = AssetInfoUnchecked;

    #[inline(always)]
    fn from_vec(value: Vec<u8>) -> StdResult<Self::Output> {
        Self::Output::try_from(Self(value))
    }
}