From 10e83e6cd752f422640f2b786e6a1dc55e369e2c Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 2 Feb 2023 15:49:23 +0000 Subject: [PATCH] switch all to AssetError --- src/asset_info.rs | 8 ++++---- src/asset_list.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/asset_info.rs b/src/asset_info.rs index b97feb8..5005433 100644 --- a/src/asset_info.rs +++ b/src/asset_info.rs @@ -167,10 +167,10 @@ impl AssetInfo { /// Query an address' balance of the asset /// /// ```rust - /// use cosmwasm_std::{Addr, Deps, StdResult, Uint128}; - /// use cw_asset::AssetInfo; + /// use cosmwasm_std::{Addr, Deps, Uint128}; + /// use cw_asset::{AssetError, AssetInfo}; /// - /// fn query_uusd_balance(deps: Deps, account_addr: &Addr) -> StdResult { + /// fn query_uusd_balance(deps: Deps, account_addr: &Addr) -> Result { /// let info = AssetInfo::native("uusd"); /// info.query_balance(&deps.querier, "account_addr") /// } @@ -179,7 +179,7 @@ impl AssetInfo { &self, querier: &QuerierWrapper, address: T, - ) -> StdResult { + ) -> Result { match self { AssetInfo::Native(denom) => { let response: BalanceResponse = diff --git a/src/asset_list.rs b/src/asset_list.rs index cf5b773..ada8548 100644 --- a/src/asset_list.rs +++ b/src/asset_list.rs @@ -1,7 +1,7 @@ use std::{fmt, str::FromStr}; use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Api, Coin, CosmosMsg, StdResult}; +use cosmwasm_std::{Addr, Api, Coin, CosmosMsg}; use cw_address_like::AddressLike; use crate::{Asset, AssetBase, AssetError, AssetInfo, AssetUnchecked}; @@ -306,7 +306,7 @@ impl AssetList { /// .unwrap() /// .amount; // should have increased to 23456 /// ``` - pub fn add(&mut self, asset_to_add: &Asset) -> StdResult<&mut Self> { + pub fn add(&mut self, asset_to_add: &Asset) -> Result<&mut Self, AssetError> { match self.0.iter_mut().find(|asset| asset.info == asset_to_add.info) { Some(asset) => { asset.amount = asset.amount.checked_add(asset_to_add.amount)?; @@ -342,7 +342,7 @@ impl AssetList { /// .unwrap() /// .amount; // should have increased to 23456 /// ``` - pub fn add_many(&mut self, assets_to_add: &AssetList) -> StdResult<&mut Self> { + pub fn add_many(&mut self, assets_to_add: &AssetList) -> Result<&mut Self, AssetError> { for asset in &assets_to_add.0 { self.add(asset)?; }