Skip to content

Commit

Permalink
feat: binary encode assets in events
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo-sturdy committed Sep 26, 2023
1 parent b200b75 commit 2e4f580
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vault-zapper"
version = "0.1.0-rc.2"
version = "0.1.0-rc.3"
authors = ["Sturdy <[email protected]>"]
edition = "2021"

Expand Down
18 changes: 6 additions & 12 deletions src/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
}
10 changes: 4 additions & 6 deletions src/withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2e4f580

Please sign in to comment.