Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions contracts/CCQueryUC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ contract CCQueryUC is UniversalChanIbcApp {
* @param timeoutSeconds The timeout in seconds (relative).
*/
function sendUniversalPacket(address destPortAddr, bytes32 channelId, uint64 timeoutSeconds) external {
// TODO - Implement sendUniversalPacket to send a packet which will be received by the other chain
// The packet should contain the caller's address and a query string
// See onRecvUniversalPacket for the expected packet format in https://forum.polymerlabs.org/t/challenge-3-cross-contract-query-with-polymer/475
// Steps:
// 1. Encode the caller's address and the query string into a payload
// 2. Set the timeout timestamp at 10h from now
// 3. Call the IbcUniversalPacketSender to send the packet

// Example of how to properly encode, set timestamp and send a packet can be found in XCounterUC.sol
bytes memory payload = abi.encode(msg.sender, "crossChainQuery");

uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * 1000000000);

IbcUniversalPacketSender(mw).sendUniversalPacket(
channelId, IbcUtils.toBytes32(destPortAddr), payload, timeoutTimestamp
);
}

/**
Expand Down Expand Up @@ -108,13 +106,12 @@ contract CCQueryUC is UniversalChanIbcApp {
override
onlyIbcMw
{
// TODO - Implement onUniversalAcknowledgement to handle the received acknowledgment packet
// The packet should contain the secret message from the Base Contract at address: 0x528f7971cE3FF4198c3e6314AA223C83C7755bf7
// Steps:
// 1. Decode the counter from the ack packet
// 2. Emit a LogAcknowledgement event with the message
ackPackets.push(UcAckWithChannel(channelId, packet, ack));

// decode the counter from the ack packet
(string memory _secretMessage) = abi.decode(ack.data, (string));

// An example of how to properly decode and handle an ack packet can be found in XCounterUC.sol
emit LogAcknowledgement(_secretMessage);
}

/**
Expand Down