lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.1.6
/// @dev Returns a boolean for whether the given address is in the given generation.
/// @param self The pool to operate on.
/// @param resourceAddress The address to check membership of
/// @param generationId The id of the generation to check.
function isInGeneration(Pool storage self, address resourceAddress, uint generationId) constant returns (bool) {
            // TODO: tests
            if (generationId == 0) {
                return false;
            }
            Generation memory generation = self.generations[generationId];
            for (uint i = 0; i < generation.members.length; i++) {
                if (generation.members[i] == resourceAddress) {
                    return true;
                }
            }
            return false;
        }
// Solidity 0.1.6
/// @dev Returns a boolean as to whether the provided address is allowed to enter the pool at this time.
/// @param self The pool to operate on.
/// @param resourceAddress The address in question
/// @param minimumBond The minimum bond amount that should be required for entry.
function canEnterPool(Pool storage self, address resourceAddress, uint minimumBond) constant returns (bool) {
            /*
             *  - bond
             *  - pool is open
             *  - not already in it.
             *  - not already left it.
             */
            // TODO: tests
            if (self.bonds[resourceAddress] < minimumBond) {
                // Insufficient bond balance;
                return false;
            }

            if (isInPool(self, resourceAddress)) {
                // Already in the pool either in the next upcoming generation
                // or the currently active generation.
                return false;
            }

            var nextGenerationId = getNextGenerationId(self);
            if (nextGenerationId != 0) {
                var nextGeneration = self.generations[nextGenerationId];
                if (block.number + self.freezePeriod >= nextGeneration.startAt) {
                    // Next generation starts too soon.
                    return false;
                }
            }

            return true;
        }
// Solidity 0.1.6
/// @dev Adds the address to pool by adding them to the next generation (as well as creating it if it doesn't exist).
/// @param self The pool to operate on.
/// @param resourceAddress The address to be added to the pool
/// @param minimumBond The minimum bond amount that should be required for entry.
function enterPool(Pool storage self, address resourceAddress, uint minimumBond) public returns (uint) {
            if (!canEnterPool(self, resourceAddress, minimumBond)) {
                throw;
            }
            uint nextGenerationId = getNextGenerationId(self);
            if (nextGenerationId == 0) {
                // No next generation has formed yet so create it.
                nextGenerationId = createNextGeneration(self);
            }
            Generation storage nextGeneration = self.generations[nextGenerationId];
            // now add the new address.
            nextGeneration.members.length += 1;
            nextGeneration.members[nextGeneration.members.length - 1] = resourceAddress;
            return nextGenerationId;
        }
// Solidity 0.1.6
/// @dev Returns a boolean as to whether the provided address is allowed to exit the pool at this time.
/// @param self The pool to operate on.
/// @param resourceAddress The address in question
function canExitPool(Pool storage self, address resourceAddress) constant returns (bool) {
            if (!isInCurrentGeneration(self, resourceAddress)) {
                // Not in the pool.
                return false;
            }

            uint nextGenerationId = getNextGenerationId(self);
            if (nextGenerationId == 0) {
                // Next generation hasn't been generated yet.
                return true;
            }

            if (self.generations[nextGenerationId].startAt - self.freezePeriod <= block.number) {
                // Next generation starts too soon.
                return false;
            }

            // They can leave if they are still in the next generation.
            // otherwise they have already left it.
            return isInNextGeneration(self, resourceAddress);
        }
// Solidity 0.1.6
/// @dev Removes the address from the pool by removing them from the next generation (as well as creating it if it doesn't exist)
/// @param self The pool to operate on.
/// @param resourceAddress The address in question
function exitPool(Pool storage self, address resourceAddress) public returns (uint) {
            if (!canExitPool(self, resourceAddress)) {
                throw;
            }
            uint nextGenerationId = getNextGenerationId(self);
            if (nextGenerationId == 0) {
                // No next generation has formed yet so create it.
                nextGenerationId = createNextGeneration(self);
            }
            // Remove them from the generation
            removeFromGeneration(self, nextGenerationId, resourceAddress);
            return nextGenerationId;
        }
// Solidity 0.1.6
/// @dev Removes the address from a generation's members array. Returns boolean as to whether removal was successful.
/// @param self The pool to operate on.
/// @param generationId The id of the generation to operate on.
/// @param resourceAddress The address to be removed.
function removeFromGeneration(Pool storage self, uint generationId, address resourceAddress) public returns (bool){
            Generation storage generation = self.generations[generationId];
            // now remove the address
            for (uint i = 0; i < generation.members.length; i++) {
                if (generation.members[i] == resourceAddress) {
                    generation.members[i] = generation.members[generation.members.length - 1];
                    generation.members.length -= 1;
                    return true;
                }
            }
            return false;
        }
// Solidity 0.1.6
/// @dev Subtracts the amount from an account's bond balance.
/// @param self The pool to operate on.
/// @param resourceAddress The address of the account
/// @param value The value to subtract.
function deductFromBond(Pool storage self, address resourceAddress, uint value) public {
                /*
                 *  deduct funds from a bond value without risk of an
                 *  underflow.
                 */
                if (value > self.bonds[resourceAddress]) {
                        // Prevent Underflow.
                        throw;
                }
                self.bonds[resourceAddress] -= value;
        }
// Solidity 0.1.6
/// @dev Adds the amount to an account's bond balance.
/// @param self The pool to operate on.
/// @param resourceAddress The address of the account
/// @param value The value to add.
function addToBond(Pool storage self, address resourceAddress, uint value) public {
                /*
                 *  Add funds to a bond value without risk of an
                 *  overflow.
                 */
                if (self.bonds[resourceAddress] + value < self.bonds[resourceAddress]) {
                        // Prevent Overflow
                        throw;
                }
                self.bonds[resourceAddress] += value;
        }
// Solidity 0.1.6
/// @dev Withdraws a bond amount from an address's bond account, sending them the corresponding amount in ether.
/// @param self The pool to operate on.
/// @param resourceAddress The address of the account
/// @param value The value to withdraw.
function withdrawBond(Pool storage self, address resourceAddress, uint value, uint minimumBond) public {
                /*
                 *  Only if you are not in either of the current call pools.
                 */
                // Prevent underflow
                if (value > self.bonds[resourceAddress]) {
                        throw;
                }

                // Do a permissions check to be sure they can withdraw the
                // funds.
                if (isInPool(self, resourceAddress)) {
                        if (self.bonds[resourceAddress] - value < minimumBond) {
                            return;
                        }
                }

                deductFromBond(self, resourceAddress, value);
                if (!resourceAddress.send(value)) {
                        // Potentially sending money to a contract that
                        // has a fallback function.  So instead, try
                        // tranferring the funds with the call api.
                        if (!resourceAddress.call.gas(msg.gas).value(value)()) {
                                // Revert the entire transaction.  No
                                // need to destroy the funds.
                                throw;
                        }
                }
        }
// Solidity 0.4.24
/**
 * @dev Locks a specified amount of tokens against an address,
 *      for a specified reason and time
 * @param _reason The reason to lock tokens
 * @param _amount Number of tokens to be locked
 * @param _time Lock time in seconds
 */
function lock(bytes32 _reason, uint256 _amount, uint256 _time)
        public
        returns (bool)
    {
        uint256 validUntil = now.add(_time); //solhint-disable-line

        // If tokens are already locked, then functions extendLock or
        // increaseLockAmount should be used to make any changes
        require(tokensLocked(msg.sender, _reason) == 0, ALREADY_LOCKED);
        require(_amount != 0, AMOUNT_ZERO);

        if (locked[msg.sender][_reason].amount == 0)
            lockReason[msg.sender].push(_reason);

        transfer(address(this), _amount);

        locked[msg.sender][_reason] = lockToken(_amount, validUntil, false);

        emit Locked(msg.sender, _reason, _amount, validUntil);
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Transfers and Locks a specified amount of tokens,
 *      for a specified reason and time
 * @param _to adress to which tokens are to be transfered
 * @param _reason The reason to lock tokens
 * @param _amount Number of tokens to be transfered and locked
 * @param _time Lock time in seconds
 */
function transferWithLock(address _to, bytes32 _reason, uint256 _amount, uint256 _time)
        public
        returns (bool)
    {
        uint256 validUntil = now.add(_time); //solhint-disable-line

        require(tokensLocked(_to, _reason) == 0, ALREADY_LOCKED);
        require(_amount != 0, AMOUNT_ZERO);

        if (locked[_to][_reason].amount == 0)
            lockReason[_to].push(_reason);

        transfer(address(this), _amount);

        locked[_to][_reason] = lockToken(_amount, validUntil, false);
        
        emit Locked(_to, _reason, _amount, validUntil);
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Unlocks the unlockable tokens of a specified address
 * @param _of Address of user, claiming back unlockable tokens
 */
function unlock(address _of)
        public
        returns (uint256 unlockableTokens)
    {
        uint256 lockedTokens;

        for (uint256 i = 0; i < lockReason[_of].length; i++) {
            lockedTokens = tokensUnlockable(_of, lockReason[_of][i]);
            if (lockedTokens > 0) {
                unlockableTokens = unlockableTokens.add(lockedTokens);
                locked[_of][lockReason[_of][i]].claimed = true;
                emit Unlocked(_of, lockReason[_of][i], lockedTokens);
            }
        }  

        if (unlockableTokens > 0)
            this.transfer(_of, unlockableTokens);
    }
// Solidity 0.5.17
// Returns new campaignId.
function startCommitReveal(
        uint _startBlock,
        uint _commitDuration,
        uint _revealDuration,
        uint _revealThreshold
    )
        public
        onlyFromProxy
        returns(uint)
    {
        uint newCid = campaigns.length;
        campaigns.push(Campaign(_startBlock, _commitDuration, _revealDuration, _revealThreshold, 0, 0, 0));
        emit LogStartCommitReveal(newCid, _startBlock, _commitDuration, _revealDuration, _revealThreshold);
        return newCid;
    }
// Solidity 0.5.17
// Return value of 0 representing invalid random output.
function getRandom(uint _cid) public checkFinish(_cid) returns (uint) {
        Campaign storage c = campaigns[_cid];
        if (c.revealNum >= c.revealThreshold) {
            emit LogRandom(_cid, c.generatedRandom);
            return c.generatedRandom;
        } else{
            emit LogRandomFailure(_cid, c.commitNum, c.revealNum, c.revealThreshold);
            return 0;
        }
    }
// Solidity 0.4.24
/**
 * batch
 */
function transferArray(address[] _to, uint256[] _value) public {
        require(_to.length == _value.length);
        uint256 sum = 0;
        for(uint256 i = 0; i< _value.length; i++) {
            sum += _value[i];
        }
        require(balanceOf[msg.sender] >= sum);
        for(uint256 k = 0; k < _to.length; k++){
            _transfer(msg.sender, _to[k], _value[k]);
        }
    }
// Solidity 0.8.7
/// @notice Claim Adventure Gold for a given Loot ID
/// @param tokenId The tokenId of the Loot NFT
function claimById(uint256 tokenId) external {
        // Follow the Checks-Effects-Interactions pattern to prevent reentrancy
        // attacks

        // Checks

        // Check that the msgSender owns the token that is being claimed
        require(
            _msgSender() == lootContract.ownerOf(tokenId),
            "MUST_OWN_TOKEN_ID"
        );

        // Further Checks, Effects, and Interactions are contained within the
        // _claim() function
        _claim(tokenId, _msgSender());
    }
// Solidity 0.8.7
/// @notice Claim Adventure Gold for all tokens owned by the sender
/// @notice This function will run out of gas if you have too much loot! If
/// this is a concern, you should use claimRangeForOwner and claim Adventure
/// Gold in batches.
function claimAllForOwner() external {
        uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());

        // Checks
        require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");

        // i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
        for (uint256 i = 0; i < tokenBalanceOwner; i++) {
            // Further Checks, Effects, and Interactions are contained within
            // the _claim() function
            _claim(
                lootContract.tokenOfOwnerByIndex(_msgSender(), i),
                _msgSender()
            );
        }
    }
// Solidity 0.8.7
/// @dev Internal function to mint Loot upon claiming
function _claim(uint256 tokenId, address tokenOwner) internal {
        // Checks
        // Check that the token ID is in range
        // We use >= and <= to here because all of the token IDs are 0-indexed
        require(
            tokenId >= tokenIdStart && tokenId <= tokenIdEnd,
            "TOKEN_ID_OUT_OF_RANGE"
        );

        // Check that Adventure Gold have not already been claimed this season
        // for a given tokenId
        require(
            !seasonClaimedByTokenId[season][tokenId],
            "GOLD_CLAIMED_FOR_TOKEN_ID"
        );

        // Effects

        // Mark that Adventure Gold has been claimed for this season for the
        // given tokenId
        seasonClaimedByTokenId[season][tokenId] = true;

        // Interactions

        // Send Adventure Gold to the owner of the token ID
        _mint(tokenOwner, adventureGoldPerTokenId);
    }
// Solidity 0.8.12
// --------------------------------------------------------
// 
//  Returns a random index of token to mint depending on
//  sender addr and current block timestamp & difficulty
// 
// --------------------------------------------------------
function getRandomTokenIndex (address senderAddress) internal returns (uint) {
        uint randomNumber = random(string(abi.encodePacked(senderAddress)));
        uint i = (randomNumber % mintConfig.remaining) + mintConfig.startIndex;

        // --------------------------------------------------------
        // 
        //  If there's a cache at mintCache[i] then use it
        //  otherwise use i itself
        // 
        // --------------------------------------------------------
        uint index = mintCache[i] == 0 ? i : mintCache[i];

        // --------------------------------------------------------
        // 
        //  Grab a number from the tail & decrease remaining
        // 
        // --------------------------------------------------------
        mintCache[i] = mintCache[mintConfig.remaining - 1 + mintConfig.startIndex] == 0 ? mintConfig.remaining - 1 + mintConfig.startIndex : mintCache[mintConfig.remaining - 1 + mintConfig.startIndex];
        mintConfig.remaining--;

        return index;
    }
// Solidity 0.8.12
// --------------------------------------------------------
// 
//  Returns a date for a tokenId
//  date range: 01.01.22 - 28.12.25
// 
// --------------------------------------------------------
function getDate (uint256 _tokenId) internal pure returns (string memory) {
        uint deterministicNumber = deterministic(GuestlistedLibrary.toString(_tokenId));
        uint day = deterministicNumber % 28 + 1;
        uint month = deterministicNumber % 12 + 1;
        uint yearDeterministic = deterministicNumber % 4;
        string memory yearString = '22';

        if (yearDeterministic == 1) yearString = '23';
        else if (yearDeterministic == 2) yearString = '24';
        else if (yearDeterministic == 3) yearString = '25';

        string memory dayString = GuestlistedLibrary.toString(day);
        if (day < 10) dayString = string(abi.encodePacked('0', dayString));

        string memory monthString = GuestlistedLibrary.toString(month);
        if (month < 10) monthString = string(abi.encodePacked('0', monthString));

        return string(abi.encodePacked(dayString, '.', monthString, '.', yearString));
    }
// Solidity 0.8.12
// --------------------------------------------------------
// 
//  Updates a venue in the storage at specified index
//  Adds a new venue if the index is -1
// 
// --------------------------------------------------------
function updateVenue (int _index, GuestlistedLibrary.Venue memory _venue) public onlyOwner {
        require((_index == -1) || (uint(_index) < venues.length), 'Can not update non-existent venue.');
        if (_index == -1) venues.push(_venue);
        else venues[uint(_index)] = _venue;
    }
// Solidity 0.8.12
// ----------------------------------------------------------------
// 
//  Erease and update the custom metadata for a set of tokens.
//  This metadata will be added to specified tokens in the
//  tokenURI method.
// 
// ----------------------------------------------------------------
function updateCustomMetadata (uint[] memory _tokenIds, CustomMetadata[] memory _customMetadata) external onlyOwner {
        for (uint i = 0; i < _tokenIds.length; i++) {
            delete customMetadata[_tokenIds[i]];
            for (uint j = 0; j < _customMetadata.length; j++) {
                customMetadata[_tokenIds[i]].push(_customMetadata[j]);
            }
        }
    }
// Solidity 0.8.12
// ----------------------------------------------------------------
// 
//  Erease and update the custom attributes for a set of tokens.
//  Those attributes will be added to specified tokens in the
//  tokenURI method.
// 
// ----------------------------------------------------------------
function updateCustomAttributes (uint[] memory _tokenIds, CustomAttribute[] memory _customAttributes) external onlyOwner {
        for (uint i = 0; i < _tokenIds.length; i++) {
            delete customAttributes[_tokenIds[i]];
            for (uint j = 0; j < _customAttributes.length; j++) {
                customAttributes[_tokenIds[i]].push(_customAttributes[j]);
            }
        }
    }
// Solidity 0.8.12
// ----------------------------------------------------------------
// 
//  Returns un array of tokens owned by an address
//  (gas optimisation of tokenOfOwnerByIndex from ERC721Enumerable)
// 
// ----------------------------------------------------------------
function tokensOfOwner(address _ownerAddress) public virtual view returns (uint[] memory) {
        uint balance = balanceOf(_ownerAddress);
        uint[] memory tokens = new uint[](balance);
        uint tokenId;
        uint found;

        while (found < balance) {
            if (_exists(tokenId) && ownerOf(tokenId) == _ownerAddress) {
                tokens[found++] = tokenId;
            }
            tokenId++;
        }

        return tokens;
    }
// Solidity 0.8.3
/**
 * @notice Transfer tokens to multiple recipient
 * @dev Address array and amount array are 1:1 and are in order.
 * @param _recipients array of recipient addresses
 * @param _amounts array of token amounts
 * @return true/false
 */
function multiTransfer(address[] memory _recipients, uint256[] memory _amounts) external returns (bool) {
        require(_recipients.length == _amounts.length, "input-length-mismatch");
        for (uint256 i = 0; i < _recipients.length; i++) {
            require(transfer(_recipients[i], _amounts[i]), "multi-transfer-failed");
        }
        return true;
    }
// Solidity 0.5.7
/**
 * @dev Wesion freezed amount.
 */
function WesionFreezed() public view returns (uint256) {
        uint256 __freezed;

        if (now > _till) {
            uint256 __qrPassed = now.sub(_till).div(_3mo);

            if (__qrPassed >= 10) {
                __freezed = 0;
            }
            else {
                __freezed = _WesionAmount.mul(_freezedPct[__qrPassed]).div(100);
            }

            return __freezed;
        }

        return _WesionAmount;
    }
// Solidity 0.8.4
/**
 * @dev Mint function, step 3 of the wrapping process.
 * Users must call this function after reserving their NFT with the `reserveNFT` function and having it transferred to
 * this contract by interacting with the original Lunar contract.
 */
function mint(uint256 id) external {
        require(lunar.ownerOf(id) == address(this), "Lunar not owned by this contract");
        require(reservations[id] == msg.sender, "Caller doesn't have a reservation on this nft");

        lunar.setPrice(id, false, 0);
        _mint(msg.sender, id);
        delete reservations[id];
    }
// Solidity 0.5.8
/**
 * @dev Multiplies two unsigned integers, revert on overflow.
 */
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }
// Solidity 0.5.8
/**
 * @dev Update the storgeOperator.
 * @param _newOperator The newOperator to update.
 */
function updateOperator(address _newOperator) public onlyOwner {
        require(_newOperator != address(0), "Cannot change the newOperator to the zero address");
        require(isContract(_newOperator), "New operator must be contract address");
        emit OperatorChanged(_operator, _newOperator);
        _operator = _newOperator;
    }