-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from razor-network/update-result-manager
Remove storing of block and activeCollectionIDs from ResultManager
- Loading branch information
Showing
8 changed files
with
165 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract Token is ERC20 { | ||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
uint256 mintAmount | ||
) ERC20(_name, _symbol) { | ||
_mint(msg.sender, mintAmount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const hre = require("hardhat"); | ||
require('dotenv').config(); | ||
|
||
const SIGNER_ADDRESS = process.env.SIGNER_ADDRESS || "0xC68AcC784227DbEaE98Bb6F5aC3C57cCe1aE9B4B"; | ||
const FORWARDER_ADDRESS = "0xAfAf9554D8f425030AB51188fC84Fe0Bd5f3E908"; | ||
const TRANSPARENT_FORWARDER_ADDRESS = "0x76a6AB56E27823B2175F11b0041c489bFdb13c88"; | ||
|
||
async function main() { | ||
console.log("Deploying ResultManager contract..."); | ||
|
||
const ResultManager = await hre.ethers.getContractFactory("ResultManager"); | ||
const resultManagerV2 = await ResultManager.deploy(SIGNER_ADDRESS); | ||
console.log("ResultManager contract deployed at:", resultManagerV2.address); | ||
|
||
const Forwarder = await hre.ethers.getContractFactory("Forwarder"); | ||
const forwarder = Forwarder.attach(FORWARDER_ADDRESS); // Forwarder address from previous deployment | ||
console.log("Forwarder contract deployed at", forwarder.address); | ||
|
||
const tx1 = await forwarder.setResultManager(resultManagerV2.address); | ||
await tx1.wait(); | ||
|
||
console.log("Deploying Staking contract..."); | ||
const Staking = await hre.ethers.getContractFactory("Staking"); | ||
const staking = await Staking.deploy(); | ||
console.log("Staking contract deployed at:", staking.address); | ||
|
||
console.log( | ||
"[ResultManager] Granting FORWARDER_ROLE to forwarder contract address" | ||
); | ||
const FORWARDER_ROLE = await resultManagerV2.FORWARDER_ROLE(); | ||
const tx2 = await resultManagerV2.grantRole(FORWARDER_ROLE, forwarder.address); | ||
await tx2.wait(); | ||
|
||
|
||
const TransparentForwarder = await hre.ethers.getContractFactory( | ||
"TransparentForwarder" | ||
); | ||
const transparentForwarder = TransparentForwarder.attach(TRANSPARENT_FORWARDER_ADDRESS); // Transparent Forwarder address from previous deployment | ||
|
||
console.log( | ||
`[Tranparent Forwarder] setting staking address to ${staking.address}` | ||
); | ||
const tx3 = await transparentForwarder.setStaking(staking.address); | ||
await tx3.wait(); | ||
console.log("Transaction hash: ", tx3.hash); | ||
console.log("--------------------------------------------------------------"); | ||
|
||
console.log( | ||
`[Staking] Granting TRANSPARENT_FORWARDER_ROLE to Transparent Forwarder contract address` | ||
); | ||
const TRANSPARENT_FORWARDER_ROLE = await forwarder.TRANSPARENT_FORWARDER_ROLE(); | ||
const tx4 = await staking.grantRole( | ||
TRANSPARENT_FORWARDER_ROLE, | ||
transparentForwarder.address | ||
); | ||
await tx4.wait(); | ||
console.log("Transaction hash: ", tx4.hash); | ||
console.log("--------------------------------------------------------------"); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { ethers } = require("hardhat"); | ||
const { expect } = require("chai"); | ||
|
||
const clientAddresses = [ | ||
"0x2546BcD3c84621e976D8185a91A922aE77ECEc30", | ||
"0xbDA5747bFD65F08deb54cb465eB87D40e51B197E", | ||
"0xdD2FD4581271e230360230F9337D5c0430Bf44C0", | ||
"0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199", | ||
]; | ||
|
||
describe("Staking tests", () => { | ||
const tokenName = "Token"; | ||
const tokenSymbol = "TKN"; | ||
const mintAmount = ethers.utils.parseEther("10000000"); | ||
const defaultMinStake = ethers.utils.parseEther("1000000"); | ||
let signers; | ||
|
||
let staking; | ||
let token; | ||
|
||
before(async () => { | ||
signers = await hre.ethers.getSigners(); | ||
|
||
const Staking = await ethers.getContractFactory("Staking"); | ||
staking = await Staking.deploy(); | ||
await staking.deployed(); | ||
}); | ||
|
||
it("Deployment tests", async () => { | ||
|
||
// * deployer should have default admin role | ||
const DEFAULT_ADMIN_ROLE = await staking.DEFAULT_ADMIN_ROLE(); | ||
expect(await staking.hasRole(DEFAULT_ADMIN_ROLE, signers[0].address)).to.be | ||
.true; | ||
}); | ||
|
||
it("Only STAKING_ADMIN_ROLE can enable/disable whitelisting", async () => { | ||
const STAKING_ADMIN_ROLE = await staking.STAKING_ADMIN_ROLE(); | ||
|
||
// * cannot enable/disable whitelisting | ||
await expect(staking.connect(signers[1]).enableWhitelist()).to.be.reverted; | ||
await expect(staking.connect(signers[1]).disableWhitelist()).to.be.reverted; | ||
|
||
await staking.grantRole(STAKING_ADMIN_ROLE, signers[1].address); | ||
|
||
await expect(staking.connect(signers[1]).enableWhitelist()).to.be.not | ||
.reverted; | ||
expect(await staking.isWhitelistEnabled()).to.be.true; | ||
await expect(staking.connect(signers[1]).disableWhitelist()).to.be.not | ||
.reverted; | ||
expect(await staking.isWhitelistEnabled()).to.be.false; | ||
await staking.revokeRole(STAKING_ADMIN_ROLE, signers[1].address); | ||
}); | ||
|
||
}); |