|
1 |
| -use std::ops::Div; |
2 |
| - |
| 1 | +use cw20_ics20_msg::DelegateCw20Msg; |
3 | 2 | use schemars::JsonSchema;
|
4 | 3 | use serde::{Deserialize, Serialize};
|
5 | 4 |
|
6 | 5 | use cosmwasm_schema::cw_serde;
|
7 | 6 | use cosmwasm_std::{
|
8 |
| - attr, entry_point, from_binary, to_binary, Addr, BankMsg, Binary, CosmosMsg, Decimal, Deps, |
9 |
| - DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, |
10 |
| - IbcChannelOpenMsg, IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, |
11 |
| - IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, Storage, SubMsg, SubMsgResult, |
12 |
| - Uint128, WasmMsg, |
| 7 | + attr, entry_point, from_binary, to_binary, Addr, BankMsg, Binary, CosmosMsg, Deps, DepsMut, |
| 8 | + Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, |
| 9 | + IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, |
| 10 | + IbcReceiveResponse, Reply, Response, Storage, SubMsg, SubMsgResult, Uint128, WasmMsg, |
13 | 11 | };
|
14 | 12 |
|
15 |
| -use crate::amount::Amount; |
16 | 13 | use crate::error::{ContractError, Never};
|
17 | 14 | use crate::state::{
|
18 | 15 | get_key_ics20_ibc_denom, increase_channel_balance, reduce_channel_balance,
|
19 | 16 | undo_reduce_channel_balance, ChannelInfo, ReplyArgs, ALLOW_LIST, CHANNEL_INFO, CONFIG,
|
20 | 17 | CW20_ISC20_DENOM, NATIVE_ALLOW_LIST, REPLY_ARGS,
|
21 | 18 | };
|
22 | 19 | use cw20::Cw20ExecuteMsg;
|
| 20 | +use cw20_ics20_msg::amount::Amount; |
23 | 21 |
|
24 | 22 | pub const ICS20_VERSION: &str = "ics20-1";
|
25 | 23 | pub const ICS20_ORDERING: IbcOrder = IbcOrder::Unordered;
|
@@ -325,14 +323,20 @@ fn handle_ibc_packet_receive_native_remote_chain(
|
325 | 323 | return Err(ContractError::CustomContractRevoked {});
|
326 | 324 | }
|
327 | 325 |
|
328 |
| - let to_send = Amount::from_parts( |
329 |
| - cw20_mapping.cw20_denom, |
330 |
| - msg.amount.div(Uint128::from( |
331 |
| - 10u64.pow((cw20_mapping.remote_decimals - 6) as u32), // TODO: get cw20 decimal instead of hardcode. Also, need to check safe sub to prevent negative |
332 |
| - )), |
333 |
| - ); |
334 |
| - |
335 |
| - let cosmos_msg = send_amount(to_send, msg.receiver.clone(), Some(packet.data.clone())); |
| 326 | + let to_send = Amount::from_parts(cw20_mapping.cw20_denom, msg.amount); |
| 327 | + |
| 328 | + // send token to the custom contract for further handling |
| 329 | + let cosmos_msg: CosmosMsg = WasmMsg::Execute { |
| 330 | + contract_addr: msg.receiver.clone(), |
| 331 | + msg: to_binary(&DelegateCw20Msg { |
| 332 | + token: to_send, |
| 333 | + from_decimals: cw20_mapping.remote_decimals, |
| 334 | + data: packet.data.clone(), |
| 335 | + }) |
| 336 | + .unwrap(), |
| 337 | + funds: vec![], |
| 338 | + } |
| 339 | + .into(); |
336 | 340 | let sub_msg = SubMsg::new(cosmos_msg);
|
337 | 341 |
|
338 | 342 | let res = IbcReceiveResponse::new()
|
|
0 commit comments