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
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! Moonbeam utilities

use std::collections::BTreeMap;

use k256::SecretKey;

/// Returns the private developer keys https://docs.moonbeam.network/snippets/code/setting-up-node/dev-accounts/
pub fn dev_keys() -> Vec<SecretKey> {
    MoonbeamDev::default().into_keys().collect()
}

/// Holds private developer keys with their names
#[derive(Debug, Clone)]
pub struct MoonbeamDev {
    keys: BTreeMap<&'static str, SecretKey>,
}

impl MoonbeamDev {
    pub fn keys(&self) -> impl Iterator<Item = &SecretKey> {
        self.keys.values()
    }

    pub fn into_keys(self) -> impl Iterator<Item = SecretKey> {
        self.keys.into_values()
    }

    /// Get a key by then, like `Alith`
    pub fn get(&self, name: impl AsRef<str>) -> Option<&SecretKey> {
        self.keys.get(name.as_ref())
    }

    pub fn alith(&self) -> &SecretKey {
        self.get("Alith").unwrap()
    }

    pub fn baltathar(&self) -> &SecretKey {
        self.get("Baltathar").unwrap()
    }

    pub fn charleth(&self) -> &SecretKey {
        self.get("Charleth").unwrap()
    }

    pub fn ethan(&self) -> &SecretKey {
        self.get("Ethan").unwrap()
    }
}

impl Default for MoonbeamDev {
    fn default() -> Self {
        Self {
            keys: BTreeMap::from([
                (
                    "Alith",
                    SecretKey::from_bytes(
                        hex::decode(
                            "5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Baltathar",
                    SecretKey::from_bytes(
                        hex::decode(
                            "8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Charleth",
                    SecretKey::from_bytes(
                        hex::decode(
                            "0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Dorothy",
                    SecretKey::from_bytes(
                        hex::decode(
                            "39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Faith",
                    SecretKey::from_bytes(
                        hex::decode(
                            "b9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Goliath",
                    SecretKey::from_bytes(
                        hex::decode(
                            "96b8a38e12e1a31dee1eab2fffdf9d9990045f5b37e44d8cc27766ef294acf18",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Heath",
                    SecretKey::from_bytes(
                        hex::decode(
                            "0d6dcaaef49272a5411896be8ad16c01c35d6f8c18873387b71fbc734759b0ab",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Ida",
                    SecretKey::from_bytes(
                        hex::decode(
                            "4c42532034540267bf568198ccec4cb822a025da542861fcb146a5fab6433ff8",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
                (
                    "Judith",
                    SecretKey::from_bytes(
                        hex::decode(
                            "94c49300a58d576011096bcb006aa06f5a91b34b4383891e8029c21dc39fbb8b",
                        )
                        .unwrap(),
                    )
                    .unwrap(),
                ),
            ]),
        }
    }
}