Skip to content

Commit e6bd016

Browse files
authored
[ethers-v5] fix for getContractAt incorrect type (#479)
1 parent f15a72c commit e6bd016

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

.changeset/unlucky-ties-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@typechain/ethers-v5': patch
3+
---
4+
5+
Fix typing for `getContractAt` when using Hardhat

packages/hardhat/test/fixture-projects/hardhat-project/typechain/hardhat.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ declare module "hardhat/types/runtime" {
3737
name: "EdgeCases",
3838
address: string,
3939
signer?: ethers.Signer
40-
): Promise<Contracts.EdgeCases__factory>;
40+
): Promise<Contracts.EdgeCases>;
4141
getContractAt(
4242
name: "SafeMath",
4343
address: string,
4444
signer?: ethers.Signer
45-
): Promise<Contracts.SafeMath__factory>;
45+
): Promise<Contracts.SafeMath>;
4646
getContractAt(
4747
name: "TestContract",
4848
address: string,
4949
signer?: ethers.Signer
50-
): Promise<Contracts.TestContract__factory>;
50+
): Promise<Contracts.TestContract>;
5151
getContractAt(
5252
name: "TestContract1",
5353
address: string,
5454
signer?: ethers.Signer
55-
): Promise<Contracts.TestContract1__factory>;
55+
): Promise<Contracts.TestContract1>;
5656
getContractAt(
5757
name: "ERC20",
5858
address: string,
5959
signer?: ethers.Signer
60-
): Promise<Contracts.ERC20__factory>;
60+
): Promise<Contracts.ERC20>;
6161

6262
// default types
6363
getContractFactory(
@@ -69,10 +69,10 @@ declare module "hardhat/types/runtime" {
6969
bytecode: ethers.utils.BytesLike,
7070
signer?: ethers.Signer
7171
): Promise<ethers.ContractFactory>;
72-
getContractAt: (
72+
getContractAt(
7373
nameOrAbi: string | any[],
7474
address: string,
7575
signer?: ethers.Signer
76-
) => Promise<ethers.Contract>;
76+
): Promise<ethers.Contract>;
7777
}
7878
}

packages/target-ethers-v5/src/codegen/hardhat.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ declare module "hardhat/types/runtime" {
2020
.join('\n')}
2121
2222
${contracts
23-
.map(
24-
(n) =>
25-
`getContractAt(name: '${n}', address: string, signer?: ethers.Signer): Promise<Contracts.${
26-
n + FACTORY_POSTFIX
27-
}>`,
28-
)
23+
.map((n) => `getContractAt(name: '${n}', address: string, signer?: ethers.Signer): Promise<Contracts.${n}>`)
2924
.join('\n')}
3025
3126
// default types
@@ -38,11 +33,11 @@ declare module "hardhat/types/runtime" {
3833
bytecode: ethers.utils.BytesLike,
3934
signer?: ethers.Signer
4035
): Promise<ethers.ContractFactory>;
41-
getContractAt: (
36+
getContractAt(
4237
nameOrAbi: string | any[],
4338
address: string,
4439
signer?: ethers.Signer
45-
) => Promise<ethers.Contract>;
40+
): Promise<ethers.Contract>;
4641
}
4742
}
4843
`

0 commit comments

Comments
 (0)