Skip to content

Commit

Permalink
deploy disperse to athens
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Sep 25, 2023
1 parent 20bf86d commit b0129ae
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/addresses/src/addresses.athens.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"crossChainCounter": "",
"crossChainNft": "",
"dai": "",
"disperse": "",
"immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d",
"multiChainSwap": "0x8BD7144Ddb59c9Fa3Dcf809998521E9cAD946fa1",
"multiChainSwapZetaConnector": "",
Expand All @@ -30,6 +31,7 @@
"crossChainCounter": "",
"crossChainNft": "",
"dai": "",
"disperse": "",
"immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d",
"multiChainSwap": "0x323745f16C93e56a98012970c28788498d8B3a14",
"multiChainSwapZetaConnector": "",
Expand Down Expand Up @@ -82,6 +84,7 @@
"crossChainCounter": "",
"crossChainNft": "",
"dai": "",
"disperse": "",
"immutableCreate2Factory": "",
"multiChainSwap": "",
"multiChainValue": "",
Expand All @@ -107,6 +110,7 @@
"crossChainCounter": "",
"crossChainNft": "",
"dai": "",
"disperse": "0x1E0F767F48Fb10FcF820703f116E9B0F87319d63",
"immutableCreate2Factory": "",
"multiChainSwap": "",
"multiChainSwapZetaConnector": "",
Expand All @@ -133,6 +137,7 @@
"crossChainCounter": "",
"crossChainNft": "",
"dai": "",
"disperse": "",
"immutableCreate2Factory": "",
"multiChainSwap": "",
"multiChainSwapZetaConnector": "",
Expand Down
2 changes: 2 additions & 0 deletions packages/addresses/src/addresses.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ZetaAddress =
| "crossChainCounter"
| "crossChainNft"
| "dai"
| "disperse"
| "immutableCreate2Factory"
| "multiChainSwap"
| "multiChainSwapZetaConnector"
Expand Down Expand Up @@ -34,6 +35,7 @@ const zetaAddresses: Record<ZetaAddress, boolean> = {
crossChainCounter: true,
crossChainNft: true,
dai: true,
disperse: true,
immutableCreate2Factory: true,
multiChainSwap: true,
multiChainSwapZetaConnector: true,
Expand Down
24 changes: 24 additions & 0 deletions packages/zevm-app-contracts/contracts/disperse/Disperse.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "@openzeppelin/contracts/interfaces/IERC20.sol";

contract Disperse {
function disperseEther(address[] calldata recipients, uint256[] calldata values) external payable {
for (uint256 i = 0; i < recipients.length; i++) payable(recipients[i]).transfer(values[i]);
uint256 balance = address(this).balance;
if (balance > 0) payable(msg.sender).transfer(balance);
}

function disperseToken(IERC20 token, address[] calldata recipients, uint256[] calldata values) external {
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]));
}

function disperseTokenSimple(IERC20 token, address[] calldata recipients, uint256[] calldata values) external {
for (uint256 i = 0; i < recipients.length; i++)
require(token.transferFrom(msg.sender, recipients[i], values[i]));
}
}
23 changes: 23 additions & 0 deletions packages/zevm-app-contracts/scripts/disperse/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { isNetworkName } from "@zetachain/addresses";
import { saveAddress } from "@zetachain/addresses-tools";
import { ethers, network } from "hardhat";

import { Disperse__factory } from "../../typechain-types";

const networkName = network.name;

async function main() {
if (!isNetworkName(networkName)) throw new Error("Invalid network name");

const DisperseFactory = (await ethers.getContractFactory("Disperse")) as Disperse__factory;

const disperseFactory = await DisperseFactory.deploy();
await disperseFactory.deployed();
console.log("Disperse deployed to:", disperseFactory.address);
saveAddress("disperse", disperseFactory.address);
}

main().catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit b0129ae

Please sign in to comment.