diff --git a/cosmwasm/ucs01-relay-api/src/middleware.rs b/cosmwasm/ucs01-relay-api/src/middleware.rs index 605fea838d..bd13401117 100644 --- a/cosmwasm/ucs01-relay-api/src/middleware.rs +++ b/cosmwasm/ucs01-relay-api/src/middleware.rs @@ -48,7 +48,7 @@ pub enum PacketReturnInfo { #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct PacketId { pub height: u64, - pub index: u32, + pub index: u64, } /// Information about an in flight packet, used to process retries and refunds. @@ -71,7 +71,7 @@ pub struct InFlightPfmPacket { #[serde(untagged)] pub enum Memo { Forward { forward: PacketForward }, - None {}, + None { balls: String }, } #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] @@ -134,3 +134,20 @@ impl + From> Validate for NotEmptyString { } } } + +#[cfg(test)] +mod tests { + use super::Memo; + + #[test] + fn serde_parses_memo() { + // let memo = "\"balls\": \"string\""; + let memo = "{\"forward\": {\"receiver\": \"[eth_addr]\",\"port\": \"[union-eth port]\",\"channel\": \"[unioneth channel]\",\"timeout\": \"1000000\",\"retries\": 0}}"; + + let parsed = serde_json_wasm::from_str::(memo).expect("works"); + + dbg!(parsed); + + // panic!() + } +} diff --git a/cosmwasm/ucs01-relay-api/src/protocol.rs b/cosmwasm/ucs01-relay-api/src/protocol.rs index 44008c892e..b51793406e 100644 --- a/cosmwasm/ucs01-relay-api/src/protocol.rs +++ b/cosmwasm/ucs01-relay-api/src/protocol.rs @@ -307,7 +307,7 @@ pub trait TransferProtocol { false, )) } - Memo::None {} => {} + Memo::None { .. } => {} }; } diff --git a/cosmwasm/ucs01-relay/src/protocol.rs b/cosmwasm/ucs01-relay/src/protocol.rs index 3370210bdb..658254e780 100644 --- a/cosmwasm/ucs01-relay/src/protocol.rs +++ b/cosmwasm/ucs01-relay/src/protocol.rs @@ -536,10 +536,7 @@ impl<'a> TransferProtocol for Ics20Protocol<'a> { .expect("can normalize denom"); Coin { denom: transfer_token.denom, - amount: transfer_token - .amount - .try_into() - .expect("CosmWasm require transferred amount to be Uint128..."), + amount: transfer_token.amount, } }) .collect(); @@ -547,19 +544,13 @@ impl<'a> TransferProtocol for Ics20Protocol<'a> { // Forward the packet let forward_response = self.forward_transfer_packet( tokens, - original_packet, + original_packet.clone(), forward, override_addr, false, PacketReturnInfo::NewPacket(PacketId { height: self.common.env.block.height, - index: self - .common - .env - .transaction - .clone() - .expect("transaction has tx info") - .index, + index: original_packet.sequence, }), ); let forward_response_messages = forward_response @@ -951,10 +942,7 @@ impl<'a> TransferProtocol for Ucs01Protocol<'a> { .expect("can normalize denom"); Coin { denom: transfer_token.denom, - amount: transfer_token - .amount - .try_into() - .expect("CosmWasm require transferred amount to be Uint128..."), + amount: transfer_token.amount, } }) .collect(); @@ -962,19 +950,13 @@ impl<'a> TransferProtocol for Ucs01Protocol<'a> { // Forward the packet let forward_response = self.forward_transfer_packet( tokens, - original_packet, + original_packet.clone(), forward, override_addr, false, PacketReturnInfo::NewPacket(PacketId { height: self.common.env.block.height, - index: self - .common - .env - .transaction - .clone() - .expect("transaction has tx info") - .index, + index: original_packet.sequence, }), ); let forward_response_messages = forward_response diff --git a/cosmwasm/ucs01-relay/src/state.rs b/cosmwasm/ucs01-relay/src/state.rs index d8246e637f..ebad33ac49 100644 --- a/cosmwasm/ucs01-relay/src/state.rs +++ b/cosmwasm/ucs01-relay/src/state.rs @@ -34,7 +34,7 @@ pub struct PfmRefundPacketKey { // Block height of the original transaction pub height: u64, // Index of the original transaction from `cosmwasm_std::types::TransactionInfo` - pub index: u32, + pub index: u64, } impl<'a> Prefixer<'a> for PfmRefundPacketKey {