Skip to content

Commit

Permalink
Implement payload builders for StarknetChain
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Dec 19, 2024
1 parent 5b4c7c8 commit 174a076
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use hermes_chain_components::impls::types::commitment::ProvideBytesPacketCommitm
use hermes_chain_components::impls::types::commitment_prefix::ProvideCommitmentPrefixBytes;
use hermes_chain_components::impls::types::payloads::channel::ProvideChannelPayloadTypes;
use hermes_chain_components::impls::types::payloads::connection::ProvideConnectionPayloadTypes;
use hermes_chain_components::impls::types::payloads::packet::ProvidePacketPayloadTypes;
use hermes_chain_components::impls::types::receipt::ProvideBytesPacketReceipt;
use hermes_chain_components::traits::commitment_prefix::IbcCommitmentPrefixGetterComponent;
pub use hermes_cosmos_chain_components::components::client::*;
Expand Down Expand Up @@ -117,6 +118,7 @@ cgp_preset! {
[
HeightTypeComponent,
HeightFieldComponent,
HeightIncrementerComponent,
]:
ProvideStarknetHeight,
ChainStatusTypeComponent:
Expand Down Expand Up @@ -298,6 +300,12 @@ cgp_preset! {
ChannelOpenConfirmPayloadTypeComponent,
]:
ProvideChannelPayloadTypes,
[
ReceivePacketPayloadTypeComponent,
AckPacketPayloadTypeComponent,
TimeoutUnorderedPacketPayloadTypeComponent,
]:
ProvidePacketPayloadTypes,
[
ConnectionOpenInitPayloadBuilderComponent,
ConnectionOpenTryPayloadBuilderComponent,
Expand Down
13 changes: 13 additions & 0 deletions relayer/crates/starknet-chain-components/src/impls/types/height.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use cgp::core::Async;
use cgp::prelude::CanRaiseError;
use hermes_chain_components::traits::types::height::HeightIncrementer;
use hermes_relayer_components::chain::traits::types::height::{
HasHeightType, HeightFieldGetter, ProvideHeightType,
};
Expand All @@ -21,3 +23,14 @@ where
*height
}
}

impl<Chain> HeightIncrementer<Chain> for ProvideStarknetHeight
where
Chain: HasHeightType<Height = u64> + CanRaiseError<&'static str>,
{
fn increment_height(height: &u64) -> Result<u64, Chain::Error> {
height
.checked_add(1)
.ok_or_else(|| Chain::raise_error("u64 overflow"))
}
}
3 changes: 3 additions & 0 deletions relayer/crates/starknet-chain-context/src/contexts/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ pub trait CanUseStarknetChain:
+ CanQueryPacketCommitment<CosmosChain>
+ CanQueryPacketAcknowledgement<CosmosChain>
+ CanQueryPacketReceipt<CosmosChain>
+ CanBuildReceivePacketPayload<CosmosChain>
+ CanBuildAckPacketPayload<CosmosChain>
+ CanBuildTimeoutUnorderedPacketPayload<CosmosChain>
{
}

Expand Down

0 comments on commit 174a076

Please sign in to comment.