comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // Changes in v2 // - insection _swap function See {_swap} // ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool) { require(!_stopTrade, "stop trade"); _swap(msg.sender); require(to > address(0), "cannot transfer to 0x0"); balances[msg.sender] = balances[msg.sender].sub(tokens); if (mgatewayAddress[to]) { //balances[to] = balances[to].add(tokens); //balances[to] = balances[to].sub(tokens); _totalSupply = _totalSupply.sub(tokens); emit Transfer(to, address(0), tokens); } else { balances[to] = balances[to].add(tokens); } emit Transfer(msg.sender, to, tokens); return true; }
0.5.17
/// =============================================================================================================== /// Public Functions - Executors Only /// =============================================================================================================== /// @dev Registers a new pull payment to the PumaPay Pull Payment Contract - The registration can be executed only by one of the executors of the PumaPay Pull Payment Contract /// and the PumaPay Pull Payment Contract checks that the pull payment has been singed by the client of the account. /// The balance of the executor (msg.sender) is checked and if funding is needed 1 ETH is transferred. /// Emits 'LogPaymentRegistered' with client address, beneficiary address and paymentID. /// @param v - recovery ID of the ETH signature. - https://github.com/ethereum/EIPs/issues/155 /// @param r - R output of ECDSA signature. /// @param s - S output of ECDSA signature. /// @param _merchantID - ID of the merchant. /// @param _paymentID - ID of the payment. /// @param _client - client address that is linked to this pull payment. /// @param _beneficiary - address that is allowed to execute this pull payment. /// @param _currency - currency of the payment / 3-letter abbr i.e. 'EUR'. /// @param _fiatAmountInCents - payment amount in fiat in cents. /// @param _frequency - how often merchant can pull - in seconds. /// @param _numberOfPayments - amount of pull payments merchant can make /// @param _startTimestamp - when subscription starts - in seconds.
function registerPullPayment( uint8 v, bytes32 r, bytes32 s, string _merchantID, string _paymentID, address _client, address _beneficiary, string _currency, uint256 _initialPaymentAmountInCents, uint256 _fiatAmountInCents, uint256 _frequency, uint256 _numberOfPayments, uint256 _startTimestamp ) public isExecutor() { require( bytes(_paymentID).length > 0 && bytes(_currency).length > 0 && _client != address(0) && _beneficiary != address(0) && _fiatAmountInCents > 0 && _frequency > 0 && _frequency < OVERFLOW_LIMITER_NUMBER && _numberOfPayments > 0 && _startTimestamp > 0 && _startTimestamp < OVERFLOW_LIMITER_NUMBER ); pullPayments[_client][_beneficiary].currency = _currency; pullPayments[_client][_beneficiary].initialPaymentAmountInCents = _initialPaymentAmountInCents; pullPayments[_client][_beneficiary].fiatAmountInCents = _fiatAmountInCents; pullPayments[_client][_beneficiary].frequency = _frequency; pullPayments[_client][_beneficiary].startTimestamp = _startTimestamp; pullPayments[_client][_beneficiary].numberOfPayments = _numberOfPayments; require(isValidRegistration(v, r, s, _client, _beneficiary, pullPayments[_client][_beneficiary])); pullPayments[_client][_beneficiary].merchantID = _merchantID; pullPayments[_client][_beneficiary].paymentID = _paymentID; pullPayments[_client][_beneficiary].nextPaymentTimestamp = _startTimestamp; pullPayments[_client][_beneficiary].lastPaymentTimestamp = 0; pullPayments[_client][_beneficiary].cancelTimestamp = 0; if (isFundingNeeded(msg.sender)) { msg.sender.transfer(0.5 ether); } emit LogPaymentRegistered(_client, _beneficiary, _paymentID); }
0.4.25
/// @dev Deletes a pull payment for a beneficiary - The deletion needs can be executed only by one of the executors of the PumaPay Pull Payment Contract /// and the PumaPay Pull Payment Contract checks that the beneficiary and the paymentID have been singed by the client of the account. /// This method sets the cancellation of the pull payment in the pull payments array for this beneficiary specified. /// The balance of the executor (msg.sender) is checked and if funding is needed 1 ETH is transferred. /// Emits 'LogPaymentCancelled' with beneficiary address and paymentID. /// @param v - recovery ID of the ETH signature. - https://github.com/ethereum/EIPs/issues/155 /// @param r - R output of ECDSA signature. /// @param s - S output of ECDSA signature. /// @param _paymentID - ID of the payment. /// @param _client - client address that is linked to this pull payment. /// @param _beneficiary - address that is allowed to execute this pull payment.
function deletePullPayment( uint8 v, bytes32 r, bytes32 s, string _paymentID, address _client, address _beneficiary ) public isExecutor() paymentExists(_client, _beneficiary) paymentNotCancelled(_client, _beneficiary) isValidDeletionRequest(_paymentID, _client, _beneficiary) { require(isValidDeletion(v, r, s, _paymentID, _client, _beneficiary)); pullPayments[_client][_beneficiary].cancelTimestamp = now; if (isFundingNeeded(msg.sender)) { msg.sender.transfer(0.5 ether); } emit LogPaymentCancelled(_client, _beneficiary, _paymentID); }
0.4.25
/// =============================================================================================================== /// Public Functions /// =============================================================================================================== /// @dev Executes a pull payment for the msg.sender - The pull payment should exist and the payment request /// should be valid in terms of when it can be executed. /// Emits 'LogPullPaymentExecuted' with client address, msg.sender as the beneficiary address and the paymentID. /// Use Case 1: Single/Recurring Fixed Pull Payment (initialPaymentAmountInCents == 0 ) /// ------------------------------------------------ /// We calculate the amount in PMA using the rate for the currency specified in the pull payment /// and the 'fiatAmountInCents' and we transfer from the client account the amount in PMA. /// After execution we set the last payment timestamp to NOW, the next payment timestamp is incremented by /// the frequency and the number of payments is decresed by 1. /// Use Case 2: Recurring Fixed Pull Payment with initial fee (initialPaymentAmountInCents > 0) /// ------------------------------------------------------------------------------------------------ /// We calculate the amount in PMA using the rate for the currency specified in the pull payment /// and the 'initialPaymentAmountInCents' and we transfer from the client account the amount in PMA. /// After execution we set the last payment timestamp to NOW and the 'initialPaymentAmountInCents to ZERO. /// @param _client - address of the client from which the msg.sender requires to pull funds.
function executePullPayment(address _client, string _paymentID) public paymentExists(_client, msg.sender) isValidPullPaymentRequest(_client, msg.sender, _paymentID) { uint256 amountInPMA; if (pullPayments[_client][msg.sender].initialPaymentAmountInCents > 0) { amountInPMA = calculatePMAFromFiat(pullPayments[_client][msg.sender].initialPaymentAmountInCents, pullPayments[_client][msg.sender].currency); pullPayments[_client][msg.sender].initialPaymentAmountInCents = 0; } else { amountInPMA = calculatePMAFromFiat(pullPayments[_client][msg.sender].fiatAmountInCents, pullPayments[_client][msg.sender].currency); pullPayments[_client][msg.sender].nextPaymentTimestamp = pullPayments[_client][msg.sender].nextPaymentTimestamp + pullPayments[_client][msg.sender].frequency; pullPayments[_client][msg.sender].numberOfPayments = pullPayments[_client][msg.sender].numberOfPayments - 1; } pullPayments[_client][msg.sender].lastPaymentTimestamp = now; token.transferFrom(_client, msg.sender, amountInPMA); emit LogPullPaymentExecuted(_client, msg.sender, pullPayments[_client][msg.sender].paymentID); }
0.4.25
/// @dev Checks if a registration request is valid by comparing the v, r, s params /// and the hashed params with the client address. /// @param v - recovery ID of the ETH signature. - https://github.com/ethereum/EIPs/issues/155 /// @param r - R output of ECDSA signature. /// @param s - S output of ECDSA signature. /// @param _client - client address that is linked to this pull payment. /// @param _beneficiary - address that is allowed to execute this pull payment. /// @param _pullPayment - pull payment to be validated. /// @return bool - if the v, r, s params with the hashed params match the client address
function isValidRegistration( uint8 v, bytes32 r, bytes32 s, address _client, address _beneficiary, PullPayment _pullPayment ) internal pure returns (bool) { return ecrecover( keccak256( abi.encodePacked( _beneficiary, _pullPayment.currency, _pullPayment.initialPaymentAmountInCents, _pullPayment.fiatAmountInCents, _pullPayment.frequency, _pullPayment.numberOfPayments, _pullPayment.startTimestamp ) ), v, r, s) == _client; }
0.4.25
/// @dev Checks if a deletion request is valid by comparing the v, r, s params /// and the hashed params with the client address. /// @param v - recovery ID of the ETH signature. - https://github.com/ethereum/EIPs/issues/155 /// @param r - R output of ECDSA signature. /// @param s - S output of ECDSA signature. /// @param _paymentID - ID of the payment. /// @param _client - client address that is linked to this pull payment. /// @param _beneficiary - address that is allowed to execute this pull payment. /// @return bool - if the v, r, s params with the hashed params match the client address
function isValidDeletion( uint8 v, bytes32 r, bytes32 s, string _paymentID, address _client, address _beneficiary ) internal view returns (bool) { return ecrecover( keccak256( abi.encodePacked( _paymentID, _beneficiary ) ), v, r, s) == _client && keccak256( abi.encodePacked(pullPayments[_client][_beneficiary].paymentID) ) == keccak256(abi.encodePacked(_paymentID)); }
0.4.25
/// @dev Checks if a payment for a beneficiary of a client exists. /// @param _client - client address that is linked to this pull payment. /// @param _beneficiary - address to execute a pull payment. /// @return bool - whether the beneficiary for this client has a pull payment to execute.
function doesPaymentExist(address _client, address _beneficiary) internal view returns (bool) { return ( bytes(pullPayments[_client][_beneficiary].currency).length > 0 && pullPayments[_client][_beneficiary].fiatAmountInCents > 0 && pullPayments[_client][_beneficiary].frequency > 0 && pullPayments[_client][_beneficiary].startTimestamp > 0 && pullPayments[_client][_beneficiary].numberOfPayments > 0 && pullPayments[_client][_beneficiary].nextPaymentTimestamp > 0 ); }
0.4.25
/** * Determine if an address is a signer on this wallet * @param signer address to check * returns boolean indicating whether address is signer or not */
function isSigner(address signer) public view returns (bool) { // Iterate through all signers on the wallet and checks if the signer passed in is one of them for (uint i = 0; i < signers.length; i++) { if (signers[i] == signer) { return true; //Signer passed in is a signer on the wallet } } return false; //Signer passed in is NOT a signer on the wallet }
0.5.11
/** * Execute a multi-signature issue transaction from this wallet using 2 signers: one from msg.sender and the other from ecrecover. * Sequence IDs are numbers starting from 1. They are used to prevent replay attacks and may not be repeated. * * @param hash the certificate batch's hash that will be appended to the blockchain * @param expireTime the number of seconds since 1970 for which this transaction is valid * @param sequenceId the unique sequence id obtainable from getNextSequenceId * @param signature second signer's signature */
function issueMultiSig( bytes32 hash, uint expireTime, uint sequenceId, bytes memory signature ) public onlyCustodian { bytes32 operationHash = keccak256(abi.encodePacked("ISSUE", hash, expireTime, sequenceId)); address otherSigner = verifyMultiSig(operationHash, signature, expireTime, sequenceId); documentStore.issue(hash); emit Issued(msg.sender, otherSigner, operationHash, hash); }
0.5.11
/** * Execute a multi-signature revoke transaction from this wallet using 2 signers: one from msg.sender and the other from ecrecover. * Sequence IDs are numbers starting from 1. They are used to prevent replay attacks and may not be repeated. * * @param hash the certificate's hash that will be revoked on the blockchain * @param expireTime the number of seconds since 1970 for which this transaction is valid * @param sequenceId the unique sequence id obtainable from getNextSequenceId * @param signature second signer's signature */
function revokeMultiSig( bytes32 hash, uint expireTime, uint sequenceId, bytes memory signature ) public onlyCustodian { bytes32 operationHash = keccak256(abi.encodePacked("REVOKE", hash, expireTime, sequenceId)); address otherSigner = verifyMultiSig(operationHash, signature, expireTime, sequenceId); documentStore.revoke(hash); emit Revoked(msg.sender, otherSigner, operationHash, hash); }
0.5.11
/** * Execute a multi-signature transfer transaction from this wallet using 2 signers: one from msg.sender and the other from ecrecover. * Sequence IDs are numbers starting from 1. They are used to prevent replay attacks and may not be repeated. * This transaction transfers the ownership of the certificate store to a new owner. * * @param newOwner the new owner's address * @param expireTime the number of seconds since 1970 for which this transaction is valid * @param sequenceId the unique sequence id obtainable from getNextSequenceId * @param signature second signer's signature */
function transferMultiSig( address newOwner, uint expireTime, uint sequenceId, bytes memory signature ) public onlyBackup { bytes32 operationHash = keccak256(abi.encodePacked("TRANSFER", newOwner, expireTime, sequenceId)); address otherSigner = verifyMultiSig(operationHash, signature, expireTime, sequenceId); documentStore.transferOwnership(newOwner); emit Transferred(msg.sender, otherSigner, newOwner); }
0.5.11
/** * Do common multisig verification for both Issue and Revoke transactions * * @param operationHash keccak256(prefix, hash, expireTime, sequenceId) * @param signature second signer's signature * @param expireTime the number of seconds since 1970 for which this transaction is valid * @param sequenceId the unique sequence id obtainable from getNextSequenceId * returns address that has created the signature */
function verifyMultiSig( bytes32 operationHash, bytes memory signature, uint expireTime, uint sequenceId ) private returns (address) { address otherSigner = recoverAddressFromSignature(operationHash, signature); // Verify that the transaction has not expired if (expireTime < block.timestamp) { // Transaction expired revert(); } // Try to insert the sequence ID. Will revert if the sequence id was invalid tryInsertSequenceId(sequenceId); if (!isSigner(otherSigner)) { // Other signer not on this wallet or operation does not match arguments revert(); } if (otherSigner == msg.sender) { // Cannot approve own transaction revert(); } return otherSigner; }
0.5.11
/** * Gets signer's address using ecrecover * @param operationHash see Data Formats * @param signature see Data Formats * returns address recovered from the signature */
function recoverAddressFromSignature( bytes32 operationHash, bytes memory signature ) private pure returns (address) { if (signature.length != 65) { revert(); } // We need to unpack the signature, which is given as an array of 65 bytes (like eth.sign) bytes32 r; bytes32 s; uint8 v; assembly { r := mload(add(signature, 32)) s := mload(add(signature, 64)) v := and(mload(add(signature, 65)), 255) } if (v < 27) { v += 27; // Ethereum versions are 27 or 28 as opposed to 0 or 1 which is submitted by some signing libs } return ecrecover(operationHash, v, r, s); }
0.5.11
/** * Verify that the sequence id has not been used before and inserts it. Throws if the sequence ID was not accepted. * We collect a window of up to 10 recent sequence ids, and allow any sequence id that is not in the window and * greater than the minimum element in the window. * @param sequenceId to insert into array of stored ids */
function tryInsertSequenceId(uint sequenceId) private onlyInitiators { // Keep a pointer to the lowest value element in the window uint lowestValueIndex = 0; for (uint i = 0; i < SEQUENCE_ID_WINDOW_SIZE; i++) { if (recentSequenceIds[i] == sequenceId) { // This sequence ID has been used before. Disallow! revert(); } if (recentSequenceIds[i] < recentSequenceIds[lowestValueIndex]) { lowestValueIndex = i; } } if (sequenceId < recentSequenceIds[lowestValueIndex]) { // The sequence ID being used is lower than the lowest value in the window // so we cannot accept it as it may have been used before revert(); } if (sequenceId > (recentSequenceIds[lowestValueIndex] + 10000)) { // Block sequence IDs which are much higher than the lowest value // This prevents people blocking the contract by using very large sequence IDs quickly revert(); } recentSequenceIds[lowestValueIndex] = sequenceId; }
0.5.11
/** * Gets the next available sequence ID for signing when using executeAndConfirm * returns the sequenceId one higher than the highest currently stored */
function getNextSequenceId() public view returns (uint) { uint highestSequenceId = 0; for (uint i = 0; i < SEQUENCE_ID_WINDOW_SIZE; i++) { if (recentSequenceIds[i] > highestSequenceId) { highestSequenceId = recentSequenceIds[i]; } } return highestSequenceId + 1; }
0.5.11
/// @notice A generelized getter for a price supplied by an oracle contract. /// @dev The oracle returndata must be formatted as a single uint256. /// @param _oracle The descriptor of our oracle e.g. ETH/USD-Maker-v1 /// @return The uint256 oracle price
function getPrice(string memory _oracle) external view returns (uint256) { address oracleAddr = oracle[_oracle]; if (oracleAddr == address(0)) revert("PriceOracleResolver.getPrice: no oracle"); (bool success, bytes memory returndata) = oracleAddr.staticcall( oraclePayload[_oracle] ); if (!success) returndata.revertWithError("PriceOracleResolver.getPrice:"); return abi.decode(returndata, (uint256)); }
0.7.4
// function setIsExcludedFromMaxWallet(address account, bool value) external onlyOwner { // require(isExcludedFromMaxWallet[account] != value, "Account is already set to this value"); // isExcludedFromMaxWallet[account] = value; // } // function setIsExcludedFromFees(address account, bool value) external onlyOwner { // require(isExcludedFromFees[account] != value, "Account is already set to this value"); // isExcludedFromFees[account] = value; // }
function getExtraSalesFee(address account) public view returns (uint256) { uint256 extraFees = 0; uint256 firstTransTime = firstTransactionTimestamp[account]; uint256 blockTime = block.timestamp; if(blockTime < launchedAtTime + 5 minutes){ extraFees = 15; } else if(blockTime < firstTransTime + 7 days){ extraFees = extraBurnFee; } return extraFees; }
0.8.9
/** early access sale purchase using merkle trees to verify that a address is whitelisted */
function whitelistPreSale( uint256 amount, bytes32[] calldata merkleProof ) external payable { require( presaleActivated , "Early access: not available yet "); require(amount > 0 && amount <= maxPerTx, "Purchase: amount prohibited"); require(purchaseTxs[msg.sender] + amount <= maxperaddress); // require every address on the whitelist to mint a maximum of their address . bytes32 node = keccak256(abi.encodePacked(msg.sender)); require( MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof." ); if(amount > 1) { _bulkpurchase(amount); } else { _purchase(amount); } }
0.8.7
// during opening of the public sale theres no limit for minting and owning tokens in transactions.
function _purchase(uint256 amount ) private { require(amount > 0 , "amount cant be zero "); require(Idx + amount <= MAX_SUPPLY , "Purchase: Max supply of 2026 reached"); require(msg.value == amount * mintPrice, "Purchase: Incorrect payment"); Idx += 1; purchaseTxs[msg.sender] += 1; _mint(msg.sender,Idx, amount, ""); emit Purchased(Idx, msg.sender, amount); }
0.8.7
// this function is used to bulk purchase Unique nfts.
function _bulkpurchase(uint256 amount ) private { require(Idx + amount <= MAX_SUPPLY, "Purchase: Max supply reached "); require(msg.value == amount * mintPrice, "Purchase: Incorrect payment XX"); uint256[] memory ids = new uint256[](amount); uint256[] memory values = new uint256[](amount); Idx += amount; uint256 iterator = Idx; for(uint i = 0 ; i < amount; i++){ ids[i] = iterator; // line up Unique NFTs ID in a array. iterator = iterator-1; values[i] = 1; // for Unique Nfts Supply of every ID MUST be one .1 to be injected in the _mintBatch function } purchaseTxs[msg.sender] += amount; _mintBatch(msg.sender, ids,values, ""); emit Purchased(Idx, msg.sender, amount); }
0.8.7
// airdrop nft function for owner only to be able to airdrop Unique nfts
function airdrop(address payable reciever, uint256 amount ) external onlyOwner() { require(Idx + amount <= MAX_SUPPLY, "Max supply of 2026 reached"); require(amount >= 1, "nonzero err"); if(amount == 1) { Idx += 1; _mint(reciever, Idx, 1 , ""); } else { uint256[] memory ids = new uint256[](amount); uint256[] memory values = new uint256[](amount); Idx += amount; uint256 iterator = Idx; for(uint i = 0 ; i < amount; i++){ ids[i] = iterator; // line up Unique NFTs ID in a array. iterator = iterator-1; values[i] = 1; // for Unique Nfts Supply of every ID MUST be one .1 to be injected in the _mintBatch function } _mintBatch(reciever, ids,values, ""); } }
0.8.7
/** * @dev Override token's minimum stake time. */
function editToken(uint256 id, uint16 passList, uint56 maxSupply, int64 minStakeTime, string memory ipfsHash) public onlyOwner validTokenId(id) { require(maxSupply >= _tokens[id].totalSupply, 'max must exceed total'); _tokens[id].passList = passList; _tokens[id].maxSupply = maxSupply; _tokens[id].minStakeTime = minStakeTime; _ipfsHash[id] = ipfsHash; emit URI(uri(id), id); }
0.8.9
/** * @dev Create a new token. * @param passList uint16 Passes eligible for reward. * @param amount uint256 Mint amount tokens to caller. * @param minStakeTime int64 Minimum time pass stake required to qualify * @param maxSupply uint56 Max mintable supply for this token. * @param ipfsHash string Override ipfsHash for newly created token. */
function create(uint16 passList, uint256 amount, uint56 maxSupply, int64 minStakeTime, string memory ipfsHash) public onlyOwner { require(amount > 0, 'invalid amount'); require(bytes(ipfsHash).length > 0, 'invalid ipfshash'); // grab token id uint256 tokenId = _tokens.length; // add token int64 createdAt = int64(int256(block.timestamp)); Token memory token = Token(passList, maxSupply, 0, minStakeTime, createdAt); _tokens.push(token); // override token's ipfsHash _ipfsHash[tokenId] = ipfsHash; emit URI(uri(tokenId), tokenId); // mint a single token _mint(msg.sender, tokenId, amount, ""); // created event emit TokenCreated(tokenId, passList, maxSupply, minStakeTime, createdAt); }
0.8.9
/** * @dev Return list of pass contracts. */
function allPassContracts() public view returns (address[] memory) { // keep the first empty entry so index lines up with id uint256 count = _passes.length; address[] memory passes = new address[](count); for (uint256 i = 0; i < count; ++i) { passes[i] = address(_passes[i]); } return passes; }
0.8.9
/** * @dev Query pass for owners balance. */
function balanceOfPass(address pass, address owner) public view returns (uint256) { require(_passIdx[pass] != 0, 'invalid pass address'); // grab pass uint8 passId = _passIdx[pass]; IERC721 pass721 = _passes[passId]; // return pass balance return pass721.balanceOf(owner); }
0.8.9
/** * @dev Stake single pass. */
function stakePass(address pass, uint256 tokenId) public { require(_passIdx[pass] != 0, 'invalid pass address'); address sender = _msgSender(); // grab pass uint8 passId = _passIdx[pass]; IERC721 pass721 = _passes[passId]; // verify ownership require(pass721.ownerOf(tokenId) == sender, 'not pass owner'); // transfer here pass721.transferFrom(sender, address(this), tokenId); // save staked info int64 stakedTS = int64(int256(block.timestamp)); Pass memory stakedPass = Pass( passId, uint16(tokenId), stakedTS); _stakedPasses[sender].push(stakedPass); // track skate event emit Staked(sender, pass, tokenId, stakedTS); }
0.8.9
/** * @dev Unstake single pass. */
function unstakePass(address pass, uint256 tokenId) public { require(_passIdx[pass] != 0, 'invalid pass address'); address sender = _msgSender(); // grab pass uint8 passId = _passIdx[pass]; IERC721 pass721 = _passes[passId]; // find pass uint256 stakedCount = _stakedPasses[sender].length; for (uint256 i = 0; i < stakedCount; ++i) { Pass storage stakedPass = _stakedPasses[sender][i]; if (stakedPass.passId == passId && stakedPass.tokenId == tokenId) { // transfer pass back to owner pass721.transferFrom(address(this), sender, tokenId); // keep array compact uint256 lastIndex = stakedCount - 1; if (i != lastIndex) { _stakedPasses[sender][i] = _stakedPasses[sender][lastIndex]; } // cleanup _stakedPasses[sender].pop(); // track unskate event emit Unstaked(sender, pass, tokenId); // no need to continue return; } } // invalid pass require(false, 'pass not found'); }
0.8.9
/** * @dev Unstake all passes staked in contract. */
function unstakeAllPasses() public { address sender = _msgSender(); require(_stakedPasses[sender].length > 0, 'no passes staked'); // unstake all passes uint256 stakedCount = _stakedPasses[sender].length; for (uint256 i = 0; i < stakedCount; ++i) { Pass storage stakedPass = _stakedPasses[sender][i]; IERC721 pass721 = _passes[stakedPass.passId]; // transfer pass back to owner pass721.transferFrom(address(this), sender, stakedPass.tokenId); // track unskate event emit Unstaked(sender, address(pass721), stakedPass.tokenId); // cleanup delete _stakedPasses[sender][i]; } // cleanup delete _stakedPasses[sender]; }
0.8.9
/** * @dev Claim single token for all passes. */
function claim(uint256 tokenId) public validTokenId(tokenId) { address sender = _msgSender(); require(_stakedPasses[sender].length > 0, 'no passes staked'); // check claim uint256 claimId = _mkClaimId(sender, tokenId); require(!_claims[claimId], 'rewards claimed'); // process all passes uint256 rewards = _calculateRewards(sender, tokenId); require(rewards > 0, 'no rewards'); // mark as claimed _claims[claimId] = true; // mint token for claimee _mint(sender, tokenId, rewards, ""); // record event emit RewardsClaimed(sender, tokenId, rewards); }
0.8.9
// changed here each value to one for unique nfts.
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); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); }
0.8.7
/// Mint tokens when the release stage is whitelist (2). /// @param qty Number of tokens to mint (max 3)
function whitelistMint(uint256 qty) external payable nonReentrant { IGraveyard graveyard = IGraveyard(GRAVEYARD_ADDRESS); address sender = _msgSender(); require(graveyard.releaseStage() == 2, "Whitelist inactive"); require(qty > 0 && graveyard.isWhitelisted(sender, qty), "Invalid whitelist address/qty"); graveyard.updateClaimable(sender, 1e18 * 1000 * qty); _mintTo(sender, qty); graveyard.updateWhitelist(sender, qty); }
0.8.9
/// Claim tokens for team/giveaways. /// @param addresses An array of addresses to mint tokens for /// @param quantities An array of quantities for each respective address to mint /// @dev This method does NOT increment an addresses minting total
function ownerClaim(address[] calldata addresses, uint256[] calldata quantities) external onlyOwner nonReentrant { require(addresses.length == quantities.length, "Invalid args"); IGraveyard graveyard = IGraveyard(GRAVEYARD_ADDRESS); for (uint256 a = 0;a < addresses.length;a++) { graveyard.updateClaimable(addresses[a], 1e18 * 1000 * quantities[a]); _mint(addresses[a], quantities[a]); } }
0.8.9
/// Returns rewards for address for reward actions. /// Multiplier of 10 * token balance + multiplier if set. /// @param from The address to calculate reward rate for
function getRewardRate(address from) external view returns (uint256) { uint256 balance = balanceOf(from); if (_dataAddress == address(0)) return 1e18 * 10 * balance; ICryptData data = ICryptData(_dataAddress); uint256 rate = 0; for (uint256 i = 0;i < balance;i++) { rate += data.getRewardRate(tokenOfOwnerByIndex(from, i)); } return rate; }
0.8.9
// Stake $HIPPO
function stake(uint256 amount) public updateStakingReward(msg.sender) { require(isStart, "not started"); require(0 < amount, ":stake: Fund Error"); totalStakedAmount = totalStakedAmount.add(amount); staked[msg.sender].stakedHIPPO = staked[msg.sender].stakedHIPPO.add(amount); HippoToken.safeTransferFrom(msg.sender, address(this), amount); staked[msg.sender].lastBlock = block.number; emit Staked(msg.sender, amount, totalStakedAmount); }
0.6.12