Skip to content

Commit 709712d

Browse files
authored
Merge pull request #17 from oraichain/fix/remove-check-forward
removed check forward & forward channel mapping
2 parents 719ae24 + d06b990 commit 709712d

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

contracts/cw-ics20-latest/src/ibc.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result<Response, Contrac
150150
&reply_args.channel,
151151
&reply_args.denom,
152152
reply_args.amount,
153-
false,
154153
)?;
155154

156155
let sub_msg = handle_packet_refund(
@@ -1066,13 +1065,7 @@ fn on_packet_failure(
10661065

10671066
let sub_msg = handle_packet_refund(deps.storage, &msg.sender, &msg.denom, msg.amount)?;
10681067
// since we reduce the channel's balance optimistically when transferring back, we undo reduce it again when receiving failed ack
1069-
undo_reduce_channel_balance(
1070-
deps.storage,
1071-
&packet.src.channel_id,
1072-
&msg.denom,
1073-
msg.amount,
1074-
false,
1075-
)?;
1068+
undo_reduce_channel_balance(deps.storage, &packet.src.channel_id, &msg.denom, msg.amount)?;
10761069

10771070
let res = IbcBasicResponse::new()
10781071
.add_submessage(sub_msg)

contracts/cw-ics20-latest/src/state.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub const CHANNEL_REVERSE_STATE: Map<(&str, &str), ChannelState> =
2727
Map::new("channel_reverse_state");
2828

2929
/// Reverse channel state is used when LOCAL chain initiates ibc transfer to remote chain
30-
pub const CHANNEL_FORWARD_STATE: Map<(&str, &str), ChannelState> =
31-
Map::new("channel_forward_state");
30+
// pub const CHANNEL_FORWARD_STATE: Map<(&str, &str), ChannelState> =
31+
// Map::new("channel_forward_state");
3232

3333
/// Every cw20 contract we allow to be sent is stored here, possibly with a gas_limit
3434
pub const ALLOW_LIST: Map<&Addr, AllowInfo> = Map::new("allow_list");
@@ -143,8 +143,7 @@ pub fn increase_channel_balance(
143143
denom: &str, // should be ibc denom
144144
amount: Uint128,
145145
) -> Result<(), ContractError> {
146-
let state = CHANNEL_REVERSE_STATE;
147-
state.update(storage, (channel, denom), |orig| -> StdResult<_> {
146+
CHANNEL_REVERSE_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> {
148147
let mut state = orig.unwrap_or_default();
149148
state.outstanding += amount;
150149
state.total_sent += amount;
@@ -159,8 +158,7 @@ pub fn reduce_channel_balance(
159158
denom: &str, // should be ibc denom
160159
amount: Uint128,
161160
) -> Result<(), ContractError> {
162-
let state = CHANNEL_REVERSE_STATE;
163-
state.update(
161+
CHANNEL_REVERSE_STATE.update(
164162
storage,
165163
(channel, denom),
166164
|orig| -> Result<_, ContractError> {
@@ -190,8 +188,7 @@ pub fn override_channel_balance(
190188
outstanding: Uint128,
191189
total_sent: Option<Uint128>,
192190
) -> Result<(), ContractError> {
193-
let state = CHANNEL_REVERSE_STATE;
194-
state.update(storage, (channel, denom), |orig| -> StdResult<_> {
191+
CHANNEL_REVERSE_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> {
195192
let mut state = orig.unwrap_or_default();
196193
state.outstanding = outstanding;
197194
if let Some(total_sent) = total_sent {
@@ -209,13 +206,8 @@ pub fn undo_reduce_channel_balance(
209206
channel: &str,
210207
denom: &str,
211208
amount: Uint128,
212-
forward: bool,
213209
) -> Result<(), ContractError> {
214-
let mut state = CHANNEL_REVERSE_STATE;
215-
if forward {
216-
state = CHANNEL_FORWARD_STATE;
217-
}
218-
state.update(storage, (channel, denom), |orig| -> StdResult<_> {
210+
CHANNEL_REVERSE_STATE.update(storage, (channel, denom), |orig| -> StdResult<_> {
219211
let mut state = orig.unwrap_or_default();
220212
state.outstanding += amount;
221213
Ok(state)

0 commit comments

Comments
 (0)