This repository has been archived by the owner on Feb 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from OpenSTFoundation/develop
Merge develop into master (not a release)
- Loading branch information
Showing
11 changed files
with
1,250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.