Skip to content

Commit

Permalink
refactor: use solhint-community
Browse files Browse the repository at this point in the history
build: update yarn
build: bump deps
refactor: upgrade ethers v5 to v6
  • Loading branch information
ahmedali8 committed Jul 7, 2023
1 parent 15fbedc commit f9ab9ed
Show file tree
Hide file tree
Showing 10 changed files with 477 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
root: true,
env: {
node: true,
es6: true,
es2020: true,
jest: true,
},
extends: ["eslint:recommended", "prettier"],
Expand Down
43 changes: 15 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,54 +29,41 @@
"verify": "hardhat run scripts/verify.js --network"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/address": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/constants": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/logger": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/solidity": "^5.7.0",
"@ethersproject/transactions": "^5.7.0",
"@ethersproject/units": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@ethersproject/wordlists": "^5.7.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.1",
"@nomicfoundation/hardhat-ethers": "^3.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.3",
"@primitivefi/hardhat-dodoc": "^0.2.3",
"@typechain/ethers-v5": "^10.2.1",
"@typechain/hardhat": "^6.1.6",
"@typechain/ethers-v6": "^0.4.0",
"@typechain/hardhat": "^8.0.0",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^18.16.16",
"@types/node": "^18.16.19",
"chai": "4.3.7",
"chalk": "^4.1.2",
"child_process": "^1.0.2",
"dotenv": "^16.1.3",
"eslint": "^8.42.0",
"dotenv": "^16.3.1",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"ethers": "5.7.2",
"ethers": "6.6.2",
"evm-bn": "^1.1.2",
"fs-extra": "^11.1.1",
"hardhat": "2.14.1",
"hardhat-contract-sizer": "2.9.0",
"hardhat": "2.16.1",
"hardhat-contract-sizer": "2.10.0",
"hardhat-gas-reporter": "1.0.9",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3",
"shx": "0.3.4",
"solhint": "3.4.1",
"solhint-community": "^3.5.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "0.8.2",
"solidity-coverage": "0.8.4",
"ts-node": "^10.9.1",
"typechain": "^8.2.0",
"typescript": "^4.9.5"
"typescript": "^5.1.6"
},
"license": "UNLICENSED",
"files": [
Expand Down
6 changes: 4 additions & 2 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ async function main() {
contract: lock,
});

const lockAddress = await lock.getAddress();

console.log(
`Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lock.address}`
`Lock with 1 ETH and unlock timestamp ${unlockTime} deployed to ${lockAddress}`
);

// You don't want to verify on localhost
Expand All @@ -41,7 +43,7 @@ async function main() {
const contractPath = `contracts/${CONTRACT_NAME}.sol:${CONTRACT_NAME}`;
await verifyContract({
contractPath: contractPath,
contractAddress: lock.address,
contractAddress: lockAddress,
args: [unlockTime],
});
}
Expand Down
7 changes: 4 additions & 3 deletions test/Lock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ describe("Lock", function () {
deployOneYearLockFixture
);

expect(await ethers.provider.getBalance(lock.address)).to.equal(
lockedAmount
);
const address = await lock.getAddress();
const balance = await ethers.provider.getBalance(address);

expect(balance).to.equal(lockedAmount);
});

it("Should fail if the unlockTime is not in the future", async function () {
Expand Down
4 changes: 1 addition & 3 deletions utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"use strict";

const { toBN } = require("./format");

const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";

const ZERO_BYTES32 =
"0x0000000000000000000000000000000000000000000000000000000000000000";

const MAX_UINT256 = toBN(
const MAX_UINT256 = BigInt(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
);

Expand Down
26 changes: 17 additions & 9 deletions utils/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const { fromWei } = require("./format");
const { getExtraGasInfo } = require("./misc");

/**
* Call function before deploying contract.
* Logs information about the signer, network, and balance before deploying a contract.
*
* @param {*} obj
* @param {*} obj.signerAddress string Address of signer
* @param {*} obj.contractName string Name of Contract
* @param {*} obj.signerAddress string - The address of the signer.
* @param {*} obj.contractName string - The name of the contract to be deployed.
*/
async function preDeployConsole({ signerAddress, contractName }) {
const { chainId, name } = await ethers.provider.getNetwork();
Expand All @@ -28,27 +29,34 @@ async function preDeployConsole({ signerAddress, contractName }) {
}

/**
* Logs information about the deployment of a contract.
*
* @param {*} obj
* @param {*} obj.contractName string Name of Contract
* @param {*} obj.contract Contract Instance of Contract
* @param {*} obj.contractName string - The name of the deployed contract.
* @param {*} obj.contract BaseContract - The contract instance.
* @returns contract instance
*/
async function postDeployConsole({ contractName, contract }) {
await contract.deployed();
// Wait for the contract to be deployed
await contract.waitForDeployment();

// Get extra gas information of the deployment transaction
let extraGasInfo = "";
if (contract && contract.deployTransaction) {
extraGasInfo = (await getExtraGasInfo(contract.deployTransaction)) ?? "";
const deploymentTransaction = contract.deploymentTransaction();
if (deploymentTransaction) {
extraGasInfo = (await getExtraGasInfo(deploymentTransaction)) ?? "";
}
const contractAddress = await contract.getAddress();

// Log the deployment information
console.log(
" 📄",
chalk.cyan(contractName),
"deployed to:",
chalk.magenta(contract.address)
chalk.magenta(contractAddress)
);
console.log(" ⛽", chalk.grey(extraGasInfo));

return contract;
}

Expand Down
Loading

0 comments on commit f9ab9ed

Please sign in to comment.