-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release aragonOS 4.2.0
- Loading branch information
Showing
51 changed files
with
1,567 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
|
||
library ConversionHelpers { | ||
string private constant ERROR_IMPROPER_LENGTH = "CONVERSION_IMPROPER_LENGTH"; | ||
|
||
function dangerouslyCastUintArrayToBytes(uint256[] memory _input) internal pure returns (bytes memory output) { | ||
// Force cast the uint256[] into a bytes array, by overwriting its length | ||
// Note that the bytes array doesn't need to be initialized as we immediately overwrite it | ||
// with the input and a new length. The input becomes invalid from this point forward. | ||
uint256 byteLength = _input.length * 32; | ||
assembly { | ||
output := _input | ||
mstore(output, byteLength) | ||
} | ||
} | ||
|
||
function dangerouslyCastBytesToUintArray(bytes memory _input) internal pure returns (uint256[] memory output) { | ||
// Force cast the bytes array into a uint256[], by overwriting its length | ||
// Note that the uint256[] doesn't need to be initialized as we immediately overwrite it | ||
// with the input and a new length. The input becomes invalid from this point forward. | ||
uint256 intsLength = _input.length / 32; | ||
require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH); | ||
|
||
assembly { | ||
output := _input | ||
mstore(output, intsLength) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* SPDX-License-Identitifer: MIT | ||
*/ | ||
|
||
pragma solidity ^0.4.24; | ||
|
||
import "../common/UnstructuredStorage.sol"; | ||
|
||
|
||
contract ReentrancyGuard { | ||
using UnstructuredStorage for bytes32; | ||
|
||
/* Hardcoded constants to save gas | ||
bytes32 internal constant REENTRANCY_MUTEX_POSITION = keccak256("aragonOS.reentrancyGuard.mutex"); | ||
*/ | ||
bytes32 private constant REENTRANCY_MUTEX_POSITION = 0xe855346402235fdd185c890e68d2c4ecad599b88587635ee285bce2fda58dacb; | ||
|
||
string private constant ERROR_REENTRANT = "REENTRANCY_REENTRANT_CALL"; | ||
|
||
modifier nonReentrant() { | ||
// Ensure mutex is unlocked | ||
require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT); | ||
|
||
// Lock mutex before function call | ||
REENTRANCY_MUTEX_POSITION.setStorageBool(true); | ||
|
||
// Perform function call | ||
_; | ||
|
||
// Unlock mutex after function call | ||
REENTRANCY_MUTEX_POSITION.setStorageBool(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.