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
2108641a
Commit
2108641a
authored
Sep 28, 2018
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert distribution crowdsales to initializers
parent
418b6f7c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
9 deletions
+25
-9
FinalizableCrowdsale.sol
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
+2
-1
PostDeliveryCrowdsale.sol
contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol
+2
-1
RefundableCrowdsale.sol
contracts/crowdsale/distribution/RefundableCrowdsale.sol
+6
-2
FinalizableCrowdsaleImpl.sol
contracts/mocks/FinalizableCrowdsaleImpl.sol
+4
-1
PostDeliveryCrowdsaleImpl.sol
contracts/mocks/PostDeliveryCrowdsaleImpl.sol
+4
-1
RefundableCrowdsaleImpl.sol
contracts/mocks/RefundableCrowdsaleImpl.sol
+5
-1
PostDeliveryCrowdsale.test.js
test/crowdsale/PostDeliveryCrowdsale.test.js
+1
-1
RefundableCrowdsale.test.js
test/crowdsale/RefundableCrowdsale.test.js
+1
-1
No files found.
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../../math/SafeMath.sol";
import "../../math/SafeMath.sol";
import "../validation/TimedCrowdsale.sol";
import "../validation/TimedCrowdsale.sol";
...
@@ -9,7 +10,7 @@ import "../validation/TimedCrowdsale.sol";
...
@@ -9,7 +10,7 @@ import "../validation/TimedCrowdsale.sol";
* @dev Extension of Crowdsale with a one-off finalization action, where one
* @dev Extension of Crowdsale with a one-off finalization action, where one
* can do extra work after finishing.
* can do extra work after finishing.
*/
*/
contract FinalizableCrowdsale is TimedCrowdsale {
contract FinalizableCrowdsale is
Initializable,
TimedCrowdsale {
using SafeMath for uint256;
using SafeMath for uint256;
bool private _finalized = false;
bool private _finalized = false;
...
...
contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../validation/TimedCrowdsale.sol";
import "../validation/TimedCrowdsale.sol";
import "../../token/ERC20/IERC20.sol";
import "../../token/ERC20/IERC20.sol";
import "../../math/SafeMath.sol";
import "../../math/SafeMath.sol";
...
@@ -9,7 +10,7 @@ import "../../math/SafeMath.sol";
...
@@ -9,7 +10,7 @@ import "../../math/SafeMath.sol";
* @title PostDeliveryCrowdsale
* @title PostDeliveryCrowdsale
* @dev Crowdsale that locks tokens from withdrawal until it ends.
* @dev Crowdsale that locks tokens from withdrawal until it ends.
*/
*/
contract PostDeliveryCrowdsale is TimedCrowdsale {
contract PostDeliveryCrowdsale is
Initializable,
TimedCrowdsale {
using SafeMath for uint256;
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => uint256) private _balances;
...
...
contracts/crowdsale/distribution/RefundableCrowdsale.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../../math/SafeMath.sol";
import "../../math/SafeMath.sol";
import "./FinalizableCrowdsale.sol";
import "./FinalizableCrowdsale.sol";
import "../../payment/RefundEscrow.sol";
import "../../payment/RefundEscrow.sol";
...
@@ -11,7 +12,7 @@ import "../../payment/RefundEscrow.sol";
...
@@ -11,7 +12,7 @@ import "../../payment/RefundEscrow.sol";
* @dev Extension of Crowdsale contract that adds a funding goal, and
* @dev Extension of Crowdsale contract that adds a funding goal, and
* the possibility of users getting a refund if goal is not met.
* the possibility of users getting a refund if goal is not met.
*/
*/
contract RefundableCrowdsale is FinalizableCrowdsale {
contract RefundableCrowdsale is
Initializable,
FinalizableCrowdsale {
using SafeMath for uint256;
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
// minimum amount of funds to be raised in weis
...
@@ -20,11 +21,14 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -20,11 +21,14 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
// refund escrow used to hold funds while crowdsale is running
// refund escrow used to hold funds while crowdsale is running
RefundEscrow private _escrow;
RefundEscrow private _escrow;
constructor(uint256 goal) public {
}
/**
/**
* @dev Constructor, creates RefundEscrow.
* @dev Constructor, creates RefundEscrow.
* @param goal Funding goal
* @param goal Funding goal
*/
*/
constructor(uint256 goal) public
{
function initialize(uint256 goal) public initializer
{
require(goal > 0);
require(goal > 0);
// conditional added to make initializer idempotent in case of diamond inheritance
// conditional added to make initializer idempotent in case of diamond inheritance
...
...
contracts/mocks/FinalizableCrowdsaleImpl.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/FinalizableCrowdsale.sol";
import "../crowdsale/distribution/FinalizableCrowdsale.sol";
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
contract FinalizableCrowdsaleImpl is
Initializable, Crowdsale, TimedCrowdsale,
FinalizableCrowdsale {
constructor (
constructor (
uint256 openingTime,
uint256 openingTime,
...
@@ -17,6 +18,8 @@ contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
...
@@ -17,6 +18,8 @@ contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
Crowdsale(rate, wallet, token)
Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime)
TimedCrowdsale(openingTime, closingTime)
{
{
Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime);
}
}
}
}
contracts/mocks/PostDeliveryCrowdsaleImpl.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
contract PostDeliveryCrowdsaleImpl is
Initializable, Crowdsale, TimedCrowdsale,
PostDeliveryCrowdsale {
constructor (
constructor (
uint256 openingTime,
uint256 openingTime,
...
@@ -17,6 +18,8 @@ contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
...
@@ -17,6 +18,8 @@ contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
TimedCrowdsale(openingTime, closingTime)
TimedCrowdsale(openingTime, closingTime)
Crowdsale(rate, wallet, token)
Crowdsale(rate, wallet, token)
{
{
Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime);
}
}
}
}
contracts/mocks/RefundableCrowdsaleImpl.sol
View file @
2108641a
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/ERC20Mintable.sol";
import "../token/ERC20/ERC20Mintable.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol";
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
contract RefundableCrowdsaleImpl is
Initializable, Crowdsale, TimedCrowdsale,
RefundableCrowdsale {
constructor (
constructor (
uint256 openingTime,
uint256 openingTime,
...
@@ -19,6 +20,9 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
...
@@ -19,6 +20,9 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
TimedCrowdsale(openingTime, closingTime)
TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal)
RefundableCrowdsale(goal)
{
{
Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime);
RefundableCrowdsale.initialize(goal);
}
}
}
}
test/crowdsale/PostDeliveryCrowdsale.test.js
View file @
2108641a
...
@@ -12,7 +12,7 @@ require('chai')
...
@@ -12,7 +12,7 @@ require('chai')
.
should
();
.
should
();
const
PostDeliveryCrowdsale
=
artifacts
.
require
(
'PostDeliveryCrowdsaleImpl'
);
const
PostDeliveryCrowdsale
=
artifacts
.
require
(
'PostDeliveryCrowdsaleImpl'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken
Mock
'
);
contract
(
'PostDeliveryCrowdsale'
,
function
([
_
,
investor
,
wallet
,
purchaser
])
{
contract
(
'PostDeliveryCrowdsale'
,
function
([
_
,
investor
,
wallet
,
purchaser
])
{
const
rate
=
new
BigNumber
(
1
);
const
rate
=
new
BigNumber
(
1
);
...
...
test/crowdsale/RefundableCrowdsale.test.js
View file @
2108641a
...
@@ -13,7 +13,7 @@ require('chai')
...
@@ -13,7 +13,7 @@ require('chai')
.
should
();
.
should
();
const
RefundableCrowdsale
=
artifacts
.
require
(
'RefundableCrowdsaleImpl'
);
const
RefundableCrowdsale
=
artifacts
.
require
(
'RefundableCrowdsaleImpl'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken'
);
const
SimpleToken
=
artifacts
.
require
(
'SimpleToken
Mock
'
);
contract
(
'RefundableCrowdsale'
,
function
([
_
,
wallet
,
investor
,
purchaser
,
anyone
])
{
contract
(
'RefundableCrowdsale'
,
function
([
_
,
wallet
,
investor
,
purchaser
,
anyone
])
{
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