Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Updated transaction status view #280

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/GUIDE.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,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 @@ -1819,7 +1819,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
Loading