Merge pull request #8 from jrainville/fix/fixes
Fix to circular dep and tiny cleanup
This commit is contained in:
commit
5b9f5da50d
|
@ -5,3 +5,4 @@ config/production/password
|
||||||
config/livenet/password
|
config/livenet/password
|
||||||
chains.json
|
chains.json
|
||||||
embarkArtifacts/
|
embarkArtifacts/
|
||||||
|
.idea
|
||||||
|
|
|
@ -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 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
|
### Goals
|
||||||
- Allow `Contributors` to build social capital, ideally in the form of Merit (degrades to popularity?)
|
- Allow `Contributors` to build social capital, ideally in the form of Merit (degrades to popularity?)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*global web3*/
|
/*global web3*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import {Button, Grid, Row, Col, Alert } from 'react-bootstrap';
|
import {Button, Grid, Row, Col, Alert } from 'react-bootstrap';
|
||||||
import * as NumericInput from 'react-numeric-input';
|
import * as NumericInput from 'react-numeric-input';
|
||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const options = require("../app/js/contributors");
|
const options = require("../app/js/contributors");
|
||||||
|
|
||||||
function getContributors () {
|
function getContributors () {
|
||||||
var addresses = options.map(a => "'"+ a.value + "'");
|
var addresses = options.map(a => a.value);
|
||||||
if ( new Set(addresses).size !== addresses.length ) {
|
if ( new Set(addresses).size !== addresses.length ) {
|
||||||
throw 'duplicates in options';
|
throw 'duplicates in options';
|
||||||
}
|
}
|
||||||
|
@ -108,16 +108,46 @@ module.exports = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"afterDeploy": [
|
afterDeploy: async (deps) => {
|
||||||
// Give Tokens to Meritocracy Owner
|
try {
|
||||||
"SNT.methods.generateTokens('$accounts[0]', '1000000000000000000000').send()",
|
const {SNT, Meritocracy} = deps.contracts;
|
||||||
// Add All Contributors
|
|
||||||
"Meritocracy.methods.addContributors([" + getContributors().toString() + "]).send()",
|
|
||||||
// Allocate Owner Tokens
|
|
||||||
"SNT.methods.approve('$Meritocracy', '1000000000000000000000').send()",
|
|
||||||
"Meritocracy.methods.allocate('1000000000000000000000').send()",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
const addresses = await deps.web3.eth.getAccounts();
|
||||||
|
const mainAccount = addresses[0];
|
||||||
|
const balance = await SNT.methods.balanceOf(mainAccount).call();
|
||||||
|
if (balance !== '0') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const tokens = '1000000000000000000000';
|
||||||
|
|
||||||
|
console.log('Generating tokens for the main account...');
|
||||||
|
const generateTokens = SNT.methods.generateTokens(mainAccount, tokens);
|
||||||
|
let gas = await generateTokens.estimateGas({from: mainAccount});
|
||||||
|
await generateTokens.send({from: mainAccount, gas});
|
||||||
|
|
||||||
|
// Add All Contributors
|
||||||
|
console.log('Adding all tokens...');
|
||||||
|
const addContributors = Meritocracy.methods.addContributors(getContributors());
|
||||||
|
gas = await addContributors.estimateGas({from: mainAccount});
|
||||||
|
await addContributors.send({from: mainAccount, gas});
|
||||||
|
|
||||||
|
// Allocate Owner Tokens
|
||||||
|
console.log('Approving token transfer...');
|
||||||
|
const approve = SNT.methods.approve(Meritocracy.options.address, tokens);
|
||||||
|
gas = await approve.estimateGas({from: mainAccount});
|
||||||
|
await approve.send({from: mainAccount, gas});
|
||||||
|
|
||||||
|
console.log('Allocating tokens...');
|
||||||
|
const allocate = Meritocracy.methods.allocate(tokens);
|
||||||
|
gas = await allocate.estimateGas({from: mainAccount});
|
||||||
|
await allocate.send({from: mainAccount, gas});
|
||||||
|
|
||||||
|
console.log('All done!')
|
||||||
|
} catch (e) {
|
||||||
|
console.log("------- Error in after deploy ------- ");
|
||||||
|
console.dir(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// merges with the settings in default
|
// merges with the settings in default
|
||||||
|
|
|
@ -30,7 +30,7 @@ import "../common/Controlled.sol";
|
||||||
import "./TokenController.sol";
|
import "./TokenController.sol";
|
||||||
import "./ApproveAndCallFallBack.sol";
|
import "./ApproveAndCallFallBack.sol";
|
||||||
import "./MiniMeTokenInterface.sol";
|
import "./MiniMeTokenInterface.sol";
|
||||||
import "./MiniMeTokenFactory.sol";
|
import "./TokenFactory.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev The actual token contract, the default controller is the msg.sender
|
* @dev The actual token contract, the default controller is the msg.sender
|
||||||
|
@ -84,7 +84,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||||
bool public transfersEnabled;
|
bool public transfersEnabled;
|
||||||
|
|
||||||
// The factory used to create new clone tokens
|
// The factory used to create new clone tokens
|
||||||
MiniMeTokenFactory public tokenFactory;
|
TokenFactory public tokenFactory;
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -116,7 +116,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
tokenFactory = TokenFactory(_tokenFactory);
|
||||||
name = _tokenName; // Set the name
|
name = _tokenName; // Set the name
|
||||||
decimals = _decimalUnits; // Set the decimals
|
decimals = _decimalUnits; // Set the decimals
|
||||||
symbol = _tokenSymbol; // Set the symbol
|
symbol = _tokenSymbol; // Set the symbol
|
||||||
|
@ -425,14 +425,14 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||||
if (snapshotBlock == 0) {
|
if (snapshotBlock == 0) {
|
||||||
snapshotBlock = block.number;
|
snapshotBlock = block.number;
|
||||||
}
|
}
|
||||||
MiniMeToken cloneToken = tokenFactory.createCloneToken(
|
MiniMeToken cloneToken = MiniMeToken(tokenFactory.createCloneToken(
|
||||||
address(this),
|
address(this),
|
||||||
snapshotBlock,
|
snapshotBlock,
|
||||||
_cloneTokenName,
|
_cloneTokenName,
|
||||||
_cloneDecimalUnits,
|
_cloneDecimalUnits,
|
||||||
_cloneTokenSymbol,
|
_cloneTokenSymbol,
|
||||||
_transfersEnabled
|
_transfersEnabled
|
||||||
);
|
));
|
||||||
|
|
||||||
cloneToken.changeController(msg.sender);
|
cloneToken.changeController(msg.sender);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pragma solidity ^0.5.0;
|
pragma solidity ^0.5.0;
|
||||||
|
|
||||||
|
import "./TokenFactory.sol";
|
||||||
import "./MiniMeToken.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
|
* In solidity this is the way to create a contract from a contract of the
|
||||||
* same class
|
* same class
|
||||||
*/
|
*/
|
||||||
contract MiniMeTokenFactory {
|
contract MiniMeTokenFactory is TokenFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice Update the DApp by creating a new token with new functionalities
|
* @notice Update the DApp by creating a new token with new functionalities
|
||||||
|
@ -32,7 +33,7 @@ contract MiniMeTokenFactory {
|
||||||
uint8 _decimalUnits,
|
uint8 _decimalUnits,
|
||||||
string memory _tokenSymbol,
|
string memory _tokenSymbol,
|
||||||
bool _transfersEnabled
|
bool _transfersEnabled
|
||||||
) public returns (MiniMeToken) {
|
) public returns (address payable) {
|
||||||
MiniMeToken newToken = new MiniMeToken(
|
MiniMeToken newToken = new MiniMeToken(
|
||||||
address(this),
|
address(this),
|
||||||
_parentToken,
|
_parentToken,
|
||||||
|
@ -44,6 +45,6 @@ contract MiniMeTokenFactory {
|
||||||
);
|
);
|
||||||
|
|
||||||
newToken.changeController(msg.sender);
|
newToken.changeController(msg.sender);
|
||||||
return newToken;
|
return address(newToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue