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
use serde::{Deserialize, Serialize};

use crate::Address;

/// Collection of different account types
#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub enum Account {
    /// Account controlled by a single public key
    Single {
        /// The key controlling the account
        address: Address,

        /// System wide unique identifier
        id: u64,
        /// Account level nonce.
        sequence: u64,
    },
}

impl Account {
    pub fn address(&self) -> &Address {
        match self {
            Account::Single { address, .. } => address,
        }
    }

    pub fn id(&self) -> u64 {
        match self {
            Account::Single { id, .. } => *id,
        }
    }

    pub fn sequence(&self) -> u64 {
        match self {
            Account::Single { sequence, .. } => *sequence,
        }
    }
}