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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::wallet::Wallet;
use chain_crypto::{RistrettoGroup2HashDh, SumEd25519_12};
use chain_impl_mockchain::{
    certificate::PoolRegistration, testing::data::StakePool as StakePoolLib,
};
use jormungandr_automation::utils::StakePool as InnerStakePool;
use jormungandr_lib::crypto::key::KeyPair;

#[derive(Clone, Debug)]
pub struct StakePool {
    inner: InnerStakePool,
    owner: Wallet,
}

impl StakePool {
    pub fn new(owner: &Wallet) -> Self {
        Self {
            owner: owner.clone(),
            inner: InnerStakePool::new(&owner.identifier()),
        }
    }

    pub fn info_mut(&mut self) -> &mut PoolRegistration {
        self.inner.info_mut()
    }

    pub fn vrf(&self) -> KeyPair<RistrettoGroup2HashDh> {
        self.inner().vrf()
    }

    pub fn kes(&self) -> KeyPair<SumEd25519_12> {
        self.inner().kes()
    }

    pub fn id(&self) -> chain_impl_mockchain::certificate::PoolId {
        self.inner.id()
    }

    pub fn owner(&self) -> &Wallet {
        &self.owner
    }

    pub fn inner(&self) -> &InnerStakePool {
        &self.inner
    }
    pub fn inner_mut(&mut self) -> &mut InnerStakePool {
        &mut self.inner
    }
}

impl From<StakePool> for StakePoolLib {
    fn from(stake_pool: StakePool) -> StakePoolLib {
        stake_pool.inner.into()
    }
}