diff --git a/web3.js/.eslintignore b/web3.js/.eslintignore index ae9d81a32c..129d3c45a4 100644 --- a/web3.js/.eslintignore +++ b/web3.js/.eslintignore @@ -1,5 +1,6 @@ /commitlint.config.js /coverage +/declarations /deploy /doc /lib diff --git a/web3.js/.gitignore b/web3.js/.gitignore index c158f7d504..5aa7041905 100644 --- a/web3.js/.gitignore +++ b/web3.js/.gitignore @@ -27,3 +27,6 @@ test-ledger/ # Flow module.flow.js + +# TypeScript +declarations diff --git a/web3.js/.prettierignore b/web3.js/.prettierignore index d846c4ba2e..9c0b04c435 100644 --- a/web3.js/.prettierignore +++ b/web3.js/.prettierignore @@ -1,2 +1,3 @@ test/dist module.flow.js +declarations diff --git a/web3.js/package-lock.json b/web3.js/package-lock.json index 48316914af..0711332fe6 100644 --- a/web3.js/package-lock.json +++ b/web3.js/package-lock.json @@ -3031,15 +3031,6 @@ "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", "dev": true }, - "@mdn/browser-compat-data": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-3.2.1.tgz", - "integrity": "sha512-rIfqD67k64yP6RfFyZOVSLykDoNfAkeqRrTZnKs13rfa+EAFF/FOYAKTOpKMwMUfTM2/+FGYRGaiFmETnGRjsQ==", - "dev": true, - "requires": { - "extend": "3.0.2" - } - }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -3718,47 +3709,6 @@ "tweetnacl": "^1.0.0" } }, - "@types/babel__core": { - "version": "7.1.13", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.13.tgz", - "integrity": "sha512-CC6amBNND16pTk4K3ZqKIaba6VGKAQs3gMjEY17FVd56oI/ZWt9OhS6riYiWv9s8ENbYUi7p8lgqb0QHQvUKQQ==", - "dev": true, - "requires": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0", - "@types/babel__generator": "*", - "@types/babel__template": "*", - "@types/babel__traverse": "*" - } - }, - "@types/babel__generator": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.2.tgz", - "integrity": "sha512-MdSJnBjl+bdwkLskZ3NGFp9YcXGx5ggLpQQPqtgakVhsWK0hTtNYhjpZLlWQTviGTvF8at+Bvli3jV7faPdgeQ==", - "dev": true, - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@types/babel__template": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.0.tgz", - "integrity": "sha512-NTPErx4/FiPCGScH7foPyr+/1Dkzkni+rHiYHHoTjvwou7AQzJkNeD60A9CXRy+ZEN2B1bggmkTMCDb+Mv5k+A==", - "dev": true, - "requires": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@types/babel__traverse": { - "version": "7.11.1", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.11.1.tgz", - "integrity": "sha512-Vs0hm0vPahPMYi9tDjtP66llufgO3ST16WXaSTtDGEl9cewAl3AibmxWw6TINOqHPT9z0uABKAYjT9jNSg4npw==", - "dev": true, - "requires": { - "@babel/types": "^7.3.0" - } - }, "@types/bn.js": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", @@ -3957,12 +3907,6 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@types/object-path": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@types/object-path/-/object-path-0.11.0.tgz", - "integrity": "sha512-/tuN8jDbOXcPk+VzEVZzzAgw1Byz7s/itb2YI10qkSyy6nykJH02DuhfrflxVdAdE7AZ91h5X6Cn0dmVdFw2TQ==", - "dev": true - }, "@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -4003,12 +3947,6 @@ "@types/node": "*" } }, - "@types/semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ==", - "dev": true - }, "@types/serve-static": { "version": "1.13.9", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.9.tgz", @@ -4034,12 +3972,6 @@ "integrity": "sha512-dIPoZ3g5gcx9zZEszaxLSVTvMReD3xxyyDnQUjA6IYDG9Ba2AV0otMPs+77sG9ojB4Qr2N2Vk5RnKeuA0X/0bg==", "dev": true }, - "@types/ua-parser-js": { - "version": "0.7.35", - "resolved": "https://registry.npmjs.org/@types/ua-parser-js/-/ua-parser-js-0.7.35.tgz", - "integrity": "sha512-PsPx0RLbo2Un8+ff2buzYJnZjzwhD3jQHPOG2PtVIeOhkRDddMcKU8vJtHpzzfLB95dkUi0qAkfLg2l2Fd0yrQ==", - "dev": true - }, "@types/yauzl": { "version": "2.9.1", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", @@ -4296,133 +4228,12 @@ } } }, - "@typescript-eslint/scope-manager": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.19.0.tgz", - "integrity": "sha512-GGy4Ba/hLXwJXygkXqMzduqOMc+Na6LrJTZXJWVhRrSuZeXmu8TAnniQVKgj8uTRKe4igO2ysYzH+Np879G75g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.19.0", - "@typescript-eslint/visitor-keys": "4.19.0" - } - }, - "@typescript-eslint/types": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.19.0.tgz", - "integrity": "sha512-A4iAlexVvd4IBsSTNxdvdepW0D4uR/fwxDrKUa+iEY9UWvGREu2ZyB8ylTENM1SH8F7bVC9ac9+si3LWNxcBuA==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.19.0.tgz", - "integrity": "sha512-3xqArJ/A62smaQYRv2ZFyTA+XxGGWmlDYrsfZG68zJeNbeqRScnhf81rUVa6QG4UgzHnXw5VnMT5cg75dQGDkA==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.19.0", - "@typescript-eslint/visitor-keys": "4.19.0", - "debug": "^4.1.1", - "globby": "^11.0.1", - "is-glob": "^4.0.1", - "semver": "^7.3.2", - "tsutils": "^3.17.1" - }, - "dependencies": { - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "@typescript-eslint/visitor-keys": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.19.0.tgz", - "integrity": "sha512-aGPS6kz//j7XLSlgpzU2SeTqHPsmRYxFztj2vPuMMFJXZudpRSehE3WCV+BaxwZFvfAqMoSd86TEuM0PQ59E/A==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.19.0", - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", - "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", - "dev": true - } - } - }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, - "@wessberg/browserslist-generator": { - "version": "1.0.44", - "resolved": "https://registry.npmjs.org/@wessberg/browserslist-generator/-/browserslist-generator-1.0.44.tgz", - "integrity": "sha512-22AW+Av/Nc8kSLetBtraaowYMcacRnyjwuuglqtbpnRkUMCXkUAoi/IV1j5aNMcu8bAwXaJFX4KzSzQ1qOuc+A==", - "dev": true, - "requires": { - "@mdn/browser-compat-data": "^3.2.0", - "@types/object-path": "^0.11.0", - "@types/semver": "^7.3.4", - "@types/ua-parser-js": "^0.7.35", - "browserslist": "4.16.3", - "caniuse-lite": "^1.0.30001202", - "object-path": "^0.11.5", - "semver": "^7.3.4", - "ua-parser-js": "^0.7.24" - }, - "dependencies": { - "caniuse-lite": { - "version": "1.0.30001203", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001203.tgz", - "integrity": "sha512-/I9tvnzU/PHMH7wBPrfDMSuecDeUKerjCPX7D0xBbaJZPxoT9m+yYxt0zCTkcijCkjTdim3H56Zm0i5Adxch4w==", - "dev": true - }, - "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "@wessberg/stringutil": { - "version": "1.0.19", - "resolved": "https://registry.npmjs.org/@wessberg/stringutil/-/stringutil-1.0.19.tgz", - "integrity": "sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==", - "dev": true - }, - "@wessberg/ts-clone-node": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@wessberg/ts-clone-node/-/ts-clone-node-0.3.19.tgz", - "integrity": "sha512-BnJcU0ZwHxa5runiEkHzMZ6/ydxz+YYqBHOGQtf3eoxSZu2iWMPPaUfCum0O1/Ey5dqrrptUh+HmyMTzHPfdPA==", - "dev": true - }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", @@ -7475,12 +7286,6 @@ } } }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, "extract-zip": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", @@ -14364,12 +14169,6 @@ "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", "dev": true }, - "object-path": { - "version": "0.11.5", - "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.5.tgz", - "integrity": "sha512-jgSbThcoR/s+XumvGMTMf81QVBmah+/Q7K7YduKeKVWL7N111unR2d6pZZarSk6kY/caeNxUDyxOvMWyzoU2eg==", - "dev": true - }, "object.assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", @@ -15370,22 +15169,37 @@ "fsevents": "~2.3.1" } }, - "rollup-plugin-flat-dts": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-flat-dts/-/rollup-plugin-flat-dts-1.2.0.tgz", - "integrity": "sha512-mMo9LyOcyYPiYujiAak4CEglKhxZ5FTc6KMohvTVVjJIZMtSkHkxnusQBa8nMKrJ0rLwmZVA8ls2bS16+zbD7A==", + "rollup-plugin-dts": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-3.0.1.tgz", + "integrity": "sha512-sdTsd0tEIV1b5Bio1k4Ei3N4/7jbwcVRdlYotGYdJOKR59JH7DzqKTSCbfaKPzuAcKTp7k317z2BzYJ3bkhDTw==", "dev": true, "requires": { - "is-glob": "^4.0.1", - "micromatch": "^4.0.2", - "source-map": "^0.7.3" + "@babel/code-frame": "^7.12.13", + "magic-string": "^0.25.7" }, "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true + "@babel/code-frame": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", + "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", + "dev": true, + "optional": true, + "requires": { + "@babel/highlight": "^7.12.13" + } + }, + "@babel/highlight": { + "version": "7.13.10", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.13.10.tgz", + "integrity": "sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==", + "dev": true, + "optional": true, + "requires": { + "@babel/helper-validator-identifier": "^7.12.11", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } } } }, @@ -15501,127 +15315,6 @@ } } }, - "rollup-plugin-ts": { - "version": "1.3.10", - "resolved": "https://registry.npmjs.org/rollup-plugin-ts/-/rollup-plugin-ts-1.3.10.tgz", - "integrity": "sha512-FCqhsIOgNhIfG01SVkLkfc4bGFMNVj92LYKdOLePZmrlH6zd6bM25LWT/HqqtVSMnlKrHLWCrL50MzhNK1HmdQ==", - "dev": true, - "requires": { - "@babel/core": "^7.13.10", - "@babel/plugin-proposal-async-generator-functions": "^7.13.8", - "@babel/plugin-proposal-json-strings": "^7.13.8", - "@babel/plugin-proposal-object-rest-spread": "^7.13.8", - "@babel/plugin-proposal-optional-catch-binding": "^7.13.8", - "@babel/plugin-proposal-unicode-property-regex": "^7.12.13", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-transform-runtime": "^7.13.10", - "@babel/preset-env": "^7.13.10", - "@babel/runtime": "^7.13.10", - "@rollup/pluginutils": "^4.1.0", - "@types/babel__core": "^7.1.13", - "@wessberg/browserslist-generator": "^1.0.44", - "@wessberg/stringutil": "^1.0.19", - "@wessberg/ts-clone-node": "^0.3.19", - "browserslist": "^4.16.3", - "chalk": "^4.1.0", - "magic-string": "^0.25.7", - "slash": "^3.0.0", - "tslib": "^2.1.0" - }, - "dependencies": { - "@babel/helper-plugin-utils": { - "version": "7.13.0", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz", - "integrity": "sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ==", - "dev": true - }, - "@babel/plugin-transform-runtime": { - "version": "7.13.10", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.13.10.tgz", - "integrity": "sha512-Y5k8ipgfvz5d/76tx7JYbKQTcgFSU6VgJ3kKQv4zGTKr+a9T/KBvfRvGtSFgKDQGt/DBykQixV0vNWKIdzWErA==", - "dev": true, - "requires": { - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "babel-plugin-polyfill-corejs2": "^0.1.4", - "babel-plugin-polyfill-corejs3": "^0.1.3", - "babel-plugin-polyfill-regenerator": "^0.1.2", - "semver": "^6.3.0" - } - }, - "@rollup/pluginutils": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.0.tgz", - "integrity": "sha512-TrBhfJkFxA+ER+ew2U2/fHbebhLT/l/2pRk0hfj9KusXUuRXd2v0R58AfaZK9VXDQ4TogOSEmICVrQAA3zFnHQ==", - "dev": true, - "requires": { - "estree-walker": "^2.0.1", - "picomatch": "^2.2.2" - } - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -17501,12 +17194,6 @@ "integrity": "sha1-uk99si2RU0oZKdkACdzhYety/T8=", "dev": true }, - "ua-parser-js": { - "version": "0.7.24", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.24.tgz", - "integrity": "sha512-yo+miGzQx5gakzVK3QFfN0/L9uVhosXBBO7qmnk7c2iw1IhL212wfA3zbnI54B0obGwC/5NWub/iT9sReMx+Fw==", - "dev": true - }, "uglify-js": { "version": "3.13.0", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.0.tgz", diff --git a/web3.js/package.json b/web3.js/package.json index 258cb4254d..655d671979 100644 --- a/web3.js/package.json +++ b/web3.js/package.json @@ -25,7 +25,7 @@ }, "main": "lib/index.cjs.js", "module": "lib/index.esm.js", - "types": "lib/types/index.d.ts", + "types": "lib/index.d.ts", "browserslist": [ "defaults", "not IE 11", @@ -37,7 +37,7 @@ "/src" ], "scripts": { - "build": "cross-env NODE_ENV=production rollup -c; npm run flowgen", + "build": "npm run clean; cross-env NODE_ENV=production rollup -c; npm run generate:dts; npm run generate:flow", "build:browser-test": "rollup -c test/rollup.config.js", "build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh", "clean": "rimraf ./coverage ./lib", @@ -45,7 +45,8 @@ "dev": "cross-env NODE_ENV=development rollup -c", "doc": "set -ex; typedoc", "doc:watch": "watch 'npm run doc' . --wait=1 --ignoreDirectoryPattern=/doc/", - "flowgen": "./scripts/flowgen.sh", + "generate:dts": "./scripts/typegen.sh", + "generate:flow": "flowgen lib/index.d.ts -o module.flow.js", "lint": "set -ex; npm run pretty; eslint . --ext .js,.ts", "lint:fix": "npm run pretty:fix && eslint . --fix", "lint:watch": "watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/", @@ -126,10 +127,9 @@ "prettier": "^2.0.0", "rimraf": "3.0.2", "rollup": "2.43.1", - "rollup-plugin-flat-dts": "^1.0.3", + "rollup-plugin-dts": "^3.0.1", "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-ts": "^1.3.7", "semantic-release": "^17.0.2", "sinon": "^10.0.0", "start-server-and-test": "^1.12.0", diff --git a/web3.js/rollup.config.js b/web3.js/rollup.config.js index 808fb16ad1..e7d012b34f 100644 --- a/web3.js/rollup.config.js +++ b/web3.js/rollup.config.js @@ -1,7 +1,6 @@ import babel from '@rollup/plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; -import typescript from 'rollup-plugin-ts'; import nodeResolve from '@rollup/plugin-node-resolve'; import nodePolyfills from 'rollup-plugin-node-polyfills'; import replace from '@rollup/plugin-replace'; @@ -13,7 +12,6 @@ const extensions = ['.js', '.ts']; function generateConfig(configType, format) { const browser = configType === 'browser'; const bundle = format === 'iife'; - const generateTypescript = configType === 'typescript'; const config = { input: 'src/index.ts', @@ -25,12 +23,6 @@ function generateConfig(configType, format) { extensions, preferBuiltins: !browser, }), - generateTypescript - ? typescript({ - browserslist: false, - tsconfig: './tsconfig.d.json', - }) - : undefined, babel({ exclude: '**/node_modules/**', extensions, @@ -145,12 +137,6 @@ function generateConfig(configType, format) { }, ]; break; - case 'typescript': - config.output = { - file: 'lib/types/index.d.ts', - }; - config.plugins.push(json()); - break; default: throw new Error(`Unknown configType: ${configType}`); } @@ -160,7 +146,6 @@ function generateConfig(configType, format) { export default [ generateConfig('node'), - generateConfig('typescript'), generateConfig('browser', 'esm'), generateConfig('browser', 'iife'), ]; diff --git a/web3.js/rollup.config.types.js b/web3.js/rollup.config.types.js new file mode 100644 index 0000000000..7716ae9249 --- /dev/null +++ b/web3.js/rollup.config.types.js @@ -0,0 +1,7 @@ +import dts from 'rollup-plugin-dts'; + +export default { + input: './declarations/index.d.ts', + output: [{file: 'lib/index.d.ts', format: 'es'}], + plugins: [dts()], +}; diff --git a/web3.js/scripts/flowgen.sh b/web3.js/scripts/flowgen.sh deleted file mode 100755 index 91fb66c783..0000000000 --- a/web3.js/scripts/flowgen.sh +++ /dev/null @@ -1,16 +0,0 @@ -set -ex - -# Generate flowdef -npx flowgen lib/types/index.d.ts -o module.flow.js - -# Remove trailing export -sed -i '/declare export {/{:a;N;/}/!ba};//g' module.flow.js - -# Change all declarations to exports -sed -i 's/declare/declare export/g' module.flow.js - -# Prepend declare module line -sed -i '7s;^;declare module "@solana/web3.js" {\n;' module.flow.js - -# Append closing brace for module declaration -echo '}' >> module.flow.js diff --git a/web3.js/scripts/typegen.sh b/web3.js/scripts/typegen.sh new file mode 100755 index 0000000000..d98df5c50e --- /dev/null +++ b/web3.js/scripts/typegen.sh @@ -0,0 +1,19 @@ +set -e + +# Generate typescript declarations +npx tsc -p tsconfig.d.json -d + +# Flatten typescript declarations +npx rollup -c rollup.config.types.js + +# Replace export with closing brace for module declaration +sed -i '$s/export {.*};/}/' lib/index.d.ts + +# Replace declare's with export's +sed -i 's/declare/export/g' lib/index.d.ts + +# Prepend declare module line +sed -i '2s;^;declare module "@solana/web3.js" {\n;' lib/index.d.ts + +# Run prettier +npx prettier --write lib/index.d.ts diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index 178ff04c72..2ba430aa94 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -1417,6 +1417,7 @@ describe('Connection', () => { const newAccount = new Account().publicKey; let testToken: Token; + let testTokenPubkey: PublicKey; let testTokenAccount: PublicKey; let testSignature: TransactionSignature; let testOwner: Account; @@ -1474,11 +1475,11 @@ describe('Connection', () => { testOwner = accountOwner; testToken = token; testTokenAccount = tokenAccount as PublicKey; + testTokenPubkey = testToken.publicKey as PublicKey; }); it('get token supply', async () => { - const supply = (await connection.getTokenSupply(testToken.publicKey)) - .value; + const supply = (await connection.getTokenSupply(testTokenPubkey)).value; expect(supply.uiAmount).to.eq(111.11); expect(supply.decimals).to.eq(2); expect(supply.amount).to.eq('11111'); @@ -1488,7 +1489,7 @@ describe('Connection', () => { it('get token largest accounts', async () => { const largestAccounts = ( - await connection.getTokenLargestAccounts(testToken.publicKey) + await connection.getTokenLargestAccounts(testTokenPubkey) ).value; expect(largestAccounts).to.have.length(2); @@ -1575,7 +1576,7 @@ describe('Connection', () => { it('get parsed token accounts by owner', async () => { const tokenAccounts = ( await connection.getParsedTokenAccountsByOwner(testOwner.publicKey, { - mint: testToken.publicKey, + mint: testTokenPubkey, }) ).value; tokenAccounts.forEach(({account}) => { @@ -1593,7 +1594,7 @@ describe('Connection', () => { it('get token accounts by owner', async () => { const accountsWithMintFilter = ( await connection.getTokenAccountsByOwner(testOwner.publicKey, { - mint: testToken.publicKey, + mint: testTokenPubkey, }) ).value; expect(accountsWithMintFilter).to.have.length(2); @@ -1607,7 +1608,7 @@ describe('Connection', () => { const noAccounts = ( await connection.getTokenAccountsByOwner(newAccount, { - mint: testToken.publicKey, + mint: testTokenPubkey, }) ).value; expect(noAccounts).to.have.length(0); diff --git a/web3.js/tsconfig.d.json b/web3.js/tsconfig.d.json index 8283ec15d2..921c47b4b3 100644 --- a/web3.js/tsconfig.d.json +++ b/web3.js/tsconfig.d.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "stripInternal": true, + "emitDeclarationOnly": true, + "stripInternal": true } } diff --git a/web3.js/tsconfig.json b/web3.js/tsconfig.json index 987383d150..c6af4c4f1b 100644 --- a/web3.js/tsconfig.json +++ b/web3.js/tsconfig.json @@ -4,8 +4,7 @@ "allowJs": true, "skipLibCheck": true, "declaration": true, - "declarationMap": true, - "declarationDir": "lib/types", + "declarationDir": "declarations", "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, @@ -16,11 +15,7 @@ "isolatedModules": true, "baseUrl": "src", "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "paths": { - // This is needed so that @solana/spl-token's @solana/web3.js doesn't conflict - "@solana/web3.js": ["."] - } + "noImplicitReturns": true }, "include": ["src"] }