Skip to content

Instantly share code, notes, and snippets.

View mswezey23's full-sized avatar
🎯
Focusing

Swezey, Matt mswezey23

🎯
Focusing
View GitHub Profile
pragma solidity 0.5.5;
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract TestStructCompactionImproved {
using SafeMath for uint256;
struct Vote {
address account; // The voter's account address.
uint256 votingPower; // Token balance of the account at the proposal's creation time.
pragma solidity 0.5.5;
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract TestStructCompaction {
using SafeMath for uint256;
struct Vote {
address account; // The voter's account address.
uint256 votingPower; // Token balance of the account at the proposal's creation time.
/* file: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol */
pragma solidity ^0.5.0;
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
pragma solidity ^0.5.0;
contract testManager {
address public manager;
modifier onlyManager() {
require(msg.sender == manager);
_;
}
@mswezey23
mswezey23 / BountyComments.sol
Created November 30, 2018 17:34
BountyOne Contract Review
// endTime is already in day units from the 1st line, making the 2nd `* 1 days' incorrect in the 2nd require() statement
// endTime should be checked for > 0
// the 2nd require() statment is not logical. now + N (N being an unint > 0) will always be > now
uint endTime = _endTimeInDays * 1 days;
require(endTime < maxAuditDuration);
require(block.timestamp + endTime * 1 days > block.timestamp);
require(msg.value > 0 && _maxAuditors > 0 && _stake > 0);
// Lines 14, 16, and 17 do NOT update state. Should be the following:
// 14: audits[_id].remainingReward = audits[_id].remainingReward.sub(_reward);
@mswezey23
mswezey23 / Test SafeMath
Created November 16, 2018 05:40
SafeMath Test for uint64
pragma solidity ^0.4.24;
library SafeMathExtensions {
/**
* @dev Casts to uint8, throws on overflow.
*/
function castTo8(uint256 a) internal pure returns (uint8 c) {
c = uint8(a);
assert(a == c);