Procházet zdrojové kódy

refactor: use Hardhat's SignerWithAddress instead of Signer

Paul Razvan Berg před 4 roky
rodič
revize
c61c92913f
3 změnil soubory, kde provedl 7 přidání a 14 odebrání
  1. 4 6
      test/Greeter.ts
  2. 1 2
      types/augmentations.d.ts
  3. 2 6
      types/index.ts

+ 4 - 6
test/Greeter.ts

@@ -1,28 +1,26 @@
-import { Signer } from "@ethersproject/abstract-signer";
+import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
 import { ethers, waffle } from "hardhat";
 
 import GreeterArtifact from "../artifacts/contracts/Greeter.sol/Greeter.json";
 
-import { Accounts, Signers } from "../types";
 import { Greeter } from "../typechain/Greeter";
+import { Signers } from "../types";
 import { shouldBehaveLikeGreeter } from "./Greeter.behavior";
 
 const { deployContract } = waffle;
 
 describe("Unit tests", function () {
   before(async function () {
-    this.accounts = {} as Accounts;
     this.signers = {} as Signers;
 
-    const signers: Signer[] = await ethers.getSigners();
+    const signers: SignerWithAddress[] = await ethers.getSigners();
     this.signers.admin = signers[0];
-    this.accounts.admin = await signers[0].getAddress();
   });
 
   describe("Greeter", function () {
     beforeEach(async function () {
       const greeting: string = "Hello, world!";
-      this.greeter = (await deployContract(this.signers.admin, GreeterArtifact, [greeting])) as Greeter;
+      this.greeter = <Greeter>await deployContract(this.signers.admin, GreeterArtifact, [greeting]);
     });
 
     shouldBehaveLikeGreeter();

+ 1 - 2
types/augmentations.d.ts

@@ -1,9 +1,8 @@
-import { Accounts, Signers } from "./";
+import { Signers } from "./";
 import { Greeter } from "../typechain";
 
 declare module "mocha" {
   export interface Context {
-    accounts: Accounts;
     greeter: Greeter;
     signers: Signers;
   }

+ 2 - 6
types/index.ts

@@ -1,9 +1,5 @@
-import { Signer } from "@ethersproject/abstract-signer";
-
-export interface Accounts {
-  admin: string;
-}
+import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
 
 export interface Signers {
-  admin: Signer;
+  admin: SignerWithAddress;
 }