这是我正在试图编译的一份合同
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
contract EscrowView is Ownable {
uint public feePercent;
address public feeAddress;
enum PoolType {
BUY,
SELL
}
struct EscrowPool {
PoolType pType;
address poolCreator;
address tokenAddr;
uint amount;
address[] exchangeTknsAddr;
uint[] exchangeTknsAmount;
}
uint public noOfPools;
mapping(uint => EscrowPool) public poolsTable;
}这是我的合同的文件名:1.Escrow_view.sol
每当我运行npx hardhat compile时,都会得到以下错误:
Generating typings for: 1 artifacts in dir: typechain-types for target: ethers-v5
An unexpected error occurred:
SyntaxError: Digit expected. (4:20)
2 | /* tslint:disable */
3 | /* eslint-disable */
> 4 | import type * as 1EscrowViewSol from './1.Escrow_view.sol';
| ^
5 | export type { 1EscrowViewSol };
6 | import type * as escrowViewSol from './Escrow_view.sol';
7 | export type { escrowViewSol };
at k (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/parser-typescript.js:1:15163)
at cT (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/parser-typescript.js:257:10765)
at Object.uT [as parse] (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/parser-typescript.js:257:11074)
at Object.parse (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/index.js:7331:23)
at coreFormat (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/index.js:8645:18)
at formatWithCursor2 (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/index.js:8837:18)
at /home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/index.js:37832:12
at Object.format (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/prettier/index.js:37846:12)
at prettierOutputTransformer (/home/mahesh/web3werx/escrow/escrow_contracts/node_modules/typechain/src/codegen/outputTransformers/prettier.ts:8:19)
at /home/mahesh/web3werx/escrow/escrow_contracts/node_modules/typechain/src/typechain/io.ts:22:33 {
loc: { start: { line: 4, column: 20 } },
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[35m1\x1B[39m\x1B[33mEscrowViewSol\x1B[39m \x1B[36mfrom\x1B[39m \x1B[32m'./1.Escrow_view.sol'\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[35m1\x1B[39m\x1B[33mEscrowViewSol\x1B[39m }\x1B[33m;\x1B[39m\x1B[0m\n' +
"\x1B[0m \x1B[90m 6 |\x1B[39m \x1B[36mimport\x1B[39m type \x1B[33m*\x1B[39m \x1B[36mas\x1B[39m escrowViewSol \x1B[36mfrom\x1B[39m \x1B[32m'./Escrow_view.sol'\x1B[39m\x1B[33m;\x1B[39m\x1B[0m\n" +
'\x1B[0m \x1B[90m 7 |\x1B[39m \x1B[36mexport\x1B[39m type { escrowViewSol }\x1B[33m;\x1B[39m\x1B[0m'
}发布于 2022-12-02 10:30:56
当我将合同文件名从1.Escrow_view重命名为Escrow_view时,错误消失了。
不知道为什么会发生这种情况,因为我以前多次这样命名文件,使用一些更漂亮的标准,看起来就像是新版本的“硬帽子”。
https://ethereum.stackexchange.com/questions/140427
复制相似问题