smart-order-router icon indicating copy to clipboard operation
smart-order-router copied to clipboard

Cannot find module '../types/v3/factories/IERC20Metadata__factory' or its corresponding type declarations.

Open smartblockdev opened this issue 3 years ago • 7 comments

  • I'm submitting a bug report

  • **

  • src/providers/token-provider.ts:4:41 - error TS2307: Cannot find module '../types/v3/factories/IERC20Metadata__factory' or its corresponding type declarations.

  • 4 import { IERC20Metadata__factory } from '../types/v3/factories/IERC20Metadata__factory';

  • **

smartblockdev avatar Aug 02 '22 04:08 smartblockdev

Have you run npm install && npm run build before compiling?

zhongeric avatar Aug 02 '22 15:08 zhongeric

Have you run npm install && npm run build before compiling?

$ yarn build
yarn run v1.22.17
warning package.json: License should be a valid SPDX license expression
$ run-p compile-v3-types compile-v2-types compile-router compile-external-types && run-p build:*
warning package.json: License should be a valid SPDX license expression
warning package.json: License should be a valid SPDX license expression
warning package.json: License should be a valid SPDX license expression
warning package.json: License should be a valid SPDX license expression
$ npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/*UniswapV2*.json'
$ npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'
$ npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'
$ npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'
Successfully generated 10 typings!
Successfully generated 44 typings!
Successfully generated 31 typings!
Successfully generated 88 typings!
warning package.json: License should be a valid SPDX license expression
warning package.json: License should be a valid SPDX license expression
$ tsc -p tsconfig.module.json
$ tsc -p tsconfig.json
src/routers/alpha-router/gas-models/gas-model.ts:160:21 - error TS2842: 'V3poolProvider' is an unused renaming of 'v3poolProvider'. Did you intend to use it as a type annotation?

160     v3poolProvider: V3poolProvider,
                        ~~~~~~~~~~~~~~

src/routers/alpha-router/gas-models/gas-model.ts:162:21 - error TS2842: 'V2poolProvider' is an unused renaming of 'v2poolProvider'. Did you intend to use it as a type annotation?

162     v2poolProvider: V2poolProvider,
                        ~~~~~~~~~~~~~~


Found 2 errors in the same file, starting at: src/routers/alpha-router/gas-models/gas-model.ts:160

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "build:module" exited with 2.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I ran yarn build and had this issue. After I deleted : V2poolProvider and : V3poolProvider in src/routers/alpha-router/gas-models/gas-model.ts, the build passed.

  • Ubuntu 22.04
  • node v18.2.0

zed-wong avatar Sep 02 '22 01:09 zed-wong

don't use yarn use npm instead and it should work, dependencies are frozen using package-lock.json and if you use yarn it will just ignore package-lock.json

ss-sonic avatar Oct 06 '22 13:10 ss-sonic

I'm facing the same problem, and i'm using npm. This is the part of output when i run npm run build:

> @uniswap/[email protected] build:module
> tsc -p tsconfig.module.json


> @uniswap/[email protected] build:main
> tsc -p tsconfig.json

src/providers/multicall-uniswap-provider.ts:6:52 - error TS2307: Cannot find module '../types/v3/factories/UniswapInterfaceMulticall__factory' or its corresponding type declarations.

6 import { UniswapInterfaceMulticall__factory } from '../types/v3/factories/UniswapInterfaceMulticall__factory';
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/providers/multicall-uniswap-provider.ts:7:43 - error TS2307: Cannot find module '../types/v3/UniswapInterfaceMulticall' or its corresponding type declarations.

7 import { UniswapInterfaceMulticall } from '../types/v3/UniswapInterfaceMulticall';

The OS i'm using is Windows 10, accroding to this issue i changd these line in package.json from this:

"compile-v3-types": "npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'",
"compile-v2-types": "npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/*UniswapV2*.json'",

to this:

"compile-v3-types": "npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/v3-core/artifacts/contracts/**/*.json' './node_modules/@uniswap/v3-periphery/artifacts/contracts/**/*.json'",
"compile-v2-types": "npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/v2-core/build/*UniswapV2*.json' './node_modules/@uniswap/v2-periphery/build/*UniswapV2*.json'",

Can someone help me fix this?

VetchM avatar Jan 09 '23 02:01 VetchM

try using ubuntu

ln2-muyuan avatar Jan 09 '23 03:01 ln2-muyuan

Using Ubuntu here and this is what happened:

$ npm install && npm run build

up to date, audited 1012 packages in 2s

197 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (5 moderate, 3 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

> @uniswap/[email protected] build
> run-p compile-v3-types compile-v2-types compile-router compile-narwhal compile-external-types && run-p build:*


> @uniswap/[email protected] compile-v3-types
> npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-narwhal
> npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/narwhal/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-v2-types
> npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/*UniswapV2*.json'


> @uniswap/[email protected] compile-router
> npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-external-types
> npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'

Successfully generated 2 typings!
Successfully generated 12 typings!
Successfully generated 44 typings!
Successfully generated 31 typings!
Successfully generated 88 typings!

> @uniswap/[email protected] build:main
> tsc -p tsconfig.json


> @uniswap/[email protected] build:module
> tsc -p tsconfig.module.json

node_modules/@types/node/globals.d.ts:347:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'.

347 declare var AbortSignal: {
                ~~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:2071:13
    2071 declare var AbortSignal: {
                     ~~~~~~~~~~~
    'AbortSignal' was also declared here.

src/routers/alpha-router/gas-models/gas-model.ts:175:21 - error TS2842: 'V3poolProvider' is an unused renaming of 'v3poolProvider'. Did you intend to use it as a type annotation?

175     v3poolProvider: V3poolProvider,
                        ~~~~~~~~~~~~~~

src/routers/alpha-router/gas-models/gas-model.ts:178:21 - error TS2842: 'V2poolProvider' is an unused renaming of 'v2poolProvider'. Did you intend to use it as a type annotation?

178     v2poolProvider: V2poolProvider,
                        ~~~~~~~~~~~~~~


Found 3 errors in 2 files.

Errors  Files
     1  node_modules/@types/node/globals.d.ts:347
     2  src/routers/alpha-router/gas-models/gas-model.ts:175
ERROR: "build:module" exited with 2.

cassianotartari avatar May 24 '23 13:05 cassianotartari

Using Ubuntu here and this is what happened:

$ npm install && npm run build

up to date, audited 1012 packages in 2s

197 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (5 moderate, 3 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

> @uniswap/[email protected] build
> run-p compile-v3-types compile-v2-types compile-router compile-narwhal compile-external-types && run-p build:*


> @uniswap/[email protected] compile-v3-types
> npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/?(v3-core|v3-periphery)/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-narwhal
> npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/narwhal/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-v2-types
> npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/?(v2-core|v2-periphery)/build/*UniswapV2*.json'


> @uniswap/[email protected] compile-router
> npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'


> @uniswap/[email protected] compile-external-types
> npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'

Successfully generated 2 typings!
Successfully generated 12 typings!
Successfully generated 44 typings!
Successfully generated 31 typings!
Successfully generated 88 typings!

> @uniswap/[email protected] build:main
> tsc -p tsconfig.json


> @uniswap/[email protected] build:module
> tsc -p tsconfig.module.json

node_modules/@types/node/globals.d.ts:347:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'.

347 declare var AbortSignal: {
                ~~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:2071:13
    2071 declare var AbortSignal: {
                     ~~~~~~~~~~~
    'AbortSignal' was also declared here.

src/routers/alpha-router/gas-models/gas-model.ts:175:21 - error TS2842: 'V3poolProvider' is an unused renaming of 'v3poolProvider'. Did you intend to use it as a type annotation?

175     v3poolProvider: V3poolProvider,
                        ~~~~~~~~~~~~~~

src/routers/alpha-router/gas-models/gas-model.ts:178:21 - error TS2842: 'V2poolProvider' is an unused renaming of 'v2poolProvider'. Did you intend to use it as a type annotation?

178     v2poolProvider: V2poolProvider,
                        ~~~~~~~~~~~~~~


Found 3 errors in 2 files.

Errors  Files
     1  node_modules/@types/node/globals.d.ts:347
     2  src/routers/alpha-router/gas-models/gas-model.ts:175
ERROR: "build:module" exited with 2.

I ended up fixing it by this: (first delete build folder) and add and edit this in your package.json file

    "compile-v3-types": "npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/v3-core/artifacts/contracts/**/*.json' './node_modules/@uniswap/v3-periphery/artifacts/contracts/**/*.json'",
    "compile-v2-types": "npx typechain --target ethers-v5 --out-dir src/types/v2 './node_modules/@uniswap/v2-core/build/*UniswapV2*.json' './node_modules/@uniswap/v2-periphery/build/*UniswapV2*.json'",
    "compile-router": "npx typechain --target ethers-v5 --out-dir src/types/other './node_modules/@uniswap/swap-router-contracts/artifacts/contracts/**/*.json'",
    "compile-external-types": "npx typechain --target ethers-v5 --out-dir src/types/other 'src/abis/**/*.json'",
    "compile-meta": "npx typechain --target ethers-v5 --out-dir src/types/v3 './node_modules/@uniswap/v3-periphery/artifacts/contracts/interfaces/IERC20Metadata.sol/IERC20Metadata.json'",
    "build": "run-p compile-v3-types compile-v2-types compile-router compile-external-types compile-meta && run-p build:*",



oofmaloo avatar Jun 28 '23 05:06 oofmaloo