* Error handling in ERC20 and ERC721 * Added message string for require. * Fixed solhint errors. * Updated PR as per issue #1709 * changes as per #1709 and openzeppelin forum. * Changes in require statement * Changes in require statement * build pipeline fix * Changes as per @nventuro's comment. * Update revert reason strings. * Fianal update of revert reason strings. * WIP: Updating reason strings in test cases * WIP: Added changes to ERC20 and ERC721 * Fixes linting errors in *.tes.js files * Achieved 100% code coverage * Updated the test cases with shouldFail.reverting.withMessage() * Fix package-lock. * address review comments * fix linter issues * fix remaining revert reasons
33 lines
1.1 KiB
Solidity
33 lines
1.1 KiB
Solidity
pragma solidity ^0.5.7;
|
|
|
|
/**
|
|
* @title Helps contracts guard against reentrancy attacks.
|
|
* @author Remco Bloemen <remco@2π.com>, Eenae <alexey@mixbytes.io>
|
|
* @dev If you mark a function `nonReentrant`, you should also
|
|
* mark it `external`.
|
|
*/
|
|
contract ReentrancyGuard {
|
|
/// @dev counter to allow mutex lock with only one SSTORE operation
|
|
uint256 private _guardCounter;
|
|
|
|
constructor () internal {
|
|
// The counter starts at one to prevent changing it from zero to a non-zero
|
|
// value, which is a more expensive operation.
|
|
_guardCounter = 1;
|
|
}
|
|
|
|
/**
|
|
* @dev Prevents a contract from calling itself, directly or indirectly.
|
|
* Calling a `nonReentrant` function from another `nonReentrant`
|
|
* function is not supported. It is possible to prevent this from happening
|
|
* by making the `nonReentrant` function external, and make it call a
|
|
* `private` function that does the actual work.
|
|
*/
|
|
modifier nonReentrant() {
|
|
_guardCounter += 1;
|
|
uint256 localCounter = _guardCounter;
|
|
_;
|
|
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
|
|
}
|
|
}
|