Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Jul 8, 2024
1 parent 5f47723 commit 3538039
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 35 deletions.
64 changes: 36 additions & 28 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cw-ibc-lite-ics02-client = { version = "0.1.0", path = "./contracts/ics02-client
cw-ibc-lite-ics26-router = { version = "0.1.0", path = "./contracts/ics26-router/", default-features = false }
sha2 = "0.10.8"
ibc-proto = { version = "0.46.0", default-features = false }
anybuf = "0.5.0"
derive_more = { version = "0.99.18", default-features = false, features = [ "from", "into", "display", "try_into" ] }
proc-macro2 = "1.0"
quote = "1.0"
Expand Down
1 change: 1 addition & 0 deletions contracts/ics26-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ cw-ibc-lite-shared = { workspace = true }
cw-ibc-lite-ics02-client = { workspace = true }
ibc-client-cw = { workspace = true }
cw-ownable = { workspace = true }
anybuf = { workspace = true }
11 changes: 5 additions & 6 deletions contracts/ics26-router/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,11 @@ mod reply {
) -> Result<Response, ContractError> {
match result {
SubMsgResult::Ok(resp) => {
// TODO: allow depracated until we have working tests and then change it.
#[allow(deprecated)]
let ack: ibc::Acknowledgement = resp
.data
.ok_or(ContractError::RecvPacketCallbackNoResponse)?
.try_into()?;
let ack = ibc::Acknowledgement::new(
anybuf::Bufany::deserialize(&resp.msg_responses[0].value)?
.bytes(1)
.unwrap(),
);
let packet: ibc::Packet = cosmwasm_std::from_json(payload)?;

state::helpers::commit_packet_ack(deps.storage, &packet, &ack)?;
Expand Down
2 changes: 1 addition & 1 deletion e2e/interchaintestv8/chainconfig/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var DefaultChainSpecs = []*interchaintest.ChainSpec{
Images: []ibc.DockerImage{
{
Repository: "ghcr.io/cosmos/ibc-go-simd", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "serdar-xxx-ibc-lite-e2e-image", // FOR LOCAL IMAGE USE: Docker Image Tag
Version: "serdar-xxx-ibc-lite-e2e-debug", // FOR LOCAL IMAGE USE: Docker Image Tag
UidGid: "1025:1025",
},
},
Expand Down
1 change: 1 addition & 0 deletions e2e/interchaintestv8/ibclite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func (s *IBCLiteTestSuite) TestCW20Transfer() {

acknowledgement2, err = hex.DecodeString(ackHex)
s.Require().NoError(err)
s.Require().Equal([]byte(`{"result":"AQ=="}`), acknowledgement2)
}))

s.Require().NoError(s.Relayer.UpdateClients(ctx, s.ExecRep, s.PathName))
Expand Down
1 change: 1 addition & 0 deletions packages/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ sha2 = { workspace = true }
ibc-proto = { workspace = true }
derive_more = { workspace = true }
cw-ibc-lite-derive = { workspace = true }
anybuf = { workspace = true }
2 changes: 2 additions & 0 deletions packages/shared/src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum ContractError {
IdentifierError(#[from] ibc_core_host::types::error::IdentifierError),
#[error("{0}")]
TransferError(#[from] super::transfer::error::TransferError),
#[error("{0}")]
BufanyError(#[from] anybuf::BufanyError),

#[error("unauthorized")]
Unauthorized,
Expand Down
16 changes: 16 additions & 0 deletions packages/shared/src/types/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,19 @@ impl From<Height> for ibc_proto::ibc::core::client::v1::Height {
}
}
}

#[cfg(test)]
mod tests {
use crate::types::transfer::packet::Ics20Ack;

use super::*;

#[test]
fn packet_acknowledgement() {
let ics20_ack = Ics20Ack::success();
let bin = Binary::from(ics20_ack.to_vec());

let ack = Acknowledgement::try_from(bin).unwrap();
assert_eq!(ack.as_slice(), br#"{"result":"AQ=="}"#);
}
}
14 changes: 14 additions & 0 deletions packages/shared/src/types/transfer/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,17 @@ impl Ics20Packet {
Ok(())
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn ack_success() {
let ack = Ics20Ack::success();
assert_eq!(ack, Ics20Ack::Result(vec![1].into()));

let serialized = ack.to_vec();
assert_eq!(serialized, br#"{"result":"AQ=="}"#);
}
}

0 comments on commit 3538039

Please sign in to comment.