diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index a69d4a0ed..d55a573fb 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.24; import "../../math/SafeMath.sol"; import "./FinalizableCrowdsale.sol"; -import "../../payment/RefundEscrow.sol"; +import "../../payment/escrow/RefundEscrow.sol"; /** * @title RefundableCrowdsale diff --git a/contracts/mocks/ConditionalEscrowMock.sol b/contracts/mocks/ConditionalEscrowMock.sol index 93a594b97..3e30c21a2 100644 --- a/contracts/mocks/ConditionalEscrowMock.sol +++ b/contracts/mocks/ConditionalEscrowMock.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "../payment/ConditionalEscrow.sol"; +import "../payment/escrow/ConditionalEscrow.sol"; // mock class using ConditionalEscrow contract ConditionalEscrowMock is ConditionalEscrow { diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index 67ef8c667..4db11c089 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "./Escrow.sol"; +import "./escrow/Escrow.sol"; /** * @title PullPayment diff --git a/contracts/payment/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol similarity index 88% rename from contracts/payment/ConditionalEscrow.sol rename to contracts/payment/escrow/ConditionalEscrow.sol index 645dad479..c3f63ee37 100644 --- a/contracts/payment/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -5,6 +5,7 @@ import "./Escrow.sol"; /** * @title ConditionalEscrow * @dev Base abstract escrow to only allow withdrawal if a condition is met. + * @dev Intended usage: See Escrow.sol. Same usage guidelines apply here. */ contract ConditionalEscrow is Escrow { /** diff --git a/contracts/payment/Escrow.sol b/contracts/payment/escrow/Escrow.sol similarity index 60% rename from contracts/payment/Escrow.sol rename to contracts/payment/escrow/Escrow.sol index 7fb118e3a..b2f2a85ee 100644 --- a/contracts/payment/Escrow.sol +++ b/contracts/payment/escrow/Escrow.sol @@ -1,14 +1,19 @@ pragma solidity ^0.4.24; -import "../math/SafeMath.sol"; -import "../ownership/Secondary.sol"; +import "../../math/SafeMath.sol"; +import "../../ownership/Secondary.sol"; -/** + /** * @title Escrow - * @dev Base escrow contract, holds funds destinated to a payee until they - * withdraw them. The contract that uses the escrow as its payment method - * should be its primary, and provide public methods redirecting to the escrow's - * deposit and withdraw. + * @dev Base escrow contract, holds funds designated for a payee until they + * withdraw them. + * @dev Intended usage: This contract (and derived escrow contracts) should be a + * standalone contract, that only interacts with the contract that instantiated + * it. That way, it is guaranteed that all Ether will be handled according to + * the Escrow rules, and there is no need to check for payable functions or + * transfers in the inheritance tree. The contract that uses the escrow as its + * payment method should be its primary, and provide public methods redirecting + * to the escrow's deposit and withdraw. */ contract Escrow is Secondary { using SafeMath for uint256; diff --git a/contracts/payment/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol similarity index 81% rename from contracts/payment/RefundEscrow.sol rename to contracts/payment/escrow/RefundEscrow.sol index 3dfb3b965..a776a81c8 100644 --- a/contracts/payment/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -4,9 +4,14 @@ import "./ConditionalEscrow.sol"; /** * @title RefundEscrow - * @dev Escrow that holds funds for a beneficiary, deposited from multiple parties. - * The primary account may close the deposit period, and allow for either withdrawal - * by the beneficiary, or refunds to the depositors. + * @dev Escrow that holds funds for a beneficiary, deposited from multiple + * parties. + * @dev Intended usage: See Escrow.sol. Same usage guidelines apply here. + * @dev The primary account (that is, the contract that instantiates this + * contract) may deposit, close the deposit period, and allow for either + * withdrawal by the beneficiary, or refunds to the depositors. All interactions + * with RefundEscrow will be made through the primary contract. See the + * RefundableCrowdsale contract for an example of RefundEscrow’s use. */ contract RefundEscrow is ConditionalEscrow { enum State { Active, Refunding, Closed } diff --git a/test/payment/ConditionalEscrow.test.js b/test/payment/escrow/ConditionalEscrow.test.js similarity index 91% rename from test/payment/ConditionalEscrow.test.js rename to test/payment/escrow/ConditionalEscrow.test.js index bfb38dd86..c30b7bde5 100644 --- a/test/payment/ConditionalEscrow.test.js +++ b/test/payment/escrow/ConditionalEscrow.test.js @@ -1,7 +1,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); -const shouldFail = require('../helpers/shouldFail'); -const { ether } = require('../helpers/ether'); +const shouldFail = require('../../helpers/shouldFail'); +const { ether } = require('../../helpers/ether'); const BigNumber = web3.BigNumber; diff --git a/test/payment/Escrow.behavior.js b/test/payment/escrow/Escrow.behavior.js similarity index 93% rename from test/payment/Escrow.behavior.js rename to test/payment/escrow/Escrow.behavior.js index c724c5395..d7a7975e7 100644 --- a/test/payment/Escrow.behavior.js +++ b/test/payment/escrow/Escrow.behavior.js @@ -1,7 +1,7 @@ -const expectEvent = require('../helpers/expectEvent'); -const shouldFail = require('../helpers/shouldFail'); -const { ethGetBalance } = require('../helpers/web3'); -const { ether } = require('../helpers/ether'); +const expectEvent = require('../../helpers/expectEvent'); +const shouldFail = require('../../helpers/shouldFail'); +const { ethGetBalance } = require('../../helpers/web3'); +const { ether } = require('../../helpers/ether'); const BigNumber = web3.BigNumber; diff --git a/test/payment/Escrow.test.js b/test/payment/escrow/Escrow.test.js similarity index 100% rename from test/payment/Escrow.test.js rename to test/payment/escrow/Escrow.test.js diff --git a/test/payment/RefundEscrow.test.js b/test/payment/escrow/RefundEscrow.test.js similarity index 94% rename from test/payment/RefundEscrow.test.js rename to test/payment/escrow/RefundEscrow.test.js index 02a58a3b5..1f92e23af 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/escrow/RefundEscrow.test.js @@ -1,8 +1,8 @@ -const shouldFail = require('../helpers/shouldFail'); -const expectEvent = require('../helpers/expectEvent'); -const { ethGetBalance } = require('../helpers/web3'); -const { ether } = require('../helpers/ether'); -const { ZERO_ADDRESS } = require('../helpers/constants'); +const shouldFail = require('../../helpers/shouldFail'); +const expectEvent = require('../../helpers/expectEvent'); +const { ethGetBalance } = require('../../helpers/web3'); +const { ether } = require('../../helpers/ether'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const BigNumber = web3.BigNumber;