1
// Copyright 2025 Moonbeam foundation
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
//! # Stagenet bridge primitives
18

            
19
use bp_bridge_hub_cumulus::{
20
	BlockLength, BlockWeights, Hasher, Nonce, MAX_BRIDGE_HUB_HEADER_SIZE,
21
	MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
22
};
23
use bp_messages::{ChainWithMessages, MessageNonce, Weight};
24
use bp_runtime::{Chain, ChainId, Parachain};
25
use frame_support::dispatch::DispatchClass;
26
use sp_runtime::StateVersion;
27

            
28
pub use moonbeam_core_primitives::{AccountId, Balance, BlockNumber, Hash, Header, Signature};
29

            
30
pub const PARACHAIN_ID: u32 = 1000;
31
/// Name of the messages pallet instance that is deployed at bridged chains.
32
pub const WITH_BRIDGE_MESSAGES_PALLET_NAME: &str = "BridgeMessages";
33

            
34
/// Stagenet parachain.
35
pub struct Stagenet;
36

            
37
impl Chain for Stagenet {
38
	const ID: ChainId = *b"stgn";
39

            
40
	type BlockNumber = BlockNumber;
41
	type Hash = Hash;
42
	type Hasher = Hasher;
43
	type Header = Header;
44

            
45
	type AccountId = AccountId;
46
	type Balance = Balance;
47
	type Nonce = Nonce;
48
	type Signature = Signature;
49

            
50
	const STATE_VERSION: StateVersion = StateVersion::V1;
51

            
52
	fn max_extrinsic_size() -> u32 {
53
		*BlockLength::get().max.get(DispatchClass::Normal)
54
	}
55

            
56
	fn max_extrinsic_weight() -> Weight {
57
		BlockWeights::get()
58
			.get(DispatchClass::Normal)
59
			.max_extrinsic
60
			.unwrap_or(Weight::MAX)
61
	}
62
}
63

            
64
impl Parachain for Stagenet {
65
	const PARACHAIN_ID: u32 = PARACHAIN_ID;
66
	const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
67
}
68

            
69
impl ChainWithMessages for Stagenet {
70
	const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = WITH_BRIDGE_MESSAGES_PALLET_NAME;
71

            
72
	const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
73
		MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
74
	const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
75
		MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
76
}