Merge pull request #2228 from 0xProject/fix/3.0/refundFinalBalanceNoReentry
refundFinalBalanceNoReentry
This commit is contained in:
@@ -61,8 +61,7 @@ contract MixinExchangeCore is
|
|||||||
function cancelOrdersUpTo(uint256 targetOrderEpoch)
|
function cancelOrdersUpTo(uint256 targetOrderEpoch)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
{
|
{
|
||||||
address makerAddress = _getCurrentContextAddress();
|
address makerAddress = _getCurrentContextAddress();
|
||||||
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
||||||
@@ -103,8 +102,7 @@ contract MixinExchangeCore is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.FillResults memory fillResults)
|
returns (LibFillResults.FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = _fillOrder(
|
fillResults = _fillOrder(
|
||||||
@@ -120,8 +118,7 @@ contract MixinExchangeCore is
|
|||||||
function cancelOrder(LibOrder.Order memory order)
|
function cancelOrder(LibOrder.Order memory order)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
{
|
{
|
||||||
_cancelOrder(order);
|
_cancelOrder(order);
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,7 @@ contract MixinMatchOrders is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
|
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
|
||||||
{
|
{
|
||||||
return _batchMatchOrders(
|
return _batchMatchOrders(
|
||||||
@@ -81,8 +80,7 @@ contract MixinMatchOrders is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
|
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
|
||||||
{
|
{
|
||||||
return _batchMatchOrders(
|
return _batchMatchOrders(
|
||||||
@@ -111,8 +109,7 @@ contract MixinMatchOrders is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||||
{
|
{
|
||||||
return _matchOrders(
|
return _matchOrders(
|
||||||
@@ -141,8 +138,7 @@ contract MixinMatchOrders is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||||
{
|
{
|
||||||
return _matchOrders(
|
return _matchOrders(
|
||||||
|
@@ -22,7 +22,6 @@ pragma experimental ABIEncoderV2;
|
|||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibEIP1271.sol";
|
import "@0x/contracts-utils/contracts/src/LibEIP1271.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
@@ -35,7 +34,6 @@ import "./MixinTransactions.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
contract MixinSignatureValidator is
|
||||||
ReentrancyGuard,
|
|
||||||
LibEIP712ExchangeDomain,
|
LibEIP712ExchangeDomain,
|
||||||
LibEIP1271,
|
LibEIP1271,
|
||||||
ISignatureValidator,
|
ISignatureValidator,
|
||||||
@@ -61,8 +59,7 @@ contract MixinSignatureValidator is
|
|||||||
function preSign(bytes32 hash)
|
function preSign(bytes32 hash)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
{
|
{
|
||||||
address signerAddress = _getCurrentContextAddress();
|
address signerAddress = _getCurrentContextAddress();
|
||||||
preSigned[hash][signerAddress] = true;
|
preSigned[hash][signerAddress] = true;
|
||||||
@@ -78,8 +75,7 @@ contract MixinSignatureValidator is
|
|||||||
)
|
)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
{
|
{
|
||||||
address signerAddress = _getCurrentContextAddress();
|
address signerAddress = _getCurrentContextAddress();
|
||||||
allowedValidators[signerAddress][validatorAddress] = approval;
|
allowedValidators[signerAddress][validatorAddress] = approval;
|
||||||
|
@@ -47,8 +47,7 @@ contract MixinWrapperFunctions is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.FillResults memory fillResults)
|
returns (LibFillResults.FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = _fillOrKillOrder(
|
fillResults = _fillOrKillOrder(
|
||||||
@@ -71,8 +70,7 @@ contract MixinWrapperFunctions is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.FillResults[] memory fillResults)
|
returns (LibFillResults.FillResults[] memory fillResults)
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
@@ -99,8 +97,7 @@ contract MixinWrapperFunctions is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
returns (LibFillResults.FillResults[] memory fillResults)
|
returns (LibFillResults.FillResults[] memory fillResults)
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
@@ -287,8 +284,7 @@ contract MixinWrapperFunctions is
|
|||||||
function batchCancelOrders(LibOrder.Order[] memory orders)
|
function batchCancelOrders(LibOrder.Order[] memory orders)
|
||||||
public
|
public
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
refundFinalBalanceNoReentry
|
||||||
refundFinalBalance
|
|
||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
for (uint256 i = 0; i != ordersLength; i++) {
|
for (uint256 i = 0; i != ordersLength; i++) {
|
||||||
|
@@ -18,8 +18,12 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
|
import "./ReentrancyGuard.sol";
|
||||||
|
|
||||||
contract Refundable {
|
|
||||||
|
contract Refundable is
|
||||||
|
ReentrancyGuard
|
||||||
|
{
|
||||||
|
|
||||||
// This bool is used by the refund modifier to allow for lazily evaluated refunds.
|
// This bool is used by the refund modifier to allow for lazily evaluated refunds.
|
||||||
bool internal _shouldNotRefund;
|
bool internal _shouldNotRefund;
|
||||||
@@ -29,6 +33,13 @@ contract Refundable {
|
|||||||
_refundNonZeroBalanceIfEnabled();
|
_refundNonZeroBalanceIfEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifier refundFinalBalanceNoReentry {
|
||||||
|
_lockMutexOrThrowIfAlreadyLocked();
|
||||||
|
_;
|
||||||
|
_refundNonZeroBalanceIfEnabled();
|
||||||
|
_unlockMutex();
|
||||||
|
}
|
||||||
|
|
||||||
modifier disableRefundUntilEnd {
|
modifier disableRefundUntilEnd {
|
||||||
if (_areRefundsDisabled()) {
|
if (_areRefundsDisabled()) {
|
||||||
_;
|
_;
|
||||||
|
Reference in New Issue
Block a user