From 8f27d041ace072d767dfc005cd6bd8f2f4086706 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 3 Jul 2023 21:30:09 +0000 Subject: [PATCH] imports for offline signing --- .../src/commands/commands.rs | 10 ++++++---- demos/rust-cosmos-broadcaster-client/src/main.rs | 14 +++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/demos/rust-cosmos-broadcaster-client/src/commands/commands.rs b/demos/rust-cosmos-broadcaster-client/src/commands/commands.rs index 6625b31187..110e57115b 100644 --- a/demos/rust-cosmos-broadcaster-client/src/commands/commands.rs +++ b/demos/rust-cosmos-broadcaster-client/src/commands/commands.rs @@ -9,14 +9,16 @@ use cosmrs::tx::Msg; use cosmrs::{tx, AccountId, Coin, Denom}; use bip39; -pub async fn offline_sign() -> Vec { +pub async fn offline_sign(mnemonic: &String, to: &String) -> Vec { - // TODO load most of this from config file, take address and mnemonic from function args, take address and mnemonic from function args. in V2 take chain-id and tx-type as well + // TODO load most of this from config file. in V2 take chain-id and tx-type as well let prefix = "n"; let denom: Denom = "unym".parse().unwrap(); - let signer_mnemonic: bip39::Mnemonic = "".parse().unwrap(); + let signer_mnemonic: bip39::Mnemonic = mnemonic.parse().unwrap(); + // let signer_mnemonic: bip39::Mnemonic = "".parse().unwrap(); let validator = "https://qwerty-validator.qa.nymte.ch"; - let to_address: AccountId = "n19kdst4srf76xgwe55jg32mpcpcyf6aqgp6qrdk".parse().unwrap(); + let to_address: AccountId = to.parse().unwrap(); + // let to_address: AccountId = "n19kdst4srf76xgwe55jg32mpcpcyf6aqgp6qrdk".parse().unwrap(); let signer = DirectSecp256k1HdWallet::from_mnemonic(prefix, signer_mnemonic); let signer_address = signer.try_derive_accounts().unwrap()[0].address().clone(); diff --git a/demos/rust-cosmos-broadcaster-client/src/main.rs b/demos/rust-cosmos-broadcaster-client/src/main.rs index 46e245ab5e..63a01b9d96 100644 --- a/demos/rust-cosmos-broadcaster-client/src/main.rs +++ b/demos/rust-cosmos-broadcaster-client/src/main.rs @@ -30,8 +30,12 @@ enum Commands { #[derive(Debug, Clone, Args)] struct OfflineSignTx { - /// some random info for testing - string: String, + // / some random info for testing + // string: String, + /// mnemonic + mnemonic: String, + /// recipient nym address + to: String } #[derive(Debug, Args)] @@ -46,11 +50,11 @@ async fn main() { let cli = Cli::parse(); match &cli.command { - Some(Commands::OfflineSignTx(string)) => { - let tx_bytes = commands::commands::offline_sign(); + Some(Commands::OfflineSignTx(OfflineSignTx { mnemonic, to } )) => { + let tx_bytes = commands::commands::offline_sign(mnemonic, to); // TODO parse future // println!("{}", parsed.iter().format(", ")); - println!("end {:?}", string); + println!("signed"); } Some(Commands::SendTx(sp_address)) => { todo!();