Эх сурвалжийг харах

Moved Escrows into an escrow subdirectory, improved docs. (#1430)

* Moved Escrows into an escrow subdirectory, improved docs.

* Fixed escrow mock.

* Fixed some more imports.
Nicolás Venturo 7 жил өмнө
parent
commit
f3df2dab3d

+ 1 - 1
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

+ 1 - 1
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 {

+ 1 - 1
contracts/payment/PullPayment.sol

@@ -1,6 +1,6 @@
 pragma solidity ^0.4.24;
 
-import "./Escrow.sol";
+import "./escrow/Escrow.sol";
 
 /**
  * @title PullPayment

+ 1 - 0
contracts/payment/ConditionalEscrow.sol → 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 {
   /**

+ 12 - 7
contracts/payment/Escrow.sol → 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;

+ 8 - 3
contracts/payment/RefundEscrow.sol → 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 }

+ 2 - 2
test/payment/ConditionalEscrow.test.js → 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;
 

+ 4 - 4
test/payment/Escrow.behavior.js → 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;
 

+ 0 - 0
test/payment/Escrow.test.js → test/payment/escrow/Escrow.test.js


+ 5 - 5
test/payment/RefundEscrow.test.js → 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;