├── .changeset └── config.json ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .mocharc.js ├── .nvmrc ├── .pnpmfile.cjs ├── .prettierignore ├── .prettierrc ├── CONTRIBUTING.md ├── FUNDING.json ├── LICENSE ├── README.md ├── contracts ├── v0.6.4 │ ├── DataTypesInput.sol │ ├── DataTypesPure.sol │ ├── DataTypesView.sol │ ├── Events.sol │ ├── Issue428_Reproduction.sol │ ├── Library.sol │ ├── LibraryConsumer.sol │ ├── Name-Mangling.sol │ ├── Overloads.sol │ └── Payable │ │ ├── Payable.sol │ │ └── PayableFactory.sol └── v0.8.9 │ ├── ISimpleToken.sol │ ├── Issue552_Reproduction.sol │ ├── KingOfTheHill.sol │ ├── Rarity.sol │ ├── SimpleToken.sol │ └── nested │ ├── a │ └── NestedLibrary.json │ └── b │ └── NestedLibrary.json ├── docs └── images │ ├── aave-logo.png │ ├── arbitrum-logo.png │ ├── kyber-logo.png │ ├── maker-logo.png │ ├── optimism-logo.png │ ├── typechain-logo-black-bg.png │ ├── typechain-logo.png │ ├── uniswap-logo.png │ └── zksync-logo.png ├── examples ├── ethers-v5-nodenext │ ├── README.md │ ├── abi │ │ └── dai.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── types │ │ └── ethers-contracts │ │ ├── Dai.ts │ │ ├── common.ts │ │ ├── factories │ │ ├── Dai__factory.ts │ │ └── index.ts │ │ └── index.ts ├── ethers-v5 │ ├── README.md │ ├── abi │ │ └── dai.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── ethers-v6-nodenext │ ├── README.md │ ├── abi │ │ └── dai.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── types │ │ └── ethers-contracts │ │ ├── Dai.ts │ │ ├── common.ts │ │ ├── factories │ │ ├── Dai__factory.ts │ │ └── index.ts │ │ └── index.ts ├── ethers-v6 │ ├── README.md │ ├── abi │ │ └── dai.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── types │ │ └── ethers-contracts │ │ ├── Dai.ts │ │ ├── common.ts │ │ ├── factories │ │ ├── Dai__factory.ts │ │ └── index.ts │ │ └── index.ts ├── hardhat-truffe-v5 │ ├── README.md │ ├── contracts │ │ └── Counter.sol │ ├── hardhat.config.ts │ ├── package.json │ ├── test │ │ └── counter.ts │ └── tsconfig.json ├── hardhat │ ├── Counter.ts │ ├── README.md │ ├── contracts │ │ └── Counter.sol │ ├── hardhat.config.ts │ ├── package.json │ ├── test │ │ └── counter.ts │ └── tsconfig.json ├── truffle-v5 │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── contracts │ │ ├── ConvertLib.sol │ │ ├── MetaCoin.sol │ │ └── Migrations.sol │ ├── migrations-ts │ │ ├── 1_initial_migration.ts │ │ └── 2_deploy_contracts.ts │ ├── package.json │ ├── test │ │ └── metacoin.ts │ ├── truffle-config.js │ ├── tsconfig.json │ └── tsconfig.migrate.json └── web3-v1 │ ├── README.md │ ├── abi │ └── dai.json │ ├── package.json │ ├── src │ └── index.ts │ └── tsconfig.json ├── package.json ├── packages ├── hardhat-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── contracts │ │ ├── Counter.sol │ │ ├── Demo.sol │ │ ├── Directory │ │ │ └── Hello.sol │ │ └── StructsInConstructor.sol │ ├── hardhat.config.ts │ ├── package.json │ ├── test │ │ └── hardhat.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── typechain-types │ │ ├── Counter.ts │ │ ├── Demo.ts │ │ ├── Directory │ │ ├── Hello.ts │ │ └── index.ts │ │ ├── StructsInConstructor.ts │ │ ├── common.ts │ │ ├── factories │ │ ├── Counter__factory.ts │ │ ├── Demo__factory.ts │ │ ├── Directory │ │ │ ├── Hello__factory.ts │ │ │ └── index.ts │ │ ├── StructsInConstructor__factory.ts │ │ └── index.ts │ │ ├── hardhat.d.ts │ │ └── index.ts ├── hardhat │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── config.ts │ │ ├── constants.ts │ │ ├── index.ts │ │ ├── type-extensions.ts │ │ └── types.ts │ ├── test │ │ ├── __snapshots__ │ │ │ └── project.test.snap │ │ ├── fixture-files │ │ │ └── TestContract2.sol │ │ ├── fixture-projects │ │ │ ├── .gitignore │ │ │ ├── hardhat-project │ │ │ │ ├── contracts │ │ │ │ │ ├── EdgeCases.sol │ │ │ │ │ ├── TestContract.sol │ │ │ │ │ ├── TestContract1.sol │ │ │ │ │ └── lib │ │ │ │ │ │ └── SafeMath.sol │ │ │ │ ├── externalArtifacts │ │ │ │ │ └── ERC20.json │ │ │ │ ├── hardhat.config.ts │ │ │ │ └── typechain-types │ │ │ │ │ ├── artifacts │ │ │ │ │ ├── contracts │ │ │ │ │ │ ├── EdgeCases.ts │ │ │ │ │ │ ├── TestContract.ts │ │ │ │ │ │ ├── TestContract1.ts │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ └── lib │ │ │ │ │ │ │ ├── SafeMath.ts │ │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── index.ts │ │ │ │ │ ├── common.ts │ │ │ │ │ ├── externalArtifacts │ │ │ │ │ ├── ERC20.ts │ │ │ │ │ └── index.ts │ │ │ │ │ ├── factories │ │ │ │ │ ├── artifacts │ │ │ │ │ │ ├── contracts │ │ │ │ │ │ │ ├── EdgeCases__factory.ts │ │ │ │ │ │ │ ├── TestContract1__factory.ts │ │ │ │ │ │ │ ├── TestContract__factory.ts │ │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ │ └── lib │ │ │ │ │ │ │ │ ├── SafeMath__factory.ts │ │ │ │ │ │ │ │ └── index.ts │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── externalArtifacts │ │ │ │ │ │ ├── ERC20__factory.ts │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── index.ts │ │ │ │ │ ├── hardhat.d.ts │ │ │ │ │ └── index.ts │ │ │ └── no-override-project │ │ │ │ ├── contracts │ │ │ │ └── c.sol │ │ │ │ └── hardhat.config.ts │ │ ├── helpers.ts │ │ └── project.test.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── target-ethers-v5-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── package.json │ ├── test │ │ ├── DataTypesInput.test.ts │ │ ├── Events.test.ts │ │ ├── Issue552Reproduction.test.ts │ │ ├── Overload.test.ts │ │ ├── Polymorphism.test.ts │ │ └── common.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── types │ │ ├── common.ts │ │ ├── factories │ │ ├── index.ts │ │ ├── v0.6.4 │ │ │ ├── DataTypesInput__factory.ts │ │ │ ├── DataTypesPure__factory.ts │ │ │ ├── DataTypesView__factory.ts │ │ │ ├── Events__factory.ts │ │ │ ├── Issue428_Reproduction │ │ │ │ ├── A__factory.ts │ │ │ │ ├── B__factory.ts │ │ │ │ └── index.ts │ │ │ ├── Library │ │ │ │ ├── Lib__factory.ts │ │ │ │ └── index.ts │ │ │ ├── LibraryConsumer__factory.ts │ │ │ ├── Name-Mangling │ │ │ │ ├── NAME12mangling__factory.ts │ │ │ │ └── index.ts │ │ │ ├── Overloads__factory.ts │ │ │ ├── Payable │ │ │ │ ├── PayableFactory__factory.ts │ │ │ │ ├── Payable__factory.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── v0.8.9 │ │ │ ├── ISimpleToken__factory.ts │ │ │ ├── Issue552_Reproduction__factory.ts │ │ │ ├── KingOfTheHill │ │ │ ├── KingOfTheHill__factory.ts │ │ │ ├── Withdrawable__factory.ts │ │ │ └── index.ts │ │ │ ├── Rarity │ │ │ ├── ERC721Enumerable__factory.ts │ │ │ ├── ERC721__factory.ts │ │ │ ├── IERC721Enumerable__factory.ts │ │ │ ├── IERC721Receiver__factory.ts │ │ │ ├── IERC721__factory.ts │ │ │ ├── Rarity__factory.ts │ │ │ └── index.ts │ │ │ ├── SimpleToken__factory.ts │ │ │ ├── index.ts │ │ │ └── nested │ │ │ ├── a │ │ │ ├── NestedLibrary__factory.ts │ │ │ └── index.ts │ │ │ ├── b │ │ │ ├── NestedLibrary__factory.ts │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── v0.6.4 │ │ ├── DataTypesInput.ts │ │ ├── DataTypesPure.ts │ │ ├── DataTypesView.ts │ │ ├── Events.ts │ │ ├── Issue428_Reproduction │ │ │ ├── A.ts │ │ │ ├── B.ts │ │ │ └── index.ts │ │ ├── Library │ │ │ ├── Lib.ts │ │ │ └── index.ts │ │ ├── LibraryConsumer.ts │ │ ├── Name-Mangling │ │ │ ├── NAME12mangling.ts │ │ │ └── index.ts │ │ ├── Overloads.ts │ │ ├── Payable │ │ │ ├── Payable.ts │ │ │ ├── PayableFactory.ts │ │ │ └── index.ts │ │ └── index.ts │ │ └── v0.8.9 │ │ ├── ISimpleToken.ts │ │ ├── Issue552_Reproduction.ts │ │ ├── KingOfTheHill │ │ ├── KingOfTheHill.ts │ │ ├── Withdrawable.ts │ │ └── index.ts │ │ ├── Rarity │ │ ├── ERC721.ts │ │ ├── ERC721Enumerable.ts │ │ ├── IERC721.ts │ │ ├── IERC721Enumerable.ts │ │ ├── IERC721Receiver.ts │ │ ├── Rarity.ts │ │ └── index.ts │ │ ├── SimpleToken.ts │ │ ├── index.ts │ │ └── nested │ │ ├── a │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ ├── b │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ └── index.ts ├── target-ethers-v5 │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── codegen │ │ │ ├── events.ts │ │ │ ├── functions.ts │ │ │ ├── hardhat.ts │ │ │ ├── index.ts │ │ │ ├── reserved-keywords.ts │ │ │ ├── structs.ts │ │ │ └── types.ts │ │ ├── common.ts │ │ └── index.ts │ ├── static │ │ └── common.ts │ ├── test │ │ ├── generation.test.ts │ │ ├── index.test.ts │ │ ├── structs.test.ts │ │ ├── typelevel-test.ts │ │ └── typescript-version.test.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── target-ethers-v6-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── package.json │ ├── test │ │ ├── DataTypesInput.test.ts │ │ ├── Events.test.ts │ │ ├── Issue552Reproduction.test.ts │ │ ├── Overload.test.ts │ │ ├── Payable.test.ts │ │ ├── Polymorphism.test.ts │ │ └── common.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── types │ │ ├── common.ts │ │ ├── factories │ │ ├── index.ts │ │ ├── v0.6.4 │ │ │ ├── DataTypesInput__factory.ts │ │ │ ├── DataTypesPure__factory.ts │ │ │ ├── DataTypesView__factory.ts │ │ │ ├── Events__factory.ts │ │ │ ├── Issue428_Reproduction │ │ │ │ ├── A__factory.ts │ │ │ │ ├── B__factory.ts │ │ │ │ └── index.ts │ │ │ ├── Library │ │ │ │ ├── Lib__factory.ts │ │ │ │ └── index.ts │ │ │ ├── LibraryConsumer__factory.ts │ │ │ ├── Name-Mangling │ │ │ │ ├── NAME12mangling__factory.ts │ │ │ │ └── index.ts │ │ │ ├── Overloads__factory.ts │ │ │ ├── Payable │ │ │ │ ├── PayableFactory__factory.ts │ │ │ │ ├── Payable__factory.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── v0.8.9 │ │ │ ├── ISimpleToken__factory.ts │ │ │ ├── Issue552_Reproduction__factory.ts │ │ │ ├── KingOfTheHill │ │ │ ├── KingOfTheHill__factory.ts │ │ │ ├── Withdrawable__factory.ts │ │ │ └── index.ts │ │ │ ├── Rarity │ │ │ ├── ERC721Enumerable__factory.ts │ │ │ ├── ERC721__factory.ts │ │ │ ├── IERC721Enumerable__factory.ts │ │ │ ├── IERC721Receiver__factory.ts │ │ │ ├── IERC721__factory.ts │ │ │ ├── Rarity__factory.ts │ │ │ └── index.ts │ │ │ ├── SimpleToken__factory.ts │ │ │ ├── index.ts │ │ │ └── nested │ │ │ ├── a │ │ │ ├── NestedLibrary__factory.ts │ │ │ └── index.ts │ │ │ ├── b │ │ │ ├── NestedLibrary__factory.ts │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── v0.6.4 │ │ ├── DataTypesInput.ts │ │ ├── DataTypesPure.ts │ │ ├── DataTypesView.ts │ │ ├── Events.ts │ │ ├── Issue428_Reproduction │ │ │ ├── A.ts │ │ │ ├── B.ts │ │ │ └── index.ts │ │ ├── Library │ │ │ ├── Lib.ts │ │ │ └── index.ts │ │ ├── LibraryConsumer.ts │ │ ├── Name-Mangling │ │ │ ├── NAME12mangling.ts │ │ │ └── index.ts │ │ ├── Overloads.ts │ │ ├── Payable │ │ │ ├── Payable.ts │ │ │ ├── PayableFactory.ts │ │ │ └── index.ts │ │ └── index.ts │ │ └── v0.8.9 │ │ ├── ISimpleToken.ts │ │ ├── Issue552_Reproduction.ts │ │ ├── KingOfTheHill │ │ ├── KingOfTheHill.ts │ │ ├── Withdrawable.ts │ │ └── index.ts │ │ ├── Rarity │ │ ├── ERC721.ts │ │ ├── ERC721Enumerable.ts │ │ ├── IERC721.ts │ │ ├── IERC721Enumerable.ts │ │ ├── IERC721Receiver.ts │ │ ├── Rarity.ts │ │ └── index.ts │ │ ├── SimpleToken.ts │ │ ├── index.ts │ │ └── nested │ │ ├── a │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ ├── b │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ └── index.ts ├── target-ethers-v6 │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── codegen │ │ │ ├── events.ts │ │ │ ├── functions.ts │ │ │ ├── hardhat.ts │ │ │ ├── index.ts │ │ │ ├── reserved-keywords.ts │ │ │ ├── structs.ts │ │ │ └── types.ts │ │ ├── common.ts │ │ └── index.ts │ ├── static │ │ └── common.ts │ ├── test │ │ ├── generation.test.ts │ │ ├── index.test.ts │ │ ├── structs.test.ts │ │ ├── typelevel-test.ts │ │ └── typescript-version.test.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── target-starknet-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── contracts │ │ └── constructor.cairo │ ├── devnet.sh │ ├── example-abis │ │ ├── ArgentAccount.json │ │ ├── ERC20.json │ │ ├── constructor.json │ │ └── contract.json │ ├── package.json │ ├── test │ │ ├── InputReturnTypes.test.ts │ │ └── Transactions.test.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── types │ │ ├── ArgentAccount.ts │ │ ├── ERC20.ts │ │ ├── constructor.ts │ │ ├── contract.ts │ │ └── index.ts ├── target-starknet │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── StarknetTarget.ts │ │ ├── importer.ts │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── target-truffle-v5-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── migrations │ │ └── .gitkeep │ ├── package.json │ ├── test │ │ ├── DataTypesInput.test.ts │ │ ├── DataTypesPure.test.ts │ │ ├── DataTypesView.test.ts │ │ ├── Events.test.ts │ │ ├── NameMangling.test.ts │ │ └── Overloads.test.ts │ ├── truffle-config.js │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── types │ │ └── truffle-contracts │ │ ├── A.d.ts │ │ ├── B.d.ts │ │ ├── DataTypesInput.d.ts │ │ ├── DataTypesPure.d.ts │ │ ├── DataTypesView.d.ts │ │ ├── Events.d.ts │ │ ├── Lib.d.ts │ │ ├── LibraryConsumer.d.ts │ │ ├── NAME12mangling.d.ts │ │ ├── Overloads.d.ts │ │ ├── Payable.d.ts │ │ ├── PayableFactory.d.ts │ │ ├── index.d.ts │ │ └── types.d.ts ├── target-truffle-v5 │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── codegen │ │ │ ├── contracts.ts │ │ │ ├── events.ts │ │ │ ├── headers.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ └── index.ts │ ├── static │ │ └── types.d.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── target-web3-v1-test │ ├── .eslintrc.js │ ├── LICENSE │ ├── index.ts │ ├── package.json │ ├── test │ │ ├── DataTypesInput.test.ts │ │ ├── DataTypesPure.test.ts │ │ ├── DataTypesView.test.ts │ │ ├── Events.test.ts │ │ ├── Overload.test.ts │ │ ├── Payable.test.ts │ │ └── common.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsconfig.types.json │ └── types │ │ ├── index.ts │ │ ├── types.ts │ │ ├── v0.6.4 │ │ ├── DataTypesInput.ts │ │ ├── DataTypesPure.ts │ │ ├── DataTypesView.ts │ │ ├── Events.ts │ │ ├── Issue428_Reproduction │ │ │ ├── A.ts │ │ │ ├── B.ts │ │ │ └── index.ts │ │ ├── Library │ │ │ ├── Lib.ts │ │ │ └── index.ts │ │ ├── LibraryConsumer.ts │ │ ├── Name-Mangling │ │ │ ├── NAME12mangling.ts │ │ │ └── index.ts │ │ ├── Overloads.ts │ │ ├── Payable │ │ │ ├── Payable.ts │ │ │ ├── PayableFactory.ts │ │ │ └── index.ts │ │ └── index.ts │ │ └── v0.8.9 │ │ ├── ISimpleToken.ts │ │ ├── Issue552_Reproduction.ts │ │ ├── KingOfTheHill │ │ ├── KingOfTheHill.ts │ │ ├── Withdrawable.ts │ │ └── index.ts │ │ ├── Rarity │ │ ├── ERC721.ts │ │ ├── ERC721Enumerable.ts │ │ ├── IERC721.ts │ │ ├── IERC721Enumerable.ts │ │ ├── IERC721Receiver.ts │ │ ├── Rarity.ts │ │ └── index.ts │ │ ├── SimpleToken.ts │ │ ├── index.ts │ │ └── nested │ │ ├── a │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ ├── b │ │ ├── NestedLibrary.ts │ │ └── index.ts │ │ └── index.ts ├── target-web3-v1 │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── codegen │ │ │ ├── events.ts │ │ │ ├── functions.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ └── index.ts │ ├── static │ │ └── types.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── test-e2e │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── package.json │ ├── test │ │ └── ts-nocheck │ │ │ ├── ts-nocheck.abi.json │ │ │ └── ts-nocheck.test.ts │ └── tsconfig.json ├── test-utils │ ├── .eslintrc.js │ ├── LICENSE │ ├── package.json │ ├── src │ │ ├── contract.ts │ │ ├── index.ts │ │ └── test.ts │ ├── tsconfig.build.json │ └── tsconfig.json └── typechain │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── package.json │ ├── scripts │ └── post-build.ts │ ├── src │ ├── cli │ │ ├── cli.ts │ │ └── parseArgs.ts │ ├── codegen │ │ ├── createBarrelFiles.ts │ │ ├── normalizeDirName.ts │ │ ├── outputTransformers │ │ │ ├── index.ts │ │ │ ├── preamble.ts │ │ │ └── prettier.ts │ │ └── syntax.ts │ ├── index.ts │ ├── parser │ │ ├── abiParser.ts │ │ ├── normalizeName.ts │ │ └── parseEvmType.ts │ ├── typechain │ │ ├── findTarget.ts │ │ ├── io.ts │ │ ├── runTypeChain.ts │ │ └── types.ts │ └── utils │ │ ├── debug.ts │ │ ├── errors.ts │ │ ├── files │ │ ├── detectInputsRoot.ts │ │ ├── ensureAbsPath.ts │ │ ├── getFileExtension.ts │ │ ├── getFilename.ts │ │ ├── index.ts │ │ ├── lowestCommonPath.ts │ │ ├── normalizeSlashes.ts │ │ └── shortenFullJsonFilePath.ts │ │ ├── glob.ts │ │ ├── logger.ts │ │ ├── modules.ts │ │ └── signatures.ts │ ├── test │ ├── cli │ │ └── parseArgs.test.ts │ ├── codegen │ │ ├── normalizeDirName.test.ts │ │ └── syntax.test.ts │ ├── parser │ │ ├── abiParser.test.ts │ │ ├── normalizeName.test.ts │ │ └── parseEvmType.test.ts │ └── utils │ │ ├── files │ │ ├── lowestCommonPath.test.ts │ │ └── shortenFullJsonFilePath.test.ts │ │ └── signatures.test.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── scripts ├── _common.ts ├── check-examples.ts ├── compile-contracts.ts └── no-git-changes.sh ├── tsconfig.json └── tsconfig.prod.json /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@1.4.0/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "linked": [], 6 | "access": "public", 7 | "baseBranch": "master", 8 | "updateInternalDependencies": "minor", 9 | "ignore": [], 10 | "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { 11 | "updateInternalDependents": "always", 12 | "onlyUpdatePeerDependentsWhenOutOfRange": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | *.md 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v1 14 | - uses: pnpm/action-setup@v2 15 | with: 16 | version: 8.1 17 | - uses: actions/setup-node@v2 18 | with: 19 | node-version: '16.x' 20 | cache: 'pnpm' 21 | 22 | - run: pnpm install 23 | 24 | - name: Create Release Pull Request or Publish to npm 25 | uses: changesets/action@v1 26 | with: 27 | version: pnpm ci:version 28 | publish: pnpm ci:publish 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .nyc_output 4 | coverage 5 | packages/core/README.md 6 | *.tsbuildinfo 7 | build 8 | contracts/compiled 9 | packages/target-truffle-v4-test/contracts 10 | packages/target-truffle-v5-test/contracts 11 | packages/typechain/README.md 12 | examples/web3-v1/types 13 | examples/truffle-v4/types 14 | examples/truffle-v4/migrations 15 | examples/truffle-v5/types 16 | examples/truffle-v5/migrations 17 | examples/ethers-v5/types 18 | examples/hardhat/artifacts 19 | examples/hardhat/cache 20 | examples/hardhat/typechain-types 21 | examples/hardhat-truffe-v5/artifacts 22 | examples/hardhat-truffe-v5/cache 23 | examples/hardhat-truffe-v5/typechain-types 24 | packages/hardhat/test/fixture-projects/hardhat-project/contracts/TestContract2.sol 25 | packages/hardhat-test/cache 26 | packages/hardhat-test/artifacts 27 | examples/*/pnpm-lock.yaml 28 | pnpm-debug.log 29 | -------------------------------------------------------------------------------- /.mocharc.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = 'test' 2 | 3 | module.exports = { 4 | require: ['ts-node/register/transpile-only', 'earljs/mocha'], 5 | extension: ['ts'], 6 | watchExtensions: ['ts'], 7 | spec: ['test/**/*.test.ts'], 8 | timeout: 300_000, 9 | } 10 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /.pnpmfile.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | hooks: { 3 | readPackage(pkg, _ctx) { 4 | // We silence known peer dependency warnings which are not relevant to TypeChain 5 | if (pkg.name === '@improbable-eng/grpc-web') delete pkg.peerDependencies['google-protobuf'] 6 | if (pkg.name === 'native-fetch') delete pkg.peerDependencies['node-fetch'] 7 | if (pkg.name === 'native-abort-controller') delete pkg.peerDependencies['abort-controller'] 8 | 9 | return pkg 10 | }, 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | **/dist/** 3 | **/types/** 4 | **/build/** # truffle artifacts 5 | CHANGELOG.md 6 | packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/** 7 | packages/hardhat-test/typechain-types 8 | packages/test-e2e/test/*/out 9 | **/*.sol 10 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 2, 4 | "semi": false, 5 | "singleQuote": true, 6 | "trailingComma": "all", 7 | "proseWrap": "always" 8 | } 9 | -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0x2a03C48A5CcF19e6cB82A76EB057d3D3D7ff480e" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Issue428_Reproduction.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | // based on https://github.com/dethcrypto/TypeChain/issues/428#issuecomment-980761453 4 | 5 | contract A { 6 | event Committed(address[] whitelist); 7 | } 8 | 9 | contract B is A { 10 | event Committed(uint256 timelock); 11 | } 12 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Library.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | library Lib { 4 | enum BOOL {NO, YES} 5 | 6 | function other(BOOL b) public pure returns (BOOL) { 7 | return b == BOOL.NO ? BOOL.YES : BOOL.NO; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /contracts/v0.6.4/LibraryConsumer.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | import './Library.sol'; 4 | 5 | contract LibraryConsumer { 6 | 7 | Lib.BOOL boolean; 8 | 9 | function someOther(Lib.BOOL b) public pure returns(Lib.BOOL) { 10 | return Lib.other(b); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Name-Mangling.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | pragma experimental ABIEncoderV2; 3 | 4 | // useful during integration testing with truffle 5 | contract NAME12mangling { 6 | function works() public view returns (bool) { 7 | return true; 8 | } 9 | 10 | // test name collision 11 | function provider() public view returns (bool) { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Overloads.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | contract Overloads { 4 | function overload1(int256 input1) public pure returns (int256) { 5 | return input1; 6 | } 7 | 8 | function overload1(uint256 input1, uint256 input2) public pure returns (uint256) { 9 | return input1+input2; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Payable/Payable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | contract Payable { 4 | function payable_func() public payable {} 5 | 6 | function non_payable_func() public {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/v0.6.4/Payable/PayableFactory.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.6.4; 2 | 3 | import "./Payable.sol"; 4 | 5 | contract PayableFactory { 6 | function newPayable() public returns (Payable) { 7 | return new Payable(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /contracts/v0.8.9/ISimpleToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.7; 2 | 3 | interface ISimpleToken { 4 | function transfer(address from, uint256 value) external; 5 | } -------------------------------------------------------------------------------- /contracts/v0.8.9/Issue552_Reproduction.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.9; 3 | pragma experimental ABIEncoderV2; 4 | 5 | 6 | library Issue552_Observer { 7 | 8 | struct Observation { 9 | int val; 10 | uint blockTimestamp; 11 | } 12 | 13 | function write( 14 | Observation[65535] storage self, 15 | uint16 index, 16 | uint newVal, 17 | uint blockTimestamp 18 | ) internal returns (uint16 indexUpdated) { } 19 | } 20 | 21 | 22 | // This is used to crash TypeChain Ethers v5 with "Reached heap limit Allocation failed" 23 | contract Issue552_Reproduction { 24 | using Issue552_Observer for Issue552_Observer.Observation[65535]; 25 | 26 | struct ObservationParams { 27 | Issue552_Observer.Observation[65535] observations; 28 | uint16 index; 29 | } 30 | 31 | struct Bar { 32 | ObservationParams fooObservations; 33 | } 34 | 35 | mapping(uint => Bar) public bars; 36 | 37 | function makeObservation(uint barId, uint newVal) external {} 38 | 39 | function input(uint256[10] calldata values) public pure {} 40 | } 41 | -------------------------------------------------------------------------------- /contracts/v0.8.9/SimpleToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.7; 2 | 3 | import { ISimpleToken } from "./ISimpleToken.sol"; 4 | 5 | contract SimpleToken is ISimpleToken { 6 | function transfer(address from, uint256 value) external { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /contracts/v0.8.9/nested/a/NestedLibrary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getValue", 5 | "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], 6 | "stateMutability": "pure", 7 | "type": "function" 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /contracts/v0.8.9/nested/b/NestedLibrary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getValue", 5 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 6 | "stateMutability": "pure", 7 | "type": "function" 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /docs/images/aave-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/aave-logo.png -------------------------------------------------------------------------------- /docs/images/arbitrum-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/arbitrum-logo.png -------------------------------------------------------------------------------- /docs/images/kyber-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/kyber-logo.png -------------------------------------------------------------------------------- /docs/images/maker-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/maker-logo.png -------------------------------------------------------------------------------- /docs/images/optimism-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/optimism-logo.png -------------------------------------------------------------------------------- /docs/images/typechain-logo-black-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/typechain-logo-black-bg.png -------------------------------------------------------------------------------- /docs/images/typechain-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/typechain-logo.png -------------------------------------------------------------------------------- /docs/images/uniswap-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/uniswap-logo.png -------------------------------------------------------------------------------- /docs/images/zksync-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/docs/images/zksync-logo.png -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Ethers-v5 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm i 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm start 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-ethers-v5-nodenext", 3 | "private": true, 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "generate-types": "typechain --target=ethers-v5 --node16-modules 'abi/*.json'", 9 | "start": "ts-node ./src/index.ts", 10 | "typecheck": "pnpm generate-types && tsc --noEmit" 11 | }, 12 | "devDependencies": { 13 | "@typechain/ethers-v5": "workspace:^11.1.2", 14 | "@types/bn.js": "^5.1.0", 15 | "ts-node": "^10.7.0", 16 | "typechain": "workspace:^8.3.2", 17 | "typescript": "^4.9.5" 18 | }, 19 | "dependencies": { 20 | "ethers": "^5.1.3", 21 | "@ethersproject/providers": "^5.1.3", 22 | "@ethersproject/abi": "^5.1.3" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers, utils } from 'ethers' 2 | 3 | import { Dai__factory } from '../types/ethers-contracts/factories/Dai__factory' 4 | 5 | const RPC_HOST = 'https://mainnet.infura.io/v3/6d6c70e65c77429482df5b64a4d0c943' 6 | const DAI_ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' 7 | const BLOCK_NUMBER = 13730326 8 | 9 | async function main() { 10 | const provider = new ethers.providers.JsonRpcProvider(RPC_HOST) 11 | const dai = Dai__factory.connect(DAI_ADDRESS, provider) 12 | const balance = await dai.balanceOf('0x70b144972C5Ef6CB941A5379240B74239c418CD4') 13 | 14 | console.log(`Our DAI balance is: ${utils.formatEther(balance)}`) 15 | 16 | console.log(`Listing Transfer events for block ${BLOCK_NUMBER}`) 17 | const eventsFilter = dai.filters.Transfer() 18 | const events = await dai.queryFilter(eventsFilter, BLOCK_NUMBER, BLOCK_NUMBER) 19 | 20 | for (const event of events) { 21 | console.log(`${event.args.src} -> ${event.args.dst} | ${utils.formatEther(event.args.wad)} DAI`) 22 | } 23 | } 24 | 25 | main().catch((e) => { 26 | console.error(e) 27 | process.exit(1) 28 | }) 29 | -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "NodeNext", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/types/ethers-contracts/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Dai__factory } from "./Dai__factory.js"; 5 | -------------------------------------------------------------------------------- /examples/ethers-v5-nodenext/types/ethers-contracts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Dai } from "./Dai.js"; 5 | export * as factories from "./factories/index.js"; 6 | export { Dai__factory } from "./factories/Dai__factory.js"; 7 | -------------------------------------------------------------------------------- /examples/ethers-v5/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Ethers-v5 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm i 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm start 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/ethers-v5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-ethers-v5", 3 | "private": true, 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "generate-types": "typechain --target=ethers-v5 'abi/*.json'", 9 | "start": "ts-node ./src/index.ts", 10 | "typecheck": "pnpm generate-types && tsc --noEmit" 11 | }, 12 | "devDependencies": { 13 | "@typechain/ethers-v5": "workspace:^11.1.2", 14 | "@types/bn.js": "^5.1.0", 15 | "ts-node": "^10.7.0", 16 | "typechain": "workspace:^8.3.2", 17 | "typescript": "^4.9.5" 18 | }, 19 | "dependencies": { 20 | "ethers": "^5.1.3", 21 | "@ethersproject/providers": "^5.1.3", 22 | "@ethersproject/abi": "^5.1.3" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/ethers-v5/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers, utils } from 'ethers' 2 | 3 | import { Dai__factory } from '../types/ethers-contracts/factories/Dai__factory' 4 | 5 | const RPC_HOST = 'https://mainnet.infura.io/v3/6d6c70e65c77429482df5b64a4d0c943' 6 | const DAI_ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' 7 | const BLOCK_NUMBER = 13730326 8 | 9 | async function main() { 10 | const provider = new ethers.providers.JsonRpcProvider(RPC_HOST) 11 | const dai = Dai__factory.connect(DAI_ADDRESS, provider) 12 | const balance = await dai.balanceOf('0x70b144972C5Ef6CB941A5379240B74239c418CD4') 13 | 14 | console.log(`Our DAI balance is: ${utils.formatEther(balance)}`) 15 | 16 | console.log(`Listing Transfer events for block ${BLOCK_NUMBER}`) 17 | const eventsFilter = dai.filters.Transfer() 18 | const events = await dai.queryFilter(eventsFilter, BLOCK_NUMBER, BLOCK_NUMBER) 19 | 20 | for (const event of events) { 21 | console.log(`${event.args.src} -> ${event.args.dst} | ${utils.formatEther(event.args.wad)} DAI`) 22 | } 23 | } 24 | 25 | main().catch((e) => { 26 | console.error(e) 27 | process.exit(1) 28 | }) 29 | -------------------------------------------------------------------------------- /examples/ethers-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Ethers-v6 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm i 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm start 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-ethers-v6-nodenext", 3 | "private": true, 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "type": "module", 7 | "license": "MIT", 8 | "scripts": { 9 | "generate-types": "typechain --target=ethers-v6 --node16-modules 'abi/*.json'", 10 | "start": "ts-node ./src/index.ts", 11 | "typecheck": "pnpm generate-types && tsc --noEmit" 12 | }, 13 | "devDependencies": { 14 | "@typechain/ethers-v6": "workspace:^0.5.1", 15 | "@types/bn.js": "^5.1.0", 16 | "ts-node": "^10.7.0", 17 | "typechain": "workspace:^8.3.2", 18 | "typescript": "^4.7" 19 | }, 20 | "dependencies": { 21 | "ethers": "^6.1.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/src/index.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from 'ethers' 2 | 3 | import { Dai__factory } from '../types/ethers-contracts/factories/Dai__factory.js' 4 | 5 | const RPC_HOST = 'https://mainnet.infura.io/v3/6d6c70e65c77429482df5b64a4d0c943' 6 | const DAI_ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' 7 | const BLOCK_NUMBER = 13730326 8 | 9 | async function main() { 10 | const provider = new ethers.JsonRpcProvider(RPC_HOST) 11 | const dai = Dai__factory.connect(DAI_ADDRESS, provider) 12 | const balance = await dai.balanceOf('0x70b144972C5Ef6CB941A5379240B74239c418CD4') 13 | 14 | console.log(`Our DAI balance is: ${ethers.formatEther(balance)}`) 15 | 16 | console.log(`Listing Transfer events for block ${BLOCK_NUMBER}`) 17 | const eventsFilter = dai.filters.Transfer() 18 | const events = await dai.queryFilter(eventsFilter, BLOCK_NUMBER, BLOCK_NUMBER) 19 | 20 | for (const event of events) { 21 | console.log(`${event.args.src} -> ${event.args.dst} | ${ethers.formatEther(event.args.wad)} DAI`) 22 | } 23 | } 24 | 25 | main().catch((e) => { 26 | console.error(e) 27 | process.exit(1) 28 | }) 29 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "NodeNext", 5 | "moduleResolution": "node16", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/types/ethers-contracts/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Dai__factory } from "./Dai__factory.js"; 5 | -------------------------------------------------------------------------------- /examples/ethers-v6-nodenext/types/ethers-contracts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Dai } from "./Dai.js"; 5 | export * as factories from "./factories/index.js"; 6 | export { Dai__factory } from "./factories/Dai__factory.js"; 7 | -------------------------------------------------------------------------------- /examples/ethers-v6/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Ethers-v5 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm i 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm start 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/ethers-v6/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-ethers-v6", 3 | "private": true, 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "generate-types": "typechain --target=ethers-v6 'abi/*.json'", 9 | "start": "ts-node ./src/index.ts", 10 | "typecheck": "pnpm generate-types && tsc --noEmit" 11 | }, 12 | "devDependencies": { 13 | "@typechain/ethers-v6": "workspace:^0.5.1", 14 | "@types/bn.js": "^5.1.0", 15 | "ts-node": "^10.7.0", 16 | "typechain": "workspace:^8.3.2", 17 | "typescript": "^4.7" 18 | }, 19 | "dependencies": { 20 | "ethers": "^6.1.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/ethers-v6/src/index.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import { ethers } from 'ethers' 3 | 4 | import { Dai__factory } from '../types/ethers-contracts/factories/Dai__factory' 5 | 6 | const RPC_HOST = 'https://mainnet.infura.io/v3/6d6c70e65c77429482df5b64a4d0c943' 7 | const DAI_ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' 8 | const BLOCK_NUMBER = 13730326 9 | 10 | async function main() { 11 | const provider = new ethers.JsonRpcProvider(RPC_HOST) 12 | const dai = Dai__factory.connect(DAI_ADDRESS, provider) 13 | const balance = await dai.balanceOf('0x70b144972C5Ef6CB941A5379240B74239c418CD4') 14 | 15 | console.log(`Our DAI balance is: ${ethers.formatEther(balance)}`) 16 | 17 | console.log(`Listing Transfer events for block ${BLOCK_NUMBER}`) 18 | const eventsFilter = dai.filters.Transfer() 19 | const events = await dai.queryFilter(eventsFilter, BLOCK_NUMBER, BLOCK_NUMBER) 20 | 21 | for (const event of events) { 22 | console.log(`${event.args.src} -> ${event.args.dst} | ${ethers.formatEther(event.args.wad)} DAI`) 23 | } 24 | } 25 | 26 | main().catch((e) => { 27 | console.error(e) 28 | process.exit(1) 29 | }) 30 | -------------------------------------------------------------------------------- /examples/ethers-v6/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "CommonJS", 5 | "moduleResolution": "node16", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/ethers-v6/types/ethers-contracts/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Dai__factory } from "./Dai__factory"; 5 | -------------------------------------------------------------------------------- /examples/ethers-v6/types/ethers-contracts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Dai } from "./Dai"; 5 | export * as factories from "./factories"; 6 | export { Dai__factory } from "./factories/Dai__factory"; 7 | -------------------------------------------------------------------------------- /examples/hardhat-truffe-v5/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Hardhat x Truffle example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm install 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm test 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/hardhat-truffe-v5/contracts/Counter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.8; 3 | 4 | import "hardhat/console.sol"; 5 | 6 | 7 | contract Counter { 8 | uint256 count = 0; 9 | 10 | event CountedTo(uint256 number); 11 | 12 | function getCount() public view returns (uint256) { 13 | return count; 14 | } 15 | 16 | function countUp() public returns (uint256) { 17 | console.log("countUp: count =", count); 18 | uint256 newCount = count + 1; 19 | require(newCount > count, "Uint256 overflow"); 20 | 21 | count = newCount; 22 | 23 | emit CountedTo(count); 24 | return count; 25 | } 26 | 27 | function countDown() public returns (uint256) { 28 | console.log("countDown: count =", count); 29 | uint256 newCount = count - 1; 30 | require(newCount < count, "Uint256 underflow"); 31 | 32 | count = newCount; 33 | 34 | emit CountedTo(count); 35 | return count; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/hardhat-truffe-v5/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import '@nomiclabs/hardhat-truffle5' 2 | import '@typechain/hardhat' 3 | import { HardhatUserConfig } from 'hardhat/types' 4 | 5 | const config: HardhatUserConfig = { 6 | defaultNetwork: 'hardhat', 7 | solidity: { 8 | compilers: [{ version: '0.6.8', settings: {} }], 9 | }, 10 | typechain: { 11 | target: 'truffle-v5', 12 | }, 13 | } 14 | 15 | export default config 16 | -------------------------------------------------------------------------------- /examples/hardhat-truffe-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "outDir": "dist", 8 | "resolveJsonModule": true 9 | }, 10 | "include": ["./scripts", "./test", "./typechain-types"], 11 | "files": ["./hardhat.config.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /examples/hardhat/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Hardhat example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm install 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm test 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/hardhat/contracts/Counter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.8; 3 | 4 | import "hardhat/console.sol"; 5 | 6 | 7 | contract Counter { 8 | uint256 count = 0; 9 | 10 | event CountedTo(uint256 number); 11 | 12 | function getCount() public view returns (uint256) { 13 | return count; 14 | } 15 | 16 | function countUp() public returns (uint256) { 17 | console.log("countUp: count =", count); 18 | uint256 newCount = count + 1; 19 | require(newCount > count, "Uint256 overflow"); 20 | 21 | count = newCount; 22 | 23 | emit CountedTo(count); 24 | return count; 25 | } 26 | 27 | function countDown() public returns (uint256) { 28 | console.log("countDown: count =", count); 29 | uint256 newCount = count - 1; 30 | require(newCount < count, "Uint256 underflow"); 31 | 32 | count = newCount; 33 | 34 | emit CountedTo(count); 35 | return count; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/hardhat/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import '@typechain/hardhat' 2 | import '@nomicfoundation/hardhat-ethers' 3 | import '@nomicfoundation/hardhat-chai-matchers' 4 | 5 | import { HardhatUserConfig } from 'hardhat/types' 6 | 7 | const config: HardhatUserConfig = { 8 | defaultNetwork: 'hardhat', 9 | solidity: { 10 | compilers: [{ version: '0.6.8', settings: {} }], 11 | }, 12 | } 13 | 14 | export default config 15 | -------------------------------------------------------------------------------- /examples/hardhat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-example", 3 | "version": "1.0.0", 4 | "private": true, 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "compile": "pnpm hardhat compile", 9 | "clean": "pnpm hardhat clean", 10 | "test": "hardhat test", 11 | "typecheck": "pnpm compile && pnpm test && pnpm tsc --noEmit" 12 | }, 13 | "devDependencies": { 14 | "@nomicfoundation/hardhat-ethers": "^3.0.4", 15 | "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", 16 | "@typechain/ethers-v6": "workspace:^0.5.1", 17 | "@typechain/hardhat": "workspace:^9.1.0", 18 | "@types/chai": "^4.2.15", 19 | "@types/chai-as-promised": "^7.1.3", 20 | "@types/mocha": "^8.2.0", 21 | "@types/node": "18.14.0", 22 | "chai": "^4.3.0", 23 | "chai-as-promised": "^7.1.1", 24 | "dotenv": "^8.2.0", 25 | "ethereum-waffle": "^3.2.2", 26 | "ethers": "6.3.0", 27 | "@ethersproject/providers": "5.4.0", 28 | "@ethersproject/contracts": "5.4.0", 29 | "@ethersproject/abi": "5.4.0", 30 | "hardhat": "^2.9.9", 31 | "ts-node": "^10.7.0", 32 | "typechain": "workspace:^8.3.2", 33 | "typescript": "^4.9.5" 34 | }, 35 | "dependencies": {} 36 | } 37 | -------------------------------------------------------------------------------- /examples/hardhat/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2015", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "outDir": "dist", 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true 10 | }, 11 | "include": ["./scripts", "./test", "./typechain-types"], 12 | "files": ["./hardhat.config.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /examples/truffle-v5/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Truffle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /examples/truffle-v5/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Truffle v5 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm install 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | # run tests 19 | truffle test 20 | 21 | # migrations are kinda tricky (look at known limitation section) - we need to transpile ts to js file (this is not a case for tests) 22 | pnpm migrate 23 | ``` 24 | 25 | ## Known limitations 26 | 27 | Migrations need to be transpiled to js before execution. 28 | -------------------------------------------------------------------------------- /examples/truffle-v5/contracts/ConvertLib.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.25 <0.7.0; 2 | 3 | library ConvertLib{ 4 | function convert(uint amount,uint conversionRate) public pure returns (uint convertedAmount) 5 | { 6 | return amount * conversionRate; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/truffle-v5/contracts/MetaCoin.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.25 <0.7.0; 2 | 3 | import "./ConvertLib.sol"; 4 | 5 | // This is just a simple example of a coin-like contract. 6 | // It is not standards compatible and cannot be expected to talk to other 7 | // coin/token contracts. If you want to create a standards-compliant 8 | // token, see: https://github.com/ConsenSys/Tokens. Cheers! 9 | 10 | contract MetaCoin { 11 | mapping (address => uint) balances; 12 | 13 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 14 | 15 | constructor() public { 16 | balances[tx.origin] = 10000; 17 | } 18 | 19 | function sendCoin(address receiver, uint amount) public returns(bool sufficient) { 20 | if (balances[msg.sender] < amount) return false; 21 | balances[msg.sender] -= amount; 22 | balances[receiver] += amount; 23 | emit Transfer(msg.sender, receiver, amount); 24 | return true; 25 | } 26 | 27 | function getBalanceInEth(address addr) public view returns(uint){ 28 | return ConvertLib.convert(getBalance(addr),2); 29 | } 30 | 31 | function getBalance(address addr) public view returns(uint) { 32 | return balances[addr]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/truffle-v5/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.25 <0.7.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | constructor() public { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/truffle-v5/migrations-ts/1_initial_migration.ts: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require('Migrations') 2 | 3 | const migration: Truffle.Migration = function (deployer) { 4 | deployer.deploy(Migrations) 5 | } 6 | 7 | module.exports = migration 8 | 9 | // because of https://stackoverflow.com/questions/40900791/cannot-redeclare-block-scoped-variable-in-unrelated-files 10 | export {} 11 | -------------------------------------------------------------------------------- /examples/truffle-v5/migrations-ts/2_deploy_contracts.ts: -------------------------------------------------------------------------------- 1 | const ConvertLib = artifacts.require('ConvertLib') 2 | const MetaCoin = artifacts.require('MetaCoin') 3 | 4 | const migration: Truffle.Migration = function (deployer) { 5 | deployer.deploy(ConvertLib) 6 | deployer.link(ConvertLib, MetaCoin) 7 | deployer.deploy(MetaCoin) 8 | } 9 | 10 | module.exports = migration 11 | 12 | // because of https://stackoverflow.com/questions/40900791/cannot-redeclare-block-scoped-variable-in-unrelated-files 13 | export {} 14 | -------------------------------------------------------------------------------- /examples/truffle-v5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-truffle-v5", 3 | "private": true, 4 | "version": "0.0.9", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "generate-types": "typechain --target=truffle-v5 'build/contracts/*.json'", 9 | "migrate": "tsc -p ./tsconfig.migrate.json --outDir ./migrations && truffle migrate", 10 | "typecheck": "truffle compile && pnpm generate-types && tsc --noEmit" 11 | }, 12 | "dependencies": { 13 | "@typechain/truffle-v5": "workspace:^8.0.7", 14 | "typechain": "workspace:^8.3.2", 15 | "@types/bn.js": "^4.11.6", 16 | "@types/chai": "^4.2.11", 17 | "@types/mocha": "^7.0.2", 18 | "@types/web3": "^1.2.2", 19 | "web3-core": "^1", 20 | "web3-eth-contract": "^1", 21 | "web3-utils": "^1", 22 | "web3": "^1", 23 | "truffle": "^5.1.22", 24 | "typescript": "^4.9.5" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/truffle-v5/truffle-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // Uncommenting the defaults below 3 | // provides for an easier quick-start with Ganache. 4 | // You can also follow this format for other networks; 5 | // see 6 | // for more details on how to specify configuration options! 7 | // 8 | networks: { 9 | development: { 10 | host: "127.0.0.1", 11 | port: 8545, 12 | network_id: "*" 13 | }, 14 | } 15 | 16 | }; 17 | -------------------------------------------------------------------------------- /examples/truffle-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/truffle-v5/tsconfig.migrate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["./migrations-ts/*.ts", "./types/**/*.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/web3-v1/README.md: -------------------------------------------------------------------------------- 1 | # TypeChain x Web3 v1 example 2 | 3 | Note: examples in this dir require building monorepo first 4 | 5 | ```sh 6 | # in the root of monorepo 7 | pnpm install 8 | pnpm build 9 | ``` 10 | 11 | ## Running 12 | 13 | ```sh 14 | pnpm install # it will automatically run TypeChain types generation 15 | 16 | # pnpm generate-types to manually regenerate them 17 | 18 | pnpm start 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/web3-v1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-web3-v1", 3 | "private": true, 4 | "version": "0.0.1", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "scripts": { 8 | "generate-types": "typechain --target=web3-v1 'abi/*.json'", 9 | "start": "ts-node ./src/index.ts", 10 | "typecheck": "pnpm generate-types && tsc --noEmit" 11 | }, 12 | "devDependencies": { 13 | "@typechain/web3-v1": "workspace:^6.0.7", 14 | "@types/bn.js": "^4.11.6", 15 | "ts-node": "^10.7.0", 16 | "typechain": "workspace:^8.3.2" 17 | }, 18 | "dependencies": { 19 | "web3": "^1", 20 | "web3-eth-contract": "^1", 21 | "web3-core": "^1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/web3-v1/src/index.ts: -------------------------------------------------------------------------------- 1 | import Web3 from 'web3' 2 | 3 | import { Dai } from '../types/web3-v1-contracts/Dai' 4 | 5 | const abi = require('../abi/dai.json') 6 | 7 | const RPC_HOST = 'wss://mainnet.infura.io/ws/v3/6d6c70e65c77429482df5b64a4d0c943' 8 | const DAI_ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' 9 | 10 | async function main() { 11 | const web3 = new Web3(RPC_HOST) 12 | const fromWei = web3.utils.fromWei 13 | 14 | const dai = new web3.eth.Contract(abi, DAI_ADDRESS) as any as Dai 15 | const balance = await dai.methods.balanceOf('0x70b144972C5Ef6CB941A5379240B74239c418CD4').call() 16 | 17 | console.log(`Our DAI balance is: ${fromWei(balance)}`) 18 | 19 | console.log('Listening for transfer events...') 20 | dai.events.Transfer((err, e) => { 21 | if (err) { 22 | console.error(err) 23 | return 24 | } 25 | console.log(`${fromWei(e.returnValues.wad)} DAI transferred ${e.returnValues.src} -> ${e.returnValues.dst}`) 26 | }) 27 | } 28 | 29 | main().catch((e) => { 30 | console.error(e) 31 | process.exit(1) 32 | }) 33 | -------------------------------------------------------------------------------- /examples/web3-v1/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ES2018", "DOM"], 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "target": "ES2018", 8 | "sourceMap": true, 9 | "esModuleInterop": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/hardhat-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/hardhat-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/hardhat-test/contracts/Counter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.7; 3 | 4 | import "hardhat/console.sol"; 5 | 6 | 7 | contract Counter { 8 | uint256 count = 0; 9 | 10 | event CountedTo(uint256 number); 11 | 12 | function getCount() public view returns (uint256) { 13 | return count; 14 | } 15 | 16 | function countUp() public returns (uint256) { 17 | console.log("countUp: count =", count); 18 | uint256 newCount = count + 1; 19 | require(newCount > count, "Uint256 overflow"); 20 | 21 | count = newCount; 22 | 23 | emit CountedTo(count); 24 | return count; 25 | } 26 | 27 | function countDown() public returns (uint256) { 28 | console.log("countDown: count =", count); 29 | uint256 newCount = count - 1; 30 | require(newCount < count, "Uint256 underflow"); 31 | 32 | count = newCount; 33 | 34 | emit CountedTo(count); 35 | return count; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/hardhat-test/contracts/Demo.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.7; 3 | pragma experimental ABIEncoderV2; 4 | 5 | contract Demo { 6 | struct Struct1 { 7 | uint a; 8 | uint b; 9 | } 10 | struct Struct2 { 11 | uint a; 12 | uint b; 13 | } 14 | constructor(Struct1 memory input1, Struct2[] memory input2) {} 15 | } 16 | -------------------------------------------------------------------------------- /packages/hardhat-test/contracts/Directory/Hello.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.7; 3 | 4 | contract Hello { 5 | constructor(uint) {} 6 | } -------------------------------------------------------------------------------- /packages/hardhat-test/contracts/StructsInConstructor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.7; 3 | 4 | struct Vector2 { 5 | uint256 x; uint256 y; 6 | } 7 | 8 | contract StructsInConstructor { 9 | constructor(Vector2[2] memory segment) {} 10 | } 11 | -------------------------------------------------------------------------------- /packages/hardhat-test/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | // We load the plugin here. 2 | import '@typechain/hardhat' 3 | import '@nomicfoundation/hardhat-ethers' 4 | 5 | import type { HardhatUserConfig } from 'hardhat/types' 6 | 7 | const config: HardhatUserConfig = { 8 | solidity: '0.8.7', 9 | defaultNetwork: 'hardhat', 10 | } 11 | 12 | export default config 13 | -------------------------------------------------------------------------------- /packages/hardhat-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/hardhat-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./typechain-types", "./test", "./hardhat.config.ts"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true, 7 | "importsNotUsedAsValues": "error" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/hardhat-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./typechain-types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "lib": ["ES2018", "DOM"], 7 | "skipLibCheck": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/hardhat-test/typechain-types/Directory/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Hello } from "./Hello"; 5 | -------------------------------------------------------------------------------- /packages/hardhat-test/typechain-types/factories/Directory/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Hello__factory } from "./Hello__factory"; 5 | -------------------------------------------------------------------------------- /packages/hardhat-test/typechain-types/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as directory from "./Directory"; 5 | export { Counter__factory } from "./Counter__factory"; 6 | export { Demo__factory } from "./Demo__factory"; 7 | export { StructsInConstructor__factory } from "./StructsInConstructor__factory"; 8 | -------------------------------------------------------------------------------- /packages/hardhat-test/typechain-types/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as directory from "./Directory"; 5 | export type { directory }; 6 | export type { Counter } from "./Counter"; 7 | export type { Demo } from "./Demo"; 8 | export type { StructsInConstructor } from "./StructsInConstructor"; 9 | export * as factories from "./factories"; 10 | export { Counter__factory } from "./factories/Counter__factory"; 11 | export { Demo__factory } from "./factories/Demo__factory"; 12 | export type { Hello } from "./Directory/Hello"; 13 | export { Hello__factory } from "./factories/Directory/Hello__factory"; 14 | export { StructsInConstructor__factory } from "./factories/StructsInConstructor__factory"; 15 | -------------------------------------------------------------------------------- /packages/hardhat/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/hardhat/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor / Rahul Sethuram 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/hardhat/src/config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatConfig } from 'hardhat/types' 2 | 3 | import { TypechainConfig } from './types' 4 | 5 | export function getDefaultTypechainConfig(config: HardhatConfig): TypechainConfig { 6 | const defaultConfig: TypechainConfig = { 7 | outDir: 'typechain-types', 8 | target: 'ethers-v6', 9 | alwaysGenerateOverloads: false, 10 | discriminateTypes: false, 11 | tsNocheck: false, 12 | dontOverrideCompile: false, 13 | node16Modules: false, 14 | } 15 | 16 | return { 17 | ...defaultConfig, 18 | ...config.typechain, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/hardhat/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const TASK_TYPECHAIN: string = 'typechain' 2 | export const TASK_TYPECHAIN_GENERATE_TYPES: string = 'typechain:generate-types' 3 | -------------------------------------------------------------------------------- /packages/hardhat/src/type-extensions.ts: -------------------------------------------------------------------------------- 1 | import 'hardhat/types/config' 2 | 3 | import { TypechainConfig, TypechainUserConfig } from './types' 4 | 5 | declare module 'hardhat/types/config' { 6 | interface HardhatUserConfig { 7 | typechain?: TypechainUserConfig 8 | } 9 | 10 | interface HardhatConfig { 11 | typechain: TypechainConfig 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/hardhat/src/types.ts: -------------------------------------------------------------------------------- 1 | export interface TypechainConfig { 2 | outDir: string 3 | target: string 4 | alwaysGenerateOverloads: boolean 5 | discriminateTypes: boolean 6 | tsNocheck: boolean 7 | externalArtifacts?: string[] 8 | dontOverrideCompile: boolean 9 | node16Modules: boolean // defaults to false 10 | } 11 | 12 | export interface TypechainUserConfig extends Partial {} 13 | -------------------------------------------------------------------------------- /packages/hardhat/test/__snapshots__/project.test.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Typechain x Hardhat when recompiling generates typings only for changed files 1`] = ` 4 | "/* Autogenerated file. Do not edit manually. */ 5 | /* tslint:disable */ 6 | /* eslint-disable */ 7 | import type * as lib from \\"./lib\\"; 8 | export type { lib }; 9 | export type { EdgeCases } from \\"./EdgeCases\\"; 10 | export type { TestContract } from \\"./TestContract\\"; 11 | export type { TestContract1 } from \\"./TestContract1\\"; 12 | export type { TestContract2 } from \\"./TestContract2\\"; 13 | export * as factories from \\"./factories\\"; 14 | export { EdgeCases__factory } from \\"./factories/EdgeCases__factory\\"; 15 | export type { SafeMath } from \\"./lib/SafeMath\\"; 16 | export { SafeMath__factory } from \\"./factories/lib/SafeMath__factory\\"; 17 | export { TestContract__factory } from \\"./factories/TestContract__factory\\"; 18 | export { TestContract1__factory } from \\"./factories/TestContract1__factory\\"; 19 | export { TestContract2__factory } from \\"./factories/TestContract2__factory\\"; 20 | " 21 | `; 22 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-files/TestContract2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.7.3; 3 | 4 | 5 | contract TestContract2 { 6 | uint256 amount; 7 | 8 | string message = "placeholder"; 9 | 10 | constructor(uint256 _amount) { 11 | amount = _amount; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/.gitignore: -------------------------------------------------------------------------------- 1 | /*/artifacts 2 | /*/cache 3 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/contracts/EdgeCases.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.7.3; 3 | pragma experimental ABIEncoderV2; 4 | 5 | contract EdgeCases { 6 | // fix for: https://github.com/ethereum-ts/TypeChain/issues/389 7 | constructor ( 8 | uint256 test, 9 | bytes memory 10 | ) { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/contracts/TestContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.7.3; 3 | 4 | import "./lib/SafeMath.sol"; 5 | import "./TestContract1.sol"; 6 | 7 | 8 | contract TestContract { 9 | TestContract1 tc1; 10 | 11 | using SafeMath for uint256; 12 | 13 | uint256 amount; 14 | 15 | string message = "placeholder"; 16 | 17 | constructor(uint256 _amount) { 18 | amount = _amount.add(20); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/contracts/TestContract1.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.7.3; 3 | 4 | 5 | contract TestContract1 { 6 | uint256 amount; 7 | 8 | string message = "placeholder"; 9 | 10 | constructor(uint256 _amount) { 11 | amount = _amount; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/contracts/lib/SafeMath.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.7.3; 3 | 4 | 5 | library SafeMath { 6 | function mul(uint256 num1, uint256 num2) public pure returns (uint256) { 7 | uint256 result = num1 * num2; 8 | return result; 9 | } 10 | 11 | function div(uint256 num1, uint256 num2) public pure returns (uint256) { 12 | uint256 result = num1 / num2; 13 | return result; 14 | } 15 | 16 | function sub(uint256 num1, uint256 num2) public pure returns (uint256) { 17 | uint256 result = num1 - num2; 18 | return result; 19 | } 20 | 21 | function add(uint256 num1, uint256 num2) public pure returns (uint256) { 22 | uint256 result = num1 + num2; 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | // We load the plugin here. 2 | import '../../../src/index' 3 | 4 | import { HardhatUserConfig } from 'hardhat/types' 5 | 6 | const config: HardhatUserConfig = { 7 | solidity: '0.7.3', 8 | defaultNetwork: 'hardhat', 9 | } 10 | 11 | export default config 12 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/contracts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as lib from "./lib"; 5 | export type { lib }; 6 | export type { EdgeCases } from "./EdgeCases"; 7 | export type { TestContract } from "./TestContract"; 8 | export type { TestContract1 } from "./TestContract1"; 9 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/contracts/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { SafeMath } from "./SafeMath"; 5 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/artifacts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as contracts from "./contracts"; 5 | export type { contracts }; 6 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/externalArtifacts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { ERC20 } from "./ERC20"; 5 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/factories/artifacts/contracts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as lib from "./lib"; 5 | export { EdgeCases__factory } from "./EdgeCases__factory"; 6 | export { TestContract__factory } from "./TestContract__factory"; 7 | export { TestContract1__factory } from "./TestContract1__factory"; 8 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/factories/artifacts/contracts/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { SafeMath__factory } from "./SafeMath__factory"; 5 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/factories/artifacts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as contracts from "./contracts"; 5 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/factories/externalArtifacts/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { ERC20__factory } from "./ERC20__factory"; 5 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as artifacts from "./artifacts"; 5 | export * as externalArtifacts from "./externalArtifacts"; 6 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/hardhat-project/typechain-types/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as artifacts from "./artifacts"; 5 | export type { artifacts }; 6 | import type * as externalArtifacts from "./externalArtifacts"; 7 | export type { externalArtifacts }; 8 | export * as factories from "./factories"; 9 | export type { EdgeCases } from "./artifacts/contracts/EdgeCases"; 10 | export { EdgeCases__factory } from "./factories/artifacts/contracts/EdgeCases__factory"; 11 | export type { SafeMath } from "./artifacts/contracts/lib/SafeMath"; 12 | export { SafeMath__factory } from "./factories/artifacts/contracts/lib/SafeMath__factory"; 13 | export type { TestContract } from "./artifacts/contracts/TestContract"; 14 | export { TestContract__factory } from "./factories/artifacts/contracts/TestContract__factory"; 15 | export type { TestContract1 } from "./artifacts/contracts/TestContract1"; 16 | export { TestContract1__factory } from "./factories/artifacts/contracts/TestContract1__factory"; 17 | export type { ERC20 } from "./externalArtifacts/ERC20"; 18 | export { ERC20__factory } from "./factories/externalArtifacts/ERC20__factory"; 19 | -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/no-override-project/contracts/c.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.7.3; 2 | 3 | contract C { 4 | } -------------------------------------------------------------------------------- /packages/hardhat/test/fixture-projects/no-override-project/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | // We load the plugin here. 2 | import '../../../src/index' 3 | 4 | import { HardhatUserConfig } from 'hardhat/types' 5 | 6 | const config: HardhatUserConfig = { 7 | solidity: '0.7.3', 8 | defaultNetwork: 'hardhat', 9 | typechain: { 10 | dontOverrideCompile: true, 11 | }, 12 | } 13 | 14 | export default config 15 | -------------------------------------------------------------------------------- /packages/hardhat/test/helpers.ts: -------------------------------------------------------------------------------- 1 | import { resetHardhatContext } from 'hardhat/plugins-testing' 2 | import { HardhatRuntimeEnvironment } from 'hardhat/types' 3 | import path from 'path' 4 | 5 | declare module 'mocha' { 6 | interface Context { 7 | hre: HardhatRuntimeEnvironment 8 | } 9 | } 10 | 11 | export function useEnvironment(fixtureProjectName: string) { 12 | beforeEach('Loading hardhat environment', function () { 13 | process.chdir(path.join(__dirname, 'fixture-projects', fixtureProjectName)) 14 | 15 | // eslint-disable-next-line 16 | this.hre = require('hardhat') 17 | }) 18 | 19 | afterEach('Resetting hardhat', function () { 20 | resetHardhatContext() 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /packages/hardhat/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/hardhat/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/test/Issue552Reproduction.test.ts: -------------------------------------------------------------------------------- 1 | import type { AssertTrue, IsExact } from 'test-utils' 2 | 3 | import type { Issue552_Observer, Issue552_Reproduction } from '../types/v0.8.9/Issue552_Reproduction' 4 | import { createNewBlockchain } from './common' 5 | 6 | describe('Issue552Reproduction', () => { 7 | const chain = createNewBlockchain('Issue552_Reproduction') 8 | 9 | it.skip('does not emit overly long tuples', () => { 10 | type _ = [ 11 | AssertTrue< 12 | IsExact 13 | >, 14 | AssertTrue< 15 | IsExact< 16 | Issue552_Reproduction.ObservationParamsStructOutput['observations'], 17 | Issue552_Observer.ObservationStructOutput[] 18 | > 19 | >, 20 | ] 21 | }) 22 | 23 | it('accepts array of numbers', async () => { 24 | await chain.contract.input([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/test/Overload.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'earljs' 2 | import { BigNumber } from 'ethers' 3 | import { typedAssert } from 'test-utils' 4 | 5 | import type { Overloads } from '../types/v0.6.4/Overloads' 6 | import { createNewBlockchain } from './common' 7 | 8 | describe('Overloads', () => { 9 | const chain = createNewBlockchain('Overloads') 10 | 11 | it('works with 1st overload', async () => { 12 | typedAssert(await chain.contract['overload1(int256)'](1), BigNumber.from(1)) 13 | typedAssert(await chain.contract.functions['overload1(int256)'](1), [BigNumber.from(1)]) 14 | }) 15 | 16 | it('still doesnt create overload1 fn anymore', () => { 17 | // this is exepcted error as there is no index signature anymore on Contract 18 | // @ts-expect-error 19 | expect(chain.contract.overload1).toEqual(undefined) 20 | }) 21 | 22 | it('works with 2n overload', async () => { 23 | typedAssert(await chain.contract['overload1(uint256,uint256)'](1, 2), BigNumber.from(3)) 24 | typedAssert(await chain.contract.functions['overload1(uint256,uint256)'](1, 2), [BigNumber.from(3)]) 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/test/Polymorphism.test.ts: -------------------------------------------------------------------------------- 1 | import type { ISimpleToken, SimpleToken } from '../types' 2 | 3 | // test if we can assign exact implementation to typing of an interface aka polymorphism 4 | type ExactImplementation = SimpleToken 5 | type Interface = ISimpleToken 6 | // I am sure this can be written in a more civilized way... 7 | const _test: Interface = undefined as any as ExactImplementation 8 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true, 7 | "importsNotUsedAsValues": "error" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "lib": ["ES2018", "DOM"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as v064 from "./v0.6.4"; 5 | export * as v089 from "./v0.8.9"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Issue428_Reproduction/A__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { A, AInterface } from "../../../v0.6.4/Issue428_Reproduction/A"; 8 | 9 | const _abi = [ 10 | { 11 | anonymous: false, 12 | inputs: [ 13 | { 14 | indexed: false, 15 | internalType: "address[]", 16 | name: "whitelist", 17 | type: "address[]", 18 | }, 19 | ], 20 | name: "Committed", 21 | type: "event", 22 | }, 23 | ] as const; 24 | 25 | export class A__factory { 26 | static readonly abi = _abi; 27 | static createInterface(): AInterface { 28 | return new utils.Interface(_abi) as AInterface; 29 | } 30 | static connect(address: string, signerOrProvider: Signer | Provider): A { 31 | return new Contract(address, _abi, signerOrProvider) as A; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Issue428_Reproduction/B__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { B, BInterface } from "../../../v0.6.4/Issue428_Reproduction/B"; 8 | 9 | const _abi = [ 10 | { 11 | anonymous: false, 12 | inputs: [ 13 | { 14 | indexed: false, 15 | internalType: "uint256", 16 | name: "timelock", 17 | type: "uint256", 18 | }, 19 | ], 20 | name: "Committed", 21 | type: "event", 22 | }, 23 | { 24 | anonymous: false, 25 | inputs: [ 26 | { 27 | indexed: false, 28 | internalType: "address[]", 29 | name: "whitelist", 30 | type: "address[]", 31 | }, 32 | ], 33 | name: "Committed", 34 | type: "event", 35 | }, 36 | ] as const; 37 | 38 | export class B__factory { 39 | static readonly abi = _abi; 40 | static createInterface(): BInterface { 41 | return new utils.Interface(_abi) as BInterface; 42 | } 43 | static connect(address: string, signerOrProvider: Signer | Provider): B { 44 | return new Contract(address, _abi, signerOrProvider) as B; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Issue428_Reproduction/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { A__factory } from "./A__factory"; 5 | export { B__factory } from "./B__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Library/Lib__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { Lib, LibInterface } from "../../../v0.6.4/Library/Lib"; 8 | 9 | const _abi = [ 10 | { 11 | inputs: [ 12 | { 13 | internalType: "enum Lib.BOOL", 14 | name: "b", 15 | type: "Lib.BOOL", 16 | }, 17 | ], 18 | name: "other", 19 | outputs: [ 20 | { 21 | internalType: "enum Lib.BOOL", 22 | name: "", 23 | type: "Lib.BOOL", 24 | }, 25 | ], 26 | stateMutability: "pure", 27 | type: "function", 28 | }, 29 | ] as const; 30 | 31 | export class Lib__factory { 32 | static readonly abi = _abi; 33 | static createInterface(): LibInterface { 34 | return new utils.Interface(_abi) as LibInterface; 35 | } 36 | static connect(address: string, signerOrProvider: Signer | Provider): Lib { 37 | return new Contract(address, _abi, signerOrProvider) as Lib; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Library/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Lib__factory } from "./Lib__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/LibraryConsumer__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | LibraryConsumer, 9 | LibraryConsumerInterface, 10 | } from "../../v0.6.4/LibraryConsumer"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [ 15 | { 16 | internalType: "enum Lib.BOOL", 17 | name: "b", 18 | type: "uint8", 19 | }, 20 | ], 21 | name: "someOther", 22 | outputs: [ 23 | { 24 | internalType: "enum Lib.BOOL", 25 | name: "", 26 | type: "uint8", 27 | }, 28 | ], 29 | stateMutability: "pure", 30 | type: "function", 31 | }, 32 | ] as const; 33 | 34 | export class LibraryConsumer__factory { 35 | static readonly abi = _abi; 36 | static createInterface(): LibraryConsumerInterface { 37 | return new utils.Interface(_abi) as LibraryConsumerInterface; 38 | } 39 | static connect( 40 | address: string, 41 | signerOrProvider: Signer | Provider 42 | ): LibraryConsumer { 43 | return new Contract(address, _abi, signerOrProvider) as LibraryConsumer; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Name-Mangling/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NAME12mangling__factory } from "./NAME12mangling__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Payable/PayableFactory__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | PayableFactory, 9 | PayableFactoryInterface, 10 | } from "../../../v0.6.4/Payable/PayableFactory"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [], 15 | name: "newPayable", 16 | outputs: [ 17 | { 18 | internalType: "contract Payable", 19 | name: "", 20 | type: "address", 21 | }, 22 | ], 23 | stateMutability: "nonpayable", 24 | type: "function", 25 | }, 26 | ] as const; 27 | 28 | export class PayableFactory__factory { 29 | static readonly abi = _abi; 30 | static createInterface(): PayableFactoryInterface { 31 | return new utils.Interface(_abi) as PayableFactoryInterface; 32 | } 33 | static connect( 34 | address: string, 35 | signerOrProvider: Signer | Provider 36 | ): PayableFactory { 37 | return new Contract(address, _abi, signerOrProvider) as PayableFactory; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Payable/Payable__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | Payable, 9 | PayableInterface, 10 | } from "../../../v0.6.4/Payable/Payable"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [], 15 | name: "non_payable_func", 16 | outputs: [], 17 | stateMutability: "nonpayable", 18 | type: "function", 19 | }, 20 | { 21 | inputs: [], 22 | name: "payable_func", 23 | outputs: [], 24 | stateMutability: "payable", 25 | type: "function", 26 | }, 27 | ] as const; 28 | 29 | export class Payable__factory { 30 | static readonly abi = _abi; 31 | static createInterface(): PayableInterface { 32 | return new utils.Interface(_abi) as PayableInterface; 33 | } 34 | static connect( 35 | address: string, 36 | signerOrProvider: Signer | Provider 37 | ): Payable { 38 | return new Contract(address, _abi, signerOrProvider) as Payable; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/Payable/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Payable__factory } from "./Payable__factory"; 5 | export { PayableFactory__factory } from "./PayableFactory__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.6.4/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as issue428Reproduction from "./Issue428_Reproduction"; 5 | export * as library from "./Library"; 6 | export * as nameMangling from "./Name-Mangling"; 7 | export * as payable from "./Payable"; 8 | export { DataTypesInput__factory } from "./DataTypesInput__factory"; 9 | export { DataTypesPure__factory } from "./DataTypesPure__factory"; 10 | export { DataTypesView__factory } from "./DataTypesView__factory"; 11 | export { Events__factory } from "./Events__factory"; 12 | export { LibraryConsumer__factory } from "./LibraryConsumer__factory"; 13 | export { Overloads__factory } from "./Overloads__factory"; 14 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/ISimpleToken__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | ISimpleToken, 9 | ISimpleTokenInterface, 10 | } from "../../v0.8.9/ISimpleToken"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [ 15 | { 16 | internalType: "address", 17 | name: "from", 18 | type: "address", 19 | }, 20 | { 21 | internalType: "uint256", 22 | name: "value", 23 | type: "uint256", 24 | }, 25 | ], 26 | name: "transfer", 27 | outputs: [], 28 | stateMutability: "nonpayable", 29 | type: "function", 30 | }, 31 | ] as const; 32 | 33 | export class ISimpleToken__factory { 34 | static readonly abi = _abi; 35 | static createInterface(): ISimpleTokenInterface { 36 | return new utils.Interface(_abi) as ISimpleTokenInterface; 37 | } 38 | static connect( 39 | address: string, 40 | signerOrProvider: Signer | Provider 41 | ): ISimpleToken { 42 | return new Contract(address, _abi, signerOrProvider) as ISimpleToken; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/KingOfTheHill/Withdrawable__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | Withdrawable, 9 | WithdrawableInterface, 10 | } from "../../../v0.8.9/KingOfTheHill/Withdrawable"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [], 15 | name: "withdraw", 16 | outputs: [], 17 | stateMutability: "nonpayable", 18 | type: "function", 19 | }, 20 | ] as const; 21 | 22 | export class Withdrawable__factory { 23 | static readonly abi = _abi; 24 | static createInterface(): WithdrawableInterface { 25 | return new utils.Interface(_abi) as WithdrawableInterface; 26 | } 27 | static connect( 28 | address: string, 29 | signerOrProvider: Signer | Provider 30 | ): Withdrawable { 31 | return new Contract(address, _abi, signerOrProvider) as Withdrawable; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/KingOfTheHill/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { KingOfTheHill__factory } from "./KingOfTheHill__factory"; 5 | export { Withdrawable__factory } from "./Withdrawable__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/Rarity/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { ERC721__factory } from "./ERC721__factory"; 5 | export { ERC721Enumerable__factory } from "./ERC721Enumerable__factory"; 6 | export { IERC721__factory } from "./IERC721__factory"; 7 | export { IERC721Enumerable__factory } from "./IERC721Enumerable__factory"; 8 | export { IERC721Receiver__factory } from "./IERC721Receiver__factory"; 9 | export { Rarity__factory } from "./Rarity__factory"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/SimpleToken__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | SimpleToken, 9 | SimpleTokenInterface, 10 | } from "../../v0.8.9/SimpleToken"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [ 15 | { 16 | internalType: "address", 17 | name: "from", 18 | type: "address", 19 | }, 20 | { 21 | internalType: "uint256", 22 | name: "value", 23 | type: "uint256", 24 | }, 25 | ], 26 | name: "transfer", 27 | outputs: [], 28 | stateMutability: "nonpayable", 29 | type: "function", 30 | }, 31 | ] as const; 32 | 33 | export class SimpleToken__factory { 34 | static readonly abi = _abi; 35 | static createInterface(): SimpleTokenInterface { 36 | return new utils.Interface(_abi) as SimpleTokenInterface; 37 | } 38 | static connect( 39 | address: string, 40 | signerOrProvider: Signer | Provider 41 | ): SimpleToken { 42 | return new Contract(address, _abi, signerOrProvider) as SimpleToken; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as kingOfTheHill from "./KingOfTheHill"; 5 | export * as rarity from "./Rarity"; 6 | export * as nested from "./nested"; 7 | export { ISimpleToken__factory } from "./ISimpleToken__factory"; 8 | export { Issue552_Reproduction__factory } from "./Issue552_Reproduction__factory"; 9 | export { SimpleToken__factory } from "./SimpleToken__factory"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/nested/a/NestedLibrary__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | NestedLibrary, 9 | NestedLibraryInterface, 10 | } from "../../../../v0.8.9/nested/a/NestedLibrary"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [], 15 | name: "getValue", 16 | outputs: [ 17 | { 18 | internalType: "uint32", 19 | name: "", 20 | type: "uint32", 21 | }, 22 | ], 23 | stateMutability: "pure", 24 | type: "function", 25 | }, 26 | ] as const; 27 | 28 | export class NestedLibrary__factory { 29 | static readonly abi = _abi; 30 | static createInterface(): NestedLibraryInterface { 31 | return new utils.Interface(_abi) as NestedLibraryInterface; 32 | } 33 | static connect( 34 | address: string, 35 | signerOrProvider: Signer | Provider 36 | ): NestedLibrary { 37 | return new Contract(address, _abi, signerOrProvider) as NestedLibrary; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/nested/a/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NestedLibrary__factory } from "./NestedLibrary__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/nested/b/NestedLibrary__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Signer, utils } from "ethers"; 6 | import type { Provider } from "@ethersproject/providers"; 7 | import type { 8 | NestedLibrary, 9 | NestedLibraryInterface, 10 | } from "../../../../v0.8.9/nested/b/NestedLibrary"; 11 | 12 | const _abi = [ 13 | { 14 | inputs: [], 15 | name: "getValue", 16 | outputs: [ 17 | { 18 | internalType: "uint256", 19 | name: "", 20 | type: "uint256", 21 | }, 22 | ], 23 | stateMutability: "pure", 24 | type: "function", 25 | }, 26 | ] as const; 27 | 28 | export class NestedLibrary__factory { 29 | static readonly abi = _abi; 30 | static createInterface(): NestedLibraryInterface { 31 | return new utils.Interface(_abi) as NestedLibraryInterface; 32 | } 33 | static connect( 34 | address: string, 35 | signerOrProvider: Signer | Provider 36 | ): NestedLibrary { 37 | return new Contract(address, _abi, signerOrProvider) as NestedLibrary; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/nested/b/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NestedLibrary__factory } from "./NestedLibrary__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/factories/v0.8.9/nested/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as a from "./a"; 5 | export * as b from "./b"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.6.4/Issue428_Reproduction/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { A } from "./A"; 5 | export type { B } from "./B"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.6.4/Library/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Lib } from "./Lib"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.6.4/Name-Mangling/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NAME12mangling } from "./NAME12mangling"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.6.4/Payable/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Payable } from "./Payable"; 5 | export type { PayableFactory } from "./PayableFactory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.6.4/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as issue428Reproduction from "./Issue428_Reproduction"; 5 | export type { issue428Reproduction }; 6 | import type * as library from "./Library"; 7 | export type { library }; 8 | import type * as nameMangling from "./Name-Mangling"; 9 | export type { nameMangling }; 10 | import type * as payable from "./Payable"; 11 | export type { payable }; 12 | export type { DataTypesInput } from "./DataTypesInput"; 13 | export type { DataTypesPure } from "./DataTypesPure"; 14 | export type { DataTypesView } from "./DataTypesView"; 15 | export type { Events } from "./Events"; 16 | export type { LibraryConsumer } from "./LibraryConsumer"; 17 | export type { Overloads } from "./Overloads"; 18 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/KingOfTheHill/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { KingOfTheHill } from "./KingOfTheHill"; 5 | export type { Withdrawable } from "./Withdrawable"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/Rarity/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { ERC721 } from "./ERC721"; 5 | export type { ERC721Enumerable } from "./ERC721Enumerable"; 6 | export type { IERC721 } from "./IERC721"; 7 | export type { IERC721Enumerable } from "./IERC721Enumerable"; 8 | export type { IERC721Receiver } from "./IERC721Receiver"; 9 | export type { Rarity } from "./Rarity"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as kingOfTheHill from "./KingOfTheHill"; 5 | export type { kingOfTheHill }; 6 | import type * as rarity from "./Rarity"; 7 | export type { rarity }; 8 | import type * as nested from "./nested"; 9 | export type { nested }; 10 | export type { ISimpleToken } from "./ISimpleToken"; 11 | export type { Issue552_Reproduction } from "./Issue552_Reproduction"; 12 | export type { SimpleToken } from "./SimpleToken"; 13 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/nested/a/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/nested/b/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v5-test/types/v0.8.9/nested/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as a from "./a"; 5 | export type { a }; 6 | import type * as b from "./b"; 7 | export type { b }; 8 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/src/codegen/reserved-keywords.ts: -------------------------------------------------------------------------------- 1 | export const reservedKeywords = new Set(['signer', 'provider', 'deployTransaction', 'deployed', 'fallback', 'connect']) 2 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/src/common.ts: -------------------------------------------------------------------------------- 1 | export const FACTORY_POSTFIX = '__factory' 2 | export const STRUCT_INPUT_POSTFIX = 'Struct' 3 | export const STRUCT_OUTPUT_POSTFIX = 'StructOutput' 4 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/static/common.ts: -------------------------------------------------------------------------------- 1 | import type { Listener } from '@ethersproject/providers' 2 | import type { Event, EventFilter } from 'ethers' 3 | 4 | export interface TypedEvent = any, TArgsObject = any> extends Event { 5 | args: TArgsArray & TArgsObject 6 | } 7 | 8 | export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} 9 | 10 | export interface TypedListener { 11 | (...listenerArg: [...__TypechainArgsArray, TEvent]): void 12 | } 13 | 14 | type __TypechainArgsArray = T extends TypedEvent ? U : never 15 | 16 | export interface OnEvent { 17 | (eventFilter: TypedEventFilter, listener: TypedListener): TRes 18 | (eventName: string, listener: Listener): TRes 19 | } 20 | 21 | export type MinEthersFactory = { 22 | deploy(...a: ARGS[]): Promise 23 | } 24 | 25 | export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never 26 | 27 | export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never 28 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/test/typelevel-test.ts: -------------------------------------------------------------------------------- 1 | import { AssertTrue, IsExact } from 'test-utils' 2 | 3 | import { OnEvent, TypedEvent, TypedEventFilter } from '../static/common' 4 | 5 | export type TransferEvent = TypedEvent<[string, string, number], { from: string; to: string; tokenId: number }> 6 | 7 | declare const filter: TypedEventFilter 8 | 9 | declare const onEvent: OnEvent 10 | 11 | onEvent(filter, (...args) => { 12 | type _ = AssertTrue> 13 | }) 14 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | }, 8 | "references": [ 9 | { 10 | "path": "../typechain/tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/target-ethers-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "static"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@typechain/ethers-v6-test", 3 | "private": true, 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "scripts": { 7 | "format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"", 8 | "format:fix": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --write \"./**/*.ts\"", 9 | "lint": "eslint --ext .ts test", 10 | "lint:fix": "pnpm lint --fix", 11 | "typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json", 12 | "clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build", 13 | "generate-types": "node ../typechain/dist/cli/cli.js --target=../target-ethers-v6/dist/index.js --out-dir ./types/ '../../contracts/compiled/**/*.abi'", 14 | "test": "pnpm generate-types && mocha --config ../../.mocharc.js", 15 | "test:fix": "pnpm lint:fix && pnpm format:fix && pnpm test && pnpm typecheck" 16 | }, 17 | "devDependencies": { 18 | "ganache": "^7.8.0", 19 | "test-utils": "1.0.0", 20 | "typechain": "workspace:^8.3.2" 21 | }, 22 | "dependencies": { 23 | "ethers": "6.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/test/Issue552Reproduction.test.ts: -------------------------------------------------------------------------------- 1 | import type { AssertTrue, IsExact } from 'test-utils' 2 | 3 | import type { Issue552_Observer, Issue552_Reproduction } from '../types/v0.8.9/Issue552_Reproduction' 4 | import { createNewBlockchain } from './common' 5 | 6 | describe('Issue552Reproduction', () => { 7 | const chain = createNewBlockchain('Issue552_Reproduction') 8 | 9 | it.skip('does not emit overly long tuples', () => { 10 | type _ = [ 11 | AssertTrue< 12 | IsExact 13 | >, 14 | AssertTrue< 15 | IsExact< 16 | Issue552_Reproduction.ObservationParamsStructOutput['observations'], 17 | Issue552_Observer.ObservationStructOutput[] 18 | > 19 | >, 20 | ] 21 | }) 22 | 23 | it('accepts array of numbers', async () => { 24 | await chain.contract.input([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/test/Overload.test.ts: -------------------------------------------------------------------------------- 1 | import { typedAssert } from 'test-utils' 2 | 3 | import type { Overloads } from '../types/v0.6.4/Overloads' 4 | import { createNewBlockchain } from './common' 5 | 6 | describe('Overloads', () => { 7 | const chain = createNewBlockchain('Overloads') 8 | 9 | it('works with 1st overload', async () => { 10 | typedAssert(await chain.contract['overload1(int256)'](1), BigInt(1)) 11 | typedAssert(await chain.contract['overload1(int256)'].staticCallResult(1), [BigInt(1)]) 12 | }) 13 | 14 | it('works with 2n overload', async () => { 15 | typedAssert(await chain.contract['overload1(uint256,uint256)'](1, 2), BigInt(3)) 16 | typedAssert(await chain.contract['overload1(uint256,uint256)'].staticCallResult(1, 2), [BigInt(3)]) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/test/Payable.test.ts: -------------------------------------------------------------------------------- 1 | import type { AssertTrue, IsExact } from 'test-utils' 2 | 3 | import type { Payable } from '../types' 4 | import type { PostfixOverrides } from '../types/common' 5 | import { createNewBlockchain } from './common' 6 | 7 | describe('Payable', () => { 8 | const chain = createNewBlockchain('Payable') 9 | 10 | it('generate view override parameter types for staticCall', async () => { 11 | type InputType = Parameters 12 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 13 | type _t1 = AssertTrue>> 14 | }) 15 | 16 | it('generate view override parameter types for staticCallResult', async () => { 17 | type InputType = Parameters 18 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 19 | type _t1 = AssertTrue>> 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/test/Polymorphism.test.ts: -------------------------------------------------------------------------------- 1 | import type { ISimpleToken, SimpleToken } from '../types' 2 | 3 | // test if we can assign exact implementation to typing of an interface aka polymorphism 4 | type ExactImplementation = SimpleToken 5 | type Interface = ISimpleToken 6 | // I am sure this can be written in a more civilized way... 7 | const _test: Interface = undefined as any as ExactImplementation 8 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src", 7 | "moduleResolution": "node16" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "types"], 4 | "compilerOptions": { 5 | "target": "ES2020", 6 | "esModuleInterop": true, 7 | "skipLibCheck": true, 8 | "importsNotUsedAsValues": "error", 9 | "moduleResolution": "node16" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "lib": ["ES2018", "DOM"], 7 | "moduleResolution": "node16" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as v064 from "./v0.6.4"; 5 | export * as v089 from "./v0.8.9"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Issue428_Reproduction/A__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { A, AInterface } from "../../../v0.6.4/Issue428_Reproduction/A"; 7 | 8 | const _abi = [ 9 | { 10 | anonymous: false, 11 | inputs: [ 12 | { 13 | indexed: false, 14 | internalType: "address[]", 15 | name: "whitelist", 16 | type: "address[]", 17 | }, 18 | ], 19 | name: "Committed", 20 | type: "event", 21 | }, 22 | ] as const; 23 | 24 | export class A__factory { 25 | static readonly abi = _abi; 26 | static createInterface(): AInterface { 27 | return new Interface(_abi) as AInterface; 28 | } 29 | static connect(address: string, runner?: ContractRunner | null): A { 30 | return new Contract(address, _abi, runner) as unknown as A; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Issue428_Reproduction/B__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { B, BInterface } from "../../../v0.6.4/Issue428_Reproduction/B"; 7 | 8 | const _abi = [ 9 | { 10 | anonymous: false, 11 | inputs: [ 12 | { 13 | indexed: false, 14 | internalType: "uint256", 15 | name: "timelock", 16 | type: "uint256", 17 | }, 18 | ], 19 | name: "Committed", 20 | type: "event", 21 | }, 22 | { 23 | anonymous: false, 24 | inputs: [ 25 | { 26 | indexed: false, 27 | internalType: "address[]", 28 | name: "whitelist", 29 | type: "address[]", 30 | }, 31 | ], 32 | name: "Committed", 33 | type: "event", 34 | }, 35 | ] as const; 36 | 37 | export class B__factory { 38 | static readonly abi = _abi; 39 | static createInterface(): BInterface { 40 | return new Interface(_abi) as BInterface; 41 | } 42 | static connect(address: string, runner?: ContractRunner | null): B { 43 | return new Contract(address, _abi, runner) as unknown as B; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Issue428_Reproduction/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { A__factory } from "./A__factory"; 5 | export { B__factory } from "./B__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Library/Lib__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { Lib, LibInterface } from "../../../v0.6.4/Library/Lib"; 7 | 8 | const _abi = [ 9 | { 10 | inputs: [ 11 | { 12 | internalType: "enum Lib.BOOL", 13 | name: "b", 14 | type: "Lib.BOOL", 15 | }, 16 | ], 17 | name: "other", 18 | outputs: [ 19 | { 20 | internalType: "enum Lib.BOOL", 21 | name: "", 22 | type: "Lib.BOOL", 23 | }, 24 | ], 25 | stateMutability: "pure", 26 | type: "function", 27 | }, 28 | ] as const; 29 | 30 | export class Lib__factory { 31 | static readonly abi = _abi; 32 | static createInterface(): LibInterface { 33 | return new Interface(_abi) as LibInterface; 34 | } 35 | static connect(address: string, runner?: ContractRunner | null): Lib { 36 | return new Contract(address, _abi, runner) as unknown as Lib; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Library/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Lib__factory } from "./Lib__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/LibraryConsumer__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | LibraryConsumer, 8 | LibraryConsumerInterface, 9 | } from "../../v0.6.4/LibraryConsumer"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [ 14 | { 15 | internalType: "enum Lib.BOOL", 16 | name: "b", 17 | type: "uint8", 18 | }, 19 | ], 20 | name: "someOther", 21 | outputs: [ 22 | { 23 | internalType: "enum Lib.BOOL", 24 | name: "", 25 | type: "uint8", 26 | }, 27 | ], 28 | stateMutability: "pure", 29 | type: "function", 30 | }, 31 | ] as const; 32 | 33 | export class LibraryConsumer__factory { 34 | static readonly abi = _abi; 35 | static createInterface(): LibraryConsumerInterface { 36 | return new Interface(_abi) as LibraryConsumerInterface; 37 | } 38 | static connect( 39 | address: string, 40 | runner?: ContractRunner | null 41 | ): LibraryConsumer { 42 | return new Contract(address, _abi, runner) as unknown as LibraryConsumer; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Name-Mangling/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NAME12mangling__factory } from "./NAME12mangling__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Payable/PayableFactory__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | PayableFactory, 8 | PayableFactoryInterface, 9 | } from "../../../v0.6.4/Payable/PayableFactory"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [], 14 | name: "newPayable", 15 | outputs: [ 16 | { 17 | internalType: "contract Payable", 18 | name: "", 19 | type: "address", 20 | }, 21 | ], 22 | stateMutability: "nonpayable", 23 | type: "function", 24 | }, 25 | ] as const; 26 | 27 | export class PayableFactory__factory { 28 | static readonly abi = _abi; 29 | static createInterface(): PayableFactoryInterface { 30 | return new Interface(_abi) as PayableFactoryInterface; 31 | } 32 | static connect( 33 | address: string, 34 | runner?: ContractRunner | null 35 | ): PayableFactory { 36 | return new Contract(address, _abi, runner) as unknown as PayableFactory; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Payable/Payable__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | Payable, 8 | PayableInterface, 9 | } from "../../../v0.6.4/Payable/Payable"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [], 14 | name: "non_payable_func", 15 | outputs: [], 16 | stateMutability: "nonpayable", 17 | type: "function", 18 | }, 19 | { 20 | inputs: [], 21 | name: "payable_func", 22 | outputs: [], 23 | stateMutability: "payable", 24 | type: "function", 25 | }, 26 | ] as const; 27 | 28 | export class Payable__factory { 29 | static readonly abi = _abi; 30 | static createInterface(): PayableInterface { 31 | return new Interface(_abi) as PayableInterface; 32 | } 33 | static connect(address: string, runner?: ContractRunner | null): Payable { 34 | return new Contract(address, _abi, runner) as unknown as Payable; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/Payable/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { Payable__factory } from "./Payable__factory"; 5 | export { PayableFactory__factory } from "./PayableFactory__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.6.4/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as issue428Reproduction from "./Issue428_Reproduction"; 5 | export * as library from "./Library"; 6 | export * as nameMangling from "./Name-Mangling"; 7 | export * as payable from "./Payable"; 8 | export { DataTypesInput__factory } from "./DataTypesInput__factory"; 9 | export { DataTypesPure__factory } from "./DataTypesPure__factory"; 10 | export { DataTypesView__factory } from "./DataTypesView__factory"; 11 | export { Events__factory } from "./Events__factory"; 12 | export { LibraryConsumer__factory } from "./LibraryConsumer__factory"; 13 | export { Overloads__factory } from "./Overloads__factory"; 14 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/ISimpleToken__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | ISimpleToken, 8 | ISimpleTokenInterface, 9 | } from "../../v0.8.9/ISimpleToken"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [ 14 | { 15 | internalType: "address", 16 | name: "from", 17 | type: "address", 18 | }, 19 | { 20 | internalType: "uint256", 21 | name: "value", 22 | type: "uint256", 23 | }, 24 | ], 25 | name: "transfer", 26 | outputs: [], 27 | stateMutability: "nonpayable", 28 | type: "function", 29 | }, 30 | ] as const; 31 | 32 | export class ISimpleToken__factory { 33 | static readonly abi = _abi; 34 | static createInterface(): ISimpleTokenInterface { 35 | return new Interface(_abi) as ISimpleTokenInterface; 36 | } 37 | static connect( 38 | address: string, 39 | runner?: ContractRunner | null 40 | ): ISimpleToken { 41 | return new Contract(address, _abi, runner) as unknown as ISimpleToken; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/KingOfTheHill/Withdrawable__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | Withdrawable, 8 | WithdrawableInterface, 9 | } from "../../../v0.8.9/KingOfTheHill/Withdrawable"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [], 14 | name: "withdraw", 15 | outputs: [], 16 | stateMutability: "nonpayable", 17 | type: "function", 18 | }, 19 | ] as const; 20 | 21 | export class Withdrawable__factory { 22 | static readonly abi = _abi; 23 | static createInterface(): WithdrawableInterface { 24 | return new Interface(_abi) as WithdrawableInterface; 25 | } 26 | static connect( 27 | address: string, 28 | runner?: ContractRunner | null 29 | ): Withdrawable { 30 | return new Contract(address, _abi, runner) as unknown as Withdrawable; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/KingOfTheHill/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { KingOfTheHill__factory } from "./KingOfTheHill__factory"; 5 | export { Withdrawable__factory } from "./Withdrawable__factory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/Rarity/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { ERC721__factory } from "./ERC721__factory"; 5 | export { ERC721Enumerable__factory } from "./ERC721Enumerable__factory"; 6 | export { IERC721__factory } from "./IERC721__factory"; 7 | export { IERC721Enumerable__factory } from "./IERC721Enumerable__factory"; 8 | export { IERC721Receiver__factory } from "./IERC721Receiver__factory"; 9 | export { Rarity__factory } from "./Rarity__factory"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/SimpleToken__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | SimpleToken, 8 | SimpleTokenInterface, 9 | } from "../../v0.8.9/SimpleToken"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [ 14 | { 15 | internalType: "address", 16 | name: "from", 17 | type: "address", 18 | }, 19 | { 20 | internalType: "uint256", 21 | name: "value", 22 | type: "uint256", 23 | }, 24 | ], 25 | name: "transfer", 26 | outputs: [], 27 | stateMutability: "nonpayable", 28 | type: "function", 29 | }, 30 | ] as const; 31 | 32 | export class SimpleToken__factory { 33 | static readonly abi = _abi; 34 | static createInterface(): SimpleTokenInterface { 35 | return new Interface(_abi) as SimpleTokenInterface; 36 | } 37 | static connect(address: string, runner?: ContractRunner | null): SimpleToken { 38 | return new Contract(address, _abi, runner) as unknown as SimpleToken; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as kingOfTheHill from "./KingOfTheHill"; 5 | export * as rarity from "./Rarity"; 6 | export * as nested from "./nested"; 7 | export { ISimpleToken__factory } from "./ISimpleToken__factory"; 8 | export { Issue552_Reproduction__factory } from "./Issue552_Reproduction__factory"; 9 | export { SimpleToken__factory } from "./SimpleToken__factory"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/nested/a/NestedLibrary__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | NestedLibrary, 8 | NestedLibraryInterface, 9 | } from "../../../../v0.8.9/nested/a/NestedLibrary"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [], 14 | name: "getValue", 15 | outputs: [ 16 | { 17 | internalType: "uint32", 18 | name: "", 19 | type: "uint32", 20 | }, 21 | ], 22 | stateMutability: "pure", 23 | type: "function", 24 | }, 25 | ] as const; 26 | 27 | export class NestedLibrary__factory { 28 | static readonly abi = _abi; 29 | static createInterface(): NestedLibraryInterface { 30 | return new Interface(_abi) as NestedLibraryInterface; 31 | } 32 | static connect( 33 | address: string, 34 | runner?: ContractRunner | null 35 | ): NestedLibrary { 36 | return new Contract(address, _abi, runner) as unknown as NestedLibrary; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/nested/a/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NestedLibrary__factory } from "./NestedLibrary__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/nested/b/NestedLibrary__factory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import { Contract, Interface, type ContractRunner } from "ethers"; 6 | import type { 7 | NestedLibrary, 8 | NestedLibraryInterface, 9 | } from "../../../../v0.8.9/nested/b/NestedLibrary"; 10 | 11 | const _abi = [ 12 | { 13 | inputs: [], 14 | name: "getValue", 15 | outputs: [ 16 | { 17 | internalType: "uint256", 18 | name: "", 19 | type: "uint256", 20 | }, 21 | ], 22 | stateMutability: "pure", 23 | type: "function", 24 | }, 25 | ] as const; 26 | 27 | export class NestedLibrary__factory { 28 | static readonly abi = _abi; 29 | static createInterface(): NestedLibraryInterface { 30 | return new Interface(_abi) as NestedLibraryInterface; 31 | } 32 | static connect( 33 | address: string, 34 | runner?: ContractRunner | null 35 | ): NestedLibrary { 36 | return new Contract(address, _abi, runner) as unknown as NestedLibrary; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/nested/b/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export { NestedLibrary__factory } from "./NestedLibrary__factory"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/factories/v0.8.9/nested/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export * as a from "./a"; 5 | export * as b from "./b"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.6.4/Issue428_Reproduction/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { A } from "./A"; 5 | export type { B } from "./B"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.6.4/Library/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Lib } from "./Lib"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.6.4/Name-Mangling/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NAME12mangling } from "./NAME12mangling"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.6.4/Payable/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Payable } from "./Payable"; 5 | export type { PayableFactory } from "./PayableFactory"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.6.4/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as issue428Reproduction from "./Issue428_Reproduction"; 5 | export type { issue428Reproduction }; 6 | import type * as library from "./Library"; 7 | export type { library }; 8 | import type * as nameMangling from "./Name-Mangling"; 9 | export type { nameMangling }; 10 | import type * as payable from "./Payable"; 11 | export type { payable }; 12 | export type { DataTypesInput } from "./DataTypesInput"; 13 | export type { DataTypesPure } from "./DataTypesPure"; 14 | export type { DataTypesView } from "./DataTypesView"; 15 | export type { Events } from "./Events"; 16 | export type { LibraryConsumer } from "./LibraryConsumer"; 17 | export type { Overloads } from "./Overloads"; 18 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/KingOfTheHill/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { KingOfTheHill } from "./KingOfTheHill"; 5 | export type { Withdrawable } from "./Withdrawable"; 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/Rarity/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { ERC721 } from "./ERC721"; 5 | export type { ERC721Enumerable } from "./ERC721Enumerable"; 6 | export type { IERC721 } from "./IERC721"; 7 | export type { IERC721Enumerable } from "./IERC721Enumerable"; 8 | export type { IERC721Receiver } from "./IERC721Receiver"; 9 | export type { Rarity } from "./Rarity"; 10 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as kingOfTheHill from "./KingOfTheHill"; 5 | export type { kingOfTheHill }; 6 | import type * as rarity from "./Rarity"; 7 | export type { rarity }; 8 | import type * as nested from "./nested"; 9 | export type { nested }; 10 | export type { ISimpleToken } from "./ISimpleToken"; 11 | export type { Issue552_Reproduction } from "./Issue552_Reproduction"; 12 | export type { SimpleToken } from "./SimpleToken"; 13 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/nested/a/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/nested/b/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-ethers-v6-test/types/v0.8.9/nested/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as a from "./a"; 5 | export type { a }; 6 | import type * as b from "./b"; 7 | export type { b }; 8 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/src/codegen/reserved-keywords.ts: -------------------------------------------------------------------------------- 1 | export const reservedKeywords = new Set(['signer', 'provider', 'deployTransaction', 'deployed', 'fallback', 'connect']) 2 | 3 | export const reservedKeywordsLabels = new Set([ 4 | 'class', 5 | 'function', 6 | 'interface', 7 | 'extends', 8 | 'implements', 9 | 'constructor', 10 | 'super', 11 | 'this', 12 | 'let', 13 | 'var', 14 | 'const', 15 | 'if', 16 | 'else', 17 | 'for', 18 | 'while', 19 | 'do', 20 | 'switch', 21 | 'case', 22 | 'default', 23 | 'break', 24 | 'continue', 25 | 'new', 26 | 'delete', 27 | 'return', 28 | 'in', 29 | 'instanceof', 30 | 'typeof', 31 | 'void', 32 | 'yield', 33 | 'export', 34 | 'import', 35 | 'as', 36 | 'get', 37 | 'set', 38 | 'is', 39 | 'namespace', 40 | 'type', 41 | 'debugger', 42 | 'async', 43 | 'await', 44 | 'of', 45 | ]) 46 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/src/common.ts: -------------------------------------------------------------------------------- 1 | export const FACTORY_POSTFIX = '__factory' 2 | export const STRUCT_INPUT_POSTFIX = 'Struct' 3 | export const STRUCT_OUTPUT_POSTFIX = 'StructOutput' 4 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/test/typelevel-test.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import { AssertTrue, IsExact } from 'test-utils' 3 | 4 | import { TypedContractEvent, TypedEventLog, TypedListener } from '../static/common' 5 | 6 | export type TransferEvent = TypedContractEvent< 7 | [string, string, number], 8 | [string, string, number], 9 | { from: string; to: string; tokenId: number } 10 | > 11 | 12 | type _ = AssertTrue< 13 | IsExact< 14 | Parameters>, 15 | [string, string, number, TypedEventLog, ...undefined[]] 16 | > 17 | > 18 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src", 7 | "moduleResolution": "node16" 8 | }, 9 | "references": [ 10 | { 11 | "path": "../typechain/tsconfig.build.json" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/target-ethers-v6/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "static"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true, 7 | "moduleResolution": "node16" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-starknet-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-starknet-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-starknet-test/contracts/constructor.cairo: -------------------------------------------------------------------------------- 1 | %lang starknet 2 | 3 | from starkware.cairo.common.cairo_builtins import HashBuiltin 4 | 5 | struct Point: 6 | member x : felt 7 | member y : felt 8 | end 9 | 10 | struct PointPair: 11 | member p1 : Point 12 | member p2 : Point 13 | end 14 | 15 | @constructor 16 | func constructor{ 17 | syscall_ptr : felt*, 18 | pedersen_ptr : HashBuiltin*, 19 | range_check_ptr 20 | }( 21 | point: Point, 22 | pair: PointPair, 23 | pairs_len: felt, 24 | pairs: PointPair* 25 | ): 26 | return() 27 | end 28 | 29 | @external 30 | func xyz{ 31 | syscall_ptr : felt*, 32 | pedersen_ptr : HashBuiltin*, 33 | range_check_ptr 34 | }( 35 | point: Point, 36 | pair: PointPair, 37 | pairs_len: felt, 38 | pairs: PointPair* 39 | ): 40 | return() 41 | end 42 | 43 | -------------------------------------------------------------------------------- /packages/target-starknet-test/devnet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | cd "$(dirname "$0")" 4 | 5 | image=shardlabs/starknet-devnet:0.2.1 6 | 7 | if [ "$(uname)" == "Darwin" ]; then 8 | image="${image}-arm" 9 | fi 10 | 11 | docker rm -f devnet 12 | exec docker run --name devnet -p 127.0.0.1:5050:5050 ${image} -------------------------------------------------------------------------------- /packages/target-starknet-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-starknet-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true, 7 | "importsNotUsedAsValues": "error" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-starknet-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "lib": ["ES2018", "DOM"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-starknet-test/types/constructor.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { Contract } from "starknet"; 6 | import type { BigNumberish } from "starknet/utils/number"; 7 | import type BN from "bn.js"; 8 | 9 | export type Point = { x: BigNumberish; y: BigNumberish }; 10 | export type PointOutput = { x: BN; y: BN }; 11 | 12 | export type PointPair = { p1: Point; p2: Point }; 13 | export type PointPairOutput = { p1: PointOutput; p2: PointOutput }; 14 | 15 | export interface constructor extends Contract { 16 | functions: {}; 17 | callStatic: {}; 18 | populateTransaction: {}; 19 | estimateFee: {}; 20 | } 21 | -------------------------------------------------------------------------------- /packages/target-starknet-test/types/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { ArgentAccount } from "./ArgentAccount"; 5 | export type { constructor } from "./constructor"; 6 | export type { contract } from "./contract"; 7 | export type { ERC20 } from "./ERC20"; 8 | -------------------------------------------------------------------------------- /packages/target-starknet/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/target-starknet/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @typechain/starknet 2 | 3 | ## 0.2.9 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies [3469800] 8 | - typechain@8.3.2 9 | 10 | ## 0.2.8 11 | 12 | ### Patch Changes 13 | 14 | - Updated dependencies [9107713] 15 | - typechain@8.3.1 16 | 17 | ## 0.2.7 18 | 19 | ### Patch Changes 20 | 21 | - Updated dependencies [c4720b9] 22 | - typechain@8.3.0 23 | 24 | ## 0.2.6 25 | 26 | ### Patch Changes 27 | 28 | - Updated dependencies [cd4bb0f] 29 | - typechain@8.2.1 30 | 31 | ## 0.2.5 32 | 33 | ### Patch Changes 34 | 35 | - Updated dependencies [15541e4] 36 | - typechain@8.2.0 37 | 38 | ## 0.2.4 39 | 40 | ### Patch Changes 41 | 42 | - Updated dependencies [bbc9656] 43 | - typechain@8.1.1 44 | 45 | ## 0.2.3 46 | 47 | ### Patch Changes 48 | 49 | - 04c9378: Separate input and output types 50 | 51 | ## 0.2.1 52 | 53 | ### Patch Changes 54 | 55 | - Updated dependencies [63691c4] 56 | - typechain@8.1.0 57 | -------------------------------------------------------------------------------- /packages/target-starknet/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-starknet/README.md: -------------------------------------------------------------------------------- 1 | # Typechain target Starknet.js 2 | 3 |

4 | TypeChain 5 |

TypeChain target Starknet.js

6 |

🔌 TypeScript bindings for Starknet.js 3.x

7 | 8 |

9 | Build Status 10 | Downloads 11 | Prettier 12 | Software License 13 |

14 | 15 |

16 | Medium post | DappCon Video 17 |

18 |

19 | 20 | ## [TypeChain readme](https://github.com/ethereum-ts/TypeChain) 21 | -------------------------------------------------------------------------------- /packages/target-starknet/src/index.ts: -------------------------------------------------------------------------------- 1 | import { StarknetTarget } from './StarknetTarget' 2 | 3 | export default StarknetTarget 4 | -------------------------------------------------------------------------------- /packages/target-starknet/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "lib": ["es2020", "ESNext", "DOM"], 5 | "compilerOptions": { 6 | "outDir": "dist", 7 | "rootDir": "src", 8 | "skipLibCheck": true, 9 | "skipDefaultLibCheck": true 10 | }, 11 | "exclude": ["node_modules", "**/node_modules/*", "dist"], 12 | "references": [ 13 | { 14 | "path": "../typechain/tsconfig.build.json" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /packages/target-starknet/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "static"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dethcrypto/TypeChain/4c9773403a2aa66bf6f5fa066e8ef1b00769c71b/packages/target-truffle-v5-test/migrations/.gitkeep -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/test/NameMangling.test.ts: -------------------------------------------------------------------------------- 1 | const NameMangling = artifacts.require('NAME12mangling') 2 | 3 | contract('NameMangling', ([deployer]) => { 4 | it('works', async () => { 5 | const contract = await NameMangling.new({ from: deployer }) 6 | 7 | expect(await contract.works()).to.be.true 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/test/Overloads.test.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bn.js' 2 | import { typedAssert } from 'test-utils' 3 | 4 | import type { OverloadsInstance } from '../types/truffle-contracts/Overloads' 5 | 6 | const Overloads = artifacts.require('Overloads') 7 | 8 | contract('Overloads', ([deployer]) => { 9 | let c: OverloadsInstance 10 | 11 | beforeEach(async () => { 12 | c = await Overloads.new({ from: deployer }) 13 | }) 14 | 15 | it('works with 1st overload', async () => { 16 | const result = await c.methods['overload1(int256)'](1) 17 | typedAssert(result, new BigNumber('1')) 18 | }) 19 | 20 | it('works with 2n overload', async () => { 21 | const result = await c.methods['overload1(uint256,uint256)'](1, 2) 22 | typedAssert(result, new BigNumber('3')) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/truffle-config.js: -------------------------------------------------------------------------------- 1 | require('ts-node/register/transpile-only') 2 | 3 | module.exports = { 4 | test_file_extension_regexp: /.*\.ts$/, 5 | compilers: { 6 | solc: { 7 | version: '0.6.4', 8 | }, 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "types"], 4 | "compilerOptions": { 5 | "typeRoots": ["./node_modules/@types", "./types"], 6 | "types": ["node", "truffle-contracts"], 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "importsNotUsedAsValues": "error" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["types"], 4 | "exclude": ["node_modules"], 5 | "compilerOptions": { 6 | "esModuleInterop": true, 7 | "lib": ["ES2018", "DOM"], 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/types/truffle-contracts/A.d.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import BN from "bn.js"; 6 | import { EventData, PastEventOptions } from "web3-eth-contract"; 7 | 8 | export interface AContract extends Truffle.Contract { 9 | "new"(meta?: Truffle.TransactionDetails): Promise; 10 | } 11 | 12 | export interface Committed { 13 | name: "Committed"; 14 | args: { 15 | whitelist: string[]; 16 | 0: string[]; 17 | }; 18 | } 19 | 20 | type AllEvents = Committed; 21 | 22 | export interface AInstance extends Truffle.ContractInstance { 23 | methods: {}; 24 | 25 | getPastEvents(event: string): Promise; 26 | getPastEvents( 27 | event: string, 28 | options: PastEventOptions, 29 | callback: (error: Error, event: EventData) => void 30 | ): Promise; 31 | getPastEvents(event: string, options: PastEventOptions): Promise; 32 | getPastEvents( 33 | event: string, 34 | callback: (error: Error, event: EventData) => void 35 | ): Promise; 36 | } 37 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/types/truffle-contracts/Lib.d.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import BN from "bn.js"; 6 | import { EventData, PastEventOptions } from "web3-eth-contract"; 7 | 8 | export interface LibContract extends Truffle.Contract { 9 | "new"(meta?: Truffle.TransactionDetails): Promise; 10 | } 11 | 12 | type AllEvents = never; 13 | 14 | export interface LibInstance extends Truffle.ContractInstance { 15 | other( 16 | b: number | BN | string, 17 | txDetails?: Truffle.TransactionDetails 18 | ): Promise; 19 | 20 | methods: { 21 | other( 22 | b: number | BN | string, 23 | txDetails?: Truffle.TransactionDetails 24 | ): Promise; 25 | }; 26 | 27 | getPastEvents(event: string): Promise; 28 | getPastEvents( 29 | event: string, 30 | options: PastEventOptions, 31 | callback: (error: Error, event: EventData) => void 32 | ): Promise; 33 | getPastEvents(event: string, options: PastEventOptions): Promise; 34 | getPastEvents( 35 | event: string, 36 | callback: (error: Error, event: EventData) => void 37 | ): Promise; 38 | } 39 | -------------------------------------------------------------------------------- /packages/target-truffle-v5-test/types/truffle-contracts/LibraryConsumer.d.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import BN from "bn.js"; 6 | import { EventData, PastEventOptions } from "web3-eth-contract"; 7 | 8 | export interface LibraryConsumerContract 9 | extends Truffle.Contract { 10 | "new"(meta?: Truffle.TransactionDetails): Promise; 11 | } 12 | 13 | type AllEvents = never; 14 | 15 | export interface LibraryConsumerInstance extends Truffle.ContractInstance { 16 | someOther( 17 | b: number | BN | string, 18 | txDetails?: Truffle.TransactionDetails 19 | ): Promise; 20 | 21 | methods: { 22 | someOther( 23 | b: number | BN | string, 24 | txDetails?: Truffle.TransactionDetails 25 | ): Promise; 26 | }; 27 | 28 | getPastEvents(event: string): Promise; 29 | getPastEvents( 30 | event: string, 31 | options: PastEventOptions, 32 | callback: (error: Error, event: EventData) => void 33 | ): Promise; 34 | getPastEvents(event: string, options: PastEventOptions): Promise; 35 | getPastEvents( 36 | event: string, 37 | callback: (error: Error, event: EventData) => void 38 | ): Promise; 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/README.md: -------------------------------------------------------------------------------- 1 | # Typechain target Truffle-v5 2 | 3 |

4 | TypeChain 5 |

TypeChain target Truffle-v5

6 |

🔌 TypeScript bindings for Truffle 5.x.x smartcontracts

7 | 8 |

9 | Build Status 10 | Downloads 11 | Prettier 12 | Software License 13 |

14 | 15 |

16 | Medium post | DappCon Video 17 |

18 |

19 | 20 | ## [TypeChain readme](https://github.com/ethereum-ts/TypeChain) 21 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/src/codegen/headers.ts: -------------------------------------------------------------------------------- 1 | import { Contract } from 'typechain' 2 | 3 | export function codegenArtifactHeaders(contracts: Contract[]): string { 4 | return ` 5 | ${contracts.map((c) => `import {${c.name}Contract} from "./${c.name}";`).join('\n')} 6 | 7 | declare global { 8 | namespace Truffle { 9 | interface Artifacts { 10 | ${contracts.map((c) => `require(name: "${c.rawName}"): ${c.name}Contract;`).join('\n')} 11 | } 12 | } 13 | } 14 | 15 | ${contracts.map((c) => `export {${c.name}Contract, ${c.name}Instance} from "./${c.name}";`).join('\n')} 16 | ` 17 | } 18 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/src/codegen/index.ts: -------------------------------------------------------------------------------- 1 | export { codegenContract } from './contracts' 2 | export { codegenArtifactHeaders } from './headers' 3 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-truffle-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "static"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as v064 from './v0.6.4' 5 | export type { v064 } 6 | import type * as v089 from './v0.8.9' 7 | export type { v089 } 8 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@typechain/web3-v1-test", 3 | "private": true, 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "scripts": { 7 | "format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"", 8 | "format:fix": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --write \"./**/*.ts\"", 9 | "lint": "eslint --ext .ts test", 10 | "lint:fix": "pnpm lint --fix", 11 | "typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.types.json", 12 | "clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build", 13 | "generate-types": "node ../typechain/dist/cli/cli.js --target=../target-web3-v1/dist/index.js --out-dir ./types/ '../../contracts/compiled/**/*.abi'", 14 | "test": "pnpm generate-types && mocha --config ../../.mocharc.js", 15 | "test:fix": "pnpm lint:fix && pnpm format:fix && pnpm test && pnpm typecheck" 16 | }, 17 | "devDependencies": { 18 | "ganache": "^7.8.0", 19 | "test-utils": "1.0.0", 20 | "typechain": "workspace:^8.3.2", 21 | "web3": "^1.6.0", 22 | "web3-eth-contract": "^1.6.0", 23 | "web3-core": "^1", 24 | "@types/bn.js": "^4.11.6" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/test/Overload.test.ts: -------------------------------------------------------------------------------- 1 | import { typedAssert } from 'test-utils' 2 | 3 | import type { Overloads } from '../types/v0.6.4/Overloads' 4 | import { createNewBlockchain } from './common' 5 | 6 | describe('Overloads', () => { 7 | const chain = createNewBlockchain('Overloads') 8 | 9 | it('works with 1st overload', async () => { 10 | const result = await chain.contract.methods['overload1(int256)'](1).call() 11 | typedAssert(result, '1') 12 | }) 13 | 14 | it('works with 2n overload', async () => { 15 | const result = await chain.contract.methods['overload1(uint256,uint256)'](1, 2).call() 16 | typedAssert(result, '3') 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/test/Payable.test.ts: -------------------------------------------------------------------------------- 1 | import { typeCase, typedAssert } from 'test-utils' 2 | 3 | import type { Payable } from '../types/v0.6.4/Payable' 4 | import { createNewBlockchain } from './common' 5 | 6 | describe('Payable', () => { 7 | const chain = createNewBlockchain('Payable') 8 | 9 | it('allows to specify value when expected', async () => { 10 | const { contract, accounts } = chain 11 | const result = await contract.methods.payable_func().send({ value: 1, from: accounts[0] }) 12 | typedAssert(result.transactionIndex, 0) 13 | }) 14 | 15 | it( 16 | '[TYPE ONLY] disallows to specify value when expected', 17 | typeCase(async () => { 18 | const { contract, accounts } = chain 19 | 20 | await contract.methods.non_payable_func().send({ 21 | // @ts-expect-error: value shouldn't be here 22 | value: 1, 23 | from: accounts[0], 24 | }) 25 | }), 26 | ) 27 | }) 28 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "types"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true, 7 | "importsNotUsedAsValues": "error" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["types"], 4 | "exclude": ["node_modules"], 5 | "compilerOptions": { 6 | "esModuleInterop": true, 7 | "lib": ["ES2018", "DOM"], 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as v064 from "./v0.6.4"; 5 | export type { v064 }; 6 | import type * as v089 from "./v0.8.9"; 7 | export type { v089 }; 8 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Issue428_Reproduction/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { A } from "./A"; 5 | export type { B } from "./B"; 6 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Library/Lib.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface Lib extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): Lib; 30 | clone(): Lib; 31 | methods: { 32 | other(b: number | string | BN): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Library/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Lib } from "./Lib"; 5 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/LibraryConsumer.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface LibraryConsumer extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): LibraryConsumer; 30 | clone(): LibraryConsumer; 31 | methods: { 32 | someOther(b: number | string | BN): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Name-Mangling/NAME12mangling.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface NAME12mangling extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): NAME12mangling; 30 | clone(): NAME12mangling; 31 | methods: { 32 | provider(): NonPayableTransactionObject; 33 | 34 | works(): NonPayableTransactionObject; 35 | }; 36 | events: { 37 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Name-Mangling/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NAME12mangling } from "./NAME12mangling"; 5 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Overloads.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface Overloads extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): Overloads; 30 | clone(): Overloads; 31 | methods: { 32 | "overload1(int256)"( 33 | input1: number | string | BN 34 | ): NonPayableTransactionObject; 35 | 36 | "overload1(uint256,uint256)"( 37 | input1: number | string | BN, 38 | input2: number | string | BN 39 | ): NonPayableTransactionObject; 40 | }; 41 | events: { 42 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Payable/Payable.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface Payable extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): Payable; 30 | clone(): Payable; 31 | methods: { 32 | non_payable_func(): NonPayableTransactionObject; 33 | 34 | payable_func(): PayableTransactionObject; 35 | }; 36 | events: { 37 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Payable/PayableFactory.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface PayableFactory extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): PayableFactory; 30 | clone(): PayableFactory; 31 | methods: { 32 | newPayable(): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/Payable/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { Payable } from "./Payable"; 5 | export type { PayableFactory } from "./PayableFactory"; 6 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.6.4/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as issue428Reproduction from "./Issue428_Reproduction"; 5 | export type { issue428Reproduction }; 6 | import type * as library from "./Library"; 7 | export type { library }; 8 | import type * as nameMangling from "./Name-Mangling"; 9 | export type { nameMangling }; 10 | import type * as payable from "./Payable"; 11 | export type { payable }; 12 | export type { DataTypesInput } from "./DataTypesInput"; 13 | export type { DataTypesPure } from "./DataTypesPure"; 14 | export type { DataTypesView } from "./DataTypesView"; 15 | export type { Events } from "./Events"; 16 | export type { LibraryConsumer } from "./LibraryConsumer"; 17 | export type { Overloads } from "./Overloads"; 18 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/ISimpleToken.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface ISimpleToken extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): ISimpleToken; 30 | clone(): ISimpleToken; 31 | methods: { 32 | transfer( 33 | from: string, 34 | value: number | string | BN 35 | ): NonPayableTransactionObject; 36 | }; 37 | events: { 38 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/KingOfTheHill/Withdrawable.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface Withdrawable extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): Withdrawable; 30 | clone(): Withdrawable; 31 | methods: { 32 | withdraw(): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/KingOfTheHill/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { KingOfTheHill } from "./KingOfTheHill"; 5 | export type { Withdrawable } from "./Withdrawable"; 6 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/Rarity/IERC721Receiver.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface IERC721Receiver extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): IERC721Receiver; 30 | clone(): IERC721Receiver; 31 | methods: { 32 | onERC721Received( 33 | operator: string, 34 | from: string, 35 | tokenId: number | string | BN, 36 | data: string | number[] 37 | ): NonPayableTransactionObject; 38 | }; 39 | events: { 40 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/Rarity/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { ERC721 } from "./ERC721"; 5 | export type { ERC721Enumerable } from "./ERC721Enumerable"; 6 | export type { IERC721 } from "./IERC721"; 7 | export type { IERC721Enumerable } from "./IERC721Enumerable"; 8 | export type { IERC721Receiver } from "./IERC721Receiver"; 9 | export type { Rarity } from "./Rarity"; 10 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/SimpleToken.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface SimpleToken extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): SimpleToken; 30 | clone(): SimpleToken; 31 | methods: { 32 | transfer( 33 | from: string, 34 | value: number | string | BN 35 | ): NonPayableTransactionObject; 36 | }; 37 | events: { 38 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as kingOfTheHill from "./KingOfTheHill"; 5 | export type { kingOfTheHill }; 6 | import type * as rarity from "./Rarity"; 7 | export type { rarity }; 8 | import type * as nested from "./nested"; 9 | export type { nested }; 10 | export type { ISimpleToken } from "./ISimpleToken"; 11 | export type { Issue552_Reproduction } from "./Issue552_Reproduction"; 12 | export type { SimpleToken } from "./SimpleToken"; 13 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/nested/a/NestedLibrary.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface NestedLibrary extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): NestedLibrary; 30 | clone(): NestedLibrary; 31 | methods: { 32 | getValue(): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/nested/a/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/nested/b/NestedLibrary.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type BN from "bn.js"; 6 | import type { ContractOptions } from "web3-eth-contract"; 7 | import type { EventLog } from "web3-core"; 8 | import type { EventEmitter } from "events"; 9 | import type { 10 | Callback, 11 | PayableTransactionObject, 12 | NonPayableTransactionObject, 13 | BlockType, 14 | ContractEventLog, 15 | BaseContract, 16 | } from "../../../types"; 17 | 18 | export interface EventOptions { 19 | filter?: object; 20 | fromBlock?: BlockType; 21 | topics?: string[]; 22 | } 23 | 24 | export interface NestedLibrary extends BaseContract { 25 | constructor( 26 | jsonInterface: any[], 27 | address?: string, 28 | options?: ContractOptions 29 | ): NestedLibrary; 30 | clone(): NestedLibrary; 31 | methods: { 32 | getValue(): NonPayableTransactionObject; 33 | }; 34 | events: { 35 | allEvents(options?: EventOptions, cb?: Callback): EventEmitter; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/nested/b/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | export type { NestedLibrary } from "./NestedLibrary"; 5 | -------------------------------------------------------------------------------- /packages/target-web3-v1-test/types/v0.8.9/nested/index.ts: -------------------------------------------------------------------------------- 1 | /* Autogenerated file. Do not edit manually. */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type * as a from "./a"; 5 | export type { a }; 6 | import type * as b from "./b"; 7 | export type { b }; 8 | -------------------------------------------------------------------------------- /packages/target-web3-v1/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/target-web3-v1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/target-web3-v1/README.md: -------------------------------------------------------------------------------- 1 | # Typechain target Web3-v1 2 | 3 |

4 | TypeChain 5 |

TypeChain target Web3-v1

6 |

🔌 TypeScript bindings for Web3 1.x.x smartcontracts

7 | 8 |

9 | Build Status 10 | Downloads 11 | Prettier 12 | Software License 13 |

14 | 15 |

16 | Medium post | DappCon Video 17 |

18 |

19 | 20 | ## [TypeChain readme](https://github.com/ethereum-ts/TypeChain) 21 | -------------------------------------------------------------------------------- /packages/target-web3-v1/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/target-web3-v1/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test", "static"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/test-e2e/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../.eslintrc.js') 2 | -------------------------------------------------------------------------------- /packages/test-e2e/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-e2e", 3 | "private": true, 4 | "version": "9.9.19", 5 | "scripts": { 6 | "format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"", 7 | "format:fix": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --write \"./**/*.ts\"", 8 | "lint": "eslint --ext .ts test", 9 | "lint:fix": "pnpm lint --fix", 10 | "typecheck": "tsc --noEmit --incremental false --composite false && tsc --noEmit --incremental false --composite false -p tsconfig.json", 11 | "clean": "rm -rf dist contracts/* && rm -f tsconfig.build.tsbuildinfo && rm -rf build", 12 | "test": "mocha --config ../../.mocharc.js", 13 | "test:fix": "pnpm lint:fix && pnpm format:fix && pnpm test && pnpm typecheck" 14 | }, 15 | "dependencies": { 16 | "fs-extra": "^9.1.0", 17 | "@types/fs-extra": "^9.0.7", 18 | "typechain": "workspace:^8.3.2", 19 | "@typechain/ethers-v5": "workspace:^11.1.2" 20 | }, 21 | "devDependencies": { 22 | "mocha": "^8.2.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/test-e2e/test/ts-nocheck/ts-nocheck.abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [{ "internalType": "uint256", "name": "x", "type": "uint256" }], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/test-e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test"], 4 | "compilerOptions": { 5 | "noImplicitOverride": true, 6 | // workaround for @types/superagent/index.d.ts(31,29): error TS2304: Cannot find name 'Blob'. 7 | "skipLibCheck": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/test-utils/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | rules: { 6 | ...baseConfig.rules, 7 | 'import/no-extraneous-dependencies': 'off', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/test-utils/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/test-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-utils", 3 | "private": true, 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "main": "./dist/index.js", 7 | "module": "./dist/index.js", 8 | "types": "./dist/index.d.ts", 9 | "scripts": { 10 | "format": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --check \"./**/*.ts\"", 11 | "format:fix": "prettier --config ../../.prettierrc --ignore-path ../../.prettierignore --write \"./**/*.ts\"", 12 | "lint": "eslint --ext .ts src", 13 | "lint:fix": "pnpm lint --fix", 14 | "typecheck": "tsc --noEmit --incremental false --composite false", 15 | "clean": "rm -rf dist && rm -f tsconfig.build.tsbuildinfo", 16 | "true": "echo ok", 17 | "test:fix": "pnpm lint:fix && pnpm format:fix && pnpm test && pnpm typecheck" 18 | }, 19 | "dependencies": { 20 | "@types/glob": "7", 21 | "@types/lodash": "^4.14.139", 22 | "@types/retry-as-promised": "^2.3.3", 23 | "bignumber.js": "9.0.1", 24 | "conditional-type-checks": "^1.0.5", 25 | "glob": "7.1.7", 26 | "lodash": "^4.17.15", 27 | "retry-as-promised": "^5.0.0", 28 | "ts-essentials": "^7.0.1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/test-utils/src/contract.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from 'fs' 2 | import { sync as globSync } from 'glob' 3 | import { join } from 'path' 4 | 5 | const abiDirPath = join(__dirname, '../../../contracts/compiled') 6 | 7 | export function loadContract(contractName: string): { code: string; abi: any } { 8 | const abiPaths = globSync(`${abiDirPath}/**/${contractName}.abi`) 9 | if (abiPaths.length === 0) { 10 | throw new Error(`ABI for ${contractName} not found in ${abiDirPath}`) 11 | } else if (abiPaths.length > 1) { 12 | throw new Error(`Multiple ABIs for ${contractName} found in ${abiDirPath}`) 13 | } 14 | 15 | const [abiPath] = abiPaths 16 | const abi = JSON.parse(readFileSync(abiPath, 'utf-8')) 17 | const bin = readFileSync(abiPath.replace(/\.abi$/, '.bin'), 'utf-8') 18 | const code = '0x' + bin 19 | 20 | return { code, abi } 21 | } 22 | -------------------------------------------------------------------------------- /packages/test-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './contract' 2 | export * from './test' 3 | export * from 'conditional-type-checks' 4 | export { default as retry } from 'retry-as-promised' 5 | -------------------------------------------------------------------------------- /packages/test-utils/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/test-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/typechain/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('../../.eslintrc.js') 2 | 3 | module.exports = { 4 | ...baseConfig, 5 | } 6 | -------------------------------------------------------------------------------- /packages/typechain/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Krzysztof Kaczor 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /packages/typechain/scripts/post-build.ts: -------------------------------------------------------------------------------- 1 | import { chmodSync, copyFileSync } from 'fs' 2 | import { resolve } from 'path' 3 | 4 | const packageDir = resolve(__dirname, '..') 5 | const distDir = resolve(packageDir, 'dist') 6 | const rootDir = resolve(packageDir, '..', '..') 7 | 8 | chmodSync(resolve(distDir, 'cli/cli.js'), 0o755) 9 | copyFileSync(resolve(rootDir, 'README.md'), resolve(packageDir, 'README.md')) 10 | -------------------------------------------------------------------------------- /packages/typechain/src/codegen/normalizeDirName.ts: -------------------------------------------------------------------------------- 1 | import { camelCase } from 'lodash' 2 | 3 | /** 4 | * Converts valid directory name to valid variable name. Example: 0directory-name becomes _0DirectoryName 5 | */ 6 | export function normalizeDirName(rawName: string): string { 7 | const transformations: ((s: string) => string)[] = [ 8 | (s) => camelCase(s), // convert to camelCase 9 | (s) => s.replace(/^\d/g, (match) => '_' + match), // prepend '_' if contains a leading number 10 | ] 11 | 12 | return transformations.reduce((s, t) => t(s), rawName) 13 | } 14 | -------------------------------------------------------------------------------- /packages/typechain/src/codegen/outputTransformers/index.ts: -------------------------------------------------------------------------------- 1 | import { Config, Services } from '../../typechain/types' 2 | import { addPreambleOutputTransformer } from './preamble' 3 | import { prettierOutputTransformer } from './prettier' 4 | 5 | export type OutputTransformer = (output: string, services: Services, cfg: Config) => string 6 | 7 | export const outputTransformers = [addPreambleOutputTransformer, prettierOutputTransformer] 8 | -------------------------------------------------------------------------------- /packages/typechain/src/codegen/outputTransformers/preamble.ts: -------------------------------------------------------------------------------- 1 | import { OutputTransformer } from '.' 2 | 3 | export const addPreambleOutputTransformer: OutputTransformer = (output, _services, cfg) => { 4 | return [ 5 | '/* Autogenerated file. Do not edit manually. */', 6 | cfg.flags.tsNocheck && '// @ts-nocheck', 7 | '/* tslint:disable */', 8 | '/* eslint-disable */', 9 | output, 10 | ] 11 | .filter(Boolean) 12 | .join('\n') 13 | } 14 | -------------------------------------------------------------------------------- /packages/typechain/src/codegen/outputTransformers/prettier.ts: -------------------------------------------------------------------------------- 1 | import { Options as PrettierOptions } from 'prettier' 2 | 3 | import { OutputTransformer } from '.' 4 | 5 | export const prettierOutputTransformer: OutputTransformer = (output, { prettier }, config) => { 6 | const prettierCfg: PrettierOptions = { ...(config.prettier || {}), parser: 'typescript' } 7 | 8 | return prettier.format(output, prettierCfg) 9 | } 10 | -------------------------------------------------------------------------------- /packages/typechain/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './codegen/createBarrelFiles' 2 | export * from './codegen/syntax' 3 | export * from './parser/abiParser' 4 | export { normalizeName } from './parser/normalizeName' 5 | export * from './parser/parseEvmType' 6 | export * from './typechain/runTypeChain' 7 | export * from './typechain/types' 8 | export * from './utils/files' 9 | export * from './utils/glob' 10 | export * from './utils/signatures' 11 | -------------------------------------------------------------------------------- /packages/typechain/src/parser/normalizeName.ts: -------------------------------------------------------------------------------- 1 | import { upperFirst } from 'lodash' 2 | 3 | /** 4 | * Converts valid file names to valid javascript symbols and does best effort to make them readable. Example: ds-token.test becomes DsTokenTest 5 | */ 6 | export function normalizeName(rawName: string): string { 7 | const transformations: ((s: string) => string)[] = [ 8 | (s) => s.replace(/\s+/g, '-'), // spaces to - so later we can automatically convert them 9 | (s) => s.replace(/\./g, '-'), // replace "." 10 | (s) => s.replace(/-[a-z]/g, (match) => match.substr(-1).toUpperCase()), // delete '-' and capitalize the letter after them 11 | (s) => s.replace(/-/g, ''), // delete any '-' left 12 | (s) => s.replace(/^\d+/, ''), // removes leading digits 13 | (s) => upperFirst(s), 14 | ] 15 | 16 | const finalName = transformations.reduce((s, t) => t(s), rawName) 17 | 18 | if (finalName === '') { 19 | throw new Error(`Can't guess class name, please rename file: ${rawName}`) 20 | } 21 | 22 | return finalName 23 | } 24 | -------------------------------------------------------------------------------- /packages/typechain/src/typechain/findTarget.ts: -------------------------------------------------------------------------------- 1 | import _, { compact } from 'lodash' 2 | 3 | import { debug } from '../utils/debug' 4 | import { ensureAbsPath } from '../utils/files/ensureAbsPath' 5 | import { tryRequire } from '../utils/modules' 6 | import { Config, TypeChainTarget } from './types' 7 | 8 | export function findTarget(config: Config): TypeChainTarget { 9 | const target = config.target 10 | if (!target) { 11 | throw new Error(`Please provide --target parameter!`) 12 | } 13 | 14 | const possiblePaths = [ 15 | `@typechain/${target}`, // external module 16 | `typechain-target-${target}`, // external module 17 | ensureAbsPath(target), // path 18 | ] 19 | 20 | const moduleInfo = _(possiblePaths).compact().map(tryRequire).compact().first() 21 | 22 | if (!moduleInfo || !moduleInfo.module.default) { 23 | throw new Error( 24 | `Couldn't find ${config.target}. Tried loading: ${compact(possiblePaths).join( 25 | ', ', 26 | )}.\nPerhaps you forgot to install @typechain/${target}?`, 27 | ) 28 | } 29 | 30 | debug('Plugin found at', moduleInfo.path) 31 | 32 | return new moduleInfo.module.default(config) 33 | } 34 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/debug.ts: -------------------------------------------------------------------------------- 1 | import debugLib from 'debug' 2 | 3 | export const debug = debugLib('typechain') 4 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/errors.ts: -------------------------------------------------------------------------------- 1 | export class MalformedAbiError extends Error {} 2 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/detectInputsRoot.ts: -------------------------------------------------------------------------------- 1 | import { dirname } from 'path' 2 | 3 | import { lowestCommonPath } from './lowestCommonPath' 4 | import { shortenFullJsonFilePath } from './shortenFullJsonFilePath' 5 | 6 | export function detectInputsRoot(allFiles: string[]): string { 7 | return allFiles.length === 1 ? dirname(shortenFullJsonFilePath(allFiles[0], allFiles)) : lowestCommonPath(allFiles) 8 | } 9 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/ensureAbsPath.ts: -------------------------------------------------------------------------------- 1 | import { isAbsolute, join } from 'path' 2 | 3 | export function ensureAbsPath(path: string): string { 4 | if (isAbsolute(path)) { 5 | return path 6 | } 7 | return join(process.cwd(), path) 8 | } 9 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/getFileExtension.ts: -------------------------------------------------------------------------------- 1 | import { parse } from 'path' 2 | 3 | export function getFileExtension(path: string) { 4 | return parse(path).ext 5 | } 6 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/getFilename.ts: -------------------------------------------------------------------------------- 1 | import { parse } from 'path' 2 | 3 | export function getFilename(path: string) { 4 | return parse(path).name 5 | } 6 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/index.ts: -------------------------------------------------------------------------------- 1 | export * from './detectInputsRoot' 2 | export * from './ensureAbsPath' 3 | export * from './getFileExtension' 4 | export * from './getFilename' 5 | export * from './lowestCommonPath' 6 | export * from './normalizeSlashes' 7 | export * from './shortenFullJsonFilePath' 8 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/lowestCommonPath.ts: -------------------------------------------------------------------------------- 1 | export function lowestCommonPath(paths: string[]) { 2 | const pathParts = paths.map((path) => path.split(/[\\/]/)) 3 | const commonParts = [] as string[] 4 | const maxParts = Math.min.apply( 5 | null, 6 | pathParts.map((p) => p.length), 7 | ) 8 | for (let i = 0; i < maxParts; i++) { 9 | const part = pathParts[0][i] 10 | if (pathParts.slice(1).every((otherPath) => otherPath[i] === part)) { 11 | commonParts.push(part) 12 | } else { 13 | break 14 | } 15 | } 16 | return commonParts.join('/') 17 | } 18 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/normalizeSlashes.ts: -------------------------------------------------------------------------------- 1 | export function normalizeSlashes(path: string) { 2 | return process.platform === 'win32' ? path.replace(/\\/g, '/') : path 3 | } 4 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/files/shortenFullJsonFilePath.ts: -------------------------------------------------------------------------------- 1 | import { posix } from 'path' 2 | 3 | /** 4 | * Transforms all paths matching `ContractName(\.sol)?/ContractName.ext` 5 | */ 6 | export function shortenFullJsonFilePath(path: string, allPaths: string[]) { 7 | const { name, dir, base } = posix.parse(path) 8 | 9 | if (allPaths.filter((p) => p.startsWith(dir + '/')).length > 1) { 10 | return path 11 | } 12 | 13 | if (dir.endsWith(`/${name}.sol`) || dir.endsWith(`/${name}`)) { 14 | return dir.split('/').slice(0, -1).join('/') + '/' + base 15 | } 16 | 17 | return path 18 | } 19 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/glob.ts: -------------------------------------------------------------------------------- 1 | import { sync as globSync } from 'glob' 2 | import { flatten, uniq } from 'lodash' 3 | 4 | export function glob(cwd: string, patternsOrFiles: string[], ignoreNodeModules: boolean = true): string[] { 5 | const matches = patternsOrFiles.map((p) => 6 | globSync(p, ignoreNodeModules ? { ignore: 'node_modules/**', absolute: true, cwd } : { absolute: true, cwd }), 7 | ) 8 | 9 | return uniq(flatten(matches)) 10 | } 11 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | export class Logger { 2 | log(...args: any[]) { 3 | if (!(global as any).IS_CLI) { 4 | return 5 | } 6 | 7 | // eslint-disable-next-line no-console 8 | console.log(...args) 9 | } 10 | warn(...args: any[]) { 11 | if (!(global as any).IS_CLI) { 12 | return 13 | } 14 | // eslint-disable-next-line no-console 15 | console.warn(...args) 16 | } 17 | 18 | error(...args: any[]) { 19 | if (!(global as any).IS_CLI) { 20 | return 21 | } 22 | // eslint-disable-next-line no-console 23 | console.error(...args) 24 | } 25 | } 26 | 27 | export const logger = new Logger() 28 | -------------------------------------------------------------------------------- /packages/typechain/src/utils/modules.ts: -------------------------------------------------------------------------------- 1 | import { debug } from './debug' 2 | 3 | export function tryRequire(name: string): { module: any; name: string; path: string } | undefined { 4 | try { 5 | let path: string 6 | try { 7 | path = require.resolve(name, { paths: [process.cwd()] }) 8 | } catch { 9 | path = require.resolve(name) 10 | } 11 | 12 | const module = { module: require(path), name, path } 13 | debug('Load successfully: ', name) 14 | return module 15 | } catch (err) { 16 | if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) { 17 | // this error is expected 18 | } else { 19 | throw err 20 | } 21 | debug("Couldn't load: ", name) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/typechain/test/codegen/normalizeDirName.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'earljs' 2 | 3 | import { normalizeDirName } from '../../src/codegen/normalizeDirName' 4 | 5 | describe('dir name normalizer', () => { 6 | it('should work', () => { 7 | expect(normalizeDirName('dirname')).toEqual('dirname') 8 | expect(normalizeDirName('dir_name')).toEqual('dirName') 9 | expect(normalizeDirName('0.4.24')).toEqual('_0424') 10 | expect(normalizeDirName('0-4-24')).toEqual('_0424') 11 | expect(normalizeDirName('0424')).toEqual('_0424') 12 | expect(normalizeDirName('0dir-name.1')).toEqual('_0DirName1') 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/typechain/test/codegen/syntax.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'earljs' 2 | 3 | import { createImportsForUsedIdentifiers } from '../../src' 4 | 5 | describe(createImportsForUsedIdentifiers.name, () => { 6 | it('works', () => { 7 | expect( 8 | createImportsForUsedIdentifiers( 9 | { 10 | 'my-module': ['A', 'B', 'C'], 11 | 'other-module': ['D', 'E', 'F'], 12 | }, 13 | ` 14 | const a = new A(B.property); 15 | class Eeek extends E { 16 | constructor(private readonly f: F) { 17 | } 18 | } 19 | `, 20 | ).trim(), 21 | ).toEqual( 22 | ` 23 | import { A, B } from "my-module" 24 | import { E, F } from "other-module" 25 | `.trim(), 26 | ) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /packages/typechain/test/parser/normalizeName.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'earljs' 2 | 3 | import { normalizeName } from '../../src/parser/normalizeName' 4 | 5 | describe('name normalizer', () => { 6 | it('should work', () => { 7 | expect(normalizeName('DsToken')).toEqual('DsToken') 8 | expect(normalizeName('test')).toEqual('Test') 9 | expect(normalizeName('ds-token')).toEqual('DsToken') 10 | expect(normalizeName('ds_token')).toEqual('Ds_token') 11 | expect(normalizeName('ds token')).toEqual('DsToken') 12 | expect(normalizeName('name.abi')).toEqual('NameAbi') 13 | expect(normalizeName('1234name.abi')).toEqual('NameAbi') 14 | expect(normalizeName('ERC20.abi')).toEqual('ERC20Abi') 15 | expect(normalizeName('a')).toEqual('A') 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/typechain/test/utils/files/shortenFullJsonFilePath.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'earljs' 2 | 3 | import { shortenFullJsonFilePath } from '../../../src' 4 | 5 | describe(shortenFullJsonFilePath.name, () => { 6 | it('shortens X.sol/X.json', () => { 7 | expect(shortenFullJsonFilePath('/A/B/C/X.sol/X.json', [])).toEqual('/A/B/C/X.json') 8 | }) 9 | 10 | it('shortens X/X.abi', () => { 11 | expect(shortenFullJsonFilePath('/A/B/C/X/X.abi', [])).toEqual('/A/B/C/X.abi') 12 | }) 13 | 14 | it('does not shorten when there is more than one file in a directory', () => { 15 | const paths = ['/A/B/C/X/X.abi', '/A/B/C/X/Y.abi'] 16 | 17 | expect(shortenFullJsonFilePath(paths[0], paths)).toEqual('/A/B/C/X/X.abi') 18 | }) 19 | 20 | it('shortens even when directory has common prefix', () => { 21 | const paths = ['/A/X/X.abi', '/A/XY/Y.abi'] 22 | 23 | expect(shortenFullJsonFilePath(paths[0], paths)).toEqual('/A/X.abi') 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/typechain/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "rootDir": "src" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/typechain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src", "test"], 4 | "compilerOptions": { 5 | "esModuleInterop": true, 6 | "skipLibCheck": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/**' 3 | - 'examples/**' 4 | # exclude packages that are inside test directories 5 | - '!**/test/**' 6 | -------------------------------------------------------------------------------- /scripts/_common.ts: -------------------------------------------------------------------------------- 1 | const colored = (escapeCode: string) => (text: string | number) => `\x1b[${escapeCode}m${text}\x1b[0m` 2 | 3 | export const red = colored('31;4') 4 | export const bold = colored('1') 5 | export const brightItalic = colored('3;90') 6 | -------------------------------------------------------------------------------- /scripts/no-git-changes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | cd "$(dirname "$0")" 4 | 5 | if [[ `git status --porcelain` ]]; then 6 | echo "GIT changes detected! Run pnpm test:fix and commit and changes (especially in test fixtures)." 7 | 8 | git status --verbose --verbose 9 | 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "lib": ["ES2018", "ES2019.Array", "ES2019.Object"], 5 | "module": "CommonJS", 6 | "moduleResolution": "node", 7 | "strict": true, 8 | "target": "ES2018", 9 | "sourceMap": true, 10 | "composite": true, 11 | "incremental": true, 12 | "exactOptionalPropertyTypes": true, 13 | "noImplicitOverride": true 14 | }, 15 | "include": ["**/*.ts", "**/*.js", "**/.*.js", "scripts/.common.ts"], 16 | "exclude": ["**/node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "lib": ["ES2018"], 5 | "module": "CommonJS", 6 | "moduleResolution": "node", 7 | "strict": true, 8 | "target": "ES2018", 9 | "sourceMap": true, 10 | "composite": true, 11 | "incremental": true, 12 | "stripInternal": true 13 | }, 14 | "files": [], 15 | "references": [ 16 | { "path": "./packages/typechain/tsconfig.build.json" }, 17 | { "path": "./packages/test-utils/tsconfig.build.json" }, 18 | { "path": "./packages/target-web3-v1/tsconfig.build.json" }, 19 | { "path": "./packages/target-truffle-v5/tsconfig.build.json" }, 20 | { "path": "./packages/target-ethers-v5/tsconfig.build.json" }, 21 | { "path": "./packages/target-ethers-v6/tsconfig.build.json" }, 22 | { "path": "./packages/hardhat/tsconfig.build.json" }, 23 | { "path": "./packages/target-starknet/tsconfig.build.json" } 24 | ] 25 | } 26 | --------------------------------------------------------------------------------