dethcrypto / dethcrypto/TypeChain

Failing to generate types for @account-abstraction/contracts

Open
#816 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use the ERC-4337 contracts in the [@account-abstraction/contracts](https://www.npmjs.com/package/@account-abstraction/contracts) package.

I've created a simple Hardhat project that attempts to compile and generate types for the @account-abstraction contracts. To replicate, please use the `typechain` branch as that is barebones.
https://github.com/naddison36/abstract-accounts/tree/typechain

When I compile the project using `yarn compile`, I get the following error
```
Generating typings for: 17 artifacts in dir: src/types/typechain for target: ethers-v5
An unexpected error occurred:

SyntaxError: 'from' expected. (4:24)
2 | /* tslint:disable */
3 | /* eslint-disable */
> 4 | import type * as from './..';
| ^
5 | export type { };
6 | export * as accountAbstraction from './@account-abstraction';
7 | export * as openzeppelin from './@openzeppelin';
at D (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/parser-typescript.js:1:17100)
at LT (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/parser-typescript.js:257:10765)
at Object.RT [as parse] (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/parser-typescript.js:257:11074)
at Object.parse (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/index.js:7515:23)
at coreFormat (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/index.js:8829:18)
at formatWithCursor2 (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/index.js:9021:18)
at /Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/index.js:38176:12
at Object.format (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/prettier/index.js:38190:12)
at prettierOutputTransformer (/Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/typechain/src/codegen/outputTransformers/prettier.ts:8:19)
at /Users/nicholasaddison/Documents/workspaces/abstract-accounts/node_modules/typechain/src/typechain/io.ts:22:33 {
loc: { start: { line: 4, column: 24 } },
codeFrame: '\x1B[0m \x1B[90m 2 |\x1B[39m \x1B[90m/* tslint:disable */\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 3 |\x1B[39m \x1B[90m/* eslint-disable */\x1B[39m\x1B[0m\n' +
"\x1B[0m\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 4 |\x1B[39m \x1B[36mimport\x1B[39m type \x1B[33m*\x1B[39m \x1B[36mas\x1B[39m \x1B[36mfrom\x1B[39m \x1B[32m'./..'\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n" +
'\x1B[0m \x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 5 |\x1B[39m \x1B[36mexport\x1B[39m type { }\x1B[33m;\x1B[39m\x1B[0m\n' +
"\x1B[0m \x1B[90m 6 |\x1B[39m \x1B[36mexport\x1B[39m \x1B[33m*\x1B[39m \x1B[36mas\x1B[39m accountAbstraction \x1B[36mfrom\x1B[39m \x1B[32m'./@account-abstraction'\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n" +
"\x1B[0m \x1B[90m 7 |\x1B[39m \x1B[36mexport\x1B[39m \x1B[33m*\x1B[39m \x1B[36mas\x1B[39m openzeppelin \x1B[36mfrom\x1B[39m \x1B[32m'./@openzeppelin'\x1B[39m\x1B[33m;\x1B[39m\x1B[0m"
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

Interestingly, types are created in the `src/types` and `src/types/types` folders. If I just use the Hardhat typechain plug-in defaults, types are created in `typechain-types` and the project root.

![Screenshot 2023-03-15 at 10 54 28 am](https://user-images.githubusercontent.com/6491112/225167603-efa5f35e-07f3-450b-83c0-4cec08a6ea8c.png)

I've kept the installed packages to a minimum to try and isolate the problem
```
npm ls
abstract-accounts@0.0.1 /Users/nicholasaddison/Documents/workspaces/abstract-accounts
├── @account-abstraction/contracts@0.5.0
├── @nomiclabs/hardhat-ethers@2.2.2
├── @openzeppelin/contracts@4.8.2
├── @typechain/ethers-v5@10.2.0
├── @typechain/hardhat@6.1.5
├── @types/node@18.15.3
├── defender-relay-client@1.39.0
├── ethers@5.7.2
├── hardhat@2.13.0
├── ts-generator@0.1.1
├── ts-node@10.9.1
├── typechain@8.1.1
└── typescript@4.9.5
```

The typechain config in Hardhat is
```js
typechain: {
outDir: "src/types/typechain",
target: "ethers-v5",
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.