fix session keys order
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
11eca462a4
commit
ee23e6ba64
@ -2,7 +2,7 @@
|
|||||||
name = "ghost-eye"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
|||||||
@ -67,13 +67,13 @@ impl RotatePopup {
|
|||||||
|
|
||||||
fn parse_session_keys(&self) -> (String, String, String, String, String) {
|
fn parse_session_keys(&self) -> (String, String, String, String, String) {
|
||||||
if !self.cached_keys.is_empty() && self.cached_keys.len() == 322 {
|
if !self.cached_keys.is_empty() && self.cached_keys.len() == 322 {
|
||||||
let gran_key = format!("0x{}", &self.cached_keys[2..66]);
|
let babe_key = format!("0x{}", &self.cached_keys[2..66]);
|
||||||
let babe_key = format!("0x{}", &self.cached_keys[66..130]);
|
let gran_key = format!("0x{}", &self.cached_keys[66..130]);
|
||||||
let audi_key = format!("0x{}", &self.cached_keys[130..194]);
|
let audi_key = format!("0x{}", &self.cached_keys[130..194]);
|
||||||
let wevr_key = format!("0x{}", &self.cached_keys[194..258]);
|
let wevr_key = format!("0x{}", &self.cached_keys[194..258]);
|
||||||
let exds_key = format!("0x{}", &self.cached_keys[258..322]);
|
let exds_key = format!("0x{}", &self.cached_keys[258..322]);
|
||||||
|
|
||||||
(gran_key, babe_key, audi_key, wevr_key, exds_key)
|
(babe_key, gran_key, audi_key, wevr_key, exds_key)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
String::from("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
String::from("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
@ -145,18 +145,18 @@ impl Component for RotatePopup {
|
|||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||||
if self.is_active {
|
if self.is_active {
|
||||||
let (border_style, border_type) = self.palette.create_popup_style();
|
let (border_style, border_type) = self.palette.create_popup_style();
|
||||||
let (gran_key, babe_key, audi_key, wevr_key, exds_key) = self.parse_session_keys();
|
let (babe_key, gran_key, audi_key, wevr_key, exds_key) = self.parse_session_keys();
|
||||||
|
|
||||||
let table = Table::new(
|
let table = Table::new(
|
||||||
vec![
|
vec![
|
||||||
Row::new(vec![
|
|
||||||
Cell::from(Text::from("gran".to_string()).alignment(Alignment::Left)),
|
|
||||||
Cell::from(Text::from(gran_key).alignment(Alignment::Right)),
|
|
||||||
]),
|
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("babe".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("babe".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(babe_key).alignment(Alignment::Right)),
|
Cell::from(Text::from(babe_key).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
|
Row::new(vec![
|
||||||
|
Cell::from(Text::from("gran".to_string()).alignment(Alignment::Left)),
|
||||||
|
Cell::from(Text::from(gran_key).alignment(Alignment::Right)),
|
||||||
|
]),
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("audi".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("audi".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(audi_key).alignment(Alignment::Right)),
|
Cell::from(Text::from(audi_key).alignment(Alignment::Right)),
|
||||||
|
|||||||
@ -238,21 +238,21 @@ pub async fn get_session_keys(
|
|||||||
account_id: &[u8; 32],
|
account_id: &[u8; 32],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let maybe_session_keys = super::raw_calls::session::next_keys(api, None, account_id).await?;
|
let maybe_session_keys = super::raw_calls::session::next_keys(api, None, account_id).await?;
|
||||||
let (gran_key, babe_key, audi_key, wevr_key, exds_key) = match maybe_session_keys {
|
let (babe_key, gran_key, audi_key, wevr_key, exds_key) = match maybe_session_keys {
|
||||||
Some(session_keys) => {
|
Some(session_keys) => {
|
||||||
let gran_key = format!("0x{}", hex::encode(session_keys.grandpa.0));
|
|
||||||
let babe_key = format!("0x{}", hex::encode(session_keys.babe.0));
|
let babe_key = format!("0x{}", hex::encode(session_keys.babe.0));
|
||||||
|
let gran_key = format!("0x{}", hex::encode(session_keys.grandpa.0));
|
||||||
let audi_key = format!("0x{}", hex::encode(session_keys.authority_discovery.0));
|
let audi_key = format!("0x{}", hex::encode(session_keys.authority_discovery.0));
|
||||||
let wevr_key = format!("0x{}", hex::encode(session_keys.weaver.0));
|
let wevr_key = format!("0x{}", hex::encode(session_keys.weaver.0));
|
||||||
let exds_key = format!("0x{}", hex::encode(session_keys.exodus.0));
|
let exds_key = format!("0x{}", hex::encode(session_keys.exodus.0));
|
||||||
|
|
||||||
(gran_key, babe_key, audi_key, wevr_key, exds_key)
|
(babe_key, gran_key, audi_key, wevr_key, exds_key)
|
||||||
}
|
}
|
||||||
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
check_author_has_key(rpc_client, action_tx, &gran_key, "gran").await?;
|
|
||||||
check_author_has_key(rpc_client, action_tx, &babe_key, "babe").await?;
|
check_author_has_key(rpc_client, action_tx, &babe_key, "babe").await?;
|
||||||
|
check_author_has_key(rpc_client, action_tx, &gran_key, "gran").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &audi_key, "audi").await?;
|
check_author_has_key(rpc_client, action_tx, &audi_key, "audi").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &wevr_key, "wevr").await?;
|
check_author_has_key(rpc_client, action_tx, &wevr_key, "wevr").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &exds_key, "exds").await?;
|
check_author_has_key(rpc_client, action_tx, &exds_key, "exds").await?;
|
||||||
@ -269,25 +269,25 @@ pub async fn get_queued_session_keys(
|
|||||||
let account = super::raw_calls::convert_array_to_account_id(account_id);
|
let account = super::raw_calls::convert_array_to_account_id(account_id);
|
||||||
let maybe_queued_keys = super::raw_calls::session::queued_keys(api, None).await?;
|
let maybe_queued_keys = super::raw_calls::session::queued_keys(api, None).await?;
|
||||||
|
|
||||||
let (gran_key, babe_key, audi_key, wevr_key, exds_key) = match maybe_queued_keys {
|
let (babe_key, gran_key, audi_key, wevr_key, exds_key) = match maybe_queued_keys {
|
||||||
Some(session_keys) => match session_keys.iter().find(|tuple| tuple.0 == account) {
|
Some(session_keys) => match session_keys.iter().find(|tuple| tuple.0 == account) {
|
||||||
Some(keys) => {
|
Some(keys) => {
|
||||||
let session_keys = &keys.1;
|
let session_keys = &keys.1;
|
||||||
let gran_key = format!("0x{}", hex::encode(session_keys.grandpa.0));
|
|
||||||
let babe_key = format!("0x{}", hex::encode(session_keys.babe.0));
|
let babe_key = format!("0x{}", hex::encode(session_keys.babe.0));
|
||||||
|
let gran_key = format!("0x{}", hex::encode(session_keys.grandpa.0));
|
||||||
let audi_key = format!("0x{}", hex::encode(session_keys.authority_discovery.0));
|
let audi_key = format!("0x{}", hex::encode(session_keys.authority_discovery.0));
|
||||||
let wevr_key = format!("0x{}", hex::encode(session_keys.weaver.0));
|
let wevr_key = format!("0x{}", hex::encode(session_keys.weaver.0));
|
||||||
let exds_key = format!("0x{}", hex::encode(session_keys.exodus.0));
|
let exds_key = format!("0x{}", hex::encode(session_keys.exodus.0));
|
||||||
|
|
||||||
(gran_key, babe_key, audi_key, wevr_key, exds_key)
|
(babe_key, gran_key, audi_key, wevr_key, exds_key)
|
||||||
}
|
}
|
||||||
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
||||||
},
|
},
|
||||||
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
None => (String::new(), String::new(), String::new(), String::new(), String::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
check_author_has_key(rpc_client, action_tx, &gran_key, "q_gran").await?;
|
|
||||||
check_author_has_key(rpc_client, action_tx, &babe_key, "q_babe").await?;
|
check_author_has_key(rpc_client, action_tx, &babe_key, "q_babe").await?;
|
||||||
|
check_author_has_key(rpc_client, action_tx, &gran_key, "q_gran").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &audi_key, "q_audi").await?;
|
check_author_has_key(rpc_client, action_tx, &audi_key, "q_audi").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &wevr_key, "q_wevr").await?;
|
check_author_has_key(rpc_client, action_tx, &wevr_key, "q_wevr").await?;
|
||||||
check_author_has_key(rpc_client, action_tx, &exds_key, "q_exds").await?;
|
check_author_has_key(rpc_client, action_tx, &exds_key, "q_exds").await?;
|
||||||
|
|||||||
@ -115,7 +115,7 @@ pub async fn set_keys(
|
|||||||
hashed_keys_str: &String,
|
hashed_keys_str: &String,
|
||||||
maybe_nonce: Option<&mut u32>,
|
maybe_nonce: Option<&mut u32>,
|
||||||
) -> Result<TxProgress<CasperConfig, OnlineClient<CasperConfig>>> {
|
) -> Result<TxProgress<CasperConfig, OnlineClient<CasperConfig>>> {
|
||||||
let (gran_key, babe_key, audi_key, wevr_key, exds_key) = {
|
let (babe_key, gran_key, audi_key, wevr_key, exds_key) = {
|
||||||
let s = hashed_keys_str.trim_start_matches("0x");
|
let s = hashed_keys_str.trim_start_matches("0x");
|
||||||
(
|
(
|
||||||
hex::decode(&s[0..64])
|
hex::decode(&s[0..64])
|
||||||
@ -146,8 +146,8 @@ pub async fn set_keys(
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
let session_keys = runtime_types::casper_runtime::opaque::SessionKeys {
|
let session_keys = runtime_types::casper_runtime::opaque::SessionKeys {
|
||||||
grandpa: runtime_types::sp_consensus_grandpa::app::Public(gran_key),
|
|
||||||
babe: runtime_types::sp_consensus_babe::app::Public(babe_key),
|
babe: runtime_types::sp_consensus_babe::app::Public(babe_key),
|
||||||
|
grandpa: runtime_types::sp_consensus_grandpa::app::Public(gran_key),
|
||||||
authority_discovery: runtime_types::sp_authority_discovery::app::Public(audi_key),
|
authority_discovery: runtime_types::sp_authority_discovery::app::Public(audi_key),
|
||||||
weaver: runtime_types::ghost_weaver::sr25519::app_sr25519::Public(wevr_key),
|
weaver: runtime_types::ghost_weaver::sr25519::app_sr25519::Public(wevr_key),
|
||||||
exodus: runtime_types::ghost_exodus::sr25519::app_sr25519::Public(exds_key),
|
exodus: runtime_types::ghost_exodus::sr25519::app_sr25519::Public(exds_key),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user