diff --git a/chain/client-primitives/src/types.rs b/chain/client-primitives/src/types.rs index ad2de642944..fedd8af30cd 100644 --- a/chain/client-primitives/src/types.rs +++ b/chain/client-primitives/src/types.rs @@ -598,6 +598,12 @@ pub enum TxStatusError { TimeoutError, } +impl From for TxStatusError { + fn from(error: near_chain_primitives::Error) -> Self { + Self::ChainError(error) + } +} + impl Message for TxStatus { type Result = Result, TxStatusError>; } diff --git a/chain/client/src/view_client.rs b/chain/client/src/view_client.rs index 4557883ac9a..6458a211e76 100644 --- a/chain/client/src/view_client.rs +++ b/chain/client/src/view_client.rs @@ -371,7 +371,7 @@ impl ViewClientActor { } } - let head = self.chain.head().map_err(|e| TxStatusError::ChainError(e))?; + let head = self.chain.head()?; let target_shard_id = self .runtime_adapter .account_id_to_shard_id(&signer_account_id, &head.epoch_id) @@ -386,10 +386,8 @@ impl ViewClientActor { match self.chain.get_final_transaction_result(&tx_hash) { Ok(tx_result) => { let res = if fetch_receipt { - let final_result = self - .chain - .get_final_transaction_result_with_receipt(tx_result) - .map_err(|e| TxStatusError::ChainError(e))?; + let final_result = + self.chain.get_final_transaction_result_with_receipt(tx_result)?; FinalExecutionOutcomeViewEnum::FinalExecutionOutcomeWithReceipt( final_result, ) @@ -407,7 +405,7 @@ impl ViewClientActor { } Err(err) => { warn!(target: "client", ?err, "Error trying to get transaction result"); - Err(TxStatusError::ChainError(err)) + Err(err.into()) } } } else { @@ -417,10 +415,7 @@ impl ViewClientActor { .runtime_adapter .account_id_to_shard_id(&signer_account_id, &head.epoch_id) .map_err(|err| TxStatusError::InternalError(err.to_string()))?; - let validator = self - .chain - .find_validator_for_forwarding(target_shard_id) - .map_err(|e| TxStatusError::ChainError(e))?; + let validator = self.chain.find_validator_for_forwarding(target_shard_id)?; self.network_adapter.do_send( PeerManagerMessageRequest::NetworkRequests(NetworkRequests::TxStatus( @@ -907,7 +902,7 @@ impl Handler> for ViewClientActor { } Err(e) => match e { near_chain::Error::DBNotFoundErr(_) => { - let head = self.chain.head().map_err(|e| TxStatusError::ChainError(e))?; + let head = self.chain.head()?; let target_shard_id = self.runtime_adapter.account_id_to_shard_id(&account_id, &head.epoch_id)?; if self.runtime_adapter.cares_about_shard(