-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1005bcd
commit 80ef98f
Showing
8 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
relayer/crates/starknet-chain-components/src/components/types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
relayer/crates/starknet-chain-components/src/impls/events/channel.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use hermes_cairo_encoding_components::strategy::ViaCairo; | ||
use hermes_cairo_encoding_components::types::as_felt::AsFelt; | ||
use hermes_chain_components::traits::types::ibc::HasChannelIdType; | ||
use hermes_chain_components::traits::types::ibc_events::channel::{ | ||
ProvideChannelOpenInitEvent, ProvideChannelOpenTryEvent, | ||
}; | ||
use hermes_chain_type_components::traits::types::message_response::HasMessageResponseType; | ||
use hermes_encoding_components::traits::decode::CanDecode; | ||
use hermes_encoding_components::traits::has_encoding::HasDefaultEncoding; | ||
use hermes_encoding_components::traits::types::encoded::HasEncodedType; | ||
use starknet::core::types::Felt; | ||
|
||
use crate::types::channel_id::ChannelId; | ||
use crate::types::message_response::StarknetMessageResponse; | ||
|
||
pub struct UseStarknetChannelEvents; | ||
|
||
impl<Chain, Counterparty, Encoding> ProvideChannelOpenInitEvent<Chain, Counterparty> | ||
for UseStarknetChannelEvents | ||
where | ||
Chain: HasMessageResponseType<MessageResponse = StarknetMessageResponse> | ||
+ HasChannelIdType<Counterparty, ChannelId = ChannelId> | ||
+ HasDefaultEncoding<AsFelt, Encoding = Encoding>, | ||
Encoding: HasEncodedType<Encoded = Vec<Felt>> + CanDecode<ViaCairo, ChannelId>, | ||
{ | ||
type ChannelOpenInitEvent = ChannelId; | ||
|
||
fn try_extract_channel_open_init_event( | ||
response: &StarknetMessageResponse, | ||
) -> Option<ChannelId> { | ||
Chain::default_encoding().decode(&response.result).ok() | ||
} | ||
|
||
fn channel_open_init_event_channel_id(channel_id: &ChannelId) -> &ChannelId { | ||
channel_id | ||
} | ||
} | ||
|
||
impl<Chain, Counterparty, Encoding> ProvideChannelOpenTryEvent<Chain, Counterparty> | ||
for UseStarknetChannelEvents | ||
where | ||
Chain: HasMessageResponseType<MessageResponse = StarknetMessageResponse> | ||
+ HasChannelIdType<Counterparty, ChannelId = ChannelId> | ||
+ HasDefaultEncoding<AsFelt, Encoding = Encoding>, | ||
Encoding: HasEncodedType<Encoded = Vec<Felt>> + CanDecode<ViaCairo, ChannelId>, | ||
{ | ||
type ChannelOpenTryEvent = ChannelId; | ||
|
||
fn try_extract_channel_open_try_event(response: &StarknetMessageResponse) -> Option<ChannelId> { | ||
Chain::default_encoding().decode(&response.result).ok() | ||
} | ||
|
||
fn channel_open_try_event_channel_id(channel_id: &ChannelId) -> &ChannelId { | ||
channel_id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
relayer/crates/starknet-chain-components/src/impls/events/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod channel; | ||
pub mod connection_id; | ||
pub mod create_client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters