Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #26 from OpenSTFoundation/develop
Browse files Browse the repository at this point in the history
Merge develop into master (not a release)
  • Loading branch information
jasonklein authored Feb 2, 2018
2 parents 286e415 + c7205ec commit 9570c08
Show file tree
Hide file tree
Showing 11 changed files with 1,250 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_install:
install:
- npm install
before_script:
- nohup ./tools/runTestRpc.sh </dev/null >/dev/null 2>&1 &
- nohup sh tools/runTestRpc.sh </dev/null >/dev/null 2>&1 &
script:
- truffle test
after_script:
Expand Down
84 changes: 84 additions & 0 deletions contracts/EIP20TokenMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* solhint-disable-next-line compiler-fixed */
pragma solidity ^0.4.17;

// Copyright 2018 OpenST Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------------------------------------------------------
// Utility chain: EIP20TokenMock
//
// http://www.simpletoken.org/
//
// ----------------------------------------------------------------------------


import "./openst-protocol/EIP20Token.sol";


/// @title EIP20TokenMock - Provides EIP20Token with mock functionality to facilitate testing payments
contract EIP20TokenMock is EIP20Token {
uint256 public conversionRate;

/// @dev Takes _conversionRate, _symbol, _name, _decimals
/// @param _conversionRate conversionRate
/// @param _symbol symbol
/// @param _name name
/// @param _decimals decimals
function EIP20TokenMock(
uint256 _conversionRate,
string _symbol,
string _name,
uint8 _decimals)
/* solhint-disable-next-line visibility-modifier-order */
EIP20Token(_symbol, _name, _decimals)
public
{
conversionRate = _conversionRate;
}

/// @dev Returns 0 as mock total supply
function totalSupply()
public
view
returns (uint256 /* mock total supply */)
{
return 0;
}

/// @dev Takes _owner, _value; sets balance of _owner to _value
/// @param _owner owner
/// @param _value value
/// @return bool success
function setBalance(
address _owner,
uint256 _value)
public
returns (bool /* success */)
{
balances[_owner] = _value;
return true;
}

/// @dev Takes _conversionRate; sets conversionRate to _conversionRate
/// @param _conversionRate conversionRate
/// @return bool success
function setConverionRate(
uint256 _conversionRate)
public
returns (bool /* success */)
{
conversionRate = _conversionRate;
return true;
}
}
112 changes: 112 additions & 0 deletions contracts/OpsManaged.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
pragma solidity ^0.4.17;

// Copyright 2017 OpenST Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------------------------------------------------------
// Common: Admin / Ops Permission Model
//
// http://www.simpletoken.org/
//
// ----------------------------------------------------------------------------

import "./Owned.sol";

/**
@title OpsManaged
@notice Implements OpenST ownership and permission model
*/
contract OpsManaged is Owned {

address public opsAddress;
address public adminAddress;

event AdminAddressChanged(address indexed _newAddress);
event OpsAddressChanged(address indexed _newAddress);


function OpsManaged() public
Owned()
{
}


modifier onlyAdmin() {
require(isAdmin(msg.sender));
_;
}


modifier onlyAdminOrOps() {
require(isAdmin(msg.sender) || isOps(msg.sender));
_;
}


modifier onlyOwnerOrAdmin() {
require(isOwner(msg.sender) || isAdmin(msg.sender));
_;
}


modifier onlyOps() {
require(isOps(msg.sender));
_;
}


function isAdmin(address _address) internal view returns (bool) {
return (adminAddress != address(0) && _address == adminAddress);
}


function isOps(address _address) internal view returns (bool) {
return (opsAddress != address(0) && _address == opsAddress);
}


function isOwnerOrOps(address _address) internal view returns (bool) {
return (isOwner(_address) || isOps(_address));
}


// Owner and Admin can change the admin address. Address can also be set to 0 to 'disable' it.
function setAdminAddress(address _adminAddress) external onlyOwnerOrAdmin returns (bool) {
require(_adminAddress != owner);
require(_adminAddress != address(this));
require(!isOps(_adminAddress));

adminAddress = _adminAddress;

AdminAddressChanged(_adminAddress);

return true;
}


// Owner and Admin can change the operations address. Address can also be set to 0 to 'disable' it.
function setOpsAddress(address _opsAddress) external onlyOwnerOrAdmin returns (bool) {
require(_opsAddress != owner);
require(_opsAddress != address(this));
require(!isAdmin(_opsAddress));

opsAddress = _opsAddress;

OpsAddressChanged(_opsAddress);

return true;
}
}


74 changes: 74 additions & 0 deletions contracts/Owned.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
pragma solidity ^0.4.17;

// Copyright 2017 OpenST Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------------------------------------------------------
// Common: Basic Ownership Implementation
//
// http://www.simpletoken.org/
//
// ----------------------------------------------------------------------------

/**
@title Owned
@notice Implements basic ownership with 2-step transfers
*/
contract Owned {

address public owner;
address public proposedOwner;

event OwnershipTransferInitiated(address indexed _proposedOwner);
event OwnershipTransferCompleted(address indexed _newOwner);


function Owned() public {
owner = msg.sender;
}


modifier onlyOwner() {
require(isOwner(msg.sender));
_;
}


function isOwner(address _address) internal view returns (bool) {
return (_address == owner);
}


function initiateOwnershipTransfer(address _proposedOwner) public onlyOwner returns (bool) {
proposedOwner = _proposedOwner;

OwnershipTransferInitiated(_proposedOwner);

return true;
}


function completeOwnershipTransfer() public returns (bool) {
require(msg.sender == proposedOwner);

owner = proposedOwner;
proposedOwner = address(0);

OwnershipTransferCompleted(owner);

return true;
}
}


Loading

0 comments on commit 9570c08

Please sign in to comment.