From ed12a172fc835084fd6a9f006b9ccacd89179575 Mon Sep 17 00:00:00 2001 From: FroVolod <36816899+FroVolod@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:20:05 +0200 Subject: [PATCH] refactor: Removed excessive step during transaction status view to improve UX (#280) --- docs/GUIDE.en.md | 1 - docs/GUIDE.ru.md | 1 - src/commands/transaction/view_status/mod.rs | 41 +++++++++------------ src/js_command_match/tx_status.rs | 1 - 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/docs/GUIDE.en.md b/docs/GUIDE.en.md index 0074a6577..f1badeffb 100644 --- a/docs/GUIDE.en.md +++ b/docs/GUIDE.en.md @@ -1808,7 +1808,6 @@ To view the status of the desired transaction, type its hash in the terminal com ```txt near transaction \ view-status GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank \ - volodymyr.testnet \ network-config testnet ``` diff --git a/docs/GUIDE.ru.md b/docs/GUIDE.ru.md index a096e2b00..5dbea78ad 100644 --- a/docs/GUIDE.ru.md +++ b/docs/GUIDE.ru.md @@ -1820,7 +1820,6 @@ Contract state (proof): ```txt near transaction \ view-status GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank \ - volodymyr.testnet \ network-config testnet ``` diff --git a/src/commands/transaction/view_status/mod.rs b/src/commands/transaction/view_status/mod.rs index d39c13ff6..6c7f9dffb 100644 --- a/src/commands/transaction/view_status/mod.rs +++ b/src/commands/transaction/view_status/mod.rs @@ -8,9 +8,6 @@ use crate::common::JsonRpcClientExt; pub struct TransactionInfo { /// Enter the hash of the transaction you need to view: transaction_hash: crate::types::crypto_hash::CryptoHash, - #[interactive_clap(skip_default_input_arg)] - /// What is the signer account ID? - signer_account_id: crate::types::account_id::AccountId, #[interactive_clap(named_arg)] /// Select network network_config: crate::network::Network, @@ -26,19 +23,26 @@ impl TransactionInfoContext { ) -> color_eyre::eyre::Result { let on_after_getting_network_callback: crate::network::OnAfterGettingNetworkCallback = std::sync::Arc::new({ - let signer_account_id = scope.signer_account_id.clone(); let transaction_hash = scope.transaction_hash; move |network_config| { let query_view_transaction_status = network_config - .json_rpc_client() - .blocking_call(near_jsonrpc_client::methods::EXPERIMENTAL_tx_status::RpcTransactionStatusRequest { - transaction_info: near_jsonrpc_client::methods::EXPERIMENTAL_tx_status::TransactionInfo::TransactionId { - hash: transaction_hash.into(), - account_id: signer_account_id.clone().into() - } - }) - .wrap_err_with(|| format!("Failed to fetch query for view transaction on network <{}>", network_config.network_name))?; + .json_rpc_client() + .blocking_call( + near_jsonrpc_client::methods::tx::RpcTransactionStatusRequest { + transaction_info: + near_jsonrpc_client::methods::tx::TransactionInfo::TransactionId { + hash: transaction_hash.into(), + account_id: "near".parse::()?, + }, + }, + ) + .wrap_err_with(|| { + format!( + "Failed to fetch query for view transaction on network <{}>", + network_config.network_name + ) + })?; eprintln!("Transaction status: {:#?}", query_view_transaction_status); Ok(()) } @@ -46,7 +50,7 @@ impl TransactionInfoContext { Ok(Self(crate::network::NetworkContext { config: previous_context.config, - interacting_with_account_ids: vec![scope.signer_account_id.clone().into()], + interacting_with_account_ids: vec![], on_after_getting_network_callback, })) } @@ -57,14 +61,3 @@ impl From for crate::network::NetworkContext { item.0 } } - -impl TransactionInfo { - pub fn input_signer_account_id( - context: &crate::GlobalContext, - ) -> color_eyre::eyre::Result> { - crate::common::input_signer_account_id_from_used_account_list( - &context.config.credentials_home_dir, - "What is the signer account ID?", - ) - } -} diff --git a/src/js_command_match/tx_status.rs b/src/js_command_match/tx_status.rs index c3f365c0c..569039661 100644 --- a/src/js_command_match/tx_status.rs +++ b/src/js_command_match/tx_status.rs @@ -14,7 +14,6 @@ impl TxStatusArgs { "transaction".to_owned(), "view-status".to_owned(), self.transaction_hash.to_owned(), - self.account_id.to_owned(), "network-config".to_owned(), network_config, ]