lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
/**
 * @dev Function changes values associated with certain originalTxHash
 * @param originalTxHash Transaction hash to change
 * @param statusCode Associated status: 0-Not processed, 1-Processed, 2-Reverted
 * @param hashedParams Hashed params with which the initial transaction was executed
 */
function changeTxStatus(
        bytes32 originalTxHash,
        uint256 statusCode,
        bytes32 hashedParams
    ) external onlyRelayer {
        require(
            statusCode != 0,
            "swapContract: you cannot set the statusCode to 0"
        );
        require(
            processedTransactions[originalTxHash].statusCode != 1,
            "swapContract: transaction with this originalTxHash has already been set as succeed"
        );
        processedTransactions[originalTxHash].statusCode = statusCode;
        processedTransactions[originalTxHash].hashedParams = hashedParams;
    }
// Solidity 0.4.24
//Deletes from mapping (bytes32 => array[]) at index _index
function deleteArrayAddress(bytes32 _key, uint256 _index) internal {
        address[] storage array = addressArrayStorage[_key];
        require(_index < array.length, "Index should less than length of the array");
        array[_index] = array[array.length - 1];
        array.length = array.length - 1;
    }
// Solidity 0.4.24
//Deletes from mapping (bytes32 => bytes32[]) at index _index
function deleteArrayBytes32(bytes32 _key, uint256 _index) internal {
        bytes32[] storage array = bytes32ArrayStorage[_key];
        require(_index < array.length, "Index should less than length of the array");
        array[_index] = array[array.length - 1];
        array.length = array.length - 1;
    }
// Solidity 0.4.24
/**
 * @dev Upgrades the implementation address
 * @param _newVersion representing the version name of the new implementation to be set
 * @param _newImplementation representing the address of the new implementation to be set
 */
function _upgradeTo(string _newVersion, address _newImplementation) internal {
        require(
            __implementation != _newImplementation && _newImplementation != address(0),
            "Old address is not allowed and implementation address should not be 0x"
        );
        require(AddressUtils.isContract(_newImplementation), "Cannot set a proxy implementation to a non-contract address");
        require(bytes(_newVersion).length > 0, "Version should not be empty string");
        require(keccak256(abi.encodePacked(__version)) != keccak256(abi.encodePacked(_newVersion)), "New version equals to current");
        __version = _newVersion;
        __implementation = _newImplementation;
        emit Upgraded(_newVersion, _newImplementation);
    }
// Solidity 0.8.4
/**
 * @dev Converts a `uint256` to a `string`.
 * via OraclizeAPI - MIT licence
 * https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
 */
function fromUint(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + (temp % 10)));
            temp /= 10;
        }
        return string(buffer);
    }
// Solidity 0.8.4
/**
 * Index Of
 *
 * Locates and returns the position of a character within a string starting
 * from a defined offset
 *
 * @param _base When being used for a data type this is the extended object
 *              otherwise this is the string acting as the haystack to be
 *              searched
 * @param _value The needle to search for, at present this is currently
 *               limited to one character
 * @param _offset The starting point to start searching from which can start
 *                from 0, but must not exceed the length of the string
 * @return int The position of the needle starting from 0 and returning -1
 *             in the case of no matches found
 */
function indexOf(
        bytes memory _base,
        string memory _value,
        uint256 _offset
    ) internal pure returns (int256) {
        bytes memory _valueBytes = bytes(_value);

        assert(_valueBytes.length == 1);

        for (uint256 i = _offset; i < _base.length; i++) {
            if (_base[i] == _valueBytes[0]) {
                return int256(i);
            }
        }

        return -1;
    }
// Solidity 0.7.6
// Season of Plenty
function rewardEther(uint256 amount) internal {
        uint256 base;
        if (s.sop.base == 0) {
            base = amount.mul(BIG_BASE);
            s.sop.base = BURN_BASE;
        }
        else base = amount.mul(s.sop.base).div(s.sop.weth);

        // Award ether to claimed stalk holders
        uint256 basePerStalk = base.div(s.r.roots);
        base = basePerStalk.mul(s.r.roots);
        s.sops[s.r.start] = s.sops[s.r.start].add(basePerStalk);

        // Update total state
        s.sop.weth = s.sop.weth.add(amount);
        s.sop.base = s.sop.base.add(base);
        if (base > 0) s.sop.last = s.r.start;

    }
// Solidity 0.4.24
/** @param _owner The owner whose ships tokens we are interested in.
 * @dev This method MUST NEVER be called by smart contract code. First, it's fairly
 *  expensive (it walks the entire Collectibles owners array looking for NFT belonging to owner)
 */
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
        uint256 tokenCount = balanceOf(_owner);

        if (tokenCount == 0) {
            // Return an empty array
            return new uint256[](0);
        } else {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 totalItems = balanceOf(_owner);
            uint256 resultIndex = 0;

            // We count on the fact that all Collectible have IDs starting at 0 and increasing
            // sequentially up to the total count.
            uint256 _assetId;

            for (_assetId = 0; _assetId < totalItems; _assetId++) {
                result[resultIndex] = tokenOfOwnerByIndex(_owner,_assetId);
                resultIndex++;
            }

            return result;
        }
    }
// Solidity 0.7.6
/**
 * Shed
 **/
function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
// Solidity 0.4.24
/**
 * @notice Contribute to the presale up to `@tokenAmount(self.contributionToken(): address, _value)`
 * @param _contributor The address of the contributor
 * @param _value       The amount of contribution token to be spent
 */
function contribute(address _contributor, uint256 _value) external payable nonReentrant auth(CONTRIBUTE_ROLE) {
        require(state() == State.Funding, ERROR_INVALID_STATE);
        require(_value != 0,              ERROR_INVALID_CONTRIBUTE_VALUE);

        if (contributionToken == ETH) {
            require(msg.value == _value, ERROR_INVALID_CONTRIBUTE_VALUE);
        } else {
            require(msg.value == 0,      ERROR_INVALID_CONTRIBUTE_VALUE);
        }

        _contribute(_contributor, _value);
    }
// Solidity 0.4.24
/**
 * @notice Returns the current state of that presale
 */
function state() public view isInitialized returns (State) {
        if (openDate == 0 || openDate > getTimestamp64()) {
            return State.Pending;
        }

        if (totalRaised >= goal) {
            if (isClosed) {
                return State.Closed;
            } else {
                return State.GoalReached;
            }
        }

        if (_timeSinceOpen() < period) {
            return State.Funding;
        } else {
            return State.Refunding;
        }
    }
// Solidity 0.7.6
/**
 *  Liquidity
 **/
function addLiquidity(AddLiquidity calldata al) internal returns (uint256, uint256) {
        (uint256 beansDeposited, uint256 ethDeposited, uint256 liquidity) = _addLiquidity(
            msg.value,
            al.beanAmount,
            al.minEthAmount,
            al.minBeanAmount
        );
        (bool success,) = msg.sender.call{ value: msg.value.sub(ethDeposited) }("");
        require(success, "Market: Refund failed.");
        return (beansDeposited, liquidity);
    }
// Solidity 0.4.24
/// @dev internal function to update MLB player id
function _updateMLBPlayerId(uint256 _tokenId, uint256 _newMLBPlayerId) internal {

        // Get Token Obj
        NFT storage lsnftObj = allNFTs[_tokenId];
        
        lsnftObj.mlbPlayerId = _newMLBPlayerId;

        // Update Token Data with new updated attributes
        allNFTs[_tokenId] = lsnftObj;

        emit AssetUpdated(_tokenId);
    }
// Solidity 0.8.4
// Split the minting blob into token_id and blueprint portions
// {token_id}:{blueprint}
function split(bytes calldata blob)
        internal
        pure
        returns (uint256, bytes memory)
    {
        int256 index = Bytes.indexOf(blob, ":", 0);
        require(index >= 0, "Separator must exist");
        // Trim the { and } from the parameters
        uint256 tokenID = Bytes.toUint(blob[1:uint256(index) - 1]);
        uint256 blueprintLength = blob.length - uint256(index) - 3;
        if (blueprintLength == 0) {
            return (tokenID, bytes(""));
        }
        bytes calldata blueprint = blob[uint256(index) + 2:blob.length - 1];
        return (tokenID, blueprint);
    }
// Solidity 0.4.24
/// @dev internal function to update asset earnedBy value for an asset/token
function _updateEarnedBy(uint256 _tokenId, uint256 _earnedBy) internal {

        // Get Token Obj
        NFT storage lsnftObj = allNFTs[_tokenId];
        
        lsnftObj.earnedBy = _earnedBy;

        // Update Token Data with new updated attributes
        allNFTs[_tokenId] = lsnftObj;

        emit AssetUpdated(_tokenId);
    }
// Solidity 0.7.6
/**
 * Soil
 **/
function increaseSoil(uint256 amount) internal returns (int256) {
        uint256 maxTotalSoil = C.getMaxSoilRatioCap().mul(bean().totalSupply()).div(1e18);
        uint256 minTotalSoil = C.getMinSoilRatioCap().mul(bean().totalSupply()).div(1e18);
        if (s.f.soil > maxTotalSoil) {
            amount = s.f.soil.sub(maxTotalSoil);
            decrementTotalSoil(amount);
            return -int256(amount);
        }
        uint256 newTotalSoil = s.f.soil + amount;
        amount = newTotalSoil <= maxTotalSoil ? amount : maxTotalSoil.sub(s.f.soil);
        amount = newTotalSoil >= minTotalSoil ? amount : minTotalSoil.sub(s.f.soil);

        incrementTotalSoil(amount);
        return int256(amount);
    }
// Solidity 0.4.24
/**
 * @dev Generates promo collectibles. Only callable by Game Master, with isAttached as 0.
 * @notice The generation of an asset if limited via the generationSeasonController
 * @param _teamId           teamId of the asset/token/collectible
 * @param _posId            position of the asset/token/collectible
 * @param _attributes       attributes of asset/token/collectible
 * @param _owner            owner of asset/token/collectible
 * @param _gameId          mlb game Identifier
 * @param _playerOverrideId player override identifier
 * @param _mlbPlayerId      official mlb player identifier
 */
function createPromoCollectible(
        uint8 _teamId,
        uint8 _posId,
        uint256 _attributes,
        address _owner,
        uint256 _gameId,
        uint256 _playerOverrideId,
        uint256 _mlbPlayerId)
        external
        canCreate
        whenNotPaused
        returns (uint256)
        {

        address nftOwner = _owner;
        if (nftOwner == address(0)) {
             nftOwner = managerPrimary;
        }

        if(allNFTs.length > 0) {
            promoCreatedCount[_teamId]++;
        }
        
        uint32 _sequenceId = getSequenceId(_teamId);
        
        uint256 assetDetails = uint256(uint64(now));
        assetDetails |= uint256(_sequenceId)<<64;
        assetDetails |= uint256(_teamId)<<96;
        assetDetails |= uint256(_posId)<<104;

        uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId];
        
        return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData);
    }
// Solidity 0.7.6
/**
 * Public
 **/
function claim(Claim calldata c) public payable {
        if (c.beanWithdrawals.length > 0) _claimBeans(c.beanWithdrawals);
        if (c.lpWithdrawals.length > 0) {
            if (c.convertLP) _removeAndClaimLP(c.lpWithdrawals, c.minBeanAmount, c.minEthAmount);
            else _claimLP(c.lpWithdrawals);
        }
        if (c.plots.length > 0) _harvest(c.plots);
        if (c.claimEth) claimEth();
        if (msg.sender != address(this)) LibCheck.balanceCheck();
    }
// Solidity 0.7.6
// Claim Beans
function _claimBeans(uint32[] calldata withdrawals) private {
        uint256 beansClaimed = 0;
        for (uint256 i = 0; i < withdrawals.length; i++) {
            require(withdrawals[i] <= s.season.current, "Claim: Withdrawal not recievable.");
            beansClaimed = beansClaimed.add(claimBeanWithdrawal(msg.sender, withdrawals[i]));
        }
        IBean(s.c.bean).transfer(msg.sender, beansClaimed);
        emit BeanClaim(msg.sender, withdrawals, beansClaimed);
    }
// Solidity 0.4.24
/**
 * @dev Generaes a new single seed Collectible, with isAttached as 0.
 * @notice Helps in creating seed collectible.The generation of an asset if limited via the generationSeasonController
 * @param _teamId           teamId of the asset/token/collectible
 * @param _posId            position of the asset/token/collectible
 * @param _attributes       attributes of asset/token/collectible
 * @param _owner            owner of asset/token/collectible
 * @param _gameId          mlb game Identifier
 * @param _playerOverrideId player override identifier
 * @param _mlbPlayerId      official mlb player identifier
 */
function createSeedCollectible(
        uint8 _teamId,
        uint8 _posId,
        uint256 _attributes,
        address _owner,
        uint256 _gameId,
        uint256 _playerOverrideId,
        uint256 _mlbPlayerId)
        external
        canCreate
        whenNotPaused
        returns (uint256) {

        address nftOwner = _owner;
        
        if (nftOwner == address(0)) {
             nftOwner = managerPrimary;
        }
        
        seedCreatedCount++;
        uint32 _sequenceId = getSequenceId(_teamId);
        
        uint256 assetDetails = uint256(uint64(now));
        assetDetails |= uint256(_sequenceId)<<64;
        assetDetails |= uint256(_teamId)<<96;
        assetDetails |= uint256(_posId)<<104;

        uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId];
        
        return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData);
    }
// Solidity 0.4.24
//constructor function
//initializing lock-up periods and corresponding amounts of tokens
function CareerChainPrivateSale
    (
        uint256 _openingTime,
        uint256 _closingTime,
        uint256 _rate,
        address _wallet,
        uint256[6] _lockupEndTime,
        uint256 _firstVestedLockUpAmount,
        uint256 _stagedVestedLockUpAmounts,
        CareerChainToken _token
    )
        public
        Crowdsale(_rate, _wallet, _token)
        TimedCrowdsale(_openingTime, _closingTime)
    {
        // solium-disable-next-line security/no-block-members
        require(_lockupEndTime[0] >= block.timestamp);
        require(_lockupEndTime[1] >= _lockupEndTime[0]);
        require(_lockupEndTime[2] >= _lockupEndTime[1]);
        require(_lockupEndTime[3] >= _lockupEndTime[2]);
        require(_lockupEndTime[4] >= _lockupEndTime[3]);
        require(_lockupEndTime[5] >= _lockupEndTime[4]);

        lockupEndTime = _lockupEndTime;

        firstVestedLockUpAmount = _firstVestedLockUpAmount;
        stagedVestedLockUpAmounts = _stagedVestedLockUpAmounts;
    }
// Solidity 0.4.24
// Calculates the amount that has already vested.
function vestedAmount() private view returns (uint256) {
        uint256 lockupStage = 0;
        uint256 releasable = 0;

        //determine current lock-up phase
        uint256 i = 0;
        // solium-disable-next-line security/no-block-members
        while (i < lockupEndTime.length && lockupEndTime[i] <= now) {
            lockupStage = lockupStage.add(1);
            i = i.add(1);
        }

        //if lockupStage == 0 then all tokens are still in lock-up (first lock-up period not ended yet)
        if(lockupStage>0) {
            //calculate the releasable amount depending on the current lock-up stage
            releasable = (lockupStage.sub(1).mul(stagedVestedLockUpAmounts)).add(firstVestedLockUpAmount);
        }

        return releasable;
    }
// Solidity 0.4.24
//Withdraw tokens only after lock-up ends, applying the staged lock-up scheme.
function withdrawTokens() public {
        uint256 tobeReleased = 0;
        uint256 unreleased = releasableAmount();

        //max amount to be withdrawn is the releasable amount, excess stays in lock-up, unless all lock-ups have ended
        // solium-disable-next-line security/no-block-members
        if(balances[msg.sender] >= unreleased && lockupEndTime[lockupEndTime.length-1] > now)
        {
            tobeReleased = unreleased;
        }
        else
        {
            tobeReleased = balances[msg.sender];
        }

        //revert transaction when nothing to be withdrawn
        require(tobeReleased > 0);

        balances[msg.sender] = balances[msg.sender].sub(tobeReleased);
        tokensStillInLockup = tokensStillInLockup.sub(tobeReleased);
        released[msg.sender] = released[msg.sender].add(tobeReleased);

        _deliverTokens(msg.sender, tobeReleased);

    }
// Solidity 0.4.24
/***** external functions *****/
function prepareInstance(
        string    _boardTokenName,
        string    _boardTokenSymbol,
        address[] _boardMembers,
        uint64[3] _boardVotingSettings,
        uint64    _financePeriod
    )
        external
    {
        require(_boardMembers.length > 0,         ERROR_BAD_SETTINGS);
        require(_boardVotingSettings.length == 3, ERROR_BAD_SETTINGS);

        // deploy DAO
        (Kernel dao, ACL acl) = _createDAO();
        // deploy board token
        MiniMeToken boardToken = _createToken(_boardTokenName, _boardTokenSymbol, BOARD_TOKEN_DECIMALS);
        // install board apps
        TokenManager tm = _installBoardApps(dao, boardToken, _boardVotingSettings, _financePeriod);
        // mint board tokens
        _mintTokens(acl, tm, _boardMembers, 1);
        // cache DAO
        _cacheDao(dao);
    }
// Solidity 0.4.24
/***** internal apps installation functions *****/
function _installBoardApps(Kernel _dao, MiniMeToken _token, uint64[3] _votingSettings, uint64 _financePeriod)
        internal
        returns (TokenManager)
    {
        TokenManager tm = _installTokenManagerApp(_dao, _token, BOARD_TRANSFERABLE, BOARD_MAX_PER_ACCOUNT);
        Voting voting = _installVotingApp(_dao, _token, _votingSettings);
        Vault vault = _installVaultApp(_dao);
        Finance finance = _installFinanceApp(_dao, vault, _financePeriod == 0 ? DEFAULT_FINANCE_PERIOD : _financePeriod);

        _cacheBoardApps(tm, voting, vault, finance);

        return tm;
    }
// Solidity 0.4.24
/***** internal apps initialization functions *****/
function _initializePresale(
        uint256 _goal,
        uint64  _period,
        uint256 _exchangeRate,
        uint64  _vestingCliffPeriod,
        uint64  _vestingCompletePeriod,
        uint256 _supplyOfferedPct,
        uint256 _fundingForBeneficiaryPct,
        uint64  _openDate
    )
        internal
    {
        _presaleCache().initialize(
            _controllerCache(),
            _shareTMCache(),
            _reserveCache(),
            _vaultCache(),
            collaterals[0],
            _goal,
            _period,
            _exchangeRate,
            _vestingCliffPeriod,
            _vestingCompletePeriod,
            _supplyOfferedPct,
            _fundingForBeneficiaryPct,
            _openDate
        );
    }
// Solidity 0.4.24
/***** internal setup functions *****/
function _setupCollaterals(
        Kernel     _dao,
        uint256[2] _virtualSupplies,
        uint256[2] _virtualBalances,
        uint256[2] _slippages,
        uint256    _rateDAI,
        uint256    _floorDAI
    )
        internal
    {
        ACL acl = ACL(_dao.acl());
        (, Voting shareVoting) = _shareAppsCache();
        (,,,, AragonFundraisingController controller) = _fundraisingAppsCache();

        // create and grant ADD_COLLATERAL_TOKEN_ROLE to this template
        _createPermissionForTemplate(acl, address(controller), controller.ADD_COLLATERAL_TOKEN_ROLE());
        // add DAI both as a protected collateral and a tapped token
        controller.addCollateralToken(
            collaterals[0],
            _virtualSupplies[0],
            _virtualBalances[0],
            DAI_RESERVE_RATIO,
            _slippages[0],
            _rateDAI,
            _floorDAI
        );
        // add ANT as a protected collateral [but not as a tapped token]
        controller.addCollateralToken(
            collaterals[1],
            _virtualSupplies[1],
            _virtualBalances[1],
            ANT_RESERVE_RATIO,
            _slippages[1],
            0,
            0
        );
        // transfer ADD_COLLATERAL_TOKEN_ROLE
        _transferPermissionFromTemplate(acl, controller, shareVoting, controller.ADD_COLLATERAL_TOKEN_ROLE(), shareVoting);
    }
// Solidity 0.4.24
/**
 * @dev Generate new Reward Collectible and transfer it to the owner, with isAttached as 0.
 * @notice Helps in redeeming the Rewards using our Oracle. Creates & transfers the asset to the redeemer (_owner)
 * The generation of an asset if limited via the generationSeasonController
 * @param _teamId           teamId of the asset/token/collectible
 * @param _posId            position of the asset/token/collectible
 * @param _attributes       attributes of asset/token/collectible
 * @param _owner            owner (redeemer) of asset/token/collectible
 * @param _gameId           mlb game Identifier
 * @param _playerOverrideId player override identifier
 * @param _mlbPlayerId      official mlb player identifier
 */
function createRewardCollectible (
        uint8 _teamId,
        uint8 _posId,
        uint256 _attributes,
        address _owner,
        uint256 _gameId,
        uint256 _playerOverrideId,
        uint256 _mlbPlayerId)
        external
        canCreate
        whenNotPaused
        returns (uint256) {

        address nftOwner = _owner;
        
        if (nftOwner == address(0)) {
             nftOwner = managerPrimary;
        }
        
        rewardsRedeemed++;
        uint32 _sequenceId = getSequenceId(_teamId);
        
        uint256 assetDetails = uint256(uint64(now));
        assetDetails |= uint256(_sequenceId)<<64;
        assetDetails |= uint256(_teamId)<<96;
        assetDetails |= uint256(_posId)<<104;

        uint256[5] memory _nftData = [assetDetails, _attributes, _gameId, _playerOverrideId, _mlbPlayerId];
        
        return _createNFTCollectible(_teamId, _attributes, nftOwner, 0, _nftData);
    }