Skip to content

Commit

Permalink
Merge pull request #32 from fei-protocol/tw/add-linting
Browse files Browse the repository at this point in the history
Add linting to JavaScript code
  • Loading branch information
thomas-waite authored Jun 8, 2021
2 parents f54d7bb + baf3ea7 commit fef479b
Show file tree
Hide file tree
Showing 36 changed files with 8,066 additions and 10,904 deletions.
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ jobs:
key: repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo
lint:
working_directory: ~/repo
docker:
- image: circleci/node:12
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Run linter
command: npm run lint:js
test:
working_directory: ~/repo
docker:
Expand All @@ -46,6 +57,9 @@ workflows:
main:
jobs:
- build
- lint:
requires:
- build
- test:
requires:
- build
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
artifacts/
build/
cache/
coverage/
dist/
lib/
node_modules/
11 changes: 8 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
"comma-dangle": 0,
"func-names": 0,
"space-before-function-paren": 0,
"indent": ["error", 2],
"max-len": 150,
"no-tabs": 0
"max-len": 1,
"no-multi-spaces": 0,
"no-trailing-spaces": 0,
"object-curly-spacing": 0,
"no-tabs": 0,
"no-unused-expressions": 0,
"no-sequences": 0,
"no-mixed-spaces-and-tabs": 0
},
"globals": {
"artifacts": "readonly",
Expand Down
19 changes: 8 additions & 11 deletions deploy/1_fip_2.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
const EthReserveStabilizer = artifacts.require("EthReserveStabilizer");
const EthPCVDripper = artifacts.require("EthPCVDripper");
const EthReserveStabilizer = artifacts.require('EthReserveStabilizer');
const EthPCVDripper = artifacts.require('EthPCVDripper');
const { web3 } = require('hardhat');
require('dotenv').config();

const {
MAINNET_CORE,
MAINNET_UNISWAP_ORACLE
} = process.env
} = process.env;

async function main() {

if (!MAINNET_CORE) {
throw new Error('Failed to fetch core Set MAINNET_CORE')
throw new Error('Failed to fetch core Set MAINNET_CORE');
}

if (!MAINNET_UNISWAP_ORACLE) {
throw new Error('Failed to fetch core Set MAINNET_UNISWAP_ORACLE')
throw new Error('Failed to fetch core Set MAINNET_UNISWAP_ORACLE');
}

const ethReserveStabiliser = new web3.eth.Contract(EthReserveStabilizer.abi); // factory contract
await ethReserveStabiliser.deploy({data: EthReserveStabilizer.bytecode, arguments: [core, oracle, "9500"]}) // contract bytecode and constructor args
await ethReserveStabiliser.deploy({data: EthReserveStabilizer.bytecode, arguments: [MAINNET_CORE, MAINNET_UNISWAP_ORACLE, '9500']}); // contract bytecode and constructor args

const ethPCVDripper = new web3.eth.Contract(EthPCVDripper.abi); // factory contract
await ethPCVDripper.deploy({data: EthPCVDripper.bytecode, arguments: [core, instance.address, "3600", "5000000000000000000000"]}) // 5000 ETH per hour
await ethPCVDripper.deploy({data: EthPCVDripper.bytecode, arguments: [MAINNET_CORE, ethReserveStabiliser.address, '3600', '5000000000000000000000']}); // 5000 ETH per hour
}



main().catch(err => {
main().catch((err) => {
console.log(err);
process.exit(1);
});
113 changes: 56 additions & 57 deletions deploy/3_erc20.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { BN, ether } = require('@openzeppelin/test-helpers');
const { web3 } = require('hardhat');

const UniswapPCVDeposit = artifacts.require("UniswapPCVDeposit");
const UniswapPCVController = artifacts.require("UniswapPCVController");
const BondingCurve = artifacts.require("BondingCurve");
const UniswapPCVDeposit = artifacts.require('UniswapPCVDeposit');
const UniswapPCVController = artifacts.require('UniswapPCVController');
const BondingCurve = artifacts.require('BondingCurve');
require('dotenv').config();

const {
Expand All @@ -15,64 +15,63 @@ const {
} = process.env;

async function main() {
if (!MAINNET_CORE || !MAINNET_FEI_ETH_PAIR || !MAINNET_WETH || !MAINNET_UNISWAP_ROUTER || !MAINNET_UNISWAP_ORACLE) {
throw new Error('An environment variable contract address is not set')
}

if (!MAINNET_CORE || !MAINNET_FEI_ETH_PAIR || !MAINNET_WETH || !MAINNET_UNISWAP_ROUTER || !MAINNET_UNISWAP_ORACLE) {
throw new Error('An environment variable contract address is not set');
}

const deployAddress = (await web3.eth.getAccounts())[0]
const deployAddress = (await web3.eth.getAccounts())[0];

const uniswapPCVDeposit = new web3.eth.Contract(UniswapPCVDeposit.abi); // factory contract
await uniswapPCVDeposit.deploy({
data: UniswapPCVDeposit.bytecode,
arguments: [
MAINNET_CORE,
MAINNET_FEI_ETH_PAIR,
MAINNET_UNISWAP_ROUTER,
MAINNET_UNISWAP_ORACLE,
'100'
]
}).send({ from: deployAddress }) // contract bytecode and constructor arguments
console.log('UniswapPCVDeposit deployed to: ', uniswapPCVDeposit.address)
const uniswapPCVDeposit = new web3.eth.Contract(UniswapPCVDeposit.abi); // factory contract
await uniswapPCVDeposit.deploy({
data: UniswapPCVDeposit.bytecode,
arguments: [
MAINNET_CORE,
MAINNET_FEI_ETH_PAIR,
MAINNET_UNISWAP_ROUTER,
MAINNET_UNISWAP_ORACLE,
'100'
]
}).send({ from: deployAddress }); // contract bytecode and constructor arguments
console.log('UniswapPCVDeposit deployed to: ', uniswapPCVDeposit.address);

const tenPow18 = ether('1');
const uniswapPCVController = new web3.eth.Contract(UniswapPCVController.abi); // factory contract
await uniswapPCVController.deploy({
data: UniswapPCVDeposit.bytecode,
arguments: [
MAINNET_CORE,
uniswapPCVDeposit.address,
MAINNET_UNISWAP_ORACLE,
tenPow18.mul(new BN('500')),
new BN('100'),
MAINNET_FEI_ETH_PAIR,
14400
]
}).send({ from: deployAddress })
console.log('Uniswap PCV controller deployed to: ', uniswapPCVController.address)
const tenPow18 = ether('1');
const uniswapPCVController = new web3.eth.Contract(UniswapPCVController.abi); // factory contract
await uniswapPCVController.deploy({
data: UniswapPCVDeposit.bytecode,
arguments: [
MAINNET_CORE,
uniswapPCVDeposit.address,
MAINNET_UNISWAP_ORACLE,
tenPow18.mul(new BN('500')),
new BN('100'),
MAINNET_FEI_ETH_PAIR,
14400
]
}).send({ from: deployAddress });
console.log('Uniswap PCV controller deployed to: ', uniswapPCVController.address);

const bondingCurve = new web3.eth.Contract(BondingCurve.abi); // factory contract
await bondingCurve.deploy({
data: BondingCurve.bytecode,
arguments: [
MAINNET_CORE,
MAINNET_UNISWAP_ORACLE,
tenPow18.mul(new BN('10000000')),
[uniswapPCVDeposit.address],
[10000],
'100',
'100',
MAINNET_WETH,
tenPow18.mul(new BN('500')),
'100'
]
}).send({ from: deployAddress })
console.log('Bonding curve deployed to: ', bondingCurve.address)
const bondingCurve = new web3.eth.Contract(BondingCurve.abi); // factory contract
await bondingCurve.deploy({
data: BondingCurve.bytecode,
arguments: [
MAINNET_CORE,
MAINNET_UNISWAP_ORACLE,
tenPow18.mul(new BN('10000000')),
[uniswapPCVDeposit.address],
[10000],
'100',
'100',
MAINNET_WETH,
tenPow18.mul(new BN('500')),
'100'
]
}).send({ from: deployAddress });
console.log('Bonding curve deployed to: ', bondingCurve.address);
}

main()
.then(() => process.exit(0))
.catch(err => {
console.log(err);
process.exit(1);
});
.then(() => process.exit(0))
.catch((err) => {
console.log(err);
process.exit(1);
});
4 changes: 2 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('@nomiclabs/hardhat-waffle');
require('@nomiclabs/hardhat-truffle5');
require('@nomiclabs/hardhat-web3')
require('@nomiclabs/hardhat-web3');
require('hardhat-gas-reporter');
require('hardhat-contract-sizer');
require('solidity-coverage');
Expand All @@ -21,7 +21,7 @@ module.exports = {
chainId: 5777, // Any network (default: none)
},
localhost: {
url: "http://127.0.0.1:8545"
url: 'http://127.0.0.1:8545'
},
rinkeby: {
url: `https://eth-rinkeby.alchemyapi.io/v2/${rinkebyAlchemyApiKey}`,
Expand Down
24 changes: 12 additions & 12 deletions migrations/1_fip_2.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const EthReserveStabilizer = artifacts.require("EthReserveStabilizer");
const EthPCVDripper = artifacts.require("EthPCVDripper");
const EthReserveStabilizer = artifacts.require('EthReserveStabilizer');
const EthPCVDripper = artifacts.require('EthPCVDripper');
require('dotenv').config();

module.exports = function(deployer) {
require('dotenv').config();
const core = process.env.MAINNET_CORE;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;
deployer.then(function() {
return deployer.deploy(EthReserveStabilizer, core, oracle, "9500");
}).then(function(instance) {
return deployer.deploy(EthPCVDripper, core, instance.address, "3600", "5000000000000000000000"); // 5000 ETH per hour
});
}
module.exports = function(deployer) {
const core = process.env.MAINNET_CORE;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;
deployer.then(function() {
return deployer.deploy(EthReserveStabilizer, core, oracle, '9500');
}).then(function(instance) {
return deployer.deploy(EthPCVDripper, core, instance.address, '3600', '5000000000000000000000'); // 5000 ETH per hour
});
};
40 changes: 20 additions & 20 deletions migrations/2_fip_5.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const EthUniswapPCVDeposit = artifacts.require("EthUniswapPCVDeposit");
const EthPCVDepositAdapter = artifacts.require("EthPCVDepositAdapter");
const RatioPCVController = artifacts.require("RatioPCVController");
const EthUniswapPCVDeposit = artifacts.require('EthUniswapPCVDeposit');
const EthPCVDepositAdapter = artifacts.require('EthPCVDepositAdapter');
const RatioPCVController = artifacts.require('RatioPCVController');
require('dotenv').config();

module.exports = function(deployer) {
require('dotenv').config();
const coreAddress = process.env.MAINNET_CORE;
const pair = process.env.MAINNET_FEI_ETH_PAIR;
const router = process.env.MAINNET_UNISWAP_ROUTER;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;
const dripperAddress = process.env.MAINNET_ETH_PCV_DRIPPER;
module.exports = function(deployer) {
const coreAddress = process.env.MAINNET_CORE;
const pair = process.env.MAINNET_FEI_ETH_PAIR;
const router = process.env.MAINNET_UNISWAP_ROUTER;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;
const dripperAddress = process.env.MAINNET_ETH_PCV_DRIPPER;

deployer.then(function() {
return deployer.deploy(EthUniswapPCVDeposit, coreAddress, pair, router, oracle);
}).then(function(instance) {
return deployer.deploy(EthPCVDepositAdapter, instance.address);
}).then(function() {
return deployer.deploy(EthPCVDepositAdapter, dripperAddress);
}).then(function() {
return deployer.deploy(RatioPCVController, coreAddress);
});
}
deployer.then(function() {
return deployer.deploy(EthUniswapPCVDeposit, coreAddress, pair, router, oracle);
}).then(function(instance) {
return deployer.deploy(EthPCVDepositAdapter, instance.address);
}).then(function() {
return deployer.deploy(EthPCVDepositAdapter, dripperAddress);
}).then(function() {
return deployer.deploy(RatioPCVController, coreAddress);
});
};
46 changes: 22 additions & 24 deletions migrations/3_erc20.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
const { BN, ether } = require('@openzeppelin/test-helpers');


const UniswapPCVDeposit = artifacts.require("UniswapPCVDeposit");
const UniswapPCVController = artifacts.require("UniswapPCVController");
const BondingCurve = artifacts.require("BondingCurve");
const UniswapPCVDeposit = artifacts.require('UniswapPCVDeposit');
const UniswapPCVController = artifacts.require('UniswapPCVController');
const BondingCurve = artifacts.require('BondingCurve');
require('dotenv').config();

module.exports = function(deployer) {
require('dotenv').config();
const coreAddress = process.env.MAINNET_CORE;
const pair = process.env.MAINNET_FEI_ETH_PAIR;
const weth = process.env.MAINNET_WETH;
const router = process.env.MAINNET_UNISWAP_ROUTER;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;

var pcvDeposit;
const coreAddress = process.env.MAINNET_CORE;
const pair = process.env.MAINNET_FEI_ETH_PAIR;
const weth = process.env.MAINNET_WETH;
const router = process.env.MAINNET_UNISWAP_ROUTER;
const oracle = process.env.MAINNET_UNISWAP_ORACLE;

let tenPow18 = ether('1');
let pcvDeposit;
const tenPow18 = ether('1');

deployer.then(function() {
return deployer.deploy(UniswapPCVDeposit, coreAddress, pair, router, oracle, '100');
}).then(function(instance) {
pcvDeposit = instance;
return deployer.deploy(UniswapPCVController, coreAddress, instance.address, oracle, tenPow18.mul(new BN('500')), new BN('100'), pair, 14400);
}).then(function() {
return deployer.deploy(BondingCurve, tenPow18.mul(new BN('10000000')), coreAddress, [pcvDeposit.address], [10000], oracle, '100', tenPow18.mul(new BN('500')));
}).then(function(instance) {
return instance.setToken(weth);
});
}
deployer.then(function() {
return deployer.deploy(UniswapPCVDeposit, coreAddress, pair, router, oracle, '100');
}).then(function(instance) {
pcvDeposit = instance;
return deployer.deploy(UniswapPCVController, coreAddress, instance.address, oracle, tenPow18.mul(new BN('500')), new BN('100'), pair, 14400);
}).then(function() {
return deployer.deploy(BondingCurve, tenPow18.mul(new BN('10000000')), coreAddress, [pcvDeposit.address], [10000], oracle, '100', tenPow18.mul(new BN('500')));
}).then(function(instance) {
return instance.setToken(weth);
});
};
Loading

0 comments on commit fef479b

Please sign in to comment.