Skip to content

Commit

Permalink
Run formatter (remove trailing whitespaces)
Browse files Browse the repository at this point in the history
  • Loading branch information
larry0x committed Jan 15, 2022
1 parent a2bf6b5 commit 366f4e9
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 115 deletions.
44 changes: 22 additions & 22 deletions src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ impl<T> AssetBase<T> {
///
/// To create an unchecked instance, the [`info`] parameter may be either checked or unchecked;
/// to create a checked instance, the [`info`] paramter must also be checked.
///
///
/// ```rust
/// use cosmwasm_std::Addr;
/// use cw_asset::{Asset, AssetInfo};
///
///
/// let info1 = AssetInfo::cw20(Addr::unchecked("token_addr"));
/// let asset1 = Asset::new(info1, 12345u128);
///
///
/// let info2 = AssetInfo::native("uusd");
/// let asset2 = Asset::new(info2, 67890u128);
/// ```
Expand All @@ -49,15 +49,15 @@ impl<T> AssetBase<T> {
}

/// Create a new **asset** instance representing a CW20 token of given contract address and amount
///
///
/// To create an unchecked instance, provide the contract address in any of the following types:
/// [`cosmwasm_std::Addr`], [`String`], or [`&str`]; to create a checked instance, the address
/// must of type [`cosmwasm_std::Addr`].
///
/// [`cosmwasm_std::Addr`], [`String`], or [`&str`]; to create a checked instance, the address
/// must of type [`cosmwasm_std::Addr`].
///
/// ```rust
/// use cosmwasm_std::Addr;
/// use cw_asset::Asset;
///
///
/// let asset = Asset::cw20(Addr::unchecked("token_addr"), 12345u128);
/// ```
pub fn cw20<A: Into<T>, B: Into<Uint128>>(contract_addr: A, amount: B) -> Self {
Expand All @@ -68,10 +68,10 @@ impl<T> AssetBase<T> {
}

/// Create a new **asset** instance representing a native coin of given denom and amount
///
///
/// ```rust
/// use cw_asset::Asset;
///
///
/// let asset = Asset::native("uusd", 12345u128);
/// ```
pub fn native<A: Into<String>, B: Into<Uint128>>(denom: A, amount: B) -> Self {
Expand Down Expand Up @@ -99,11 +99,11 @@ impl From<Asset> for AssetUnchecked {
impl AssetUnchecked {
/// Validate data contained in an _unchecked_ **asset** instnace, return a new _checked_
/// **asset** instance
///
///
/// ```rust
/// use cosmwasm_std::{Addr, Api};
/// use cw_asset::{Asset, AssetUnchecked};
///
///
/// fn validate_asset(api: &dyn Api, asset_unchecked: &AssetUnchecked) {
/// match asset_unchecked.check(api) {
/// Ok(asset) => println!("asset is valid: {}", asset.to_string()),
Expand Down Expand Up @@ -143,23 +143,23 @@ impl From<&Coin> for Asset {
impl Asset {
/// Generate a message that sends a CW20 token to the specified recipient with a binary payload
///
/// NOTE: Only works for CW20 tokens. Returns error if invoked on an [`Asset`] instance
/// NOTE: Only works for CW20 tokens. Returns error if invoked on an [`Asset`] instance
/// representing a native coin, as native coins do not have an equivalent method mplemented.
///
/// ```rust
/// use serde::Serialize;
///
///
/// #[derive(Serialize)]
/// enum MockReceiveMsg {
/// MockCommand {}
/// }
///
///
/// use cosmwasm_std::{to_binary, Addr, Response, StdResult};
/// use cw_asset::Asset;
///
///
/// fn send_asset(asset: &Asset, contract_addr: &Addr, msg: &MockReceiveMsg) -> StdResult<Response> {
/// let msg = asset.send_msg(contract_addr, to_binary(msg)?)?;
///
///
/// Ok(Response::new()
/// .add_message(msg)
/// .add_attribute("asset_sent", asset.to_string()))
Expand Down Expand Up @@ -187,10 +187,10 @@ impl Asset {
/// ```rust
/// use cosmwasm_std::{Addr, Response, StdResult};
/// use cw_asset::Asset;
///
///
/// fn transfer_asset(asset: &Asset, recipient_addr: &Addr) -> StdResult<Response> {
/// let msg = asset.transfer_msg(recipient_addr)?;
///
///
/// Ok(Response::new()
/// .add_message(msg)
/// .add_attribute("asset_sent", asset.to_string()))
Expand Down Expand Up @@ -219,16 +219,16 @@ impl Asset {
/// Generate a message that draws the asset from the account specified by [`from`] to the one
/// specified by [`to`]
///
/// NOTE: Only works for CW20 tokens. Returns error if invoked on an [`Asset`] instance
/// NOTE: Only works for CW20 tokens. Returns error if invoked on an [`Asset`] instance
/// representing a native coin, as native coins do not have an equivalent method mplemented.
///
/// ```rust
/// use cosmwasm_std::{Addr, Response, StdResult};
/// use cw_asset::Asset;
///
///
/// fn draw_asset(asset: &Asset, user_addr: &Addr, contract_addr: &Addr) -> StdResult<Response> {
/// let msg = asset.transfer_from_msg(user_addr, contract_addr)?;
///
///
/// Ok(Response::new()
/// .add_message(msg)
/// .add_attribute("asset_drawn", asset.to_string()))
Expand Down
30 changes: 15 additions & 15 deletions src/asset_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Represents the type of an fungible asset
///
///
/// Each **asset info** instance can be one of two variants:
///
///
/// - CW20 tokens. To create an **asset info** instance of this type, provide the contract address.
/// - Native SDK coins. To create an **asset info** instance of this type, provide the denomination.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
Expand All @@ -24,26 +24,26 @@ pub enum AssetInfoBase<T> {

impl<T> AssetInfoBase<T> {
/// Create an **asset info** instance of the _CW20_ variant
///
///
/// To create an unchecked instance, provide the contract address in any of the following types:
/// [`cosmwasm_std::Addr`], [`String`], or [`&str`]; to create a checked instance, the address
/// [`cosmwasm_std::Addr`], [`String`], or [`&str`]; to create a checked instance, the address
/// must of type [`cosmwasm_std::Addr`].
///
///
/// ```rust
/// use cosmwasm_std::Addr;
/// use cw_asset::AssetInfo;
///
///
/// let info = AssetInfo::cw20(Addr::unchecked("token_addr"));
/// ```
pub fn cw20<A: Into<T>>(contract_addr: A) -> Self {
AssetInfoBase::Cw20(contract_addr.into())
}

/// Create an **asset info** instance of the _native_ variant by providing the coin's denomination
///
///
/// ```rust
/// use cw_asset::AssetInfo;
///
///
/// let info = AssetInfo::native("uusd");
/// ```
pub fn native<A: Into<String>>(denom: A) -> Self {
Expand All @@ -66,17 +66,17 @@ impl From<AssetInfo> for AssetInfoUnchecked {
}

impl AssetInfoUnchecked {
/// Validate data contained in an _unchecked_ **asset info** instance; return a new _checked_
/// Validate data contained in an _unchecked_ **asset info** instance; return a new _checked_
/// **asset info** instance
///
///
/// ```rust
/// use cosmwasm_std::{Addr, Api, StdResult};
/// use cw_asset::{AssetInfo, AssetInfoUnchecked};
///
///
/// fn validate_asset_info(api: &dyn Api, info_unchecked: &AssetInfoUnchecked) {
/// match info_unchecked.check(api) {
/// Ok(info) => println!("asset info is valid: {}", info.to_string()),
/// Err(err) => println!("asset is invalid! reason: {}", err),
/// Err(err) => println!("asset is invalid! reason: {}", err),
/// }
/// }
/// ```
Expand All @@ -101,11 +101,11 @@ impl fmt::Display for AssetInfo {

impl AssetInfo {
/// Query an address' balance of the asset
///
///
/// ```rust
/// use cosmwasm_std::{Addr, Deps, StdResult, Uint128};
/// use cw_asset::AssetInfo;
///
///
/// fn query_uusd_balance(deps: Deps, account_addr: &Addr) -> StdResult<Uint128> {
/// let info = AssetInfo::native("uusd");
/// info.query_balance(&deps.querier, "account_addr")
Expand Down Expand Up @@ -216,8 +216,8 @@ impl std::cmp::PartialEq<astroport::asset::AssetInfo> for AssetInfo {

#[cfg(test)]
mod test {
use super::*;
use super::super::testing::mock_dependencies;
use super::*;
use cosmwasm_std::testing::MockApi;
use cosmwasm_std::Coin;

Expand Down
Loading

0 comments on commit 366f4e9

Please sign in to comment.