Skip to content

Commit

Permalink
conform to eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
HristiyanG committed Jun 14, 2021
1 parent d13c1fa commit 1829a27
Show file tree
Hide file tree
Showing 42 changed files with 442 additions and 1,143 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"plugins": [
// "truffle"
"@typescript-eslint"
]
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
},
{
"files": "*.js",
"files": "*.ts",
"options": {
"printWidth": 80,
"tabWidth": 2,
Expand Down
21 changes: 10 additions & 11 deletions config/getAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import fs from 'fs';
const privateKeys = JSON.parse(fs.readFileSync('config/accounts.json', 'utf8'))[
'private_keys'
];

export default function getAccountsWithBalance(secretPropName) {
return Object.entries(privateKeys).map((entry) => ({
[secretPropName]: `0x${entry[1]}`,
balance: '0x02b5e3af16b1880000', // 50 ETH
}));
}
// import fs from 'fs';
// const privateKeys = JSON.parse(fs.readFileSync('config/accounts.json', 'utf8'))[
// 'private_keys'
// ];

// export default function getAccountsWithBalance(secretPropName) : Array<any> {
// return Object.entries(privateKeys).map((entry) => ({
// [secretPropName]: `0x${entry[1]}`,
// balance: '0x02b5e3af16b1880000', // 50 ETH
// }));
// }
2 changes: 0 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const lazyImport = async (module) => {
task("deploy", "Deploy contracts on a provided network")
.setAction( async () => {
const deploymentScript = await lazyImport('./scripts/deploy')
console.log(deploymentScript);

await deploymentScript.default();
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"tests:lint": "eslint test/**/*.ts testHelpers/**/*.ts",
"tests:lint-fix": "eslint --fix test/**/*.ts testHelpers/**/*.ts scripts/**/*.ts config/**/*.ts",
"tests:format": "prettier --list-different test/**/*.js testHelpers/**/*.js scripts/**/*.js config/**/*.js",
"tests:format-fix": "prettier --write test/**/*.js testHelpers/**/*.js scripts/**/*.js config/**/*.js",
"tests:format-fix": "prettier --write test/**/*.ts testHelpers/**/*.ts scripts/**/*.ts config/**/*.ts",
"tests:unit": "hardhat test",
"tests:coverage": "npx hardhat coverage",
"contracts:size": "hardhat size-contracts"
Expand Down
6 changes: 4 additions & 2 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import fs from 'fs';
import hre, {ethers} from 'hardhat';

export default async function () {
export default async function (): Promise<void> {
const ERC1155ERC721 = await ethers.getContractFactory('ERC1155ERC721');
const VoucherKernel = await ethers.getContractFactory('VoucherKernel');
const Cashier = await ethers.getContractFactory('Cashier');
Expand Down Expand Up @@ -87,7 +87,9 @@ export default async function () {
voucherKernel: voucherKernel.address,
cashier: cashier.address,
br: br.address,
}, this, 2
},
this,
2
),
'utf-8'
);
Expand Down
4 changes: 2 additions & 2 deletions scripts/verify.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import hre from 'hardhat';
import fs from 'fs';
import fs from 'fs';
const contracts = JSON.parse(
fs.readFileSync('./scripts/contracts.json', 'utf-8')
);

export default async function () {
export default async function (): Promise<void> {
if (contracts.network != hre.network.name) {
throw new Error(
'Contracts are not deployer on the same network, that you are trying to verify!'
Expand Down
30 changes: 14 additions & 16 deletions test/1_test_fullpath.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ethers } from "hardhat";
import { Signer, ContractFactory, Contract } from "ethers";
import {ethers} from 'hardhat';
import {Signer, ContractFactory, Contract} from 'ethers';

// later consider using
// https://github.com/OpenZeppelin/openzeppelin-test-helpers

import constants from '../testHelpers/constants'
import { advanceTimeSeconds } from '../testHelpers/timemachine'
import Users from '../testHelpers/users'
import Utils from'../testHelpers/utils'
import constants from '../testHelpers/constants';
import {advanceTimeSeconds} from '../testHelpers/timemachine';
import Users from '../testHelpers/users';
import Utils from '../testHelpers/utils';

import {assert, expect} from 'chai'
import {assert, expect} from 'chai';

import revertReasons from '../testHelpers/revertReasons'
import * as eventUtils from '../testHelpers/events';
import revertReasons from '../testHelpers/revertReasons';
import * as eventUtils from '../testHelpers/events';
const eventNames = eventUtils.eventNames;
import fnSignatures from '../testHelpers/functionSignatures';

Expand Down Expand Up @@ -507,7 +507,7 @@ describe('Voucher tests', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER_SINGLE,
(ev) => {
assert.isTrue(ev._operator === contractVoucherKernel.address);
Expand All @@ -520,7 +520,7 @@ describe('Voucher tests', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER,
(ev) => {
assert.isTrue(ev._from === constants.ZERO_ADDRESS);
Expand Down Expand Up @@ -604,7 +604,7 @@ describe('Voucher tests', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER_SINGLE,
(ev) => {
assert.isTrue(ev._operator === contractVoucherKernel.address);
Expand All @@ -617,7 +617,7 @@ describe('Voucher tests', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER,
(ev) => {
assert.isTrue(ev._from === constants.ZERO_ADDRESS);
Expand Down Expand Up @@ -1324,9 +1324,7 @@ describe('Voucher tests - UNHAPPY PATH', () => {
complainTx.blockNumber
);
assert.isTrue(
voucherStatus.cancelFaultPeriodStart.eq(
BN(transactionBlock.timestamp)
)
voucherStatus.cancelFaultPeriodStart.eq(BN(transactionBlock.timestamp))
);

// [1010.1000] = hex"A8" = 168 = REFUND_COMPLAIN
Expand Down
61 changes: 28 additions & 33 deletions test/2_test_fullpath_with_permit.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ethers } from "hardhat";
import { Signer, ContractFactory, Contract } from "ethers";
import {ethers} from 'hardhat';
import {Signer, ContractFactory, Contract} from 'ethers';

import {assert, expect} from 'chai'
import {assert, expect} from 'chai';
import {ecsign} from 'ethereumjs-util';

import constants from '../testHelpers/constants'
import { advanceTimeSeconds } from '../testHelpers/timemachine'
import constants from '../testHelpers/constants';
import {advanceTimeSeconds} from '../testHelpers/timemachine';

import Users from '../testHelpers/users'
import Utils from'../testHelpers/utils'
import UtilsBuilder from '../testHelpers/utilsBuilder'
import Users from '../testHelpers/users';
import Utils from '../testHelpers/utils';
import UtilsBuilder from '../testHelpers/utilsBuilder';

import {toWei, getApprovalDigest} from '../testHelpers/permitUtils';

Expand All @@ -20,8 +20,8 @@ let BosonRouter: ContractFactory;
let FundLimitsOracle: ContractFactory;
let MockERC20Permit: ContractFactory;

import revertReasons from '../testHelpers/revertReasons'
import * as eventUtils from '../testHelpers/events';
import revertReasons from '../testHelpers/revertReasons';
import * as eventUtils from '../testHelpers/events';
const eventNames = eventUtils.eventNames;
import fnSignatures from '../testHelpers/functionSignatures';

Expand Down Expand Up @@ -926,7 +926,7 @@ describe('Cashier and VoucherKernel', () => {

await expect(
sellerInstance.requestCreateOrderTKNETH(
'',
'',
[
constants.PROMISE_VALID_FROM,
constants.PROMISE_VALID_TO,
Expand Down Expand Up @@ -3027,9 +3027,7 @@ describe('Cashier and VoucherKernel', () => {

await utils.cancel(voucherID, users.seller.signer);

await advanceTimeSeconds(
complainPeriod + constants.ONE_MINUTE
);
await advanceTimeSeconds(complainPeriod + constants.ONE_MINUTE);

await expect(
utils.complain(voucherID, users.buyer.signer)
Expand Down Expand Up @@ -3110,9 +3108,7 @@ describe('Cashier and VoucherKernel', () => {
);
await utils.redeem(voucherID, users.buyer.signer);
await utils.cancel(voucherID, users.seller.signer),
await advanceTimeSeconds(
complainPeriod + constants.ONE_MINUTE
);
await advanceTimeSeconds(complainPeriod + constants.ONE_MINUTE);

await expect(
utils.complain(voucherID, users.buyer.signer)
Expand All @@ -3128,9 +3124,7 @@ describe('Cashier and VoucherKernel', () => {

await utils.redeem(voucherID, users.buyer.signer);
await utils.complain(voucherID, users.buyer.signer),
await advanceTimeSeconds(
cancelPeriod + constants.ONE_MINUTE
);
await advanceTimeSeconds(cancelPeriod + constants.ONE_MINUTE);

await expect(
utils.cancel(voucherID, users.seller.signer)
Expand Down Expand Up @@ -3183,9 +3177,7 @@ describe('Cashier and VoucherKernel', () => {
await utils.refund(voucherID, users.buyer.signer);
await utils.complain(voucherID, users.buyer.signer);

await advanceTimeSeconds(
cancelPeriod + constants.ONE_MINUTE
);
await advanceTimeSeconds(cancelPeriod + constants.ONE_MINUTE);

await expect(
utils.cancel(voucherID, users.seller.signer)
Expand All @@ -3202,9 +3194,7 @@ describe('Cashier and VoucherKernel', () => {
await utils.refund(voucherID, users.buyer.signer);
await utils.cancel(voucherID, users.seller.signer);

await advanceTimeSeconds(
complainPeriod + constants.ONE_MINUTE
);
await advanceTimeSeconds(complainPeriod + constants.ONE_MINUTE);

await expect(
utils.complain(voucherID, users.buyer.signer)
Expand Down Expand Up @@ -3568,7 +3558,10 @@ describe('Cashier and VoucherKernel', () => {
await advanceTimeSeconds(60);
await utils.finalize(voucherID, users.deployer.signer);

const withdrawTx = await utils.withdraw(voucherID, users.deployer.signer);
const withdrawTx = await utils.withdraw(
voucherID,
users.deployer.signer
);

const txReceipt = await withdrawTx.wait();

Expand Down Expand Up @@ -3623,7 +3616,7 @@ describe('Cashier and VoucherKernel', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractVoucherKernel,
VoucherKernel,
eventNames.LOG_VOUCHER_FAULT_CANCEL,
(ev) => {
assert.isTrue(ev._tokenIdVoucher.eq(voucherID));
Expand Down Expand Up @@ -4168,7 +4161,7 @@ describe('Cashier and VoucherKernel', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractVoucherKernel,
VoucherKernel,
eventNames.LOG_VOUCHER_FAULT_CANCEL,
(ev) => {
assert.isTrue(ev._tokenIdVoucher.eq(voucherID));
Expand Down Expand Up @@ -4440,7 +4433,7 @@ describe('Cashier and VoucherKernel', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractVoucherKernel,
VoucherKernel,
eventNames.LOG_VOUCHER_FAULT_CANCEL,
(ev) => {
assert.isTrue(ev._tokenIdVoucher.eq(voucherID));
Expand Down Expand Up @@ -4533,7 +4526,7 @@ describe('Cashier and VoucherKernel', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER,
(ev) => {
assert.equal(ev._from, users.other1.address);
Expand All @@ -4553,7 +4546,9 @@ describe('Cashier and VoucherKernel', () => {
tokenSupplyKey
);

const balanceBeforeTransfer = (await balanceOf(users.other1.address))[0];
const balanceBeforeTransfer = (
await balanceOf(users.other1.address)
)[0];

const transferTx = await utils.safeTransfer721(
users.other1.address,
Expand All @@ -4573,7 +4568,7 @@ describe('Cashier and VoucherKernel', () => {

eventUtils.assertEventEmitted(
txReceipt,
contractERC1155ERC721,
ERC1155ERC721,
eventNames.TRANSFER,
(ev) => {
assert.equal(ev._from, users.other1.address);
Expand Down
Loading

0 comments on commit 1829a27

Please sign in to comment.