Skip to content

Commit

Permalink
Add support for solc@^0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jijordre committed May 19, 2019
1 parent 25efb27 commit d32f978
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 90 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Solidity Utils Contrubutions
# Solidity Utils Contributions

When contributing to this repository please try and adhear to the following before making a pull request:
When contributing to this repository please try and adhere to the following before making a pull request:
- Keep styling and naming conventions consistent with the pre-existing solutions
- Be mindful of gas consumption and highlight high gas costs
- Clearly document the changes or additions
Expand Down
4 changes: 2 additions & 2 deletions lib/Addresses.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

/**
* Addresses Library
Expand All @@ -17,7 +17,7 @@ library Addresses {
* @param _base The address on the network to check if it is a contract
* @return bool Returns true if it is a valid contract
*/
function isContract(address _base) returns (bool _r) {
function isContract(address _base) internal view returns (bool _r) {
assembly {
_r := gt(extcodesize(_base), 0)
}
Expand Down
26 changes: 15 additions & 11 deletions lib/Integers.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

/**
* Integers Library
Expand All @@ -18,18 +18,19 @@ library Integers {
* @param _value The ASCII string to be converted to an unsigned integer
* @return uint The unsigned value of the ASCII string
*/
function parseInt(string _value)
function parseInt(string memory _value)
public
pure
returns (uint _ret) {
bytes memory _bytesValue = bytes(_value);
uint j = 1;
for(uint i = _bytesValue.length-1; i >= 0 && i < _bytesValue.length; i--) {
assert(_bytesValue[i] >= 48 && _bytesValue[i] <= 57);
_ret += (uint(_bytesValue[i]) - 48)*j;
assert(uint8(_bytesValue[i]) >= 48 && uint8(_bytesValue[i]) <= 57);
_ret += (uint8(_bytesValue[i]) - 48)*j;
j*=10;
}
}

/**
* To String
*
Expand All @@ -38,13 +39,14 @@ library Integers {
* @param _base The unsigned integer to be converted to a string
* @return string The resulting ASCII string value
*/
function toString(uint _base)
function toString(uint _base)
internal
returns (string) {
pure
returns (string memory) {
bytes memory _tmp = new bytes(32);
uint i;
for(i = 0;_base > 0;i++) {
_tmp[i] = byte((_base % 10) + 48);
_tmp[i] = byte(uint8((_base % 10) + 48));
_base /= 10;
}
bytes memory _real = new bytes(i--);
Expand All @@ -62,8 +64,9 @@ library Integers {
* @param _base The 8 bit unsigned integer
* @return byte The byte equivalent
*/
function toByte(uint8 _base)
function toByte(uint8 _base)
public
pure
returns (byte _ret) {
assembly {
let m_alloc := add(msize(),0x1)
Expand All @@ -80,9 +83,10 @@ library Integers {
* @param _base The integer to be converted to bytes
* @return bytes The bytes equivalent
*/
function toBytes(uint _base)
function toBytes(uint _base)
internal
returns (bytes _ret) {
pure
returns (bytes memory _ret) {
assembly {
let m_alloc := add(msize(),0x1)
_ret := mload(m_alloc)
Expand Down
Loading

0 comments on commit d32f978

Please sign in to comment.