Skip to content

Commit

Permalink
insert height into query_packet_receipt and query_packet_acknowledgem…
Browse files Browse the repository at this point in the history
…ent grpc metadata
  • Loading branch information
noot committed Sep 11, 2024
1 parent f4ac139 commit 4fbe195
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions crates/relayer-types/src/applications/transfer/msgs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod send;
pub mod transfer;

// TODO: does this need to be updated?
pub const ASTRIA_WITHDRAWAL_TYPE_URL: &str = "/astria.sequencer.v1.Ics20Withdrawal";
34 changes: 26 additions & 8 deletions crates/relayer/src/chain/astria/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ impl AstriaEndpoint {
TransactionParams,
UnsignedTransaction,
},
Protobuf as _,
};
use astria_sequencer_client::SequencerClientExt as _;
use ibc_relayer_types::applications::transfer::msgs::ASTRIA_WITHDRAWAL_TYPE_URL;
use penumbra_ibc::IbcRelay;
use penumbra_proto::core::component::ibc::v1::IbcRelay as RawIbcRelay;
use astria_core::Protobuf as _;

let msg_len = tracked_msgs.msgs.len();
let mut actions: Vec<Action> = Vec::with_capacity(msg_len);
Expand Down Expand Up @@ -731,12 +731,12 @@ impl ChainEndpoint for AstriaEndpoint {
}
.into_request();

let map = req.metadata_mut();
let height_str: String = match request.height {
QueryHeight::Latest => 0.to_string(),
QueryHeight::Specific(h) => h.to_string(),
let height = match request.height {
QueryHeight::Latest => 0,
QueryHeight::Specific(h) => h.revision_height(),
};
map.insert("height", height_str.parse().expect("valid ascii string"));
req.metadata_mut()
.insert("height", height.to_string().parse().expect("valid ascii"));

let response = self
.block_on(client.client_state(req))
Expand Down Expand Up @@ -1176,7 +1176,16 @@ impl ChainEndpoint for AstriaEndpoint {
// TODO: height is ignored
};

let request = tonic::Request::new(req);
let height = match request.height {
QueryHeight::Latest => 0,
QueryHeight::Specific(h) => h.revision_height(),
};

let mut request = tonic::Request::new(req);
request
.metadata_mut()
.insert("height", height.to_string().parse().expect("valid ascii"));

let response = self
.block_on(client.packet_receipt(request))
.map_err(|e| Error::grpc_status(e, "query_packet_receipt".to_owned()))?
Expand Down Expand Up @@ -1238,7 +1247,16 @@ impl ChainEndpoint for AstriaEndpoint {
// TODO: height is ignored
};

let request = tonic::Request::new(req);
let height = match request.height {
QueryHeight::Latest => 0,
QueryHeight::Specific(h) => h.revision_height(),
};

let mut request = tonic::Request::new(req);
request
.metadata_mut()
.insert("height", height.to_string().parse().expect("valid ascii"));

let response = self
.block_on(client.packet_acknowledgement(request))
.map_err(|e| Error::grpc_status(e, "query_packet_acknowledgement".to_owned()))?
Expand Down

0 comments on commit 4fbe195

Please sign in to comment.