diff --git a/hardhat.config.ts b/hardhat.config.ts index 338ec4f34..5cdc7cab9 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,10 +1,13 @@ import type { HardhatUserConfig } from "hardhat/types"; import "@nomiclabs/hardhat-waffle"; -import "hardhat-typechain"; +import "@typechain/hardhat"; import "hardhat-gas-reporter"; import "@nomiclabs/hardhat-ethers"; const config: HardhatUserConfig = { + typechain: { + outDir: "typechain", // overrides upstream 'fix' for another issue which changed this to 'typechain-types' + }, networks: { hardhat: { blockGasLimit: 100000000, diff --git a/package-lock.json b/package-lock.json index 4c00647e4..32496601a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2170,15 +2170,27 @@ "dev": true }, "@typechain/ethers-v5": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-5.0.0.tgz", - "integrity": "sha512-SnLnq6BCq2NBgm5xsQP8kRIawJ7gppLux8EOMb2ceoB5EuoW87AOyi6r1J5LTYe65/J59HjOVtaGCqsO+38Xrw==", - "dev": true + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-8.0.2.tgz", + "integrity": "sha512-oRMA3X5UWrsUiNb/lFTusa8xBpw6CckOHAk7sZBHeDQh4tAp+ZU24wdwdURcOtPnagzdCv5Dvl1qlD038brf1A==", + "dev": true, + "requires": { + "lodash": "^4.17.15", + "ts-essentials": "^7.0.1" + }, + "dependencies": { + "ts-essentials": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-7.0.3.tgz", + "integrity": "sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==", + "dev": true + } + } }, "@typechain/hardhat": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@typechain/hardhat/-/hardhat-2.3.0.tgz", - "integrity": "sha512-zERrtNol86L4DX60ktnXxP7Cq8rSZHPaQvsChyiQQVuvVs2FTLm24Yi+MYnfsIdbUBIXZG7SxDWhtCF5I0tJNQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@typechain/hardhat/-/hardhat-3.0.0.tgz", + "integrity": "sha512-FpnIIXkDXm54XCHI/Z2iOet7h1MrFSvZfuljX9Uzc6FEjEfb01Tuzu8ywe2iquD3g5JXqovgdv+M54L/2Z6jkg==", "dev": true, "requires": { "fs-extra": "^9.1.0" @@ -17010,12 +17022,6 @@ "murmur-128": "^0.2.1" } }, - "hardhat-typechain": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/hardhat-typechain/-/hardhat-typechain-0.3.4.tgz", - "integrity": "sha512-oI9YSutDfZnRlAV1bYTpLkBHw4rkhz9JDWAEXz2PR34ylpgLWxPFbPiHT5QXadGTlBqJUAT6JSTxCK1kADMkjA==", - "dev": true - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -22943,18 +22949,21 @@ } }, "typechain": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/typechain/-/typechain-4.0.1.tgz", - "integrity": "sha512-H/1VpRmplp1qhCTVLU9PCgzyVCQ7Lth7YvaaI1hTvT31IpWnLLNpDpQD4vXJGr26T9BsZ0ZIceOwieAbcoywXw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/typechain/-/typechain-6.0.2.tgz", + "integrity": "sha512-fphYQ2+r5z38eq02qr4KjgU9/Xdda8Cj+eV2QHSRXhDPyhEVv+ln9123iGjjDLEhGyROb3DQkbvjm3Dl0GtUeQ==", "dev": true, "requires": { + "@types/prettier": "^2.1.1", "command-line-args": "^4.0.7", "debug": "^4.1.1", "fs-extra": "^7.0.0", + "glob": "^7.1.6", "js-sha3": "^0.8.0", "lodash": "^4.17.15", - "ts-essentials": "^7.0.1", - "ts-generator": "^0.1.1" + "mkdirp": "^1.0.4", + "prettier": "^2.1.2", + "ts-essentials": "^7.0.1" }, "dependencies": { "fs-extra": { @@ -22978,9 +22987,9 @@ } }, "ts-essentials": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-7.0.1.tgz", - "integrity": "sha512-8lwh3QJtIc1UWhkQtr9XuksXu3O0YQdEE5g79guDfhCaU1FWTDIEDZ1ZSx4HTHUmlJZ8L812j3BZQ4a0aOUkSA==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-7.0.3.tgz", + "integrity": "sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index 0d24cb435..e846ed85b 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "@rollup/plugin-typescript": "^6.0.0", "@truffle/hdwallet-provider": "^1.2.1", "@tsconfig/svelte": "^1.0.0", - "@typechain/ethers-v5": "^5.0.0", - "@typechain/hardhat": "^2.3.0", + "@typechain/ethers-v5": "^8.0.2", + "@typechain/hardhat": "^3.0.0", "@types/mocha": "^8.2.0", "@types/node": "^14.14.22", "autoprefixer": "^10.1.0", @@ -51,7 +51,6 @@ "hardhat": "^2.0.8", "hardhat-gas-reporter": "^1.0.4", "hardhat-preprocessor": "^0.1.3", - "hardhat-typechain": "^0.3.4", "husky": "^7.0.1", "mnemonics": "^1.1.3", "node-fetch": "^2.6.1", @@ -80,7 +79,7 @@ "ts-generator": "^0.1.1", "ts-node": "^9.1.1", "tslib": "^2.0.0", - "typechain": "^4.0.1", + "typechain": "^6.0.2", "typescript": "^3.9.3", "ansi-regex": ">=5.0.1", "nth-check": ">=2.0.1", diff --git a/shell.nix b/shell.nix index bceb9b064..15e8d4273 100644 --- a/shell.nix +++ b/shell.nix @@ -74,6 +74,7 @@ let ''; ci-test = pkgs.writeShellScriptBin "ci-test" '' + hardhat compile --force hardhat test ''; @@ -113,11 +114,6 @@ let rm -rf artifacts/*Reentrant* rm -rf artifacts/*ForceSendEther* rm -rf artifacts/*Mock* - - rm -rf typechain/**/*Test* - rm -rf typechain/**/*Reentrant* - rm -rf typechain/**/*ForceSendEther* - rm -rf typechain/**/*Mock* ''; prepublish = pkgs.writeShellScriptBin "prepublish" '' diff --git a/test/Phased/Phased.sol.ts b/test/Phased/Phased.sol.ts index eb991e50c..115488028 100644 --- a/test/Phased/Phased.sol.ts +++ b/test/Phased/Phased.sol.ts @@ -5,6 +5,7 @@ import { ethers } from "hardhat"; import type { PhasedTest } from "../../typechain/PhasedTest"; import type { PhasedScheduleTest } from "../../typechain/PhasedScheduleTest"; import type { ReserveToken } from "../../typechain/ReserveToken"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -39,7 +40,8 @@ describe("Phased", async function () { it("should return highest attained phase even if several phases have the same block number", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const highestPhase = await phased.phaseAtBlockNumber( [0, 1, 2, 3, 3, 4, 5, 5], @@ -52,7 +54,8 @@ describe("Phased", async function () { it("if every phase block is after the block number then phase zero is returned", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const highestPhase = await phased.phaseAtBlockNumber( [100, 110, 120, 130, 140, 150, 160, 170], @@ -65,7 +68,8 @@ describe("Phased", async function () { it("if every phase block is before the block number then phase EIGHT is returned", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const highestPhase = await phased.phaseAtBlockNumber( [100, 110, 120, 130, 140, 150, 160, 170], @@ -83,7 +87,7 @@ describe("Phased", async function () { const phasedScheduleTest = (await Util.basicDeploy( "PhasedScheduleTest", {} - )) as PhasedScheduleTest; + )) as PhasedScheduleTest & Contract; assert( (await phasedScheduleTest.currentPhase()) === 0, @@ -108,9 +112,10 @@ describe("Phased", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const pastBlock = await ethers.provider.getBlockNumber(); @@ -127,7 +132,8 @@ describe("Phased", async function () { it("cannot schedule the next phase if it is already scheduled", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const firstBlock = await ethers.provider.getBlockNumber(); @@ -143,7 +149,8 @@ describe("Phased", async function () { it("the next phase block must not be uninitialized", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const firstBlock = await ethers.provider.getBlockNumber(); @@ -162,7 +169,8 @@ describe("Phased", async function () { it("is not possible to skip a phase", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const firstBlock = await ethers.provider.getBlockNumber(); @@ -178,7 +186,8 @@ describe("Phased", async function () { it("_beforeScheduleNextPhase hook can be used to impose conditions on phase changes", async function () { this.timeout(0); - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; const firstBlock = await ethers.provider.getBlockNumber(); @@ -202,9 +211,10 @@ describe("Phased", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; // check constants @@ -313,9 +323,10 @@ describe("Phased", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; - const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest; + const phased = (await Util.basicDeploy("PhasedTest", {})) as PhasedTest & + Contract; // onlyPhase assert(await phased.runsOnlyPhase(Phase.ZERO)); diff --git a/test/RedeemableERC20/RedeemableERC20.sol.ts b/test/RedeemableERC20/RedeemableERC20.sol.ts index 408024eab..ed9872d93 100644 --- a/test/RedeemableERC20/RedeemableERC20.sol.ts +++ b/test/RedeemableERC20/RedeemableERC20.sol.ts @@ -5,6 +5,7 @@ import { ethers } from "hardhat"; import type { ReserveToken } from "../../typechain/ReserveToken"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -46,16 +47,16 @@ describe("RedeemableERC20", async function () { const reserve1 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; @@ -73,7 +74,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); await redeemableERC20.grantRole( @@ -95,7 +96,7 @@ describe("RedeemableERC20", async function () { const signers = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -127,7 +128,7 @@ describe("RedeemableERC20", async function () { const signers = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -201,12 +202,12 @@ describe("RedeemableERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.GOLD; await tier.setTier(sender.address, Tier.COPPER, []); @@ -228,7 +229,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await token.deployed(); @@ -287,12 +288,12 @@ describe("RedeemableERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -311,7 +312,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -335,35 +336,35 @@ describe("RedeemableERC20", async function () { const reserve0 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve1 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve3 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve4 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve5 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve6 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve7 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserves = [ reserve0, @@ -379,7 +380,7 @@ describe("RedeemableERC20", async function () { // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -398,7 +399,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -473,12 +474,12 @@ describe("RedeemableERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -495,7 +496,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -741,7 +742,7 @@ describe("RedeemableERC20", async function () { const signers = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -761,7 +762,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -796,7 +797,7 @@ describe("RedeemableERC20", async function () { const signers = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const redeemableERC20Factory = await ethers.getContractFactory( @@ -813,7 +814,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -834,12 +835,12 @@ describe("RedeemableERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; // Set owner to COPPER status, lower than minimum status of DIAMOND await tier.setTier(signers[0].address, Tier.COPPER, []); @@ -860,7 +861,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -891,12 +892,12 @@ describe("RedeemableERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.GOLD; @@ -919,7 +920,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -968,16 +969,16 @@ describe("RedeemableERC20", async function () { const reserve1 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; @@ -995,7 +996,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); await redeemableERC20.grantRole( @@ -1180,14 +1181,14 @@ describe("RedeemableERC20", async function () { const reserve1 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; @@ -1205,7 +1206,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); @@ -1293,7 +1294,7 @@ describe("RedeemableERC20", async function () { const signers = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; @@ -1311,7 +1312,7 @@ describe("RedeemableERC20", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); diff --git a/test/RedeemableERC20/RedeemableERC20Reentrant.sol.ts b/test/RedeemableERC20/RedeemableERC20Reentrant.sol.ts index 3848b55c8..14d38812b 100644 --- a/test/RedeemableERC20/RedeemableERC20Reentrant.sol.ts +++ b/test/RedeemableERC20/RedeemableERC20Reentrant.sol.ts @@ -5,6 +5,7 @@ import { ethers } from "hardhat"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20Reentrant } from "../../typechain/RedeemableERC20Reentrant"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -45,7 +46,7 @@ describe("RedeemableERC20Reentrant", async function () { // Constructing the RedeemableERC20 sets the parameters but nothing stateful happens. const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; @@ -69,13 +70,13 @@ describe("RedeemableERC20Reentrant", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemableERC20.deployed(); const maliciousReserve = (await maliciousReserveFactory.deploy( redeemableERC20.address - )) as RedeemableERC20Reentrant; + )) as RedeemableERC20Reentrant & Contract; await redeemableERC20.grantRole( await redeemableERC20.REDEEMABLE_ADDER(), diff --git a/test/RedeemableERC20Pool/RedeemableERC20Pool.sol.ts b/test/RedeemableERC20Pool/RedeemableERC20Pool.sol.ts index 822eea4f1..387edec12 100644 --- a/test/RedeemableERC20Pool/RedeemableERC20Pool.sol.ts +++ b/test/RedeemableERC20Pool/RedeemableERC20Pool.sol.ts @@ -6,6 +6,7 @@ import type { ReserveToken } from "../../typechain/ReserveToken"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -38,10 +39,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -72,7 +73,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -87,7 +88,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -111,10 +112,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -145,7 +146,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -162,7 +163,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool, + })) as RedeemableERC20Pool & Contract, "revert 0_TRADING_DURATION", "wrongly constructed pool with 0 minimum trading duration" ); @@ -178,10 +179,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -212,7 +213,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -227,7 +228,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -297,10 +298,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -331,7 +332,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -346,7 +347,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -370,10 +371,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -404,7 +405,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -419,7 +420,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -538,10 +539,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -572,7 +573,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -587,7 +588,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -675,10 +676,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -715,7 +716,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -745,7 +746,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -820,10 +821,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -853,7 +854,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -883,7 +884,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); @@ -941,10 +942,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -974,7 +975,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -1006,7 +1007,7 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; await pool.deployed(); }, "revert RESERVE_INIT_MINIMUM", @@ -1024,10 +1025,10 @@ describe("RedeemableERC20Pool", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = 0; const redeemableFactory = await ethers.getContractFactory( @@ -1057,7 +1058,7 @@ describe("RedeemableERC20Pool", async function () { tier: tier.address, minimumStatus: minimumStatus, totalSupply: totalTokenSupply, - })) as RedeemableERC20; + })) as RedeemableERC20 & Contract; await redeemable.deployed(); @@ -1087,6 +1088,6 @@ describe("RedeemableERC20Pool", async function () { initialValuation: initialValuation, finalValuation: finalValuation, minimumTradingDuration, - })) as RedeemableERC20Pool; + })) as RedeemableERC20Pool & Contract; }); }); diff --git a/test/SeedERC20/SeedERC20.sol.ts b/test/SeedERC20/SeedERC20.sol.ts index d39ebba12..e6113fc9a 100644 --- a/test/SeedERC20/SeedERC20.sol.ts +++ b/test/SeedERC20/SeedERC20.sol.ts @@ -5,6 +5,7 @@ import { ethers } from "hardhat"; import type { ReserveToken } from "../../typechain/ReserveToken"; import type { SeedERC20 } from "../../typechain/SeedERC20"; import type { SeedERC20ForceSendEther } from "../../typechain/SeedERC20ForceSendEther"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -22,7 +23,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const aliceReserve = reserve.connect(alice); const bobReserve = reserve.connect(bob); @@ -45,7 +46,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const aliceSeed = seedERC20.connect(alice); const bobSeed = seedERC20.connect(bob); @@ -113,7 +114,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const aliceReserve = reserve.connect(alice); const bobReserve = reserve.connect(bob); @@ -136,7 +137,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const aliceSeed = seedERC20.connect(alice); const bobSeed = seedERC20.connect(bob); @@ -157,7 +158,8 @@ describe("SeedERC20", async function () { "SeedERC20ForceSendEther" ); const forceSendEther = - (await forceSendEtherFactory.deploy()) as SeedERC20ForceSendEther; + (await forceSendEtherFactory.deploy()) as SeedERC20ForceSendEther & + Contract; // send ether to attacker contract const txResult = await signers[0].sendTransaction({ @@ -181,7 +183,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const seedPrice = 100; const seedUnits = 10; @@ -196,7 +198,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; // SeedERC20 has 0 decimals const decimals = await seedERC20.decimals(); @@ -214,7 +216,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const bobReserve = reserve.connect(bob); const carolReserve = reserve.connect(carol); @@ -233,7 +235,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const bobSeed = seedERC20.connect(bob); const carolSeed = seedERC20.connect(carol); @@ -318,7 +320,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const aliceReserve = reserve.connect(alice); const bobReserve = reserve.connect(bob); @@ -341,7 +343,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const aliceSeed = seedERC20.connect(alice); const bobSeed = seedERC20.connect(bob); @@ -389,7 +391,7 @@ describe("SeedERC20", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const aliceReserve = reserve.connect(alice); const bobReserve = reserve.connect(bob); @@ -412,7 +414,7 @@ describe("SeedERC20", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const aliceSeed = seedERC20.connect(alice); const bobSeed = seedERC20.connect(bob); diff --git a/test/SeedERC20/SeedERC20Reentrant.sol.ts b/test/SeedERC20/SeedERC20Reentrant.sol.ts index 7fe7976dc..82a35aded 100644 --- a/test/SeedERC20/SeedERC20Reentrant.sol.ts +++ b/test/SeedERC20/SeedERC20Reentrant.sol.ts @@ -4,6 +4,7 @@ import { solidity } from "ethereum-waffle"; import { ethers } from "hardhat"; import type { SeedERC20Reentrant } from "../../typechain/SeedERC20Reentrant"; import type { SeedERC20 } from "../../typechain/SeedERC20"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -18,7 +19,7 @@ describe("SeedERC20Reentrant", async function () { const maliciousReserve = (await Util.basicDeploy( "SeedERC20Reentrant", {} - )) as SeedERC20Reentrant; + )) as SeedERC20Reentrant & Contract; const bobReserve = maliciousReserve.connect(bob); const daveReserve = maliciousReserve.connect(dave); @@ -38,7 +39,7 @@ describe("SeedERC20Reentrant", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const bobSeed = seedERC20.connect(bob); @@ -77,7 +78,7 @@ describe("SeedERC20Reentrant", async function () { const maliciousReserve = (await Util.basicDeploy( "SeedERC20Reentrant", {} - )) as SeedERC20Reentrant; + )) as SeedERC20Reentrant & Contract; const bobReserve = maliciousReserve.connect(bob); @@ -96,7 +97,7 @@ describe("SeedERC20Reentrant", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; // setup reserve to reentrantly call `seed` method in `_beforeTokenTransfer` hook await maliciousReserve.addReentrantTarget(seedERC20.address); @@ -124,7 +125,7 @@ describe("SeedERC20Reentrant", async function () { const maliciousReserve = (await Util.basicDeploy( "SeedERC20Reentrant", {} - )) as SeedERC20Reentrant; + )) as SeedERC20Reentrant & Contract; const bobReserve = maliciousReserve.connect(bob); @@ -143,7 +144,7 @@ describe("SeedERC20Reentrant", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; const bobSeed = seedERC20.connect(bob); diff --git a/test/Tier/AlwaysTier.sol.ts b/test/Tier/AlwaysTier.sol.ts index 9b9579a81..757dce497 100644 --- a/test/Tier/AlwaysTier.sol.ts +++ b/test/Tier/AlwaysTier.sol.ts @@ -1,5 +1,6 @@ import chai from "chai"; import { solidity } from "ethereum-waffle"; +import type { Contract } from "ethers"; import { ethers } from "hardhat"; import type { AlwaysTier } from "../../typechain/AlwaysTier"; import type { NeverTier } from "../../typechain/NeverTier"; @@ -29,7 +30,7 @@ describe("AlwaysTier", async function () { const alwaysTierFactory = await ethers.getContractFactory("AlwaysTier"); - alwaysTier = (await alwaysTierFactory.deploy()) as AlwaysTier; + alwaysTier = (await alwaysTierFactory.deploy()) as AlwaysTier & Contract; await alwaysTier.deployed(); }); @@ -58,7 +59,7 @@ describe("NeverTier", async function () { const neverTierFactory = await ethers.getContractFactory("NeverTier"); - neverTier = (await neverTierFactory.deploy()) as NeverTier; + neverTier = (await neverTierFactory.deploy()) as NeverTier & Contract; await neverTier.deployed(); }); diff --git a/test/Tier/ERC20BalanceTier.sol.ts b/test/Tier/ERC20BalanceTier.sol.ts index fb66e50d0..0c07ff8bf 100644 --- a/test/Tier/ERC20BalanceTier.sol.ts +++ b/test/Tier/ERC20BalanceTier.sol.ts @@ -1,5 +1,6 @@ import chai from "chai"; import { solidity } from "ethereum-waffle"; +import type { Contract } from "ethers"; import { ethers } from "hardhat"; import type { ERC20BalanceTier } from "../../typechain/ERC20BalanceTier"; import type { ReserveTokenTest } from "../../typechain/ReserveTokenTest"; @@ -28,13 +29,14 @@ const LEVEL_SIZE_LINEAR = ethers.BigNumber.from(1 + eighteenZeros); describe("ERC20BalanceTier", async function () { let owner: any; let alice: any; - let erc20BalanceTier: ERC20BalanceTier; - let reserve: ReserveTokenTest; + let erc20BalanceTier: ERC20BalanceTier & Contract; + let reserve: ReserveTokenTest & Contract; beforeEach(async () => { [owner, alice] = await ethers.getSigners(); - reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest; + reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest & + Contract; const erc20BalanceTierFactory = await ethers.getContractFactory( "ERC20BalanceTier" @@ -42,7 +44,7 @@ describe("ERC20BalanceTier", async function () { erc20BalanceTier = (await erc20BalanceTierFactory.deploy( reserve.address, LEVELS - )) as ERC20BalanceTier; + )) as ERC20BalanceTier & Contract; await erc20BalanceTier.deployed(); }); diff --git a/test/Tier/ERC20TransferTier.sol.ts b/test/Tier/ERC20TransferTier.sol.ts index 4bdcc4e10..557520098 100644 --- a/test/Tier/ERC20TransferTier.sol.ts +++ b/test/Tier/ERC20TransferTier.sol.ts @@ -1,5 +1,6 @@ import chai from "chai"; import { solidity } from "ethereum-waffle"; +import type { Contract } from "ethers"; import { ethers } from "hardhat"; import type { ERC20TransferTier } from "../../typechain/ERC20TransferTier"; import type { ReserveTokenTest } from "../../typechain/ReserveTokenTest"; @@ -29,13 +30,14 @@ describe("ERC20TransferTier", async function () { let owner: any; let alice: any; let bob: any; - let erc20TransferTier: ERC20TransferTier; - let reserve: ReserveTokenTest; + let erc20TransferTier: ERC20TransferTier & Contract; + let reserve: ReserveTokenTest & Contract; beforeEach(async () => { [owner, alice, bob] = await ethers.getSigners(); - reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest; + reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest & + Contract; const erc20TransferTierFactory = await ethers.getContractFactory( "ERC20TransferTier" @@ -44,7 +46,7 @@ describe("ERC20TransferTier", async function () { erc20TransferTier = (await erc20TransferTierFactory.deploy( reserve.address, LEVELS - )) as ERC20TransferTier; + )) as ERC20TransferTier & Contract; await erc20TransferTier.deployed(); }); diff --git a/test/Tier/ReadWriteTier.sol.ts b/test/Tier/ReadWriteTier.sol.ts index 7938438f4..6f4c60e12 100644 --- a/test/Tier/ReadWriteTier.sol.ts +++ b/test/Tier/ReadWriteTier.sol.ts @@ -4,6 +4,7 @@ import { ethers } from "hardhat"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { tierReport, blockNumbersToReport, assertError } from "../Util"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -34,10 +35,13 @@ enum Tier { EIGHT, } -const setup = async (): Promise<[SignerWithAddress[], ReadWriteTier]> => { +const setup = async (): Promise< + [SignerWithAddress[], ReadWriteTier & Contract] +> => { const signers = await ethers.getSigners(); const readWriteTierFactory = await ethers.getContractFactory("ReadWriteTier"); - const readWriteTier = (await readWriteTierFactory.deploy()) as ReadWriteTier; + const readWriteTier = (await readWriteTierFactory.deploy()) as ReadWriteTier & + Contract; await readWriteTier.deployed(); return [signers, readWriteTier]; }; diff --git a/test/Tier/TierByConstruction.sol.ts b/test/Tier/TierByConstruction.sol.ts index d87f3d223..0fc34e76e 100644 --- a/test/Tier/TierByConstruction.sol.ts +++ b/test/Tier/TierByConstruction.sol.ts @@ -5,6 +5,7 @@ import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { TierByConstructionTest } from "../../typechain/TierByConstructionTest"; import type { TierByConstructionClaimTest } from "../../typechain/TierByConstructionClaimTest"; import { assertError } from "../Util"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -13,13 +14,13 @@ describe("TierByConstruction", async function () { let alice: any; let owner: any; let tierByConstructionFactory: any; - let readWriteTier: ReadWriteTier; + let readWriteTier: ReadWriteTier & Contract; let tierByConstruction: TierByConstructionTest; beforeEach(async () => { [owner, alice] = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - readWriteTier = (await tierFactory.deploy()) as ReadWriteTier; + readWriteTier = (await tierFactory.deploy()) as ReadWriteTier & Contract; await readWriteTier.deployed(); // Need to set the tier before construction. @@ -184,15 +185,15 @@ describe("TierByConstruction", async function () { describe("TierByConstructionClaim", async function () { let owner: any; - let readWriteTier: ReadWriteTier; - let tierByConstructionClaim: TierByConstructionClaimTest; + let readWriteTier: ReadWriteTier & Contract; + let tierByConstructionClaim: TierByConstructionClaimTest & Contract; let tierByConstructionClaimFactory: any; before(async () => { [owner] = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - readWriteTier = (await tierFactory.deploy()) as ReadWriteTier; + readWriteTier = (await tierFactory.deploy()) as ReadWriteTier & Contract; await readWriteTier.deployed(); tierByConstructionClaimFactory = await ethers.getContractFactory( @@ -200,7 +201,7 @@ describe("TierByConstructionClaim", async function () { ); tierByConstructionClaim = (await tierByConstructionClaimFactory.deploy( readWriteTier.address - )) as TierByConstructionClaimTest; + )) as TierByConstructionClaimTest & Contract; await tierByConstructionClaim.deployed(); }); @@ -217,7 +218,7 @@ describe("TierByConstructionClaim", async function () { it("should enter the function and mint 100 tokens if the owner has tier 4", async function () { tierByConstructionClaim = (await tierByConstructionClaimFactory.deploy( readWriteTier.address - )) as TierByConstructionClaimTest; + )) as TierByConstructionClaimTest & Contract; await tierByConstructionClaim.deployed(); await tierByConstructionClaim.claim(owner.address, []); diff --git a/test/Tier/TierByContructionClaim.sol.ts b/test/Tier/TierByContructionClaim.sol.ts index a64db7c77..1862193b8 100644 --- a/test/Tier/TierByContructionClaim.sol.ts +++ b/test/Tier/TierByContructionClaim.sol.ts @@ -1,5 +1,6 @@ import chai from "chai"; import { solidity } from "ethereum-waffle"; +import type { Contract } from "ethers"; import { ethers } from "hardhat"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { TierByConstructionClaim } from "../../typechain/TierByConstructionClaim"; @@ -24,13 +25,13 @@ enum Tier { describe("TierByConstructionClaim", async function () { let alice: any; let owner: any; - let readWriteTier: ReadWriteTier; + let readWriteTier: ReadWriteTier & Contract; let tierByConstructionClaimFactory: any; beforeEach(async () => { [owner, alice] = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - readWriteTier = (await tierFactory.deploy()) as ReadWriteTier; + readWriteTier = (await tierFactory.deploy()) as ReadWriteTier & Contract; await readWriteTier.deployed(); // Need to set the tier before construction. @@ -167,7 +168,7 @@ describe("TierByConstructionClaim", async function () { const tierByConstructionClaimTest = (await tierByConstructionClaimTestFactory.deploy( readWriteTier.address - )) as TierByConstructionClaimTest; + )) as TierByConstructionClaimTest & Contract; await tierByConstructionClaimTest.deployed(); diff --git a/test/Tier/TierUtil.sol.ts b/test/Tier/TierUtil.sol.ts index 872152f17..d836a5835 100644 --- a/test/Tier/TierUtil.sol.ts +++ b/test/Tier/TierUtil.sol.ts @@ -5,6 +5,7 @@ import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { TierUtilTest } from "../../typechain/TierUtilTest"; import type { ReserveTokenTest } from "../../typechain/ReserveTokenTest"; import { assertError, basicDeploy, zeroPad32, zeroPad4 } from "../Util"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -24,20 +25,22 @@ enum Tier { describe("TierUtil", async function () { let owner: any; let signer1: any; - let readWriteTier: ReadWriteTier; - let reserve: ReserveTokenTest; - let tierUtil: TierUtilTest; + let readWriteTier: ReadWriteTier & Contract; + let reserve: ReserveTokenTest & Contract; + let tierUtil: TierUtilTest & Contract; beforeEach(async () => { [owner, signer1] = await ethers.getSigners(); const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - readWriteTier = (await tierFactory.deploy()) as ReadWriteTier; + readWriteTier = (await tierFactory.deploy()) as ReadWriteTier & Contract; await readWriteTier.deployed(); - tierUtil = (await basicDeploy("TierUtilTest", {})) as TierUtilTest; + tierUtil = (await basicDeploy("TierUtilTest", {})) as TierUtilTest & + Contract; - reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest; + reserve = (await basicDeploy("ReserveTokenTest", {})) as ReserveTokenTest & + Contract; }); it("should correctly return the highest achieved tier relative to a given report and block number", async () => { diff --git a/test/Tier/ValueTier.sol.ts b/test/Tier/ValueTier.sol.ts index 222cf419e..58a0e6787 100644 --- a/test/Tier/ValueTier.sol.ts +++ b/test/Tier/ValueTier.sol.ts @@ -1,5 +1,6 @@ import chai from "chai"; import { solidity } from "ethereum-waffle"; +import type { Contract } from "ethers"; import { ethers } from "hardhat"; import type { ValueTierTest } from "../../typechain/ValueTierTest"; import { assertError, basicDeploy, eighteenZeros } from "../Util"; @@ -27,14 +28,15 @@ describe("ValueTierTest", async function () { let owner: any; let alice: any; let bob: any; - let valueTier: ValueTierTest; + let valueTier: ValueTierTest & Contract; beforeEach(async () => { [owner, alice, bob] = await ethers.getSigners(); const valueTierFactory = await ethers.getContractFactory("ValueTierTest"); - valueTier = (await valueTierFactory.deploy(LEVELS)) as ValueTierTest; + valueTier = (await valueTierFactory.deploy(LEVELS)) as ValueTierTest & + Contract; await valueTier.deployed(); }); diff --git a/test/Tier/VerifyTier.sol.ts b/test/Tier/VerifyTier.sol.ts index d8e95d169..d3cd57e65 100644 --- a/test/Tier/VerifyTier.sol.ts +++ b/test/Tier/VerifyTier.sol.ts @@ -4,6 +4,7 @@ import { solidity } from "ethereum-waffle"; import { ethers } from "hardhat"; import type { VerifyTier } from "../../typechain/VerifyTier"; import type { Verify } from "../../typechain/Verify"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -32,9 +33,12 @@ describe("Verify", async function () { const tierFactory = await ethers.getContractFactory("VerifyTier"); - const verify = (await verifyFactory.deploy(admin.address)) as Verify; + const verify = (await verifyFactory.deploy(admin.address)) as Verify & + Contract; - const verifyTier = (await tierFactory.deploy(verify.address)) as VerifyTier; + const verifyTier = (await tierFactory.deploy( + verify.address + )) as VerifyTier & Contract; await verify.grantRole(await verify.APPROVER(), verifier.address); await verify.grantRole(await verify.BANNER(), verifier.address); diff --git a/test/Trust/Trust.sol.ts b/test/Trust/Trust.sol.ts index eaa50ab30..8fa596301 100644 --- a/test/Trust/Trust.sol.ts +++ b/test/Trust/Trust.sol.ts @@ -10,6 +10,7 @@ import { factoriesDeploy } from "../Util"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; import type { ConfigurableRightsPool } from "../../typechain/ConfigurableRightsPool"; import type { BPool } from "../../typechain/BPool"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -58,10 +59,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -128,17 +129,17 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const crp = new ethers.Contract( await pool.crp(), (await artifacts.readArtifact("ConfigurableRightsPool")).abi, creator - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; // seeder needs some cash, give enough to seeder await reserve.transfer(seeder.address, reserveInit); @@ -147,7 +148,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -160,7 +161,7 @@ describe("Trust", async function () { await crp.bPool(), (await artifacts.readArtifact("BPool")).abi, creator - ) as BPool; + ) as BPool & Contract; const swapReserveForTokens = async (signer, spend) => { // give signer some reserve @@ -220,10 +221,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -290,17 +291,17 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const crp = new ethers.Contract( await pool.crp(), (await artifacts.readArtifact("ConfigurableRightsPool")).abi, creator - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; // seeder needs some cash, give enough to seeder await reserve.transfer(seeder.address, reserveInit); @@ -309,7 +310,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -322,7 +323,7 @@ describe("Trust", async function () { await crp.bPool(), (await artifacts.readArtifact("BPool")).abi, creator - ) as BPool; + ) as BPool & Contract; const swapReserveForTokens = async (signer, spend) => { // give signer some reserve @@ -369,10 +370,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -442,7 +443,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -451,12 +452,12 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -516,10 +517,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -589,7 +590,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -598,12 +599,12 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -686,10 +687,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -753,7 +754,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; assert( (await token.currentPhase()) === Phase.ZERO, @@ -767,7 +768,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -776,7 +777,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -817,10 +818,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -884,7 +885,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; let [crp, bPool] = await Util.poolContracts(signers, pool); assert( @@ -899,7 +900,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -934,10 +935,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1001,12 +1002,12 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; // seeder needs some cash, give enough to seeder await reserve.transfer(seeder.address, reserveInit); @@ -1023,7 +1024,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -1108,10 +1109,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1183,7 +1184,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder transfers insufficient reserve liquidity await reserveSeeder.transfer(await trust.pool(), reserveInit.sub(1)); @@ -1193,7 +1194,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, signers[2] - ) as Trust; + ) as Trust & Contract; await Util.assertError( async () => await pool2.startDutchAuction({ gasLimit: 100000000 }), @@ -1218,10 +1219,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1293,14 +1294,14 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; await reserveSeeder.transfer(await trust.pool(), reserveInit); const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -1315,7 +1316,7 @@ describe("Trust", async function () { trust.address, (await artifacts.readArtifact("Trust")).abi, signers[2] - ) as Trust; + ) as Trust & Contract; // other user attempts to immediately end raise await Util.assertError( @@ -1335,42 +1336,42 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve3 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve4 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve5 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve6 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve7 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve8 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve9 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1438,7 +1439,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // creator can add redeemable via proxy method on trust contract await token.addRedeemable(reserve2.address); @@ -1482,10 +1483,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1551,7 +1552,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // the trust renounces the admin role after deploying the redeemable token. assert( @@ -1571,7 +1572,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signers[2] - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // non-creator cannot add unfreezable, (no one but admin can add receiver) await Util.assertError( @@ -1592,10 +1593,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1665,7 +1666,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; await reserveSeeder.transfer(await trust.pool(), reserveInit); const blockBeforeRaiseSetup = await ethers.provider.getBlockNumber(); @@ -1676,7 +1677,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -1710,10 +1711,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1788,7 +1789,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -1803,13 +1804,13 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -2020,12 +2021,12 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signers[2] - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const token2 = new ethers.Contract( await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signers[3] - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // redeem all await token1.redeem(signer1EndingTokenBalance); @@ -2087,10 +2088,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -2160,7 +2161,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, signers[1] - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -2175,13 +2176,13 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -2377,12 +2378,12 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signers[2] - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const token2 = new ethers.Contract( await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signers[3] - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // redeem all await token1.redeem(signer1EndingTokenBalance); @@ -2441,10 +2442,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -2514,7 +2515,7 @@ describe("Trust", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; const seederReserveBeforeStart = await reserve.balanceOf(seeder.address); @@ -2522,7 +2523,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await Util.assertError( async () => await pool.startDutchAuction({ gasLimit: 100000000 }), @@ -2553,10 +2554,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -2627,14 +2628,14 @@ describe("Trust", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; await reserveSeeder.transfer(await trust.pool(), reserveInit); const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000, @@ -2646,7 +2647,7 @@ describe("Trust", async function () { trust.address, trust.interface, signer1 - ) as Trust; + ) as Trust & Contract; // some other signer triggers trust to exit before phase change, should fail await Util.assertError( async () => await trust2.anonEndDistribution(), @@ -2682,10 +2683,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -2753,7 +2754,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000, @@ -2775,7 +2776,7 @@ describe("Trust", async function () { await pool.crp(), (await artifacts.readArtifact("ConfigurableRightsPool")).abi, signer1 - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; let i = 0; while (i < 10) { @@ -2833,7 +2834,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signer1 - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await token1.redeem(await token1.balanceOf(signer1.address)); const reserveBalance1 = await reserve.balanceOf(signer1.address); const expectedBalance1 = "1829853948"; @@ -2846,7 +2847,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signer2 - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await token2.redeem(await token2.balanceOf(signer2.address)); const reserveBalance2 = await reserve.balanceOf(signer2.address); const expectedBalance2 = "170146068"; @@ -2866,10 +2867,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -2939,7 +2940,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000, @@ -3004,7 +3005,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signer1 - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await token1.redeem(await token1.balanceOf(signer1.address)); const reserveBalance1 = await reserve.balanceOf(signer1.address); const expectedBalance1 = "841344575"; @@ -3017,7 +3018,7 @@ describe("Trust", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, signer2 - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await token2.redeem(await token1.balanceOf(signer2.address)); const reserveBalance2 = await reserve.balanceOf(signer2.address); const expectedBalance2 = "2158655434"; @@ -3037,10 +3038,10 @@ describe("Trust", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -3108,7 +3109,7 @@ describe("Trust", async function () { await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000, diff --git a/test/Trust/TrustConstruction.sol.ts b/test/Trust/TrustConstruction.sol.ts index ad82dbd31..4892c4ba7 100644 --- a/test/Trust/TrustConstruction.sol.ts +++ b/test/Trust/TrustConstruction.sol.ts @@ -4,7 +4,7 @@ import { solidity } from "ethereum-waffle"; import type { Trust } from "../../typechain/Trust"; import type { ReserveToken } from "../../typechain/ReserveToken"; import * as Util from "../Util"; -import { utils } from "ethers"; +import type { Contract } from "ethers"; import type { BigNumber } from "ethers"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; @@ -77,10 +77,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -193,10 +193,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -260,7 +260,7 @@ describe("TrustConstruction", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; assert((await redeemableERC20.balanceOf(trust.address)).eq(0)); assert( @@ -278,10 +278,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -351,7 +351,7 @@ describe("TrustConstruction", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; let [crp, bPool] = await Util.poolContracts(signers, pool); @@ -391,7 +391,7 @@ describe("TrustConstruction", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -418,10 +418,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -498,10 +498,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -578,10 +578,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -655,10 +655,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -804,7 +804,7 @@ describe("TrustConstruction", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -816,7 +816,7 @@ describe("TrustConstruction", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; assert( raiseProgressSeeded.distributionStatus === DistributionStatus.SEEDED, @@ -867,7 +867,7 @@ describe("TrustConstruction", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; let [crp, bPool] = await Util.poolContracts(signers, pool); @@ -998,10 +998,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1081,10 +1081,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1164,10 +1164,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.GOLD; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1233,7 +1233,7 @@ describe("TrustConstruction", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; assert( (await token.minimumTier()) === minimumStatus, @@ -1251,10 +1251,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1320,7 +1320,7 @@ describe("TrustConstruction", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; assert( (await token.totalSupply()).eq(totalTokenSupply), @@ -1338,14 +1338,14 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1411,7 +1411,7 @@ describe("TrustConstruction", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; assert( (await token.getRedeemables())[0] === reserve.address, @@ -1441,10 +1441,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1518,10 +1518,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1595,10 +1595,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1672,10 +1672,10 @@ describe("TrustConstruction", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); diff --git a/test/Trust/TrustDistribute.sol.ts b/test/Trust/TrustDistribute.sol.ts index 0275ff6d6..29c3cf79d 100644 --- a/test/Trust/TrustDistribute.sol.ts +++ b/test/Trust/TrustDistribute.sol.ts @@ -4,7 +4,7 @@ import { solidity } from "ethereum-waffle"; import type { Trust } from "../../typechain/Trust"; import type { ReserveToken } from "../../typechain/ReserveToken"; import * as Util from "../Util"; -import { utils } from "ethers"; +import type { Contract } from "ethers"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; @@ -53,10 +53,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -127,7 +127,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -136,12 +136,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -196,10 +196,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -277,10 +277,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -351,7 +351,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -360,12 +360,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -421,10 +421,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -502,7 +502,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -516,12 +516,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -598,10 +598,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -678,7 +678,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -692,7 +692,7 @@ describe("TrustDistribute", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -744,10 +744,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -818,7 +818,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer funds before pool can init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -827,12 +827,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -901,10 +901,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -974,7 +974,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool can init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -983,7 +983,7 @@ describe("TrustDistribute", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -1033,10 +1033,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1109,7 +1109,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -1118,12 +1118,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -1187,10 +1187,10 @@ describe("TrustDistribute", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -1263,7 +1263,7 @@ describe("TrustDistribute", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -1272,12 +1272,12 @@ describe("TrustDistribute", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); diff --git a/test/Trust/TrustReentrant.sol.ts b/test/Trust/TrustReentrant.sol.ts index 685cc92d4..41cf0ee07 100644 --- a/test/Trust/TrustReentrant.sol.ts +++ b/test/Trust/TrustReentrant.sol.ts @@ -11,6 +11,7 @@ import type { SeedERC20Reentrant } from "../../typechain/SeedERC20Reentrant"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; import type { ConfigurableRightsPool } from "../../typechain/ConfigurableRightsPool"; import { factoriesDeploy } from "../Util"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -38,10 +39,10 @@ describe("TrustReentrant", async function () { const maliciousReserve = (await Util.basicDeploy( "TrustReentrant", {} - )) as TrustReentrant; + )) as TrustReentrant & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -108,17 +109,17 @@ describe("TrustReentrant", async function () { await trust.token(), (await artifacts.readArtifact("RedeemableERC20")).abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), (await artifacts.readArtifact("RedeemableERC20Pool")).abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const crp = new ethers.Contract( await pool.crp(), (await artifacts.readArtifact("ConfigurableRightsPool")).abi, creator - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; await maliciousReserve.addReentrantTarget(trust.address); @@ -129,7 +130,7 @@ describe("TrustReentrant", async function () { maliciousReserve.address, maliciousReserve.interface, seeder - ) as SeedERC20Reentrant; + ) as SeedERC20Reentrant & Contract; // seeder must transfer funds to pool await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -142,7 +143,7 @@ describe("TrustReentrant", async function () { await crp.bPool(), (await artifacts.readArtifact("BPool")).abi, creator - ) as BPool; + ) as BPool & Contract; const swapReserveForTokens = async (signer, spend) => { // give signer some reserve diff --git a/test/Trust/TrustRewards.sol.ts b/test/Trust/TrustRewards.sol.ts index a20da4b89..46c87ecf6 100644 --- a/test/Trust/TrustRewards.sol.ts +++ b/test/Trust/TrustRewards.sol.ts @@ -4,7 +4,7 @@ import { solidity } from "ethereum-waffle"; import type { Trust } from "../../typechain/Trust"; import type { ReserveToken } from "../../typechain/ReserveToken"; import * as Util from "../Util"; -import { utils } from "ethers"; +import type { Contract } from "ethers"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; @@ -64,18 +64,18 @@ describe("TrustRewards", async function () { const reserveA = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserveB = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserveC = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -141,7 +141,7 @@ describe("TrustRewards", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await token.connect(creator).addRedeemable(reserveB.address); @@ -182,22 +182,22 @@ describe("TrustRewards", async function () { const reserveA = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserveB = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserveC = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserveD = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -273,12 +273,12 @@ describe("TrustRewards", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -495,10 +495,10 @@ describe("TrustRewards", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -568,7 +568,7 @@ describe("TrustRewards", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -577,12 +577,12 @@ describe("TrustRewards", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -693,10 +693,10 @@ describe("TrustRewards", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -767,7 +767,7 @@ describe("TrustRewards", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -776,12 +776,12 @@ describe("TrustRewards", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -843,10 +843,10 @@ describe("TrustRewards", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -912,17 +912,17 @@ describe("TrustRewards", async function () { const reserve2 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const reserve3 = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const token = new ethers.Contract( await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; await Util.assertError( async () => await token.connect(deployer).addRedeemable(reserve2.address), diff --git a/test/Trust/TrustSeed.sol.ts b/test/Trust/TrustSeed.sol.ts index 368bf60fe..cb70f4c52 100644 --- a/test/Trust/TrustSeed.sol.ts +++ b/test/Trust/TrustSeed.sol.ts @@ -9,6 +9,7 @@ import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; import type { Trust } from "../../typechain/Trust"; import { factoriesDeploy } from "../Util"; +import type { Contract } from "ethers"; chai.use(solidity); const { expect, assert } = chai; @@ -56,10 +57,10 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -128,7 +129,7 @@ describe("TrustSeed", async function () { seeder, seedERC20Json.abi, signers[0] - ) as SeedERC20; + ) as SeedERC20 & Contract; const seeder1Units = 4; @@ -210,7 +211,7 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const seedFactory = await ethers.getContractFactory("SeedERC20"); @@ -237,7 +238,7 @@ describe("TrustSeed", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20; + })) as SeedERC20 & Contract; await seederContract.deployed(); @@ -256,7 +257,7 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const seedFactory = await ethers.getContractFactory("SeedERC20"); @@ -285,7 +286,7 @@ describe("TrustSeed", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20, + })) as SeedERC20 & Contract, "revert UNITS_0", "seeder contract was wrongly constructed with seedUnits set to 0" ); @@ -299,7 +300,7 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const seedFactory = await ethers.getContractFactory("SeedERC20"); @@ -326,7 +327,7 @@ describe("TrustSeed", async function () { cooldownDuration, name: "seed", symbol: "SD", - })) as SeedERC20, + })) as SeedERC20 & Contract, "revert PRICE_0", "seeder contract was wrongly constructed with seedPrice set to 0" ); @@ -343,10 +344,10 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -415,7 +416,7 @@ describe("TrustSeed", async function () { seeder, seedERC20Json.abi, signers[0] - ) as SeedERC20; + ) as SeedERC20 & Contract; const seeder1Units = 4; const seeder2Units = 6; @@ -464,10 +465,10 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -535,7 +536,7 @@ describe("TrustSeed", async function () { await trust.seeder(), seedERC20Json.abi, signers[0] - ) as SeedERC20; + ) as SeedERC20 & Contract; const seeder1Units = 4; const seeder2Units = 6; @@ -559,7 +560,7 @@ describe("TrustSeed", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await Util.assertError( async () => await pool.startDutchAuction({ gasLimit: 100000000 }), @@ -583,10 +584,10 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -661,18 +662,18 @@ describe("TrustSeed", async function () { seeder, seedERC20Json.abi, signers[0] - ) as SeedERC20; + ) as SeedERC20 & Contract; const token = new ethers.Contract( await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const recipient = await trust.pool(); @@ -873,10 +874,10 @@ describe("TrustSeed", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -949,13 +950,13 @@ describe("TrustSeed", async function () { seeder, seedERC20Json.abi, signers[0] - ) as SeedERC20; + ) as SeedERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const seeder1Units = 4; const seeder2Units = 6; diff --git a/test/Trust/TrustTrade.sol.ts b/test/Trust/TrustTrade.sol.ts index 3259dd112..6c6053ff9 100644 --- a/test/Trust/TrustTrade.sol.ts +++ b/test/Trust/TrustTrade.sol.ts @@ -4,7 +4,7 @@ import { solidity } from "ethereum-waffle"; import type { Trust } from "../../typechain/Trust"; import type { ReserveToken } from "../../typechain/ReserveToken"; import * as Util from "../Util"; -import { utils } from "ethers"; +import type { Contract } from "ethers"; import type { ReadWriteTier } from "../../typechain/ReadWriteTier"; import type { RedeemableERC20Pool } from "../../typechain/RedeemableERC20Pool"; import type { RedeemableERC20 } from "../../typechain/RedeemableERC20"; @@ -44,10 +44,10 @@ describe("TrustTrade", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.GOLD; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -126,7 +126,7 @@ describe("TrustTrade", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -135,12 +135,12 @@ describe("TrustTrade", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -189,10 +189,10 @@ describe("TrustTrade", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -261,7 +261,7 @@ describe("TrustTrade", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -270,7 +270,7 @@ describe("TrustTrade", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -278,7 +278,7 @@ describe("TrustTrade", async function () { await pool.crp(), crpJson.abi, creator - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; const expectedRights = [false, false, true, true, false, false]; @@ -313,10 +313,10 @@ describe("TrustTrade", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -385,7 +385,7 @@ describe("TrustTrade", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -394,12 +394,12 @@ describe("TrustTrade", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; const pool = new ethers.Contract( await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; await pool.startDutchAuction({ gasLimit: 100000000 }); @@ -565,10 +565,10 @@ describe("TrustTrade", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.GOLD; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -642,13 +642,13 @@ describe("TrustTrade", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; const token = new ethers.Contract( await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; // seeder needs some cash, give enough to seeder await reserve.transfer(seeder.address, reserveInit); @@ -657,7 +657,7 @@ describe("TrustTrade", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -752,10 +752,10 @@ describe("TrustTrade", async function () { const reserve = (await Util.basicDeploy( "ReserveToken", {} - )) as ReserveToken; + )) as ReserveToken & Contract; const tierFactory = await ethers.getContractFactory("ReadWriteTier"); - const tier = (await tierFactory.deploy()) as ReadWriteTier; + const tier = (await tierFactory.deploy()) as ReadWriteTier & Contract; const minimumStatus = Tier.NIL; const { trustFactory } = await factoriesDeploy(crpFactory, bFactory); @@ -903,7 +903,7 @@ describe("TrustTrade", async function () { await trust.pool(), poolJson.abi, creator - ) as RedeemableERC20Pool; + ) as RedeemableERC20Pool & Contract; // seeder needs some cash, give enough to seeder await reserve.transfer(seeder.address, reserveInit); @@ -912,7 +912,7 @@ describe("TrustTrade", async function () { reserve.address, reserve.interface, seeder - ) as ReserveToken; + ) as ReserveToken & Contract; // seeder must transfer seed funds before pool init await reserveSeeder.transfer(await trust.pool(), reserveInit); @@ -923,7 +923,7 @@ describe("TrustTrade", async function () { await trust.token(), redeemableTokenJson.abi, creator - ) as RedeemableERC20; + ) as RedeemableERC20 & Contract; let [crp, bPool] = await Util.poolContracts(signers, pool); const bPool1 = bPool.connect(signer1); diff --git a/test/Util.ts b/test/Util.ts index c41a51a7e..404b06d11 100644 --- a/test/Util.ts +++ b/test/Util.ts @@ -9,7 +9,7 @@ import type { SeedERC20Factory } from "../typechain/SeedERC20Factory"; import type { RedeemableERC20Pool } from "../typechain/RedeemableERC20Pool"; import type { ConfigurableRightsPool } from "../typechain/ConfigurableRightsPool"; import type { BPool } from "../typechain/BPool"; -import type { BigNumber } from "ethers"; +import type { BigNumber, Contract } from "ethers"; import type { Trust } from "../typechain/Trust"; import type { SmartPoolManager } from "../typechain/SmartPoolManager"; @@ -48,7 +48,9 @@ export const basicDeploy = async (name, libs) => { return contract; }; -export const balancerDeploy = async (): Promise<[CRPFactory, BFactory]> => { +export const balancerDeploy = async (): Promise< + [CRPFactory & Contract, BFactory & Contract] +> => { let rightsManager; if (rightsManagerAddress) { rightsManager = new ethers.Contract( @@ -69,31 +71,31 @@ export const balancerDeploy = async (): Promise<[CRPFactory, BFactory]> => { balancerSafeMath = await basicDeploy("BalancerSafeMath", {}); } - let smartPoolManager: SmartPoolManager; + let smartPoolManager: SmartPoolManager & Contract; if (smartPoolManagerAddress) { smartPoolManager = new ethers.Contract( smartPoolManagerAddress, (await artifacts.readArtifact("SmartPoolManager")).abi - ) as SmartPoolManager; + ) as SmartPoolManager & Contract; } else { smartPoolManager = (await basicDeploy( "SmartPoolManager", {} - )) as SmartPoolManager; + )) as SmartPoolManager & Contract; } - let crpFactory: CRPFactory; + let crpFactory: CRPFactory & Contract; if (crpFactoryAddress) { crpFactory = new ethers.Contract( crpFactoryAddress, (await artifacts.readArtifact("CRPFactory")).abi - ) as CRPFactory; + ) as CRPFactory & Contract; } else { crpFactory = (await basicDeploy("CRPFactory", { RightsManager: rightsManager.address, BalancerSafeMath: balancerSafeMath.address, SmartPoolManager: smartPoolManager.address, - })) as CRPFactory; + })) as CRPFactory & Contract; } let bFactory; @@ -101,30 +103,31 @@ export const balancerDeploy = async (): Promise<[CRPFactory, BFactory]> => { bFactory = new ethers.Contract( bFactoryAddress, (await artifacts.readArtifact("BFactory")).abi - ) as BFactory; + ) as BFactory & Contract; } else { - bFactory = (await basicDeploy("BFactory", {})) as BFactory; + bFactory = (await basicDeploy("BFactory", {})) as BFactory & Contract; } return [crpFactory, bFactory]; }; export interface Factories { - redeemableERC20Factory: RedeemableERC20Factory; - redeemableERC20PoolFactory: RedeemableERC20PoolFactory; - seedERC20Factory: SeedERC20Factory; - trustFactory: TrustFactory; + redeemableERC20Factory: RedeemableERC20Factory & Contract; + redeemableERC20PoolFactory: RedeemableERC20PoolFactory & Contract; + seedERC20Factory: SeedERC20Factory & Contract; + trustFactory: TrustFactory & Contract; } export const factoriesDeploy = async ( - crpFactory: CRPFactory, - balancerFactory: BFactory + crpFactory: CRPFactory & Contract, + balancerFactory: BFactory & Contract ): Promise => { const redeemableERC20FactoryFactory = await ethers.getContractFactory( "RedeemableERC20Factory" ); const redeemableERC20Factory = - (await redeemableERC20FactoryFactory.deploy()) as RedeemableERC20Factory; + (await redeemableERC20FactoryFactory.deploy()) as RedeemableERC20Factory & + Contract; await redeemableERC20Factory.deployed(); const redeemableERC20PoolFactoryFactory = await ethers.getContractFactory( @@ -134,14 +137,14 @@ export const factoriesDeploy = async ( (await redeemableERC20PoolFactoryFactory.deploy({ crpFactory: crpFactory.address, balancerFactory: balancerFactory.address, - })) as RedeemableERC20PoolFactory; + })) as RedeemableERC20PoolFactory & Contract; await redeemableERC20PoolFactory.deployed(); const seedERC20FactoryFactory = await ethers.getContractFactory( "SeedERC20Factory" ); const seedERC20Factory = - (await seedERC20FactoryFactory.deploy()) as SeedERC20Factory; + (await seedERC20FactoryFactory.deploy()) as SeedERC20Factory & Contract; await seedERC20Factory.deployed(); const trustFactoryFactory = await ethers.getContractFactory("TrustFactory"); @@ -149,7 +152,7 @@ export const factoriesDeploy = async ( redeemableERC20Factory: redeemableERC20Factory.address, redeemableERC20PoolFactory: redeemableERC20PoolFactory.address, seedERC20Factory: seedERC20Factory.address, - })) as TrustFactory; + })) as TrustFactory & Contract; await trustFactory.deployed(); return { @@ -205,28 +208,29 @@ export const assertError = async (f: Function, s: string, e: string) => { export const poolContracts = async ( signers: any, - pool: RedeemableERC20Pool -): Promise<[ConfigurableRightsPool, BPool]> => { + pool: RedeemableERC20Pool & Contract +): Promise<[ConfigurableRightsPool & Contract, BPool & Contract]> => { const crp = new ethers.Contract( await pool.crp(), (await artifacts.readArtifact("ConfigurableRightsPool")).abi, signers[0] - ) as ConfigurableRightsPool; + ) as ConfigurableRightsPool & Contract; const bPool = new ethers.Contract( await crp.bPool(), (await artifacts.readArtifact("BPool")).abi, signers[0] - ) as BPool; + ) as BPool & Contract; return [crp, bPool]; }; export const trustDeploy = async ( - trustFactory: TrustFactory, + trustFactory: TrustFactory & Contract, creator: any, ...args -): Promise => { +): Promise => { const tx = await trustFactory[ "createChild((address,uint256,address,uint256,uint16,uint16,uint256),(string,string,address,uint8,uint256),(address,uint256,uint256,uint256,uint256))" + // @ts-ignore ](...args); const receipt = await tx.wait(); @@ -241,7 +245,7 @@ export const trustDeploy = async ( ), (await artifacts.readArtifact("Trust")).abi, creator - ) as Trust; + ) as Trust & Contract; if (!ethers.utils.isAddress(trust.address)) { throw new Error( diff --git a/tsconfig.json b/tsconfig.json index c545e60da..419dedf53 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "@tsconfig/svelte/tsconfig.json", - "include": ["src/**/*"], + "include": ["./test"], "exclude": ["node_modules/*", "__sapper__/*", "public/*"], "compilerOptions": { "target": "ES2020" - } + }, + "files": ["./hardhat.config.ts"] }