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 20 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
5 changes: 2 additions & 3 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 @@ -26,9 +25,9 @@ contract CoGatewayUtilityTokenInterface {
/**
* @notice Get the utility token address.
*
* @return address of utility token.
* @return utilityToken_ Address of utility token.
*/
function utilityToken()
public
returns (address);
returns (address utilityToken_);
deepesh-kn marked this conversation as resolved.
Show resolved Hide resolved
}
47 changes: 27 additions & 20 deletions contracts/gateway/EIP20CoGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,12 @@ contract EIP20CoGateway is GatewayBase {
* @notice This is internal method for process minting contains common logic.
*
* @param _messageHash Message hash.
* @param _initialGas initial gas during progress process.
* @param _initialGas Initial gas during progress process.
*
* @param _proofProgress true if progress with proof, false if progress
* @param _proofProgress `true` if progress with proof, false if progress
* with hashlock.
* @param _unlockSecret unlock secret to progress, zero in case of progress
* with proof
* @param _unlockSecret Unlock secret to progress, zero in case of progress
* with proof.
*
* @return beneficiary_ Address to which the utility tokens will be
* transferred after minting.
Expand All @@ -1075,7 +1075,7 @@ contract EIP20CoGateway is GatewayBase {
* is given to the facilitator.
* @return mintedAmount_ Actual minted amount, after deducting the reward
* from the total amount.
* @return rewardAmount_ Reward amount that is transferred to facilitator
* @return rewardAmount_ Reward amount that is transferred to facilitator.
*/

function progressMintInternal(
Expand Down Expand Up @@ -1109,16 +1109,22 @@ contract EIP20CoGateway is GatewayBase {

mintedAmount_ = stakeAmount_.sub(rewardAmount_);

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

//reward beneficiary with the reward amount
UtilityTokenInterface(utilityToken).mint(msg.sender, rewardAmount_);
// Reward beneficiary with the reward amount.
UtilityTokenInterface(utilityToken).increaseSupply(
msg.sender,
rewardAmount_
);

// delete the mint data
// Delete the mint data.
delete mints[_messageHash];

// Emit MintProgressed event
// Emit MintProgressed event.
emit MintProgressed(
_messageHash,
message.sender,
Expand All @@ -1136,13 +1142,13 @@ contract EIP20CoGateway is GatewayBase {
* @notice Internal method to progressRedeemInternal.
*
* @param _messageHash Message hash.
* @param _proofProgress true if progress with proof, false if progress
* @param _proofProgress True if progress with proof, false if progress
* with hashlock.
* @param _unlockSecret unlock secret to progress, zero in case of progress
* with proof
* @param _unlockSecret Unlock secret to progress, zero in case of progress
* with proof.
*
* @return redeemer_ Redeemer address
* @return redeemAmount_ Redeem amount
* @return redeemer_ Redeemer address.
* @return redeemAmount_ Redeem amount.
*/
function progressRedeemInternal(
bytes32 _messageHash,
Expand All @@ -1159,13 +1165,14 @@ contract EIP20CoGateway is GatewayBase {

redeemer_ = message.sender;
redeemAmount_ = redeems[_messageHash].amount;
// Burn the redeem amount.
UtilityTokenInterface(utilityToken).burn(redeemAmount_);

// Transfer the bounty amount to the facilitator
// Decrease the token supply.
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);

// delete the redeem data
// Delete the redeem data.
delete redeems[_messageHash];

// Emit RedeemProgressed event.
Expand Down
60 changes: 57 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,53 @@ 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.
*
* @dev The parameters _account and _amount should not be zero. This check
* is added in function increaseSupplyInternal.
*
* @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.
*
* @dev The parameters _amount should not be zero. This check is added in
* function decreaseSupplyInternal.
*
* @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