Upgrade to Truffle version 3.2.2 and Solidity version 0.4.11

This commit is contained in:
David Knott
2017-06-06 21:26:24 -06:00
parent c3cb0dcf80
commit 6ede3d9001
56 changed files with 71 additions and 63 deletions

View File

@ -5,7 +5,7 @@ language: node_js
node_js: node_js:
- "6" - "6"
before_install: before_install:
- npm install truffle@3.1.9 -g - npm install truffle@3.2.2 -g
- npm i -g ethereumjs-testrpc - npm i -g ethereumjs-testrpc
script: script:
- testrpc > /dev/null & - testrpc > /dev/null &

View File

@ -48,7 +48,7 @@ We think much more could be done here, and recommend the OpenZeppelin team keep
## Solidity Version Updates Recommended ## Solidity Version Updates Recommended
Most of the code uses Solidity 0.4.8, but some files under `Ownership` are marked 0.4.0. These should be updated. Most of the code uses Solidity 0.4.11, but some files under `Ownership` are marked 0.4.0. These should be updated.
Solidity 0.4.10 will add several features which could be useful in these contracts: Solidity 0.4.10 will add several features which could be useful in these contracts:

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './payment/PullPayment.sol'; import './payment/PullPayment.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**
* @title DayLimit * @title DayLimit

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./ownership/Multisig.sol"; import "./ownership/Multisig.sol";
@ -93,7 +93,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
/** /**
* @dev Updates the daily limit value. * @dev Updates the daily limit value.
* @param _newLimit * @param _newLimit Uint to represent the new limit.
*/ */
function setDailyLimit(uint _newLimit) onlymanyowners(keccak256(msg.data)) external { function setDailyLimit(uint _newLimit) onlymanyowners(keccak256(msg.data)) external {
_setDailyLimit(_newLimit); _setDailyLimit(_newLimit);

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**
* @title Helps contracts guard agains rentrancy attacks. * @title Helps contracts guard agains rentrancy attacks.

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
@ -10,6 +10,8 @@ import "../ownership/Ownable.sol";
*/ */
contract Destructible is Ownable { contract Destructible is Ownable {
function Destructible() payable { }
/** /**
* @dev Transfers the current balance to the owner and terminates the contract. * @dev Transfers the current balance to the owner and terminates the contract.
*/ */

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../ownership/Ownable.sol'; import '../ownership/Ownable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
@ -12,6 +12,8 @@ import "../token/ERC20Basic.sol";
*/ */
contract TokenDestructible is Ownable { contract TokenDestructible is Ownable {
function TokenDestructible() payable { }
/** /**
* @notice Terminate contract and refund to owner * @notice Terminate contract and refund to owner
* @param tokens List of addresses of ERC20 or ERC20Basic token contracts to * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './Ownable.sol'; import './Ownable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './Ownable.sol'; import './Ownable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './Claimable.sol'; import './Claimable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./Ownable.sol"; import "./Ownable.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./Ownable.sol"; import "./Ownable.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./Ownable.sol"; import "./Ownable.sol";
import "../token/ERC20Basic.sol"; import "../token/ERC20Basic.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./HasNoEther.sol"; import "./HasNoEther.sol";
import "./HasNoTokens.sol"; import "./HasNoTokens.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../SafeMath.sol'; import '../SafeMath.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './ERC20Basic.sol'; import './ERC20Basic.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./StandardToken.sol"; import "./StandardToken.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './ERC20Basic.sol'; import './ERC20Basic.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
/** /**

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./ERC20.sol"; import "./ERC20.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './StandardToken.sol'; import './StandardToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './StandardToken.sol'; import './StandardToken.sol';
import '../lifecycle/Pausable.sol'; import '../lifecycle/Pausable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./StandardToken.sol"; import "./StandardToken.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import './BasicToken.sol'; import './BasicToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "./StandardToken.sol"; import "./StandardToken.sol";
import "./LimitedTransferToken.sol"; import "./LimitedTransferToken.sol";

View File

@ -40,6 +40,6 @@
"ethereumjs-testrpc": "^3.0.2", "ethereumjs-testrpc": "^3.0.2",
"mocha-lcov-reporter": "^1.3.0", "mocha-lcov-reporter": "^1.3.0",
"solidity-coverage": "^0.1.0", "solidity-coverage": "^0.1.0",
"truffle": "https://github.com/ConsenSys/truffle.git#3.1.9" "truffle": "3.2.2"
} }
} }

View File

@ -49,7 +49,7 @@ contract('DelayedClaimable', function(accounts) {
} catch (error) { } catch (error) {
err = error; err = error;
} }
assert.isFalse(err.message.search('invalid JUMP') === -1); assert.isFalse(err.message.search('invalid opcode') === -1);
let owner = await delayedClaimable.owner(); let owner = await delayedClaimable.owner();
assert.isTrue(owner !== accounts[1]); assert.isTrue(owner !== accounts[1]);
}); });
@ -62,7 +62,7 @@ contract('DelayedClaimable', function(accounts) {
} catch (error) { } catch (error) {
err = error; err = error;
} }
assert.isFalse(err.message.search('invalid JUMP') === -1); assert.isFalse(err.message.search('invalid opcode') === -1);
}); });
}); });

View File

@ -35,7 +35,8 @@ contract('HasNoEther', function(accounts) {
assert.equal(startBalance, 0); assert.equal(startBalance, 0);
// Force ether into it // Force ether into it
await ForceEther.new(hasNoEther.address, {value: amount}); let forceEther = await ForceEther.new({value: amount});
await forceEther.destroyAndSend(hasNoEther.address);
const forcedBalance = await web3.eth.getBalance(hasNoEther.address); const forcedBalance = await web3.eth.getBalance(hasNoEther.address);
assert.equal(forcedBalance, amount); assert.equal(forcedBalance, amount);
@ -53,7 +54,8 @@ contract('HasNoEther', function(accounts) {
let hasNoEther = await HasNoEtherTest.new({from: accounts[0]}); let hasNoEther = await HasNoEtherTest.new({from: accounts[0]});
// Force ether into it // Force ether into it
await ForceEther.new(hasNoEther.address, {value: amount}); let forceEther = await ForceEther.new({value: amount});
await forceEther.destroyAndSend(hasNoEther.address);
const forcedBalance = await web3.eth.getBalance(hasNoEther.address); const forcedBalance = await web3.eth.getBalance(hasNoEther.address);
assert.equal(forcedBalance, amount); assert.equal(forcedBalance, amount);

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/token/BasicToken.sol'; import '../../contracts/token/BasicToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../../contracts/DayLimit.sol"; import "../../contracts/DayLimit.sol";
contract DayLimitMock is DayLimit { contract DayLimitMock is DayLimit {

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/token/BasicToken.sol'; import '../../contracts/token/BasicToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
// @title Force Ether into a contract. // @title Force Ether into a contract.
// @notice even // @notice even
@ -6,8 +6,10 @@ pragma solidity ^0.4.8;
// @notice To use, construct the contract with the target as argument. // @notice To use, construct the contract with the target as argument.
// @author Remco Bloemen <remco@neufund.org> // @author Remco Bloemen <remco@neufund.org>
contract ForceEther { contract ForceEther {
function ForceEther(address target) payable {
// Selfdestruct transfers all Ether to the arget address function ForceEther() payable { }
selfdestruct(target);
function destroyAndSend(address _recipient) {
selfdestruct(_recipient);
} }
} }

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../../contracts/ownership/HasNoEther.sol"; import "../../contracts/ownership/HasNoEther.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import {Bounty, Target} from "../../contracts/Bounty.sol"; import {Bounty, Target} from "../../contracts/Bounty.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/LimitBalance.sol'; import '../../contracts/LimitBalance.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../../contracts/MultisigWallet.sol"; import "../../contracts/MultisigWallet.sol";
contract MultisigWalletMock is MultisigWallet { contract MultisigWalletMock is MultisigWallet {

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/lifecycle/Pausable.sol'; import '../../contracts/lifecycle/Pausable.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/token/PausableToken.sol'; import '../../contracts/token/PausableToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/payment/PullPayment.sol'; import '../../contracts/payment/PullPayment.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
contract ReentrancyAttack { contract ReentrancyAttack {

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/ReentrancyGuard.sol'; import '../../contracts/ReentrancyGuard.sol';
import './ReentrancyAttack.sol'; import './ReentrancyAttack.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/SafeMath.sol'; import '../../contracts/SafeMath.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import {Bounty, Target} from "../../contracts/Bounty.sol"; import {Bounty, Target} from "../../contracts/Bounty.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import "../../contracts/ownership/Shareable.sol"; import "../../contracts/ownership/Shareable.sol";
contract ShareableMock is Shareable { contract ShareableMock is Shareable {

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/token/StandardToken.sol'; import '../../contracts/token/StandardToken.sol';

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.8; pragma solidity ^0.4.11;
import '../../contracts/token/VestedToken.sol'; import '../../contracts/token/VestedToken.sol';

View File

@ -1,3 +1,3 @@
module.exports = function(error) { module.exports = function(error) {
assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP error must be returned'); assert.isAbove(error.message.search('invalid opcode'), -1, 'Invalid opcode error must be returned');
} }

View File

@ -4,14 +4,14 @@ export default async promise => {
} catch (error) { } catch (error) {
// TODO: Check jump destination to destinguish between a throw // TODO: Check jump destination to destinguish between a throw
// and an actual invalid jump. // and an actual invalid jump.
const invalidJump = error.message.search('invalid JUMP') >= 0; const invalidOpcode = error.message.search('invalid opcode') >= 0;
// TODO: When we contract A calls contract B, and B throws, instead // TODO: When we contract A calls contract B, and B throws, instead
// of an 'invalid jump', we get an 'out of gas' error. How do // of an 'invalid jump', we get an 'out of gas' error. How do
// we distinguish this from an actual out of gas event? (The // we distinguish this from an actual out of gas event? (The
// testrpc log actually show an 'invalid jump' event.) // testrpc log actually show an 'invalid jump' event.)
const outOfGas = error.message.search('out of gas') >= 0; const outOfGas = error.message.search('out of gas') >= 0;
assert( assert(
invalidJump || outOfGas, invalidOpcode || outOfGas,
"Expected throw, got '" + error + "' instead", "Expected throw, got '" + error + "' instead",
); );
return; return;