domain_test_service/
keyring.rs1use fp_account::AccountId20;
3use sp_core::ecdsa::{Pair, Public, Signature};
4use sp_core::{ecdsa, keccak_256, Pair as PairT};
5
6#[allow(missing_docs)]
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum Keyring {
9 Alice,
10 Bob,
11 Charlie,
12 Dave,
13 Eve,
14 Ferdie,
15 One,
16 Two,
17}
18
19impl Keyring {
20 pub fn sign(self, msg: &[u8]) -> Signature {
22 let msg = keccak_256(msg);
23 self.pair().sign_prehashed(&msg)
24 }
25
26 pub fn pair(self) -> Pair {
28 ecdsa::Pair::from_string(self.to_seed().as_str(), None).unwrap()
29 }
30
31 pub fn public(self) -> Public {
33 self.pair().public()
34 }
35
36 pub fn to_seed(self) -> String {
38 format!("//{:?}", self)
39 }
40
41 pub fn to_account_id(self) -> AccountId20 {
43 self.public().into()
44 }
45}