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

ST' needs payable Initialize() to accept all base tokens #7

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Changes from all 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
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I felt it should not be exposed / considered for ST' to ever be un-initialised; if ST' is not yet initialised the utility chain is not even worth considering for adding as a Core

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK


/*
* 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