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

Show tx hash. #1542

Merged
merged 2 commits into from
Feb 11, 2025
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
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
Loading