Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
175e2c72
Commit
175e2c72
authored
Sep 27, 2018
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert Crowdsale to initializers
parent
a0a3187b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
Crowdsale.sol
contracts/crowdsale/Crowdsale.sol
+6
-2
CrowdsaleMock.sol
contracts/mocks/CrowdsaleMock.sol
+11
-0
Crowdsale.test.js
test/crowdsale/Crowdsale.test.js
+2
-2
No files found.
contracts/crowdsale/Crowdsale.sol
View file @
175e2c72
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/IERC20.sol";
import "../math/SafeMath.sol";
import "../math/SafeMath.sol";
import "../token/ERC20/SafeERC20.sol";
import "../token/ERC20/SafeERC20.sol";
...
@@ -17,7 +18,7 @@ import "../token/ERC20/SafeERC20.sol";
...
@@ -17,7 +18,7 @@ import "../token/ERC20/SafeERC20.sol";
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
* behavior.
* behavior.
*/
*/
contract Crowdsale {
contract Crowdsale
is Initializable
{
using SafeMath for uint256;
using SafeMath for uint256;
using SafeERC20 for IERC20;
using SafeERC20 for IERC20;
...
@@ -50,6 +51,9 @@ contract Crowdsale {
...
@@ -50,6 +51,9 @@ contract Crowdsale {
uint256 amount
uint256 amount
);
);
constructor(uint256 rate, address wallet, IERC20 token) public {
}
/**
/**
* @param rate Number of token units a buyer gets per wei
* @param rate Number of token units a buyer gets per wei
* @dev The rate is the conversion between wei and the smallest and indivisible
* @dev The rate is the conversion between wei and the smallest and indivisible
...
@@ -58,7 +62,7 @@ contract Crowdsale {
...
@@ -58,7 +62,7 @@ contract Crowdsale {
* @param wallet Address where collected funds will be forwarded to
* @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold
* @param token Address of the token being sold
*/
*/
constructor(uint256 rate, address wallet, IERC20 token) public
{
function initialize(uint256 rate, address wallet, IERC20 token) public initializer
{
require(rate > 0);
require(rate > 0);
require(wallet != address(0));
require(wallet != address(0));
require(token != address(0));
require(token != address(0));
...
...
contracts/mocks/CrowdsaleMock.sol
0 → 100644
View file @
175e2c72
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Initializable, Crowdsale {
constructor(uint256 rate, address wallet, IERC20 token) public Crowdsale(rate, wallet, token) {
Crowdsale.initialize(rate, wallet, token);
}
}
test/crowdsale/Crowdsale.test.js
View file @
175e2c72
...
@@ -8,8 +8,8 @@ const should = require('chai')
...
@@ -8,8 +8,8 @@ const should = require('chai')
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
.
should
();
const
Crowdsale
=
artifacts
.
require
(
'Crowdsale'
);
const
Crowdsale
=
artifacts
.
require
(
'Crowdsale
Mock
'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken
Mock
'
);
contract
(
'Crowdsale'
,
function
([
_
,
investor
,
wallet
,
purchaser
])
{
contract
(
'Crowdsale'
,
function
([
_
,
investor
,
wallet
,
purchaser
])
{
const
rate
=
new
BigNumber
(
1
);
const
rate
=
new
BigNumber
(
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment