fix circular dependency with MiniMeToken -

This commit is contained in:
Jonathan Rainville 2019-04-08 16:34:04 -04:00
parent df2bbab7a0
commit 92e0c8282a
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
6 changed files with 46 additions and 33 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ config/production/password
config/livenet/password
chains.json
embarkArtifacts/
.idea

View File

@ -6,7 +6,7 @@ The Status Meritocracy allows `Contributors` to show their appreciation of other
The Status Meritocracy is a SNT Reward System that allows a `Contributor` in the registry to award allocated SNT, along with praise, to other `Contributors`.
The DApp will also display a leaderboard of `Contributors` who have been awarded the most and have partcipated the most in the Meritocracy, along with their praise
The DApp will also display a leaderboard of `Contributors` who have been awarded the most and have participated the most in the Meritocracy, along with their praise
### Goals
- Allow `Contributors` to build social capital, ideally in the form of Merit (degrades to popularity?)

View File

@ -1,7 +1,6 @@
/*global web3*/
import React from 'react';
import ReactDOM from 'react-dom';
import {Button, Grid, Row, Col, Alert } from 'react-bootstrap';
import * as NumericInput from 'react-numeric-input';
import Select from 'react-select';
@ -69,7 +68,7 @@ class App extends React.Component {
this.setState({ error: 'Please connect to Mainnet' });
return;
}
this.setState({busy: false});
options = options.map(prepareOptions);
@ -86,7 +85,7 @@ class App extends React.Component {
handleAwardChange(_amount) {
const { currentContributor: {allocation}, selectedContributors} = this.state;
const maxAllocation = allocation / selectedContributors.length;
const award = (_amount <= maxAllocation ? _amount : maxAllocation );
this.setState({award});
@ -137,7 +136,7 @@ class App extends React.Component {
const contributorList = options.filter(x => registry.includes(x.value) && x.value !== web3.eth.defaultAccount);
this.setState({contributorList});
}
async awardTokens(e) {
const {award, selectedContributors, praise} = this.state;
@ -200,7 +199,7 @@ class App extends React.Component {
const estimatedGas = await toSend.estimateGas({from: web3.eth.defaultAccount});
const receipt = await toSend.send({from: web3.eth.defaultAccount, gas: estimatedGas + 1000});
this.getCurrentContributorData();
} catch(e) {
this.setState({errorMsg: 'tx failed? Did you allocate all your tokens first?'});
@ -212,7 +211,7 @@ class App extends React.Component {
render() {
const { selectedContributors, contributorList, award, currentContributor, praise, busy, error, errorMsg } = this.state;
if (error) {
return (<div>
<div>Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:</div>
@ -224,7 +223,7 @@ class App extends React.Component {
return (<div>
<h3>Status Meritocracy</h3>
{errorMsg && <Alert bsStyle="danger">{errorMsg}</Alert>}
{currentContributor.name && <h2>Hello, {currentContributor.name} !</h2>}
@ -261,7 +260,7 @@ class App extends React.Component {
})}
</Row>
</Grid>
</div>);
}
}

View File

@ -30,7 +30,7 @@ import "../common/Controlled.sol";
import "./TokenController.sol";
import "./ApproveAndCallFallBack.sol";
import "./MiniMeTokenInterface.sol";
import "./MiniMeTokenFactory.sol";
import "./TokenFactory.sol";
/**
* @dev The actual token contract, the default controller is the msg.sender
@ -84,13 +84,13 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
bool public transfersEnabled;
// The factory used to create new clone tokens
MiniMeTokenFactory public tokenFactory;
TokenFactory public tokenFactory;
////////////////
// Constructor
////////////////
/**
/**
* @notice Constructor to create a MiniMeToken
* @param _tokenFactory The address of the MiniMeTokenFactory contract that
* will create the Clone token contracts, the token factory needs to be
@ -113,10 +113,10 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
uint8 _decimalUnits,
string memory _tokenSymbol,
bool _transfersEnabled
)
)
public
{
tokenFactory = MiniMeTokenFactory(_tokenFactory);
tokenFactory = TokenFactory(_tokenFactory);
name = _tokenName; // Set the name
decimals = _decimalUnits; // Set the decimals
symbol = _tokenSymbol; // Set the symbol
@ -154,8 +154,8 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
address _from,
address _to,
uint256 _amount
)
public
)
public
returns (bool success)
{
@ -167,7 +167,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
require(transfersEnabled);
// The standard ERC 20 transferFrom functionality
if (allowed[_from][msg.sender] < _amount) {
if (allowed[_from][msg.sender] < _amount) {
return false;
}
allowed[_from][msg.sender] -= _amount;
@ -187,7 +187,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
address _from,
address _to,
uint _amount
)
)
internal
returns(bool)
{
@ -234,7 +234,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
address _spender,
uint256 _amount
)
internal
internal
returns (bool)
{
require(transfersEnabled);
@ -285,7 +285,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
function allowance(
address _owner,
address _spender
)
)
external
view
returns (uint256 remaining)
@ -305,7 +305,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
address _spender,
uint256 _amount,
bytes memory _extraData
)
)
public
returns (bool success)
{
@ -343,10 +343,10 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
function balanceOfAt(
address _owner,
uint _blockNumber
)
)
public
view
returns (uint)
returns (uint)
{
// These next few lines are used when the balance of the token is
@ -417,7 +417,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
string memory _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
)
)
public
returns(address)
{
@ -425,14 +425,14 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
if (snapshotBlock == 0) {
snapshotBlock = block.number;
}
MiniMeToken cloneToken = tokenFactory.createCloneToken(
MiniMeToken cloneToken = MiniMeToken(tokenFactory.createCloneToken(
address(this),
snapshotBlock,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
));
cloneToken.changeController(msg.sender);
@ -444,7 +444,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
////////////////
// Generate and destroy tokens
////////////////
/**
* @notice Generates `_amount` tokens that are assigned to `_owner`
* @param _owner The address that will be assigned the new tokens
@ -478,7 +478,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
function destroyTokens(
address _owner,
uint _amount
)
)
public
onlyController
returns (bool)
@ -518,7 +518,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
function getValueAt(
Checkpoint[] storage checkpoints,
uint _block
)
)
internal
view
returns (uint)
@ -576,7 +576,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
uint size;
if (_addr == address(0)){
return false;
}
}
assembly {
size := extcodesize(_addr)
}

View File

@ -1,5 +1,6 @@
pragma solidity ^0.5.0;
import "./TokenFactory.sol";
import "./MiniMeToken.sol";
////////////////
@ -11,7 +12,7 @@ import "./MiniMeToken.sol";
* In solidity this is the way to create a contract from a contract of the
* same class
*/
contract MiniMeTokenFactory {
contract MiniMeTokenFactory is TokenFactory {
/**
* @notice Update the DApp by creating a new token with new functionalities
@ -32,7 +33,7 @@ contract MiniMeTokenFactory {
uint8 _decimalUnits,
string memory _tokenSymbol,
bool _transfersEnabled
) public returns (MiniMeToken) {
) public returns (address payable) {
MiniMeToken newToken = new MiniMeToken(
address(this),
_parentToken,
@ -44,6 +45,6 @@ contract MiniMeTokenFactory {
);
newToken.changeController(msg.sender);
return newToken;
return address(newToken);
}
}

View File

@ -0,0 +1,12 @@
pragma solidity ^0.5.0;
contract TokenFactory {
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string memory _tokenName,
uint8 _decimalUnits,
string memory _tokenSymbol,
bool _transfersEnabled
) public returns (address payable);
}