From 0a14dffe9b87a79f5dc9b9039862c2035a59ec25 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 11 Dec 2024 22:40:05 -0600 Subject: [PATCH 1/2] add action to finalize-sale --- .../stargaze-marketplace-v2/src/execute.rs | 29 +++++++++++++++++-- .../stargaze-marketplace-v2/src/helpers.rs | 4 ++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/contracts/stargaze-marketplace-v2/src/execute.rs b/contracts/stargaze-marketplace-v2/src/execute.rs index 25eed89a..aef2b9b5 100644 --- a/contracts/stargaze-marketplace-v2/src/execute.rs +++ b/contracts/stargaze-marketplace-v2/src/execute.rs @@ -274,7 +274,16 @@ pub fn execute_set_ask( if let Some(matching_bid) = match_result { // If a match is found finalize the sale - response = finalize_sale(deps, &env, &ask, &config, &matching_bid, false, response)?; + response = finalize_sale( + deps, + &env, + &ask, + &config, + &matching_bid, + false, + "set-ask", + response, + )?; } else if sell_now { // If no match is found and sell_now is true, abort transaction Err(ContractError::NoMatchFound)?; @@ -350,7 +359,16 @@ pub fn execute_update_ask( if let Some(matching_bid) = match_result { // If a match is found finalize the sale - response = finalize_sale(deps, &env, &ask, &config, &matching_bid, false, response)?; + response = finalize_sale( + deps, + &env, + &ask, + &config, + &matching_bid, + false, + "update-ask", + response, + )?; } else { // If no match is found continue updating the ask ask.save(deps.storage)?; @@ -459,6 +477,7 @@ pub fn execute_accept_ask( &config, &MatchingBid::Bid(bid), true, + "accept-ask", Response::new(), )?; @@ -517,6 +536,7 @@ pub fn execute_set_bid( &config, &MatchingBid::Bid(bid), true, + "set-bid", response, )?; } else if buy_now { @@ -611,6 +631,7 @@ pub fn execute_update_bid( &config, &MatchingBid::Bid(bid), true, + "update-bid", response, )?; } else { @@ -730,6 +751,7 @@ pub fn execute_accept_bid( &config, &MatchingBid::Bid(bid), false, + "accept-bid", Response::new(), )?; @@ -781,6 +803,7 @@ pub fn execute_set_collection_bid( &config, &MatchingBid::CollectionBid(collection_bid), true, + "set-collection-bid", response, )?; } else if buy_now { @@ -882,6 +905,7 @@ pub fn execute_update_collection_bid( &config, &MatchingBid::CollectionBid(collection_bid), true, + "update-collection-bid", response, )?; } else { @@ -1004,6 +1028,7 @@ pub fn execute_accept_collection_bid( &config, &MatchingBid::CollectionBid(collection_bid), false, + "accept-collection-bid", Response::new(), )?; diff --git a/contracts/stargaze-marketplace-v2/src/helpers.rs b/contracts/stargaze-marketplace-v2/src/helpers.rs index 5450f38e..f1b8fa22 100644 --- a/contracts/stargaze-marketplace-v2/src/helpers.rs +++ b/contracts/stargaze-marketplace-v2/src/helpers.rs @@ -118,6 +118,7 @@ pub fn finalize_sale( config: &Config, matching_bid: &MatchingBid, ask_before_bid: bool, + action: &str, response: Response, ) -> Result { let (nft_recipient, bid_details) = match &matching_bid { @@ -204,7 +205,8 @@ pub fn finalize_sale( .add_attribute("price", sale_price.amount.to_string()) .add_attribute("seller_recipient", seller_recipient.to_string()) .add_attribute("nft_recipient", nft_recipient.to_string()) - .add_attribute("ask", ask.id.to_string()); + .add_attribute("ask", ask.id.to_string()) + .add_attribute("action", action.to_string()); match &matching_bid { MatchingBid::Bid(bid) => { From ce52e6e29419a3f8f98fa07be4a383751776a2ff Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 11 Dec 2024 22:42:29 -0600 Subject: [PATCH 2/2] fix clippy --- contracts/stargaze-marketplace-v2/src/helpers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/stargaze-marketplace-v2/src/helpers.rs b/contracts/stargaze-marketplace-v2/src/helpers.rs index f1b8fa22..3aed5650 100644 --- a/contracts/stargaze-marketplace-v2/src/helpers.rs +++ b/contracts/stargaze-marketplace-v2/src/helpers.rs @@ -111,6 +111,7 @@ pub fn divide_protocol_fees( Ok(protocol_fees) } +#[allow(clippy::too_many_arguments)] pub fn finalize_sale( deps: DepsMut, env: &Env,