Skip to content

Commit

Permalink
Move contracts to subdirectories (#1253)
Browse files Browse the repository at this point in the history
* Move contracts to subdirectories

Fixes #1177.

This Change also removes the LimitBalance contract.

* fix import

* move MerkleProof to cryptography

* Fix import
  • Loading branch information
Leo Arias authored and frangio committed Sep 3, 2018
1 parent 964bc40 commit 2441fd7
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 161 deletions.
31 changes: 0 additions & 31 deletions contracts/LimitBalance.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/access/SignatureBouncer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.4.24;

import "../ownership/Ownable.sol";
import "../access/rbac/RBAC.sol";
import "../ECRecovery.sol";
import "../cryptography/ECDSA.sol";


/**
Expand Down Expand Up @@ -30,7 +30,7 @@ import "../ECRecovery.sol";
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
*/
contract SignatureBouncer is Ownable, RBAC {
using ECRecovery for bytes32;
using ECDSA for bytes32;

string public constant ROLE_BOUNCER = "bouncer";
uint internal constant METHOD_ID_SIZE = 4;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pragma solidity ^0.4.24;


import "./payment/PullPayment.sol";
import "./lifecycle/Destructible.sol";
import "../payment/PullPayment.sol";
import "../lifecycle/Destructible.sol";


/**
* @title Bounty
* @title BreakInvariantBounty
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
*/
contract Bounty is PullPayment, Destructible {
contract BreakInvariantBounty is PullPayment, Destructible {
bool public claimed;
mapping(address => address) public researchers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pragma solidity ^0.4.24;
* See https://github.com/ethereum/solidity/issues/864
*/

library ECRecovery {
library ECDSA {

/**
* @dev Recover signer address from a message by using their signature
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion contracts/mocks/AutoIncrementingImpl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../AutoIncrementing.sol";
import "../utils/AutoIncrementing.sol";


contract AutoIncrementingImpl {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pragma solidity ^0.4.24;


import "../ECRecovery.sol";
import "../cryptography/ECDSA.sol";


contract ECRecoveryMock {
using ECRecovery for bytes32;
contract ECDSAMock {
using ECDSA for bytes32;

function recover(bytes32 _hash, bytes _signature)
public
Expand Down
20 changes: 20 additions & 0 deletions contracts/mocks/InsecureInvariantTargetBounty.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pragma solidity ^0.4.24;

// When this line is split, truffle parsing fails.
// See: https://github.com/ethereum/solidity/issues/4871
// solium-disable-next-line max-len
import {BreakInvariantBounty, Target} from "../../contracts/bounties/BreakInvariantBounty.sol";


contract InsecureInvariantTargetMock is Target {
function checkInvariant() public returns(bool) {
return false;
}
}


contract InsecureInvariantTargetBounty is BreakInvariantBounty {
function deployContract() internal returns (address) {
return new InsecureInvariantTargetMock();
}
}
17 changes: 0 additions & 17 deletions contracts/mocks/InsecureTargetBounty.sol

This file was deleted.

13 changes: 0 additions & 13 deletions contracts/mocks/LimitBalanceMock.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/mocks/MerkleProofWrapper.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import { MerkleProof } from "../MerkleProof.sol";
import { MerkleProof } from "../cryptography/MerkleProof.sol";


contract MerkleProofWrapper {
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ReentrancyMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../ReentrancyGuard.sol";
import "../utils/ReentrancyGuard.sol";
import "./ReentrancyAttack.sol";


Expand Down
20 changes: 20 additions & 0 deletions contracts/mocks/SecureInvariantTargetBounty.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pragma solidity ^0.4.24;

// When this line is split, truffle parsing fails.
// See: https://github.com/ethereum/solidity/issues/4871
// solium-disable-next-line max-len
import {BreakInvariantBounty, Target} from "../../contracts/bounties/BreakInvariantBounty.sol";


contract SecureInvariantTargetMock is Target {
function checkInvariant() public returns(bool) {
return true;
}
}


contract SecureInvariantTargetBounty is BreakInvariantBounty {
function deployContract() internal returns (address) {
return new SecureInvariantTargetMock();
}
}
17 changes: 0 additions & 17 deletions contracts/mocks/SecureTargetBounty.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/token/ERC721/ERC721Basic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "./IERC721Basic.sol";
import "./IERC721Receiver.sol";
import "../../math/SafeMath.sol";
import "../../AddressUtils.sol";
import "../../utils/Address.sol";
import "../../introspection/SupportsInterfaceWithLookup.sol";


Expand All @@ -14,7 +14,7 @@ import "../../introspection/SupportsInterfaceWithLookup.sol";
contract ERC721Basic is SupportsInterfaceWithLookup, IERC721Basic {

using SafeMath for uint256;
using AddressUtils for address;
using Address for address;

// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
Expand Down
2 changes: 1 addition & 1 deletion contracts/AddressUtils.sol → contracts/utils/Address.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.4.24;
/**
* Utility library of inline functions on addresses
*/
library AddressUtils {
library Address {

/**
* Returns whether the target address is a contract
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions test/Bounty.test.js → test/BreakInvariantBounty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
const expectEvent = require('./helpers/expectEvent');
const { assertRevert } = require('./helpers/assertRevert');

const SecureTargetBounty = artifacts.require('SecureTargetBounty');
const InsecureTargetBounty = artifacts.require('InsecureTargetBounty');
const SecureInvariantTargetBounty = artifacts.require('SecureInvariantTargetBounty');
const InsecureInvariantTargetBounty = artifacts.require('InsecureInvariantTargetBounty');

require('chai')
.use(require('chai-bignumber')(web3.BigNumber))
Expand All @@ -17,10 +17,10 @@ const sendReward = async (from, to, value) => ethSendTransaction({

const reward = new web3.BigNumber(web3.toWei(1, 'ether'));

contract('Bounty', function ([_, owner, researcher, nonTarget]) {
contract('BreakInvariantBounty', function ([_, owner, researcher, nonTarget]) {
context('against secure contract', function () {
beforeEach(async function () {
this.bounty = await SecureTargetBounty.new({ from: owner });
this.bounty = await SecureInvariantTargetBounty.new({ from: owner });
});

it('can set reward', async function () {
Expand Down Expand Up @@ -53,7 +53,7 @@ contract('Bounty', function ([_, owner, researcher, nonTarget]) {

context('against broken contract', function () {
beforeEach(async function () {
this.bounty = await InsecureTargetBounty.new();
this.bounty = await InsecureInvariantTargetBounty.new();

const result = await this.bounty.createTarget({ from: researcher });
const event = expectEvent.inLogs(result.logs, 'TargetCreated');
Expand Down
59 changes: 0 additions & 59 deletions test/LimitBalance.test.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const { signMessage, toEthSignedMessageHash } = require('../helpers/sign');
const { expectThrow } = require('../helpers/expectThrow');

const ECRecoveryMock = artifacts.require('ECRecoveryMock');
const ECDSAMock = artifacts.require('ECDSAMock');

require('chai')
.should();

const TEST_MESSAGE = web3.sha3('OpenZeppelin');
const WRONG_MESSAGE = web3.sha3('Nope');

contract('ECRecovery', function ([_, anyone]) {
contract('ECDSA', function ([_, anyone]) {
beforeEach(async function () {
this.mock = await ECRecoveryMock.new();
this.mock = await ECDSAMock.new();
});

it('recover v0', async function () {
Expand Down

0 comments on commit 2441fd7

Please sign in to comment.