forked from OpenSpace100/blockchain-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMultiCall.sol
More file actions
45 lines (33 loc) · 1.1 KB
/
Copy pathtestMultiCall.sol
File metadata and controls
45 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/utils/Multicall.sol";
import "@openzeppelin/contracts/utils/Address.sol";
contract TestMulticall {
mapping(address => uint256) public deposits;
uint public count;
// 0xd09de08a
function increment() external payable {
count += 1;
deposits[msg.sender] += msg.value;
}
// issue: payable need to remove
// [0xd0e30db0, 0xd09de08a]
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
// 0xd0e30db0
function deposit() external payable {
deposits[msg.sender] += msg.value;
}
//
function withdraw() external {
uint d = deposits[msg.sender];
deposits[msg.sender] = 0;
(bool success, ) = msg.sender.call{value: d}("");
require(success, "Failed to send Ether");
}
}