Skip to content

Commit

Permalink
✨script: added deploy.js script
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay-sol committed Sep 15, 2024
1 parent 79021a3 commit 1a1511b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { ethers } = require("hardhat");

async function main() {
const Diamond = await ethers.getContractFactory("Diamond");
const diamond = await Diamond.deploy();
await diamond.deployed();
console.log("Diamond deployed to:", diamond.address);

const OwnershipFacet = await ethers.getContractFactory("OwnershipFacet");
const ownershipFacet = await OwnershipFacet.deploy();
await ownershipFacet.deployed();
console.log("OwnershipFacet deployed to:-", ownershipFacet.address);

const TokenFacet = await ethers.getContractFactory("TokenFacet");
const tokenFacet = await TokenFacet.deploy();
await tokenFacet.deployed();
console.log("TokenFacet deployed to:-", tokenFacet.address);

let ownershipSelectors = Object.keys(OwnershipFacet.interface.functions).map(
(signature) => OwnershipFacet.interface.getSighash(signature)
);
await diamond.updateFacet(ownershipFacet.address, ownershipSelectors);
console.log("OwnershipFacet functions added to Diamond");

let tokenSelectors = Object.keys(TokenFacet.interface.functions).map(
(signature) => TokenFacet.interface.getSighash(signature)
);
await diamond.updateFacet(tokenFacet.address, tokenSelectors);
console.log("TokenFacet functions added to Diamond");
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 1a1511b

Please sign in to comment.