Skip to content

Commit

Permalink
Associate address in event (#229)
Browse files Browse the repository at this point in the history
* Fix associated address event

* Add test
  • Loading branch information
shanev authored Dec 10, 2022
1 parent 88a5445 commit ae900ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion contracts/name-minter/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ fn bid(app: &mut StargazeApp, bidder: &str, amount: u128) {
}

mod execute {
use cosmwasm_std::StdError;
use cosmwasm_std::{attr, StdError};
use cw721::{NftInfoResponse, OperatorsResponse};
use name_marketplace::state::{Ask, SudoParams};
use sg721_name::msg::QueryMsg as Sg721NameQueryMsg;
Expand Down Expand Up @@ -656,6 +656,14 @@ mod execute {
&[],
);
assert!(res.is_ok());

res.unwrap().events.iter().for_each(|e| {
if e.ty == "wasm-associate-address" {
assert_eq!(e.attributes[1], attr("name", NAME));
assert_eq!(e.attributes[2], attr("owner", ADMIN2));
assert_eq!(e.attributes[3], attr("address", MINTER));
}
});
}

#[test]
Expand Down
7 changes: 5 additions & 2 deletions contracts/sg721-name/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ pub fn execute_associate_address(
// 6. save new reverse map entry
token_uri.map(|addr| REVERSE_MAP.save(deps.storage, &addr, &name));

let event = Event::new("associate-address")
let mut event = Event::new("associate-address")
.add_attribute("name", name)
.add_attribute("owner", info.sender);
address.map(|addr| event.clone().add_attribute("address", addr));

if let Some(address) = address {
event = event.add_attribute("address", address);
}

Ok(Response::new().add_event(event))
}
Expand Down

0 comments on commit ae900ad

Please sign in to comment.