Skip to content

Commit

Permalink
feat: Add events to disperse (#146)
Browse files Browse the repository at this point in the history
* feat: Add events to disperse

* rename

* deploy

* add from to event
  • Loading branch information
andresaiello authored Jan 28, 2024
1 parent fc42ff8 commit d7f76a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/zevm-app-contracts/contracts/disperse/Disperse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -36,15 +39,20 @@ 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(
IERC20 token,
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]);
}
}
}
2 changes: 1 addition & 1 deletion packages/zevm-app-contracts/data/addresses.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"zevm": {
"zeta_testnet": {
"disperse": "0x1E0F767F48Fb10FcF820703f116E9B0F87319d63",
"disperse": "0xf394dc01879E39f19eDA533EFD10C82eEee5B2b1",
"rewardDistributorFactory": "0x667e4C493d40015256BDC89E3ba750B2F90359E1",
"zetaSwap": "0x44D1F1f9289DBA1Cf5824bd667184cEBE020aA1c",
"zetaSwapBtcInbound": "0x008b393933D5CA2457Df570CA5D628380FFf6da4",
Expand Down

0 comments on commit d7f76a5

Please sign in to comment.