Skip to content

Commit

Permalink
contracts: payable STP.initialize(); modifier onlyInitialized for cla…
Browse files Browse the repository at this point in the history
…im, mint, burn
  • Loading branch information
benjaminbollen authored and jasonklein committed Nov 24, 2017
1 parent 8b2a550 commit 33fe779
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions contracts/STPrime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ import "./STPrimeConfig.sol";
contract STPrime is UtilityTokenAbstract, STPrimeConfig {
using SafeMath for uint256;


/*
* Storage
*/
/// set when ST' has received TOKENS_MAX tokens;
/// when uninitialised minting is not allowed
bool private initialized;

/*
* Modifiers
*/
modifier onlyInitialized() {
require(initialized);
_;
}

/*
* Public functions
*/
Expand All @@ -55,6 +71,21 @@ contract STPrime is UtilityTokenAbstract, STPrimeConfig {

}

/// On setup of the utility chain the base tokens need to be transfered
/// in full to STPrime for the base tokens to be minted as ST'
function initialize()
public
payable
{
// @dev before the registrar registers a core on the value chain
// it must verify that the genesis exactly specified TOKENS_MAX
// so that all base tokens are held by STPrime
require(msg.value == TOKENS_MAX);
require(msg.sender.balance == 0);
initialized = true;
}


/// @dev transfer full claim to beneficiary
/// claim can be called publicly as the beneficiary
/// and amount are set, and this allows for reduced
Expand All @@ -66,6 +97,7 @@ contract STPrime is UtilityTokenAbstract, STPrimeConfig {
function claim(
address _beneficiary)
public
onlyInitialized
returns (bool /* success */)
{
uint256 amount = claimInternal(_beneficiary);
Expand All @@ -87,6 +119,7 @@ contract STPrime is UtilityTokenAbstract, STPrimeConfig {
uint256 _amount)
public
onlyProtocol
onlyInitialized
returns (bool /* success */)
{
// add the minted amount to the beneficiary's claim
Expand All @@ -100,6 +133,7 @@ contract STPrime is UtilityTokenAbstract, STPrimeConfig {
uint256 _amount)
public
onlyProtocol
onlyInitialized
payable
returns (bool /* success */)
{
Expand Down

0 comments on commit 33fe779

Please sign in to comment.