|
@@ -2,6 +2,7 @@ pragma solidity ^0.5.0;
|
|
|
|
|
|
import "../../math/SafeMath.sol";
|
|
|
import "../../ownership/Secondary.sol";
|
|
|
+import "../../utils/Address.sol";
|
|
|
|
|
|
/**
|
|
|
* @title Escrow
|
|
@@ -18,6 +19,7 @@ import "../../ownership/Secondary.sol";
|
|
|
*/
|
|
|
contract Escrow is Secondary {
|
|
|
using SafeMath for uint256;
|
|
|
+ using Address for address payable;
|
|
|
|
|
|
event Deposited(address indexed payee, uint256 weiAmount);
|
|
|
event Withdrawn(address indexed payee, uint256 weiAmount);
|
|
@@ -40,7 +42,14 @@ contract Escrow is Secondary {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Withdraw accumulated balance for a payee.
|
|
|
+ * @dev Withdraw accumulated balance for a payee, forwarding 2300 gas (a
|
|
|
+ * Solidity `transfer`).
|
|
|
+ *
|
|
|
+ * NOTE: This function has been deprecated, use {withdrawWithGas} instead.
|
|
|
+ * Calling contracts with fixed-gas limits is an anti-pattern and may break
|
|
|
+ * contract interactions in network upgrades (hardforks).
|
|
|
+ * https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more.]
|
|
|
+ *
|
|
|
* @param payee The address whose funds will be withdrawn and transferred to.
|
|
|
*/
|
|
|
function withdraw(address payable payee) public onlyPrimary {
|
|
@@ -52,4 +61,21 @@ contract Escrow is Secondary {
|
|
|
|
|
|
emit Withdrawn(payee, payment);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @dev Same as {withdraw}, but forwarding all gas to the recipient.
|
|
|
+ *
|
|
|
+ * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
|
|
|
+ * Make sure you trust the recipient, or are either following the
|
|
|
+ * checks-effects-interactions pattern or using {ReentrancyGuard}.
|
|
|
+ */
|
|
|
+ function withdrawWithGas(address payable payee) public onlyPrimary {
|
|
|
+ uint256 payment = _deposits[payee];
|
|
|
+
|
|
|
+ _deposits[payee] = 0;
|
|
|
+
|
|
|
+ payee.sendValue(payment);
|
|
|
+
|
|
|
+ emit Withdrawn(payee, payment);
|
|
|
+ }
|
|
|
}
|