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 all 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 contracts/Core/StakeManager.sol
Expand Up @@ -228,7 +228,7 @@ contract StakeManager is Initializable, 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 @@ -53,7 +53,7 @@ const setupContracts = async () => {
const jobManager = await JobManager.deploy(stateManager.address);
const stakeManager = await StakeManager.deploy(BLOCK_REWARD.toHexString());
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