Skip to content

Commit

Permalink
chore: final fixes
Browse files Browse the repository at this point in the history
Signed-off-by: aeryz <[email protected]>
  • Loading branch information
aeryz committed Jan 2, 2025
1 parent 4eab795 commit 5443e38
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 77 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cosmwasm/ibc-union/light-clients/tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cometbft-types = { workspace = true, features = ["proto", "hash"]
ibc-union-light-client = { workspace = true }
ibc-union-msg = { workspace = true }
ics23 = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tendermint-light-client-types = { workspace = true, features = ["ethabi", "serde"] }
tendermint-verifier = { workspace = true }
unionlabs = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/connect/app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "Connect your App"

import Mermaid from "#/components/Mermaid.astro";

Connect your app on a [Union-supported chain](../protocol/chains/overview/) to transfer assets and data to any other chain.
Connect your app on a [Union-supported chain](/protocol/chains/overview/) to transfer assets and data to any other chain.

## Asset transfers

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/connect/new-chain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "Connect a new Chain"

import { Tabs, TabItem, FileTree, Steps } from '@astrojs/starlight/components'

If your chain is not yet [connected to Union](../protocol/chains/overview/), then you can permissionlessly add support. Union supports L1s, L2s, L3s, and Rollups. The steps to connect are simple:
If your chain is not yet [connected to Union](/protocol/chains/overview/), then you can permissionlessly add support. Union supports L1s, L2s, L3s, and Rollups. The steps to connect are simple:

<Steps>
1. Upload Union contracts
Expand Down
91 changes: 16 additions & 75 deletions voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,80 +391,21 @@ event! {
packet: ibc_solidity::Packet,
},

// #[event(
// tag = "write_acknowledgement",
// deprecated("packet_data", "packet_ack", "packet_connection")
// )]
// WriteAcknowledgement {
// #[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
// packet_data_hex: Bytes,
// #[parse(u64::from_str)]
// packet_timeout_height: Height,
// #[parse(u64::from_str)]
// packet_timeout_timestamp: u64,
// #[parse(NonZeroU64::from_str)]
// packet_sequence: NonZeroU64,
// #[parse(String::from_str)]
// packet_src_port: String,
// #[parse(u32::from_str)]
// packet_src_channel: u32,
// #[parse(String::from_str)]
// packet_dst_port: String,
// #[parse(u32::from_str)]
// packet_dst_channel: u32,
// #[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
// packet_ack_hex: Bytes,
// #[parse(u32::from_str)]
// connection_id: u32,
// },

// #[event(tag = "recv_packet", deprecated("packet_data", "packet_connection"))]
// RecvPacket {
// #[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
// packet_data_hex: Bytes,
// #[parse(u64::from_str)]
// packet_timeout_height: Height,
// #[parse(u64::from_str)]
// packet_timeout_timestamp: u64,
// #[parse(NonZeroU64::from_str)]
// packet_sequence: NonZeroU64,
// #[parse(String::from_str)]
// packet_src_port: String,
// #[parse(u32::from_str)]
// packet_src_channel: u32,
// #[parse(String::from_str)]
// packet_dst_port: String,
// #[parse(u32::from_str)]
// packet_dst_channel: u32,
// #[parse(Order::from_str)]
// packet_channel_ordering: Order,
// #[parse(u32::from_str)]
// connection_id: u32,
// },
#[event(tag = "wasm-recv_packet")]
UnionRecvPacket {
#[parse(serde_json::from_str)]
packet: ibc_solidity::Packet,
#[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
relayer_msg: Bytes,
},

// #[event(tag = "send_packet", deprecated("packet_data", "packet_connection"))]
// SendPacket {
// #[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
// packet_data_hex: Bytes,
// #[parse(u64::from_str)]
// packet_timeout_height: Height,
// #[parse(u64::from_str)]
// packet_timeout_timestamp: u64,
// #[parse(NonZeroU64::from_str)]
// packet_sequence: NonZeroU64,
// #[parse(String::from_str)]
// packet_src_port: String,
// #[parse(u32::from_str)]
// packet_src_channel: u32,
// #[parse(String::from_str)]
// packet_dst_port: String,
// #[parse(u32::from_str)]
// packet_dst_channel: u32,
// #[parse(Order::from_str)]
// packet_channel_ordering: Order,
// #[parse(u32::from_str)]
// connection_id: u32,
// },
#[event(tag = "wasm-acknowledge_packet")]
UnionAcknowledgePacket {
#[parse(serde_json::from_str)]
packet: ibc_solidity::Packet,
#[parse(|s: &str| s.parse::<Bytes<HexUnprefixed>>().map(|b| b.into_encoding()))]
acknowledgement: Bytes,
},

// #[event(tag = "acknowledge_packet", deprecated("packet_connection"))]
// AcknowledgePacket {
Expand Down Expand Up @@ -547,9 +488,9 @@ impl IbcEvent {
IbcEvent::UnionChannelOpenAck(_) => "channel_open_ack",
IbcEvent::UnionChannelOpenConfirm(_) => "channel_open_confirm",
// IbcEvent::UnionWriteAcknowledgement(_) => "write_acknowledgement",
// IbcEvent::UnionRecvPacket(_) => "recv_packet",
IbcEvent::UnionRecvPacket(_) => "recv_packet",
IbcEvent::UnionSendPacket(_) => "send_packet",
// IbcEvent::UnionAcknowledgePacket(_) => "acknowledge_packet",
IbcEvent::UnionAcknowledgePacket(_) => "acknowledge_packet",
// IbcEvent::UnionTimeoutPacket(_) => "timeout_packet",
}
}
Expand Down
174 changes: 174 additions & 0 deletions voyager/plugins/event-source/cosmos-sdk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,180 @@ impl PluginServer<ModuleCall, ModuleCallback> for Module {

ibc_union_spec::log_event(&event, &self.chain_id);

Ok(data(ChainEvent {
chain_id: self.chain_id.clone(),
client_info,
counterparty_chain_id: client_meta.chain_id,
tx_hash,
provable_height,
ibc_spec_id: IbcUnion::ID,
event: into_value::<ibc_union_spec::FullEvent>(event),
}))
}
IbcEvent::UnionAcknowledgePacket(ack_packet) => {
let packet = ack_packet.packet;

let source_channel = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ChannelPath {
channel_id: packet.source_channel,
},
)
.await?
.state
.unwrap();

let source_connection = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ConnectionPath {
connection_id: source_channel.connection_id,
},
)
.await?
.state
.unwrap();

let client_info = voyager_client
.client_info::<IbcUnion>(
self.chain_id.clone(),
source_connection.client_id,
)
.await?;

let client_meta = voyager_client
.client_meta::<IbcUnion>(
self.chain_id.clone(),
height.into(),
source_connection.client_id,
)
.await?;

let event = ibc_union_spec::PacketAck {
packet_data: packet.data.into(),
packet: ibc_union_spec::PacketMetadata {
source_channel: ibc_union_spec::ChannelMetadata {
channel_id: packet.source_channel,
version: source_channel.version.clone(),
connection: ibc_union_spec::ConnectionMetadata {
client_id: source_connection.client_id,
connection_id: source_channel.connection_id,
},
},
destination_channel: ibc_union_spec::ChannelMetadata {
channel_id: packet.destination_channel,
version: source_channel.version,
connection: ibc_union_spec::ConnectionMetadata {
client_id: source_connection.counterparty_client_id,
connection_id: source_connection.counterparty_connection_id,
},
},
timeout_height: packet.timeout_height,
timeout_timestamp: packet.timeout_timestamp,
},
acknowledgement: ack_packet.acknowledgement.into(),
}
.into();

ibc_union_spec::log_event(&event, &self.chain_id);

Ok(data(ChainEvent {
chain_id: self.chain_id.clone(),
client_info,
counterparty_chain_id: client_meta.chain_id,
tx_hash,
provable_height,
ibc_spec_id: IbcUnion::ID,
event: into_value::<ibc_union_spec::FullEvent>(event),
}))
}
IbcEvent::UnionRecvPacket(recv_packet) => {
let packet = recv_packet.packet;

let source_channel = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ChannelPath {
channel_id: packet.source_channel,
},
)
.await?
.state
.unwrap();

let destination_channel = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ChannelPath {
channel_id: packet.destination_channel,
},
)
.await?
.state
.unwrap();

let destination_connection = voyager_client
.query_ibc_state(
self.chain_id.clone(),
QueryHeight::Specific(height),
ibc_union_spec::ConnectionPath {
connection_id: destination_channel.connection_id,
},
)
.await?
.state
.unwrap();

let client_info = voyager_client
.client_info::<IbcUnion>(
self.chain_id.clone(),
destination_connection.client_id,
)
.await?;

let client_meta = voyager_client
.client_meta::<IbcUnion>(
self.chain_id.clone(),
height.into(),
destination_connection.client_id,
)
.await?;

let event = ibc_union_spec::PacketRecv {
packet_data: packet.data.into(),
packet: ibc_union_spec::PacketMetadata {
source_channel: ibc_union_spec::ChannelMetadata {
channel_id: packet.source_channel,
version: source_channel.version.clone(),
connection: ibc_union_spec::ConnectionMetadata {
client_id: destination_connection.counterparty_client_id,
connection_id: destination_connection
.counterparty_connection_id,
},
},
destination_channel: ibc_union_spec::ChannelMetadata {
channel_id: packet.destination_channel,
version: destination_channel.version.clone(),

connection: ibc_union_spec::ConnectionMetadata {
client_id: destination_connection.client_id,
connection_id: destination_channel.connection_id,
},
},
timeout_height: packet.timeout_height,
timeout_timestamp: packet.timeout_timestamp,
},
relayer_msg: recv_packet.relayer_msg.into(),
}
.into();

ibc_union_spec::log_event(&event, &self.chain_id);

Ok(data(ChainEvent {
chain_id: self.chain_id.clone(),
client_info,
Expand Down

0 comments on commit 5443e38

Please sign in to comment.