Created
September 18, 2022 04:03
-
-
Save korrio/329aad898bae2d265a728aedd5e3a696 to your computer and use it in GitHub Desktop.
OnlyFans.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
abstract contract Context { | |
function _msgSender() internal view virtual returns (address) { | |
return msg.sender; | |
} | |
function _msgData() internal view virtual returns (bytes calldata) { | |
return msg.data; | |
} | |
} | |
abstract contract Ownable is Context { | |
address private _owner; | |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
/** | |
* @dev Initializes the contract setting the deployer as the initial owner. | |
*/ | |
constructor() { | |
_setOwner(_msgSender()); | |
} | |
/** | |
* @dev Returns the address of the current owner. | |
*/ | |
function owner() public view virtual returns (address) { | |
return _owner; | |
} | |
/** | |
* @dev Throws if called by any account other than the owner. | |
*/ | |
modifier onlyOwner() { | |
require(owner() == _msgSender(), "Ownable: caller is not the owner"); | |
_; | |
} | |
/** | |
* @dev Leaves the contract without owner. It will not be possible to call | |
* `onlyOwner` functions anymore. Can only be called by the current owner. | |
* | |
* NOTE: Renouncing ownership will leave the contract without an owner, | |
* thereby removing any functionality that is only available to the owner. | |
*/ | |
// function renounceOwnership() public virtual onlyOwner { | |
// _setOwner(address(0)); | |
// } | |
/** | |
* @dev Transfers ownership of the contract to a new account (`newOwner`). | |
* Can only be called by the current owner. | |
*/ | |
function transferOwnership(address newOwner) public virtual onlyOwner { | |
require(newOwner != address(0), "Ownable: new owner is the zero address"); | |
_setOwner(newOwner); | |
} | |
function _setOwner(address newOwner) private { | |
address oldOwner = _owner; | |
_owner = newOwner; | |
emit OwnershipTransferred(oldOwner, newOwner); | |
} | |
} | |
contract OnlyFans is Ownable { | |
// Enum representing Fans status | |
enum Status { | |
Pending, | |
Unpaid, | |
Paid, | |
Rejected, | |
Canceled | |
} | |
mapping (address => bool) public isFan; | |
mapping (address => Status) public fanStatus; | |
modifier onlyFans() { | |
require(isFan[msg.sender],"onlyFans: caller is not subscriber"); | |
_; | |
} | |
function setFan(address _fanAddress) public onlyOwner { | |
isFan[_fanAddress] = true; | |
} | |
function unsetFan(address _fanAddress) public onlyOwner { | |
isFan[_fanAddress] = false; | |
} | |
function setFanStatus(address _fanAddress, Status _status) public onlyOwner { | |
fanStatus[_fanAddress] = _status; | |
} | |
// Default value is the first element listed in | |
// definition of the type, in this case "Pending" | |
Status public status; | |
// Returns uint | |
// Pending - 0 | |
// Shipped - 1 | |
// Accepted - 2 | |
// Rejected - 3 | |
// Canceled - 4 | |
function get() public view returns (Status) { | |
return status; | |
} | |
// Update status by passing uint into input | |
function set(Status _status) public { | |
status = _status; | |
} | |
// You can update to a specific enum like this | |
function cancel() public { | |
status = Status.Canceled; | |
} | |
// delete resets the enum to its first value, 0 | |
function reset() public { | |
delete status; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment