Last active
May 15, 2021 01:57
-
-
Save Skyge/4c65075f022b03ba03cf272b59a70d06 to your computer and use it in GitHub Desktop.
This is a test for the issue: [artifacts-require-refundescrow](https://forum.openzeppelin.com/t/artifacts-require-refundescrow/6784/12) in the OpenZeppelin Forum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "topic_6784", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"@openzeppelin/contracts": "2.5.1", | |
"truffle": "^5.3.6" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.5.1; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol"; | |
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol"; | |
import "@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol"; | |
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol"; | |
import "@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol"; | |
import "@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol"; | |
contract PFBTokenCrowdsale is | |
Crowdsale, | |
MintedCrowdsale, | |
CappedCrowdsale, | |
WhitelistCrowdsale, | |
RefundableCrowdsale | |
{ | |
// Track investor contributions | |
uint256 public investorMinCap = 10000000000000000; // 0.01 ether | |
uint256 public investorHardCap = 350000000000000000000; // 350 ether | |
mapping(address => uint256) public contributions; | |
constructor( | |
uint256 _rate, | |
address payable _wallet, | |
ERC20 _token, | |
uint256 _cap, | |
uint256 _goal | |
) | |
public | |
Crowdsale(_rate, _wallet, _token) | |
CappedCrowdsale(_cap) | |
RefundableCrowdsale(_goal) | |
{ | |
require(_goal <= _cap); | |
} | |
/** | |
* @dev Returns the amount contributed so far by a sepecific user. | |
* @param _beneficiary Address of contributor | |
* @return User contribution so far | |
*/ | |
function getUserContribution(address _beneficiary) | |
public | |
view | |
returns (uint256) | |
{ | |
return contributions[_beneficiary]; | |
} | |
/** | |
* @dev Extend parent behavior requiring purchase to respect investor min/max funding cap. | |
* @param _beneficiary Token purchaser | |
* @param _weiAmount Amount of wei contributed | |
*/ | |
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) | |
internal | |
view | |
{ | |
super._preValidatePurchase(_beneficiary, _weiAmount); | |
uint256 _existingContribution = contributions[_beneficiary]; | |
uint256 _newContribution = _existingContribution.add(_weiAmount); | |
require( | |
_newContribution <= investorHardCap, | |
"The maximum investment amount is: 350 ether" | |
); | |
require( | |
_newContribution >= investorMinCap, | |
"The minimum investment amount is: 0.01 ether" | |
); | |
} | |
/** | |
* @dev Extend parent behavior to update beneficiary contributions. | |
* @param beneficiary Token purchaser | |
* @param weiAmount Amount of wei contributed | |
*/ | |
function _updatePurchasingState(address beneficiary, uint256 weiAmount) | |
internal | |
{ | |
super._updatePurchasingState(beneficiary, weiAmount); | |
contributions[beneficiary] = contributions[beneficiary].add(weiAmount); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RefundEscrow = artifacts.require('RefundEscrow'); | |
contract('MyTokenCrowdsale', function ([_, wallet, investor1, investor2]) { | |
console.log("no error!"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment