Skip to content

Commit

Permalink
fix(eos): <- use internal key parsing with defaults when creating pro…
Browse files Browse the repository at this point in the history
…ducer schedule
  • Loading branch information
gskapka committed Feb 16, 2024
1 parent e88a54f commit 3d427e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions common/eos/src/eos_crypto/eos_public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use common::{
errors::AppError,
types::{Byte, Bytes, Result},
};
use eos_chain::{PublicKey as EosCratePublicKey, UnsignedInt};
use secp256k1::{
self,
key::{PublicKey, SecretKey},
Expand All @@ -18,6 +19,15 @@ use crate::{
eos_hash::ripemd160,
};

impl From<EosPublicKey> for EosCratePublicKey {
fn from(pub_key: EosPublicKey) -> EosCratePublicKey {
EosCratePublicKey {
type_: UnsignedInt::default(),
data: pub_key.public_key.serialize(),
}
}
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct EosPublicKey {
pub compressed: bool,
Expand Down
3 changes: 2 additions & 1 deletion common/eos/src/eos_producer_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ fn convert_keys_json_to_vec_of_eos_keys(keys_json: &[ProducerKeyJsonV2]) -> comm
}

fn convert_key_json_to_eos_key(key_json: &ProducerKeyJsonV2) -> common::Result<EosKey> {
let internal_eos_pub_key = crate::eos_crypto::eos_public_key::EosPublicKey::from_str(&key_json.key)?;
Ok(EosKey {
weight: key_json.weight,
key: EosPublicKey::from_str(&key_json.key)?,
key: internal_eos_pub_key.into(),
})
}

Expand Down

0 comments on commit 3d427e0

Please sign in to comment.