Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion domains/pallets/transporter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub use weights::WeightInfo;
/// Zero EVM address.
/// Used to ensure dst_account is not ZERO address.
const ZERO_EVM_ADDRESS: MultiAccountId = MultiAccountId::AccountId20([0; 20]);
const ZERO_SUBSTRATE_ADDRESS: MultiAccountId = MultiAccountId::AccountId32([0; 32]);

/// Location that either sends or receives transfers between chains.
#[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo, DecodeWithMemTracking)]
Expand Down Expand Up @@ -83,7 +84,7 @@ mod pallet {
use crate::weights::WeightInfo;
use crate::{
BalanceOf, Location, MessageIdOf, MultiAccountId, Transfer, TryConvertBack,
ZERO_EVM_ADDRESS,
ZERO_EVM_ADDRESS, ZERO_SUBSTRATE_ADDRESS,
};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
Expand Down Expand Up @@ -265,6 +266,11 @@ mod pallet {
Error::<T>::InvalidAccountId
);

ensure!(
dst_location.account_id != ZERO_SUBSTRATE_ADDRESS,
Error::<T>::InvalidAccountId
);

// burn transfer amount
let _imbalance = T::Currency::withdraw(
&sender,
Expand Down
17 changes: 17 additions & 0 deletions domains/pallets/transporter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ fn test_transfer_invalid_account_id() {
})
}

#[test]
fn test_transfer_invalid_account_id_substrate() {
new_test_ext().execute_with(|| {
let account = USER_ACCOUNT;
let amount: Balance = 500;
// transfer 500 to dst_chain id 100
let dst_chain_id: ChainId = 1.into();
let dst_location = Location {
chain_id: dst_chain_id,
account_id: MultiAccountId::AccountId32([0; 32]),
};

let res = Transporter::transfer(RuntimeOrigin::signed(account), dst_location, amount);
assert_err!(res, Error::<MockRuntime>::InvalidAccountId)
})
}

#[test]
fn test_transfer_response_revert() {
new_test_ext().execute_with(|| {
Expand Down
Loading