Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter on ci #31

Merged
merged 6 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ETHERSCAN_API_KEY=
POLYGON_MUMBAI_API_KEY=

# WALLET
PRIVATE_KEY=
DEV_MNEMONIC=

# LOCAL FORK
Expand All @@ -14,4 +13,4 @@ RINKEBY_URL=
GOERLI_URL=
ROPSTEN_URL=
MUMBAI_URL=
REPORT_GAS=
REPORT_GAS=
13 changes: 9 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
env: {node: true},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
env: { node: true },
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "prettier", "mocha"],
rules: {
"prettier/prettier": "error",
"mocha/no-skipped-tests": "error",
"mocha/no-exclusive-tests": "error",
},
root: true,
};
48 changes: 15 additions & 33 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,20 @@ on:
pull_request:
branches: ['main']
jobs:
build:

monolith:
runs-on: ubuntu-latest

# strategy:
# matrix:
# node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

env:
DEV_MNEMONIC: ${{ secrets.DEV_MNEMONIC }}
MUMBAI_URL: ${{secrets.MUMBAI_URL}}
FORK_URL: ${{ secrets.FORK_URL }}
steps:
- uses: actions/checkout@v2
- uses: borales/[email protected]
name: install
with:
cmd: install
- uses: borales/[email protected]
name: compile
with:
cmd: hardhat compile
- uses: borales/[email protected]
name: tests
with:
cmd: hardhat test --network hardhat
env:
FORK_URL: ${{ secrets.FORK_URL }}
DEV_MNEMONIC: ${{ secrets.DEV_MNEMONIC }}

- uses: borales/[email protected]
name: deploy
with:
cmd: rimraf deployments/mumbai/AludelFactory.json && yarn hardhat deploy --network mumbai --write true --tags templates
env:
DEV_MNEMONIC: ${{ secrets.DEV_MNEMONIC }}
MUMBAI_URL: ${{secrets.MUMBAI_URL}}
DEPLOY_CHAIN: mumbai
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: yarn install --dev
- run: yarn compile
- run: yarn lint-sol
- run: yarn lint-ts
- run: yarn test-ts
- run: rm deployments/mumbai/AludelFactory.json && yarn hardhat deploy --network mumbai --tags templates
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["warn", { "ignoreConstructors": true }]
"func-visibility": ["error", { "ignoreConstructors": true }],
"state-visibility": ["error"]
}
}
2 changes: 1 addition & 1 deletion deploy/AludelFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ const deployFunc = async function ({
contract: "AludelFactory",
deterministicDeployment: false,
});
}
};
deployFunc.tags = ["AludelFactory"];
export default deployFunc;
2 changes: 1 addition & 1 deletion deploy/PowerSwitchFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const deployFunc = async function ({
contract: "PowerSwitchFactory",
deterministicDeployment: false,
});
}
};
deployFunc.tags = ["PowerSwitchFactory"];
export default deployFunc;
2 changes: 1 addition & 1 deletion deploy/RewardPoolFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const deployFunc = async function ({
contract: "RewardPoolFactory",
deterministicDeployment: false,
});
}
};

deployFunc.tags = ["RewardPoolFactory"];
export default deployFunc;
12 changes: 7 additions & 5 deletions deploy/Templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import "@nomiclabs/hardhat-ethers";
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const deployFunc = function ({
deployments,
}: HardhatRuntimeEnvironment) {
const deployFunc = function ({ deployments }: HardhatRuntimeEnvironment) {
deployments.log("running virtual task to configure all templates");
}
};

deployFunc.tags = ["templates"];
deployFunc.dependencies = ["GeyserV2Template", "AludelV2Template", "AludelV1Template"];
deployFunc.dependencies = [
"GeyserV2Template",
"AludelV2Template",
"AludelV1Template",
];
export default deployFunc;
71 changes: 35 additions & 36 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,105 +1,104 @@
import * as dotenv from "dotenv";

import "@nomiclabs/hardhat-waffle";
import { HardhatUserConfig, task } from "hardhat/config";
import { HardhatUserConfig } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "hardhat-deploy"
import "hardhat-deploy";

import "hardhat-contract-sizer"
import "hardhat-storage-layout"
import "./tasks/aludel"
import "hardhat-contract-sizer";
import "hardhat-storage-layout";
import "./tasks/aludel";

dotenv.config();

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
const forkingUrl = process.env.FORK_URL || ''
const mnemonic = process.env.DEV_MNEMONIC || ''
const privateKey = process.env.PRIVATE_KEY || ''
const rinkebyUrl = process.env.RINKEBY_URL || ''
const goerliUrl = process.env.GOERLI_URL || ''
const infuraKey = process.env.ETHERSCAN_API_KEY || ''
const polyscanApiKey = process.env.POLYGON_MUMBAI_API_KEY || ''
const forkingUrl = process.env.FORK_URL || "";
const mnemonic = process.env.DEV_MNEMONIC || "";
const rinkebyUrl = process.env.RINKEBY_URL || "";
const goerliUrl = process.env.GOERLI_URL || "";
const infuraKey = process.env.ETHERSCAN_API_KEY || "";
const polyscanApiKey = process.env.POLYGON_MUMBAI_API_KEY || "";

const config: HardhatUserConfig = {
solidity: {
version: "0.8.6",
settings: {
outputSelection: {
"*": {
"*": ["storageLayout"],
"*": ["storageLayout"],
},
},
}
},
},
networks: {
hardhat: {
forking: {
url: forkingUrl,
blockNumber: 14169000
blockNumber: 14169000,
},
accounts: {
mnemonic
}
mnemonic,
},
},
ropsten: {
url: process.env.ROPSTEN_URL || "",
accounts: {
mnemonic
mnemonic,
},
live: true,
saveDeployments: true,
tags: ['staging']
tags: ["staging"],
},
goerli: {
url: goerliUrl,
accounts: {
mnemonic
mnemonic,
},
live: true,
saveDeployments: true,
tags: ['staging']
tags: ["staging"],
},
rinkeby: {
url: rinkebyUrl,
accounts: {
mnemonic
mnemonic,
},
live: true,
saveDeployments: true,
tags: ['staging']
tags: ["staging"],
},
mumbai: {
url: process.env.MUMBAI_URL || '',
url: process.env.MUMBAI_URL || "",
accounts: {
mnemonic
mnemonic,
},
saveDeployments: true
saveDeployments: true,
},
avalanche: {
url: 'https://api.avax.network/ext/bc/C/rpc',
url: "https://api.avax.network/ext/bc/C/rpc",
chainId: 43114,
accounts: {
mnemonic
}
mnemonic,
},
},
localhost: {
url: 'http://127.0.0.1:8545',
url: "http://127.0.0.1:8545",
accounts: {
mnemonic
mnemonic,
},
}
},
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
currency: "USD",
},
namedAccounts: {
deployer: {
default: 0
default: 0,
},
dev: {
// Default to 1
Expand All @@ -112,10 +111,10 @@ const config: HardhatUserConfig = {
apiKey: {
goerli: infuraKey,
rinkeby: infuraKey,
polygonMumbai: polyscanApiKey
}
polygonMumbai: polyscanApiKey,
},
},

paths: {
artifacts: "./out",
sources: "./src/contracts",
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"repository": "[email protected]:alchemistcoin/crucible-collection.git",
"author": "Ignacio Tirabasso <[email protected]>",
"license": "MIT",
"scripts": {
"lint-sol": "git ls-files |grep '\\.sol$' |xargs ./node_modules/.bin/solhint",
"lint-ts": "git ls-files |grep '\\.[tj]s$'| xargs ./node_modules/.bin/eslint",
"compile": "hardhat compile",
"test-ts": "hardhat --network hardhat test"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "2.0.6",
"@nomiclabs/hardhat-etherscan": "3.1.0",
Expand Down Expand Up @@ -60,7 +66,7 @@
"ds-math": "https://github.com/dapphub/ds-math",
"ds-test": "https://github.com/dapphub/ds-test",
"ds-token": "https://github.com/dapphub/ds-token",
"forge-std": "https://github.com/foundry-rs/forge-std",
"rimraf": "^3.0.2"
"eslint-plugin-mocha": "^10.1.0",
"forge-std": "https://github.com/foundry-rs/forge-std"
}
}
36 changes: 17 additions & 19 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
import { ethers, run } from "hardhat";

const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

async function main() {

const signer = (await ethers.getSigners())[0]
console.log('Signer:', signer.address)
const signer = (await ethers.getSigners())[0];
console.log("Signer:", signer.address);

// We get the contract to deploy
const AludelFactory = await ethers.getContractFactory("AludelFactory");
const factory = await AludelFactory.deploy();
await factory.deployed()
await factory.deployed();
console.log("AludelFactory deployed to:", factory.address);

// await factory.deployTransaction.wait(1)
await sleep(150000)
await sleep(150000);
// verify source
console.log('Verifying source on etherscan')
await run('verify:verify', {
console.log("Verifying source on etherscan");
await run("verify:verify", {
address: factory.address,
constructorArguments: [],
})
});

const AludelTemplate = await ethers.getContractFactory("Aludel");
const template = await AludelTemplate.deploy();
await template.deployed()
await template.deployed();
console.log("AludelTemplate deployed to:", template.address);

// await template.deployTransaction.wait(1)
await sleep(150000)
await sleep(150000);

// verify source
console.log('Verifying source on etherscan')
await run('verify:verify', {
console.log("Verifying source on etherscan");
await run("verify:verify", {
address: template.address,
constructorArguments: [],
})
});

// add template
await factory.addTemplate(template.address)

await factory.addTemplate(template.address);
}

main().catch((error) => {
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/aludel/Aludel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ contract Aludel is IAludel, Ownable, Initializable, Powered {
EnumerableSet.AddressSet internal _vaultFactorySet;


address _feeRecipient;
uint16 _feeBps;
address private _feeRecipient;
uint16 private _feeBps;

struct AludelInitializationParams {
address rewardPoolFactory;
Expand Down Expand Up @@ -1101,4 +1101,4 @@ contract Aludel is IAludel, Ownable, Initializable, Powered {
}
return newArray;
}
}
}
Loading