Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up of UtilityToken and UtilityTokenInterface. #540

Merged
merged 21 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contracts/gateway/CoGatewayUtilityTokenInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pragma solidity ^0.5.0;
// limitations under the License.
//
// ----------------------------------------------------------------------------
// Auxiliary Chain: CoGatewayUtilityTokenInterface
//
// http://www.simpletoken.org/
//
Expand All @@ -30,5 +29,5 @@ contract CoGatewayUtilityTokenInterface {
*/
function utilityToken()
public
returns (address);
returns (address utilityToken_);
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 3 additions & 3 deletions contracts/gateway/EIP20CoGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,10 @@ contract EIP20CoGateway is GatewayBase {
mintedAmount_ = stakeAmount_.sub(rewardAmount_);

//Mint token after subtracting reward amount
UtilityTokenInterface(utilityToken).mint(beneficiary_, mintedAmount_);
UtilityTokenInterface(utilityToken).increaseSupply(beneficiary_, mintedAmount_);

//reward beneficiary with the reward amount
UtilityTokenInterface(utilityToken).mint(msg.sender, rewardAmount_);
UtilityTokenInterface(utilityToken).increaseSupply(msg.sender, rewardAmount_);
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved

// delete the mint data
delete mints[_messageHash];
Expand Down Expand Up @@ -1160,7 +1160,7 @@ contract EIP20CoGateway is GatewayBase {
redeemer_ = message.sender;
redeemAmount_ = redeems[_messageHash].amount;
// Burn the redeem amount.
UtilityTokenInterface(utilityToken).burn(redeemAmount_);
UtilityTokenInterface(utilityToken).decreaseSupply(redeemAmount_);
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved

// Transfer the bounty amount to the facilitator
msg.sender.transfer(redeems[_messageHash].bounty);
Expand Down
54 changes: 51 additions & 3 deletions contracts/gateway/OSTPrime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pragma solidity ^0.5.0;
import "../lib/SafeMath.sol";
import "./UtilityToken.sol";
import "./OSTPrimeConfig.sol";

import "../lib/IsMemberInterface.sol";

/**
* @title OSTPrime contract implements UtilityToken and
Expand Down Expand Up @@ -92,14 +92,19 @@ contract OSTPrime is UtilityToken, OSTPrimeConfig {
* @dev This contract should be deployed with zero gas.
*
* @param _valueToken ERC20 token address in origin chain.
* @param _membersManager Address of a contract that manages organization.
*/
constructor(address _valueToken)
constructor(
EIP20Interface _valueToken,
IsMemberInterface _membersManager
)
public
UtilityToken(
_valueToken,
TOKEN_SYMBOL,
TOKEN_NAME,
TOKEN_DECIMALS,
_valueToken
_membersManager
)
{}

Expand Down Expand Up @@ -212,4 +217,47 @@ contract OSTPrime is UtilityToken, OSTPrimeConfig {
success_ = true;
}

/**
* @notice Adds number of OST Prime tokens to account balance and increases
* the total token supply. Can be called only when contract is
* initialized and only by CoGateway address.
*
* @param _account Account address for which the OST Prime balance will be
* increased.
* @param _amount Amount of tokens.
*
* @return success_ `true` if increase supply is successful, false otherwise.
*/
function increaseSupply(
address _account,
uint256 _amount
)
external
onlyInitialized
onlyCoGateway
returns (bool success_)
{
success_ = increaseSupplyInternal(_account, _amount);
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @notice Decreases the OST Prime token balance from the msg.sender
* address and decreases the total token supply count. Can be
* called only when contract is initialized and only by CoGateway
* address.
*
* @param _amount Amount of tokens.
*
* @return success_ `true` if decrease supply is successful, false otherwise.
*/
function decreaseSupply(
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved
uint256 _amount
)
external
onlyInitialized
onlyCoGateway
returns (bool success_)
{
success_ = decreaseSupplyInternal(_amount);
}
}
Loading