diff --git a/.changeset/cuddly-ghosts-drum.md b/.changeset/cuddly-ghosts-drum.md new file mode 100644 index 000000000..06e38f90c --- /dev/null +++ b/.changeset/cuddly-ghosts-drum.md @@ -0,0 +1,6 @@ +--- +'@typechain/hardhat': patch +'@typechain/ethers-v6': patch +--- + +Support for the newest hardhat-ethers version diff --git a/examples/hardhat/package.json b/examples/hardhat/package.json index 12918ab37..69ac63d05 100644 --- a/examples/hardhat/package.json +++ b/examples/hardhat/package.json @@ -11,7 +11,7 @@ "typecheck": "pnpm compile && pnpm test && pnpm tsc --noEmit" }, "devDependencies": { - "@nomicfoundation/hardhat-ethers": "^3.0.0", + "@nomicfoundation/hardhat-ethers": "^3.0.4", "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", "@typechain/ethers-v6": "workspace:^0.4.0", "@typechain/hardhat": "workspace:^8.0.0", diff --git a/examples/hardhat/test/counter.ts b/examples/hardhat/test/counter.ts index 5e0fa2c3f..5236ccb82 100644 --- a/examples/hardhat/test/counter.ts +++ b/examples/hardhat/test/counter.ts @@ -2,6 +2,7 @@ import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import { solidity } from 'ethereum-waffle' import { ethers } from 'hardhat' +import { DeployContractOptions } from '@nomicfoundation/hardhat-ethers/types' import type { Counter } from '../typechain-types' @@ -17,13 +18,15 @@ describe('Counter', () => { const signers = await ethers.getSigners() // 2 - counter = await ethers.deployContract('Counter') - + const gasPrice = 1637083528 + const options: DeployContractOptions = { gasPrice } + counter = await ethers.deployContract('Counter', options) const initialCount = await counter.getCount() // 3 expect(initialCount).to.eq(0) expect(await counter.getAddress()).to.properAddress + expect(counter.deploymentTransaction()?.gasPrice).to.eq(gasPrice) }) // 4 diff --git a/packages/hardhat-test/typechain-types/hardhat.d.ts b/packages/hardhat-test/typechain-types/hardhat.d.ts index 6f73f8e1f..f4155a0c4 100644 --- a/packages/hardhat-test/typechain-types/hardhat.d.ts +++ b/packages/hardhat-test/typechain-types/hardhat.d.ts @@ -4,6 +4,7 @@ import { ethers } from "ethers"; import { + DeployContractOptions, FactoryOptions, HardhatEthersHelpers as HardhatEthersHelpersBase, } from "@nomicfoundation/hardhat-ethers/types"; @@ -52,40 +53,40 @@ declare module "hardhat/types/runtime" { deployContract( name: "Counter", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "Demo", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "Hello", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "StructsInConstructor", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "Counter", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "Demo", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "Hello", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "StructsInConstructor", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; // default types @@ -105,12 +106,12 @@ declare module "hardhat/types/runtime" { ): Promise; deployContract( name: string, - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: string, args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; } } diff --git a/packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/hardhat.d.ts b/packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/hardhat.d.ts index 654172f72..9bcc45ddb 100644 --- a/packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/hardhat.d.ts +++ b/packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/hardhat.d.ts @@ -4,6 +4,7 @@ import { ethers } from "ethers"; import { + DeployContractOptions, FactoryOptions, HardhatEthersHelpers as HardhatEthersHelpersBase, } from "@nomicfoundation/hardhat-ethers/types"; @@ -61,49 +62,49 @@ declare module "hardhat/types/runtime" { deployContract( name: "EdgeCases", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "SafeMath", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "TestContract", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "TestContract1", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "ERC20", - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "EdgeCases", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "SafeMath", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "TestContract", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "TestContract1", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: "ERC20", args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; // default types @@ -123,12 +124,12 @@ declare module "hardhat/types/runtime" { ): Promise; deployContract( name: string, - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: string, args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; } } diff --git a/packages/target-ethers-v6/src/codegen/hardhat.ts b/packages/target-ethers-v6/src/codegen/hardhat.ts index e9d459307..0d326f5e3 100644 --- a/packages/target-ethers-v6/src/codegen/hardhat.ts +++ b/packages/target-ethers-v6/src/codegen/hardhat.ts @@ -5,7 +5,7 @@ export function generateHardhatHelper(contracts: string[]): string { return ` import { ethers } from 'ethers' -import { FactoryOptions, HardhatEthersHelpers as HardhatEthersHelpersBase} from "@nomicfoundation/hardhat-ethers/types"; +import { DeployContractOptions, FactoryOptions, HardhatEthersHelpers as HardhatEthersHelpersBase} from "@nomicfoundation/hardhat-ethers/types"; import * as Contracts from "." @@ -29,14 +29,15 @@ declare module "hardhat/types/runtime" { ${contracts .map( - (n) => `deployContract(name: '${n}', signerOrOptions?: ethers.Signer | FactoryOptions): Promise`, + (n) => + `deployContract(name: '${n}', signerOrOptions?: ethers.Signer | DeployContractOptions): Promise`, ) .join('\n')} ${contracts .map( (n) => - `deployContract(name: '${n}', args: any[], signerOrOptions?: ethers.Signer | FactoryOptions): Promise`, + `deployContract(name: '${n}', args: any[], signerOrOptions?: ethers.Signer | DeployContractOptions): Promise`, ) .join('\n')} @@ -57,12 +58,12 @@ declare module "hardhat/types/runtime" { ): Promise; deployContract( name: string, - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; deployContract( name: string, args: any[], - signerOrOptions?: ethers.Signer | FactoryOptions + signerOrOptions?: ethers.Signer | DeployContractOptions ): Promise; } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 783ec14a1..c961779e8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -147,10 +147,10 @@ importers: version: 5.4.0 '@nomicfoundation/hardhat-chai-matchers': specifier: ^2.0.0 - version: 2.0.0(@nomicfoundation/hardhat-ethers@3.0.0)(chai@4.3.6)(ethers@6.3.0)(hardhat@2.9.9) + version: 2.0.0(@nomicfoundation/hardhat-ethers@3.0.4)(chai@4.3.6)(ethers@6.3.0)(hardhat@2.9.9) '@nomicfoundation/hardhat-ethers': - specifier: ^3.0.0 - version: 3.0.0(ethers@6.3.0)(hardhat@2.9.9) + specifier: ^3.0.4 + version: 3.0.4(ethers@6.3.0)(hardhat@2.9.9) '@typechain/ethers-v6': specifier: workspace:^0.4.0 version: link:../../packages/target-ethers-v6 @@ -2004,7 +2004,7 @@ packages: fastq: 1.13.0 dev: true - /@nomicfoundation/hardhat-chai-matchers@2.0.0(@nomicfoundation/hardhat-ethers@3.0.0)(chai@4.3.6)(ethers@6.3.0)(hardhat@2.9.9): + /@nomicfoundation/hardhat-chai-matchers@2.0.0(@nomicfoundation/hardhat-ethers@3.0.4)(chai@4.3.6)(ethers@6.3.0)(hardhat@2.9.9): resolution: {integrity: sha512-e2ZFunJBIWDcFKIxQt6GpFRRKUn8ZshoiZ5cmgaKOR1S9XwimiCs2aLUCZ/xjNrdl049kPqdVKYDj6aYeR6WuQ==} peerDependencies: '@nomicfoundation/hardhat-ethers': ^3.0.0 @@ -2013,7 +2013,7 @@ packages: hardhat: ^2.9.4 dependencies: '@ethersproject/abi': 5.6.0 - '@nomicfoundation/hardhat-ethers': 3.0.0(ethers@6.3.0)(hardhat@2.9.9) + '@nomicfoundation/hardhat-ethers': 3.0.4(ethers@6.3.0)(hardhat@2.9.9) '@types/chai-as-promised': 7.1.5 chai: 4.3.6 chai-as-promised: 7.1.1(chai@4.3.6) @@ -2029,8 +2029,22 @@ packages: ethers: ^6.1.0 hardhat: ^2.0.0 dependencies: + ethers: 6.3.0 + hardhat: 2.9.9(ts-node@10.7.0)(typescript@4.6.2) + dev: true + + /@nomicfoundation/hardhat-ethers@3.0.4(ethers@6.3.0)(hardhat@2.9.9): + resolution: {integrity: sha512-k9qbLoY7qn6C6Y1LI0gk2kyHXil2Tauj4kGzQ8pgxYXIGw8lWn8tuuL72E11CrlKaXRUvOgF0EXrv/msPI2SbA==} + peerDependencies: + ethers: ^6.1.0 + hardhat: ^2.0.0 + dependencies: + debug: 4.3.3(supports-color@8.1.1) ethers: 6.3.0 hardhat: 2.9.9(ts-node@10.7.0)(typescript@4.9.5) + lodash.isequal: 4.5.0 + transitivePeerDependencies: + - supports-color dev: true /@nomiclabs/hardhat-etherscan@2.1.8(hardhat@2.9.9): @@ -10115,8 +10129,7 @@ packages: dev: true /lodash.isequal@4.5.0: - resolution: {integrity: sha1-QVxEePK8wwEgwizhDtMib30+GOA=} - optional: true + resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} /lodash.keys@4.2.0: resolution: {integrity: sha1-oIYCrBLk+4P5H8H7ejYKTZujUgU=}