瀏覽代碼

refactor: switch to typed getContractFactory

Paul Razvan Berg 4 年之前
父節點
當前提交
3def942b3a
共有 1 個文件被更改,包括 5 次插入10 次删除
  1. 5 10
      scripts/deploy.ts

+ 5 - 10
scripts/deploy.ts

@@ -1,26 +1,21 @@
-import { Contract, ContractFactory } from "ethers";
+import { Contract } from "ethers";
 // We require the Hardhat Runtime Environment explicitly here. This is optional
 // but useful for running the script in a standalone fashion through `node <script>`.
 // When running the script with `hardhat run <script>` you'll find the Hardhat
 // Runtime Environment's members available in the global scope.
 import { ethers } from "hardhat";
 
-async function main(): Promise<void> {
-  // Hardhat always runs the compile task when running scripts through it.
-  // If this runs in a standalone fashion you may want to call compile manually
-  // to make sure everything is compiled
-  // await run("compile");
+import { Greeter__factory } from "../typechain";
 
-  // We get the contract to deploy
-  const Greeter: ContractFactory = await ethers.getContractFactory("Greeter");
+async function main(): Promise<void> {
+  const Greeter: Greeter__factory = await ethers.getContractFactory("Greeter");
   const greeter: Contract = await Greeter.deploy("Hello, Buidler!");
   await greeter.deployed();
 
   console.log("Greeter deployed to: ", greeter.address);
 }
 
-// We recommend this pattern to be able to use async/await everywhere
-// and properly handle errors.
+// We recommend this pattern to be able to use async/await everywhere and properly handle errors.
 main()
   .then(() => process.exit(0))
   .catch((error: Error) => {