From 1bee13a52daba35fc796a8bb028383040b6c441d Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Fri, 21 Jul 2023 16:22:42 +0200 Subject: [PATCH] removal of missed unwrap() --- demos/rust-cosmos-broadcaster/bin/client.rs | 28 +++++++++++---------- demos/rust-cosmos-broadcaster/src/client.rs | 9 +++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/demos/rust-cosmos-broadcaster/bin/client.rs b/demos/rust-cosmos-broadcaster/bin/client.rs index dfc728175a..2171122700 100644 --- a/demos/rust-cosmos-broadcaster/bin/client.rs +++ b/demos/rust-cosmos-broadcaster/bin/client.rs @@ -30,16 +30,16 @@ struct OfflineSignTx { mnemonic: bip39::Mnemonic, /// recipient nyx chain address for token transfer nyx_token_receipient: AccountId, - /// the address of the broadcaster service - this submits txs and queries the chain on our behalf - sp_address: String + /// the address of the broadcaster service - this submits txs and queries the chain on our behalf + sp_address: String, } #[derive(Debug, Args)] struct SendTx { /// the base58 encoded signed payload created in OfflineSign() base58_payload: String, - /// the address of the broadcaster service - this submits txs and queries the chain on our behalf - sp_address: String + /// the address of the broadcaster service - this submits txs and queries the chain on our behalf + sp_address: String, } #[tokio::main] @@ -53,21 +53,21 @@ async fn main() -> anyhow::Result<()> { Some(Commands::OfflineSignTx(OfflineSignTx { mnemonic, nyx_token_receipient, - sp_address + sp_address, })) => { println!("\nsending offline sign info to broadcaster via the mixnet: getting signing account sequence and chain ID"); - let sp_address = Recipient::try_from_base58_string(sp_address).unwrap(); + let sp_address = Recipient::try_from_base58_string(sp_address).unwrap(); let base58_tx_bytes = offline_sign( mnemonic.clone(), nyx_token_receipient.clone(), &mut client, sp_address, ) - .await; + .await?; println!( "Encoded response (signed tx data) as base58 for tx broadcast: \n\n{:?}\n", - &base58_tx_bytes.as_ref() + &base58_tx_bytes ); println!("do you also wish to send the tx? y/n"); @@ -77,8 +77,7 @@ async fn main() -> anyhow::Result<()> { if input.starts_with('y') { println!("\nsending pre-signed tx through the mixnet to broadcaster service"); - let (tx_hash, success) = - send_tx(base58_tx_bytes.unwrap(), sp_address, &mut client).await?; + let (tx_hash, success) = send_tx(base58_tx_bytes, sp_address, &mut client).await?; println!( "tx hash returned from the broadcaster: {}\ntx was successful: {}", tx_hash, success @@ -89,9 +88,12 @@ async fn main() -> anyhow::Result<()> { println!("\nunrecognised user input"); } } - Some(Commands::SendTx(SendTx { base58_payload, sp_address})) => { - let sp_address = Recipient::try_from_base58_string(sp_address).unwrap(); - let tx_hash = send_tx(base58_payload.clone(), sp_address, &mut client).await; + Some(Commands::SendTx(SendTx { + base58_payload, + sp_address, + })) => { + let sp_address = Recipient::try_from_base58_string(sp_address).unwrap(); + let tx_hash = send_tx(base58_payload.clone(), sp_address, &mut client).await?; println!("response from the broadcaster (tx hash) {:#?}", tx_hash); } None => { diff --git a/demos/rust-cosmos-broadcaster/src/client.rs b/demos/rust-cosmos-broadcaster/src/client.rs index 99bcf8a404..0f7bb542b0 100644 --- a/demos/rust-cosmos-broadcaster/src/client.rs +++ b/demos/rust-cosmos-broadcaster/src/client.rs @@ -30,9 +30,9 @@ pub async fn offline_sign( signer_address: signer_address.clone(), // our (sender) address, derived from mnemonic }; - // send req to service via the mixnet + // send request to service via the mixnet client - .send_str(sp_address, &serde_json::to_string(&message).unwrap()) + .send_str(sp_address, &serde_json::to_string(&message)?) .await; // listen for response from service @@ -101,10 +101,7 @@ pub async fn send_tx( // send broadcast request containing base58 encoded signed tx to service via mixnet client - .send_str( - sp_address, - &serde_json::to_string(&broadcast_request).unwrap(), - ) + .send_str(sp_address, &serde_json::to_string(&broadcast_request)?) .await; println!("Waiting for reply");