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

Deploy disperse to athens #120

Merged
merged 4 commits into from
Sep 27, 2023
Merged
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
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);
});
Loading