diff --git a/shared/src/block.rs b/shared/src/block.rs index 44b81232..2d8c608c 100644 --- a/shared/src/block.rs +++ b/shared/src/block.rs @@ -388,38 +388,36 @@ impl Block { let (msg, packet_data) = data?; let denom = packet_data.token.denom.to_string(); - // If the denom is the native token, we can just return the - // receiver + let ibc_trace = format!( + "{}/{}/{}", + msg.packet.port_id_on_b, + msg.packet.chan_id_on_b, + packet_data.token.denom + ); + + let trace = Id::IbcTrace(ibc_trace.clone()); + let address = namada_ibc::trace::convert_to_address(ibc_trace) + .expect("Failed to convert IBC trace to address"); + + let mut balances = vec![BalanceChange::new( + Id::Account(String::from(packet_data.receiver.as_ref())), + Token::Ibc(IbcToken { + address: Id::from(address.clone()), + trace, + }), + )]; + + // If the denom contains the namada native token, try to fetch + // the balance if denom.contains(&native_token.to_string()) { - vec![BalanceChange::new( + balances.push(BalanceChange::new( Id::Account(String::from( packet_data.receiver.as_ref(), )), Token::Native(native_token.clone()), - )] - } else { - let ibc_trace = format!( - "{}/{}/{}", - msg.packet.port_id_on_b, - msg.packet.chan_id_on_b, - packet_data.token.denom - ); - - let trace = Id::IbcTrace(ibc_trace.clone()); - let address = - namada_ibc::trace::convert_to_address(ibc_trace) - .expect("Failed to convert IBC trace to address"); - - vec![BalanceChange::new( - Id::Account(String::from( - packet_data.receiver.as_ref(), - )), - Token::Ibc(IbcToken { - address: Id::from(address.clone()), - trace, - }), - )] + )) } + balances } TransactionKind::TransparentTransfer(data) => { let data = data.as_ref()?;