@@ -10,15 +10,18 @@ use andromeda_finance::{
10
10
} ;
11
11
use andromeda_std:: {
12
12
ado_base:: { InstantiateMsg as BaseInstantiateMsg , MigrateMsg } ,
13
- amp:: { messages:: AMPPkt , Recipient } ,
13
+ amp:: {
14
+ messages:: { AMPMsg , AMPPkt } ,
15
+ Recipient ,
16
+ } ,
14
17
andr_execute_fn,
15
18
common:: { encode_binary, expiration:: Expiry , Milliseconds } ,
16
19
error:: ContractError ,
17
20
} ;
18
21
use andromeda_std:: { ado_contract:: ADOContract , common:: context:: ExecuteContext } ;
19
22
use cosmwasm_std:: {
20
- attr, coin, coins, ensure, entry_point, from_json, Binary , Coin , Deps , DepsMut , Env ,
21
- MessageInfo , Reply , Response , StdError , SubMsg , Uint128 ,
23
+ attr, coin, coins, ensure, entry_point, from_json, to_json_binary , Binary , Coin , Deps , DepsMut ,
24
+ Env , MessageInfo , Reply , Response , StdError , SubMsg , Uint128 ,
22
25
} ;
23
26
use cw20:: { Cw20Coin , Cw20ReceiveMsg } ;
24
27
@@ -105,7 +108,7 @@ pub fn handle_receive_cw20(
105
108
let ExecuteContext { ref info, .. } = ctx;
106
109
let asset_sent = info. sender . clone ( ) . into_string ( ) ;
107
110
let amount_sent = receive_msg. amount ;
108
- let sender = receive_msg. sender ;
111
+ let sender = receive_msg. sender . clone ( ) ;
109
112
110
113
ensure ! (
111
114
!amount_sent. is_zero( ) ,
@@ -118,6 +121,17 @@ pub fn handle_receive_cw20(
118
121
Cw20HookMsg :: Send { config } => {
119
122
execute_send_cw20 ( ctx, sender, amount_sent, asset_sent, config)
120
123
}
124
+ Cw20HookMsg :: AmpReceive ( mut packet) => {
125
+ let msg = to_json_binary ( & ExecuteMsg :: Receive ( Cw20ReceiveMsg {
126
+ sender : sender. clone ( ) ,
127
+ amount : amount_sent,
128
+ msg : to_json_binary ( & Cw20HookMsg :: Send { config : None } ) ?,
129
+ } ) ) ?;
130
+ let funds = packet. messages [ 0 ] . funds . clone ( ) ;
131
+ let recipient = packet. messages [ 0 ] . recipient . clone ( ) ;
132
+ packet. messages = vec ! [ AMPMsg :: new( recipient, msg, Some ( funds) ) ] ;
133
+ execute ( ctx. deps , ctx. env , ctx. info , ExecuteMsg :: AMPReceive ( packet) )
134
+ }
121
135
}
122
136
}
123
137
0 commit comments