IBC transfer not according to spec
The data packet for an ICS20 transfer is defined as such:
interface FungibleTokenPacketData {
denom: string
amount: uint256
sender: string
receiver: string
memo: string
}
However, the ICS20 transfer code is defined as such, failing if the packet_data
is too large for a u128
due to overflow. This is something to be aware of, as a valid ICS20 transfer may fail.
#[allow(clippy::too_many_lines)]
async fn execute_ics20_transfer<S: StateWriteExt>(
state: &mut S,
data: &[u8],
source_port: &PortId,
source_channel: &ChannelId,
dest_port: &PortId,
dest_channel: &ChannelId,
is_refund: bool,
) -> Result<()> {
let packet_data: FungibleTokenPacketData =
serde_json::from_slice(data).context("failed to decode FungibleTokenPacketData")?;
let packet_amount: u128 = packet_data
.amount
.parse()
.context("failed to parse packet data amount to u128")?;
...
}