Skip to content

Commit

Permalink
Show tx hash. (#1542)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch authored Feb 11, 2025
1 parent aeda47c commit 7b40742
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tc-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use tc_subxt::SubxtClient;
use time_primitives::{
balance::BalanceFormatter, traits::IdentifyAccount, AccountId, Address, BatchId, BlockHash,
BlockNumber, ChainName, ChainNetwork, ConnectorParams, Gateway, GatewayMessage, GmpEvent,
GmpEvents, GmpMessage, IConnectorAdmin, MemberStatus, MessageId, NetworkConfig, NetworkId,
PeerId, PublicKey, Route, ShardId, ShardStatus, TaskId, TssPublicKey,
GmpEvents, GmpMessage, Hash, IConnectorAdmin, MemberStatus, MessageId, NetworkConfig,
NetworkId, PeerId, PublicKey, Route, ShardId, ShardStatus, TaskId, TssPublicKey,
};
use tokio::time::sleep;

Expand Down Expand Up @@ -359,6 +359,7 @@ pub struct Batch {
pub batch: BatchId,
pub msg: GatewayMessage,
pub task: TaskId,
pub tx: Option<Hash>,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -611,6 +612,7 @@ impl Tc {
batch,
msg: self.runtime.batch_message(batch).await?.context("invalid batch id")?,
task: self.runtime.batch_task(batch).await?.context("invalid batch id")?,
tx: self.runtime.batch_tx_hash(batch).await?,
})
}

Expand Down
2 changes: 2 additions & 0 deletions tc-cli/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl IntoRow for Task {
pub struct BatchEntry {
batch: BatchId,
task: TaskId,
tx: String,
}

impl IntoRow for Batch {
Expand All @@ -248,6 +249,7 @@ impl IntoRow for Batch {
Ok(BatchEntry {
batch: self.batch,
task: self.task,
tx: self.tx.map(hex::encode).unwrap_or_else(|| "pending".into()),
})
}
}
Expand Down
9 changes: 7 additions & 2 deletions tc-subxt/src/api/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{metadata, SubxtClient};
use anyhow::Result;
use futures::channel::oneshot;
use time_primitives::{
BatchId, ErrorMsg, GatewayMessage, GmpEvents, MessageId, NetworkId, PublicKey, ShardId, Task,
TaskId, TaskResult,
BatchId, ErrorMsg, GatewayMessage, GmpEvents, Hash, MessageId, NetworkId, PublicKey, ShardId,
Task, TaskId, TaskResult,
};

impl SubxtClient {
Expand Down Expand Up @@ -96,6 +96,11 @@ impl SubxtClient {
Ok(self.client.storage().at_latest().await?.fetch(&storage_query).await?)
}

pub async fn batch_tx_hash(&self, batch: BatchId) -> Result<Option<Hash>> {
let storage_query = metadata::storage().tasks().batch_tx_hash(batch);
Ok(self.client.storage().at_latest().await?.fetch(&storage_query).await?)
}

pub async fn message_received_task(&self, message: MessageId) -> Result<Option<TaskId>> {
let storage_query = metadata::storage().tasks().message_received_task_id(message);
Ok(self.client.storage().at_latest().await?.fetch(&storage_query).await?)
Expand Down

0 comments on commit 7b40742

Please sign in to comment.