diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index 73e9fe07d..621d33c11 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.8; import './payment/PullPayment.sol'; -import './lifecycle/Killable.sol'; +import './lifecycle/Destructible.sol'; /* @@ -10,7 +10,7 @@ import './lifecycle/Killable.sol'; * * This bounty will pay out to a researcher if they break invariant logic of the contract. */ -contract Bounty is PullPayment, Killable { +contract Bounty is PullPayment, Destructible { bool public claimed; mapping(address => address) public researchers; diff --git a/contracts/MultisigWallet.sol b/contracts/MultisigWallet.sol index f9249218d..4c26241c1 100644 --- a/contracts/MultisigWallet.sol +++ b/contracts/MultisigWallet.sol @@ -24,8 +24,8 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { Shareable(_owners, _required) DayLimit(_daylimit) { } - // kills the contract sending everything to `_to`. - function kill(address _to) onlymanyowners(keccak256(msg.data)) external { + // destroys the contract sending everything to `_to`. + function destroy(address _to) onlymanyowners(keccak256(msg.data)) external { selfdestruct(_to); } diff --git a/contracts/lifecycle/Destructible.sol b/contracts/lifecycle/Destructible.sol new file mode 100644 index 000000000..21de1869d --- /dev/null +++ b/contracts/lifecycle/Destructible.sol @@ -0,0 +1,15 @@ +pragma solidity ^0.4.8; + + +import "../ownership/Ownable.sol"; + + +/* + * Destructible + * Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. + */ +contract Destructible is Ownable { + function destroy() onlyOwner { + selfdestruct(owner); + } +} diff --git a/contracts/lifecycle/Killable.sol b/contracts/lifecycle/Killable.sol deleted file mode 100644 index 0a1367df8..000000000 --- a/contracts/lifecycle/Killable.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma solidity ^0.4.8; - - -import "../ownership/Ownable.sol"; - - -/* - * Killable - * Base contract that can be killed by owner. All funds in contract will be sent to the owner. - */ -contract Killable is Ownable { - function kill() onlyOwner { - selfdestruct(owner); - } -} diff --git a/contracts/lifecycle/TokenKillable.sol b/contracts/lifecycle/TokenDestructible.sol similarity index 79% rename from contracts/lifecycle/TokenKillable.sol rename to contracts/lifecycle/TokenDestructible.sol index e0dfbfe71..69c686ff8 100644 --- a/contracts/lifecycle/TokenKillable.sol +++ b/contracts/lifecycle/TokenDestructible.sol @@ -4,18 +4,18 @@ pragma solidity ^0.4.8; import "../ownership/Ownable.sol"; import "../token/ERC20Basic.sol"; -/// @title TokenKillable: +/// @title TokenDestructible: /// @author Remco Bloemen -///.Base contract that can be killed by owner. All funds in contract including +///.Base contract that can be destroyed by owner. All funds in contract including /// listed tokens will be sent to the owner -contract TokenKillable is Ownable { +contract TokenDestructible is Ownable { /// @notice Terminate contract and refund to owner /// @param tokens List of addresses of ERC20 or ERC20Basic token contracts to // refund /// @notice The called token contracts could try to re-enter this contract. // Only supply token contracts you - function kill(address[] tokens) onlyOwner { + function destroy(address[] tokens) onlyOwner { // Transfer tokens to owner for(uint i = 0; i < tokens.length; i++) { diff --git a/docs/source/bounty.rst b/docs/source/bounty.rst index 1bc2173fc..d82707eca 100644 --- a/docs/source/bounty.rst +++ b/docs/source/bounty.rst @@ -55,6 +55,6 @@ If researchers break the contract, they can claim their reward. For each researcher who wants to hack the contract and claims the reward, refer to our `Test `_ for the detail. -Finally, if you manage to protect your contract from security researchers, you can reclaim the bounty funds. To end the bounty, kill the contract so that all the rewards go back to the owner.:: +Finally, if you manage to protect your contract from security researchers, you can reclaim the bounty funds. To end the bounty, destroy the contract so that all the rewards go back to the owner.:: - bounty.kill(); + bounty.destroy(); diff --git a/docs/source/index.rst b/docs/source/index.rst index 42ff0bda6..aaa9b98fb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -27,7 +27,7 @@ The code is open-source, and `available on github initBalance); + }); + +}); diff --git a/test/Killable.js b/test/Killable.js deleted file mode 100644 index 6480bd116..000000000 --- a/test/Killable.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var Killable = artifacts.require('../contracts/lifecycle/Killable.sol'); -require('./helpers/transactionMined.js'); - -contract('Killable', function(accounts) { - - it('should send balance to owner after death', async function() { - let killable = await Killable.new({from: accounts[0], value: web3.toWei('10','ether')}); - let owner = await killable.owner(); - let initBalance = web3.eth.getBalance(owner); - await killable.kill({from: owner}); - let newBalance = web3.eth.getBalance(owner); - - assert.isTrue(newBalance > initBalance); - }); - -}); diff --git a/test/MultisigWallet.js b/test/MultisigWallet.js index f750dca13..9c78ee114 100644 --- a/test/MultisigWallet.js +++ b/test/MultisigWallet.js @@ -22,11 +22,11 @@ contract('MultisigWallet', function(accounts) { let walletBalance = web3.eth.getBalance(wallet.address); let hash = 1234; - //Call kill function from two different owner accounts, satisfying owners required - await wallet.kill(accounts[0], {data: hash}); - let txnHash = await wallet.kill(accounts[0], {from: accounts[1], data: hash}); + //Call destroy function from two different owner accounts, satisfying owners required + await wallet.destroy(accounts[0], {data: hash}); + let txnHash = await wallet.destroy(accounts[0], {from: accounts[1], data: hash}); - //Get balances of owner and wallet after kill function is complete, compare with previous values + //Get balances of owner and wallet after destroy function is complete, compare with previous values let newOwnerBalance = web3.eth.getBalance(accounts[0]); let newWalletBalance = web3.eth.getBalance(wallet.address); diff --git a/test/TokenDestructible.js b/test/TokenDestructible.js new file mode 100644 index 000000000..1f943e3df --- /dev/null +++ b/test/TokenDestructible.js @@ -0,0 +1,32 @@ +'use strict'; + +var TokenDestructible = artifacts.require('../contracts/lifecycle/TokenDestructible.sol'); +var StandardTokenMock = artifacts.require("./helpers/StandardTokenMock.sol"); +require('./helpers/transactionMined.js'); + +contract('TokenDestructible', function(accounts) { + + it('should send balance to owner after destruction', async function() { + let destructible = await TokenDestructible.new({from: accounts[0], value: web3.toWei('10','ether')}); + let owner = await destructible.owner(); + let initBalance = web3.eth.getBalance(owner); + await destructible.destroy([], {from: owner}); + let newBalance = web3.eth.getBalance(owner); + assert.isTrue(newBalance > initBalance); + }); + + it('should send tokens to owner after destruction', async function() { + let destructible = await TokenDestructible.new({from: accounts[0], value: web3.toWei('10','ether')}); + let owner = await destructible.owner(); + let token = await StandardTokenMock.new(destructible.address, 100); + let initContractBalance = await token.balanceOf(destructible.address); + let initOwnerBalance = await token.balanceOf(owner); + assert.equal(initContractBalance, 100); + assert.equal(initOwnerBalance, 0); + await destructible.destroy([token.address], {from: owner}); + let newContractBalance = await token.balanceOf(destructible.address); + let newOwnerBalance = await token.balanceOf(owner); + assert.equal(newContractBalance, 0); + assert.equal(newOwnerBalance, 100); + }); +}); diff --git a/test/TokenKillable.js b/test/TokenKillable.js deleted file mode 100644 index 88b06c1b0..000000000 --- a/test/TokenKillable.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -var TokenKillable = artifacts.require('../contracts/lifecycle/TokenKillable.sol'); -var StandardTokenMock = artifacts.require("./helpers/StandardTokenMock.sol"); -require('./helpers/transactionMined.js'); - -contract('TokenKillable', function(accounts) { - - it('should send balance to owner after death', async function() { - let killable = await TokenKillable.new({from: accounts[0], value: web3.toWei('10','ether')}); - let owner = await killable.owner(); - let initBalance = web3.eth.getBalance(owner); - await killable.kill([], {from: owner}); - let newBalance = web3.eth.getBalance(owner); - assert.isTrue(newBalance > initBalance); - }); - - it('should send tokens to owner after death', async function() { - let killable = await TokenKillable.new({from: accounts[0], value: web3.toWei('10','ether')}); - let owner = await killable.owner(); - let token = await StandardTokenMock.new(killable.address, 100); - let initContractBalance = await token.balanceOf(killable.address); - let initOwnerBalance = await token.balanceOf(owner); - assert.equal(initContractBalance, 100); - assert.equal(initOwnerBalance, 0); - await killable.kill([token.address], {from: owner}); - let newContractBalance = await token.balanceOf(killable.address); - let newOwnerBalance = await token.balanceOf(owner); - assert.equal(newContractBalance, 0); - assert.equal(newOwnerBalance, 100); - }); -});