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
e2e05294
Commit
e2e05294
authored
Sep 26, 2018
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert RefundEscrow to initializers
parent
3130a3f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
4 deletions
+24
-4
RefundableCrowdsale.sol
contracts/crowdsale/distribution/RefundableCrowdsale.sol
+7
-1
RefundEscrowMock.sol
contracts/mocks/RefundEscrowMock.sol
+10
-0
RefundEscrow.sol
contracts/payment/RefundEscrow.sol
+6
-2
RefundEscrow.test.js
test/payment/RefundEscrow.test.js
+1
-1
No files found.
contracts/crowdsale/distribution/RefundableCrowdsale.sol
View file @
e2e05294
...
@@ -26,7 +26,13 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -26,7 +26,13 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
*/
constructor(uint256 goal) public {
constructor(uint256 goal) public {
require(goal > 0);
require(goal > 0);
_escrow = new RefundEscrow(wallet());
// conditional added to make initializer idempotent in case of diamond inheritance
if (address(_escrow) == address(0)) {
_escrow = new RefundEscrow();
_escrow.initialize(wallet());
}
_goal = goal;
_goal = goal;
}
}
...
...
contracts/mocks/RefundEscrowMock.sol
0 → 100644
View file @
e2e05294
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../payment/RefundEscrow.sol";
contract RefundEscrowMock is Initializable, RefundEscrow {
constructor(address beneficiary) public {
RefundEscrow.initialize(beneficiary);
}
}
contracts/payment/RefundEscrow.sol
View file @
e2e05294
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "./ConditionalEscrow.sol";
import "./ConditionalEscrow.sol";
import "../ownership/Secondary.sol";
import "../ownership/Secondary.sol";
...
@@ -10,7 +11,7 @@ import "../ownership/Secondary.sol";
...
@@ -10,7 +11,7 @@ import "../ownership/Secondary.sol";
* The primary account may close the deposit period, and allow for either withdrawal
* The primary account may close the deposit period, and allow for either withdrawal
* by the beneficiary, or refunds to the depositors.
* by the beneficiary, or refunds to the depositors.
*/
*/
contract RefundEscrow is Secondary, ConditionalEscrow {
contract RefundEscrow is
Initializable,
Secondary, ConditionalEscrow {
enum State { Active, Refunding, Closed }
enum State { Active, Refunding, Closed }
event Closed();
event Closed();
...
@@ -23,7 +24,10 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
...
@@ -23,7 +24,10 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
* @dev Constructor.
* @dev Constructor.
* @param beneficiary The beneficiary of the deposits.
* @param beneficiary The beneficiary of the deposits.
*/
*/
constructor(address beneficiary) public {
function initialize(address beneficiary) public initializer {
Secondary.initialize();
ConditionalEscrow.initialize();
require(beneficiary != address(0));
require(beneficiary != address(0));
_beneficiary = beneficiary;
_beneficiary = beneficiary;
_state = State.Active;
_state = State.Active;
...
...
test/payment/RefundEscrow.test.js
View file @
e2e05294
...
@@ -9,7 +9,7 @@ require('chai')
...
@@ -9,7 +9,7 @@ require('chai')
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
.
should
();
const
RefundEscrow
=
artifacts
.
require
(
'RefundEscrow'
);
const
RefundEscrow
=
artifacts
.
require
(
'RefundEscrow
Mock
'
);
contract
(
'RefundEscrow'
,
function
([
_
,
primary
,
beneficiary
,
refundee1
,
refundee2
])
{
contract
(
'RefundEscrow'
,
function
([
_
,
primary
,
beneficiary
,
refundee1
,
refundee2
])
{
const
amount
=
web3
.
toWei
(
54.0
,
'ether'
);
const
amount
=
web3
.
toWei
(
54.0
,
'ether'
);
...
...
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