-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecretDoor.sol
38 lines (31 loc) · 881 Bytes
/
SecretDoor.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
35
36
37
38
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "hardhat/console.sol";
contract SecretDoor is Ownable, ReentrancyGuard {
bool public isLocked;
uint8 private doorNumber;
bytes32 private doorOwnerName;
bytes32 private secretSpell;
constructor(
uint8 _doorNumber,
bool _isLocked,
bytes32 _doorOwnerName,
bytes32 _secretSpell
) {
doorNumber = _doorNumber;
isLocked = _isLocked;
doorOwnerName = _doorOwnerName;
secretSpell = _secretSpell;
}
function unlockDoor(bytes32 _secretSpell) external returns (bool) {
if (secretSpell == _secretSpell) {
isLocked = false;
} else {
isLocked = true;
}
console.log("unlockDoor: isLocked: %s", isLocked);
return !(isLocked);
}
}