xcm_docs/cookbook/relay_token_transactor/relay_chain/
mod.rs1use frame::{
21 deps::{frame_support::weights::WeightMeter, sp_runtime::AccountId32},
22 prelude::*,
23 runtime::prelude::*,
24 traits::{IdentityLookup, ProcessMessage, ProcessMessageError},
25};
26use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
27use xcm::latest::prelude::*;
28
29mod xcm_config;
30pub use xcm_config::LocationToAccountId;
31use xcm_config::XcmConfig;
32
33pub type AccountId = AccountId32;
34pub type Balance = u64;
35
36parameter_types! {
37 pub const BlockHashCount: u64 = 250;
38}
39
40#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
41impl frame_system::Config for Runtime {
42 type AccountId = AccountId;
43 type Lookup = IdentityLookup<Self::AccountId>;
44 type Block = Block;
45 type AccountData = pallet_balances::AccountData<Balance>;
46}
47
48#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
49impl pallet_balances::Config for Runtime {
50 type AccountStore = System;
51}
52
53type Block = frame_system::mocking::MockBlock<Runtime>;
54
55parameter_types! {
56 pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000);
58 pub const MessageQueueHeapSize: u32 = 65_536;
59 pub const MessageQueueMaxStale: u32 = 16;
60}
61
62pub struct MessageProcessor;
64impl ProcessMessage for MessageProcessor {
65 type Origin = AggregateMessageOrigin;
66
67 fn process_message(
68 message: &[u8],
69 origin: Self::Origin,
70 meter: &mut WeightMeter,
71 id: &mut [u8; 32],
72 ) -> Result<bool, ProcessMessageError> {
73 let para = match origin {
74 AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
75 };
76 xcm_builder::ProcessXcmMessage::<
77 Junction,
78 xcm_executor::XcmExecutor<XcmConfig>,
79 RuntimeCall,
80 >::process_message(message, Junction::Parachain(para.into()), meter, id)
81 }
82}
83
84impl pallet_message_queue::Config for Runtime {
85 type RuntimeEvent = RuntimeEvent;
86 type Size = u32;
87 type HeapSize = MessageQueueHeapSize;
88 type MaxStale = MessageQueueMaxStale;
89 type ServiceWeight = MessageQueueServiceWeight;
90 type MessageProcessor = MessageProcessor;
91 type QueueChangeHandler = ();
92 type QueuePausedQuery = ();
93 type WeightInfo = ();
94 type IdleMaxServiceWeight = MessageQueueServiceWeight;
95}
96
97construct_runtime! {
98 pub struct Runtime {
99 System: frame_system,
100 Balances: pallet_balances,
101 MessageQueue: pallet_message_queue,
102 XcmPallet: pallet_xcm,
103 }
104}