mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 04:31:02 +00:00
@@ -24,12 +24,17 @@ use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// Set of test accounts with friendly names.
|
||||
/// Set of test accounts with friendly names: Alice.
|
||||
pub const ALICE: Account = Account(0);
|
||||
/// Set of test accounts with friendly names: Bob.
|
||||
pub const BOB: Account = Account(1);
|
||||
/// Set of test accounts with friendly names: Charlie.
|
||||
pub const CHARLIE: Account = Account(2);
|
||||
/// Set of test accounts with friendly names: Dave.
|
||||
pub const DAVE: Account = Account(3);
|
||||
/// Set of test accounts with friendly names: Eve.
|
||||
pub const EVE: Account = Account(4);
|
||||
/// Set of test accounts with friendly names: Ferdie.
|
||||
pub const FERDIE: Account = Account(5);
|
||||
|
||||
/// A test account which can be used to sign messages.
|
||||
@@ -37,10 +42,12 @@ pub const FERDIE: Account = Account(5);
|
||||
pub struct Account(pub u16);
|
||||
|
||||
impl Account {
|
||||
/// Returns public key of this account.
|
||||
pub fn public(&self) -> VerifyingKey {
|
||||
self.pair().verifying_key()
|
||||
}
|
||||
|
||||
/// Returns key pair, used to sign data on behalf of this account.
|
||||
pub fn pair(&self) -> SigningKey {
|
||||
let data = self.0.encode();
|
||||
let mut bytes = [0_u8; 32];
|
||||
@@ -48,6 +55,7 @@ impl Account {
|
||||
SigningKey::from_bytes(&bytes)
|
||||
}
|
||||
|
||||
/// Generate a signature of given message.
|
||||
pub fn sign(&self, msg: &[u8]) -> Signature {
|
||||
use ed25519_dalek::Signer;
|
||||
self.pair().sign(msg)
|
||||
|
||||
Reference in New Issue
Block a user