Skip to content

Commit

Permalink
feat(zkgm): upgrade (#3519)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-aitlahcen authored Jan 15, 2025
2 parents e03f81b + 2982e21 commit 21556cc
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 42 deletions.
24 changes: 23 additions & 1 deletion evm/contracts/apps/ucs/00-pingpong/PingPong.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@openzeppelin-upgradeable/utils/PausableUpgradeable.sol";

import "../../Base.sol";
import "../../../core/25-handler/IBCHandler.sol";
import "../03-zkgm/IEurekaModule.sol";

// Protocol specific packet
struct PingPongPacket {
Expand All @@ -20,10 +21,12 @@ library PingPongLib {
error ErrInvalidAck();
error ErrNoChannel();
error ErrInfiniteGame();
error ErrOnlyZKGM();

event Ring(bool ping);
event TimedOut();
event Acknowledged();
event Zkgoblim(uint32 channelId, bytes sender, bytes message);

function encode(
PingPongPacket memory packet
Expand All @@ -44,13 +47,15 @@ contract PingPong is
Initializable,
UUPSUpgradeable,
OwnableUpgradeable,
PausableUpgradeable
PausableUpgradeable,
IEurekaModule
{
using PingPongLib for *;

IIBCPacket private ibcHandler;
uint32 private _gap0;
uint64 private timeout;
address private zkgmProtocol;

constructor() {
_disableInitializers();
Expand Down Expand Up @@ -191,4 +196,21 @@ contract PingPong is
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {}

function setZkgm(
address zkgm
) public onlyOwner {
zkgmProtocol = zkgm;
}

function onZkgm(
uint32 channelId,
bytes calldata sender,
bytes calldata message
) public {
if (msg.sender != zkgmProtocol) {
revert PingPongLib.ErrOnlyZKGM();
}
emit PingPongLib.Zkgoblim(channelId, sender, message);
}
}
6 changes: 5 additions & 1 deletion evm/contracts/apps/ucs/03-zkgm/IEurekaModule.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
pragma solidity ^0.8.27;

interface IEurekaModule {
function onZkgm(bytes calldata sender, bytes calldata message) external;
function onZkgm(
uint32 channelId,
bytes calldata sender,
bytes calldata message
) external;
}
Loading

0 comments on commit 21556cc

Please sign in to comment.