|
@@ -25,17 +25,34 @@ contract PullPayment {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @dev Withdraw accumulated payments.
|
|
* @dev Withdraw accumulated payments.
|
|
- * @param payee Whose payments will be withdrawn.
|
|
|
|
*
|
|
*
|
|
* Note that _any_ account can call this function, not just the `payee`.
|
|
* Note that _any_ account can call this function, not just the `payee`.
|
|
* This means that contracts unaware of the `PullPayment` protocol can still
|
|
* This means that contracts unaware of the `PullPayment` protocol can still
|
|
* receive funds this way, by having a separate account call
|
|
* receive funds this way, by having a separate account call
|
|
* {withdrawPayments}.
|
|
* {withdrawPayments}.
|
|
|
|
+ *
|
|
|
|
+ * NOTE: This function has been deprecated, use {withdrawPaymentsWithGas}
|
|
|
|
+ * 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 Whose payments will be withdrawn.
|
|
*/
|
|
*/
|
|
function withdrawPayments(address payable payee) public {
|
|
function withdrawPayments(address payable payee) public {
|
|
_escrow.withdraw(payee);
|
|
_escrow.withdraw(payee);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @dev Same as {withdrawPayments}, 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 withdrawPaymentsWithGas(address payable payee) public {
|
|
|
|
+ _escrow.withdrawWithGas(payee);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @dev Returns the payments owed to an address.
|
|
* @dev Returns the payments owed to an address.
|
|
* @param dest The creditor's address.
|
|
* @param dest The creditor's address.
|
|
@@ -46,11 +63,11 @@ contract PullPayment {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @dev Called by the payer to store the sent amount as credit to be pulled.
|
|
* @dev Called by the payer to store the sent amount as credit to be pulled.
|
|
- * @param dest The destination address of the funds.
|
|
|
|
- * @param amount The amount to transfer.
|
|
|
|
- *
|
|
|
|
* Funds sent in this way are stored in an intermediate {Escrow} contract, so
|
|
* Funds sent in this way are stored in an intermediate {Escrow} contract, so
|
|
* there is no danger of them being spent before withdrawal.
|
|
* there is no danger of them being spent before withdrawal.
|
|
|
|
+ *
|
|
|
|
+ * @param dest The destination address of the funds.
|
|
|
|
+ * @param amount The amount to transfer.
|
|
*/
|
|
*/
|
|
function _asyncTransfer(address dest, uint256 amount) internal {
|
|
function _asyncTransfer(address dest, uint256 amount) internal {
|
|
_escrow.deposit.value(amount)(dest);
|
|
_escrow.deposit.value(amount)(dest);
|