From a50b90b6aad289f7dd2a657ae336aa2b5d26b540 Mon Sep 17 00:00:00 2001 From: abhimanyu121 Date: Sun, 8 Oct 2023 14:48:50 +0530 Subject: [PATCH] Added deploy scripts and code cleanup --- contracts/src/hyperboards/HyperboardNFT.sol | 4 +- contracts/src/interfaces/IERC6551Registry.sol | 30 ------------- contracts/tasks/deploy.ts | 45 +++++++++++++++++++ contracts/test/foundry/HyperboardNFT.t.sol | 3 -- 4 files changed, 46 insertions(+), 36 deletions(-) delete mode 100644 contracts/src/interfaces/IERC6551Registry.sol diff --git a/contracts/src/hyperboards/HyperboardNFT.sol b/contracts/src/hyperboards/HyperboardNFT.sol index 85fe4e29..a2e4f4c9 100644 --- a/contracts/src/hyperboards/HyperboardNFT.sol +++ b/contracts/src/hyperboards/HyperboardNFT.sol @@ -13,9 +13,7 @@ import { Strings } from "oz-contracts/contracts/utils/Strings.sol"; import { Ownable } from "oz-contracts/contracts/access/Ownable.sol"; import { CountersUpgradeable } from "oz-upgradeable/utils/CountersUpgradeable.sol"; -import { Errors } from "../libs/errors.sol"; -import { IERC6551Registry } from "../interfaces/IERC6551Registry.sol"; -import "forge-std/console.sol"; +import { Errors } from "../libs/Errors.sol"; /// @title A hyperboard NFT /// @author Abhimanyu Shekhawat diff --git a/contracts/src/interfaces/IERC6551Registry.sol b/contracts/src/interfaces/IERC6551Registry.sol deleted file mode 100644 index 7eb9b684..00000000 --- a/contracts/src/interfaces/IERC6551Registry.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.16; - -interface IERC6551Registry { - event AccountCreated( - address account, - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt - ); - - function createAccount( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 seed, - bytes calldata initData - ) external returns (address); - - function account( - address implementation, - uint256 chainId, - address tokenContract, - uint256 tokenId, - uint256 salt - ) external view returns (address); -} diff --git a/contracts/tasks/deploy.ts b/contracts/tasks/deploy.ts index 75a87639..44f5bf08 100644 --- a/contracts/tasks/deploy.ts +++ b/contracts/tasks/deploy.ts @@ -90,3 +90,48 @@ task("deploy-trader", "Deploy HypercertTrader and verify") } } }); + +task("deploy-hyperboard", "Deploy Hyperboard and verify") + .addOptionalParam("output", "write the details of the deployment to this file if this is set") + .setAction(async ({ output }, { ethers, upgrades }) => { + const Hyperboard = await ethers.getContractFactory("Hyperboard"); + const hyperboard = await upgrades.deployProxy(Hyperboard, { + kind: "uups", + unsafeAllow: ["constructor"], + }); + const contract = await hyperboard.deployed(); + console.log(`hyperboard is deployed to proxy address: ${hyperboard.address}`); + + // If the `deploymentFile` option is set then write the deployed address to + // a json object on disk. This is intended to be deliberate with how we + // output the contract address and other contract information. + if (output) { + const txReceipt = await contract.provider.getTransactionReceipt(hyperboard.deployTransaction.hash); + await writeFile( + output, + JSON.stringify({ + address: hyperboard.address, + blockNumber: txReceipt.blockNumber, + }), + "utf-8", + ); + } + + if (hre.network.name !== "hardhat" && hre.network.name !== "localhost") { + try { + const code = await hyperboard.instance?.provider.getCode(hyperboard.address); + if (code === "0x") { + console.log(`${hyperboard.name} contract deployment has not completed. waiting to verify...`); + await hyperboard.instance?.deployed(); + } + await hre.run("verify:verify", { + address: hyperboard.address, + }); + } catch ({ message }) { + if ((message as string).includes("Reason: Already Verified")) { + console.log("Reason: Already Verified"); + } + console.error(message); + } + } + }); diff --git a/contracts/test/foundry/HyperboardNFT.t.sol b/contracts/test/foundry/HyperboardNFT.t.sol index 4978d803..90b3c4e7 100644 --- a/contracts/test/foundry/HyperboardNFT.t.sol +++ b/contracts/test/foundry/HyperboardNFT.t.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; import { ERC20 } from "oz-contracts/contracts/token/ERC20/ERC20.sol"; -// import { WalletImpl } from "./WalletImpl.sol"; // Replace with your wallet implementation contract -import { IERC6551Registry } from "../../src/interfaces/IERC6551Registry.sol"; import { Hyperboard } from "../../src/hyperboards/HyperboardNFT.sol"; import { Test } from "forge-std/Test.sol"; import { Vm } from "forge-std/Vm.sol"; @@ -15,7 +13,6 @@ import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; contract TestHyperboard is Test { Hyperboard private _hyperboard; // WalletImpl _walletImpl; - IERC6551Registry private _erc6551Registry; address private _owner; address private _user1; address private _user2;