From 2e4f5802b13e069c62c93784e367c82ee33bacf4 Mon Sep 17 00:00:00 2001 From: Sturdy <91910406+apollo-sturdy@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:42:58 +0200 Subject: [PATCH] feat: binary encode assets in events --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/deposit.rs | 18 ++++++------------ src/withdraw.rs | 10 ++++------ 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4472e9..4350b37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3397,7 +3397,7 @@ checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "vault-zapper" -version = "0.1.0-rc.2" +version = "0.1.0-rc.3" dependencies = [ "apollo-cw-asset", "apollo-utils", diff --git a/Cargo.toml b/Cargo.toml index 6be1356..814f41f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vault-zapper" -version = "0.1.0-rc.2" +version = "0.1.0-rc.3" authors = ["Sturdy "] edition = "2021" diff --git a/src/deposit.rs b/src/deposit.rs index 596dfc2..4a657b8 100644 --- a/src/deposit.rs +++ b/src/deposit.rs @@ -45,7 +45,7 @@ pub fn execute_deposit( .into_cosmos_msg(&env)?; let event = Event::new("apollo/vault-zapper/execute_deposit") - .add_attribute("assets", assets.to_string()) + .add_attribute("assets", to_binary(&assets)?.to_string()) .add_attribute("vault_address", &vault_address) .add_attribute("recipient", &recipient) .add_attribute("min_out", min_out); @@ -229,17 +229,11 @@ pub fn callback_enforce_min_out( } } - let mut event = Event::new("apollo/vault-zapper/callback_enforce_min_out") - .add_attribute("recipient", recipient); - if !assets.is_empty() { - event = event.add_attribute("assets", format!("{:?}", assets)); - } - if min_out.len() > 0 { - event = event.add_attribute("min_out", format!("{:?}", min_out)); - } - if assets_received.len() > 0 { - event = event.add_attribute("assets_received", format!("{:?}", assets_received)); - } + let event = Event::new("apollo/vault-zapper/callback_enforce_min_out") + .add_attribute("recipient", recipient) + .add_attribute("assets", to_binary(&assets)?.to_string()) + .add_attribute("min_out", to_binary(&min_out)?.to_string()) + .add_attribute("assets_received", to_binary(&assets_received)?.to_string()); Ok(Response::new().add_event(event)) } diff --git a/src/withdraw.rs b/src/withdraw.rs index 6e1a931..17f73eb 100644 --- a/src/withdraw.rs +++ b/src/withdraw.rs @@ -119,14 +119,12 @@ pub fn withdraw( }), }; - let mut event = Event::new("apollo/vault-zapper/withdraw") + let event = Event::new("apollo/vault-zapper/withdraw") .add_attribute("vault_address", &vault_address) .add_attribute("recipient", &recipient) - .add_attribute("receive_choice", format!("{:?}", receive_choice)) - .add_attribute("withdraw_type", format!("{:?}", withdraw_type)); - if min_out.len() > 0 { - event = event.add_attribute("min_out", min_out.to_string()); - } + .add_attribute("receive_choice", to_binary(&receive_choice)?.to_string()) + .add_attribute("withdraw_type", to_binary(&withdraw_type)?.to_string()) + .add_attribute("min_out", to_binary(&min_out)?.to_string()); Ok(Response::new() .add_message(withdraw_msg)