Skip to content

Commit a036651

Browse files
krzkaczoriainnash
andauthored
Fix for unused type in new ethers-v5 codegen (#831)
Co-authored-by: Iain <[email protected]>
1 parent b505397 commit a036651

File tree

11 files changed

+43
-52
lines changed

11 files changed

+43
-52
lines changed

.changeset/wise-kings-reply.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 for unused type in new ethers-v5 codegen

packages/hardhat-test/typechain-types/Directory/Hello.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../common";
1413

1514
export interface HelloInterface extends utils.Interface {

packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/contracts/EdgeCases.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../../common";
1413

1514
export interface EdgeCasesInterface extends utils.Interface {

packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/contracts/TestContract.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../../common";
1413

1514
export interface TestContractInterface extends utils.Interface {

packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/contracts/TestContract1.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../../common";
1413

1514
export interface TestContract1Interface extends utils.Interface {

packages/target-ethers-v5-test/types/v0.6.4/Issue428_Reproduction/A.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../../common";
1413

1514
export interface AInterface extends utils.Interface {

packages/target-ethers-v5-test/types/v0.6.4/Issue428_Reproduction/B.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
TypedEvent,
1010
TypedListener,
1111
OnEvent,
12-
PromiseOrValue,
1312
} from "../../common";
1413

1514
export interface BInterface extends utils.Interface {

packages/target-ethers-v5-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
TypedEvent,
1818
TypedListener,
1919
OnEvent,
20-
PromiseOrValue,
2120
} from "../../common";
2221

2322
export interface NAME12manglingInterface extends utils.Interface {

packages/target-ethers-v5-test/types/v0.8.9/nested/a/NestedLibrary.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
TypedEvent,
1818
TypedListener,
1919
OnEvent,
20-
PromiseOrValue,
2120
} from "../../../common";
2221

2322
export interface NestedLibraryInterface extends utils.Interface {

packages/target-ethers-v5-test/types/v0.8.9/nested/b/NestedLibrary.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
TypedEvent,
1818
TypedListener,
1919
OnEvent,
20-
PromiseOrValue,
2120
} from "../../../common";
2221

2322
export interface NestedLibraryInterface extends utils.Interface {

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

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
CodegenConfig,
55
Contract,
66
createImportsForUsedIdentifiers,
7-
createImportTypeDeclaration,
87
EventDeclaration,
98
FunctionDeclaration,
109
StructType,
@@ -120,29 +119,27 @@ export function codegenContractTypings(contract: Contract, codegenConfig: Codege
120119
? `${new Array(contract.path.length).fill('..').join('/')}/common`
121120
: './common'
122121

123-
const imports =
124-
createImportsForUsedIdentifiers(
125-
{
126-
'type ethers': [
127-
'BaseContract',
128-
'BigNumber',
129-
'BigNumberish',
130-
'BytesLike',
131-
'CallOverrides',
132-
'ContractTransaction',
133-
'Overrides',
134-
'PayableOverrides',
135-
'PopulatedTransaction',
136-
'Signer',
137-
'utils',
138-
],
139-
'type @ethersproject/abi': ['FunctionFragment', 'Result', 'EventFragment'],
140-
'type @ethersproject/providers': ['Listener', 'Provider'],
141-
},
142-
source,
143-
) +
144-
'\n' +
145-
createImportTypeDeclaration([...EVENT_IMPORTS, 'PromiseOrValue'], commonPath)
122+
const imports = createImportsForUsedIdentifiers(
123+
{
124+
'type ethers': [
125+
'BaseContract',
126+
'BigNumber',
127+
'BigNumberish',
128+
'BytesLike',
129+
'CallOverrides',
130+
'ContractTransaction',
131+
'Overrides',
132+
'PayableOverrides',
133+
'PopulatedTransaction',
134+
'Signer',
135+
'utils',
136+
],
137+
'type @ethersproject/abi': ['FunctionFragment', 'Result', 'EventFragment'],
138+
'type @ethersproject/providers': ['Listener', 'Provider'],
139+
[`type ${commonPath}`]: [...EVENT_IMPORTS, 'PromiseOrValue'],
140+
},
141+
source,
142+
)
146143

147144
return imports + source
148145
}
@@ -204,25 +201,23 @@ export function codegenContractFactory(
204201

205202
const commonPath = `${new Array(contract.path.length + 1).fill('..').join('/')}/common`
206203

207-
const imports =
208-
createImportsForUsedIdentifiers(
209-
{
210-
ethers: [
211-
'Signer',
212-
'utils',
213-
'Contract',
214-
'ContractFactory',
215-
'PayableOverrides',
216-
'BytesLike',
217-
'BigNumberish',
218-
'Overrides',
219-
],
220-
'type @ethersproject/providers': ['Provider', 'TransactionRequest'],
221-
},
222-
source,
223-
) +
224-
'\n' +
225-
createImportTypeDeclaration(['PromiseOrValue'], commonPath)
204+
const imports = createImportsForUsedIdentifiers(
205+
{
206+
ethers: [
207+
'Signer',
208+
'utils',
209+
'Contract',
210+
'ContractFactory',
211+
'PayableOverrides',
212+
'BytesLike',
213+
'BigNumberish',
214+
'Overrides',
215+
],
216+
'type @ethersproject/providers': ['Provider', 'TransactionRequest'],
217+
[`type ${commonPath}`]: ['PromiseOrValue'],
218+
},
219+
source,
220+
)
226221

227222
return imports + source
228223
}

0 commit comments

Comments
 (0)