opensea.io sdkを使用した非常に単純なコード (nest.js サービス)です。
import { Injectable } from '@nestjs/common';
import Web3 from 'web3';
import { OpenSeaPort, Network } from 'opensea-js';
import { OpenSeaAsset } from 'opensea-js/lib/types';
const provider = new Web3.providers.HttpProvider('https://mainnet.infura.io');
const seaport = new OpenSeaPort(provider, {
networkName: Network.Main,
});
const tokenAddress = '0x06012c8cf97bead5deae237070f9587f8e7a266d';
const tokenId = '1';
@Injectable()
export class OpenseaService {
async fetchTrendingAssets() {
const asset: OpenSeaAsset = await seaport.api.getAsset({
tokenAddress,
tokenId,
});
return asset;
}
}
によって実行されts-node -r tsconfig-paths/register src/main.ts
ます。
しかし、でコンパイルするとスタックしましたtsc
。
私が見ている端末ログは次のとおりです。
yarn run v1.22.17
$ rm -rf dist && tsc
node_modules/@0xproject/types/lib/index.d.ts:23:16 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntry'.
23 logs: Web3.LogEntry[];
~~~~~~~~
node_modules/@0xproject/types/lib/index.d.ts:39:60 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'DecodedLogEntry'.
39 export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {
~~~~~~~~~~~~~~~
node_modules/@0xproject/types/lib/index.d.ts:41:35 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntry'.
41 export declare type RawLog = Web3.LogEntry;
~~~~~~~~
node_modules/@0xproject/types/lib/index.d.ts:49:59 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntry'.
49 logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>;
~~~~~~~~
node_modules/opensea-js/lib/seaport.d.ts:7:11 - error TS2709: Cannot use namespace 'Web3' as a type.
7 web3: Web3;
~~~~
node_modules/opensea-js/lib/seaport.d.ts:8:19 - error TS2709: Cannot use namespace 'Web3' as a type.
8 web3ReadOnly: Web3;
~~~~
node_modules/opensea-js/lib/seaport.d.ts:29:32 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'Provider'.
29 constructor(provider: Web3.Provider, apiConfig?: OpenSeaAPIConfig, logger?: (arg: string) => void);
~~~~~~~~
node_modules/opensea-js/lib/types.d.ts:498:57 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'JSONRPCResponsePayload'.
498 export declare type Web3RPCCallback = Web3Callback<Web3.JSONRPCResponsePayload>;
~~~~~~~~~~~~~~~~~~~~~~
node_modules/opensea-js/lib/types.d.ts:504:16 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'AbiType'.
504 type: Web3.AbiType | string;
~~~~~~~
node_modules/opensea-js/lib/types.d.ts:511:28 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ConstructorStateMutability'.
511 stateMutability?: Web3.ConstructorStateMutability | string;
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:19:49 - error TS2709: Cannot use namespace 'Web3' as a type.
19 export declare const confirmTransaction: (web3: Web3, txHash: string) => Promise<unknown>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:42:49 - error TS2709: Cannot use namespace 'Web3' as a type.
42 export declare function personalSignAsync(web3: Web3, message: string, signerAddress: string): Promise<ECSignature>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:48:49 - error TS2709: Cannot use namespace 'Web3' as a type.
48 export declare function isContractAddress(web3: Web3, address: string): Promise<boolean>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:65:50 - error TS2709: Cannot use namespace 'Web3' as a type.
65 export declare function sendRawTransaction(web3: Web3, { from, to, data, gasPrice, value, gas }: Web3.TxData, onError: (error: Error) => void): Promise<string>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:65:103 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'TxData'.
65 export declare function sendRawTransaction(web3: Web3, { from, to, data, gasPrice, value, gas }: Web3.TxData, onError: (error: Error) => void): Promise<string>;
~~~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:76:39 - error TS2709: Cannot use namespace 'Web3' as a type.
76 export declare function rawCall(web3: Web3, { from, to, data }: Web3.CallData, onError?: (error: Error) => void): Promise<string>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:76:70 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'CallData'.
76 export declare function rawCall(web3: Web3, { from, to, data }: Web3.CallData, onError?: (error: Error) => void): Promise<string>;
~~~~~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:85:43 - error TS2709: Cannot use namespace 'Web3' as a type.
85 export declare function estimateGas(web3: Web3, { from, to, data, value }: Web3.TxData): Promise<number>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:85:81 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'TxData'.
85 export declare function estimateGas(web3: Web3, { from, to, data, value }: Web3.TxData): Promise<number>;
~~~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:90:50 - error TS2709: Cannot use namespace 'Web3' as a type.
90 export declare function getCurrentGasPrice(web3: Web3): Promise<BigNumber>;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:96:54 - error TS2709: Cannot use namespace 'Web3' as a type.
96 export declare function getTransferFeeSettings(web3: Web3, { asset, accountAddress }: {
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:151:62 - error TS2709: Cannot use namespace 'Web3' as a type.
151 export declare function validateAndFormatWalletAddress(web3: Web3, address: string): string;
~~~~
node_modules/opensea-js/lib/utils/utils.d.ts:161:77 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
161 export declare function getNonCompliantApprovalAddress(erc721Contract: Web3.ContractInstance, tokenId: string, accountAddress: string): Promise<string | undefined>;
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/base_contract.d.ts:4:42 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
4 protected web3ContractInstance: Web3.ContractInstance;
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/base_contract.d.ts:7:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
7 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/wyvern_atomicizer.d.ts:15:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
15 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/wyvern_d_a_o.d.ts:102:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
102 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/wyvern_exchange.d.ts:128:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
128 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/wyvern_proxy_registry.d.ts:69:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
69 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/abi_gen/wyvern_token.d.ts:110:44 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'ContractInstance'.
110 constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>);
~~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/types.d.ts:47:37 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntryEvent'.
47 export declare type LogEvent = Web3.LogEntryEvent;
~~~~~~~~~~~~~
node_modules/wyvern-js/lib/types.d.ts:56:60 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'DecodedLogEntry'.
56 export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {
~~~~~~~~~~~~~~~
node_modules/wyvern-js/lib/types.d.ts:59:59 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntry'.
59 logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>;
~~~~~~~~
node_modules/wyvern-js/lib/types.d.ts:71:35 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'LogEntry'.
71 export declare type RawLog = Web3.LogEntry;
~~~~~~~~
node_modules/wyvern-js/lib/types.d.ts:155:41 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'Provider'.
155 export declare type Web3Provider = Web3.Provider;
~~~~~~~~
node_modules/wyvern-schemas/dist/index.d.ts:4:10 - error TS2614: Module '"web3"' has no exported member 'AbiType'. Did you mean to use 'import AbiType from "web3"' instead?
4 export { AbiType, } from 'web3';
~~~~~~~
node_modules/wyvern-schemas/dist/types.d.ts:56:16 - error TS2694: Namespace '"/home/netfan/oneandzeros/node-nft-backend/node_modules/web3/types/index"' has no exported member 'AbiType'.
56 type: Web3.AbiType.Event;
~~~~~~~
Found 37 errors.
error Command failed with exit code 2.
そして、ここに私のtsconfigがあります:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./src",
"paths": {
"modules/*": ["modules/*"]
},
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
package.json
ファイルはここにあります:
{
"name": "nest-starter",
"version": "1.0.0",
"description": "Nest.js Starter For Minimalists",
"author": "CrazyOptimist",
"license": "ISC",
"scripts": {
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "nodemon",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rm -rf dist && tsc",
"start:prod": "node -r ./tsconfig-paths-bootstrap.js dist/main.js",
"start:hmr": "node dist/server",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json",
"webpack": "webpack --config webpack.config.js",
"ts-typeorm": "ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm",
"migration:create": "typeorm migration:create -d src/migrations",
"migration:run": "yarn ts-typeorm migration:run",
"migration:revert": "yarn ts-typeorm migration:revert",
"prepare": "husky install"
},
"dependencies": {
"@nestjs/common": "^7.6.5",
"@nestjs/core": "^7.6.5",
"@nestjs/jwt": "^7.2.0",
"@nestjs/passport": "^7.1.5",
"@nestjs/platform-express": "^7.6.5",
"@nestjs/swagger": "^4.7.12",
"@nestjs/typeorm": "^7.1.5",
"@types/bcrypt": "^3.0.0",
"bcrypt": "^5.0.0",
"class-transformer": "^0.3.2",
"class-validator": "^0.13.1",
"dotenv": "^8.2.0",
"lint-staged": "^11.1.2",
"mysql": "^2.18.1",
"opensea-js": "^1.2.1",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.6.3",
"swagger-ui-express": "^4.1.6",
"typeorm": "^0.2.30",
"typescript": "^4.1.3",
"web3": "^1.6.0"
},
"devDependencies": {
"@nestjs/testing": "^7.6.5",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.22",
"@types/supertest": "^2.0.10",
"@types/swagger-ui-express": "^4.1.2",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"eslint": "^7.18.0",
"husky": "^7.0.0",
"jest": "^26.6.3",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"supertest": "6.1.0",
"ts-jest": "^26.4.4",
"ts-loader": "^8.0.14",
"ts-node": "^8.1.1",
"tsconfig-paths": "^3.9.0",
"webpack": "^5.17.0",
"webpack-cli": "^4.4.0",
"webpack-node-externals": "^2.5.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
環境
- オペレーティング システム: Ubuntu 20.04
- ブラウザ:未使用
- Node.js バージョン: 16.13 (v14.17 と同じ動作)
- NPM バージョン: 8.1.0 (v6.4 と同じ)
tsconfig に何か問題がありますか、それとも他に何か不足していますか? どんな助けでも大歓迎です。