Skip to content

Commit

Permalink
fix: pending packets with sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Jan 2, 2025
1 parent 72013c4 commit b62a2f4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/os/andromeda-kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "andromeda-kernel"
version = "1.2.0-b.2"
version = "1.2.0-b.3"
authors = ["Connor Barr <[email protected]>"]
edition = "2021"
rust-version = "1.65.0"
Expand Down
18 changes: 12 additions & 6 deletions contracts/os/andromeda-kernel/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use andromeda_std::{
aos_querier::AOSQuerier,
kernel::{
ChainNameResponse, ChannelInfoResponse, EnvResponse, Ics20PacketInfo,
VerifyAddressResponse,
PacketInfoAndSequence, PendingPacketResponse, VerifyAddressResponse,
},
},
};
Expand Down Expand Up @@ -76,22 +76,28 @@ pub fn chain_name(deps: Deps) -> Result<ChainNameResponse, ContractError> {
pub fn pending_packets(
deps: Deps,
channel_id: Option<String>,
) -> Result<Vec<Ics20PacketInfo>, ContractError> {
let packets: Vec<Ics20PacketInfo> = if let Some(channel_id) = channel_id {
) -> Result<PendingPacketResponse, ContractError> {
let packets: Vec<PacketInfoAndSequence> = if let Some(channel_id) = channel_id {
CHANNEL_TO_EXECUTE_MSG
.prefix(channel_id)
.range(deps.storage, None, None, Order::Ascending)
.filter_map(|item| item.ok())
.map(|(_, packet)| packet)
.map(|(sequence, packet)| PacketInfoAndSequence {
packet_info: packet,
sequence,
})
.collect()
} else {
CHANNEL_TO_EXECUTE_MSG
.range(deps.storage, None, None, Order::Ascending)
.filter_map(|item| item.ok())
.map(|(_, packet)| packet)
.map(|((_, sequence), packet)| PacketInfoAndSequence {
packet_info: packet,
sequence,
})
.collect()
};
Ok(packets)
Ok(PendingPacketResponse { packets })
}

pub fn get_env(deps: Deps, variable: String) -> Result<EnvResponse, ContractError> {
Expand Down
8 changes: 7 additions & 1 deletion packages/std/src/os/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ pub struct ChainNameResponse {

#[cw_serde]
pub struct PendingPacketResponse {
pub packets: Vec<Ics20PacketInfo>,
pub packets: Vec<PacketInfoAndSequence>,
}

#[cw_serde]
pub struct PacketInfoAndSequence {
pub packet_info: Ics20PacketInfo,
pub sequence: u64,
}

#[cw_serde]
Expand Down

0 comments on commit b62a2f4

Please sign in to comment.