Skip to content

Commit

Permalink
warn upon retracted
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Apr 2, 2024
1 parent 480823e commit d01bc07
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use ac_node_api::EventDetails;
use ac_primitives::Bytes;
use alloc::{string::String, vec::Vec};
use codec::Decode;
use codec::{Decode, Encode};
use log::warn;
use serde::{Deserialize, Serialize};

pub use api_client::Api;
Expand Down Expand Up @@ -115,7 +116,7 @@ pub enum TransactionStatus<Hash, BlockHash> {
Invalid,
}

impl<Hash, BlockHash> TransactionStatus<Hash, BlockHash> {
impl<Hash, BlockHash: Encode> TransactionStatus<Hash, BlockHash> {
pub fn as_u8(&self) -> u8 {
match self {
TransactionStatus::Future => 0,
Expand All @@ -136,8 +137,11 @@ impl<Hash, BlockHash> TransactionStatus<Hash, BlockHash> {
TransactionStatus::Ready
| TransactionStatus::Broadcast(_)
| TransactionStatus::InBlock(_)
| TransactionStatus::Retracted(_)
| TransactionStatus::Finalized(_) => Ok(()),
TransactionStatus::Retracted(hash) => {
warn!("xt is retracted: block: 0x{}", hex::encode(hash.encode()));
Ok(())
}
TransactionStatus::Future => Err(Error::UnexpectedTxStatus(UnexpectedTxStatus::Future)),
TransactionStatus::FinalityTimeout(_) =>
Err(Error::UnexpectedTxStatus(UnexpectedTxStatus::FinalityTimeout)),
Expand Down

0 comments on commit d01bc07

Please sign in to comment.