Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added events to new directory #62

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
933 changes: 0 additions & 933 deletions abi/SdkICS20Transfer.json

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
11 changes: 11 additions & 0 deletions src/events/IICS02ClientEvents.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.25;

import { IICS02ClientMsgs } from "../msgs/IICS02ClientMsgs.sol";

interface IICS02ClientEvents {
/// @notice Emitted when a new client is added to the client router.
/// @param clientId The newly created client identifier
/// @param counterpartyInfo The counterparty client information for the added client
event ICS02ClientAdded(string clientId, IICS02ClientMsgs.CounterpartyInfo counterpartyInfo);
}
25 changes: 25 additions & 0 deletions src/events/IICS20TransferEvents.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.25;

import { ICS20Lib } from "../utils/ICS20Lib.sol";

interface IICS20TransferEvents {
/// @notice Emitted when a packet is handled in onSendPacket and a transfer has been initiated
/// @param packetData The transfer packet data
/// @param erc20Address The address of the ERC20 contract of the token sent
event ICS20Transfer(ICS20Lib.PacketDataJSON packetData, address erc20Address);

/// @notice Emitted when a packet is received in onReceivePacket
/// @param packetData The transfer packet data
/// @param erc20Address The address of the ERC20 contract of the token received
event ICS20ReceiveTransfer(ICS20Lib.PacketDataJSON packetData, address erc20Address);

/// @notice Emitted after handling acknowledgement in onAcknowledgementPacket
/// @param packetData The transfer packet data
/// @param acknowledgement The acknowledgement data
event ICS20Acknowledgement(ICS20Lib.PacketDataJSON packetData, bytes acknowledgement);

/// @notice Emitted after handling a timeout in onTimeoutPacket
/// @param packetData The transfer packet data
event ICS20Timeout(ICS20Lib.PacketDataJSON packetData);
}
33 changes: 33 additions & 0 deletions src/events/IICS26RouterEvents.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.25;

import { IICS26RouterMsgs } from "../msgs/IICS26RouterMsgs.sol";

interface IICS26RouterEvents is IICS26RouterMsgs {
/// @notice Emitted when an IBC application is added to the router
/// @param portId The port identifier
/// @param app The address of the IBC application contract
event IBCAppAdded(string portId, address app);

/// @notice Emitted when a packet is sent
/// @param packet The sent packet
event SendPacket(Packet packet);

/// @notice Emitted when a packet is received
/// @param packet The received packet
event RecvPacket(Packet packet);

/// @notice Emitted when a packet acknowledgement is written
/// @param packet The packet that was acknowledged
/// @param acknowledgement The acknowledgement data
event WriteAcknowledgement(Packet packet, bytes acknowledgement);

/// @notice Emitted when a packet is timed out
/// @param packet The packet that was timed out
event TimeoutPacket(Packet packet);

/// @notice Emitted when a packet is acknowledged
/// @param packet The packet that was acknowledged
/// @param acknowledgement The acknowledgement data
event AckPacket(Packet packet, bytes acknowledgement);
}
8 changes: 2 additions & 6 deletions src/interfaces/IICS02Client.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ pragma solidity >=0.8.25;

import { IICS02ClientMsgs } from "../msgs/IICS02ClientMsgs.sol";
import { ILightClient } from "./ILightClient.sol";
import { IICS02ClientEvents } from "../events/IICS02ClientEvents.sol";

/// @title ICS02 Light Client Router Interface
/// @notice IICS02Client is an interface for the IBC Eureka client router
interface IICS02Client is IICS02ClientMsgs {
/// @notice Emitted when a new client is added to the client router.
/// @param clientId The newly created client identifier
/// @param counterpartyInfo The counterparty client information, if provided
event ICS02ClientAdded(string clientId, CounterpartyInfo counterpartyInfo);

interface IICS02Client is IICS02ClientMsgs, IICS02ClientEvents {
/// @notice Returns the counterparty client information given the client identifier.
/// @param clientId The client identifier
/// @return The counterparty client information
Expand Down
23 changes: 2 additions & 21 deletions src/interfaces/IICS20Transfer.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.25;

import { ICS20Lib } from "../utils/ICS20Lib.sol";
import { IICS20TransferMsgs } from "../msgs/IICS20TransferMsgs.sol";
import { IICS20TransferEvents } from "../events/IICS20TransferEvents.sol";

interface IICS20Transfer is IICS20TransferMsgs {
/// @notice Called when a packet is handled in onSendPacket and a transfer has been initiated
/// @param packetData The transfer packet data
/// @param erc20Address The address of the ERC20 contract of the token sent
event ICS20Transfer(ICS20Lib.PacketDataJSON packetData, address erc20Address);

/// @notice Called when a packet is received in onReceivePacket
/// @param packetData The transfer packet data
/// @param erc20Address The address of the ERC20 contract of the token received
event ICS20ReceiveTransfer(ICS20Lib.PacketDataJSON packetData, address erc20Address);

/// @notice Called after handling acknowledgement in onAcknowledgementPacket
/// @param packetData The transfer packet data
/// @param acknowledgement The acknowledgement data
event ICS20Acknowledgement(ICS20Lib.PacketDataJSON packetData, bytes acknowledgement);

/// @notice Called after handling a timeout in onTimeoutPacket
/// @param packetData The transfer packet data
event ICS20Timeout(ICS20Lib.PacketDataJSON packetData);

interface IICS20Transfer is IICS20TransferMsgs, IICS20TransferEvents {
/// @notice Send a transfer
/// @param msg The message for sending a transfer
/// @return sequence The sequence number of the packet created
Expand Down
28 changes: 2 additions & 26 deletions src/interfaces/IICS26Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ pragma solidity >=0.8.25;

import { IICS26RouterMsgs } from "../msgs/IICS26RouterMsgs.sol";
import { IIBCApp } from "./IIBCApp.sol";
import { IICS26RouterEvents } from "../events/IICS26RouterEvents.sol";

/// @title ICS26 Router Interface
/// @notice IICS26Router is an interface for the IBC Eureka router
interface IICS26Router is IICS26RouterMsgs {
/// @notice Emitted when an IBC application is added to the router
/// @param portId The port identifier
/// @param app The address of the IBC application contract
event IBCAppAdded(string portId, address app);

interface IICS26Router is IICS26RouterMsgs, IICS26RouterEvents {
/// @notice Returns the address of the IBC application given the port identifier
/// @param portId The port identifier
/// @return The address of the IBC application contract
Expand Down Expand Up @@ -40,24 +36,4 @@ interface IICS26Router is IICS26RouterMsgs {
/// @notice Timeouts a packet
/// @param msg The message for timing out packets
function timeoutPacket(MsgTimeoutPacket calldata msg) external;

// --------------------- Events --------------------- //

/// @notice Emitted when a packet is sent
/// @param packet The sent packet
event SendPacket(Packet packet);
/// @notice Emitted when a packet is received
/// @param packet The received packet
event RecvPacket(Packet packet);
/// @notice Emitted when a packet acknowledgement is written
/// @param packet The packet that was acknowledged
/// @param acknowledgement The acknowledgement data
event WriteAcknowledgement(Packet packet, bytes acknowledgement);
/// @notice Emitted when a packet is timed out
/// @param packet The packet that was timed out
event TimeoutPacket(Packet packet);
/// @notice Emitted when a packet is acknowledged
/// @param packet The packet that was acknowledged
/// @param acknowledgement The acknowledgement data
event AckPacket(Packet packet, bytes acknowledgement);
}
3 changes: 2 additions & 1 deletion test/ICS02ClientTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Test } from "forge-std/Test.sol";
import { IICS02Client } from "../src/interfaces/IICS02Client.sol";
import { ICS02Client } from "../src/ICS02Client.sol";
import { IICS02ClientMsgs } from "../src/msgs/IICS02ClientMsgs.sol";
import { IICS02ClientEvents } from "../src/events/IICS02ClientEvents.sol";
import { ILightClient } from "../src/interfaces/ILightClient.sol";
import { ILightClientMsgs } from "../src/msgs/ILightClientMsgs.sol";
import { DummyLightClient } from "./mocks/DummyLightClient.sol";
Expand All @@ -27,7 +28,7 @@ contract ICS02ClientTest is Test {
IICS02ClientMsgs.CounterpartyInfo memory counterpartyInfo =
IICS02ClientMsgs.CounterpartyInfo(counterpartyClient, merklePrefix);
vm.expectEmit();
emit IICS02Client.ICS02ClientAdded("07-tendermint-0", counterpartyInfo);
emit IICS02ClientEvents.ICS02ClientAdded("07-tendermint-0", counterpartyInfo);
string memory clientIdentifier = ics02Client.addClient("07-tendermint", counterpartyInfo, address(lightClient));

ILightClient fetchedLightClient = ics02Client.getClient(clientIdentifier);
Expand Down
32 changes: 17 additions & 15 deletions test/ICS20TransferTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Test } from "forge-std/Test.sol";
import { IICS26RouterMsgs } from "../src/msgs/IICS26RouterMsgs.sol";
import { IICS26Router } from "../src/interfaces/IICS26Router.sol";
import { IIBCAppCallbacks } from "../src/msgs/IIBCAppCallbacks.sol";
import { IICS20Transfer } from "../src/interfaces/IICS20Transfer.sol";
import { IICS20TransferMsgs } from "../src/msgs/IICS20TransferMsgs.sol";
import { IICS20TransferEvents } from "../src/events/IICS20TransferEvents.sol";
import { ICS20Transfer } from "../src/ICS20Transfer.sol";
import { TestERC20, MalfunctioningERC20 } from "./mocks/TestERC20.sol";
import { IBCERC20 } from "../src/utils/IBCERC20.sol";
Expand Down Expand Up @@ -130,7 +130,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceBefore, 0);

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand Down Expand Up @@ -159,7 +159,7 @@ contract ICS20TransferTest is Test {
expectedDefaultSendPacketData.amount = largeAmount;

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand Down Expand Up @@ -268,7 +268,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceBefore, 0);

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand All @@ -279,7 +279,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceAfterSend, defaultAmount);

vm.expectEmit();
emit IICS20Transfer.ICS20Acknowledgement(
emit IICS20TransferEvents.ICS20Acknowledgement(
expectedDefaultSendPacketData, ICS20Lib.SUCCESSFUL_ACKNOWLEDGEMENT_JSON
);
ics20Transfer.onAcknowledgementPacket(
Expand Down Expand Up @@ -308,7 +308,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceBefore, 0);

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand All @@ -319,7 +319,9 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceAfterSend, defaultAmount);

vm.expectEmit();
emit IICS20Transfer.ICS20Acknowledgement(expectedDefaultSendPacketData, ICS20Lib.FAILED_ACKNOWLEDGEMENT_JSON);
emit IICS20TransferEvents.ICS20Acknowledgement(
expectedDefaultSendPacketData, ICS20Lib.FAILED_ACKNOWLEDGEMENT_JSON
);
ics20Transfer.onAcknowledgementPacket(
IIBCAppCallbacks.OnAcknowledgementPacketCallback({
packet: packet,
Expand Down Expand Up @@ -384,7 +386,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceBefore, 0);

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand All @@ -395,7 +397,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceAfterSend, defaultAmount);

vm.expectEmit();
emit IICS20Transfer.ICS20Timeout(expectedDefaultSendPacketData);
emit IICS20TransferEvents.ICS20Timeout(expectedDefaultSendPacketData);
ics20Transfer.onTimeoutPacket(
IIBCAppCallbacks.OnTimeoutPacketCallback({ packet: packet, relayer: makeAddr("relayer") })
);
Expand Down Expand Up @@ -444,7 +446,7 @@ contract ICS20TransferTest is Test {
assertEq(contractBalanceBefore, 0);

vm.expectEmit();
emit IICS20Transfer.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
emit IICS20TransferEvents.ICS20Transfer(expectedDefaultSendPacketData, address(erc20));
ics20Transfer.onSendPacket(
IIBCAppCallbacks.OnSendPacketCallback({ packet: packet, sender: address(ics20Transfer) })
);
Expand Down Expand Up @@ -472,7 +474,7 @@ contract ICS20TransferTest is Test {
packet.sourceChannel = newSourceChannel;

vm.expectEmit();
emit IICS20Transfer.ICS20ReceiveTransfer(
emit IICS20TransferEvents.ICS20ReceiveTransfer(
ICS20Lib.PacketDataJSON({
denom: receivedDenom,
sender: senderStr,
Expand Down Expand Up @@ -513,7 +515,7 @@ contract ICS20TransferTest is Test {
vm.expectEmit(true, true, true, false); // Not checking data because we don't know the address yet
ICS20Lib.PacketDataJSON memory packetData;
address erc20Address;
emit IICS20Transfer.ICS20ReceiveTransfer(packetData, erc20Address); // we check these values later
emit IICS20TransferEvents.ICS20ReceiveTransfer(packetData, erc20Address); // we check these values later
vm.recordLogs();
bytes memory ack = ics20Transfer.onRecvPacket(
IIBCAppCallbacks.OnRecvPacketCallback({ packet: packet, relayer: makeAddr("relayer") })
Expand All @@ -524,7 +526,7 @@ contract ICS20TransferTest is Test {
Vm.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries.length, 4);
Vm.Log memory receiveTransferLog = entries[3];
assertEq(receiveTransferLog.topics[0], IICS20Transfer.ICS20ReceiveTransfer.selector);
assertEq(receiveTransferLog.topics[0], IICS20TransferEvents.ICS20ReceiveTransfer.selector);

(packetData, erc20Address) = abi.decode(receiveTransferLog.data, (ICS20Lib.PacketDataJSON, address));
assertEq(packetData.denom, foreignDenom);
Expand Down Expand Up @@ -562,7 +564,7 @@ contract ICS20TransferTest is Test {
vm.expectEmit(true, true, true, false); // Not checking data because we don't know the address yet
ICS20Lib.PacketDataJSON memory packetData;
address erc20Address;
emit IICS20Transfer.ICS20ReceiveTransfer(packetData, erc20Address); // we check these values later
emit IICS20TransferEvents.ICS20ReceiveTransfer(packetData, erc20Address); // we check these values later
vm.recordLogs();
bytes memory ack = ics20Transfer.onRecvPacket(
IIBCAppCallbacks.OnRecvPacketCallback({ packet: packet, relayer: makeAddr("relayer") })
Expand All @@ -573,7 +575,7 @@ contract ICS20TransferTest is Test {
Vm.Log[] memory entries = vm.getRecordedLogs();
assertEq(entries.length, 4);
Vm.Log memory receiveTransferLog = entries[3];
assertEq(receiveTransferLog.topics[0], IICS20Transfer.ICS20ReceiveTransfer.selector);
assertEq(receiveTransferLog.topics[0], IICS20TransferEvents.ICS20ReceiveTransfer.selector);

(packetData, erc20Address) = abi.decode(receiveTransferLog.data, (ICS20Lib.PacketDataJSON, address));
assertEq(packetData.denom, foreignDenom);
Expand Down
6 changes: 3 additions & 3 deletions test/ICS26RouterTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Test } from "forge-std/Test.sol";
import { ICS02Client } from "../src/ICS02Client.sol";
import { IICS02ClientMsgs } from "../src/msgs/IICS02ClientMsgs.sol";
import { ICS26Router } from "../src/ICS26Router.sol";
import { IICS26Router } from "../src/interfaces/IICS26Router.sol";
import { IICS26RouterMsgs } from "../src/msgs/IICS26RouterMsgs.sol";
import { IICS26RouterEvents } from "../src/events/IICS26RouterEvents.sol";
import { ICS20Transfer } from "../src/ICS20Transfer.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { DummyLightClient } from "./mocks/DummyLightClient.sol";
Expand All @@ -30,7 +30,7 @@ contract ICS26RouterTest is Test {
string memory ics20AddressStr = Strings.toHexString(address(ics20Transfer));

vm.expectEmit();
emit IICS26Router.IBCAppAdded(ics20AddressStr, address(ics20Transfer));
emit IICS26RouterEvents.IBCAppAdded(ics20AddressStr, address(ics20Transfer));
ics26Router.addIBCApp("", address(ics20Transfer));

assertEq(address(ics20Transfer), address(ics26Router.getIBCApp(ics20AddressStr)));
Expand All @@ -40,7 +40,7 @@ contract ICS26RouterTest is Test {
ICS20Transfer ics20Transfer = new ICS20Transfer(address(ics26Router));

vm.expectEmit();
emit IICS26Router.IBCAppAdded("transfer", address(ics20Transfer));
emit IICS26RouterEvents.IBCAppAdded("transfer", address(ics20Transfer));
ics26Router.addIBCApp("transfer", address(ics20Transfer));

assertEq(address(ics20Transfer), address(ics26Router.getIBCApp("transfer")));
Expand Down
Loading
Loading