From 41dbe2ad2fa47957529a1d3a18c0126502dc31f4 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Fri, 8 Dec 2023 10:11:14 +0100 Subject: [PATCH 1/6] add failing test demonstrating some of the current name clashes --- contracts/v0.8.9/NameClashes.sol | 17 ++ .../test/NameClashes.test.ts | 18 ++ .../factories/v0.8.9/NameClashes__factory.ts | 191 +++++++++++++++++ .../types/factories/v0.8.9/index.ts | 1 + packages/target-ethers-v6-test/types/index.ts | 2 + .../types/v0.8.9/NameClashes.ts | 194 ++++++++++++++++++ .../types/v0.8.9/index.ts | 1 + 7 files changed, 424 insertions(+) create mode 100644 contracts/v0.8.9/NameClashes.sol create mode 100644 packages/target-ethers-v6-test/test/NameClashes.test.ts create mode 100644 packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts create mode 100644 packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts diff --git a/contracts/v0.8.9/NameClashes.sol b/contracts/v0.8.9/NameClashes.sol new file mode 100644 index 000000000..6cb5546a8 --- /dev/null +++ b/contracts/v0.8.9/NameClashes.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.8.7; + +contract NameClashes { + address public target; + address public runner; + address public filters; + address public connect; + address public attach; + address public getAddress; + address public getDeployedCode; + address public getFunction; + address public on; + address public off; + address public once; + address public listeners; + address public then; +} diff --git a/packages/target-ethers-v6-test/test/NameClashes.test.ts b/packages/target-ethers-v6-test/test/NameClashes.test.ts new file mode 100644 index 000000000..cab361740 --- /dev/null +++ b/packages/target-ethers-v6-test/test/NameClashes.test.ts @@ -0,0 +1,18 @@ +import type { BaseContract } from 'ethers' +import type { AssertTrue, Has } from 'test-utils' + +import type { NameClashes } from '../types/v0.8.9/NameClashes' + +type _testTarget = AssertTrue> +type _testRunner = AssertTrue> +type _testFilters = AssertTrue> +type _testGetAddress = AssertTrue> +type _testGetDeployedCode = AssertTrue> +type _testGetFunction = AssertTrue> +type _testOn = AssertTrue> +type _testOff = AssertTrue> +type _testOnce = AssertTrue> +type _testListeners = AssertTrue> + +// "then" won't be passed through by ethers as it's listed in `passProperties` (see: https://github.com/ethers-io/ethers.js/blob/6ee1a5f8bb38ec31fa84c00aae7f091e1d3d6837/src.ts/contract/contract.ts#L779) +type _testThen = AssertTrue<'then' extends keyof NameClashes ? false : true> diff --git a/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts b/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts new file mode 100644 index 000000000..c4d8ee53c --- /dev/null +++ b/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts @@ -0,0 +1,191 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + NameClashes, + NameClashesInterface, +} from "../../v0.8.9/NameClashes"; + +const _abi = [ + { + inputs: [], + name: "attach", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "connect", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "filters", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getDeployedCode", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getFunction", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "listeners", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "off", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "on", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "once", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "runner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "target", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "then", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class NameClashes__factory { + static readonly abi = _abi; + static createInterface(): NameClashesInterface { + return new Interface(_abi) as NameClashesInterface; + } + static connect(address: string, runner?: ContractRunner | null): NameClashes { + return new Contract(address, _abi, runner) as unknown as NameClashes; + } +} diff --git a/packages/target-ethers-v6-test/types/factories/v0.8.9/index.ts b/packages/target-ethers-v6-test/types/factories/v0.8.9/index.ts index 964695c88..af7f489dd 100644 --- a/packages/target-ethers-v6-test/types/factories/v0.8.9/index.ts +++ b/packages/target-ethers-v6-test/types/factories/v0.8.9/index.ts @@ -6,4 +6,5 @@ export * as rarity from "./Rarity"; export * as nested from "./nested"; export { ISimpleToken__factory } from "./ISimpleToken__factory"; export { Issue552_Reproduction__factory } from "./Issue552_Reproduction__factory"; +export { NameClashes__factory } from "./NameClashes__factory"; export { SimpleToken__factory } from "./SimpleToken__factory"; diff --git a/packages/target-ethers-v6-test/types/index.ts b/packages/target-ethers-v6-test/types/index.ts index 86c671afb..0f56e2d84 100644 --- a/packages/target-ethers-v6-test/types/index.ts +++ b/packages/target-ethers-v6-test/types/index.ts @@ -38,6 +38,8 @@ export type { KingOfTheHill } from "./v0.8.9/KingOfTheHill/KingOfTheHill"; export { KingOfTheHill__factory } from "./factories/v0.8.9/KingOfTheHill/KingOfTheHill__factory"; export type { Withdrawable } from "./v0.8.9/KingOfTheHill/Withdrawable"; export { Withdrawable__factory } from "./factories/v0.8.9/KingOfTheHill/Withdrawable__factory"; +export type { NameClashes } from "./v0.8.9/NameClashes"; +export { NameClashes__factory } from "./factories/v0.8.9/NameClashes__factory"; export type { NestedLibrary } from "./v0.8.9/nested/a/NestedLibrary"; export { NestedLibrary__factory } from "./factories/v0.8.9/nested/a/NestedLibrary__factory"; export type { ERC721 } from "./v0.8.9/Rarity/ERC721"; diff --git a/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts new file mode 100644 index 000000000..970edeffa --- /dev/null +++ b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts @@ -0,0 +1,194 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "../common"; + +export interface NameClashesInterface extends Interface { + getFunction( + nameOrSignature: + | "attach" + | "connect" + | "filters" + | "getAddress" + | "getDeployedCode" + | "getFunction" + | "listeners" + | "off" + | "on" + | "once" + | "runner" + | "target" + | "then" + ): FunctionFragment; + + encodeFunctionData(functionFragment: "attach", values?: undefined): string; + encodeFunctionData(functionFragment: "connect", values?: undefined): string; + encodeFunctionData(functionFragment: "filters", values?: undefined): string; + encodeFunctionData( + functionFragment: "getAddress", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getDeployedCode", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getFunction", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "listeners", values?: undefined): string; + encodeFunctionData(functionFragment: "off", values?: undefined): string; + encodeFunctionData(functionFragment: "on", values?: undefined): string; + encodeFunctionData(functionFragment: "once", values?: undefined): string; + encodeFunctionData(functionFragment: "runner", values?: undefined): string; + encodeFunctionData(functionFragment: "target", values?: undefined): string; + encodeFunctionData(functionFragment: "then", values?: undefined): string; + + decodeFunctionResult(functionFragment: "attach", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "connect", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "filters", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getAddress", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getDeployedCode", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getFunction", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "listeners", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "off", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "on", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "once", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "runner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "target", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "then", data: BytesLike): Result; +} + +export interface NameClashes extends BaseContract { + connect(runner?: ContractRunner | null): NameClashes; + waitForDeployment(): Promise; + + interface: NameClashesInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + attach: TypedContractMethod<[], [string], "view">; + + filters: TypedContractMethod<[], [string], "view">; + + getAddress: TypedContractMethod<[], [string], "view">; + + getDeployedCode: TypedContractMethod<[], [string], "view">; + + getFunction: TypedContractMethod<[], [string], "view">; + + listeners: TypedContractMethod<[], [string], "view">; + + off: TypedContractMethod<[], [string], "view">; + + on: TypedContractMethod<[], [string], "view">; + + once: TypedContractMethod<[], [string], "view">; + + runner: TypedContractMethod<[], [string], "view">; + + target: TypedContractMethod<[], [string], "view">; + + then: TypedContractMethod<[], [string], "view">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "attach" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "connect" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "filters" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "getAddress" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "getDeployedCode" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "getFunction" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "listeners" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "off" + ): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "on"): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "once" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "runner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "target" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "then" + ): TypedContractMethod<[], [string], "view">; + + filters: {}; +} diff --git a/packages/target-ethers-v6-test/types/v0.8.9/index.ts b/packages/target-ethers-v6-test/types/v0.8.9/index.ts index 25c6eeca5..613fbc4b1 100644 --- a/packages/target-ethers-v6-test/types/v0.8.9/index.ts +++ b/packages/target-ethers-v6-test/types/v0.8.9/index.ts @@ -9,4 +9,5 @@ import type * as nested from "./nested"; export type { nested }; export type { ISimpleToken } from "./ISimpleToken"; export type { Issue552_Reproduction } from "./Issue552_Reproduction"; +export type { NameClashes } from "./NameClashes"; export type { SimpleToken } from "./SimpleToken"; From 92a92f5ffce9517d7df4ca84175b2a3c8c642056 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Fri, 8 Dec 2023 10:51:26 +0100 Subject: [PATCH 2/6] fix: ethers v6 name clashes read ethers built-ins instead of maintaining a property list --- contracts/v0.8.9/NameClashes.sol | 3 +++ .../v0.6.4/Name-Mangling/NAME12mangling.ts | 2 ++ .../types/v0.8.9/NameClashes.ts | 22 ------------------- .../target-ethers-v6/src/codegen/index.ts | 5 +++-- .../src/codegen/reserved-keywords.ts | 8 ++++++- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/contracts/v0.8.9/NameClashes.sol b/contracts/v0.8.9/NameClashes.sol index 6cb5546a8..fe6f0fc53 100644 --- a/contracts/v0.8.9/NameClashes.sol +++ b/contracts/v0.8.9/NameClashes.sol @@ -13,5 +13,8 @@ contract NameClashes { address public off; address public once; address public listeners; + address public signer; + address public provider; + address public deployed; address public then; } diff --git a/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts b/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts index dd97cdda8..c91b91415 100644 --- a/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts +++ b/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts @@ -72,6 +72,8 @@ export interface NAME12mangling extends BaseContract { event?: TCEvent ): Promise; + provider: TypedContractMethod<[], [boolean], "view">; + works: TypedContractMethod<[], [boolean], "view">; getFunction( diff --git a/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts index 970edeffa..19b08369c 100644 --- a/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts +++ b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts @@ -126,28 +126,6 @@ export interface NameClashes extends BaseContract { attach: TypedContractMethod<[], [string], "view">; - filters: TypedContractMethod<[], [string], "view">; - - getAddress: TypedContractMethod<[], [string], "view">; - - getDeployedCode: TypedContractMethod<[], [string], "view">; - - getFunction: TypedContractMethod<[], [string], "view">; - - listeners: TypedContractMethod<[], [string], "view">; - - off: TypedContractMethod<[], [string], "view">; - - on: TypedContractMethod<[], [string], "view">; - - once: TypedContractMethod<[], [string], "view">; - - runner: TypedContractMethod<[], [string], "view">; - - target: TypedContractMethod<[], [string], "view">; - - then: TypedContractMethod<[], [string], "view">; - getFunction( key: string | FunctionFragment ): T; diff --git a/packages/target-ethers-v6/src/codegen/index.ts b/packages/target-ethers-v6/src/codegen/index.ts index fa0ff9d16..697dd21e2 100644 --- a/packages/target-ethers-v6/src/codegen/index.ts +++ b/packages/target-ethers-v6/src/codegen/index.ts @@ -30,7 +30,7 @@ import { generateGetFunctionForInterface, generateParamNames, } from './functions' -import { reservedKeywords } from './reserved-keywords' +import { baseContractProperties, ethersPassProperties } from './reserved-keywords' import { generateStructTypes } from './structs' import { generateInputTypes } from './types' @@ -73,8 +73,9 @@ export function codegenContractTypings(contract: Contract, codegenConfig: Codege ${EVENT_METHOD_OVERRIDES} + ${values(contract.functions) - .filter((f) => !reservedKeywords.has(f[0].name)) + .filter((f) => !ethersPassProperties.has(f[0].name) && !baseContractProperties.has(f[0].name)) .map(codegenFunctions.bind(null, { codegenConfig })) .join('\n')} diff --git a/packages/target-ethers-v6/src/codegen/reserved-keywords.ts b/packages/target-ethers-v6/src/codegen/reserved-keywords.ts index 1cc0f1eed..f0567bd21 100644 --- a/packages/target-ethers-v6/src/codegen/reserved-keywords.ts +++ b/packages/target-ethers-v6/src/codegen/reserved-keywords.ts @@ -1,4 +1,10 @@ -export const reservedKeywords = new Set(['signer', 'provider', 'deployTransaction', 'deployed', 'fallback', 'connect']) +import { BaseContract } from 'ethers' + +export const ethersPassProperties = new Set(['then']) +export const baseContractProperties = new Set([ + ...Object.getOwnPropertyNames(BaseContract.prototype), // for methods + ...Object.keys(new BaseContract('0x', [])), // for readOnly properties +]) export const reservedKeywordsLabels = new Set([ 'class', From 50ff0eefd5fb6179c0b0c8645478c14dfb392f36 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Fri, 8 Dec 2023 11:07:47 +0100 Subject: [PATCH 3/6] add changeset --- .changeset/rotten-rockets-give.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rotten-rockets-give.md diff --git a/.changeset/rotten-rockets-give.md b/.changeset/rotten-rockets-give.md new file mode 100644 index 000000000..bae5d8741 --- /dev/null +++ b/.changeset/rotten-rockets-give.md @@ -0,0 +1,5 @@ +--- +'@typechain/ethers-v6': patch +--- + +Fix clashes with built-in contract properties From bd9bc86fdb296a507a110b8c3338a500cad3a5bc Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 9 Jan 2024 21:16:34 +0100 Subject: [PATCH 4/6] also fix reserved keywords for ethers-v5 --- .../target-ethers-v5/src/codegen/reserved-keywords.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/target-ethers-v5/src/codegen/reserved-keywords.ts b/packages/target-ethers-v5/src/codegen/reserved-keywords.ts index 478698758..61cb6d272 100644 --- a/packages/target-ethers-v5/src/codegen/reserved-keywords.ts +++ b/packages/target-ethers-v5/src/codegen/reserved-keywords.ts @@ -1 +1,7 @@ -export const reservedKeywords = new Set(['signer', 'provider', 'deployTransaction', 'deployed', 'fallback', 'connect']) +import { BaseContract } from 'ethers' + +export const reservedKeywords = new Set([ + 'then', + ...Object.getOwnPropertyNames(BaseContract.prototype), // for methods + ...Object.keys(new BaseContract('0x', [])), // for readOnly properties +]) From 083dea02d54e71983c0f5bbb5b2f5cc7dcb38864 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 9 Jan 2024 21:19:55 +0100 Subject: [PATCH 5/6] update changeset --- .changeset/{rotten-rockets-give.md => clean-cameras-destroy.md} | 1 + 1 file changed, 1 insertion(+) rename .changeset/{rotten-rockets-give.md => clean-cameras-destroy.md} (73%) diff --git a/.changeset/rotten-rockets-give.md b/.changeset/clean-cameras-destroy.md similarity index 73% rename from .changeset/rotten-rockets-give.md rename to .changeset/clean-cameras-destroy.md index bae5d8741..fdce8454f 100644 --- a/.changeset/rotten-rockets-give.md +++ b/.changeset/clean-cameras-destroy.md @@ -1,4 +1,5 @@ --- +'@typechain/ethers-v5': patch '@typechain/ethers-v6': patch --- From eaff379485a655d7f343f3b513448966562ab5a5 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Wed, 10 Jul 2024 12:41:31 +0200 Subject: [PATCH 6/6] fix a bug, making all tests green --- .../factories/v0.8.9/NameClashes__factory.ts | 234 ++++++++++++++ .../types/factories/v0.8.9/index.ts | 1 + packages/target-ethers-v5-test/types/index.ts | 2 + .../types/v0.8.9/NameClashes.ts | 301 ++++++++++++++++++ .../types/v0.8.9/index.ts | 1 + .../src/codegen/reserved-keywords.ts | 4 +- .../factories/v0.8.9/NameClashes__factory.ts | 39 +++ .../v0.6.4/Name-Mangling/NAME12mangling.ts | 2 - .../types/v0.8.9/NameClashes.ts | 40 +++ .../types/v0.8.9/NameClashes.ts | 67 ++++ .../target-web3-v1-test/types/v0.8.9/index.ts | 1 + 11 files changed, 688 insertions(+), 4 deletions(-) create mode 100644 packages/target-ethers-v5-test/types/factories/v0.8.9/NameClashes__factory.ts create mode 100644 packages/target-ethers-v5-test/types/v0.8.9/NameClashes.ts create mode 100644 packages/target-web3-v1-test/types/v0.8.9/NameClashes.ts diff --git a/packages/target-ethers-v5-test/types/factories/v0.8.9/NameClashes__factory.ts b/packages/target-ethers-v5-test/types/factories/v0.8.9/NameClashes__factory.ts new file mode 100644 index 000000000..2ce1ee94b --- /dev/null +++ b/packages/target-ethers-v5-test/types/factories/v0.8.9/NameClashes__factory.ts @@ -0,0 +1,234 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { + NameClashes, + NameClashesInterface, +} from "../../v0.8.9/NameClashes"; + +const _abi = [ + { + inputs: [], + name: "attach", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "connect", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "deployed", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "filters", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getDeployedCode", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getFunction", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "listeners", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "off", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "on", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "once", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "provider", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "runner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "signer", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "target", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "then", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class NameClashes__factory { + static readonly abi = _abi; + static createInterface(): NameClashesInterface { + return new utils.Interface(_abi) as NameClashesInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): NameClashes { + return new Contract(address, _abi, signerOrProvider) as NameClashes; + } +} diff --git a/packages/target-ethers-v5-test/types/factories/v0.8.9/index.ts b/packages/target-ethers-v5-test/types/factories/v0.8.9/index.ts index 964695c88..af7f489dd 100644 --- a/packages/target-ethers-v5-test/types/factories/v0.8.9/index.ts +++ b/packages/target-ethers-v5-test/types/factories/v0.8.9/index.ts @@ -6,4 +6,5 @@ export * as rarity from "./Rarity"; export * as nested from "./nested"; export { ISimpleToken__factory } from "./ISimpleToken__factory"; export { Issue552_Reproduction__factory } from "./Issue552_Reproduction__factory"; +export { NameClashes__factory } from "./NameClashes__factory"; export { SimpleToken__factory } from "./SimpleToken__factory"; diff --git a/packages/target-ethers-v5-test/types/index.ts b/packages/target-ethers-v5-test/types/index.ts index 86c671afb..0f56e2d84 100644 --- a/packages/target-ethers-v5-test/types/index.ts +++ b/packages/target-ethers-v5-test/types/index.ts @@ -38,6 +38,8 @@ export type { KingOfTheHill } from "./v0.8.9/KingOfTheHill/KingOfTheHill"; export { KingOfTheHill__factory } from "./factories/v0.8.9/KingOfTheHill/KingOfTheHill__factory"; export type { Withdrawable } from "./v0.8.9/KingOfTheHill/Withdrawable"; export { Withdrawable__factory } from "./factories/v0.8.9/KingOfTheHill/Withdrawable__factory"; +export type { NameClashes } from "./v0.8.9/NameClashes"; +export { NameClashes__factory } from "./factories/v0.8.9/NameClashes__factory"; export type { NestedLibrary } from "./v0.8.9/nested/a/NestedLibrary"; export { NestedLibrary__factory } from "./factories/v0.8.9/nested/a/NestedLibrary__factory"; export type { ERC721 } from "./v0.8.9/Rarity/ERC721"; diff --git a/packages/target-ethers-v5-test/types/v0.8.9/NameClashes.ts b/packages/target-ethers-v5-test/types/v0.8.9/NameClashes.ts new file mode 100644 index 000000000..2302094de --- /dev/null +++ b/packages/target-ethers-v5-test/types/v0.8.9/NameClashes.ts @@ -0,0 +1,301 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BytesLike, + CallOverrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { FunctionFragment, Result } from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from "../common"; + +export interface NameClashesInterface extends utils.Interface { + functions: { + "attach()": FunctionFragment; + "connect()": FunctionFragment; + "deployed()": FunctionFragment; + "filters()": FunctionFragment; + "getAddress()": FunctionFragment; + "getDeployedCode()": FunctionFragment; + "getFunction()": FunctionFragment; + "listeners()": FunctionFragment; + "off()": FunctionFragment; + "on()": FunctionFragment; + "once()": FunctionFragment; + "provider()": FunctionFragment; + "runner()": FunctionFragment; + "signer()": FunctionFragment; + "target()": FunctionFragment; + "then()": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | "attach" + | "connect" + | "deployed" + | "filters" + | "getAddress" + | "getDeployedCode" + | "getFunction" + | "listeners" + | "off" + | "on" + | "once" + | "provider" + | "runner" + | "signer" + | "target" + | "then" + ): FunctionFragment; + + encodeFunctionData(functionFragment: "attach", values?: undefined): string; + encodeFunctionData(functionFragment: "connect", values?: undefined): string; + encodeFunctionData(functionFragment: "deployed", values?: undefined): string; + encodeFunctionData(functionFragment: "filters", values?: undefined): string; + encodeFunctionData( + functionFragment: "getAddress", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getDeployedCode", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getFunction", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "listeners", values?: undefined): string; + encodeFunctionData(functionFragment: "off", values?: undefined): string; + encodeFunctionData(functionFragment: "on", values?: undefined): string; + encodeFunctionData(functionFragment: "once", values?: undefined): string; + encodeFunctionData(functionFragment: "provider", values?: undefined): string; + encodeFunctionData(functionFragment: "runner", values?: undefined): string; + encodeFunctionData(functionFragment: "signer", values?: undefined): string; + encodeFunctionData(functionFragment: "target", values?: undefined): string; + encodeFunctionData(functionFragment: "then", values?: undefined): string; + + decodeFunctionResult(functionFragment: "attach", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "connect", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "deployed", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "filters", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getAddress", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getDeployedCode", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getFunction", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "listeners", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "off", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "on", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "once", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "provider", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "runner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "signer", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "target", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "then", data: BytesLike): Result; + + events: {}; +} + +export interface NameClashes extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: NameClashesInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + attach(overrides?: CallOverrides): Promise<[string]>; + + connect(overrides?: CallOverrides): Promise<[string]>; + + deployed(overrides?: CallOverrides): Promise<[string]>; + + filters(overrides?: CallOverrides): Promise<[string]>; + + getAddress(overrides?: CallOverrides): Promise<[string]>; + + getDeployedCode(overrides?: CallOverrides): Promise<[string]>; + + getFunction(overrides?: CallOverrides): Promise<[string]>; + + listeners(overrides?: CallOverrides): Promise<[string]>; + + off(overrides?: CallOverrides): Promise<[string]>; + + on(overrides?: CallOverrides): Promise<[string]>; + + once(overrides?: CallOverrides): Promise<[string]>; + + provider(overrides?: CallOverrides): Promise<[string]>; + + runner(overrides?: CallOverrides): Promise<[string]>; + + signer(overrides?: CallOverrides): Promise<[string]>; + + target(overrides?: CallOverrides): Promise<[string]>; + + then(overrides?: CallOverrides): Promise<[string]>; + }; + + attach(overrides?: CallOverrides): Promise; + + filters(overrides?: CallOverrides): Promise; + + getAddress(overrides?: CallOverrides): Promise; + + getDeployedCode(overrides?: CallOverrides): Promise; + + getFunction(overrides?: CallOverrides): Promise; + + listeners(overrides?: CallOverrides): Promise; + + off(overrides?: CallOverrides): Promise; + + on(overrides?: CallOverrides): Promise; + + once(overrides?: CallOverrides): Promise; + + runner(overrides?: CallOverrides): Promise; + + target(overrides?: CallOverrides): Promise; + + then(overrides?: CallOverrides): Promise; + + callStatic: { + attach(overrides?: CallOverrides): Promise; + + connect(overrides?: CallOverrides): Promise; + + deployed(overrides?: CallOverrides): Promise; + + filters(overrides?: CallOverrides): Promise; + + getAddress(overrides?: CallOverrides): Promise; + + getDeployedCode(overrides?: CallOverrides): Promise; + + getFunction(overrides?: CallOverrides): Promise; + + listeners(overrides?: CallOverrides): Promise; + + off(overrides?: CallOverrides): Promise; + + on(overrides?: CallOverrides): Promise; + + once(overrides?: CallOverrides): Promise; + + provider(overrides?: CallOverrides): Promise; + + runner(overrides?: CallOverrides): Promise; + + signer(overrides?: CallOverrides): Promise; + + target(overrides?: CallOverrides): Promise; + + then(overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + attach(overrides?: CallOverrides): Promise; + + connect(overrides?: CallOverrides): Promise; + + deployed(overrides?: CallOverrides): Promise; + + filters(overrides?: CallOverrides): Promise; + + getAddress(overrides?: CallOverrides): Promise; + + getDeployedCode(overrides?: CallOverrides): Promise; + + getFunction(overrides?: CallOverrides): Promise; + + listeners(overrides?: CallOverrides): Promise; + + off(overrides?: CallOverrides): Promise; + + on(overrides?: CallOverrides): Promise; + + once(overrides?: CallOverrides): Promise; + + provider(overrides?: CallOverrides): Promise; + + runner(overrides?: CallOverrides): Promise; + + signer(overrides?: CallOverrides): Promise; + + target(overrides?: CallOverrides): Promise; + + then(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + attach(overrides?: CallOverrides): Promise; + + connect(overrides?: CallOverrides): Promise; + + deployed(overrides?: CallOverrides): Promise; + + filters(overrides?: CallOverrides): Promise; + + getAddress(overrides?: CallOverrides): Promise; + + getDeployedCode(overrides?: CallOverrides): Promise; + + getFunction(overrides?: CallOverrides): Promise; + + listeners(overrides?: CallOverrides): Promise; + + off(overrides?: CallOverrides): Promise; + + on(overrides?: CallOverrides): Promise; + + once(overrides?: CallOverrides): Promise; + + provider(overrides?: CallOverrides): Promise; + + runner(overrides?: CallOverrides): Promise; + + signer(overrides?: CallOverrides): Promise; + + target(overrides?: CallOverrides): Promise; + + then(overrides?: CallOverrides): Promise; + }; +} diff --git a/packages/target-ethers-v5-test/types/v0.8.9/index.ts b/packages/target-ethers-v5-test/types/v0.8.9/index.ts index 25c6eeca5..613fbc4b1 100644 --- a/packages/target-ethers-v5-test/types/v0.8.9/index.ts +++ b/packages/target-ethers-v5-test/types/v0.8.9/index.ts @@ -9,4 +9,5 @@ import type * as nested from "./nested"; export type { nested }; export type { ISimpleToken } from "./ISimpleToken"; export type { Issue552_Reproduction } from "./Issue552_Reproduction"; +export type { NameClashes } from "./NameClashes"; export type { SimpleToken } from "./SimpleToken"; diff --git a/packages/target-ethers-v5/src/codegen/reserved-keywords.ts b/packages/target-ethers-v5/src/codegen/reserved-keywords.ts index 61cb6d272..047b3aa63 100644 --- a/packages/target-ethers-v5/src/codegen/reserved-keywords.ts +++ b/packages/target-ethers-v5/src/codegen/reserved-keywords.ts @@ -1,7 +1,7 @@ -import { BaseContract } from 'ethers' +import { BaseContract, constants } from 'ethers' export const reservedKeywords = new Set([ 'then', ...Object.getOwnPropertyNames(BaseContract.prototype), // for methods - ...Object.keys(new BaseContract('0x', [])), // for readOnly properties + ...Object.keys(new BaseContract(constants.AddressZero, [])), // for readOnly properties ]) diff --git a/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts b/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts index c4d8ee53c..09f0b33bf 100644 --- a/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts +++ b/packages/target-ethers-v6-test/types/factories/v0.8.9/NameClashes__factory.ts @@ -35,6 +35,19 @@ const _abi = [ stateMutability: "view", type: "function", }, + { + inputs: [], + name: "deployed", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [], name: "filters", @@ -139,6 +152,19 @@ const _abi = [ stateMutability: "view", type: "function", }, + { + inputs: [], + name: "provider", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [], name: "runner", @@ -152,6 +178,19 @@ const _abi = [ stateMutability: "view", type: "function", }, + { + inputs: [], + name: "signer", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [], name: "target", diff --git a/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts b/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts index c91b91415..dd97cdda8 100644 --- a/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts +++ b/packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts @@ -72,8 +72,6 @@ export interface NAME12mangling extends BaseContract { event?: TCEvent ): Promise; - provider: TypedContractMethod<[], [boolean], "view">; - works: TypedContractMethod<[], [boolean], "view">; getFunction( diff --git a/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts index 19b08369c..0e319e0cd 100644 --- a/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts +++ b/packages/target-ethers-v6-test/types/v0.8.9/NameClashes.ts @@ -24,6 +24,7 @@ export interface NameClashesInterface extends Interface { nameOrSignature: | "attach" | "connect" + | "deployed" | "filters" | "getAddress" | "getDeployedCode" @@ -32,13 +33,16 @@ export interface NameClashesInterface extends Interface { | "off" | "on" | "once" + | "provider" | "runner" + | "signer" | "target" | "then" ): FunctionFragment; encodeFunctionData(functionFragment: "attach", values?: undefined): string; encodeFunctionData(functionFragment: "connect", values?: undefined): string; + encodeFunctionData(functionFragment: "deployed", values?: undefined): string; encodeFunctionData(functionFragment: "filters", values?: undefined): string; encodeFunctionData( functionFragment: "getAddress", @@ -56,12 +60,15 @@ export interface NameClashesInterface extends Interface { encodeFunctionData(functionFragment: "off", values?: undefined): string; encodeFunctionData(functionFragment: "on", values?: undefined): string; encodeFunctionData(functionFragment: "once", values?: undefined): string; + encodeFunctionData(functionFragment: "provider", values?: undefined): string; encodeFunctionData(functionFragment: "runner", values?: undefined): string; + encodeFunctionData(functionFragment: "signer", values?: undefined): string; encodeFunctionData(functionFragment: "target", values?: undefined): string; encodeFunctionData(functionFragment: "then", values?: undefined): string; decodeFunctionResult(functionFragment: "attach", data: BytesLike): Result; decodeFunctionResult(functionFragment: "connect", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "deployed", data: BytesLike): Result; decodeFunctionResult(functionFragment: "filters", data: BytesLike): Result; decodeFunctionResult(functionFragment: "getAddress", data: BytesLike): Result; decodeFunctionResult( @@ -76,7 +83,9 @@ export interface NameClashesInterface extends Interface { decodeFunctionResult(functionFragment: "off", data: BytesLike): Result; decodeFunctionResult(functionFragment: "on", data: BytesLike): Result; decodeFunctionResult(functionFragment: "once", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "provider", data: BytesLike): Result; decodeFunctionResult(functionFragment: "runner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "signer", data: BytesLike): Result; decodeFunctionResult(functionFragment: "target", data: BytesLike): Result; decodeFunctionResult(functionFragment: "then", data: BytesLike): Result; } @@ -126,6 +135,28 @@ export interface NameClashes extends BaseContract { attach: TypedContractMethod<[], [string], "view">; + filters: TypedContractMethod<[], [string], "view">; + + getAddress: TypedContractMethod<[], [string], "view">; + + getDeployedCode: TypedContractMethod<[], [string], "view">; + + getFunction: TypedContractMethod<[], [string], "view">; + + listeners: TypedContractMethod<[], [string], "view">; + + off: TypedContractMethod<[], [string], "view">; + + on: TypedContractMethod<[], [string], "view">; + + once: TypedContractMethod<[], [string], "view">; + + runner: TypedContractMethod<[], [string], "view">; + + target: TypedContractMethod<[], [string], "view">; + + then: TypedContractMethod<[], [string], "view">; + getFunction( key: string | FunctionFragment ): T; @@ -136,6 +167,9 @@ export interface NameClashes extends BaseContract { getFunction( nameOrSignature: "connect" ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "deployed" + ): TypedContractMethod<[], [string], "view">; getFunction( nameOrSignature: "filters" ): TypedContractMethod<[], [string], "view">; @@ -158,9 +192,15 @@ export interface NameClashes extends BaseContract { getFunction( nameOrSignature: "once" ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "provider" + ): TypedContractMethod<[], [string], "view">; getFunction( nameOrSignature: "runner" ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "signer" + ): TypedContractMethod<[], [string], "view">; getFunction( nameOrSignature: "target" ): TypedContractMethod<[], [string], "view">; diff --git a/packages/target-web3-v1-test/types/v0.8.9/NameClashes.ts b/packages/target-web3-v1-test/types/v0.8.9/NameClashes.ts new file mode 100644 index 000000000..f8e469bd6 --- /dev/null +++ b/packages/target-web3-v1-test/types/v0.8.9/NameClashes.ts @@ -0,0 +1,67 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import type BN from "bn.js"; +import type { ContractOptions } from "web3-eth-contract"; +import type { EventLog } from "web3-core"; +import type { EventEmitter } from "events"; +import type { + Callback, + PayableTransactionObject, + NonPayableTransactionObject, + BlockType, + ContractEventLog, + BaseContract, +} from "../types"; + +export interface EventOptions { + filter?: object; + fromBlock?: BlockType; + topics?: string[]; +} + +export interface NameClashes extends BaseContract { + constructor( + jsonInterface: any[], + address?: string, + options?: ContractOptions + ): NameClashes; + clone(): NameClashes; + methods: { + attach(): NonPayableTransactionObject; + + connect(): NonPayableTransactionObject; + + deployed(): NonPayableTransactionObject; + + filters(): NonPayableTransactionObject; + + getAddress(): NonPayableTransactionObject; + + getDeployedCode(): NonPayableTransactionObject; + + getFunction(): NonPayableTransactionObject; + + listeners(): NonPayableTransactionObject; + + off(): NonPayableTransactionObject; + + on(): NonPayableTransactionObject; + + once(): NonPayableTransactionObject; + + provider(): NonPayableTransactionObject; + + runner(): NonPayableTransactionObject; + + signer(): NonPayableTransactionObject; + + target(): NonPayableTransactionObject; + + then(): NonPayableTransactionObject; + }; + events: { + allEvents(options?: EventOptions, cb?: Callback): EventEmitter; + }; +} diff --git a/packages/target-web3-v1-test/types/v0.8.9/index.ts b/packages/target-web3-v1-test/types/v0.8.9/index.ts index 25c6eeca5..613fbc4b1 100644 --- a/packages/target-web3-v1-test/types/v0.8.9/index.ts +++ b/packages/target-web3-v1-test/types/v0.8.9/index.ts @@ -9,4 +9,5 @@ import type * as nested from "./nested"; export type { nested }; export type { ISimpleToken } from "./ISimpleToken"; export type { Issue552_Reproduction } from "./Issue552_Reproduction"; +export type { NameClashes } from "./NameClashes"; export type { SimpleToken } from "./SimpleToken";