Skip to content

Commit

Permalink
switch all to AssetError
Browse files Browse the repository at this point in the history
  • Loading branch information
larry0x committed Feb 2, 2023
1 parent 848ed65 commit 10e83e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/asset_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint128> {
/// fn query_uusd_balance(deps: Deps, account_addr: &Addr) -> Result<Uint128, AssetError> {
/// let info = AssetInfo::native("uusd");
/// info.query_balance(&deps.querier, "account_addr")
/// }
Expand All @@ -179,7 +179,7 @@ impl AssetInfo {
&self,
querier: &QuerierWrapper,
address: T,
) -> StdResult<Uint128> {
) -> Result<Uint128, AssetError> {
match self {
AssetInfo::Native(denom) => {
let response: BalanceResponse =
Expand Down
6 changes: 3 additions & 3 deletions src/asset_list.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
}
Expand Down

0 comments on commit 10e83e6

Please sign in to comment.