Commit 35363c01 by Manuel Araoz

improve docs of base contracts

parent 47d979aa
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
import './Ownable.sol'; import './Ownable.sol';
/* /*
* Claimable * Claimable
* Extension for the Ownable contract, where the ownership needs to be claimed *
* Extension for the Ownable contract, where the ownership needs to be claimed. This allows the new owner to accept the transfer.
*/ */
contract Claimable is Ownable { contract Claimable is Ownable {
address public pendingOwner; address public pendingOwner;
......
...@@ -3,7 +3,7 @@ import "./Ownable.sol"; ...@@ -3,7 +3,7 @@ import "./Ownable.sol";
/* /*
* Killable * Killable
* Base contract that can be killed by owner * Base contract that can be killed by owner. All funds in contract will be sent to the owner.
*/ */
contract Killable is Ownable { contract Killable is Ownable {
function kill() onlyOwner { function kill() onlyOwner {
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
/* /*
* Ownable * Ownable
* Base contract with an owner *
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/ */
contract Ownable { contract Ownable {
address public owner; address public owner;
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
/* /*
* PullPayment * PullPayment
* Base contract supporting async send for pull payments. * Base contract supporting async send for pull payments.
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
/** /**
* Math operations with safety checks * Math operations with safety checks
*/ */
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
import "./Ownable.sol"; import "./Ownable.sol";
/* /*
* Stoppable * Stoppable
* Abstract contract that allows children to implement an * Abstract contract that allows children to implement an
...@@ -12,10 +15,12 @@ contract Stoppable is Ownable { ...@@ -12,10 +15,12 @@ contract Stoppable is Ownable {
modifier stopInEmergency { if (!stopped) _; } modifier stopInEmergency { if (!stopped) _; }
modifier onlyInEmergency { if (stopped) _; } modifier onlyInEmergency { if (stopped) _; }
// called by the owner on emergency, triggers stopped state
function emergencyStop() external onlyOwner { function emergencyStop() external onlyOwner {
stopped = true; stopped = true;
} }
// called by the owner on end of emergency, returns to normal state
function release() external onlyOwner onlyInEmergency { function release() external onlyOwner onlyInEmergency {
stopped = false; stopped = false;
} }
......
pragma solidity ^0.4.4;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Ownable.sol";
contract TestOwnable {
Ownable ownable = new Ownable();
function testHasOwner() {
Assert.isNotZero(ownable.owner(), "Ownable should have an owner upon creation.");
}
function testChangesOwner() {
address originalOwner = ownable.owner();
ownable.transfer(0x0);
Assert.notEqual(originalOwner, ownable.owner(), "Ownable should change owners after transfer.");
}
function testOnlyOwnerCanChangeOwner() {
Ownable deployedOwnable = Ownable(DeployedAddresses.Ownable());
address originalOwner = deployedOwnable.owner();
deployedOwnable.transfer(0x0);
Assert.equal(originalOwner, deployedOwnable.owner(), "Ownable should prevent non-owners from transfering");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment