Skip to content

Commit

Permalink
Fix linting & run linter in CI (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke committed Jun 22, 2021
1 parent 5c1ac70 commit 21013c9
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- run:
name: Transpile Contracts
command: yarn build
- run:
name: Lint
command: yarn lint
- save_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
paths:
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"transpile-dist": "tsc -p tsconfig.dist.json",
"typechain": "npx hardhat typechain"
},
"resolutions": {
"ganache-cli": "6.12.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/SetProtocol/index-coop-contracts.git"
Expand Down Expand Up @@ -79,8 +82,8 @@
"solidity-coverage": "^0.7.13",
"ts-generator": "^0.1.1",
"ts-node": "^8.10.1",
"tslint": "^5.8.0",
"tslint-eslint-rules": "^5.3.1",
"tslint": "^6.1.3",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.9.3"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion tasks/subtasks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
TASK_COMPILE_SOLIDITY_COMPILE,
TASK_TEST_SETUP_TEST_ENVIRONMENT,
TASK_COMPILE_SOLIDITY_GET_ARTIFACT_FROM_COMPILATION_OUTPUT,
} from "hardhat/builtin-tasks/task-names";

Expand Down
38 changes: 20 additions & 18 deletions test/token/otcEscrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("OtcEscrow", () => {
let owner: Account;
let indexGov: Account;
let investor: Account;

let deployer: DeployHelper;
let index: IndexToken;
let usdc: StandardTokenMock;
Expand All @@ -33,15 +33,15 @@ describe("OtcEscrow", () => {
[
owner,
indexGov,
investor
investor,
] = await getAccounts();

deployer = new DeployHelper(owner.wallet);

index = await deployer.token.deployIndexToken(owner.address);
await index.transfer(indexGov.address, ether(1000));
usdc = await deployer.mocks.deployStandardTokenMock(owner.address, 6);
await usdc.transfer(investor.address, BigNumber.from(1_000_000 * 10**6));
await usdc.transfer(investor.address, BigNumber.from(1_000_000 * 10 ** 6));
});

addSnapshotBeforeRestoreAfterEach();
Expand All @@ -55,11 +55,11 @@ describe("OtcEscrow", () => {
let subjectIndexAmount: BigNumber;

beforeEach(async () => {
const now = await getLastBlockTimestamp()
const now = await getLastBlockTimestamp();
subjectVestingStart = now;
subjectVestingCliff = now.add(60 * 60 * 24 * 183);
subjectVestingEnd = now.add(60 * 60 * 24 * 547);
subjectUSDCAmount = BigNumber.from(100_000 * 10**6);
subjectUSDCAmount = BigNumber.from(100_000 * 10 ** 6);
subjectIndexAmount = ether(100);
});

Expand Down Expand Up @@ -102,11 +102,11 @@ describe("OtcEscrow", () => {
let subjectIndexAmount: BigNumber;

beforeEach(async () => {
const now = await getLastBlockTimestamp()
const now = await getLastBlockTimestamp();
subjectVestingStart = now.add(10);
subjectVestingCliff = now.add(60 * 60 * 24 * 183);
subjectVestingEnd = now.add(60 * 60 * 24 * 547);
subjectUSDCAmount = BigNumber.from(100_000 * 10**6);
subjectUSDCAmount = BigNumber.from(100_000 * 10 ** 6);
subjectIndexAmount = ether(100);

subjectOtcEscrow = await deployer.token.deployOtcEscrow(
Expand All @@ -120,7 +120,7 @@ describe("OtcEscrow", () => {
usdc.address,
index.address
);

await index.connect(indexGov.wallet).transfer(subjectOtcEscrow.address, subjectIndexAmount);
await usdc.connect(investor.wallet).approve(subjectOtcEscrow.address, subjectUSDCAmount);
});
Expand Down Expand Up @@ -149,6 +149,7 @@ describe("OtcEscrow", () => {
it("it should transfer index to the vesting contract", async () => {
await subject();

// tslint:disable-next-line:no-null-keyword
const vestingDeployed = (await subjectOtcEscrow.queryFilter(subjectOtcEscrow.filters.VestingDeployed(null)))[0];
const vestingAddress = vestingDeployed.args?.vesting;

Expand All @@ -158,6 +159,7 @@ describe("OtcEscrow", () => {
it("it should set the state variables of the vesting contract correctly", async () => {
await subject();

// tslint:disable-next-line:no-null-keyword
const vestingDeployed = (await subjectOtcEscrow.queryFilter(subjectOtcEscrow.filters.VestingDeployed(null)))[0];
const vestingAddress = vestingDeployed.args?.vesting;

Expand Down Expand Up @@ -202,7 +204,7 @@ describe("OtcEscrow", () => {
usdc.address,
index.address
);

await index.connect(indexGov.wallet).transfer(subjectOtcEscrow.address, ether(50));
await usdc.connect(investor.wallet).approve(subjectOtcEscrow.address, subjectUSDCAmount);
});
Expand All @@ -224,9 +226,9 @@ describe("OtcEscrow", () => {
});

context("when the sender does not have enough USDC", async () => {

beforeEach(async () => {

subjectOtcEscrow = await deployer.token.deployOtcEscrow(
await getRandomAddress(),
indexGov.address,
Expand All @@ -238,7 +240,7 @@ describe("OtcEscrow", () => {
usdc.address,
index.address
);

await index.connect(indexGov.wallet).transfer(subjectOtcEscrow.address, subjectIndexAmount);
await usdc.connect(investor.wallet).approve(subjectOtcEscrow.address, subjectUSDCAmount);
});
Expand All @@ -259,7 +261,7 @@ describe("OtcEscrow", () => {
}

it("should revert", async () => {

await expect(subject()).to.be.revertedWith("swap already executed");
});
});
Expand All @@ -275,11 +277,11 @@ describe("OtcEscrow", () => {
let subjectIndexAmount: BigNumber;

beforeEach(async () => {
const now = await getLastBlockTimestamp()
const now = await getLastBlockTimestamp();
subjectVestingStart = now.add(10);
subjectVestingCliff = now.add(60 * 60 * 24 * 183);
subjectVestingEnd = now.add(60 * 60 * 24 * 547);
subjectUSDCAmount = BigNumber.from(100_000 * 10**6);
subjectUSDCAmount = BigNumber.from(100_000 * 10 ** 6);
subjectIndexAmount = ether(100);

subjectOtcEscrow = await deployer.token.deployOtcEscrow(
Expand All @@ -293,7 +295,7 @@ describe("OtcEscrow", () => {
usdc.address,
index.address
);

await index.connect(indexGov.wallet).transfer(subjectOtcEscrow.address, subjectIndexAmount);
await usdc.connect(investor.wallet).approve(subjectOtcEscrow.address, subjectUSDCAmount);
});
Expand Down Expand Up @@ -337,11 +339,11 @@ describe("OtcEscrow", () => {
let subjectIndexAmount: BigNumber;

beforeEach(async () => {
const now = await getLastBlockTimestamp()
const now = await getLastBlockTimestamp();
subjectVestingStart = now.add(10);
subjectVestingCliff = now.add(60 * 60 * 24 * 183);
subjectVestingEnd = now.add(60 * 60 * 24 * 547);
subjectUSDCAmount = BigNumber.from(100_000 * 10**6);
subjectUSDCAmount = BigNumber.from(100_000 * 10 ** 6);
subjectIndexAmount = ether(100);

subjectOtcEscrow = await deployer.token.deployOtcEscrow(
Expand Down
12 changes: 3 additions & 9 deletions utils/common/protocolUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { JsonRpcProvider, Web3Provider } from "@ethersproject/providers";

import { BigNumber } from "@ethersproject/bignumber";
import { ethers, constants } from "ethers";

import { EMPTY_BYTES } from "../constants";
import { Address } from "../types";

const { AddressZero } = constants;
import { ethers } from "ethers";

export class ProtocolUtils {
public _provider: Web3Provider | JsonRpcProvider;
Expand All @@ -20,10 +14,10 @@ export class ProtocolUtils {
throw new Error("Invalid transaction hash");
}

const abi = ['event SetTokenCreated(address indexed _setToken, address _manager, string _name, string _symbol)'];
const abi = ["event SetTokenCreated(address indexed _setToken, address _manager, string _name, string _symbol)"];
const iface = new ethers.utils.Interface(abi);

const topic = ethers.utils.id('SetTokenCreated(address,address,string,string)');
const topic = ethers.utils.id("SetTokenCreated(address,address,string,string)");
const logs = await this._provider.getLogs({
fromBlock: "latest",
toBlock: "latest",
Expand Down
2 changes: 1 addition & 1 deletion utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export { RewardsDistributionRecipient } from "../typechain/RewardsDistributionRe
export { StakingRewards } from "../typechain/StakingRewards";
export { StakingRewardsV2 } from "../typechain/StakingRewardsV2";
export { Vesting } from "../typechain/Vesting";
export { OtcEscrow } from "../typechain/OtcEscrow"
export { OtcEscrow } from "../typechain/OtcEscrow";
export { IndexPowah } from "../typechain/IndexPowah";
1 change: 1 addition & 0 deletions utils/merkleUtils/merkleTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class MerkleTree {
if (pairIdx < layer.length) {
return layer[pairIdx];
} else {
// tslint:disable-next-line:no-null-keyword
return null;
}
}
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4138,10 +4138,10 @@ functional-red-black-tree@^1.0.1, functional-red-black-tree@~1.0.1:
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=

ganache-cli@^6.11.0:
version "6.12.1"
resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-6.12.1.tgz#148cf6541494ef1691bd68a77e4414981910cb3e"
integrity sha512-zoefZLQpQyEJH9jgtVYgM+ENFLAC9iwys07IDCsju2Ieq9KSTLH89RxSP4bhizXKV/h/+qaWpfyCBGWnBfqgIQ==
ganache-cli@6.12.2, ganache-cli@^6.11.0:
version "6.12.2"
resolved "https://registry.yarnpkg.com/ganache-cli/-/ganache-cli-6.12.2.tgz#c0920f7db0d4ac062ffe2375cb004089806f627a"
integrity sha512-bnmwnJDBDsOWBUP8E/BExWf85TsdDEFelQSzihSJm9VChVO1SHp94YXLP5BlA4j/OTxp0wR4R1Tje9OHOuAJVw==
dependencies:
ethereumjs-util "6.2.1"
source-map-support "0.5.12"
Expand Down Expand Up @@ -5999,7 +5999,7 @@ mkdirp@*:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mkdirp@0.5.5, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1:
mkdirp@0.5.5, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
Expand Down Expand Up @@ -8267,12 +8267,12 @@ tslib@1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==

tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslint-eslint-rules@^5.3.1:
tslint-eslint-rules@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz#e488cc9181bf193fe5cd7bfca213a7695f1737b5"
integrity sha512-WlSXE+J2vY/VPgIcqQuijMQiel+UtmXS+4nvK4ZzlDiqBfXse8FAvkNnTcYhnQyOTW5KFM+uRRGXxYhFpuBc6w==
Expand All @@ -8281,10 +8281,10 @@ tslint-eslint-rules@^5.3.1:
tslib "1.9.0"
tsutils "^3.0.0"

tslint@^5.8.0:
version "5.20.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.1.tgz#e401e8aeda0152bc44dd07e614034f3f80c67b7d"
integrity sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==
tslint@^6.1.3:
version "6.1.3"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.3.tgz#5c23b2eccc32487d5523bd3a470e9aa31789d904"
integrity sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==
dependencies:
"@babel/code-frame" "^7.0.0"
builtin-modules "^1.1.1"
Expand All @@ -8294,10 +8294,10 @@ tslint@^5.8.0:
glob "^7.1.1"
js-yaml "^3.13.1"
minimatch "^3.0.4"
mkdirp "^0.5.1"
mkdirp "^0.5.3"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tslib "^1.13.0"
tsutils "^2.29.0"

tsort@0.0.1:
Expand Down

0 comments on commit 21013c9

Please sign in to comment.