Skip to content

Commit

Permalink
Merge pull request #64 from MyriadFlow/Update5
Browse files Browse the repository at this point in the history
Hardhat: Revoke Role && Grant Role Added
  • Loading branch information
soumalya340 authored Sep 22, 2023
2 parents e3ca550 + 1e1472d commit 6d808c1
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 46 deletions.
8 changes: 6 additions & 2 deletions contracts/accessmaster/AccessMaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract AccessMaster is AccessControlEnumerable {
keccak256("FLOW_OPERATOR_ROLE");
bytes32 public constant FLOW_CREATOR_ROLE = keccak256("FLOW_CREATOR_ROLE");

constructor() {
constructor(address storefrontAdmin) {
_setupRole(FLOW_ADMIN_ROLE, _msgSender());

_setRoleAdmin(FLOW_ADMIN_ROLE, FLOW_ADMIN_ROLE);
Expand All @@ -28,7 +28,11 @@ contract AccessMaster is AccessControlEnumerable {

// add Admin to operator and Creator
grantRole(FLOW_OPERATOR_ROLE, _msgSender());
grantRole(FLOW_CREATOR_ROLE, _msgSender());

// assigning storefront publisher Wallet the Admin role
grantRole(FLOW_ADMIN_ROLE, storefrontAdmin);
grantRole(FLOW_OPERATOR_ROLE, storefrontAdmin);
grantRole(FLOW_CREATOR_ROLE, storefrontAdmin);
}

function updateName(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"launchFilCalibration" : "hardhat run scripts/launch/launch.js --network filecoinCalibaration",
"launchLineaGoerli" : "hardhat run scripts/launch/launch.js --network lineaGoerli",
"contractAddress" : "hardhat run scripts/contractAddress.js",
"grantRole" : "hardhat run scripts/grantRole.js"
"revokeRole" : "hardhat run scripts/revokeRole.js"

},
"devDependencies": {
Expand Down
20 changes: 0 additions & 20 deletions scripts/contractAddress.js

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/grantRole.json

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/launch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The JSON file should have the following format:
{
"contractName" : "AccessMaster",
"constructorParams":{
"param1" : "0x83AD8ddAdb013fbA80DE0d802FD4fB1a949AD79f" // storefrontAdmin wallet
}
}
```
Expand All @@ -28,7 +29,7 @@ The JSON file should have the following format:
"constructorParams":{
"param1": 30, // PlaformFee
"param2" : "NFT BAZAAR", // TradeHub Name
"param3" : "0xEFf4209584cc2cE0409a5FA06175002537b055DC" // AccessMaster Address
"param3" : "0xEFf4209584cc2cE0409a5FA06175002537b055DC" // AccessMaster Address
}
}
```
Expand All @@ -54,7 +55,7 @@ The JSON file should have the following format:
{
"contractName" : "SignatureSeries",
"constructorParams":{
"param1" : "NFT Baazar", // Name
"param1" : "NFT Baazar", // Name
"param2" : "NFB",// Symbol
"param3" : "0x1B8683e1885B3ee93524cD58BC10Cf3Ed6af4298", // TradeHub Address
"param4" : "0xEFf4209584cc2cE0409a5FA06175002537b055DC"// AccessMaster Address
Expand Down
8 changes: 6 additions & 2 deletions scripts/launch/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ let blockNumber
let Verified = false

async function AccessMasterDeploy() {
const constructorParam = jsonContent.constructorParams

const AccessMasterFactory = await hre.ethers.getContractFactory(
"AccessMaster"
)
const AccessMaster = await AccessMasterFactory.deploy()
const AccessMaster = await AccessMasterFactory.deploy(
constructorParam.param1
)
await AccessMaster.deployed()
console.log(`AccessMaster Deployed to : ${AccessMaster.address}`)
//console.log(AccessMaster)
Expand All @@ -23,7 +27,7 @@ async function AccessMasterDeploy() {
///VERIFY
if (hre.network.name != "hardhat") {
await AccessMaster.deployTransaction.wait(6)
await verify(AccessMaster.address, [])
await verify(AccessMaster.address, [constructorParam.param1])
}
}

Expand Down
1 change: 1 addition & 0 deletions scripts/launch/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"contractName" : "AccessMaster",
"constructorParams":{
"param1" : "0x59Ecbeb479C45de2AB9996129499A5afd437454d"
}
}
23 changes: 21 additions & 2 deletions scripts/grantRole.js → scripts/revokeRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { json } = require("node:stream/consumers")
async function main() {
const accounts = await ethers.getSigners()

const scripts = `scripts/grantRole.json`
const scripts = `scripts/revokeRole.json`
const data = fs.readFileSync(scripts, "utf8")
const jsonContent = JSON.parse(data)

Expand All @@ -15,6 +15,7 @@ async function main() {
/// fetching the abi
const contractArtifact = await artifacts.readArtifact("AccessMaster")

/// TO revoke Admin Role
const FLOW_ADMIN_ROLE =
"0x8f882e9b3b0c043c8507802fbb9a0ed808c8f0587361ab18424493e6841512a8"

Expand All @@ -24,7 +25,7 @@ async function main() {
accounts[0]
)

const transactionResponse = await contract.grantRole(
const transactionResponse = await contract.revokeRole(
FLOW_ADMIN_ROLE,
walletAddress
)
Expand All @@ -39,6 +40,24 @@ async function main() {

const isAdmin = await contract.isAdmin(walletAddress)
console.log(`Is the Wallet Address ${walletAddress} is Admin : ${isAdmin}`)

// To revoke Operator Role
const FLOW_CREATOR_ROLE =
"0xb75d0c3e4b0e01fa592ef743acc55a0b7765ffd271595abd71aa99cbf3518c07"

const transactionResponse1 = await contract.revokeRole(
FLOW_CREATOR_ROLE,
walletAddress
)

const transactionReceipt1 = await transactionResponse1.wait()

if (transactionReceipt1.status === 1) {
console.log("Transaction successful")
console.log(`The operator role is also revoked for ${contractAddress}`)
} else {
console.log("Transaction failed")
}
}

// main
Expand Down
4 changes: 4 additions & 0 deletions scripts/revokeRole.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"contractAddr" : "0xdaE2ACcC94b90587d83f5FBF3044D3954ce3d674",
"walletAddr" : "0x83AD8ddAdb013fbA80DE0d802FD4fB1a949AD79f"
}
3 changes: 0 additions & 3 deletions scripts/txhash.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/01-signatureseries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("TradeHub && SignatureSeries Contract", () => {

before(async () => {
const AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessmaster = await AccessMasterFactory.deploy()
accessmaster = await AccessMasterFactory.deploy(owner.address)


let TradeHubFactory = await ethers.getContractFactory("TradeHub")
Expand Down
2 changes: 1 addition & 1 deletion test/02-fusionseries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("TradeHub && FusionSeries contract", () => {

before(async () => {
const AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessmaster = await AccessMasterFactory.deploy()
accessmaster = await AccessMasterFactory.deploy(owner.address)

let TradeHubFactory = await ethers.getContractFactory("TradeHub")
tradehub = await TradeHubFactory.deploy(300,"MyMarketplace", accessmaster.address)
Expand Down
2 changes: 1 addition & 1 deletion test/03-instagen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("TradeHub and InstaGen contracts", () => {
Saleprice = ethers.utils.parseEther("0.01")

const AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessmaster = await AccessMasterFactory.deploy()
accessmaster = await AccessMasterFactory.deploy(owner.address)


let TradeHubFactory = await ethers.getContractFactory("TradeHub")
Expand Down
2 changes: 1 addition & 1 deletion test/04-eternumpass.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Eternumpass Contract", () => {

before(async () => {
const AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessmaster = await AccessMasterFactory.deploy()
accessmaster = await AccessMasterFactory.deploy(owner.address)
const EternumPassFactory = await ethers.getContractFactory("EternumPass")
eternumpass = await EternumPassFactory.deploy(metadata.name, metadata.symbol,baseURI,publicSalePrice,30,subscriptionPerMonth,500,accessmaster.address,"0x1B8683e1885B3ee93524cD58BC10Cf3Ed6af4298");
})
Expand Down
2 changes: 1 addition & 1 deletion test/05-offerstation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("FlowOfferStation contract", () => {
}
before(async () => {
let AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessMaster = await AccessMasterFactory.deploy();
accessMaster = await AccessMasterFactory.deploy(owner.address);

let offerStationFactory = await ethers.getContractFactory("MyriadFlowOfferStation")
offerstation = await offerStationFactory.deploy(300 , false , accessMaster.address)
Expand Down
2 changes: 1 addition & 1 deletion test/07-eternalsoul.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Eternal Soul Contract", () => {

before(async () => {
const AccessMasterFactory = await ethers.getContractFactory("AccessMaster")
accessmaster = await AccessMasterFactory.deploy()
accessmaster = await AccessMasterFactory.deploy(owner.address)

const EternalSoulFactory = await ethers.getContractFactory("EternalSoul")
eternalsoul = await EternalSoulFactory.deploy(metadata.name, metadata.symbol,"www.xyz.com" ,accessmaster.address)
Expand Down
Loading

0 comments on commit 6d808c1

Please sign in to comment.