From 991edc5e0f1b18efb339843d1b79baa4892e14a6 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Mon, 19 Sep 2022 02:37:59 +0100 Subject: [PATCH] fix bug: no funds stringifies to empty string --- contracts/hub/src/helpers.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contracts/hub/src/helpers.rs b/contracts/hub/src/helpers.rs index a8e74fd..46a9638 100644 --- a/contracts/hub/src/helpers.rs +++ b/contracts/hub/src/helpers.rs @@ -31,8 +31,14 @@ pub fn stringify_option(opt: Option) -> String { opt.map_or_else(|| "undefined".to_string(), |value| value.to_string()) } -/// Casting Vec to a string +/// Casting Vec 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())