From 1a1511b33c0139657d60ddbf01786847813da366 Mon Sep 17 00:00:00 2001 From: Sanjay Sirangi Date: Sun, 15 Sep 2024 06:22:26 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8script:=20added=20deploy.js=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts/deploy.js diff --git a/scripts/deploy.js b/scripts/deploy.js new file mode 100644 index 0000000..c072ffd --- /dev/null +++ b/scripts/deploy.js @@ -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); + });