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

Removed Mint method #130

Merged
merged 17 commits into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.ganache
Expand Up @@ -9,7 +9,7 @@ PROVIDER_HOST=127.0.0.1
PROVIDER_PORT=8545

# Schelling Coin Address (if want to re-use already deployed instance)
SCHELLING_COIN_ADDRESS=0xB007d2B950467c397846e7797675B76128f8B2C4
SCHELLING_COIN_ADDRESS=0xF4c08930165661f13CEb5671CB0B0EC372b08151

# List of Stakers
STAKER_ADDRESSES=0x1D68ad204637173b2d8656B7972c57dcE41Bc80e,0x9FF5085aa345C019cDF2A427B02Bd6746DeF549B,0xc4695904751Ad8414c75798d6Ff2579f55e61522,0x40d57C3F5c3BAbac3033E2D50AB7C6886A595F46,0xa2B827aCF6073f5D9e2350cbf0646Ba2535a5B0C
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/StakeManager.sol
Expand Up @@ -227,7 +227,7 @@ contract StakeManager is ACL, StakeStorage {
if (blockReward > 0) {
uint256 newStake = stakers[stakerId].stake+(blockReward);
_setStakerStake(stakerId, newStake, "Block Reward", epoch);
require(sch.mint(address(this), blockReward));

}
uint256 prevStakeGettingReward = stakeGettingReward;
stakeGettingReward = 0;
Expand Down
4 changes: 2 additions & 2 deletions contracts/SchellingCoin.sol
Expand Up @@ -21,9 +21,9 @@ contract SchellingCoin is ERC20, ACL {
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor (address minter) ERC20("SchellingCoin", "SCH") {
constructor () ERC20("SchellingCoin", "SCH") {
_mint(msg.sender, INITIAL_SUPPLY);
grantRole(MINTER_ROLE, minter);

}

function addMinter(address account) external {
Expand Down
4 changes: 1 addition & 3 deletions migrations/src/8_deploy_schelling_coin_and_faucet.js
Expand Up @@ -2,14 +2,12 @@ const { NETWORK, SCHELLING_COIN_ADDRESS } = process.env;
const {
deployContract,
appendDeploymentFile,
readDeploymentFile,
readOldDeploymentFile,
} = require('../migrationHelpers');

const deploySchellingCoinAndFaucet = async () => {
if (NETWORK !== 'mainnet' && SCHELLING_COIN_ADDRESS === '') {
const { StateManager } = await readDeploymentFile();
const schellingCoin = await deployContract('SchellingCoin', [], [StateManager]);
const schellingCoin = await deployContract('SchellingCoin', [], []);
await deployContract('Faucet', [], [schellingCoin.address]);
} else {
const { Faucet, SchellingCoin } = await readOldDeploymentFile();
Expand Down
21 changes: 12 additions & 9 deletions migrations/src/postDeploymentSetup.js
@@ -1,9 +1,9 @@
const {
getdeployedContractInstance,
readDeploymentFile,
readOldDeploymentFile,
} = require('../migrationHelpers');

const { BigNumber } = ethers;
const {
NETWORK,
SCHELLING_COIN_ADDRESS,
Expand Down Expand Up @@ -44,22 +44,25 @@ module.exports = async () => {
// Only transfer tokens in testnets
if (NETWORK !== 'mainnet') {
// Add new instance of StakeManager contract & Deployer address as Minter
await schellingCoin.addMinter(stakeManagerAddress);
await schellingCoin.addMinter(signers[0].address);

if (SCHELLING_COIN_ADDRESS !== '') {
const { StakeManager: oldStakeManagerAddress } = await readOldDeploymentFile();
const initialSupply = await schellingCoin.INITIAL_SUPPLY();

const mintableSupply = (BigNumber.from(10).pow(BigNumber.from(26))).mul(BigNumber.from(6));
const deployerBalance = BigNumber.from(await schellingCoin.balanceOf(signers[0].address));
const deployerSupply = BigNumber.from(initialSupply).sub(BigNumber.from(deployerBalance));

if (SCHELLING_COIN_ADDRESS !== '') {
// if previous instances of Schelling Coin is reused again and again,
// then initial balance will get depleted, thus intial tokens minting is needed,
// each time Schelling Coin instance is reused
const initialSupply = await schellingCoin.INITIAL_SUPPLY();
await schellingCoin.mint(signers[0].address, initialSupply);
await schellingCoin.addMinter(signers[0].address);

await schellingCoin.mint(signers[0].address, (deployerSupply));

// Remove previous instance of StakeManager contract & Deployer address from Minter
await schellingCoin.removeMinter(oldStakeManagerAddress);
// Remove previous instance of Deployer address from Minter
await schellingCoin.removeMinter(signers[0].address);
0xcuriousapple marked this conversation as resolved.
Show resolved Hide resolved
}
await schellingCoin.transfer(stakeManagerAddress, mintableSupply);

for (let i = 0; i < stakerAddressList.length; i++) {
const tx = await schellingCoin.transfer(stakerAddressList[i], SEED_AMOUNT);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/testSetup.js
Expand Up @@ -54,7 +54,7 @@ const setupContracts = async () => {
const stakeManager = await StakeManager.deploy(BLOCK_REWARD.toHexString());
const stateManager = await StateManager.deploy();
const voteManager = await VoteManager.deploy();
const schellingCoin = await SchellingCoin.deploy(stakeManager.address);
const schellingCoin = await SchellingCoin.deploy();
const faucet = await Faucet.deploy(schellingCoin.address);

await blockManager.deployed();
Expand Down