Skip to content

Commit 08d532b

Browse files
authored
Merge pull request #30 from Web3Camp-Labs/main
merge back
2 parents 0968f60 + 57abe60 commit 08d532b

15 files changed

Lines changed: 9228 additions & 117 deletions

File tree

abi/MultiSender.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,47 @@
135135
"stateMutability": "payable",
136136
"type": "function"
137137
},
138+
{
139+
"inputs": [
140+
{
141+
"internalType": "address",
142+
"name": "_token",
143+
"type": "address"
144+
},
145+
{
146+
"internalType": "address[]",
147+
"name": "_targets",
148+
"type": "address[]"
149+
},
150+
{
151+
"internalType": "uint256",
152+
"name": "_amount",
153+
"type": "uint256"
154+
}
155+
],
156+
"name": "batchSendFixedERC20",
157+
"outputs": [],
158+
"stateMutability": "nonpayable",
159+
"type": "function"
160+
},
161+
{
162+
"inputs": [
163+
{
164+
"internalType": "address payable[]",
165+
"name": "_targets",
166+
"type": "address[]"
167+
},
168+
{
169+
"internalType": "uint256",
170+
"name": "_amount",
171+
"type": "uint256"
172+
}
173+
],
174+
"name": "batchSendFixedEther",
175+
"outputs": [],
176+
"stateMutability": "payable",
177+
"type": "function"
178+
},
138179
{
139180
"inputs": [
140181
{

cli/send.ts

Lines changed: 283 additions & 70 deletions
Large diffs are not rendered by default.

cli/testaddress.csv

Lines changed: 8625 additions & 0 deletions
Large diffs are not rendered by default.

contracts/MultiSender.sol

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ contract MultiSender is OwnableUpgradeable, ReentrancyGuardUpgradeable {
4242
return true;
4343
}
4444

45+
function batchSendFixedERC20(
46+
address _token,
47+
address[] memory _targets,
48+
uint256 _amount
49+
) public {
50+
require(_targets.length > 0, "none address provided");
51+
52+
IERC20Upgradeable token = IERC20Upgradeable(_token);
53+
uint256 total = _amount * _targets.length;
54+
for (uint256 i = 0; i < _targets.length; i++) {
55+
token.safeTransferFrom(msg.sender, _targets[i], _amount);
56+
}
57+
emit MultisendToken(total, _token);
58+
}
59+
4560
function batchSendEther(
4661
address payable[] memory _targets,
4762
uint256[] memory _amounts
@@ -66,6 +81,23 @@ contract MultiSender is OwnableUpgradeable, ReentrancyGuardUpgradeable {
6681
emit MultisendToken(total, address(0));
6782
}
6883

84+
function batchSendFixedEther(
85+
address payable[] memory _targets,
86+
uint256 _amount
87+
) public payable {
88+
require(_targets.length > 0, "none address provided");
89+
uint256 total = _targets.length * _amount;
90+
91+
require(msg.value >= total, "insufficient fund");
92+
93+
for (uint256 i = 0; i < _targets.length; i++) {
94+
(bool sent, ) = _targets[i].call{value: _amount}("");
95+
require(sent, "transfer eth failed");
96+
}
97+
98+
emit MultisendToken(total, address(0));
99+
}
100+
69101
function claimBalance(address _token) public onlyOwner {
70102
uint256 balance = 0x0;
71103
address _owner = this.owner();

front-end/pages/_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function MyApp({ Component, pageProps }: AppProps) {
1414
<ContextProvider>
1515
<Component {...pageProps} />
1616
</ContextProvider>
17-
<link rel="stylesheet" href="https://web3camp.us/globals.css"/>
17+
<link rel="stylesheet" href="./globals.css"/>
1818
</>
1919
}
2020

front-end/pages/components/footerBox.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import styled from "styled-components";
22
import {Container} from 'react-bootstrap';
33
const Footer = styled.div`
44
height: 80px;
5-
margin-top: 100px;
5+
margin-top: 60px;
6+
width: 100%;
7+
padding-top: 15px;
8+
background: #fff;
9+
font-size: 14px;
610
.midBox{
711
display: flex;
812
justify-content: space-between;
@@ -15,18 +19,28 @@ const Footer = styled.div`
1519
.lft{
1620
padding-left: 10px;
1721
}
22+
a{
23+
display: inline-block;
24+
margin-left: 20px;
25+
}
1826
`
1927
export default function footerBox(){
2028
return <Footer>
2129
<Container>
2230
<div className="midBox">
23-
<div className="lft">&copy; 2022 Web3camp.us</div>
31+
<a href="https://web3camp.us" target="_blank" rel="noreferrer">
32+
<div className="lft">&copy; 2022 Web3camp.us</div>
33+
</a>
34+
2435
<div>
25-
<a href="https://github.com/Web3-Camp/multisender" target="_blank" rel="noreferrer">
26-
<img src="https://web3camp.us/assets/images/GitHub-Mark.png" alt=""/>
36+
<a href="https://github.com/Web3Camp-Labs/multisender" target="_blank" rel="noreferrer">
37+
<img src="./github.png" alt=""/>
38+
</a>
39+
<a href="https://twitter.com/Web3Camp" target="_blank" rel="noreferrer">
40+
<img src="./Twitter.png" alt=""/>
2741
</a>
2842
</div>
2943
</div>
3044
</Container>
31-
</Footer>
45+
</Footer>
3246
}

front-end/pages/components/step2.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,25 +242,25 @@ export default function Step2(props:Iprops) {
242242
//
243243
// if (chainId === 1) {
244244
// sender = contracts.mainnet;
245-
// // url = 'https://etherscan.io/tx/';
245+
// // url = 'https://etherscan.io/tx';
246246
// // } else if (chainId === 42) {
247247
// // sender = contracts.kovan;
248-
// // url = 'https://kovan.etherscan.io/tx/';
248+
// // url = 'https://kovan.etherscan.io/tx';
249249
// // } else if (chainId === 128) {
250250
// // sender = contracts.heco;
251-
// // url = 'https://hecoinfo.com/tx/';
251+
// // url = 'https://hecoinfo.com/tx';
252252
// // } else if (chainId === 256) {
253253
// // sender = contracts.hecotest;
254-
// // url = 'https://testnet.hecoinfo.com/tx/';
254+
// // url = 'https://testnet.hecoinfo.com/tx';
255255
// } else if (chainId === 137) {
256256
// sender = contracts.polygon;
257-
// // url = 'https://polygonscan.com/tx/';
257+
// // url = 'https://polygonscan.com/tx';
258258
// } else if (chainId === 56) {
259259
// sender = contracts.bsc;
260-
// // url = 'https://bscscan.com/tx/';
260+
// // url = 'https://bscscan.com/tx';
261261
// } else if (chainId === 97) {
262262
// sender = contracts.bsctest;
263-
// // url = 'https://testnet.bscscan.com/tx/';
263+
// // url = 'https://testnet.bscscan.com/tx';
264264
// } else {
265265
// console.error('Unsupported network!!!!');
266266
// return;
@@ -393,11 +393,10 @@ export default function Step2(props:Iprops) {
393393

394394
settips(`Sending Ether in progress... (${txIndex}/${Math.ceil(addressArray.length / pageSize)})`);
395395
dispatch({ type: ActionType.TIPS, payload: `Sending Ether in progress... (${txIndex}/${Math.ceil(addressArray.length / pageSize)})` })
396-
397-
await multiSender.connect(signer).batchSendEther(addressArr, amountWeiArr, { from: account, value: ethers.utils.hexValue(sendValue) }).then((data: {
398-
transactionHash: string; hash: string;
399-
}) => {
400-
console.log('batchSendEther', data);
396+
try{
397+
let res = await multiSender.connect(signer).batchSendEther(addressArr, amountWeiArr, { from: account, value: ethers.utils.hexValue(sendValue) })
398+
let data = await res.wait();
399+
console.log('batchSendEther', res);
401400
txHashArr.push(data.hash || data?.transactionHash);
402401
if (txIndex >= Math.ceil(addressArray.length / pageSize)) {
403402
setshowLoading(false);
@@ -406,12 +405,13 @@ export default function Step2(props:Iprops) {
406405
handleNext(3);
407406

408407
}
409-
}).catch((err: any) => {
408+
}catch (err: any){
410409
console.error('batchSendEther error: ', err);
411-
setErrorTips(err.data?.message || err.message)
410+
setErrorTips(err.data?.message || err.message)
412411
setshowLoading(false);
413412
dispatch({ type: ActionType.TIPS, payload: null })
414-
});
413+
}
414+
415415

416416
}
417417
// setTxHashList(txHashArr);
@@ -468,8 +468,9 @@ export default function Step2(props:Iprops) {
468468
}
469469

470470
const downLoadExcel = (data:string[]) => {
471-
if (importRecord == null ) return;
472-
let amountStr = `Address,amount\n`;
471+
if (importRecord == null || !data.length) return;
472+
let amountStr = `Address,Amount\n`;
473+
let addressStr = "";
473474
importRecord.map((item)=>{
474475
const { address, amount} = item;
475476
let isSuccess = false;
@@ -479,10 +480,13 @@ export default function Step2(props:Iprops) {
479480
}
480481
}
481482
if(!isSuccess){
482-
amountStr += `${address},${amount} \n`;
483+
addressStr += `${address},${amount} \n`;
483484
}
484485
});
485-
console.log(amountStr)
486+
amountStr += addressStr;
487+
console.log(addressStr.split("\n"))
488+
if(addressStr.split("\n").length === 1) return;
489+
486490

487491
let uri = `data:text/csv;charset=utf-8,\ufeff ${amountStr}`;
488492

front-end/pages/config/url.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
[
22
{
33
"id": 1,
4-
"url": "https://etherscan.io/tx/"
4+
"url": "https://etherscan.io/tx"
55
},
66
{
77
"id": 42,
8-
"url": "https://kovan.etherscan.io/tx/"
8+
"url": "https://kovan.etherscan.io/tx"
99
},
1010
{
1111
"id": 56,
12-
"url": "https://bscscan.com/tx/"
12+
"url": "https://bscscan.com/tx"
1313
},
1414
{
1515
"id": 97,
16-
"url": "https://testnet.bscscan.com/tx/"
16+
"url": "https://testnet.bscscan.com/tx"
1717
},
1818
{
1919
"id": 128,
20-
"url": "https://hecoinfo.com/tx/"
20+
"url": "https://hecoinfo.com/tx"
2121
},
2222
{
2323
"id": 137,
24-
"url": "https://polygonscan.com/tx/"
24+
"url": "https://polygonscan.com/tx"
2525
},
2626
{
2727
"id": 256,
28-
"url": "https://testnet.hecoinfo.com/tx/"
28+
"url": "https://testnet.hecoinfo.com/tx"
2929
}
3030
]

front-end/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const NavBox = styled.div`
4545
height: 80px;
4646
}
4747
li{
48-
background: #fff;
49-
padding: 0 40px;
48+
background: #FAFBFC;
49+
padding: 0 20px;
5050
.circle{
5151
width: 80px;
5252
height: 80px;

front-end/public/Twitter.png

1.92 KB
Loading

0 commit comments

Comments
 (0)