-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cw0::Balance for atomic swap Balance
- Loading branch information
Showing
4 changed files
with
23 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use cosmwasm_std::Coin; | ||
use cw20::Cw20Coin; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum Balance { | ||
Native(Vec<Coin>), | ||
Native(cw0::Balance), | ||
Cw20(Cw20Coin), | ||
} | ||
|
||
impl Default for Balance { | ||
fn default() -> Balance { | ||
Balance::Native(vec![]) | ||
Balance::Native(cw0::Balance(vec![])) | ||
} | ||
} | ||
|
||
impl Balance { | ||
pub fn is_empty(&self) -> bool { | ||
match self { | ||
Balance::Native(coins) => coins.is_empty(), | ||
Balance::Native(balance) => balance.is_empty(), | ||
Balance::Cw20(coin) => coin.is_empty(), | ||
} | ||
} | ||
|
||
/// normalize Wallet | ||
pub fn normalize(&mut self) { | ||
match self { | ||
Balance::Native(balance) => balance.normalize(), | ||
Balance::Cw20(_) => {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters