1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::space::Space;
use rlp_derive::{RlpDecodable, RlpEncodable};

#[derive(
    Default, Copy, Clone, Debug, Eq, PartialEq, RlpEncodable, RlpDecodable,
)]
pub struct AllChainID {
    native: u32,
    ethereum: u32,
}

impl AllChainID {
    pub fn new(native: u32, ethereum: u32) -> Self { Self { native, ethereum } }

    pub fn fake_for_virtual(chain_id: u32) -> Self {
        Self {
            native: chain_id,
            ethereum: chain_id,
        }
    }

    pub fn in_space(&self, space: Space) -> u32 {
        match space {
            Space::Native => self.native,
            Space::Ethereum => self.ethereum,
        }
    }

    pub fn in_native_space(&self) -> u32 { self.in_space(Space::Native) }

    pub fn in_evm_space(&self) -> u32 { self.in_space(Space::Ethereum) }
}