From ae246b225b289b35bf2c7d9306a2c1fc5e6f36bf Mon Sep 17 00:00:00 2001 From: hans Date: Tue, 4 Jan 2022 21:16:25 -0800 Subject: [PATCH 1/3] added: matic network --- .../src/contracts/hardhat_contracts.json | 218 +++++++++++++++++- 1 file changed, 217 insertions(+), 1 deletion(-) diff --git a/packages/react-app/src/contracts/hardhat_contracts.json b/packages/react-app/src/contracts/hardhat_contracts.json index 7eba6f23..5d28b79f 100644 --- a/packages/react-app/src/contracts/hardhat_contracts.json +++ b/packages/react-app/src/contracts/hardhat_contracts.json @@ -1,11 +1,227 @@ { + "1": { + "mainnet": { + "name": "mainnet", + "chainId": "1", + "contracts": { + "Distributor": { + "address": "0x3E1516166E38eF3C995BDad7a27e8B1643e3450D", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "ethDistributed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "tokenDistributed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeEther", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + } + } + } + }, "5": { "goerli": { "name": "goerli", "chainId": "5", "contracts": { "Distributor": { - "address": "0x7B31B672aF3160F7f90799D41223Ab05840c3097", + "address": "0x80fB8Dc425f13b9118d8B382803cAA5289F93218", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "ethDistributed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "tokenDistributed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeEther", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + } + } + } + }, + "137": { + "matic": { + "name": "matic", + "chainId": "137", + "contracts": { + "Distributor": { + "address": "0x9d9957844608f0784c4e7bfa44d3261f355e28a9", "abi": [ { "anonymous": false, From 659c63258881a66a8eb88d3be51a45513e8fd369 Mon Sep 17 00:00:00 2001 From: hans Date: Tue, 4 Jan 2022 21:37:45 -0800 Subject: [PATCH 2/3] solmates --- packages/hardhat/contracts/Distributor.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/hardhat/contracts/Distributor.sol b/packages/hardhat/contracts/Distributor.sol index bfb37cd9..0c630835 100644 --- a/packages/hardhat/contracts/Distributor.sol +++ b/packages/hardhat/contracts/Distributor.sol @@ -55,8 +55,7 @@ contract Distributor { } if (msg.value > total) { - (bool sent, ) = msg.sender.call{value: msg.value - total}(""); - require(sent, "FAILED_CONTRACT_DRAIN"); + SafeTransferLib.safeTransferETH(msg.sender, msg.value - total); } emit ethDistributed(msg.sender, id); From 08b3d40322e53ea7eae4024d421e12c74aedc7da Mon Sep 17 00:00:00 2001 From: hans Date: Tue, 4 Jan 2022 22:02:36 -0800 Subject: [PATCH 3/3] abi update --- .../src/contracts/hardhat_contracts.json | 114 +++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/packages/react-app/src/contracts/hardhat_contracts.json b/packages/react-app/src/contracts/hardhat_contracts.json index 5d28b79f..129bb1ff 100644 --- a/packages/react-app/src/contracts/hardhat_contracts.json +++ b/packages/react-app/src/contracts/hardhat_contracts.json @@ -5,7 +5,115 @@ "chainId": "1", "contracts": { "Distributor": { - "address": "0x3E1516166E38eF3C995BDad7a27e8B1643e3450D", + "address": "0x14313eB3823D0268C49d2D977b6Fb1eE2233Ef20", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "ethDistributed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "tokenDistributed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeEther", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "distributeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + } + } + } + }, + "4": { + "rinkeby": { + "name": "rinkeby", + "chainId": "4", + "contracts": { + "Distributor": { + "address": "0xEa99C58645f897ac8BF530538e36e6D651ff8bF7", "abi": [ { "anonymous": false, @@ -113,7 +221,7 @@ "chainId": "5", "contracts": { "Distributor": { - "address": "0x80fB8Dc425f13b9118d8B382803cAA5289F93218", + "address": "0xC7fE6Af7dAa0e3f98d56ebbABdE0b97EfA5Ed42f", "abi": [ { "anonymous": false, @@ -221,7 +329,7 @@ "chainId": "137", "contracts": { "Distributor": { - "address": "0x9d9957844608f0784c4e7bfa44d3261f355e28a9", + "address": "0x9bb1f87f3e80bee26bcb491489c1b41e0e15b16d", "abi": [ { "anonymous": false,