improve docs of base contracts

pull/87/head
Manuel Araoz 8 years ago
parent 47d979aa72
commit 35363c01b1
  1. 8
      contracts/Claimable.sol
  2. 2
      contracts/Killable.sol
  3. 5
      contracts/Ownable.sol
  4. 2
      contracts/PullPayment.sol
  5. 1
      contracts/SafeMath.sol
  6. 5
      contracts/Stoppable.sol
  7. 25
      test/TestOwnable.sol

@ -1,11 +1,15 @@
pragma solidity ^0.4.0;
import './Ownable.sol';
/*
* 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 {
address public pendingOwner;

@ -3,7 +3,7 @@ import "./Ownable.sol";
/*
* 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 {
function kill() onlyOwner {

@ -1,8 +1,11 @@
pragma solidity ^0.4.4;
/*
* 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 {
address public owner;

@ -1,4 +1,6 @@
pragma solidity ^0.4.4;
/*
* PullPayment
* Base contract supporting async send for pull payments.

@ -1,5 +1,6 @@
pragma solidity ^0.4.4;
/**
* Math operations with safety checks
*/

@ -1,6 +1,9 @@
pragma solidity ^0.4.4;
import "./Ownable.sol";
/*
* Stoppable
* Abstract contract that allows children to implement an
@ -12,10 +15,12 @@ contract Stoppable is Ownable {
modifier stopInEmergency { if (!stopped) _; }
modifier onlyInEmergency { if (stopped) _; }
// called by the owner on emergency, triggers stopped state
function emergencyStop() external onlyOwner {
stopped = true;
}
// called by the owner on end of emergency, returns to normal state
function release() external onlyOwner onlyInEmergency {
stopped = false;
}

@ -1,25 +0,0 @@
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");
}
}
Loading…
Cancel
Save