-
Notifications
You must be signed in to change notification settings - Fork 76
/
DenialFactory.sol
34 lines (26 loc) · 958 Bytes
/
DenialFactory.sol
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import '../BaseLevel.sol';
import './Denial.sol';
contract DenialFactory is Level {
uint public initialDeposit = 0.001 ether;
function createInstance(address _player) override public payable returns (address) {
_player;
require(msg.value >= initialDeposit);
Denial instance = new Denial();
(bool result,) = address(instance).call{value:msg.value}("");
require(result);
return address(instance);
}
function validateInstance(address payable _instance, address _player) override public returns (bool) {
_player;
Denial instance = Denial(_instance);
if (address(instance).balance <= 100 wei) { // cheating otherwise
return false;
}
// fix the gas limit for this call
(bool result,) = address(instance).call{gas:1000000}(abi.encodeWithSignature("withdraw()")); // Must revert
return !result;
}
receive() external payable {}
}