From 8ada44456d062049f9ea41dbf78cc07421c506c0 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Mon, 15 Mar 2021 13:08:10 +0800 Subject: [PATCH] chore: migrate tests to typescript --- web3.js/.eslintignore | 1 - web3.js/.prettierignore | 1 + web3.js/.travis/script.sh | 2 - web3.js/package-lock.json | 759 ++---------------- web3.js/package.json | 20 +- web3.js/rollup.config.js | 4 +- web3.js/src/connection.ts | 8 +- .../test/{account.test.js => account.test.ts} | 0 ...-manager.test.js => agent-manager.test.ts} | 0 ...{bpf-loader.test.js => bpf-loader.test.ts} | 2 +- .../test/{cluster.test.js => cluster.test.ts} | 3 +- ...{connection.test.js => connection.test.ts} | 108 +-- .../test/mocks/{rpc-http.js => rpc-http.ts} | 42 +- .../{rpc-websockets.js => rpc-websockets.ts} | 29 +- web3.js/test/{nonce.test.js => nonce.test.ts} | 7 +- .../{publickey.test.js => publickey.test.ts} | 0 web3.js/test/rollup.config.js | 24 +- ...gram.test.js => secp256k1-program.test.ts} | 0 ...ding.test.js => shortvec-encoding.test.ts} | 6 +- ...-program.test.js => stake-program.test.ts} | 0 ...program.test.js => system-program.test.ts} | 0 ...ayer.test.js => transaction-payer.test.ts} | 9 +- ...ransaction.test.js => transaction.test.ts} | 36 +- web3.js/test/{url.js => url.ts} | 0 ...or-info.test.js => validator-info.test.ts} | 0 .../{websocket.test.js => websocket.test.ts} | 0 web3.js/tsconfig.json | 6 +- 27 files changed, 242 insertions(+), 825 deletions(-) rename web3.js/test/{account.test.js => account.test.ts} (100%) rename web3.js/test/{agent-manager.test.js => agent-manager.test.ts} (100%) rename web3.js/test/{bpf-loader.test.js => bpf-loader.test.ts} (99%) rename web3.js/test/{cluster.test.js => cluster.test.ts} (89%) rename web3.js/test/{connection.test.js => connection.test.ts} (96%) rename web3.js/test/mocks/{rpc-http.js => rpc-http.ts} (80%) rename web3.js/test/mocks/{rpc-websockets.js => rpc-websockets.ts} (83%) rename web3.js/test/{nonce.test.js => nonce.test.ts} (97%) rename web3.js/test/{publickey.test.js => publickey.test.ts} (100%) rename web3.js/test/{secp256k1-program.test.js => secp256k1-program.test.ts} (100%) rename web3.js/test/{shortvec-encoding.test.js => shortvec-encoding.test.ts} (93%) rename web3.js/test/{stake-program.test.js => stake-program.test.ts} (100%) rename web3.js/test/{system-program.test.js => system-program.test.ts} (100%) rename web3.js/test/{transaction-payer.test.js => transaction-payer.test.ts} (94%) rename web3.js/test/{transaction.test.js => transaction.test.ts} (96%) rename web3.js/test/{url.js => url.ts} (100%) rename web3.js/test/{validator-info.test.js => validator-info.test.ts} (100%) rename web3.js/test/{websocket.test.js => websocket.test.ts} (100%) diff --git a/web3.js/.eslintignore b/web3.js/.eslintignore index 3444b0317..aa35977f9 100644 --- a/web3.js/.eslintignore +++ b/web3.js/.eslintignore @@ -2,7 +2,6 @@ /coverage /deploy /doc -/flow-typed /lib /module.flow.js /.eslintrc.js diff --git a/web3.js/.prettierignore b/web3.js/.prettierignore index 94fde9b99..d846c4ba2 100644 --- a/web3.js/.prettierignore +++ b/web3.js/.prettierignore @@ -1 +1,2 @@ test/dist +module.flow.js diff --git a/web3.js/.travis/script.sh b/web3.js/.travis/script.sh index 2d1cee242..dde7004a7 100644 --- a/web3.js/.travis/script.sh +++ b/web3.js/.travis/script.sh @@ -8,8 +8,6 @@ test -r lib/index.iife.js test -r lib/index.cjs.js test -r lib/index.esm.js npm run doc -npm run defs -npm run flow npm run lint npm run codecov make -C examples/bpf-c-noop/ diff --git a/web3.js/package-lock.json b/web3.js/package-lock.json index de9d443e6..268d5d947 100644 --- a/web3.js/package-lock.json +++ b/web3.js/package-lock.json @@ -3029,31 +3029,12 @@ "integrity": "sha512-b3nHy/0uufJJsaZERwZM0syLRO6gfr6vvBPLewQxBKzzbhGDx1ygTyoELMNADD7mIPPzGMqbfdCeJTSeZueZwA==", "dev": true }, - "@octokit/plugin-paginate-rest": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz", - "integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==", - "dev": true, - "requires": { - "@octokit/types": "^2.0.1" - } - }, "@octokit/plugin-request-log": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz", "integrity": "sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==", "dev": true }, - "@octokit/plugin-rest-endpoint-methods": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz", - "integrity": "sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ==", - "dev": true, - "requires": { - "@octokit/types": "^2.0.1", - "deprecation": "^2.3.1" - } - }, "@octokit/request": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.3.1.tgz", @@ -3117,30 +3098,6 @@ "once": "^1.4.0" } }, - "@octokit/rest": { - "version": "16.43.2", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.43.2.tgz", - "integrity": "sha512-ngDBevLbBTFfrHZeiS7SAMAZ6ssuVmXuya+F/7RaVvlysgGa1JKJkKWY+jV6TCJYcW0OALfJ7nTIGXcBXzycfQ==", - "dev": true, - "requires": { - "@octokit/auth-token": "^2.4.0", - "@octokit/plugin-paginate-rest": "^1.1.1", - "@octokit/plugin-request-log": "^1.0.0", - "@octokit/plugin-rest-endpoint-methods": "2.4.0", - "@octokit/request": "^5.2.0", - "@octokit/request-error": "^1.0.2", - "atob-lite": "^2.0.0", - "before-after-hook": "^2.0.0", - "btoa-lite": "^1.0.0", - "deprecation": "^2.0.0", - "lodash.get": "^4.4.2", - "lodash.set": "^4.3.2", - "lodash.uniq": "^4.5.0", - "octokit-pagination-methods": "^1.1.0", - "once": "^1.4.0", - "universal-user-agent": "^4.0.0" - } - }, "@octokit/types": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.1.1.tgz", @@ -3852,12 +3809,6 @@ "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", "dev": true }, - "@sindresorhus/is": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-2.1.1.tgz", - "integrity": "sha512-/aPsuoj/1Dw/kzhkgz+ES6TxG0zfTMGLwuK2ZG00k/iJzYHTLCE8mVU8EPqEOp/lmxPoq1C1C9RYToRKb2KEfg==", - "dev": true - }, "@sinonjs/commons": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.2.tgz", @@ -3978,15 +3929,6 @@ } } }, - "@szmarczak/http-timer": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", - "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", - "dev": true, - "requires": { - "defer-to-connect": "^2.0.0" - } - }, "@types/babel__core": { "version": "7.1.12", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.12.tgz", @@ -4067,16 +4009,19 @@ } } }, - "@types/cacheable-request": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", - "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==", + "@types/chai": { + "version": "4.2.15", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz", + "integrity": "sha512-rYff6FI+ZTKAPkJUoyz7Udq3GaoDZnxYDEvdEdFZASiA7PoErltHezDishqQiSDWrGxvxmplH304jyzQmjp0AQ==", + "dev": true + }, + "@types/chai-as-promised": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.3.tgz", + "integrity": "sha512-FQnh1ohPXJELpKhzjuDkPLR2BZCAqed+a6xV4MI/T3XzHfd2FlarfUGUdZYgqYe8oxkYn0fchHEeHfHqdZ96sg==", "dev": true, "requires": { - "@types/http-cache-semantics": "*", - "@types/keyv": "*", - "@types/node": "*", - "@types/responselike": "*" + "@types/chai": "*" } }, "@types/color-name": { @@ -4127,12 +4072,6 @@ "@types/range-parser": "*" } }, - "@types/http-cache-semantics": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", - "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==", - "dev": true - }, "@types/json-schema": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", @@ -4145,15 +4084,6 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, - "@types/keyv": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz", - "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/lodash": { "version": "4.14.168", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.168.tgz", @@ -4171,6 +4101,21 @@ "integrity": "sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=", "dev": true }, + "@types/mocha": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.1.tgz", + "integrity": "sha512-NysN+bNqj6E0Hv4CTGWSlPzMW6vTKjDpOteycDkV4IWBsO+PU48JonrPzV9ODjiI2XrjmA05KInLgF5ivZ/YGQ==", + "dev": true + }, + "@types/mz": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/mz/-/mz-2.7.3.tgz", + "integrity": "sha512-Zp1NUJ4Alh3gaun0a5rkF3DL7b2j1WB6rPPI5h+CJ98sQnxe9qwskClvupz/4bqChGR3L/BRhTjlaOwR+uiZJg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/node": { "version": "14.14.31", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz", @@ -4254,15 +4199,6 @@ "@types/node": "*" } }, - "@types/responselike": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", - "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", @@ -4294,6 +4230,21 @@ "@types/node": "*" } }, + "@types/sinon": { + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.11.tgz", + "integrity": "sha512-PwP4UY33SeeVKodNE37ZlOsR9cReypbMJOhZ7BVE0lB+Hix3efCOxiJWiE5Ia+yL9Cn2Ch72EjFTRze8RZsNtg==", + "dev": true, + "requires": { + "@types/sinonjs__fake-timers": "*" + } + }, + "@types/sinonjs__fake-timers": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.2.tgz", + "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", @@ -4681,6 +4632,12 @@ "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", "dev": true }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -5039,12 +4996,6 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, - "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true - }, "async": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", @@ -5072,12 +5023,6 @@ "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", "dev": true }, - "atob-lite": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", - "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=", - "dev": true - }, "axios": { "version": "0.21.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", @@ -5139,22 +5084,6 @@ "integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==", "dev": true }, - "big-integer": { - "version": "1.6.48", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.48.tgz", - "integrity": "sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w==", - "dev": true - }, - "binary": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", - "dev": true, - "requires": { - "buffers": "~0.1.1", - "chainsaw": "~0.1.0" - } - }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -5201,12 +5130,6 @@ } } }, - "bluebird": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=", - "dev": true - }, "bn.js": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", @@ -5318,12 +5241,6 @@ "base-x": "^3.0.2" } }, - "btoa-lite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", - "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=", - "dev": true - }, "buffer": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz", @@ -5345,23 +5262,11 @@ "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", "dev": true }, - "buffer-indexof-polyfill": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz", - "integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==", - "dev": true - }, "buffer-layout": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.0.tgz", "integrity": "sha512-iiyRoho/ERzBUv6kFvfsrLNgTlVwOkqQcSQN7WrO3Y+c5SeuEhCn6+y1KwhM0V3ndptF5mI/RI44zkw0qcR5Jg==" }, - "buffers": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=", - "dev": true - }, "bufferutil": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.3.tgz", @@ -5383,39 +5288,6 @@ "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", "dev": true }, - "cacheable-lookup": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-2.0.1.tgz", - "integrity": "sha512-EMMbsiOTcdngM/K6gV/OxF2x0t07+vMOWxZNSCRQMjO2MY2nhZQ6OYhOOpyQrbhqsgtvKGI7hcq6xjnA92USjg==", - "dev": true, - "requires": { - "@types/keyv": "^3.1.1", - "keyv": "^4.0.0" - } - }, - "cacheable-request": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz", - "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==", - "dev": true, - "requires": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^4.1.0", - "responselike": "^2.0.0" - }, - "dependencies": { - "normalize-url": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", - "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==", - "dev": true - } - } - }, "caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -5542,15 +5414,6 @@ "check-error": "^1.0.2" } }, - "chainsaw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", - "dev": true, - "requires": { - "traverse": ">=0.3.0 <0.4" - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -5562,12 +5425,6 @@ "supports-color": "^5.3.0" } }, - "charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", - "dev": true - }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -6245,6 +6102,12 @@ } } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -6310,12 +6173,6 @@ "which": "^1.2.9" } }, - "crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", - "dev": true - }, "crypto-hash": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", @@ -6389,15 +6246,6 @@ } } }, - "decompress-response": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-5.0.0.tgz", - "integrity": "sha512-TLZWWybuxWgoW7Lykv+gq9xvzOsUjQ9tF09Tj6NSTYGMTCHNXzrPnD6Hi+TgZq19PyTAGH4Ll/NIM/eTGglnMw==", - "dev": true, - "requires": { - "mimic-response": "^2.0.0" - } - }, "deep-eql": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", @@ -6441,12 +6289,6 @@ } } }, - "defer-to-connect": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz", - "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg==", - "dev": true - }, "define-properties": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", @@ -6619,12 +6461,6 @@ "readable-stream": "^2.0.2" } }, - "duplexer3": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", - "dev": true - }, "duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", @@ -6675,12 +6511,6 @@ "integrity": "sha512-Ot1pPtAVb5nd7jeVF651zmfLFilRVFomlDzwXmdlWe5jyzOGa6mVsQ06XnAurT7wWfg5VEIY+LopbAdD/bpo5w==", "dev": true }, - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -7310,16 +7140,6 @@ "pkg-dir": "^2.0.0" } }, - "eslint-plugin-flowtype": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-5.3.1.tgz", - "integrity": "sha512-mziJD+zw+VTwLtF9qLIxYac0GJCbSEDyqMLP5ENzQeNY5EOxbAfitMFLo+UItjYOISQdh1BCobwE2d4i1o+9Rw==", - "dev": true, - "requires": { - "lodash": "^4.17.15", - "string-natural-compare": "^3.0.1" - } - }, "eslint-plugin-import": { "version": "2.22.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", @@ -7970,146 +7790,6 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, - "flow-bin": { - "version": "0.130.0", - "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.130.0.tgz", - "integrity": "sha512-1TSLwCPXvKPwiae7Fh+dpipCzwlHQ1UcBHfCpQImz+hsxYIUWkLWJWEm34bY6I7dSM4ekSiVeP02BhzVJGwtpw==", - "dev": true - }, - "flow-parser": { - "version": "0.145.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.145.0.tgz", - "integrity": "sha512-dqpYiE0rZopmex5FR6pi/HTia8i+q/euc9WUWH6fTLt6sQgXjnAcsOwgMMLHCxwCSqPrvi/XFmBiicKitLNrKA==", - "dev": true - }, - "flow-remove-types": { - "version": "2.145.0", - "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.145.0.tgz", - "integrity": "sha512-P80u1yzJsiFu15+poHqoYbU/rcEqUcaI3NcR6kmPyAjgcrhPlxLi3/73tfg3C5FFl9+JR7+Xkv/PQYgg4yyCoQ==", - "dev": true, - "requires": { - "flow-parser": "^0.145.0", - "pirates": "^3.0.2", - "vlq": "^0.2.1" - }, - "dependencies": { - "pirates": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-3.0.2.tgz", - "integrity": "sha512-c5CgUJq6H2k6MJz72Ak1F5sN9n9wlSlJyEnwvpm9/y3WB4E3pHBDT2c6PEiS1vyJvq2bUxUAIu0EGf8Cx4Ic7Q==", - "dev": true, - "requires": { - "node-modules-regexp": "^1.0.0" - } - } - } - }, - "flow-typed": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flow-typed/-/flow-typed-3.3.1.tgz", - "integrity": "sha512-svxMNRJNTeKfOwBt/bPZvOrgkjpYH1nXC2v7dgbq4sZgZu/Slna6kAPD45fnOJ4D0TCS2B4yp6Nhc32AV1sxpQ==", - "dev": true, - "requires": { - "@octokit/rest": "^16.43.1", - "colors": "^1.4.0", - "flowgen": "^1.10.0", - "fs-extra": "^8.1.0", - "glob": "^7.1.6", - "got": "^10.5.7", - "md5": "^2.2.1", - "mkdirp": "^1.0.3", - "prettier": "^1.19.1", - "rimraf": "^3.0.2", - "semver": "7.3.2", - "table": "^5.4.6", - "through": "^2.3.8", - "unzipper": "^0.10.8", - "which": "^2.0.2", - "yargs": "^15.1.0" - }, - "dependencies": { - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", - "dev": true - }, - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true - }, - "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", - "dev": true, - "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, "flowgen": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/flowgen/-/flowgen-1.13.0.tgz", @@ -8266,29 +7946,6 @@ "dev": true, "optional": true }, - "fstream": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", - "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - }, - "dependencies": { - "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } - } - }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -8653,37 +8310,6 @@ } } }, - "got": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/got/-/got-10.7.0.tgz", - "integrity": "sha512-aWTDeNw9g+XqEZNcTjMMZSy7B7yE9toWOFYip7ofFTLleJhvZwUxxTxkTpKvF+p1SAA4VHmuEy7PiHTHyq8tJg==", - "dev": true, - "requires": { - "@sindresorhus/is": "^2.0.0", - "@szmarczak/http-timer": "^4.0.0", - "@types/cacheable-request": "^6.0.1", - "cacheable-lookup": "^2.0.0", - "cacheable-request": "^7.0.1", - "decompress-response": "^5.0.0", - "duplexer3": "^0.1.4", - "get-stream": "^5.0.0", - "lowercase-keys": "^2.0.0", - "mimic-response": "^2.1.0", - "p-cancelable": "^2.0.0", - "p-event": "^4.0.0", - "responselike": "^2.0.0", - "to-readable-stream": "^2.0.0", - "type-fest": "^0.10.0" - }, - "dependencies": { - "type-fest": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.10.0.tgz", - "integrity": "sha512-EUV9jo4sffrwlg8s0zDhP0T2WD3pru5Xi0+HTE3zTUmBaZNhfkite9PdSJwdXLwPVW0jnAHT56pZHIOYckPEiw==", - "dev": true - } - } - }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", @@ -8843,12 +8469,6 @@ "readable-stream": "^2.0.2" } }, - "http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", - "dev": true - }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -9095,12 +8715,6 @@ "binary-extensions": "^2.0.0" } }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, "is-builtin-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", @@ -9636,12 +9250,6 @@ "esprima": "^4.0.0" } }, - "json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -9674,15 +9282,6 @@ "minimist": "^1.2.5" } }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -9726,15 +9325,6 @@ "101": "^1.0.0" } }, - "keyv": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", - "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", - "dev": true, - "requires": { - "json-buffer": "3.0.1" - } - }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -9768,12 +9358,6 @@ "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", "dev": true }, - "listenercount": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", - "integrity": "sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc=", - "dev": true - }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -9909,12 +9493,6 @@ "integrity": "sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU=", "dev": true }, - "lodash.set": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", - "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=", - "dev": true - }, "lodash.some": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", @@ -9927,12 +9505,6 @@ "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", "dev": true }, - "lodash.uniq": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", - "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=", - "dev": true - }, "lodash.uniqby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz", @@ -10016,12 +9588,6 @@ } } }, - "lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", - "dev": true - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -10037,12 +9603,6 @@ "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", "dev": true }, - "macos-release": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.4.1.tgz", - "integrity": "sha512-H/QHeBIN1fIGJX517pvK8IEK53yQOW7YcEI55oYtgjDdoCQQz7eJS94qt5kNrscReEyuD/JcdFCm2XBEcGOITg==", - "dev": true - }, "magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", @@ -10076,6 +9636,12 @@ } } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "map-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.1.0.tgz", @@ -10185,17 +9751,6 @@ } } }, - "md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "dev": true, - "requires": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -10504,12 +10059,6 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, - "mimic-response": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", - "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", - "dev": true - }, "min-indent": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.0.tgz", @@ -15063,12 +14612,6 @@ } } }, - "octokit-pagination-methods": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz", - "integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==", - "dev": true - }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -15128,37 +14671,12 @@ "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==", "dev": true }, - "os-name": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-name/-/os-name-3.1.0.tgz", - "integrity": "sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg==", - "dev": true, - "requires": { - "macos-release": "^2.2.0", - "windows-release": "^3.1.0" - } - }, - "p-cancelable": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.0.0.tgz", - "integrity": "sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg==", - "dev": true - }, "p-each-series": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-2.2.0.tgz", "integrity": "sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA==", "dev": true }, - "p-event": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/p-event/-/p-event-4.2.0.tgz", - "integrity": "sha512-KXatOjCRXXkSePPb1Nbi0p0m+gQAwdlbhi4wQKJPI1HsMQS9g+Sqp2o+QHziPr7eYJyOZet836KoHEVM1mwOrQ==", - "dev": true, - "requires": { - "p-timeout": "^3.1.0" - } - }, "p-filter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/p-filter/-/p-filter-2.1.0.tgz", @@ -15220,15 +14738,6 @@ "retry": "^0.12.0" } }, - "p-timeout": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", - "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", - "dev": true, - "requires": { - "p-finally": "^1.0.0" - } - }, "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", @@ -15882,15 +15391,6 @@ "global-dirs": "^0.1.1" } }, - "responselike": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", - "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", - "dev": true, - "requires": { - "lowercase-keys": "^2.0.0" - } - }, "retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", @@ -16737,12 +16237,6 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", - "dev": true - }, "setprototypeof": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", @@ -16899,28 +16393,6 @@ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - } - } - }, "sort-keys": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", @@ -17226,40 +16698,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string-natural-compare": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz", - "integrity": "sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==", - "dev": true - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, "string.prototype.padend": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz", @@ -18091,24 +17529,12 @@ "integrity": "sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==", "dev": true }, - "to-readable-stream": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-2.1.0.tgz", - "integrity": "sha512-o3Qa6DGg1CEXshSdvWNX2sN4QHqg03SPq7U6jPXRahlQdl5dK8oXjkU/2/sGrnOZKeGV1zLSO8qPwyKklPPE7w==", - "dev": true - }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, - "traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=", - "dev": true - }, "trim-newlines": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.0.tgz", @@ -18121,6 +17547,20 @@ "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", "dev": true }, + "ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, "tsconfig-paths": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", @@ -18397,15 +17837,6 @@ "crypto-random-string": "^2.0.0" } }, - "universal-user-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz", - "integrity": "sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==", - "dev": true, - "requires": { - "os-name": "^3.1.0" - } - }, "universal-websocket-client": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/universal-websocket-client/-/universal-websocket-client-1.0.2.tgz", @@ -18428,44 +17859,12 @@ } } }, - "universalify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", - "dev": true - }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, - "unzipper": { - "version": "0.10.11", - "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.11.tgz", - "integrity": "sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw==", - "dev": true, - "requires": { - "big-integer": "^1.6.17", - "binary": "~0.3.0", - "bluebird": "~3.4.1", - "buffer-indexof-polyfill": "~1.0.0", - "duplexer2": "~0.1.4", - "fstream": "^1.0.12", - "graceful-fs": "^4.2.2", - "listenercount": "~1.0.1", - "readable-stream": "~2.3.6", - "setimmediate": "~1.0.4" - }, - "dependencies": { - "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true - } - } - }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -18544,12 +17943,6 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, - "vlq": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", - "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", - "dev": true - }, "vscode-textmate": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", @@ -18980,6 +18373,12 @@ "fd-slicer": "~1.1.0" } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/web3.js/package.json b/web3.js/package.json index ddd306e68..b778b3628 100644 --- a/web3.js/package.json +++ b/web3.js/package.json @@ -56,12 +56,8 @@ "codecov": "set -ex; npm run test:cover; cat ./coverage/lcov.info | codecov", "dev": "cross-env NODE_ENV=development rollup -c", "doc": "set -ex; typedoc", - "defs": "set -ex; flow check-contents < module.flow.js; tsc module.d.ts", "doc:watch": "watch 'npm run doc' . --wait=1 --ignoreDirectoryPattern=/doc/", "examples": "set -ex; for example in examples/*.js; do node $example; done", - "flow": "set -ex; flow stop; flow", - "flow:stop": "flow stop", - "flow:watch": "flow stop; watch 'flow' . --wait=1 --ignoreDirectoryPattern=/doc/", "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/", @@ -69,13 +65,13 @@ "localnet:logs": "bin/localnet.sh logs -f", "localnet:up": "bin/localnet.sh up", "localnet:update": "bin/localnet.sh update", - "ok": "run-s lint flow test doc defs", + "ok": "run-s lint test doc", "prepare": "run-s clean bpf-sdk:install bpf-sdk:remove-symlinks build", "pretty": "prettier --check '{,{examples,src,test}/**/}*.{j,t}s'", "pretty:fix": "prettier --write '{,{examples,src,test}/**/}*.{j,t}s'", "re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git", - "test": "npm run build:fixtures && mocha './test/**/*.test.js'", - "test:cover": "nyc --reporter=lcov mocha './test/**/*.test.js'", + "test": "npm run build:fixtures && mocha -r ts-node/register './test/**/*.test.ts'", + "test:cover": "nyc --reporter=lcov mocha './test/**/*.test.ts'", "test:browser": "TEST_LIVE=1 npm run build:fixtures && npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000", "test:browser-with-server": "start-server-and-test 'http-server -p 8080' 8080 test:browser", "test:browser-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:browser-with-server", @@ -116,9 +112,14 @@ "@solana/spl-token": "^0.0.13", "@types/bn.js": "^5.1.0", "@types/bs58": "^4.0.1", + "@types/chai": "^4.2.15", + "@types/chai-as-promised": "^7.1.3", + "@types/mocha": "^8.2.1", + "@types/mz": "^2.7.3", "@types/node": "^14.14.26", "@types/node-fetch": "^2.5.8", "@types/secp256k1": "^4.0.1", + "@types/sinon": "^9.0.11", "@typescript-eslint/eslint-plugin": "^4.14.2", "@typescript-eslint/parser": "^4.14.2", "chai": "^4.3.0", @@ -127,14 +128,10 @@ "cross-env": "7.0.3", "eslint": "^7.19.0", "eslint-config-prettier": "^8.0.0", - "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-mocha": "^8.0.0", "eslint-plugin-prettier": "^3.0.0", "esm": "^3.2.25", - "flow-bin": "0.130.0", - "flow-remove-types": "^2.143.1", - "flow-typed": "3.3.1", "flowgen": "^1.13.0", "http-server": "^0.12.3", "mocha": "^8.2.1", @@ -152,6 +149,7 @@ "semantic-release": "^17.0.2", "sinon": "^9.2.4", "start-server-and-test": "^1.12.0", + "ts-node": "^9.1.1", "tslib": "^2.1.0", "typedoc": "^0.20.31", "typescript": "^4.1.5", diff --git a/web3.js/rollup.config.js b/web3.js/rollup.config.js index 41b1dfa47..383268c7b 100644 --- a/web3.js/rollup.config.js +++ b/web3.js/rollup.config.js @@ -27,8 +27,8 @@ function generateConfig(configType, format) { }), generateTypescript ? typescript({ - browserslist: false, - }) + browserslist: false, + }) : undefined, babel({ exclude: '**/node_modules/**', diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 36c3922f4..4326ce10f 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -55,6 +55,12 @@ const BufferFromRawAccountData = coerce( value => Buffer.from(value[0], 'base64'), ); +/** + * Attempt to use a recent blockhash for up to 30 seconds + * @internal + */ +export const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000; + type RpcRequest = (methodName: string, args: Array) => any; export type TokenAccountsFilter = @@ -2578,8 +2584,6 @@ export class Connection { while (this._pollingBlockhash) { await sleep(100); } - // Attempt to use a recent blockhash for up to 30 seconds - const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000; const timeSinceFetch = Date.now() - this._blockhashInfo.lastFetch; const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS; if (this._blockhashInfo.recentBlockhash !== null && !expired) { diff --git a/web3.js/test/account.test.js b/web3.js/test/account.test.ts similarity index 100% rename from web3.js/test/account.test.js rename to web3.js/test/account.test.ts diff --git a/web3.js/test/agent-manager.test.js b/web3.js/test/agent-manager.test.ts similarity index 100% rename from web3.js/test/agent-manager.test.js rename to web3.js/test/agent-manager.test.ts diff --git a/web3.js/test/bpf-loader.test.js b/web3.js/test/bpf-loader.test.ts similarity index 99% rename from web3.js/test/bpf-loader.test.js rename to web3.js/test/bpf-loader.test.ts index b4aacd3de..4fb8c7eb8 100644 --- a/web3.js/test/bpf-loader.test.js +++ b/web3.js/test/bpf-loader.test.ts @@ -154,7 +154,7 @@ if (process.env.TEST_LIVE) { const {signatures, message} = parsedTx.transaction; expect(signatures[0]).to.eq(signature); const ix = message.instructions[0]; - if (ix.parsed) { + if ('parsed' in ix) { expect('parsed' in ix).to.eq(false); } else { expect(ix.programId).to.eql(program.publicKey); diff --git a/web3.js/test/cluster.test.js b/web3.js/test/cluster.test.ts similarity index 89% rename from web3.js/test/cluster.test.js rename to web3.js/test/cluster.test.ts index 0ff1dbdad..dba174e03 100644 --- a/web3.js/test/cluster.test.js +++ b/web3.js/test/cluster.test.ts @@ -5,8 +5,7 @@ import {clusterApiUrl} from '../src/util/cluster'; describe('Cluster Util', () => { it('invalid', () => { expect(() => { - // $FlowExpectedError - clusterApiUrl('abc123'); + clusterApiUrl('abc123' as any); }).to.throw(); }); diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.ts similarity index 96% rename from web3.js/test/connection.test.js rename to web3.js/test/connection.test.ts index 2f304c9bd..1873030cd 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.ts @@ -1,4 +1,5 @@ import bs58 from 'bs58'; +import invariant from 'assert'; import {Buffer} from 'buffer'; import {Token, u64} from '@solana/spl-token'; import {expect, use} from 'chai'; @@ -18,7 +19,17 @@ import { } from '../src'; import {DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND} from '../src/timing'; import {MOCK_PORT, url} from './url'; -import {BLOCKHASH_CACHE_TIMEOUT_MS} from '../src/connection'; +import { + BLOCKHASH_CACHE_TIMEOUT_MS, + Commitment, + CompiledInnerInstruction, + EpochInfo, + EpochSchedule, + InflationGovernor, + ParsedInnerInstruction, + ParsedInstruction, + SlotInfo, +} from '../src/connection'; import {sleep} from '../src/util/sleep'; import { helpers, @@ -66,14 +77,15 @@ describe('Connection', () => { connection = new Connection(url); }); - if (!process.env.TEST_LIVE) { + if (mockServer) { + const server = mockServer; beforeEach(() => { - mockServer.start(MOCK_PORT); + server.start(MOCK_PORT); stubRpcWebSocket(connection); }); afterEach(() => { - mockServer.stop(); + server.stop(); restoreRpcWebSocket(connection); }); } @@ -289,14 +301,15 @@ describe('Connection', () => { }); const inflation = await connection.getInflationGovernor(); - - for (const key of [ + const inflationKeys: (keyof InflationGovernor)[] = [ 'initial', 'terminal', 'taper', 'foundation', 'foundationTerm', - ]) { + ]; + + for (const key of inflationKeys) { expect(inflation).to.have.property(key); expect(inflation[key]).to.be.greaterThan(0); } @@ -316,14 +329,15 @@ describe('Connection', () => { }); const epochInfo = await connection.getEpochInfo('confirmed'); - - for (const key of [ + const epochInfoKeys: (keyof EpochInfo)[] = [ 'epoch', 'slotIndex', 'slotsInEpoch', 'absoluteSlot', 'blockHeight', - ]) { + ]; + + for (const key of epochInfoKeys) { expect(epochInfo).to.have.property(key); expect(epochInfo[key]).to.be.at.least(0); } @@ -343,13 +357,14 @@ describe('Connection', () => { }); const epochSchedule = await connection.getEpochSchedule(); - - for (const key of [ + const epochScheduleKeys: (keyof EpochSchedule)[] = [ 'firstNormalEpoch', 'firstNormalSlot', 'leaderScheduleSlotOffset', 'slotsPerEpoch', - ]) { + ]; + + for (const key of epochScheduleKeys) { expect(epochSchedule).to.have.property('warmup'); expect(epochSchedule).to.have.property(key); if (epochSchedule.warmup) { @@ -385,7 +400,7 @@ describe('Connection', () => { }); const slot = await connection.getSlot(); - if (!process.env.TEST_LIVE) { + if (mockServer) { expect(slot).to.eq(123); } else { // No idea what the correct slot value should be on a live cluster, so @@ -402,7 +417,7 @@ describe('Connection', () => { }); const slotLeader = await connection.getSlotLeader(); - if (!process.env.TEST_LIVE) { + if (mockServer) { expect(slotLeader).to.eq('11111111111111111111111111111111'); } else { // No idea what the correct slotLeader value should be on a live cluster, so @@ -427,7 +442,7 @@ describe('Connection', () => { }); const clusterNodes = await connection.getClusterNodes(); - if (!process.env.TEST_LIVE) { + if (mockServer) { expect(clusterNodes).to.have.length(1); expect(clusterNodes[0].pubkey).to.eq('11111111111111111111111111111111'); expect(typeof clusterNodes[0].gossip).to.eq('string'); @@ -564,8 +579,8 @@ describe('Connection', () => { // Find a block that has a transaction, usually Block 1 let slot = 0; - let address: ?PublicKey; - let expectedSignature: ?string; + let address: PublicKey | undefined; + let expectedSignature: string | undefined; while (!address || !expectedSignature) { slot++; const block = await connection.getConfirmedBlock(slot); @@ -628,7 +643,7 @@ describe('Connection', () => { {limit: 1}, ); expect(confirmedSignatures2).to.have.length(1); - if (!process.env.TEST_LIVE) { + if (mockServer) { expect(confirmedSignatures2[0].signature).to.eq(expectedSignature); expect(confirmedSignatures2[0].slot).to.eq(slot); expect(confirmedSignatures2[0].err).to.be.null; @@ -699,7 +714,7 @@ describe('Connection', () => { // Find a block that has a transaction, usually Block 1 let slot = 0; - let confirmedTransaction: ?string; + let confirmedTransaction: string | undefined; while (!confirmedTransaction) { slot++; const block = await connection.getConfirmedBlock(slot); @@ -791,12 +806,12 @@ describe('Connection', () => { expect(nullResponse).to.be.null; }); - if (!process.env.TEST_LIVE) { + if (mockServer) { it('get parsed confirmed transaction coerces public keys of inner instructions', async () => { const confirmedTransaction: TransactionSignature = '4ADvAUQYxkh4qWKYE9QLW8gCLomGG94QchDLG4quvpBz1WqARYvzWQDDitKduAKspuy1DjcbnaDAnCAfnKpJYs48'; - function getMockData(inner) { + function getMockData(inner: any) { return { slot: 353050305, transaction: { @@ -853,15 +868,10 @@ describe('Connection', () => { confirmedTransaction, ); - if ( - result !== null && - result.meta && - result.meta.innerInstructions !== undefined && - result.meta.innerInstructions.length > 0 - ) { - expect( - result.meta.innerInstructions[0].instructions[0].programId, - ).to.be.instanceOf(PublicKey); + if (result && result.meta && result.meta.innerInstructions) { + const innerInstructions = result.meta.innerInstructions; + const firstIx = innerInstructions[0].instructions[0]; + expect(firstIx.programId).to.be.instanceOf(PublicKey); } await mockRpcResponse({ @@ -877,15 +887,21 @@ describe('Connection', () => { }), }); - //$FlowFixMe const result2 = await connection.getParsedConfirmedTransaction( confirmedTransaction, ); - let instruction = result2.meta.innerInstructions[0].instructions[0]; - expect(instruction.programId).to.be.instanceOf(PublicKey); - expect(instruction.accounts[0]).to.be.instanceOf(PublicKey); - expect(instruction.accounts[1]).to.be.instanceOf(PublicKey); + if (result2 && result2.meta && result2.meta.innerInstructions) { + const innerInstructions = result2.meta.innerInstructions; + const instruction = innerInstructions[0].instructions[0]; + expect(instruction.programId).to.be.instanceOf(PublicKey); + if ('accounts' in instruction) { + expect(instruction.accounts[0]).to.be.instanceOf(PublicKey); + expect(instruction.accounts[1]).to.be.instanceOf(PublicKey); + } else { + expect('accounts' in instruction).to.be.true; + } + } }); } @@ -998,7 +1014,8 @@ describe('Connection', () => { }); it('get recent blockhash', async () => { - for (const commitment of ['processed', 'confirmed', 'finalized']) { + const commitments: Commitment[] = ['processed', 'confirmed', 'finalized']; + for (const commitment of commitments) { const {blockhash, feeCalculator} = await helpers.recentBlockhash({ connection, commitment, @@ -1189,7 +1206,7 @@ describe('Connection', () => { testOwner = accountOwner; testToken = token; - testTokenAccount = tokenAccount; + testTokenAccount = tokenAccount as PublicKey; }); it('get token supply', async () => { @@ -1229,7 +1246,7 @@ describe('Connection', () => { const {signatures, message} = parsedTx.transaction; expect(signatures[0]).to.eq(testSignature); const ix = message.instructions[0]; - if (ix.parsed) { + if ('parsed' in ix) { expect(ix.program).to.eq('spl-token'); expect(ix.programId).to.eql(TOKEN_PROGRAM_ID); } else { @@ -1456,11 +1473,11 @@ describe('Connection', () => { }); } - if (!process.env.TEST_LIVE) { + if (mockServer) { it('stake activation should only accept state with valid string literals', async () => { const publicKey = new Account().publicKey; - const addStakeActivationMock = async state => { + const addStakeActivationMock = async (state: any) => { await mockRpcResponse({ method: 'getStakeActivation', params: [publicKey.toBase58(), {}], @@ -1567,7 +1584,7 @@ describe('Connection', () => { if (parsedAccountInfo === null) { expect(parsedAccountInfo).not.to.be.null; return; - } else if (parsedAccountInfo.data.parsed) { + } else if ('parsed' in parsedAccountInfo.data) { expect(parsedAccountInfo.data.parsed).not.to.be.ok; return; } @@ -1616,6 +1633,7 @@ describe('Connection', () => { ).value; expect(confirmResult.err).to.eql(expectedErr); + invariant(transaction.signature); const signature = bs58.encode(transaction.signature); await mockRpcResponse({ method: 'getSignatureStatuses', @@ -1814,7 +1832,7 @@ describe('Connection', () => { }); // it('account change notification', async () => { - // if (!process.env.TEST_LIVE) { + // if (mockServer) { // console.log('non-live test skipped'); // return; // } @@ -1939,7 +1957,7 @@ describe('Connection', () => { }); it('slot notification', async () => { - let notifiedSlotInfo; + let notifiedSlotInfo: SlotInfo | undefined; const subscriptionId = connection.onSlotChange(slotInfo => { notifiedSlotInfo = slotInfo; }); @@ -1963,7 +1981,7 @@ describe('Connection', () => { }); it('root notification', async () => { - let roots = []; + let roots: number[] = []; const subscriptionId = connection.onRootChange(root => { roots.push(root); }); diff --git a/web3.js/test/mocks/rpc-http.js b/web3.js/test/mocks/rpc-http.ts similarity index 80% rename from web3.js/test/mocks/rpc-http.js rename to web3.js/test/mocks/rpc-http.ts index 15804c19a..60fec16b6 100644 --- a/web3.js/test/mocks/rpc-http.js +++ b/web3.js/test/mocks/rpc-http.ts @@ -1,20 +1,21 @@ import bs58 from 'bs58'; import BN from 'bn.js'; +import invariant from 'assert'; import * as mockttp from 'mockttp'; import {mockRpcMessage} from './rpc-websockets'; import {Account, Connection, PublicKey, Transaction} from '../../src'; import type {Commitment} from '../../src/connection'; -export const mockServer: mockttp.Mockttp = - process.env.TEST_LIVE || mockttp.getLocal(); +export const mockServer: mockttp.Mockttp | undefined = + process.env.TEST_LIVE === undefined ? mockttp.getLocal() : undefined; let uniqueCounter = 0; export const uniqueSignature = () => { - return bs58.encode(new BN(++uniqueCounter).toArray(null, 64)); + return bs58.encode(new BN(++uniqueCounter).toArray(undefined, 64)); }; export const uniqueBlockhash = () => { - return bs58.encode(new BN(++uniqueCounter).toArray(null, 32)); + return bs58.encode(new BN(++uniqueCounter).toArray(undefined, 32)); }; export const mockErrorMessage = 'Invalid'; @@ -30,13 +31,13 @@ export const mockRpcResponse = async ({ error, withContext, }: { - method: string, - params: Array, - value?: any, - error?: any, - withContext?: boolean, + method: string; + params: Array; + value?: any; + error?: any; + withContext?: boolean; }) => { - if (process.env.TEST_LIVE) return; + if (!mockServer) return; let result = value; if (withContext) { @@ -70,8 +71,8 @@ const recentBlockhash = async ({ connection, commitment, }: { - connection: Connection, - commitment?: Commitment, + connection: Connection; + commitment?: Commitment; }) => { const blockhash = uniqueBlockhash(); const params = []; @@ -101,17 +102,18 @@ const processTransaction = async ({ commitment, err, }: { - connection: Connection, - transaction: Transaction, - signers: Array, - commitment: Commitment, - err?: any, + connection: Connection; + transaction: Transaction; + signers: Array; + commitment: Commitment; + err?: any; }) => { const blockhash = (await recentBlockhash({connection})).blockhash; transaction.recentBlockhash = blockhash; transaction.sign(...signers); const encoded = transaction.serialize().toString('base64'); + invariant(transaction.signature !== null); const signature = bs58.encode(transaction.signature); await mockRpcResponse({ method: 'sendTransaction', @@ -146,9 +148,9 @@ const airdrop = async ({ address, amount, }: { - connection: Connection, - address: PublicKey, - amount: number, + connection: Connection; + address: PublicKey; + amount: number; }) => { await mockRpcResponse({ method: 'requestAirdrop', diff --git a/web3.js/test/mocks/rpc-websockets.js b/web3.js/test/mocks/rpc-websockets.ts similarity index 83% rename from web3.js/test/mocks/rpc-websockets.js rename to web3.js/test/mocks/rpc-websockets.ts index 6e68f9081..27ec346ec 100644 --- a/web3.js/test/mocks/rpc-websockets.js +++ b/web3.js/test/mocks/rpc-websockets.ts @@ -5,15 +5,15 @@ import sinon from 'sinon'; import {Connection} from '../../src'; type RpcRequest = { - method: string, - params?: Array, + method: string; + params?: Array; }; type RpcResponse = { context: { - slot: number, - }, - value: any, + slot: number; + }; + value: any; }; const mockRpcSocket: Array<[RpcRequest, RpcResponse]> = []; @@ -24,9 +24,9 @@ export const mockRpcMessage = ({ params, result, }: { - method: string, - params: Array, - result: any, + method: string; + params: Array; + result: any; }) => { mockRpcSocket.push([ {method, params}, @@ -46,9 +46,11 @@ export const stubRpcWebSocket = (connection: Connection) => { sandbox.stub(rpcWebSocket, 'close').callsFake(() => { mockClient.close(); }); - sandbox.stub(rpcWebSocket, 'call').callsFake((method, params) => { - return mockClient.call(method, params); - }); + sandbox + .stub(rpcWebSocket, 'call') + .callsFake((method: string, params: any) => { + return mockClient.call(method, params); + }); }; export const restoreRpcWebSocket = (connection: Connection) => { @@ -85,7 +87,10 @@ class MockClient { call(method: string, params: Array): Promise { expect(mockRpcSocket.length).to.be.at.least(1); - const [mockRequest, mockResponse] = mockRpcSocket.shift(); + const [mockRequest, mockResponse] = mockRpcSocket.shift() as [ + RpcRequest, + RpcResponse, + ]; expect(method).to.eq(mockRequest.method); expect(params).to.eql(mockRequest.params); diff --git a/web3.js/test/nonce.test.js b/web3.js/test/nonce.test.ts similarity index 97% rename from web3.js/test/nonce.test.js rename to web3.js/test/nonce.test.ts index ae4c185d9..797616f26 100644 --- a/web3.js/test/nonce.test.js +++ b/web3.js/test/nonce.test.ts @@ -31,14 +31,15 @@ describe('Nonce', () => { connection = new Connection(url); }); - if (!process.env.TEST_LIVE) { + if (mockServer) { + const server = mockServer; beforeEach(() => { - mockServer.start(MOCK_PORT); + server.start(MOCK_PORT); stubRpcWebSocket(connection); }); afterEach(() => { - mockServer.stop(); + server.stop(); restoreRpcWebSocket(connection); }); } diff --git a/web3.js/test/publickey.test.js b/web3.js/test/publickey.test.ts similarity index 100% rename from web3.js/test/publickey.test.js rename to web3.js/test/publickey.test.ts diff --git a/web3.js/test/rollup.config.js b/web3.js/test/rollup.config.js index 74a0c34fc..488af9254 100644 --- a/web3.js/test/rollup.config.js +++ b/web3.js/test/rollup.config.js @@ -1,17 +1,18 @@ import alias from '@rollup/plugin-alias'; import babel from '@rollup/plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; -import flowRemoveTypes from 'flow-remove-types'; import json from '@rollup/plugin-json'; import multi from '@rollup/plugin-multi-entry'; import nodeResolve from '@rollup/plugin-node-resolve'; import nodePolyfills from 'rollup-plugin-node-polyfills'; import replace from '@rollup/plugin-replace'; +const extensions = ['.js', '.ts']; + export default { input: { - include: ['test/**/*.test.js'], - exclude: ['test/agent-manager.test.js', 'test/bpf-loader.test.js'], + include: ['test/**/*.test.ts'], + exclude: ['test/agent-manager.test.ts', 'test/bpf-loader.test.ts'], }, external: ['node-forge', 'http2', '_stream_wrap'], output: { @@ -20,16 +21,17 @@ export default { sourcemap: true, }, plugins: [ - flow(), multi(), commonjs(), nodeResolve({ browser: true, preferBuiltins: false, + extensions, dedupe: ['bn.js', 'buffer'], }), babel({ exclude: '**/node_modules/**', + extensions, babelHelpers: 'runtime', plugins: ['@babel/plugin-transform-runtime'], }), @@ -54,18 +56,6 @@ export default { } }, treeshake: { - moduleSideEffects: path => path.endsWith('test.js'), + moduleSideEffects: path => path.endsWith('test.ts'), }, }; - -// Using this instead of rollup-plugin-flow due to -// https://github.com/leebyron/rollup-plugin-flow/issues/5 -function flow() { - return { - name: 'flow-remove-types', - transform: code => ({ - code: flowRemoveTypes(code).toString(), - map: null, - }), - }; -} diff --git a/web3.js/test/secp256k1-program.test.js b/web3.js/test/secp256k1-program.test.ts similarity index 100% rename from web3.js/test/secp256k1-program.test.js rename to web3.js/test/secp256k1-program.test.ts diff --git a/web3.js/test/shortvec-encoding.test.js b/web3.js/test/shortvec-encoding.test.ts similarity index 93% rename from web3.js/test/shortvec-encoding.test.js rename to web3.js/test/shortvec-encoding.test.ts index 4cc711a0c..f807017ca 100644 --- a/web3.js/test/shortvec-encoding.test.js +++ b/web3.js/test/shortvec-encoding.test.ts @@ -21,7 +21,7 @@ function checkEncodedArray( describe('shortvec', () => { it('decodeLength', () => { - let array = []; + let array: number[] = []; checkDecodedArray(array, 0); array = [5]; @@ -47,7 +47,7 @@ describe('shortvec', () => { }); it('encodeLength', () => { - let array = []; + let array: number[] = []; let prevLength = 1; checkEncodedArray(array, 0, prevLength, 1, [0]); @@ -63,7 +63,7 @@ describe('shortvec', () => { checkEncodedArray(array, 0x7fff, (prevLength += 3), 3, [0xff, 0xff, 0x01]); - prevLength = checkEncodedArray(array, 0x200000, (prevLength += 4), 4, [ + checkEncodedArray(array, 0x200000, (prevLength += 4), 4, [ 0x80, 0x80, 0x80, diff --git a/web3.js/test/stake-program.test.js b/web3.js/test/stake-program.test.ts similarity index 100% rename from web3.js/test/stake-program.test.js rename to web3.js/test/stake-program.test.ts diff --git a/web3.js/test/system-program.test.js b/web3.js/test/system-program.test.ts similarity index 100% rename from web3.js/test/system-program.test.js rename to web3.js/test/system-program.test.ts diff --git a/web3.js/test/transaction-payer.test.js b/web3.js/test/transaction-payer.test.ts similarity index 94% rename from web3.js/test/transaction-payer.test.js rename to web3.js/test/transaction-payer.test.ts index 313f89eb0..a57edca49 100644 --- a/web3.js/test/transaction-payer.test.js +++ b/web3.js/test/transaction-payer.test.ts @@ -1,4 +1,5 @@ import base58 from 'bs58'; +import invariant from 'assert'; import {expect} from 'chai'; import { @@ -18,14 +19,15 @@ describe('Transaction Payer', () => { connection = new Connection(url); }); - if (!process.env.TEST_LIVE) { + if (mockServer) { + const server = mockServer; beforeEach(() => { - mockServer.start(MOCK_PORT); + server.start(MOCK_PORT); stubRpcWebSocket(connection); }); afterEach(() => { - mockServer.stop(); + server.stop(); restoreRpcWebSocket(connection); }); } @@ -76,6 +78,7 @@ describe('Transaction Payer', () => { commitment: 'confirmed', }); + invariant(transaction.signature); const signature = base58.encode(transaction.signature); await mockRpcResponse({ diff --git a/web3.js/test/transaction.test.js b/web3.js/test/transaction.test.ts similarity index 96% rename from web3.js/test/transaction.test.js rename to web3.js/test/transaction.test.ts index e34b187ce..25be2b6dd 100644 --- a/web3.js/test/transaction.test.js +++ b/web3.js/test/transaction.test.ts @@ -1,4 +1,5 @@ import bs58 from 'bs58'; +import invariant from 'assert'; import {Buffer} from 'buffer'; import nacl from 'tweetnacl'; import {expect} from 'chai'; @@ -9,6 +10,7 @@ import {Transaction} from '../src/transaction'; import {StakeProgram} from '../src/stake-program'; import {SystemProgram} from '../src/system-program'; import {Message} from '../src/message'; +import {toBuffer} from '../src/util/to-buffer'; describe('Transaction', () => { describe('compileMessage', () => { @@ -160,22 +162,17 @@ describe('Transaction', () => { expect(partialTransaction).to.eql(transaction); - if ( - partialTransaction.signatures[0].signature != null /* <-- pacify flow */ - ) { - partialTransaction.signatures[0].signature[0] = 0; - expect(() => - partialTransaction.serialize({requireAllSignatures: false}), - ).to.throw(); - expect(() => - partialTransaction.serialize({ - verifySignatures: false, - requireAllSignatures: false, - }), - ).not.to.throw(); - } else { - throw new Error('unreachable'); - } + invariant(partialTransaction.signatures[0].signature); + partialTransaction.signatures[0].signature[0] = 0; + expect(() => + partialTransaction.serialize({requireAllSignatures: false}), + ).to.throw(); + expect(() => + partialTransaction.serialize({ + verifySignatures: false, + requireAllSignatures: false, + }), + ).not.to.throw(); }); describe('dedupe', () => { @@ -261,7 +258,6 @@ describe('Transaction', () => { const newTransaction = new Transaction({ recentBlockhash: orgTransaction.recentBlockhash, - feePayer: orgTransaction.feePayer, signatures: orgTransaction.signatures, }).add(transfer1, transfer2); @@ -451,7 +447,7 @@ describe('Transaction', () => { // Serializing the message is allowed when signature array has null signatures expectedTransaction.serializeMessage(); - expectedTransaction.feePayer = null; + expectedTransaction.feePayer = undefined; expectedTransaction.setSigners(sender.publicKey); expect(expectedTransaction.signatures).to.have.length(1); @@ -510,7 +506,7 @@ describe('Transaction', () => { tx.setSigners(from.publicKey); const tx_bytes = tx.serializeMessage(); const signature = nacl.sign.detached(tx_bytes, from.secretKey); - tx.addSignature(from.publicKey, signature); + tx.addSignature(from.publicKey, toBuffer(signature)); expect(tx.verifySignatures()).to.be.true; }); @@ -532,7 +528,7 @@ describe('Transaction', () => { tx.feePayer = from.publicKey; const tx_bytes = tx.serializeMessage(); const signature = nacl.sign.detached(tx_bytes, from.secretKey); - tx.addSignature(from.publicKey, signature); + tx.addSignature(from.publicKey, toBuffer(signature)); expect(tx.verifySignatures()).to.be.true; }); }); diff --git a/web3.js/test/url.js b/web3.js/test/url.ts similarity index 100% rename from web3.js/test/url.js rename to web3.js/test/url.ts diff --git a/web3.js/test/validator-info.test.js b/web3.js/test/validator-info.test.ts similarity index 100% rename from web3.js/test/validator-info.test.js rename to web3.js/test/validator-info.test.ts diff --git a/web3.js/test/websocket.test.js b/web3.js/test/websocket.test.ts similarity index 100% rename from web3.js/test/websocket.test.js rename to web3.js/test/websocket.test.ts diff --git a/web3.js/tsconfig.json b/web3.js/tsconfig.json index 9dc0b9d82..987383d15 100644 --- a/web3.js/tsconfig.json +++ b/web3.js/tsconfig.json @@ -16,7 +16,11 @@ "isolatedModules": true, "baseUrl": "src", "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true + "noImplicitReturns": true, + "paths": { + // This is needed so that @solana/spl-token's @solana/web3.js doesn't conflict + "@solana/web3.js": ["."] + } }, "include": ["src"] }