Skip to content

Commit

Permalink
refactor: Removed excessive step during transaction status view to im…
Browse files Browse the repository at this point in the history
…prove UX (#280)
  • Loading branch information
FroVolod authored Dec 21, 2023
1 parent 32dff46 commit ed12a17
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
1 change: 0 additions & 1 deletion docs/GUIDE.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 0 additions & 1 deletion docs/GUIDE.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,6 @@ Contract state (proof):
```txt
near transaction \
view-status GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank \
volodymyr.testnet \
network-config testnet
```

Expand Down
41 changes: 17 additions & 24 deletions src/commands/transaction/view_status/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,27 +23,34 @@ impl TransactionInfoContext {
) -> color_eyre::eyre::Result<Self> {
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::<near_primitives::types::AccountId>()?,
},
},
)
.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(())
}
});

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,
}))
}
Expand All @@ -57,14 +61,3 @@ impl From<TransactionInfoContext> for crate::network::NetworkContext {
item.0
}
}

impl TransactionInfo {
pub fn input_signer_account_id(
context: &crate::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::account_id::AccountId>> {
crate::common::input_signer_account_id_from_used_account_list(
&context.config.credentials_home_dir,
"What is the signer account ID?",
)
}
}
1 change: 0 additions & 1 deletion src/js_command_match/tx_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down

0 comments on commit ed12a17

Please sign in to comment.