Merge pull request #283 from OpenZeppelin/crowdsale

Add Crowdsale contracts
This commit is contained in:
Manuel Aráoz
2017-07-02 17:59:19 -03:00
committed by GitHub
22 changed files with 814 additions and 85 deletions

View File

@ -0,0 +1,21 @@
pragma solidity ^0.4.11;
import '../../contracts/crowdsale/CappedCrowdsale.sol';
contract CappedCrowdsaleImpl is CappedCrowdsale {
function CappedCrowdsaleImpl (
uint256 _startBlock,
uint256 _endBlock,
uint256 _rate,
address _wallet,
uint256 _cap
)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
CappedCrowdsale(_cap)
{
}
}

1
test/helpers/EVMThrow.js Normal file
View File

@ -0,0 +1 @@
export default 'invalid opcode'

View File

@ -0,0 +1,20 @@
pragma solidity ^0.4.11;
import '../../contracts/crowdsale/FinalizableCrowdsale.sol';
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
function FinalizableCrowdsaleImpl (
uint256 _startBlock,
uint256 _endBlock,
uint256 _rate,
address _wallet
)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
FinalizableCrowdsale()
{
}
}

View File

@ -0,0 +1,21 @@
pragma solidity ^0.4.11;
import '../../contracts/crowdsale/RefundableCrowdsale.sol';
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
function RefundableCrowdsaleImpl (
uint256 _startBlock,
uint256 _endBlock,
uint256 _rate,
address _wallet,
uint256 _goal
)
Crowdsale(_startBlock, _endBlock, _rate, _wallet)
RefundableCrowdsale(_goal)
{
}
}

View File

@ -0,0 +1,22 @@
export function advanceBlock() {
return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync({
jsonrpc: '2.0',
method: 'evm_mine',
id: Date.now(),
}, (err, res) => {
return err ? reject(err) : resolve(res)
})
})
}
// Advances the block number so that the last mined block is `number`.
export default async function advanceToBlock(number) {
if (web3.eth.blockNumber > number) {
throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`)
}
while (web3.eth.blockNumber < number) {
await advanceBlock()
}
}

3
test/helpers/ether.js Normal file
View File

@ -0,0 +1,3 @@
export default function ether(n) {
return new web3.BigNumber(web3.toWei(n, 'ether'))
}