diff --git a/src/asset.rs b/src/asset.rs index bc12824..4771354 100644 --- a/src/asset.rs +++ b/src/asset.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{to_binary, Addr, Api, BankMsg, Binary, Coin, CosmosMsg, Uint1 use cw20::Cw20ExecuteMsg; use cw_address_like::AddressLike; -use crate::{AssetInfo, AssetInfoBase, AssetInfoUnchecked, AssetError}; +use crate::{AssetError, AssetInfo, AssetInfoBase, AssetInfoUnchecked}; /// Represents a fungible asset with a known amount /// @@ -93,7 +93,7 @@ impl FromStr for AssetUnchecked { if words.len() != 3 { return Err(AssetError::InvalidAssetFormat { received: s.into(), - }) + }); } AssetInfoUnchecked::from_str(&format!("{}:{}", words[0], words[1]))? }, @@ -105,10 +105,8 @@ impl FromStr for AssetUnchecked { }; let amount_str = words[words.len() - 1]; - let amount = Uint128::from_str(amount_str).map_err(|_| { - AssetError::InvalidAssetAmount { - amount: amount_str.into(), - } + let amount = Uint128::from_str(amount_str).map_err(|_| AssetError::InvalidAssetAmount { + amount: amount_str.into(), })?; Ok(AssetUnchecked { @@ -399,7 +397,7 @@ mod tests { Asset { info: AssetInfo::Native(String::from("uusd")), amount: Uint128::new(123456u128) - } + }, ); let asset = Asset::cw20(Addr::unchecked("mock_token"), 123456u128); @@ -408,7 +406,7 @@ mod tests { Asset { info: AssetInfo::Cw20(Addr::unchecked("mock_token")), amount: Uint128::new(123456u128) - } + }, ); let asset = Asset::native("uusd", 123456u128); @@ -417,7 +415,7 @@ mod tests { Asset { info: AssetInfo::Native(String::from("uusd")), amount: Uint128::new(123456u128) - } + }, ) } @@ -514,7 +512,7 @@ mod tests { ); let s = "native:uusd:12345"; - assert_eq!(AssetUnchecked::from_str(s).unwrap(), AssetUnchecked::native("uusd", 12345u128),); + assert_eq!(AssetUnchecked::from_str(s).unwrap(), AssetUnchecked::native("uusd", 12345u128)); let s = "cw20:mock_token:12345"; assert_eq!( @@ -537,7 +535,7 @@ mod tests { AssetUnchecked::native( "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", 69420u128 - ) + ), ); let asset = AssetUnchecked::from_sdk_string( @@ -549,7 +547,7 @@ mod tests { AssetUnchecked::native( "factory/osmo1z926ax906k0ycsuckele6x5hh66e2m4m6ry7dn", 88888u128 - ) + ), ); let err = AssetUnchecked::from_sdk_string("ngmi"); @@ -583,7 +581,7 @@ mod tests { Err(AssetError::UnacceptedDenom { denom: "uatom".into(), whitelist: "uusd|uluna|uosmo".into(), - }) + }), ); } @@ -638,7 +636,7 @@ mod tests { }) .unwrap(), funds: vec![] - }) + }), ); let msg = coin.transfer_msg("alice").unwrap(); @@ -647,7 +645,7 @@ mod tests { CosmosMsg::Bank(BankMsg::Send { to_address: String::from("alice"), amount: vec![Coin::new(123456, "uusd")] - }) + }), ); let msg = token.transfer_from_msg("bob", "charlie").unwrap(); @@ -662,7 +660,7 @@ mod tests { }) .unwrap(), funds: vec![] - }) + }), ); let err = coin.transfer_from_msg("bob", "charlie"); assert_eq!( diff --git a/src/asset_info.rs b/src/asset_info.rs index 2349890..8ddb1fb 100644 --- a/src/asset_info.rs +++ b/src/asset_info.rs @@ -1,4 +1,4 @@ -use std::{fmt, str::FromStr, any::type_name}; +use std::{any::type_name, fmt, str::FromStr}; use cosmwasm_schema::cw_serde; use cosmwasm_std::{ @@ -469,7 +469,8 @@ mod test { let (key1, key2, key3) = mock_keys(); map.save(deps.as_mut().storage, (key1.clone(), key2.clone(), key3.clone()), &42069) .unwrap(); - map.save(deps.as_mut().storage, (key1.clone(), key1.clone(), key2.clone()), &11).unwrap(); + map.save(deps.as_mut().storage, (key1.clone(), key1.clone(), key2.clone()), &11) + .unwrap(); map.save(deps.as_mut().storage, (key1.clone(), key1.clone(), key3.clone()), &69420) .unwrap(); @@ -482,8 +483,7 @@ mod test { assert_eq!(items[1], (key3.clone(), 69420)); assert_eq!(items[0], (key2.clone(), 11)); - let val1 = - map.load(deps.as_ref().storage, (key1, key2, key3)).unwrap(); + let val1 = map.load(deps.as_ref().storage, (key1, key2, key3)).unwrap(); assert_eq!(val1, 42069); } } diff --git a/src/asset_list.rs b/src/asset_list.rs index a5696af..f281683 100644 --- a/src/asset_list.rs +++ b/src/asset_list.rs @@ -71,8 +71,7 @@ impl AssetListUnchecked { api: &dyn Api, optional_whitelist: Option<&[&str]>, ) -> Result { - self - .0 + self.0 .iter() .map(|asset| asset.check(api, optional_whitelist)) .collect::, _>>() @@ -610,7 +609,7 @@ mod tests { AssetList::from(vec![ Asset::native("uusd", 34710u128), Asset::new(mock_token(), 44444u128) - ]) + ]), ); } @@ -698,8 +697,8 @@ mod tests { }) .unwrap(), funds: vec![] - }) - ] + }), + ], ); } } diff --git a/src/error.rs b/src/error.rs index 800331a..0616597 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{StdError, OverflowError}; +use cosmwasm_std::{OverflowError, StdError}; use thiserror::Error; #[derive(Error, Debug, PartialEq)]