Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,43 @@ where
|| channel.para_id != channel_info.para_id
|| channel.agent_id != channel_info.agent_id
{
log::debug!(
"Unexpected channel id: {:?} != {:?}",
(envelope.channel_id, channel.para_id, channel.agent_id),
(
channel_info.channel_id,
channel_info.para_id,
channel_info.agent_id
)
);
return false;
}
} else {
log::warn!("CurrentChannelInfo not set in storage");
return false;
}

// Check it is from the right gateway
if envelope.gateway != T::GatewayAddress::get() {
log::warn!("Wrong gateway address: {:?}", envelope.gateway);
return false;
}

if let Some(eth_transfer_data) =
Self::decode_message_for_eth_transfer(envelope.payload.as_slice())
{
// Check if the token location is a foreign asset included in ForeignAssetCreator
return pallet_foreign_asset_creator::ForeignAssetToAssetId::<Runtime>::get(
eth_transfer_data.token_location,
)
.is_some();
let asset_id_exists =
pallet_foreign_asset_creator::ForeignAssetToAssetId::<Runtime>::get(
&eth_transfer_data.token_location,
)
.is_some();

if !asset_id_exists {
log::warn!("EthTokensLocalProcessor: location not found in ForeignAssetToAssetId map: {:?}", eth_transfer_data.token_location);
}

return asset_id_exists;
}

false
Expand All @@ -217,6 +235,8 @@ where
let eth_transfer_data = Self::decode_message_for_eth_transfer(envelope.payload.as_slice())
.ok_or(DispatchError::Other("unexpected message"))?;

log::trace!("EthTokensLocalProcessor: {:?}", eth_transfer_data);

match eth_transfer_data.destination {
Destination::AccountId32 { id: _ } => {
Self::process_xcm_local_native_eth_transfer(eth_transfer_data)
Expand All @@ -231,6 +251,7 @@ where
}

/// Information needed to process an eth transfer message or check its validity.
#[derive(Debug)]
pub struct EthTransferData {
token_location: Location,
destination: Destination,
Expand Down Expand Up @@ -284,7 +305,14 @@ where
amount,
})
}
_ => None,
Ok(msg) => {
log::trace!("EthTokensLocalProcessor: unexpected message: {:?}", msg);
None
}
Err(e) => {
log::trace!("EthTokensLocalProcessor: failed to decode message. This is expected if the message is not for this processor. Error: {:?}", e);
None
}
}
}

Expand Down
Loading