2020-08-25 15:49:21 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-06 21:11:23 +00:00
|
|
|
|
2020-08-24 17:30:39 +00:00
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
2020-09-12 10:12:37 +00:00
|
|
|
interface DeployerInterface {
|
2020-09-12 09:33:57 +00:00
|
|
|
function signer(address) external view returns (bool);
|
2020-09-06 21:11:23 +00:00
|
|
|
function isConnector(address[] calldata) external view returns (bool);
|
2020-08-24 17:30:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contract Flusher {
|
2020-09-06 21:11:23 +00:00
|
|
|
event LogCast(address indexed sender, uint value);
|
2020-08-24 17:30:39 +00:00
|
|
|
|
2020-09-06 21:11:23 +00:00
|
|
|
string constant public name = "Flusher-v1";
|
2020-09-06 22:05:09 +00:00
|
|
|
|
2020-09-12 10:12:37 +00:00
|
|
|
DeployerInterface public constant deployer = DeployerInterface(address(0)); // TODO - Change while deploying
|
2020-08-24 17:30:39 +00:00
|
|
|
|
2020-09-06 21:11:23 +00:00
|
|
|
function spell(address _target, bytes memory _data) internal {
|
2020-08-24 17:30:39 +00:00
|
|
|
require(_target != address(0), "target-invalid");
|
|
|
|
assembly {
|
2020-09-06 21:11:23 +00:00
|
|
|
let succeeded := delegatecall(gas(), _target, add(_data, 0x20), mload(_data), 0, 0)
|
2020-08-24 17:30:39 +00:00
|
|
|
switch iszero(succeeded)
|
2020-09-06 21:11:23 +00:00
|
|
|
case 1 {
|
|
|
|
let size := returndatasize()
|
|
|
|
returndatacopy(0x00, 0x00, size)
|
|
|
|
revert(0x00, size)
|
|
|
|
}
|
2020-08-24 17:30:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-06 21:11:23 +00:00
|
|
|
function cast(address[] calldata _targets, bytes[] calldata _datas) external payable {
|
2020-09-12 10:12:37 +00:00
|
|
|
require(deployer.signer(msg.sender), "not-signer");
|
2020-09-06 21:11:23 +00:00
|
|
|
require(_targets.length == _datas.length , "invalid-array-length");
|
2020-09-12 10:12:37 +00:00
|
|
|
require(deployer.isConnector(_targets), "not-connector");
|
2020-09-06 21:11:23 +00:00
|
|
|
for (uint i = 0; i < _targets.length; i++) {
|
|
|
|
spell(_targets[i], _datas[i]);
|
|
|
|
}
|
|
|
|
emit LogCast(msg.sender, msg.value);
|
|
|
|
}
|
2020-08-24 17:32:13 +00:00
|
|
|
|
2020-09-06 21:11:23 +00:00
|
|
|
receive() external payable {}
|
|
|
|
}
|