From d7f76a5e001126004eafe0ebbe116245e997d0cc Mon Sep 17 00:00:00 2001 From: Andres Martin Aiello <50411235+andresaiello@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:16:04 -0300 Subject: [PATCH] feat: Add events to disperse (#146) * feat: Add events to disperse * rename * deploy * add from to event --- .../contracts/disperse/Disperse.sol | 12 ++++++++++-- packages/zevm-app-contracts/data/addresses.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/zevm-app-contracts/contracts/disperse/Disperse.sol b/packages/zevm-app-contracts/contracts/disperse/Disperse.sol index 2f1ae711..21efac64 100644 --- a/packages/zevm-app-contracts/contracts/disperse/Disperse.sol +++ b/packages/zevm-app-contracts/contracts/disperse/Disperse.sol @@ -6,6 +6,8 @@ import "@openzeppelin/contracts/interfaces/IERC20.sol"; contract Disperse { bool private locked; + event FundsDispersed(address indexed token, address indexed from, address indexed recipient, uint256 value); + modifier noReentrancy() { require(!locked, "No reentrancy"); locked = true; @@ -19,6 +21,7 @@ contract Disperse { for (uint256 i = 0; i < recipients.length; i++) { (bool sent, ) = payable(recipients[i]).call{value: values[i]}(""); require(sent, "Failed to send Ether"); + emit FundsDispersed(address(0), msg.sender, recipients[i], values[i]); } uint256 balance = address(this).balance; @@ -36,7 +39,10 @@ contract Disperse { uint256 total = 0; for (uint256 i = 0; i < recipients.length; i++) total += values[i]; require(token.transferFrom(msg.sender, address(this), total)); - for (uint256 i = 0; i < recipients.length; i++) require(token.transfer(recipients[i], values[i])); + for (uint256 i = 0; i < recipients.length; i++) { + require(token.transfer(recipients[i], values[i])); + emit FundsDispersed(address(token), msg.sender, recipients[i], values[i]); + } } function disperseTokenSimple( @@ -44,7 +50,9 @@ contract Disperse { address[] calldata recipients, uint256[] calldata values ) external noReentrancy { - for (uint256 i = 0; i < recipients.length; i++) + for (uint256 i = 0; i < recipients.length; i++) { require(token.transferFrom(msg.sender, recipients[i], values[i])); + emit FundsDispersed(address(token), msg.sender, recipients[i], values[i]); + } } } diff --git a/packages/zevm-app-contracts/data/addresses.json b/packages/zevm-app-contracts/data/addresses.json index 08869c18..e040ed8f 100644 --- a/packages/zevm-app-contracts/data/addresses.json +++ b/packages/zevm-app-contracts/data/addresses.json @@ -1,7 +1,7 @@ { "zevm": { "zeta_testnet": { - "disperse": "0x1E0F767F48Fb10FcF820703f116E9B0F87319d63", + "disperse": "0xf394dc01879E39f19eDA533EFD10C82eEee5B2b1", "rewardDistributorFactory": "0x667e4C493d40015256BDC89E3ba750B2F90359E1", "zetaSwap": "0x44D1F1f9289DBA1Cf5824bd667184cEBE020aA1c", "zetaSwapBtcInbound": "0x008b393933D5CA2457Df570CA5D628380FFf6da4",