-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate the denom of each new limiter to be part of the pool assets
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use super::TransmuterPool; | ||
|
||
impl TransmuterPool { | ||
/// Check if the pool has the specified denom | ||
pub fn has_denom(&self, denom: &str) -> bool { | ||
self.pool_assets | ||
.iter() | ||
.any(|pool_asset| pool_asset.denom == denom) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::denom::Denom; | ||
|
||
#[test] | ||
fn test_has_denom() { | ||
let pool_assets = vec![ | ||
Denom::unchecked("asset1"), | ||
Denom::unchecked("asset2"), | ||
Denom::unchecked("asset3"), | ||
]; | ||
let pool = TransmuterPool::new(&pool_assets).unwrap(); | ||
|
||
assert!(pool.has_denom("asset1")); | ||
assert!(pool.has_denom("asset2")); | ||
assert!(pool.has_denom("asset3")); | ||
assert!(!pool.has_denom("asset4")); | ||
} | ||
} |
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