Skip to content

Commit

Permalink
Refactor key pair implementations
Browse files Browse the repository at this point in the history
This commit refactors the key pair implementations, adding a `KeyFile` type for each one.
  • Loading branch information
DaviRain-Su committed Aug 26, 2023
1 parent c44d2b1 commit 7e506cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/relayer/src/keyring/ed25519_key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl Ed25519KeyPair {

impl SigningKeyPair for Ed25519KeyPair {
const KEY_TYPE: KeyType = KeyType::Ed25519;
type KeyFile = KeyFile;

fn from_key_file(key_file: KeyFile, hd_path: &StandardHDPath) -> Result<Self, Error> {
use ed25519_dalek::PUBLIC_KEY_LENGTH;
Expand Down
1 change: 1 addition & 0 deletions crates/relayer/src/keyring/secp256k1_key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ impl Secp256k1KeyPair {

impl SigningKeyPair for Secp256k1KeyPair {
const KEY_TYPE: KeyType = KeyType::Secp256k1;
type KeyFile = KeyFile;

fn from_key_file(key_file: KeyFile, hd_path: &StandardHDPath) -> Result<Self, Error> {
// Decode the Bech32-encoded address from the key file
Expand Down
5 changes: 3 additions & 2 deletions crates/relayer/src/keyring/signing_key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ use core::any::Any;
use hdpath::StandardHDPath;
use serde::{de::DeserializeOwned, Serialize};

use super::{errors::Error, KeyFile, KeyType};
use super::{errors::Error, KeyType};
use crate::config::AddressType;

pub trait SigningKeyPair {
const KEY_TYPE: KeyType;
type KeyFile: DeserializeOwned;

fn from_key_file(key_file: KeyFile, hd_path: &StandardHDPath) -> Result<Self, Error>
fn from_key_file(key_file: Self::KeyFile, hd_path: &StandardHDPath) -> Result<Self, Error>
where
Self: Sized;

Expand Down

0 comments on commit 7e506cd

Please sign in to comment.