Skip to content

Commit

Permalink
Merge branch 'dev' into acl-log-set-params
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai committed Aug 10, 2018
2 parents 52f5380 + 898310f commit ca14bfd
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 8,106 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Dependencies
node_modules/

# Yarn lock files
# Lock files
package-lock.json
yarn.lock

# coverage
Expand Down
4 changes: 4 additions & 0 deletions contracts/acl/ACLSyntaxSugar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ contract ACLSyntaxSugar {
return arr(uint256(_a), _b, _c);
}

function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
return arr(uint256(_a), _b, _c, _d);
}

function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {
return arr(uint256(_a), uint256(_b));
}
Expand Down
12 changes: 2 additions & 10 deletions contracts/common/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
pragma solidity ^0.4.18;

import "../apps/AppStorage.sol";
import "../common/TimeHelpers.sol";


contract Initializable is AppStorage {
contract Initializable is AppStorage, TimeHelpers {
modifier onlyInit {
require(initializationBlock == 0);
_;
Expand All @@ -31,13 +32,4 @@ contract Initializable is AppStorage {
function initialized() internal onlyInit {
initializationBlock = getBlockNumber();
}

/**
* @dev Returns the current block number.
* Using a function rather than `block.number` allows us to easily mock the block number in
* tests.
*/
function getBlockNumber() internal view returns (uint256) {
return block.number;
}
}
48 changes: 48 additions & 0 deletions contracts/common/TimeHelpers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* SPDX-License-Identitifer: MIT
*/

pragma solidity ^0.4.18;

import "./Uint256Helpers.sol";


contract TimeHelpers {
using Uint256Helpers for uint256;

/**
* @dev Returns the current block number.
* Using a function rather than `block.number` allows us to easily mock the block number in
* tests.
*/
function getBlockNumber() internal view returns (uint256) {
return block.number;
}

/**
* @dev Returns the current block number, converted to uint64.
* Using a function rather than `block.number` allows us to easily mock the block number in
* tests.
*/
function getBlockNumber64() internal view returns (uint64) {
return getBlockNumber().toUint64();
}

/**
* @dev Returns the current timestamp.
* Using a function rather than `now` allows us to easily mock it in
* tests.
*/
function getTimestamp() internal view returns (uint256) {
return now;
}

/**
* @dev Returns the current timestamp, covnerted to uint64.
* Using a function rather than `now` allows us to easily mock it in
* tests.
*/
function getTimestamp64() internal view returns (uint64) {
return getTimestamp().toUint64();
}
}
11 changes: 11 additions & 0 deletions contracts/common/Uint256Helpers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity ^0.4.18;


library Uint256Helpers {
uint256 public constant MAX_UINT64 = uint64(-1);

function toUint64(uint256 a) internal pure returns (uint64) {
require(a <= MAX_UINT64);
return uint64(a);
}
}
Loading

0 comments on commit ca14bfd

Please sign in to comment.