Skip to content

Commit

Permalink
fix bug: no funds stringifies to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
larry0x committed Sep 19, 2022
1 parent 0ae2b73 commit 991edc5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/hub/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ pub fn stringify_option(opt: Option<impl fmt::Display>) -> String {
opt.map_or_else(|| "undefined".to_string(), |value| value.to_string())
}

/// Casting Vec<Coin> to a string
/// Casting Vec<Coin> to a string.
///
/// If there is no fund (i.e. empty Vec), return the string `[]`. This is because wasm module does
/// not allow an empty string as event attribute.
pub fn stringify_funds(funds: &[Coin]) -> String {
if funds.is_empty() {
return "[]".to_string();
}
funds
.iter()
.map(|coin| coin.to_string())
Expand Down

0 comments on commit 991edc5

Please sign in to comment.