Преглед на файлове

fix: import of "Greeter_factory" type

chore: use "import type" instead of "import" to import TypeScript types
chore: update description in "package.json"
docs: americanize spelling in README.md
refactor: import "artifacts", "ethers" and "waffle" objects instead of entire HRE
Paul Razvan Berg преди 3 години
родител
ревизия
5dbfc918c5
променени са 5 файла, в които са добавени 13 реда и са изтрити 15 реда
  1. 1 1
      README.md
  2. 1 1
      package.json
  3. 1 1
      tasks/deploy/greeter.ts
  4. 7 9
      test/greeter/Greeter.ts
  5. 3 3
      test/types.ts

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # Solidity Template
 
-My favourite setup for writing Solidity smart contracts.
+My favorite setup for writing Solidity smart contracts.
 
 - [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network
 - [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@paulrberg/solidity-template",
-  "description": "Setup for writing Solidity smart contracts",
+  "description": "Template for writing Solidity smart contracts",
   "version": "1.0.0",
   "author": {
     "name": "Paul Razvan Berg",

+ 1 - 1
tasks/deploy/greeter.ts

@@ -2,7 +2,7 @@ import { task } from "hardhat/config";
 import { TaskArguments } from "hardhat/types";
 
 import { Greeter } from "../../types/Greeter";
-import { Greeter__factory } from "../../types/Greeter__factory";
+import { Greeter__factory } from "../../types/factories/Greeter__factory";
 
 task("deploy:Greeter")
   .addParam("greeting", "Say hello, be nice")

+ 7 - 9
test/greeter/Greeter.ts

@@ -1,26 +1,24 @@
-import hre from "hardhat";
-import { Artifact } from "hardhat/types";
-import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
+import { artifacts, ethers, waffle } from "hardhat";
+import type { Artifact } from "hardhat/types";
+import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
 
-import { Greeter } from "../../types/Greeter";
+import type { Greeter } from "../../types/Greeter";
 import { Signers } from "../types";
 import { shouldBehaveLikeGreeter } from "./Greeter.behavior";
 
-const { deployContract } = hre.waffle;
-
 describe("Unit tests", function () {
   before(async function () {
     this.signers = {} as Signers;
 
-    const signers: SignerWithAddress[] = await hre.ethers.getSigners();
+    const signers: SignerWithAddress[] = await ethers.getSigners();
     this.signers.admin = signers[0];
   });
 
   describe("Greeter", function () {
     beforeEach(async function () {
       const greeting: string = "Hello, world!";
-      const greeterArtifact: Artifact = await hre.artifacts.readArtifact("Greeter");
-      this.greeter = <Greeter>await deployContract(this.signers.admin, greeterArtifact, [greeting]);
+      const greeterArtifact: Artifact = await artifacts.readArtifact("Greeter");
+      this.greeter = <Greeter>await waffle.deployContract(this.signers.admin, greeterArtifact, [greeting]);
     });
 
     shouldBehaveLikeGreeter();

+ 3 - 3
test/types.ts

@@ -1,7 +1,7 @@
-import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
-import { Fixture } from "ethereum-waffle";
+import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
+import type { Fixture } from "ethereum-waffle";
 
-import { Greeter } from "../types/Greeter";
+import type { Greeter } from "../types/Greeter";
 
 declare module "mocha" {
   export interface Context {