1
// Copyright 2019-2025 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
//! Transactor and call encoding helpers for XCM tests
18

            
19
// Transactor setup helpers
20

            
21
// Call encoding helpers for relay chain transactions
22
9
pub fn encode_relay_balance_transfer_call(
23
9
	dest: crate::xcm_mock::relay_chain::AccountId,
24
9
	amount: u128,
25
9
) -> Vec<u8> {
26
	use frame_support::traits::PalletInfo;
27
	use parity_scale_codec::Encode;
28

            
29
9
	let mut encoded: Vec<u8> = Vec::new();
30
9
	let index =
31
9
		<crate::xcm_mock::relay_chain::Runtime as frame_system::Config>::PalletInfo::index::<
32
9
			crate::xcm_mock::relay_chain::Balances,
33
9
		>()
34
9
		.unwrap() as u8;
35
9

            
36
9
	encoded.push(index);
37
9

            
38
9
	let mut call_bytes =
39
9
		pallet_balances::Call::<crate::xcm_mock::relay_chain::Runtime>::transfer_allow_death {
40
9
			dest,
41
9
			value: amount.into(),
42
9
		}
43
9
		.encode();
44
9

            
45
9
	encoded.append(&mut call_bytes);
46
9
	encoded
47
9
}