Skip to content

Commit

Permalink
feat: bump ethers to v6.7.1 (#141)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Bumped ethers version from v5.4.0 to v6.7.1


* feat: bump ethers to v6.7.1

* wip: bump

* wip: bump

* fix: updated hardhat tests for v6

* fix: remove test.js files

* fix: somewhat working

* fix: bump ci node version

* fix: restore test:js

* fix: use hardhat.config for outDir

---------

Co-authored-by: osslgtm <68947167+osslgtm@users.noreply.github.com>
  • Loading branch information
zixiang2018 and osslgtm authored Sep 25, 2023
1 parent 172e510 commit 427fec2
Show file tree
Hide file tree
Showing 11 changed files with 28,433 additions and 34,640 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- run: npm ci --ignore-scripts
- run: npm run lint

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
release:
name: Publish Release
runs-on: ubuntu-latest
needs: [ tests, linters ]
needs: [tests, linters]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- run: npm ci
- run: npm run build
- uses: codfish/semantic-release-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- run: npm ci
- run: npm run test

Expand All @@ -25,6 +25,6 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- run: npm ci --ignore-scripts
- run: npm run build
29 changes: 19 additions & 10 deletions benchmark/GasCostBenchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const getCumulativeGasUsed = async (tx) => {

if (tx.deployTransaction) {
receipt = await tx.deployTransaction.wait();
cumulativeGasUsed = receipt.cumulativeGasUsed.toNumber();
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
} else {
receipt = await tx.wait();
cumulativeGasUsed = await receipt.cumulativeGasUsed.toNumber();
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
}

return cumulativeGasUsed;
Expand All @@ -61,12 +61,20 @@ describe("Gas Cost Benchmarks", () => {
});
};

const benchmarkTransfer = async (contractName, contractInstance, accounts) => {
const tx = await contractInstance.transferOwnership(accounts[2].address);
recordGasCost(contractName, "transferOwnership", await getCumulativeGasUsed(tx));
const benchmarkGrantRole = async (contractName, contractInstance, accounts) => {
const tx = await contractInstance.grantRole(ethers.ZeroHash, accounts[2].address);
recordGasCost(contractName, "grantRole", await getCumulativeGasUsed(tx));

// Revert the owner by transferring back
await contractInstance.connect(accounts[2]).transferOwnership(accounts[0].address);
// Revert the change by revoking role
await contractInstance.connect(accounts[0]).revokeRole(ethers.ZeroHash, accounts[2].address);
};

const benchmarkRevokeRole = async (contractName, contractInstance, accounts) => {
// Setup by granting role
await contractInstance.connect(accounts[0]).grantRole(ethers.ZeroHash, accounts[2].address);

const tx = await contractInstance.revokeRole(ethers.ZeroHash, accounts[2].address);
recordGasCost(contractName, "revokeRole", await getCumulativeGasUsed(tx));
};

const benchmarkIssue = async (contractName, contractInstance) => {
Expand Down Expand Up @@ -152,7 +160,7 @@ describe("Gas Cost Benchmarks", () => {
it("runs benchmark", async () => {
// Deploy & initialize document store contract
const documentStoreInstance = await DocumentStore.deploy(contractName, Accounts[0].address);
const tx = await documentStoreInstance.deployed();
const tx = await documentStoreInstance.deploymentTransaction();
recordGasCost(contractName, "deployment", await getCumulativeGasUsed(tx));

// const documentStoreInstance = await UpgradableDocumentStore.deploy();
Expand All @@ -163,7 +171,8 @@ describe("Gas Cost Benchmarks", () => {
// (await getCumulativeGasUsed(documentStoreInstance)) + (await getCumulativeGasUsed(initializeTx))
// );

await benchmarkTransfer(contractName, documentStoreInstance, Accounts);
await benchmarkGrantRole(contractName, documentStoreInstance, Accounts);
await benchmarkRevokeRole(contractName, documentStoreInstance, Accounts);
await benchmarkIssue(contractName, documentStoreInstance);
await benchmarkBulkIssue(contractName, documentStoreInstance);
await benchmarkRevoke(contractName, documentStoreInstance);
Expand All @@ -174,7 +183,7 @@ describe("Gas Cost Benchmarks", () => {
describe("DocumentStoreCreator", () => {
it("runs benchmark", async () => {
const documentStoreCreatorInstance = await DocumentStoreCreator.deploy();
const tx = await documentStoreCreatorInstance.deployed();
const tx = await documentStoreCreatorInstance.deploymentTransaction();
recordGasCost("DocumentStoreCreator", "deployment", await getCumulativeGasUsed(tx));
});
});
Expand Down
5 changes: 3 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */

require("@nomiclabs/hardhat-waffle");
require("hardhat-typechain");
require("@nomicfoundation/hardhat-toolbox");
require("@typechain/hardhat");

/**
* @type import('hardhat/config').HardhatUserConfig
Expand All @@ -19,5 +19,6 @@ module.exports = {
},
typechain: {
outDir: "src/contracts",
dontOverrideCompile: false,
},
};
Loading

0 comments on commit 427fec2

Please sign in to comment.