编译器
0.8.19+commit.7dd6d404
文件 1 的 19:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 19:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 19:ERC1155.sol
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
mapping(uint256 => mapping(address => uint256)) private _balances;
mapping(address => mapping(address => bool)) private _operatorApprovals;
string private _uri;
constructor(string memory uri_) {
_setURI(uri_);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual override returns (uint256[] memory) {
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
function _burn(address from, uint256 id, uint256 amount) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
文件 4 的 19:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 19:FloridaManCard.sol
pragma solidity ^0.8.19;
import "openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-contracts/contracts/utils/Context.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import "openzeppelin-contracts/contracts/utils/math/SafeMath.sol";
import "openzeppelin-contracts/contracts/utils/Strings.sol";
import "v2-periphery/interfaces/IUniswapV2Router02.sol";
import "./IFloridaManCard.sol";
import "./IFloridaManCardStaking.sol";
contract FloridaManCard is ERC1155, Ownable, IFloridaManCard {
using SafeMath for uint256;
struct Card {
uint256 id;
uint256 price;
uint256 totalSupply;
uint256 maxOwnable;
uint256 level;
}
struct Season {
uint256 id;
uint256 level1Probability;
uint256 level2Probability;
uint256 level3Probability;
uint256 level4Probability;
uint256 level5Probability;
uint256 mysteryPack1Price;
uint256 mysteryPack5Price;
uint256 mysteryPack10Price;
uint256[] cardIds;
}
string public name = "Florida Man Card";
string public symbol = "FMANCARD";
address payable private _developerAddress;
address internal _tokenAddress = 0xD56990D60A7Abf3a7945F0565A98A708234b802C;
address internal _wethAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address internal _usdcAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address internal _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address internal _stakingAddress = address(0);
bool internal _mintingActive = false;
uint256[] internal _cardIds;
uint256[] internal _seasonIds;
mapping(uint256 => Card) internal _cardMap;
mapping(uint256 => Season) internal _seasonMap;
mapping(uint256 => uint256) internal _cardSupply;
mapping(uint256 => bool) internal _mintDroppableMap;
modifier onlyDeveloper() {
require(_developerAddress == _msgSender(), "Caller is not the developer");
_;
}
modifier onlyOwnerOrDeveloper() {
require(owner() == _msgSender() || _developerAddress == _msgSender(), "Caller is not owner or developer");
_;
}
event CreateCard(address indexed _firom, uint256 indexed _id, uint256 _level);
event CreateSeason(address indexed _from, uint256 indexed _id, uint256[] _cardIds);
event Purchase(address indexed _from, uint256 _amount, string _token);
event SeasonProbabilitesUpdate(
address indexed _from,
uint256 indexed _id,
uint256 _level1Probability,
uint256 _level2Probability,
uint256 _level3Probability,
uint256 _level4Probability,
uint256 _level5Probability
);
event SeasonPackPricesUpdate(
address indexed _from, uint256 indexed _id, uint256 _pack1Price, uint256 _pack5Price, uint256 _pack10Price
);
event SeasonCardsUpdate(address indexed _from, uint256 indexed _id, uint256[] _cardIds);
constructor(address __developerAddress, address __tokenAddress) ERC1155("https://nft.floridamantoken.com/jsons/") {
_developerAddress = payable(__developerAddress);
_tokenAddress = __tokenAddress;
}
function setDeveloperAddress(address payable newAddress) external onlyDeveloper {
_developerAddress = newAddress;
}
function setTokenAddress(address newTokenAddress) external onlyOwner {
_tokenAddress = newTokenAddress;
}
function setUsdcAddress(address newAddress) external onlyOwner {
_usdcAddress = newAddress;
}
function setRouterAddress(address newRouterAddress) external onlyOwner {
_routerAddress = newRouterAddress;
}
function setMintingActive(bool newState) external onlyOwner {
_mintingActive = newState;
}
function setMintDroppable(uint256 _cardId, bool droppable) external onlyOwner {
require(isCardValid(_cardId), "Card does not exist");
_mintDroppableMap[_cardId] = droppable;
}
function createCard(uint256 _id, uint256 _priceUSD, uint256 _totalSupply, uint256 _maxOwnable, uint256 _level)
external
onlyOwner
{
require(!isCardValid(_id), "Card with id already exists");
require(_totalSupply >= 1, "Total available must be > 0");
require(_maxOwnable >= 1, "Max ownable must be > 0");
require(_level >= 1 && _level <= 5, "Level must be between 1 & 5");
Card memory newCard =
Card({id: _id, price: _priceUSD, totalSupply: _totalSupply, maxOwnable: _maxOwnable, level: _level});
_cardMap[_id] = newCard;
_cardIds.push(_id);
emit CreateCard(_msgSender(), _id, _level);
}
function updateCard(uint256 _id, uint256 _priceUSD, uint256 _totalSupply, uint256 _maxOwnable, uint256 _level)
external
onlyOwner
{
require(isCardValid(_id), "Card does not exist");
require(_totalSupply >= 1, "Total available must be > 0");
require(_totalSupply >= _cardSupply[_id], "Total available must be more than minted supply");
require(_maxOwnable >= 1, "Max ownable must be > 0");
require(_level >= 1 && _level <= 5, "Level must be between 1 & 5");
Card storage fetchedCard = _cardMap[_id];
fetchedCard.price = _priceUSD;
fetchedCard.totalSupply = _totalSupply;
fetchedCard.maxOwnable = _maxOwnable;
fetchedCard.level = _level;
}
function createSeason(
uint256 _id,
uint256[] memory __cardIds,
uint256 _level1Probability,
uint256 _level2Probability,
uint256 _level3Probability,
uint256 _level4Probability,
uint256 _level5Probability,
uint256 _mysteryPack1PriceUSD,
uint256 _mysteryPack5PriceUSD,
uint256 _mysteryPack10PriceUSD
) external onlyOwner {
require(!_seasonExists(_id), "Season with id already exists");
require(
_level1Probability + _level2Probability + _level3Probability + _level4Probability + _level5Probability
== 100,
"Probabilities must equal 100"
);
Season storage season = _seasonMap[_id];
season.id = _id;
for (uint256 i = 0; i < __cardIds.length; i++) {
uint256 _cardId = __cardIds[i];
require(isCardValid(_cardId), "Card does not exist");
season.cardIds.push(_cardId);
}
season.level1Probability = _level1Probability;
season.level2Probability = _level2Probability;
season.level3Probability = _level3Probability;
season.level4Probability = _level4Probability;
season.level5Probability = _level5Probability;
season.mysteryPack1Price = _mysteryPack1PriceUSD;
season.mysteryPack5Price = _mysteryPack5PriceUSD;
season.mysteryPack10Price = _mysteryPack10PriceUSD;
_seasonIds.push(_id);
emit CreateSeason(_msgSender(), _id, _cardIds);
}
function updateSeasonProbabilities(
uint256 _id,
uint256 _level1Probability,
uint256 _level2Probability,
uint256 _level3Probability,
uint256 _level4Probability,
uint256 _level5Probability
) external onlyOwner {
require(_seasonExists(_id), "Season does not exist");
require(
_level1Probability + _level2Probability + _level3Probability + _level4Probability + _level5Probability
== 100,
"Probabilities must equal 100"
);
Season storage season = _seasonMap[_id];
season.level1Probability = _level1Probability;
season.level2Probability = _level2Probability;
season.level3Probability = _level3Probability;
season.level4Probability = _level4Probability;
season.level5Probability = _level5Probability;
emit SeasonProbabilitesUpdate(
_msgSender(),
_id,
_level1Probability,
_level2Probability,
_level3Probability,
_level4Probability,
_level5Probability
);
}
function updateSeasonPackPrices(
uint256 _id,
uint256 _mysteryPack1PriceUSD,
uint256 _mysteryPack5PriceUSD,
uint256 _mysteryPack10PriceUSD
) external onlyOwner {
require(_seasonExists(_id), "Season does not exist");
Season storage season = _seasonMap[_id];
season.mysteryPack1Price = _mysteryPack1PriceUSD;
season.mysteryPack5Price = _mysteryPack5PriceUSD;
season.mysteryPack10Price = _mysteryPack10PriceUSD;
emit SeasonPackPricesUpdate(
_msgSender(), _id, _mysteryPack1PriceUSD, _mysteryPack5PriceUSD, _mysteryPack10PriceUSD
);
}
function updateSeasonCards(uint256 _id, uint256[] memory __cardIds) external onlyOwner {
require(_seasonExists(_id), "Season does not exist");
Season storage season = _seasonMap[_id];
season.cardIds = new uint256[](__cardIds.length);
for (uint256 i = 0; i < __cardIds.length; i++) {
uint256 _cardId = __cardIds[i];
require(isCardValid(_cardId), "Card does not exist");
Card memory fetchedCard = _cardMap[_cardId];
require(_cardSupply[_cardId] < fetchedCard.totalSupply, "Card supply exhausted, update card's totalSupply");
season.cardIds[i] = _cardId;
}
emit SeasonCardsUpdate(_msgSender(), _id, __cardIds);
}
function mintBatch(address _to, uint256[] memory _ids, uint256[] memory _amounts) public onlyOwner {
_mintBatch(_to, _ids, _amounts, "0x");
for (uint256 i = 0; i < _ids.length; i++) {
_cardSupply[_ids[i]] = _cardSupply[_ids[i]].add(_amounts[i]);
}
}
function mintStakeBatch(address _for, uint256[] memory _ids, uint256[] memory _amounts) external onlyOwner {
require(_stakingAddress != address(0), "Staking contract address not set");
mintBatch(_for, _ids, _amounts);
IFloridaManCardStaking(payable(address(_stakingAddress))).stakeBatch(_for, _ids, _amounts);
}
function withdrawFMAN() public onlyOwner {
uint256 balance = IERC20(_tokenAddress).balanceOf(address(this));
require(IERC20(_tokenAddress).transfer(owner(), balance), "Failed to withdraw to owner");
}
function withdrawETH() public onlyOwner {
uint256 balance = address(this).balance;
uint256 developerBalance = balance.mul(1000).div(10000);
uint256 ownerBalance = balance.sub(developerBalance);
payable(_developerAddress).transfer(developerBalance);
payable(owner()).transfer(ownerBalance);
}
function uri(uint256 _id) public view override returns (string memory) {
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
function isCardValid(uint256 _id) public view returns (bool) {
Card memory fetchedCard = _cardMap[_id];
if (fetchedCard.id > 0) {
return true;
}
return false;
}
function isSeasonValid(uint256 _id) public view returns (bool) {
Season memory fetchedSeason = _seasonMap[_id];
if (fetchedSeason.id > 0) {
return true;
}
return false;
}
function isMintingActive() external view returns (bool active) {
return _mintingActive;
}
function isMintDroppable(uint256 _cardId) external view returns (bool droppable) {
require(isCardValid(_cardId), "Card does not exist");
return _mintDroppableMap[_cardId];
}
function getMintedSupply(uint256 _cardId) external view returns (uint256 supply) {
require(isCardValid(_cardId), "Card does not exist");
return _cardSupply[_cardId];
}
function getAvailableSupply(uint256 _cardId) public view returns (uint256 supply) {
require(isCardValid(_cardId), "Card does not exist");
if (_cardSupply[_cardId] > _cardMap[_cardId].totalSupply) {
return 0;
}
return _cardMap[_cardId].totalSupply - _cardSupply[_cardId];
}
function getMysterPackPrices(uint256 _seasonId)
external
view
returns (uint256 pack1, uint256 pack5, uint256 pack10)
{
require(_seasonExists(_seasonId), "Season does not exist");
Season memory season = _seasonMap[_seasonId];
uint256 pack1Price = _getFMANFromUSD(season.mysteryPack1Price);
uint256 pack5Price = _getFMANFromUSD(season.mysteryPack5Price);
uint256 pack10Price = _getFMANFromUSD(season.mysteryPack10Price);
return (pack1Price, pack5Price, pack10Price);
}
function getAvailableSeasonSupply(uint256 _id) external view returns (uint256 supply) {
require(_seasonExists(_id), "Season does not exist");
uint256[] memory seasonCardIds = _seasonMap[_id].cardIds;
uint256 available = 0;
for (uint256 i = 0; i < seasonCardIds.length; i++) {
available += getAvailableSupply(seasonCardIds[i]);
}
return available;
}
function getCard(uint256 _id)
external
view
returns (
uint256 id,
uint256 level,
uint256 usdPrice,
uint256 totalSupply,
uint256 maxOwnable,
uint256 availableAmount,
uint256 ownedAmount
)
{
require(isCardValid(_id), "Card does not exist");
Card memory fetchedCard = _cardMap[_id];
uint256 available = getAvailableSupply(fetchedCard.id);
uint256 owned = 0;
if (_msgSender() != address(0)) {
balanceOf(_msgSender(), fetchedCard.id);
}
return (
fetchedCard.id,
fetchedCard.level,
fetchedCard.price,
fetchedCard.totalSupply,
fetchedCard.maxOwnable,
available,
owned
);
}
function getSeasonIds() external view returns (uint256[] memory allSeasonIds) {
return _seasonIds;
}
function getCardIds() external view returns (uint256[] memory allCardIds) {
return _cardIds;
}
function getSeasonCards(uint256 _id) external view returns (uint256[] memory seasonCardIds) {
require(_seasonExists(_id), "Season does not exist");
return _seasonMap[_id].cardIds;
}
function mintMysteryPack(address _to, uint256 _seasonId, uint256 _quantity)
external
returns (uint256[] memory minted)
{
require(_mintingActive, "Minting is not active");
require(_seasonExists(_seasonId), "Season does not exist");
require(_quantity == 1 || _quantity == 5 || _quantity == 10, "Quantity must be 1,5, or 10");
Season memory season = _seasonMap[_seasonId];
uint256 seasonCardSupply = 0;
for (uint256 i = 0; i < season.cardIds.length; i++) {
uint256 cardId = season.cardIds[i];
seasonCardSupply = seasonCardSupply + getAvailableSupply(cardId);
}
require(seasonCardSupply >= _quantity, "Not enough cards left to mint");
uint256 usdAmount = season.mysteryPack10Price;
if (_quantity == 5) {
usdAmount = season.mysteryPack5Price;
} else if (_quantity == 1) {
usdAmount = season.mysteryPack1Price;
}
uint256 tokenAmount = _getFMANFromUSD(usdAmount);
require(IERC20(_tokenAddress).balanceOf(_msgSender()) >= tokenAmount, "Insufficient balance to mint");
require(IERC20(_tokenAddress).transferFrom(_msgSender(), address(this), tokenAmount), "Failed to transfer FMAN");
emit Purchase(_msgSender(), tokenAmount, "FMAN");
uint256[] memory randomSeeds = __generateRandomMulti(_generateRandom(), _quantity);
uint256[] memory mintedCardIds = new uint256[](_quantity);
for (uint256 i = 0; i < _quantity; i++) {
uint256 seed = randomSeeds[i];
uint256 cardId = _getMysteryPackCard(_to, _seasonId, seed);
_mint(_to, cardId, 1, "0x");
_cardSupply[cardId] = _cardSupply[cardId].add(1);
mintedCardIds[i] = cardId;
}
return mintedCardIds;
}
function mintDrop(address _to, uint256 _cardId, uint256 _quantity) external payable returns (uint256 minted) {
require(_mintingActive, "Minting is not active");
require(isCardValid(_cardId), "Card does not exist");
require(_mintDroppableMap[_cardId], "Card is not mint droppable");
Card memory fetchedCard = _cardMap[_cardId];
uint256 supply = getAvailableSupply(_cardId);
uint256 ownedBalance = balanceOf(_to, _cardId);
require(supply > 0, "Card has no supply left");
require(ownedBalance < fetchedCard.maxOwnable, "Owned max supply of card");
uint256 tokenAmount = _getETHFromUSD(fetchedCard.price * _quantity);
require(msg.value >= tokenAmount, "Insufficient balance to mint");
emit Purchase(_msgSender(), tokenAmount, "ETH");
_mint(_to, _cardId, _quantity, "0x");
_cardSupply[_cardId] = _cardSupply[_cardId].add(1);
return _cardId;
}
function transfer(address _to, uint256 _id, uint256 _quantity) external {
safeTransferFrom(_msgSender(), _to, _id, _quantity, "0x");
}
function _getFMANFromUSD(uint256 _usd) internal view returns (uint256 amount) {
address[] memory path = new address[](3);
path[0] = _usdcAddress;
path[1] = _wethAddress;
path[2] = _tokenAddress;
uint256[] memory amounts = IUniswapV2Router02(_routerAddress).getAmountsOut(_usd * (10 ** 6), path);
return amounts[2];
}
function _getETHFromUSD(uint256 _usd) public view returns (uint256 amount) {
address[] memory path = new address[](2);
path[0] = _usdcAddress;
path[1] = _wethAddress;
uint256[] memory amounts = IUniswapV2Router02(_routerAddress).getAmountsOut(_usd * (10 ** 6), path);
return amounts[1];
}
function _seasonExists(uint256 _id) internal view returns (bool) {
Season memory season = _seasonMap[_id];
if (season.id > 0) {
return true;
}
return false;
}
function _getSeasonLevelProbability(uint256 _id, uint256 _level) internal view returns (uint256 probability) {
require(_seasonExists(_id), "Season does not exist");
Season memory season = _seasonMap[_id];
if (_level == 1) {
return season.level1Probability;
} else if (_level == 2) {
return season.level2Probability;
} else if (_level == 3) {
return season.level3Probability;
} else if (_level == 4) {
return season.level4Probability;
} else if (_level == 5) {
return season.level5Probability;
}
}
function _getMysteryPackMintableCardIds(address _owner, uint256 _seasonId)
internal
view
returns (uint256[] memory ids)
{
require(_seasonExists(_seasonId), "Season does not exist");
Season memory season = _seasonMap[_seasonId];
uint256[] memory seasonCardIds = season.cardIds;
uint256[] memory mintableCardIds = new uint256[](seasonCardIds.length);
for (uint256 i = 0; i < seasonCardIds.length; i++) {
Card memory fetchedCard = _cardMap[seasonCardIds[i]];
uint256 supply = getAvailableSupply(fetchedCard.id);
uint256 ownedBalance = balanceOf(_owner, fetchedCard.id);
if (supply > 0 && ownedBalance < fetchedCard.maxOwnable) {
mintableCardIds[i] = fetchedCard.id;
} else {
mintableCardIds[i] = 0;
}
}
return mintableCardIds;
}
function _getMysteryPackCard(address _owner, uint256 _seasonId, uint256 _targetNumberSeed)
internal
view
returns (uint256 id)
{
require(_seasonExists(_seasonId), "Season does not exist");
Season memory season = _seasonMap[_seasonId];
uint256 level = _getMysteryPackLevel(_owner, _seasonId, _targetNumberSeed);
for (uint256 i = 0; i < season.cardIds.length; i++) {
Card memory fetchedCard = _cardMap[season.cardIds[i]];
if (fetchedCard.level == level) {
return fetchedCard.id;
}
}
return _getMysteryPackCard(_owner, _seasonId, _targetNumberSeed);
}
function _getMysteryPackLevel(address _owner, uint256 _seasonId, uint256 _targetNumberSeed)
internal
view
returns (uint256 level)
{
uint256[] memory mintableCardIds = _getMysteryPackMintableCardIds(_owner, _seasonId);
uint256 totalWeight = 0;
uint256[] memory levels = new uint256[](_cardIds.length);
for (uint256 i = 0; i < mintableCardIds.length; i++) {
if (mintableCardIds[i] > 0) {
uint256 probability = _getSeasonLevelProbability(_seasonId, mintableCardIds[i]);
totalWeight = totalWeight + probability;
levels[i] = probability;
}
}
uint256 targetNumber = _targetNumberSeed.mod(totalWeight).add(1);
for (uint256 i = 0; i < levels.length; i++) {
if (targetNumber <= levels[i]) {
return i + 1;
}
targetNumber = targetNumber - levels[i];
}
return _getMysteryPackLevel(_owner, _seasonId, _targetNumberSeed);
}
function _generateRandom() private view returns (uint256) {
return uint256(keccak256(abi.encodePacked(block.prevrandao, block.timestamp)));
}
function __generateRandomMulti(uint256 _seed, uint256 _times) private pure returns (uint256[] memory generated) {
generated = new uint256[](_times);
for (uint256 i = 0; i < _times; i++) {
generated[i] = uint256(keccak256(abi.encode(_seed, i)));
}
return generated;
}
}
文件 6 的 19:IERC1155.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155 is IERC165 {
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
function balanceOf(address account, uint256 id) external view returns (uint256);
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
function setApprovalForAll(address operator, bool approved) external;
function isApprovedForAll(address account, address operator) external view returns (bool);
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 7 的 19:IERC1155MetadataURI.sol
pragma solidity ^0.8.0;
import "../IERC1155.sol";
interface IERC1155MetadataURI is IERC1155 {
function uri(uint256 id) external view returns (string memory);
}
文件 8 的 19:IERC1155Receiver.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155Receiver is IERC165 {
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
文件 9 的 19:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 10 的 19:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
文件 11 的 19:IFloridaManCard.sol
import "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
pragma solidity ^0.8.19;
interface IFloridaManCard is IERC1155 {
function mintMysteryPack(address _to, uint256 _seasonId, uint256 _quantity)
external
returns (uint256[] memory minted);
function withdrawFMAN() external;
function transfer(address _to, uint256 _id, uint256 _quantity) external;
function isCardValid(uint256 _id) external view returns (bool);
function isSeasonValid(uint256 _id) external view returns (bool);
function getSeasonCards(uint256 _id) external view returns (uint256[] memory seasonCardIds);
function getSeasonIds() external view returns (uint256[] memory allSeasonIds);
function getCardIds() external view returns (uint256[] memory allCardIds);
function getCard(uint256 _id)
external
view
returns (
uint256 id,
uint256 level,
uint256 usdPrice,
uint256 totalSupply,
uint256 maxOwnable,
uint256 availableAmount,
uint256 ownedAmount
);
}
文件 12 的 19:IFloridaManCardStaking.sol
pragma solidity ^0.8.19;
interface IFloridaManCardStaking {
event Stake(address indexed _from, uint256 indexed _id, uint256 _quantity);
event Unstake(address indexed _from, uint256 indexed _id, uint256 _quantity);
function stakeBatch(address _for, uint256[] memory _ids, uint256[] memory _quantities) external;
function distribute(uint256 _startIndex) external;
}
文件 13 的 19:IUniswapV2Router01.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
文件 14 的 19:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
文件 15 的 19:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1, "Math: mulDiv overflow");
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
文件 16 的 19:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 17 的 19:SafeMath.sol
pragma solidity ^0.8.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
文件 18 的 19:SignedMath.sol
pragma solidity ^0.8.0;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 19 的 19:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
{
"compilationTarget": {
"src/FloridaManCard.sol": "FloridaManCard"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":v2-core/=lib/v2-core/contracts/",
":v2-periphery/=lib/v2-periphery/contracts/",
"lib/forge-std:ds-test/=lib/forge-std/lib/ds-test/src/",
"lib/openzeppelin-contracts:ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/openzeppelin-contracts:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/openzeppelin-contracts:forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/",
"lib/openzeppelin-contracts:openzeppelin/=lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"__developerAddress","type":"address"},{"internalType":"address","name":"__tokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_firom","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level","type":"uint256"}],"name":"CreateCard","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"_cardIds","type":"uint256[]"}],"name":"CreateSeason","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"_token","type":"string"}],"name":"Purchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"_cardIds","type":"uint256[]"}],"name":"SeasonCardsUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_pack1Price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_pack5Price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_pack10Price","type":"uint256"}],"name":"SeasonPackPricesUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level1Probability","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level2Probability","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level3Probability","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level4Probability","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_level5Probability","type":"uint256"}],"name":"SeasonProbabilitesUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"uint256","name":"_usd","type":"uint256"}],"name":"_getETHFromUSD","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_priceUSD","type":"uint256"},{"internalType":"uint256","name":"_totalSupply","type":"uint256"},{"internalType":"uint256","name":"_maxOwnable","type":"uint256"},{"internalType":"uint256","name":"_level","type":"uint256"}],"name":"createCard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256[]","name":"__cardIds","type":"uint256[]"},{"internalType":"uint256","name":"_level1Probability","type":"uint256"},{"internalType":"uint256","name":"_level2Probability","type":"uint256"},{"internalType":"uint256","name":"_level3Probability","type":"uint256"},{"internalType":"uint256","name":"_level4Probability","type":"uint256"},{"internalType":"uint256","name":"_level5Probability","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack1PriceUSD","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack5PriceUSD","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack10PriceUSD","type":"uint256"}],"name":"createSeason","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"getAvailableSeasonSupply","outputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cardId","type":"uint256"}],"name":"getAvailableSupply","outputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"getCard","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"uint256","name":"usdPrice","type":"uint256"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"maxOwnable","type":"uint256"},{"internalType":"uint256","name":"availableAmount","type":"uint256"},{"internalType":"uint256","name":"ownedAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCardIds","outputs":[{"internalType":"uint256[]","name":"allCardIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cardId","type":"uint256"}],"name":"getMintedSupply","outputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_seasonId","type":"uint256"}],"name":"getMysterPackPrices","outputs":[{"internalType":"uint256","name":"pack1","type":"uint256"},{"internalType":"uint256","name":"pack5","type":"uint256"},{"internalType":"uint256","name":"pack10","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"getSeasonCards","outputs":[{"internalType":"uint256[]","name":"seasonCardIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSeasonIds","outputs":[{"internalType":"uint256[]","name":"allSeasonIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"isCardValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cardId","type":"uint256"}],"name":"isMintDroppable","outputs":[{"internalType":"bool","name":"droppable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMintingActive","outputs":[{"internalType":"bool","name":"active","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"isSeasonValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_cardId","type":"uint256"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"mintDrop","outputs":[{"internalType":"uint256","name":"minted","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_seasonId","type":"uint256"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"mintMysteryPack","outputs":[{"internalType":"uint256[]","name":"minted","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_for","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"mintStakeBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setDeveloperAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cardId","type":"uint256"},{"internalType":"bool","name":"droppable","type":"bool"}],"name":"setMintDroppable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newState","type":"bool"}],"name":"setMintingActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRouterAddress","type":"address"}],"name":"setRouterAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTokenAddress","type":"address"}],"name":"setTokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setUsdcAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_priceUSD","type":"uint256"},{"internalType":"uint256","name":"_totalSupply","type":"uint256"},{"internalType":"uint256","name":"_maxOwnable","type":"uint256"},{"internalType":"uint256","name":"_level","type":"uint256"}],"name":"updateCard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256[]","name":"__cardIds","type":"uint256[]"}],"name":"updateSeasonCards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack1PriceUSD","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack5PriceUSD","type":"uint256"},{"internalType":"uint256","name":"_mysteryPack10PriceUSD","type":"uint256"}],"name":"updateSeasonPackPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_level1Probability","type":"uint256"},{"internalType":"uint256","name":"_level2Probability","type":"uint256"},{"internalType":"uint256","name":"_level3Probability","type":"uint256"},{"internalType":"uint256","name":"_level4Probability","type":"uint256"},{"internalType":"uint256","name":"_level5Probability","type":"uint256"}],"name":"updateSeasonProbabilities","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFMAN","outputs":[],"stateMutability":"nonpayable","type":"function"}]