@@ -7,17 +7,17 @@ use andromeda_std::{
77 InstantiateMsg as BaseInstantiateMsg , MigrateMsg ,
88 } ,
99 ado_contract:: ADOContract ,
10+ andr_execute_fn,
1011 common:: { context:: ExecuteContext , deduct_funds, encode_binary, Funds } ,
1112 error:: ContractError ,
1213} ;
1314
1415use cosmwasm_std:: {
15- attr, coin, ensure , Binary , Coin , Deps , DepsMut , Env , Event , MessageInfo , Reply , Response ,
16- StdError , SubMsg ,
16+ attr, coin, Binary , Coin , Deps , DepsMut , Env , Event , MessageInfo , Reply , Response , StdError ,
17+ SubMsg ,
1718} ;
1819use cosmwasm_std:: { entry_point, from_json} ;
1920use cw20:: Cw20Coin ;
20- use cw_utils:: nonpayable;
2121// version info for migration info
2222const CONTRACT_NAME : & str = "crates.io:andromeda-rates" ;
2323const CONTRACT_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -52,24 +52,8 @@ pub fn instantiate(
5252 Ok ( inst_resp)
5353}
5454
55- #[ cfg_attr( not( feature = "library" ) , entry_point) ]
56- pub fn execute (
57- deps : DepsMut ,
58- env : Env ,
59- info : MessageInfo ,
60- msg : ExecuteMsg ,
61- ) -> Result < Response , ContractError > {
62- let ctx = ExecuteContext :: new ( deps, info, env) ;
63-
64- match msg {
65- ExecuteMsg :: AMPReceive ( pkt) => {
66- ADOContract :: default ( ) . execute_amp_receive ( ctx, pkt, handle_execute)
67- }
68- _ => handle_execute ( ctx, msg) ,
69- }
70- }
71-
72- pub fn handle_execute ( ctx : ExecuteContext , msg : ExecuteMsg ) -> Result < Response , ContractError > {
55+ #[ andr_execute_fn]
56+ pub fn execute ( ctx : ExecuteContext , msg : ExecuteMsg ) -> Result < Response , ContractError > {
7357 match msg {
7458 ExecuteMsg :: SetRate { action, rate } => execute_set_rate ( ctx, action, rate) ,
7559 ExecuteMsg :: RemoveRate { action } => execute_remove_rate ( ctx, action) ,
@@ -82,13 +66,8 @@ fn execute_set_rate(
8266 action : String ,
8367 rate : LocalRate ,
8468) -> Result < Response , ContractError > {
85- let ExecuteContext { deps, info, .. } = ctx;
86- nonpayable ( & info) ?;
69+ let ExecuteContext { deps, .. } = ctx;
8770
88- ensure ! (
89- ADOContract :: default ( ) . is_contract_owner( deps. storage, info. sender. as_str( ) ) ?,
90- ContractError :: Unauthorized { }
91- ) ;
9271 rate. validate ( deps. as_ref ( ) ) ?;
9372
9473 RATES . save ( deps. storage , & action, & rate) ?;
@@ -97,13 +76,8 @@ fn execute_set_rate(
9776}
9877
9978fn execute_remove_rate ( ctx : ExecuteContext , action : String ) -> Result < Response , ContractError > {
100- let ExecuteContext { deps, info, .. } = ctx;
101- nonpayable ( & info) ?;
79+ let ExecuteContext { deps, .. } = ctx;
10280
103- ensure ! (
104- ADOContract :: default ( ) . is_contract_owner( deps. storage, info. sender. as_str( ) ) ?,
105- ContractError :: Unauthorized { }
106- ) ;
10781 if RATES . has ( deps. storage , & action) {
10882 RATES . remove ( deps. storage , & action) ;
10983 Ok ( Response :: new ( ) . add_attributes ( vec ! [ attr( "action" , "remove_rates" ) ] ) )
0 commit comments