Skip to content

Commit

Permalink
Fix for unused type in new ethers-v5 codegen (#831)
Browse files Browse the repository at this point in the history
Co-authored-by: Iain <iain@zora.co>
  • Loading branch information
krzkaczor and iainnash committed May 7, 2023
1 parent b505397 commit a036651
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-kings-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@typechain/ethers-v5": patch
---

Fix for unused type in new ethers-v5 codegen
1 change: 0 additions & 1 deletion packages/hardhat-test/typechain-types/Directory/Hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../common";

export interface HelloInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface EdgeCasesInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface TestContractInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface TestContract1Interface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface AInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface BInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface NAME12manglingInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../common";

export interface NestedLibraryInterface extends utils.Interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../common";

export interface NestedLibraryInterface extends utils.Interface {
Expand Down
81 changes: 38 additions & 43 deletions packages/target-ethers-v5/src/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CodegenConfig,
Contract,
createImportsForUsedIdentifiers,
createImportTypeDeclaration,
EventDeclaration,
FunctionDeclaration,
StructType,
Expand Down Expand Up @@ -120,29 +119,27 @@ export function codegenContractTypings(contract: Contract, codegenConfig: Codege
? `${new Array(contract.path.length).fill('..').join('/')}/common`
: './common'

const imports =
createImportsForUsedIdentifiers(
{
'type ethers': [
'BaseContract',
'BigNumber',
'BigNumberish',
'BytesLike',
'CallOverrides',
'ContractTransaction',
'Overrides',
'PayableOverrides',
'PopulatedTransaction',
'Signer',
'utils',
],
'type @ethersproject/abi': ['FunctionFragment', 'Result', 'EventFragment'],
'type @ethersproject/providers': ['Listener', 'Provider'],
},
source,
) +
'\n' +
createImportTypeDeclaration([...EVENT_IMPORTS, 'PromiseOrValue'], commonPath)
const imports = createImportsForUsedIdentifiers(
{
'type ethers': [
'BaseContract',
'BigNumber',
'BigNumberish',
'BytesLike',
'CallOverrides',
'ContractTransaction',
'Overrides',
'PayableOverrides',
'PopulatedTransaction',
'Signer',
'utils',
],
'type @ethersproject/abi': ['FunctionFragment', 'Result', 'EventFragment'],
'type @ethersproject/providers': ['Listener', 'Provider'],
[`type ${commonPath}`]: [...EVENT_IMPORTS, 'PromiseOrValue'],
},
source,
)

return imports + source
}
Expand Down Expand Up @@ -204,25 +201,23 @@ export function codegenContractFactory(

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

const imports =
createImportsForUsedIdentifiers(
{
ethers: [
'Signer',
'utils',
'Contract',
'ContractFactory',
'PayableOverrides',
'BytesLike',
'BigNumberish',
'Overrides',
],
'type @ethersproject/providers': ['Provider', 'TransactionRequest'],
},
source,
) +
'\n' +
createImportTypeDeclaration(['PromiseOrValue'], commonPath)
const imports = createImportsForUsedIdentifiers(
{
ethers: [
'Signer',
'utils',
'Contract',
'ContractFactory',
'PayableOverrides',
'BytesLike',
'BigNumberish',
'Overrides',
],
'type @ethersproject/providers': ['Provider', 'TransactionRequest'],
[`type ${commonPath}`]: ['PromiseOrValue'],
},
source,
)

return imports + source
}
Expand Down

0 comments on commit a036651

Please sign in to comment.