diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-21 08:38:25 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-08-25 08:30:56 +0800 |
commit | d8cb56caa33885397f557afac5a4ccb24efb47d0 (patch) | |
tree | 9763f8ac1245f4ea29bd49b7f91d25ce22066c90 /packages/contracts | |
parent | 044415e23d3a079e6301d8fb838da60456794c4f (diff) | |
download | dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar.gz dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar.bz2 dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar.lz dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar.xz dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.tar.zst dexon-0x-contracts-d8cb56caa33885397f557afac5a4ccb24efb47d0.zip |
Add ReentrancyGuard contract
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol b/packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol new file mode 100644 index 000000000..70fc4ca6b --- /dev/null +++ b/packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol @@ -0,0 +1,44 @@ +/* + + Copyright 2018 ZeroEx Intl. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +pragma solidity 0.4.24; + + +contract ReentrancyGuard { + + // Locked state of mutex + bool private locked = false; + + /// @dev Functions with this modifier cannot be reentered. + modifier nonReentrant() { + // Ensure mutex is unlocked + require( + !locked, + "REENTRANCY_ILLEGAL" + ); + + // Lock mutex before function call + locked = true; + + // Perform function call + _; + + // Unlock mutex after function call + locked = false; + } + +} |