Skip to content

Commit 427fec2

Browse files
zixiang2018osslgtm
andauthored
feat: bump ethers to v6.7.1 (#141)
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>
1 parent 172e510 commit 427fec2

File tree

11 files changed

+28433
-34640
lines changed

11 files changed

+28433
-34640
lines changed

.github/workflows/linters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 14.x
17+
node-version: 18.x
1818
- run: npm ci --ignore-scripts
1919
- run: npm run lint
2020

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
release:
2323
name: Publish Release
2424
runs-on: ubuntu-latest
25-
needs: [ tests, linters ]
25+
needs: [tests, linters]
2626
steps:
2727
- uses: actions/checkout@v3
2828
- uses: actions/setup-node@v3
2929
with:
30-
node-version: 14.x
30+
node-version: 18.x
3131
- run: npm ci
3232
- run: npm run build
3333
- uses: codfish/semantic-release-action@v2

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 14.x
17+
node-version: 18.x
1818
- run: npm ci
1919
- run: npm run test
2020

@@ -25,6 +25,6 @@ jobs:
2525
- uses: actions/checkout@v3
2626
- uses: actions/setup-node@v3
2727
with:
28-
node-version: 14.x
28+
node-version: 18.x
2929
- run: npm ci --ignore-scripts
3030
- run: npm run build

benchmark/GasCostBenchmark.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const getCumulativeGasUsed = async (tx) => {
4242

4343
if (tx.deployTransaction) {
4444
receipt = await tx.deployTransaction.wait();
45-
cumulativeGasUsed = receipt.cumulativeGasUsed.toNumber();
45+
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
4646
} else {
4747
receipt = await tx.wait();
48-
cumulativeGasUsed = await receipt.cumulativeGasUsed.toNumber();
48+
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
4949
}
5050

5151
return cumulativeGasUsed;
@@ -61,12 +61,20 @@ describe("Gas Cost Benchmarks", () => {
6161
});
6262
};
6363

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

68-
// Revert the owner by transferring back
69-
await contractInstance.connect(accounts[2]).transferOwnership(accounts[0].address);
68+
// Revert the change by revoking role
69+
await contractInstance.connect(accounts[0]).revokeRole(ethers.ZeroHash, accounts[2].address);
70+
};
71+
72+
const benchmarkRevokeRole = async (contractName, contractInstance, accounts) => {
73+
// Setup by granting role
74+
await contractInstance.connect(accounts[0]).grantRole(ethers.ZeroHash, accounts[2].address);
75+
76+
const tx = await contractInstance.revokeRole(ethers.ZeroHash, accounts[2].address);
77+
recordGasCost(contractName, "revokeRole", await getCumulativeGasUsed(tx));
7078
};
7179

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

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

166-
await benchmarkTransfer(contractName, documentStoreInstance, Accounts);
174+
await benchmarkGrantRole(contractName, documentStoreInstance, Accounts);
175+
await benchmarkRevokeRole(contractName, documentStoreInstance, Accounts);
167176
await benchmarkIssue(contractName, documentStoreInstance);
168177
await benchmarkBulkIssue(contractName, documentStoreInstance);
169178
await benchmarkRevoke(contractName, documentStoreInstance);
@@ -174,7 +183,7 @@ describe("Gas Cost Benchmarks", () => {
174183
describe("DocumentStoreCreator", () => {
175184
it("runs benchmark", async () => {
176185
const documentStoreCreatorInstance = await DocumentStoreCreator.deploy();
177-
const tx = await documentStoreCreatorInstance.deployed();
186+
const tx = await documentStoreCreatorInstance.deploymentTransaction();
178187
recordGasCost("DocumentStoreCreator", "deployment", await getCumulativeGasUsed(tx));
179188
});
180189
});

hardhat.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable import/no-extraneous-dependencies */
22

3-
require("@nomiclabs/hardhat-waffle");
4-
require("hardhat-typechain");
3+
require("@nomicfoundation/hardhat-toolbox");
4+
require("@typechain/hardhat");
55

66
/**
77
* @type import('hardhat/config').HardhatUserConfig
@@ -19,5 +19,6 @@ module.exports = {
1919
},
2020
typechain: {
2121
outDir: "src/contracts",
22+
dontOverrideCompile: false,
2223
},
2324
};

0 commit comments

Comments
 (0)