From 02ae7ac1885fe8ed4b06c2b6e9f508de1f00fec9 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Fri, 10 Jan 2025 14:22:17 -0500 Subject: [PATCH] declare validate --- crates/test-cli/src/lib.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/test-cli/src/lib.rs b/crates/test-cli/src/lib.rs index a448f7856..9ec470ebe 100644 --- a/crates/test-cli/src/lib.rs +++ b/crates/test-cli/src/lib.rs @@ -23,6 +23,8 @@ use entropy_client::{ bounded_collections::bounded_vec::BoundedVec, pallet_programs::pallet::ProgramInfo, pallet_registry::pallet::{ProgramInstance, RegisteredInfo}, + pallet_staking::{ValidatorPrefs}, + pallet_staking_extension::pallet::JoiningServerInfo, }, EntropyConfig, }, @@ -215,6 +217,12 @@ enum CliCommand { }, /// Declares intention to validate DeclareValidate { + /// Threshold account + tss_account: String, + /// X25519 public key + x25519_public_key: String, + /// Endpoint to change to (ex. "127.0.0.1:3001") + endpoint: String, /// The mnemonic for the signer which will trigger the call. #[arg(short, long)] mnemonic_option: Option, @@ -600,13 +608,18 @@ pub async fn run_command( Ok("Session Keys updates".to_string()) } }, - CliCommand::DeclareValidate { mnemonic_option } => { + CliCommand::DeclareValidate { tss_account, x25519_public_key, endpoint, mnemonic_option } => { let signer = handle_mnemonic(mnemonic_option)?; cli.log(format!("Account being used for session keys: {}", signer.public())); - - // let result_event = - // declare_validate(&api, &rpc, signer).await?; - // cli.log(format!("Event result: {:?}", result_event)); + let tss_account = SubxtAccountId32::from_str(&tss_account)?; + let x25519_public_key = hex::decode(x25519_public_key)? + .try_into() + .map_err(|_| anyhow!("X25519 pub key needs to be 32 bytes"))?; + let joining_server_info = + JoiningServerInfo { tss_account, x25519_public_key, endpoint }; + let result_event = + declare_validate(&api, &rpc, signer , joining_server_info, ValidatorPrefs::default(), vec![]).await?; + cli.log(format!("Event result: {:?}", result_event)); if cli.json { Ok("{}".to_string())