From 116ff7807e71b675c1f8039e7a9405cbbc4252c7 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Mon, 3 Jun 2024 16:12:33 +0200 Subject: [PATCH] feat(law-stone): prevent contract execution with funds --- contracts/axone-law-stone/src/contract.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contracts/axone-law-stone/src/contract.rs b/contracts/axone-law-stone/src/contract.rs index ec807458..e9b15041 100644 --- a/contracts/axone-law-stone/src/contract.rs +++ b/contracts/axone-law-stone/src/contract.rs @@ -9,6 +9,7 @@ use cosmwasm_std::{ WasmMsg, }; use cw2::set_contract_version; +use cw_utils::nonpayable; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; @@ -57,6 +58,7 @@ pub fn execute( info: MessageInfo, msg: ExecuteMsg, ) -> Result { + nonpayable(&info)?; match msg { ExecuteMsg::BreakStone => execute::break_stone(deps, env, info), } @@ -291,9 +293,9 @@ mod tests { Order, OwnedDeps, SubMsgResponse, SubMsgResult, SystemError, SystemResult, WasmQuery, }; use cw_utils::ParseReplyError::SubMsgFailure; + use cw_utils::PaymentError; use std::collections::VecDeque; use std::marker::PhantomData; - use cw_utils::PaymentError; fn custom_logic_handler_with_dependencies( dependencies: Vec, @@ -867,7 +869,10 @@ mod tests { ExecuteMsg::BreakStone, ); assert!(result.is_err()); - assert_eq!(result.unwrap_err(), ContractError::Payment(PaymentError::NonPayable {})); + assert_eq!( + result.unwrap_err(), + ContractError::Payment(PaymentError::NonPayable {}) + ); } #[test]