From f4719818e92d508d79feaa7d90b573b18f04f25e Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Wed, 16 Oct 2019 16:04:39 +0900 Subject: [PATCH 1/5] receipt is missing on error event (#3129) * receipt added for error event listener on sending of a transaction * packages updated in package-lock because of security warnings from npm * passing of parameters to _fireError updated in Method object of the web3-core-method module * CHANGELOG.md updated * documentation for sendTransaction and contract.methods.myMethod.send() updated * Update packages/web3-core-method/src/index.js Co-Authored-By: cgewecke * Update docs/web3-eth.rst Co-Authored-By: cgewecke * wrongly passed parameters for the _fireError function fixed * Update docs/web3-eth-contract.rst Co-Authored-By: cgewecke --- CHANGELOG.md | 1 + docs/web3-eth-contract.rst | 2 +- docs/web3-eth.rst | 2 +- package-lock.json | 104 ++++++++++++------------- packages/web3-core-method/src/index.js | 55 ++++++++++--- packages/web3-utils/src/index.js | 7 +- 6 files changed, 102 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7b997fa2ed..17de47e063a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,3 +74,4 @@ Released with 1.0.0-beta.37 code base. - Gas check fixed (#2381) - Signing issues #1998, #2033, and #1074 fixed (#3125) - Fix hexToNumber and hexToNumberString prefix validation (#3086) +- The receipt will now returned on a EVM error (this got removed on beta.18) (#3129) diff --git a/docs/web3-eth-contract.rst b/docs/web3-eth-contract.rst index de710fba48c..98e7e756ea2 100644 --- a/docs/web3-eth-contract.rst +++ b/docs/web3-eth-contract.rst @@ -543,7 +543,7 @@ The **callback** will return the 32 bytes transaction hash. - ``"transactionHash"`` returns ``String``: is fired right after the transaction is sent and a transaction hash is available. - ``"receipt"`` returns ``Object``: is fired when the transaction *receipt* is available. Receipts from contracts will have no ``logs`` property, but instead an ``events`` property with event names as keys and events as properties. See :ref:`getPastEvents return values ` for details about the returned event object. - ``"confirmation"`` returns ``Number``, ``Object``: is fired for every confirmation up to the 24th confirmation. Receives the confirmation number as the first and the receipt as the second argument. Fired from confirmation 1 on, which is the block where it's minded. -- ``"error"`` returns ``Error``: is fired if an error occurs during sending. If a out of gas error, the second parameter is the receipt. +``"error"`` returns ``Error`` and ``Object|undefined``: Is fired if an error occurs during sending. If the transaction was rejected by the network with a receipt, the second parameter will be the receipt. ------- diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index 6b86ab07ffe..a35450e03fa 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -1010,7 +1010,7 @@ The **callback** will return the 32 bytes transaction hash. - ``"transactionHash"`` returns ``String``: Is fired right after the transaction is sent and a transaction hash is available. - ``"receipt"`` returns ``Object``: Is fired when the transaction receipt is available. - ``"confirmation"`` returns ``Number``, ``Object``: Is fired for every confirmation up to the 12th confirmation. Receives the confirmation number as the first and the :ref:`receipt ` as the second argument. Fired from confirmation 0 on, which is the block where its minded. -- ``"error"`` returns ``Error``: Is fired if an error occurs during sending. If a out of gas error, the second parameter is the receipt. +``"error"`` returns ``Error`` and ``Object|undefined``: Is fired if an error occurs during sending. If the transaction was rejected by the network with a receipt, the second parameter will be the receipt. ------- diff --git a/package-lock.json b/package-lock.json index d9f460f0ead..646f880cf42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4424,7 +4424,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -4448,13 +4449,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4471,19 +4474,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4614,7 +4620,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4628,6 +4635,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4644,6 +4652,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4652,13 +4661,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": false, "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4679,6 +4690,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4767,7 +4779,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4781,6 +4794,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4876,7 +4890,8 @@ "version": "5.1.2", "resolved": false, "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4918,6 +4933,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4939,6 +4955,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4987,13 +5004,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": false, "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -6509,9 +6528,9 @@ } }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.3.tgz", + "integrity": "sha512-B0W4A2U1ww3q7VVthTKfh+epHx+q4mCt6iK+zEAzbMBpWQAwxCeKxEGpj/1oQTpzPXDNSOG7hmG14TsISH50yw==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -8084,9 +8103,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, "lodash._reinterpolate": { @@ -8120,9 +8139,9 @@ "dev": true }, "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, "lodash.template": { @@ -8597,9 +8616,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -10633,9 +10652,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -11749,38 +11768,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-stream": { @@ -12515,7 +12511,7 @@ "requires": { "underscore": "1.9.1", "web3-core-helpers": "1.2.1", - "websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e" + "websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" } }, "web3-shh": { diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index a67c62a2dcc..6948332214f 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -257,7 +257,14 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { .catch(function (err) { sub.unsubscribe(); promiseResolved = true; - utils._fireError({message: 'Failed to check for transaction receipt:', data: err}, defer.eventEmitter, defer.reject); + utils._fireError( + { + message: 'Failed to check for transaction receipt:', + data: err + }, + defer.eventEmitter, + defer.reject + ); }) // if CONFIRMATION listener exists check for confirmations, by setting canUnsubscribe = false .then(function(receipt) { @@ -303,7 +310,13 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { promiseResolved = true; } - utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.eventEmitter, defer.reject); + utils._fireError( + new Error('The transaction receipt didn\'t contain a contract address.'), + defer.eventEmitter, + defer.reject, + null, + receipt + ); return; } @@ -330,7 +343,13 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { } } else { - utils._fireError(new Error('The contract code couldn\'t be stored, please check your gas limit.'), defer.eventEmitter, defer.reject); + utils._fireError( + new Error('The contract code couldn\'t be stored, please check your gas limit.'), + defer.eventEmitter, + defer.reject, + null, + receipt + ); } if (canUnsubscribe) { @@ -344,9 +363,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { }) // CHECK for normal tx check for receipt only .then(function(receipt) { - if (!isContractDeployment && !promiseResolved) { - if(!receipt.outOfGas && (!gasProvided || gasProvided !== utils.numberToHex(receipt.gasUsed)) && (receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) { @@ -360,13 +377,23 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { } else { receiptJSON = JSON.stringify(receipt, null, 2); + if (receipt.status === false || receipt.status === '0x0') { - utils._fireError(new Error("Transaction has been reverted by the EVM:\n" + receiptJSON), - defer.eventEmitter, defer.reject); + utils._fireError( + new Error("Transaction has been reverted by the EVM:\n" + receiptJSON), + defer.eventEmitter, + defer.reject, + null, + receipt + ); } else { utils._fireError( new Error("Transaction ran out of gas. Please provide more gas:\n" + receiptJSON), - defer.eventEmitter, defer.reject); + defer.eventEmitter, + defer.reject, + null, + receipt + ); } } @@ -387,13 +414,21 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { if (timeoutCount - 1 >= POLLINGTIMEOUT) { sub.unsubscribe(); promiseResolved = true; - utils._fireError(new Error('Transaction was not mined within' + POLLINGTIMEOUT + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); + utils._fireError( + new Error('Transaction was not mined within ' + POLLINGTIMEOUT + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), + defer.eventEmitter, + defer.reject + ); } } else { if (timeoutCount - 1 >= TIMEOUTBLOCK) { sub.unsubscribe(); promiseResolved = true; - utils._fireError(new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); + utils._fireError( + new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), + defer.eventEmitter, + defer.reject + ); } } }); diff --git a/packages/web3-utils/src/index.js b/packages/web3-utils/src/index.js index 2736c07ef25..a1e3758d02b 100644 --- a/packages/web3-utils/src/index.js +++ b/packages/web3-utils/src/index.js @@ -38,9 +38,10 @@ var randombytes = require('randombytes'); * @param {Object} emitter * @param {Function} reject * @param {Function} callback + * @param {any} optionalData * @return {Object} the emitter */ -var _fireError = function (error, emitter, reject, callback) { +var _fireError = function (error, emitter, reject, callback, optionalData) { /*jshint maxcomplexity: 10 */ // add data if given @@ -57,7 +58,7 @@ var _fireError = function (error, emitter, reject, callback) { } if (_.isFunction(callback)) { - callback(error); + callback(error, optionalData); } if (_.isFunction(reject)) { // suppress uncatched error if an error listener is present @@ -76,7 +77,7 @@ var _fireError = function (error, emitter, reject, callback) { if(emitter && _.isFunction(emitter.emit)) { // emit later, to be able to return emitter setTimeout(function () { - emitter.emit('error', error); + emitter.emit('error', error, optionalData); emitter.removeAllListeners(); }, 1); } From d25d90b13febecea0dadde480bb6d6af5113aa39 Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Wed, 16 Oct 2019 12:03:15 +0200 Subject: [PATCH 2/5] The transaction confirmation workflow can now be configured (#3130) * transactionBlockTimeout, transactionConfirmationBlock, and transactionPollingTimeout property added to the Eth, Contract, and Method class * CHANGELOG.md updated * documentation updated * default values added to the documentation for the newely introduced transaction fconfirmation workflow configuration properties * test cases for the new properties added and adding of the Contract reference in the Eth module fixed * missing space added * Update docs/web3-eth.rst Co-Authored-By: cgewecke * Update docs/web3-eth-contract.rst Co-Authored-By: cgewecke --- CHANGELOG.md | 1 + docs/web3-eth-contract.rst | 148 ++++++++++++++++++++++ docs/web3-eth.rst | 63 +++++++++ packages/web3-bzz/package-lock.json | 4 +- packages/web3-core-method/src/index.js | 21 ++- packages/web3-eth-contract/src/index.js | 6 + packages/web3-eth/src/index.js | 60 +++++++++ test/eth.transactionBlockTimeout.js | 25 ++++ test/eth.transactionConfirmationBlocks.js | 25 ++++ test/eth.transactionPollingTimeout.js | 25 ++++ 10 files changed, 366 insertions(+), 12 deletions(-) create mode 100644 test/eth.transactionBlockTimeout.js create mode 100644 test/eth.transactionConfirmationBlocks.js create mode 100644 test/eth.transactionPollingTimeout.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 17de47e063a..3d2750752e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Released with 1.0.0-beta.37 code base. - getNetworkType method extended with Görli testnet (#3095) - supportsSubscriptions method added to providers (#3116) - Add `eth.getChainId` method (#3113) +- The transaction confirmation workflow can now be configured (#3130) ### Fixed diff --git a/docs/web3-eth-contract.rst b/docs/web3-eth-contract.rst index 98e7e756ea2..0f801f1ceab 100644 --- a/docs/web3-eth-contract.rst +++ b/docs/web3-eth-contract.rst @@ -77,6 +77,154 @@ Example = Properties = ========= +------------------------------------------------------------------------------ + +.. _eth-contract-defaultaccount + +defaultAccount +===================== + +.. code-block:: javascript + + web3.eth.Contract.defaultAccount + contract.defaultAccount // on contract instance + +This default address is used as the default ``"from"`` property, if no ``"from"`` property is specified in for the following methods: + +- :ref:`web3.eth.sendTransaction() ` +- :ref:`web3.eth.call() ` +- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().call() ` +- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().send() ` + +-------- +Property +-------- + + +``String`` - 20 Bytes: Any ethereum address. You should have the private key for that address in your node or keystore. (Default is ``undefined``) + + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.defaultAccount; + > undefined + + // set the default account + web3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'; + + +------------------------------------------------------------------------------ + +.. _eth-contract-defaultblock: + +defaultBlock +===================== + +.. code-block:: javascript + + web3.eth.Contract.defaultBlock + contract.defaultBlock // on contract instance + +The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. +The default value of it is "latest". + +---------- +Property +---------- + + +Default block parameters can be one of the following: + +- ``Number``: A block number +- ``"genesis"`` - ``String``: The genesis block +- ``"latest"`` - ``String``: The latest block (current head of the blockchain) +- ``"pending"`` - ``String``: The currently mined block (including pending transactions) + +Default is ``"latest"`` + + +------- +Example +------- + +.. code-block:: javascript + + contract.defaultBlock; + > "latest" + + // set the default block + contract.defaultBlock = 231; + + +------------------------------------------------------------------------------ + +.. _eth-contract-transactionblocktimeout: + +transactionBlockTimeout +===================== + +.. code-block:: javascript + + web3.eth.Contract.transcationBlockTimeout + contract.transactionBlockTimeout // on contract instance + +The ``transactionBlockTimeout`` will be used over a socket based connection. This option does define the amount of new blocks it should wait until the first confirmation happens. +This means the PromiEvent rejects with a timeout error when the timeout got exceeded. + + +------- +Returns +------- + +``number``: The current value of transactionBlockTimeout (default: 50) + +------------------------------------------------------------------------------ + +.. _eth-contract-module-transactionconfirmationblocks: + +transactionConfirmationBlocks +===================== + +.. code-block:: javascript + + web3.eth.Contract.transactionConfirmationBlocks + contract.transactionConfirmationBlocks // on contract instance + +This defines the number of blocks it requires until a transaction will be handled as confirmed. + + +------- +Returns +------- + +``number``: The current value of transactionConfirmationBlocks (default: 24) + +------------------------------------------------------------------------------ + +.. _eth-contract-module-transactionpollingtimeout: + +transactionPollingTimeout +===================== + +.. code-block:: javascript + + web3.eth.Contract.transactionPollingTimeout + contract.transactionPollingTimeout // on contract instance + +The ``transactionPollingTimeout`` will be used over a HTTP connection. +This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. NB: If this method times out, the transaction may still be pending. + + +------- +Returns +------- + +``number``: The current value of transactionPollingTimeout (default: 750) ------------------------------------------------------------------------------ diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index a35450e03fa..622e749c5ce 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -121,6 +121,7 @@ For ``web3.eth.net`` see the :ref:`net reference documentation ` ------------------------------------------------------------------------------ +.. _eth-defaultaccount defaultAccount ===================== @@ -207,6 +208,68 @@ Example web3.eth.defaultBlock = 231; +------------------------------------------------------------------------------ + +.. _web3-module-transactionblocktimeout: + +transactionBlockTimeout +===================== + +.. code-block:: javascript + + web3.eth.transactionBlockTimeout + +The ``transactionBlockTimeout`` will be used over a socket based connection. This option does define the amount of new blocks it should wait until the first confirmation happens. +This means the PromiEvent rejects with a timeout error when the timeout got exceeded. + + +------- +Returns +------- + +``number``: The current value of transactionBlockTimeout (default: 50) + +------------------------------------------------------------------------------ + +.. _web3-module-transactionconfirmationblocks: + +transactionConfirmationBlocks +===================== + +.. code-block:: javascript + + web3.eth.transactionConfirmationBlocks + +This defines the number of blocks it requires until a transaction will be handled as confirmed. + + +------- +Returns +------- + +``number``: The current value of transactionConfirmationBlocks (default: 24) + +------------------------------------------------------------------------------ + +.. _web3-module-transactionpollingtimeout: + +transactionPollingTimeout +===================== + +.. code-block:: javascript + + web3.eth.transactionPollingTimeout + +The ``transactionPollingTimeout`` will be used over a HTTP connection. +This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. NB: If this method times out, the transaction may still be pending. + + +------- +Returns +------- + +``number``: The current value of transactionPollingTimeout (default: 750) + ------------------------------------------------------------------------------ getProtocolVersion diff --git a/packages/web3-bzz/package-lock.json b/packages/web3-bzz/package-lock.json index 4c1dbdc4cd6..d97a94d54fb 100644 --- a/packages/web3-bzz/package-lock.json +++ b/packages/web3-bzz/package-lock.json @@ -1,6 +1,8 @@ { - "requires": true, + "name": "web3-bzz", + "version": "1.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { "@sindresorhus/is": { "version": "0.14.0", diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index 6948332214f..c5ef5deb38e 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -30,10 +30,6 @@ var utils = require('web3-utils'); var promiEvent = require('web3-core-promievent'); var Subscriptions = require('web3-core-subscriptions').subscriptions; -var TIMEOUTBLOCK = 50; -var POLLINGTIMEOUT = 15 * TIMEOUTBLOCK; // ~average block time (seconds) * TIMEOUTBLOCK -var CONFIRMATIONBLOCKS = 24; - var Method = function Method(options) { if(!options.call || !options.name) { @@ -55,6 +51,9 @@ var Method = function Method(options) { this.defaultBlock = options.defaultBlock || 'latest'; this.defaultAccount = options.defaultAccount || null; + this.transactionBlockTimeout = options.transactionBlockTimeout || 50; + this.transactionConfirmationBlocks = options.transactionConfirmationBlocks || 24; + this.transactionPollingTimeout = options.transactionPollingTimeout || 750; }; Method.prototype.setRequestManager = function (requestManager, accounts) { @@ -290,7 +289,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { canUnsubscribe = false; confirmationCount++; - if (confirmationCount === CONFIRMATIONBLOCKS + 1) { // add 1 so we account for conf 0 + if (confirmationCount === method.transactionConfirmationBlocks + 1) { // add 1 so we account for conf 0 sub.unsubscribe(); defer.eventEmitter.removeAllListeners(); } @@ -410,22 +409,22 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { // check to see if we are http polling if(!!isPolling) { - // polling timeout is different than TIMEOUTBLOCK blocks since we are triggering every second - if (timeoutCount - 1 >= POLLINGTIMEOUT) { + // polling timeout is different than transactionBlockTimeout blocks since we are triggering every second + if (timeoutCount - 1 >= method.transactionPollingTimeout) { sub.unsubscribe(); promiseResolved = true; utils._fireError( - new Error('Transaction was not mined within ' + POLLINGTIMEOUT + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), - defer.eventEmitter, + new Error('Transaction was not mined within ' + method.transactionPollingTimeout + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), + defer.eventEmitter, defer.reject ); } } else { - if (timeoutCount - 1 >= TIMEOUTBLOCK) { + if (timeoutCount - 1 >= method.transactionBlockTimeout) { sub.unsubscribe(); promiseResolved = true; utils._fireError( - new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), + new Error('Transaction was not mined within ' + method.transactionBlockTimeout + ' blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject ); diff --git a/packages/web3-eth-contract/src/index.js b/packages/web3-eth-contract/src/index.js index b5bfdec1976..d85aa0e6fe8 100644 --- a/packages/web3-eth-contract/src/index.js +++ b/packages/web3-eth-contract/src/index.js @@ -180,6 +180,9 @@ var Contract = function Contract(jsonInterface, address, options) { // get default account from the Class var defaultAccount = this.constructor.defaultAccount; var defaultBlock = this.constructor.defaultBlock || 'latest'; + this.transactionBlockTimeout = this.constructor.transactionBlockTimeout; + this.transactionConfirmationBlocks = this.constructor.transactionConfirmationBlocks; + this.transactionPollingTimeout = this.constructor.transactionPollingTimeout; Object.defineProperty(this, 'defaultAccount', { get: function () { @@ -891,6 +894,9 @@ Contract.prototype._executeMethod = function _executeMethod(){ accounts: _this.constructor._ethAccounts || _this._ethAccounts, // is eth.accounts (necessary for wallet signing) defaultAccount: _this._parent.defaultAccount, defaultBlock: _this._parent.defaultBlock, + transactionBlockTimeout: _this._parent.transactionBlockTimeout, + transactionConfirmationBlocks: _this._parent.transactionConfirmationBlocks, + transactionPollingTimeout: _this._parent.transactionPollingTimeout, extraFormatters: extraFormatters })).createFunction(); diff --git a/packages/web3-eth/src/index.js b/packages/web3-eth/src/index.js index c6b1dec712f..d2cd4608989 100644 --- a/packages/web3-eth/src/index.js +++ b/packages/web3-eth/src/index.js @@ -81,7 +81,61 @@ var Eth = function Eth() { var defaultAccount = null; var defaultBlock = 'latest'; + var transactionBlockTimeout = 50; + var transactionConfirmationBlocks = 24; + var transactionPollingTimeout = 750; + Object.defineProperty(this, 'transactionPollingTimeout', { + get: function () { + return transactionPollingTimeout; + }, + set: function (val) { + transactionPollingTimeout = val; + + // also set on the Contract object + _this.Contract.transactionPollingTimeout = transactionPollingTimeout; + + // update defaultBlock + methods.forEach(function(method) { + method.transactionPollingTimeout = transactionPollingTimeout; + }); + }, + enumerable: true + }); + Object.defineProperty(this, 'transactionConfirmationBlocks', { + get: function () { + return transactionConfirmationBlocks; + }, + set: function (val) { + transactionConfirmationBlocks = val; + + // also set on the Contract object + _this.Contract.transactionConfirmationBlocks = transactionConfirmationBlocks; + + // update defaultBlock + methods.forEach(function(method) { + method.transactionConfirmationBlocks = transactionConfirmationBlocks; + }); + }, + enumerable: true + }); + Object.defineProperty(this, 'transactionBlockTimeout', { + get: function () { + return transactionBlockTimeout; + }, + set: function (val) { + transactionBlockTimeout = val; + + // also set on the Contract object + _this.Contract.transactionBlockTimeout = transactionBlockTimeout; + + // update defaultBlock + methods.forEach(function(method) { + method.transactionBlockTimeout = transactionBlockTimeout; + }); + }, + enumerable: true + }); Object.defineProperty(this, 'defaultAccount', { get: function () { return defaultAccount; @@ -173,6 +227,9 @@ var Eth = function Eth() { this.Contract = Contract; this.Contract.defaultAccount = this.defaultAccount; this.Contract.defaultBlock = this.defaultBlock; + this.Contract.transactionBlockTimeout = this.transactionBlockTimeout; + this.Contract.transactionConfirmationBlocks = this.transactionConfirmationBlocks; + this.Contract.transactionPollingTimeout = this.transactionPollingTimeout; this.Contract.setProvider(this.currentProvider, this.accounts); // add IBAN @@ -461,6 +518,9 @@ var Eth = function Eth() { method.setRequestManager(_this._requestManager, _this.accounts); // second param means is eth.accounts (necessary for wallet signing) method.defaultBlock = _this.defaultBlock; method.defaultAccount = _this.defaultAccount; + method.transactionBlockTimeout = _this.transactionBlockTimeout; + method.transactionConfirmationBlocks = _this.transactionConfirmationBlocks; + method.transactionPollingTimeout = _this.transactionPollingTimeout; }); }; diff --git a/test/eth.transactionBlockTimeout.js b/test/eth.transactionBlockTimeout.js new file mode 100644 index 00000000000..901930f789e --- /dev/null +++ b/test/eth.transactionBlockTimeout.js @@ -0,0 +1,25 @@ +var chai = require('chai'); +var assert = chai.assert; +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); + +var setValue = 123; + +describe('web3.eth', function () { + describe('transactionBlockTimeout', function () { + it('should check if transactionBlockTimeout is set to proper value', function () { + assert.equal(eth.transactionBlockTimeout, 50); + assert.equal(eth.Contract.transactionBlockTimeout, 50); + assert.equal(eth.getCode.method.transactionBlockTimeout, 50); + }); + it('should set transactionBlockTimeout for all sub packages is set to proper value, if Eth package is changed', function () { + eth.transactionBlockTimeout = setValue; + + assert.equal(eth.transactionBlockTimeout, setValue); + assert.equal(eth.Contract.transactionBlockTimeout, setValue); + assert.equal(eth.getCode.method.transactionBlockTimeout, setValue); + }); + }); +}); + diff --git a/test/eth.transactionConfirmationBlocks.js b/test/eth.transactionConfirmationBlocks.js new file mode 100644 index 00000000000..abfb7065423 --- /dev/null +++ b/test/eth.transactionConfirmationBlocks.js @@ -0,0 +1,25 @@ +var chai = require('chai'); +var assert = chai.assert; +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); + +var setValue = 123; + +describe('web3.eth', function () { + describe('transactionConfirmationBlocks', function () { + it('should check if transactionConfirmationBlocks is set to proper value', function () { + assert.equal(eth.transactionConfirmationBlocks, 24); + assert.equal(eth.Contract.transactionConfirmationBlocks, 24); + assert.equal(eth.getCode.method.transactionConfirmationBlocks, 24); + }); + it('should set transactionConfirmationBlocks for all sub packages is set to proper value, if Eth package is changed', function () { + eth.transactionConfirmationBlocks = setValue; + + assert.equal(eth.transactionConfirmationBlocks, setValue); + assert.equal(eth.Contract.transactionConfirmationBlocks, setValue); + assert.equal(eth.getCode.method.transactionConfirmationBlocks, setValue); + }); + }); +}); + diff --git a/test/eth.transactionPollingTimeout.js b/test/eth.transactionPollingTimeout.js new file mode 100644 index 00000000000..bb8ab5569f3 --- /dev/null +++ b/test/eth.transactionPollingTimeout.js @@ -0,0 +1,25 @@ +var chai = require('chai'); +var assert = chai.assert; +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); + +var setValue = 123; + +describe('web3.eth', function () { + describe('transactionPollingTimeout', function () { + it('should check if transactionPollingTimeout is set to proper value', function () { + assert.equal(eth.transactionPollingTimeout, 750); + assert.equal(eth.Contract.transactionPollingTimeout, 750); + assert.equal(eth.getCode.method.transactionPollingTimeout, 750); + }); + it('should set transactionPollingTimeout for all sub packages is set to proper value, if Eth package is changed', function () { + eth.transactionPollingTimeout = setValue; + + assert.equal(eth.transactionPollingTimeout, setValue); + assert.equal(eth.Contract.transactionPollingTimeout, setValue); + assert.equal(eth.getCode.method.transactionPollingTimeout, setValue); + }); + }); +}); + From 03ed119895d08399e966cc07684ae230012c92cd Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Wed, 16 Oct 2019 12:04:13 +0200 Subject: [PATCH 3/5] Minified file added to web3 package (#3131) * minfied file added to web3 package for npm and cdn's * CHANGELOG.md updated --- .gitignore | 1 + CHANGELOG.md | 1 + gulpfile.js | 2 ++ packages/web3/package.json | 1 + 4 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 46f98b48121..b69bc021448 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ bower_components .npm/ .vscode/ dist/ +packages/web3/dist/ !./dist/web3.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d2750752e7..89b50feb070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Released with 1.0.0-beta.37 code base. - getNetworkType method extended with Görli testnet (#3095) - supportsSubscriptions method added to providers (#3116) - Add `eth.getChainId` method (#3113) +- Minified file added to web3 package (#3131) - The transaction confirmation workflow can now be configured (#3130) ### Fixed diff --git a/gulpfile.js b/gulpfile.js index 65bf5578ab2..7a43c6c3419 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,6 +20,7 @@ var replace = require('gulp-replace'); var exec = require('child_process').exec; var DEST = path.join(__dirname, 'dist/'); +var WEB3_PACKAGE_DEST = path.join(__dirname, 'packages/web3/dist'); var packages = [{ fileName: 'web3', @@ -189,6 +190,7 @@ packages.forEach(function (pckg, i) { .pipe(streamify(uglify(ugliyOptions))) .on('error', function (err) { console.error(err); }) .pipe(rename(pckg.fileName + '.min.js')) + .pipe(gulp.dest(WEB3_PACKAGE_DEST)) .pipe(gulp.dest(DEST)); })); }); diff --git a/packages/web3/package.json b/packages/web3/package.json index 1fe2c2ea0c1..3a414844353 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -8,6 +8,7 @@ "node": ">=8.0.0" }, "main": "src/index.js", + "browser": "dist/web3.min.js", "bugs": { "url": "https://github.com/ethereum/web3.js/issues" }, From 8ac5c0ede641c84404d32227610ad3d7414e6649 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Wed, 16 Oct 2019 15:46:01 +0100 Subject: [PATCH 4/5] Types back-port from 2.x with changes to match the 1.x logic (#3132) * docs: update readme to contain TS usage * feat: learna dtslint * feat: types for `web3` module * feat: `web3` module install dtslint * docs: readme web3 module types * feat: `web3-core` types * docs: update readme for `web3-core` for types * feat: install type dependencies for `web3-core` * feat: `web3-core-helper` types * feat: install type dependency for `web3-core-helpers` * docs: update readme for typings * fix: remove @types/node from `web3-core-helpers` * feat: `web3-core-method` types * feat: install type dependencies for `web3-core-method` * docs: update types for `web3-core-method` in readme * feat: `web3-eth` typings * feat: install type dependencies for `web3-eth` * docs: update readme for `web3-eth` * feat: `web3-eth-abi` typings * feat: install type dependencies for `web3-eth-abi` * docs: update readme for `web3-eth-abi` * feat: `web3-eth-accounts` typings * feat: install type dependencies for `web3-eth-accounts` * docs: update readme for `web3-eth-accounts` * feat: `web3-eth-contract` typings * feat: `web3-eth-contract` tests * feat: install types dependencies for `web3-eth-contract` * docs: update readme for `web3-eth-contract` * feat: `web3-eth-ens` typings * test: `web3-eth-ens` tests * feat: install type dependencies for `web3-eth-ens` * docs: update readme for `web3-eth-ens` * feat: `web3-eth-iban` typings * test: `web3-eth-iban` typing tests * feat: install `web3-eth-iban` typings dependencies * docs: update readme for `web3-eth-iban` * feat: `web3-eth-personal` typings * test: `web3-eth-personal` typings tests * feat: install dependencies for `web3-eth-personal` * docs: update readme `web3-eth-personal` * feat: `web3-net` typings * fix: remove dev dependencies which are not relavant * test: `web3-net` typings tests * docs: update readme for `web3-net` * feat: install dev dependencies for `web3-net` * feat: `web3-shh` typings * test: `web3-shh` typings tests * docs: update `web3-shh` readme * feat: install dev dependencies in `web3-shh` * feat: web3-utils type config files * feat: ascii to hex typings test * feat: bytes to hex typings test * feat: check address checksum typings test * feat: from ascii typings test * feat: from decimal typings test * feat: from utf8 typings test * feat: from wei typings test * feat: get signature params typings test * feat: get unit value typings test * feat: hex to ascii typings test * feat: hex to bytes typings test * feat: hex to number string typings test * feat: hex to number typings test * feat: hex to string typings test * feat: hex to utf8 typings test * feat: is address typings test * feat: is big number typings test * feat: is bloom typings test * feat: is bn typings test * feat: is hex strict typings test * feat: is hex typings test * feat: is topic typings test * feat: json interface method to string typings test * feat: keccak256 typings test * feat: left pad typings test * feat: number to hex typings test * feat: utils type tests * feat: add types in package.json * feat: new lock files for all packages * feat: new lock files for web3-eth-account * feat: new lock file for web3-provider.ws * feat: install new dev dependencies for typings on root * feat: export the typings in the package.json * feat: web3 typings tests to reference web3-core * feat: reference web3-core over web3-providers * feat: typings moved around due to different approach in 2.x * feat: web3-bzz types * feat: web3-bzz dependencies * test: web3 bzz types * fix: resolve dtslint typing tests fails * feat: web3-provider-http types * test: web3-provider-http tests * refactor: rename to `tests` * docs: add author to the http provider * feat: install web3-provider-ipc new dev dependencies * docs: update readme for web3-provider-ipc * feat: `web3-providers-ipc` typings * test: web3-provider-ipc test typings * feat: typings for web3-providers-ipc * fix: remove file comment * fix: resolve index.d.ts file * feat: install type dependencies for web3-provider-ws * feat: `web-providers-ws` typings * feat: web3-providers-ws ts files * test: web3-provider-ws-tests * fix: remove batch request from web3-bzz * feat: export errors from web3-core-helpers * fix: remove options from `web3.shh` * fix: define callback in the filter methods * feat: remove `TransactionSigner` * docs: add web3-eth-personal docs * fix: resolve typings 1.0 from pr comments * types updated * ci script updated * global install of typescript for CI added * installation of typescript moved to before_script * lerna-debug.log added to gitignore * lerna-debug removed * getNodeInfo added to types and documentation * getChainId to types added * travis.yml fixed * global install of typescript removed and just added as dependency to the root package.json * fix: dtslint to version `0.4.2` * fix: remove repeating typings --- .gitignore | 1 + README.md | 57 +- docs/web3-eth-personal.rst | 170 +- docs/web3-eth.rst | 27 + lerna-debug.log | 2027 ----------------- package-lock.json | 21 +- package.json | 9 +- packages/web3-bzz/README.md | 8 +- packages/web3-bzz/package-lock.json | 297 +++ packages/web3-bzz/package.json | 9 + packages/web3-bzz/types/index.d.ts | 42 + packages/web3-bzz/types/tests/bzz-test.ts | 69 + packages/web3-bzz/types/tsconfig.json | 17 + packages/web3-bzz/types/tslint.json | 11 + packages/web3-core-helpers/README.md | 5 +- packages/web3-core-helpers/package-lock.json | 339 +++ packages/web3-core-helpers/package.json | 8 + packages/web3-core-helpers/types/index.d.ts | 177 ++ .../types/tests/errors-test.ts | 38 + .../types/tests/formatters-test.ts | 68 + .../web3-core-helpers/types/tsconfig.json | 17 + packages/web3-core-helpers/types/tslint.json | 10 + packages/web3-core-method/README.md | 6 +- packages/web3-core-method/package-lock.json | 339 +++ packages/web3-core-method/package.json | 8 + packages/web3-core-method/types/index.d.ts | 32 + packages/web3-core-method/types/tsconfig.json | 17 + packages/web3-core-method/types/tslint.json | 10 + .../web3-core-subscriptions/package-lock.json | 391 +++- packages/web3-core-subscriptions/package.json | 8 + .../src/subscription.js | 2 +- .../web3-core-subscriptions/types/index.d.ts | 78 + .../types/tests/subscriptions.tests.ts | 85 + .../types/tsconfig.json | 17 + .../web3-core-subscriptions/types/tslint.json | 12 + packages/web3-core/README.md | 9 +- packages/web3-core/package-lock.json | 358 +++ packages/web3-core/package.json | 10 + packages/web3-core/types/index.d.ts | 371 +++ packages/web3-core/types/tsconfig.json | 17 + packages/web3-core/types/tslint.json | 10 + packages/web3-eth-abi/README.md | 6 +- packages/web3-eth-abi/package-lock.json | 334 +++ packages/web3-eth-abi/package.json | 8 + packages/web3-eth-abi/types/index.d.ts | 42 + .../types/tests/abi-coder-test.ts | 753 ++++++ packages/web3-eth-abi/types/tsconfig.json | 17 + packages/web3-eth-abi/types/tslint.json | 10 + packages/web3-eth-accounts/README.md | 6 +- packages/web3-eth-accounts/package-lock.json | 370 ++- packages/web3-eth-accounts/package.json | 8 + packages/web3-eth-accounts/types/index.d.ts | 36 + .../types/tests/accounts-tests.ts | 240 ++ .../web3-eth-accounts/types/tsconfig.json | 17 + packages/web3-eth-accounts/types/tslint.json | 10 + packages/web3-eth-contract/README.md | 7 +- packages/web3-eth-contract/package-lock.json | 352 +++ packages/web3-eth-contract/package.json | 9 + packages/web3-eth-contract/types/index.d.ts | 150 ++ .../types/tests/contract-test.ts | 146 ++ .../web3-eth-contract/types/tsconfig.json | 17 + packages/web3-eth-contract/types/tslint.json | 12 + packages/web3-eth-ens/README.md | 16 +- packages/web3-eth-ens/package-lock.json | 339 +++ packages/web3-eth-ens/package.json | 8 + packages/web3-eth-ens/types/index.d.ts | 125 + packages/web3-eth-ens/types/tests/ens-test.ts | 97 + packages/web3-eth-ens/types/tsconfig.json | 17 + packages/web3-eth-ens/types/tslint.json | 12 + packages/web3-eth-iban/README.md | 10 +- packages/web3-eth-iban/package-lock.json | 339 +++ packages/web3-eth-iban/package.json | 8 + packages/web3-eth-iban/types/index.d.ts | 60 + .../web3-eth-iban/types/tests/iban-tests.ts | 154 ++ packages/web3-eth-iban/types/tsconfig.json | 17 + packages/web3-eth-iban/types/tslint.json | 9 + packages/web3-eth-personal/README.md | 6 +- packages/web3-eth-personal/package-lock.json | 350 +++ packages/web3-eth-personal/package.json | 9 + packages/web3-eth-personal/types/index.d.ts | 80 + .../types/tests/personal-tests.ts | 136 ++ .../web3-eth-personal/types/tsconfig.json | 17 + packages/web3-eth-personal/types/tslint.json | 10 + packages/web3-eth/README.md | 6 +- packages/web3-eth/package-lock.json | 339 +++ packages/web3-eth/package.json | 8 + packages/web3-eth/types/index.d.ts | 402 ++++ packages/web3-eth/types/tests/eth.tests.ts | 619 +++++ packages/web3-eth/types/tsconfig.json | 17 + packages/web3-eth/types/tslint.json | 11 + packages/web3-net/README.md | 6 +- packages/web3-net/package-lock.json | 345 +++ packages/web3-net/package.json | 8 + packages/web3-net/types/index.d.ts | 22 + packages/web3-net/types/tests/network-test.ts | 63 + packages/web3-net/types/tsconfig.json | 17 + packages/web3-net/types/tslint.json | 10 + packages/web3-providers-http/README.md | 10 +- .../web3-providers-http/package-lock.json | 339 +++ packages/web3-providers-http/package.json | 8 + packages/web3-providers-http/types/index.d.ts | 43 + .../types/tests/web3-provider-http-tests.ts | 40 + .../web3-providers-http/types/tsconfig.json | 17 + .../web3-providers-http/types/tslint.json | 10 + packages/web3-providers-ipc/README.md | 8 +- packages/web3-providers-ipc/package-lock.json | 391 +++- packages/web3-providers-ipc/package.json | 8 + packages/web3-providers-ipc/types/index.d.ts | 54 + .../types/tests/web3-provider-ipc-tests.ts | 68 + .../web3-providers-ipc/types/tsconfig.json | 17 + packages/web3-providers-ipc/types/tslint.json | 10 + packages/web3-providers-ws/README.md | 11 +- packages/web3-providers-ws/package-lock.json | 391 +++- packages/web3-providers-ws/package.json | 36 +- packages/web3-providers-ws/types/index.d.ts | 59 + .../types/tests/web3-provider-ws-tests.ts | 78 + .../web3-providers-ws/types/tsconfig.json | 17 + packages/web3-providers-ws/types/tslint.json | 10 + packages/web3-shh/README.md | 8 +- packages/web3-shh/package-lock.json | 345 +++ packages/web3-shh/package.json | 8 + packages/web3-shh/types/index.d.ts | 194 ++ packages/web3-shh/types/tests/shh-test.ts | 244 ++ packages/web3-shh/types/tsconfig.json | 17 + packages/web3-shh/types/tslint.json | 11 + packages/web3-utils/README.md | 8 +- packages/web3-utils/package-lock.json | 321 +++ packages/web3-utils/package.json | 8 + packages/web3-utils/types/index.d.ts | 225 ++ .../types/tests/ascii-to-hex-test.ts | 47 + .../types/tests/bytes-to-hex-test.ts | 44 + .../tests/check-address-checksum-test.ts | 60 + .../web3-utils/types/tests/from-ascii-test.ts | 44 + .../types/tests/from-decimal-test.ts | 44 + .../web3-utils/types/tests/from-utf8-test.ts | 44 + .../web3-utils/types/tests/from-wei-test.ts | 52 + .../types/tests/get-signature-params-test.ts | 45 + .../types/tests/get-unit-value-test.ts | 46 + .../types/tests/hex-to-ascii-test.ts | 44 + .../types/tests/hex-to-bytes-test.ts | 44 + .../types/tests/hex-to-number-string-test.ts | 44 + .../types/tests/hex-to-number-test.ts | 44 + .../types/tests/hex-to-string-test.ts | 44 + .../types/tests/hex-to-utf8-test.ts | 44 + .../web3-utils/types/tests/is-address-test.ts | 60 + .../types/tests/is-big-number-test.ts | 44 + .../web3-utils/types/tests/is-bloom-test.ts | 44 + packages/web3-utils/types/tests/is-bn-test.ts | 44 + .../types/tests/is-hex-strict-test.ts | 44 + .../web3-utils/types/tests/is-hex-test.ts | 44 + .../web3-utils/types/tests/is-topic-test.ts | 44 + .../json-interface-method-to-string-test.ts | 120 + .../web3-utils/types/tests/keccak256-test.ts | 44 + .../web3-utils/types/tests/left-pad-test.ts | 73 + .../types/tests/number-to-hex-test.ts | 46 + .../web3-utils/types/tests/pad-left-test.ts | 74 + .../web3-utils/types/tests/pad-right-test.ts | 74 + .../web3-utils/types/tests/random-hex-test.ts | 44 + .../web3-utils/types/tests/right-pad-test.ts | 74 + packages/web3-utils/types/tests/sha3-test.ts | 44 + .../types/tests/solidity-sha3-test.ts | 52 + .../types/tests/string-to-hex-test.ts | 44 + .../types/tests/strip-hex-prefix-test.ts | 44 + .../types/tests/test-address-test.ts | 62 + .../web3-utils/types/tests/test-topic-test.ts | 62 + .../web3-utils/types/tests/to-ascii-test.ts | 44 + packages/web3-utils/types/tests/to-bn-test.ts | 41 + .../types/tests/to-check-sum-address-test.ts | 60 + .../web3-utils/types/tests/to-decimal-test.ts | 44 + .../web3-utils/types/tests/to-hex-test.ts | 44 + .../types/tests/to-twos-compement-test.ts | 44 + .../web3-utils/types/tests/to-utf8-test.ts | 44 + .../web3-utils/types/tests/to-wei-test.ts | 50 + .../web3-utils/types/tests/unit-map-test.ts | 26 + .../types/tests/utf8-to-hex-test.ts | 44 + packages/web3-utils/types/tsconfig.json | 17 + packages/web3-utils/types/tslint.json | 9 + packages/web3/README.md | 7 + packages/web3/package-lock.json | 350 +++ packages/web3/package.json | 9 + packages/web3/types/index.d.ts | 57 + packages/web3/types/tests/web3-test.ts | 70 + packages/web3/types/tsconfig.json | 17 + packages/web3/types/tslint.json | 11 + scripts/ci.sh | 2 + 185 files changed, 15179 insertions(+), 2145 deletions(-) delete mode 100644 lerna-debug.log create mode 100644 packages/web3-bzz/types/index.d.ts create mode 100644 packages/web3-bzz/types/tests/bzz-test.ts create mode 100644 packages/web3-bzz/types/tsconfig.json create mode 100644 packages/web3-bzz/types/tslint.json create mode 100644 packages/web3-core-helpers/types/index.d.ts create mode 100644 packages/web3-core-helpers/types/tests/errors-test.ts create mode 100644 packages/web3-core-helpers/types/tests/formatters-test.ts create mode 100644 packages/web3-core-helpers/types/tsconfig.json create mode 100644 packages/web3-core-helpers/types/tslint.json create mode 100644 packages/web3-core-method/types/index.d.ts create mode 100644 packages/web3-core-method/types/tsconfig.json create mode 100644 packages/web3-core-method/types/tslint.json create mode 100644 packages/web3-core-subscriptions/types/index.d.ts create mode 100644 packages/web3-core-subscriptions/types/tests/subscriptions.tests.ts create mode 100644 packages/web3-core-subscriptions/types/tsconfig.json create mode 100644 packages/web3-core-subscriptions/types/tslint.json create mode 100644 packages/web3-core/package-lock.json create mode 100644 packages/web3-core/types/index.d.ts create mode 100644 packages/web3-core/types/tsconfig.json create mode 100644 packages/web3-core/types/tslint.json create mode 100644 packages/web3-eth-abi/types/index.d.ts create mode 100644 packages/web3-eth-abi/types/tests/abi-coder-test.ts create mode 100644 packages/web3-eth-abi/types/tsconfig.json create mode 100644 packages/web3-eth-abi/types/tslint.json create mode 100644 packages/web3-eth-accounts/types/index.d.ts create mode 100644 packages/web3-eth-accounts/types/tests/accounts-tests.ts create mode 100644 packages/web3-eth-accounts/types/tsconfig.json create mode 100644 packages/web3-eth-accounts/types/tslint.json create mode 100644 packages/web3-eth-contract/types/index.d.ts create mode 100644 packages/web3-eth-contract/types/tests/contract-test.ts create mode 100644 packages/web3-eth-contract/types/tsconfig.json create mode 100644 packages/web3-eth-contract/types/tslint.json create mode 100644 packages/web3-eth-ens/types/index.d.ts create mode 100644 packages/web3-eth-ens/types/tests/ens-test.ts create mode 100644 packages/web3-eth-ens/types/tsconfig.json create mode 100644 packages/web3-eth-ens/types/tslint.json create mode 100644 packages/web3-eth-iban/types/index.d.ts create mode 100644 packages/web3-eth-iban/types/tests/iban-tests.ts create mode 100644 packages/web3-eth-iban/types/tsconfig.json create mode 100644 packages/web3-eth-iban/types/tslint.json create mode 100644 packages/web3-eth-personal/package-lock.json create mode 100644 packages/web3-eth-personal/types/index.d.ts create mode 100644 packages/web3-eth-personal/types/tests/personal-tests.ts create mode 100644 packages/web3-eth-personal/types/tsconfig.json create mode 100644 packages/web3-eth-personal/types/tslint.json create mode 100644 packages/web3-eth/types/index.d.ts create mode 100644 packages/web3-eth/types/tests/eth.tests.ts create mode 100644 packages/web3-eth/types/tsconfig.json create mode 100644 packages/web3-eth/types/tslint.json create mode 100644 packages/web3-net/package-lock.json create mode 100644 packages/web3-net/types/index.d.ts create mode 100644 packages/web3-net/types/tests/network-test.ts create mode 100644 packages/web3-net/types/tsconfig.json create mode 100644 packages/web3-net/types/tslint.json create mode 100644 packages/web3-providers-http/types/index.d.ts create mode 100644 packages/web3-providers-http/types/tests/web3-provider-http-tests.ts create mode 100644 packages/web3-providers-http/types/tsconfig.json create mode 100644 packages/web3-providers-http/types/tslint.json create mode 100644 packages/web3-providers-ipc/types/index.d.ts create mode 100644 packages/web3-providers-ipc/types/tests/web3-provider-ipc-tests.ts create mode 100644 packages/web3-providers-ipc/types/tsconfig.json create mode 100644 packages/web3-providers-ipc/types/tslint.json create mode 100644 packages/web3-providers-ws/types/index.d.ts create mode 100644 packages/web3-providers-ws/types/tests/web3-provider-ws-tests.ts create mode 100644 packages/web3-providers-ws/types/tsconfig.json create mode 100644 packages/web3-providers-ws/types/tslint.json create mode 100644 packages/web3-shh/package-lock.json create mode 100644 packages/web3-shh/types/index.d.ts create mode 100644 packages/web3-shh/types/tests/shh-test.ts create mode 100644 packages/web3-shh/types/tsconfig.json create mode 100644 packages/web3-shh/types/tslint.json create mode 100644 packages/web3-utils/types/index.d.ts create mode 100644 packages/web3-utils/types/tests/ascii-to-hex-test.ts create mode 100644 packages/web3-utils/types/tests/bytes-to-hex-test.ts create mode 100644 packages/web3-utils/types/tests/check-address-checksum-test.ts create mode 100644 packages/web3-utils/types/tests/from-ascii-test.ts create mode 100644 packages/web3-utils/types/tests/from-decimal-test.ts create mode 100644 packages/web3-utils/types/tests/from-utf8-test.ts create mode 100644 packages/web3-utils/types/tests/from-wei-test.ts create mode 100644 packages/web3-utils/types/tests/get-signature-params-test.ts create mode 100644 packages/web3-utils/types/tests/get-unit-value-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-ascii-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-bytes-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-number-string-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-number-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-string-test.ts create mode 100644 packages/web3-utils/types/tests/hex-to-utf8-test.ts create mode 100644 packages/web3-utils/types/tests/is-address-test.ts create mode 100644 packages/web3-utils/types/tests/is-big-number-test.ts create mode 100644 packages/web3-utils/types/tests/is-bloom-test.ts create mode 100644 packages/web3-utils/types/tests/is-bn-test.ts create mode 100644 packages/web3-utils/types/tests/is-hex-strict-test.ts create mode 100644 packages/web3-utils/types/tests/is-hex-test.ts create mode 100644 packages/web3-utils/types/tests/is-topic-test.ts create mode 100644 packages/web3-utils/types/tests/json-interface-method-to-string-test.ts create mode 100644 packages/web3-utils/types/tests/keccak256-test.ts create mode 100644 packages/web3-utils/types/tests/left-pad-test.ts create mode 100644 packages/web3-utils/types/tests/number-to-hex-test.ts create mode 100644 packages/web3-utils/types/tests/pad-left-test.ts create mode 100644 packages/web3-utils/types/tests/pad-right-test.ts create mode 100644 packages/web3-utils/types/tests/random-hex-test.ts create mode 100644 packages/web3-utils/types/tests/right-pad-test.ts create mode 100644 packages/web3-utils/types/tests/sha3-test.ts create mode 100644 packages/web3-utils/types/tests/solidity-sha3-test.ts create mode 100644 packages/web3-utils/types/tests/string-to-hex-test.ts create mode 100644 packages/web3-utils/types/tests/strip-hex-prefix-test.ts create mode 100644 packages/web3-utils/types/tests/test-address-test.ts create mode 100644 packages/web3-utils/types/tests/test-topic-test.ts create mode 100644 packages/web3-utils/types/tests/to-ascii-test.ts create mode 100644 packages/web3-utils/types/tests/to-bn-test.ts create mode 100644 packages/web3-utils/types/tests/to-check-sum-address-test.ts create mode 100644 packages/web3-utils/types/tests/to-decimal-test.ts create mode 100644 packages/web3-utils/types/tests/to-hex-test.ts create mode 100644 packages/web3-utils/types/tests/to-twos-compement-test.ts create mode 100644 packages/web3-utils/types/tests/to-utf8-test.ts create mode 100644 packages/web3-utils/types/tests/to-wei-test.ts create mode 100644 packages/web3-utils/types/tests/unit-map-test.ts create mode 100644 packages/web3-utils/types/tests/utf8-to-hex-test.ts create mode 100644 packages/web3-utils/types/tsconfig.json create mode 100644 packages/web3-utils/types/tslint.json create mode 100644 packages/web3/package-lock.json create mode 100644 packages/web3/types/index.d.ts create mode 100644 packages/web3/types/tests/web3-test.ts create mode 100644 packages/web3/types/tsconfig.json create mode 100644 packages/web3/types/tslint.json diff --git a/.gitignore b/.gitignore index b69bc021448..6166a268186 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ bower_components .vscode/ dist/ packages/web3/dist/ +lerna-debug.log !./dist/web3.min.js diff --git a/README.md b/README.md index b2ba7cb34cb..a4b6c2574a5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ This is the Ethereum [JavaScript API][docs] which connects to the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec. - You need to run a local or remote [Ethereum](https://www.ethereum.org/) node to use this library. Please read the [documentation][docs] for more. @@ -31,7 +30,7 @@ yarn add web3 ### Meteor -*Note*: works only in the Browser for now. (PR welcome). +_Note_: works only in the Browser for now. (PR welcome). ```bash meteor add ethereum:web3 @@ -39,7 +38,7 @@ meteor add ethereum:web3 ### In the Browser -Use the prebuild ``dist/web3.min.js``, or +Use the prebuild `dist/web3.min.js`, or build using the [web3.js][repo] repository: ```bash @@ -76,40 +75,39 @@ web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546')); There you go, now you can use it: ```js -web3.eth.getAccounts() -.then(console.log); +web3.eth.getAccounts().then(console.log); ``` ### Usage with TypeScript -Type definitions are maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) by others. You can install them with: - -```bash -npm install --dev @types/web3.js -``` - -You might need to install type definitions for `bignumber.js` and `lodash` too. +We support types within the repo itself. Please open an issue here if you find any wrong types. -And then use `web3.js` as follows: +You can use `web3.js` as follows: ```typescript -import Web3 = require("web3"); // Note the special syntax! Copy this line when in doubt! -const web3 = new Web3("ws://localhost:8546"); +import Web3 from 'web3'; +const web3 = new Web3('ws://localhost:8546'); ``` -**Please note:** We do not support TypeScript ourselves. If you have any issue with TypeScript and `web3.js` do not create an issue here. Go over to DefinitelyTyped and do it there. +If you are using the types in a `commonjs` module like for example a node app you just have to enable `esModuleInterop` in your `tsconfig` compile option, also enable `allowSyntheticDefaultImports` for typesystem compatibility: + +```js +"compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + .... +``` ## Documentation Documentation can be found at [read the docs][docs]. - ## Building ### Requirements -* [Node.js](https://nodejs.org) -* [npm](https://www.npmjs.com/) +- [Node.js](https://nodejs.org) +- [npm](https://www.npmjs.com/) ```bash sudo apt-get update @@ -133,7 +131,6 @@ npm run-script build-all This will put all the browser build files into the `dist` folder. - ### Testing (mocha) ```bash @@ -142,22 +139,22 @@ npm test ### Contributing -- All contributions have to go into develop, or the 1.0 branch -- Please follow the code style of the other files, we use 4 spaces as tabs. +- All contributions have to go into develop, or the 1.0 branch +- Please follow the code style of the other files, we use 4 spaces as tabs. ### Community - - [Gitter](https://gitter.im/ethereum/web3.js?source=orgpage) - - [Forum](https://forum.ethereum.org/categories/ethereum-js) +- [Gitter](https://gitter.im/ethereum/web3.js?source=orgpage) +- [Forum](https://forum.ethereum.org/categories/ethereum-js) ### Similar libraries in other languages - - Python - [Web3.py](https://github.com/ethereum/web3.py) - - Haskell - [hs-web3](https://github.com/airalab/hs-web3) - - Java - [web3j](https://github.com/web3j/web3j) - - Scala - [web3j-scala](https://github.com/mslinn/web3j-scala) - - Purescript - [purescript-web3](https://github.com/f-o-a-m/purescript-web3) - - PHP - [web3.php](https://github.com/sc0Vu/web3.php) +- Python - [Web3.py](https://github.com/ethereum/web3.py) +- Haskell - [hs-web3](https://github.com/airalab/hs-web3) +- Java - [web3j](https://github.com/web3j/web3j) +- Scala - [web3j-scala](https://github.com/mslinn/web3j-scala) +- Purescript - [purescript-web3](https://github.com/f-o-a-m/purescript-web3) +- PHP - [web3.php](https://github.com/sc0Vu/web3.php) [repo]: https://github.com/ethereum/web3.js [docs]: http://web3js.readthedocs.io/ diff --git a/docs/web3-eth-personal.rst b/docs/web3-eth-personal.rst index 3314fb5926f..1af7bfa116a 100644 --- a/docs/web3-eth-personal.rst +++ b/docs/web3-eth-personal.rst @@ -239,6 +239,54 @@ Example ------------------------------------------------------------------------------ +sendTransaction +===================== + +.. code-block:: javascript + + web3.eth.personal.sendTransaction(transactionOptions, password [, callback]) + +This method sends a transaction over the management API. + +.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure. + +---------- +Parameters +---------- + + +1. ``Object`` - The transaction options +2. ``String`` - The passphrase for the current account +3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` - The transaction hash. + + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.sendTransaction({ + from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0", + gasPrice: "20000000000", + gas: "21000", + to: '0x3535353535353535353535353535353535353535', + value: "1000000000000000000", + data: "" + }, 'MyPassword!').then(console.log); + > '0xda3be87732110de6c1354c83770aae630ede9ac308d9f7b399ecfba23d923384' + +------------------------------------------------------------------------------ + unlockAccount ===================== @@ -271,6 +319,124 @@ Example .then(console.log('Account unlocked!')); > "Account unlocked!" -// TODO +------------------------------------------------------------------------------ + +lockAccount +===================== + +.. code-block:: javascript + + web3.eth.personal.lockAccount(address [, callback]) + +Locks the given account. + +.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure. + +---------- +Parameters +---------- + + +1. ``address`` - ``String``: The account address. +4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` + + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.personal.lockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe") + .then(console.log('Account locked!')); + > "Account locked!" + +------------------------------------------------------------------------------ + +.. _personal-getaccounts: + +getAccounts +===================== + +.. code-block:: javascript + + web3.eth.personal.getAccounts([callback]) + +Returns a list of accounts the node controls by using the provider and calling +the RPC method ``personal_listAccounts``. Using :ref:`web3.eth.accounts.create() ` +will not add accounts into this list. For that use +:ref:`web3.eth.personal.newAccount() `. + +The results are the same as :ref:`web3.eth.getAccounts() ` except that calls +the RPC method ``eth_accounts``. + +------- +Returns +------- + + +``Promise`` - An array of addresses controlled by node. + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.personal.getAccounts() + .then(console.log); + > ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"] + +------------------------------------------------------------------------------ + +importRawKey +===================== + +.. code-block:: javascript + + web3.eth.personal.importRawKey(privateKey, password) + +Imports the given private key into the key store, encrypting it with the passphrase. + +Returns the address of the new account. + +.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure. + +---------- +Parameters +---------- + + +1. ``privateKey`` - ``String`` - An unencrypted private key (hex string). +2. ``password`` - ``String`` - The password of the account. + + +------- +Returns +------- + + +``Promise`` - The address of the account. + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.personal.importRawKey("cd3376bb711cb332ee3fb2ca04c6a8b9f70c316fcdf7a1f44ef4c7999483295e", "password1234") + .then(console.log); + > "0x8f337bf484b2fc75e4b0436645dcc226ee2ac531" + -getAccounts, lockAccount, sendTransaction diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index 622e749c5ce..b38bc8adcae 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -1558,3 +1558,30 @@ Example > 61 ------------------------------------------------------------------------------ + +.. _eth-getNodeInfo: + +getNodeInfo +=========== + +.. code-block:: javascript + + web3.eth.getNodeInfo([callback]) + +------- +Returns +------- + +``Promise`` - The current client version. + +------- +Example +------- + + +.. code-block:: javascript + + web3.eth.getNodeInfo().then(console.log); + > "Mist/v0.9.3/darwin/go1.4.1" + +------------------------------------------------------------------------------ diff --git a/lerna-debug.log b/lerna-debug.log deleted file mode 100644 index 9eff98d44c3..00000000000 --- a/lerna-debug.log +++ /dev/null @@ -1,2027 +0,0 @@ -0 silly input [ 'publish' ] -1 silly flags { _: [ 'publish' ], 'reject-cycles': false, rejectCycles: false } -2 verbose rootPath /Users/work/Development/foundation/web3.js -3 info version 2.11.0 -4 silly isInitialized -5 silly isInitialized true -6 silly existsSync /Users/work/Development/foundation/web3.js/VERSION -7 silly initialize attempt -8 info current version 1.2.0 -9 silly getUpdates -10 info Checking for updated packages... -11 silly hasTags -12 verbose hasTags true -13 silly getLastTag -14 verbose getLastTag v1.2.0 -15 info Comparing with v1.2.0. -16 silly diffSinceIn v1.2.0 packages/web3-bzz -17 silly diff packages/web3-bzz/package.json -18 silly diffSinceIn v1.2.0 packages/web3-core-helpers -19 silly diff packages/web3-core-helpers/package.json -20 silly diffSinceIn v1.2.0 packages/web3-core-method -21 silly diff packages/web3-core-method/package.json -22 silly diffSinceIn v1.2.0 packages/web3-core-promievent -23 silly diff packages/web3-core-promievent/package.json -24 silly diffSinceIn v1.2.0 packages/web3-core-requestmanager -25 silly diff packages/web3-core-requestmanager/package.json -26 silly diffSinceIn v1.2.0 packages/web3-core-subscriptions -27 silly diff packages/web3-core-subscriptions/package.json -28 silly diffSinceIn v1.2.0 packages/web3-core -29 silly diff packages/web3-core/package.json -30 silly diffSinceIn v1.2.0 packages/web3-eth-abi -31 silly diff packages/web3-eth-abi/package.json -32 silly diffSinceIn v1.2.0 packages/web3-eth-accounts -33 silly diff packages/web3-eth-accounts/package-lock.json -33 silly diff packages/web3-eth-accounts/package.json -33 silly diff packages/web3-eth-accounts/src/index.js -33 silly diff packages/web3-eth-accounts/src/scrypt.js -34 silly diffSinceIn v1.2.0 packages/web3-eth-contract -35 silly diff packages/web3-eth-contract/package.json -36 silly diffSinceIn v1.2.0 packages/web3-eth-ens -37 silly diff packages/web3-eth-ens/package.json -38 silly diffSinceIn v1.2.0 packages/web3-eth-iban -39 silly diff packages/web3-eth-iban/package.json -40 silly diffSinceIn v1.2.0 packages/web3-eth-personal -41 silly diff packages/web3-eth-personal/package.json -42 silly diffSinceIn v1.2.0 packages/web3-eth -43 silly diff packages/web3-eth/package.json -44 silly diffSinceIn v1.2.0 packages/web3-net -45 silly diff packages/web3-net/package.json -46 silly diffSinceIn v1.2.0 packages/web3-providers-http -47 silly diff packages/web3-providers-http/package.json -48 silly diffSinceIn v1.2.0 packages/web3-providers-ipc -49 silly diff packages/web3-providers-ipc/package.json -50 silly diffSinceIn v1.2.0 packages/web3-providers-ws -51 silly diff packages/web3-providers-ws/package-lock.json -51 silly diff packages/web3-providers-ws/package.json -51 silly diff packages/web3-providers-ws/src/index.js -52 silly diffSinceIn v1.2.0 packages/web3-shh -53 silly diff packages/web3-shh/package.json -54 silly diffSinceIn v1.2.0 packages/web3-utils -55 silly diff packages/web3-utils/package.json -56 silly diffSinceIn v1.2.0 packages/web3 -57 silly diff packages/web3/README.md -57 silly diff packages/web3/package.json -58 verbose updated web3-bzz -59 verbose updated web3-core-helpers -60 verbose updated web3-core-method -61 verbose updated web3-core-promievent -62 verbose updated web3-core-requestmanager -63 verbose updated web3-core-subscriptions -64 verbose updated web3-core -65 verbose updated web3-eth-abi -66 verbose updated web3-eth-accounts -67 verbose updated web3-eth-contract -68 verbose updated web3-eth-ens -69 verbose updated web3-eth-iban -70 verbose updated web3-eth-personal -71 verbose updated web3-eth -72 verbose updated web3-net -73 verbose updated web3-providers-http -74 verbose updated web3-providers-ipc -75 verbose updated web3-providers-ws -76 verbose updated web3-shh -77 verbose updated web3-utils -78 verbose updated web3 -79 info Checking for prereleased packages... -80 silly collectDependents -81 silly isPackageDependentOf web3-bzz web3-bzz -82 silly isPackageDependentOf web3-bzz web3-core-helpers -83 silly isPackageDependentOf web3-bzz web3-core-method -84 silly isPackageDependentOf web3-bzz web3-core-promievent -85 silly isPackageDependentOf web3-bzz web3-core-requestmanager -86 silly isPackageDependentOf web3-bzz web3-core-subscriptions -87 silly isPackageDependentOf web3-bzz web3-core -88 silly isPackageDependentOf web3-bzz web3-eth-abi -89 silly isPackageDependentOf web3-bzz web3-eth-accounts -90 silly isPackageDependentOf web3-bzz web3-eth-contract -91 silly isPackageDependentOf web3-bzz web3-eth-ens -92 silly isPackageDependentOf web3-bzz web3-eth-iban -93 silly isPackageDependentOf web3-bzz web3-eth-personal -94 silly isPackageDependentOf web3-bzz web3-eth -95 silly isPackageDependentOf web3-bzz web3-net -96 silly isPackageDependentOf web3-bzz web3-providers-http -97 silly isPackageDependentOf web3-bzz web3-providers-ipc -98 silly isPackageDependentOf web3-bzz web3-providers-ws -99 silly isPackageDependentOf web3-bzz web3-shh -100 silly isPackageDependentOf web3-bzz web3-utils -101 silly isPackageDependentOf web3-bzz web3 -102 silly isPackageDependentOf web3-core-helpers web3-bzz -103 silly isPackageDependentOf web3-eth-iban web3-bzz -104 silly isPackageDependentOf web3-utils web3-bzz -105 silly isPackageDependentOf web3-utils web3-bzz -106 silly isPackageDependentOf web3-core-helpers web3-core-helpers -107 silly isPackageDependentOf web3-eth-iban web3-core-helpers -108 silly isPackageDependentOf web3-utils web3-core-helpers -109 silly isPackageDependentOf web3-utils web3-core-helpers -110 silly isPackageDependentOf web3-core-helpers web3-core-method -111 silly isPackageDependentOf web3-eth-iban web3-core-method -112 silly isPackageDependentOf web3-utils web3-core-method -113 silly isPackageDependentOf web3-utils web3-core-method -114 silly isPackageDependentOf web3-core-helpers web3-core-promievent -115 silly isPackageDependentOf web3-eth-iban web3-core-promievent -116 silly isPackageDependentOf web3-utils web3-core-promievent -117 silly isPackageDependentOf web3-utils web3-core-promievent -118 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -119 silly isPackageDependentOf web3-eth-iban web3-core-requestmanager -120 silly isPackageDependentOf web3-utils web3-core-requestmanager -121 silly isPackageDependentOf web3-utils web3-core-requestmanager -122 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -123 silly isPackageDependentOf web3-eth-iban web3-core-subscriptions -124 silly isPackageDependentOf web3-utils web3-core-subscriptions -125 silly isPackageDependentOf web3-utils web3-core-subscriptions -126 silly isPackageDependentOf web3-core-helpers web3-core -127 silly isPackageDependentOf web3-eth-iban web3-core -128 silly isPackageDependentOf web3-utils web3-core -129 silly isPackageDependentOf web3-utils web3-core -130 silly isPackageDependentOf web3-core-helpers web3-eth-abi -131 silly isPackageDependentOf web3-eth-iban web3-eth-abi -132 silly isPackageDependentOf web3-utils web3-eth-abi -133 silly isPackageDependentOf web3-utils web3-eth-abi -134 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -135 silly isPackageDependentOf web3-eth-iban web3-eth-accounts -136 silly isPackageDependentOf web3-utils web3-eth-accounts -137 silly isPackageDependentOf web3-utils web3-eth-accounts -138 silly isPackageDependentOf web3-core-helpers web3-eth-contract -139 silly isPackageDependentOf web3-eth-iban web3-eth-contract -140 silly isPackageDependentOf web3-utils web3-eth-contract -141 silly isPackageDependentOf web3-utils web3-eth-contract -142 silly isPackageDependentOf web3-core-helpers web3-eth-ens -143 silly isPackageDependentOf web3-eth-iban web3-eth-ens -144 silly isPackageDependentOf web3-utils web3-eth-ens -145 silly isPackageDependentOf web3-utils web3-eth-ens -146 silly isPackageDependentOf web3-core-helpers web3-eth-iban -147 verbose dependent web3-core-helpers depends on web3-eth-iban -148 silly isPackageDependentOf web3-core-helpers web3-eth-personal -149 silly isPackageDependentOf web3-eth-iban web3-eth-personal -150 silly isPackageDependentOf web3-utils web3-eth-personal -151 silly isPackageDependentOf web3-utils web3-eth-personal -152 silly isPackageDependentOf web3-core-helpers web3-eth -153 silly isPackageDependentOf web3-eth-iban web3-eth -154 silly isPackageDependentOf web3-utils web3-eth -155 silly isPackageDependentOf web3-utils web3-eth -156 silly isPackageDependentOf web3-core-helpers web3-net -157 silly isPackageDependentOf web3-eth-iban web3-net -158 silly isPackageDependentOf web3-utils web3-net -159 silly isPackageDependentOf web3-utils web3-net -160 silly isPackageDependentOf web3-core-helpers web3-providers-http -161 silly isPackageDependentOf web3-eth-iban web3-providers-http -162 silly isPackageDependentOf web3-utils web3-providers-http -163 silly isPackageDependentOf web3-utils web3-providers-http -164 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -165 silly isPackageDependentOf web3-eth-iban web3-providers-ipc -166 silly isPackageDependentOf web3-utils web3-providers-ipc -167 silly isPackageDependentOf web3-utils web3-providers-ipc -168 silly isPackageDependentOf web3-core-helpers web3-providers-ws -169 silly isPackageDependentOf web3-eth-iban web3-providers-ws -170 silly isPackageDependentOf web3-utils web3-providers-ws -171 silly isPackageDependentOf web3-utils web3-providers-ws -172 silly isPackageDependentOf web3-core-helpers web3-shh -173 silly isPackageDependentOf web3-eth-iban web3-shh -174 silly isPackageDependentOf web3-utils web3-shh -175 silly isPackageDependentOf web3-utils web3-shh -176 silly isPackageDependentOf web3-core-helpers web3-utils -177 verbose dependent web3-core-helpers depends on web3-utils -178 silly isPackageDependentOf web3-core-helpers web3 -179 silly isPackageDependentOf web3-eth-iban web3 -180 silly isPackageDependentOf web3-utils web3 -181 silly isPackageDependentOf web3-utils web3 -182 silly isPackageDependentOf web3-core-method web3-bzz -183 silly isPackageDependentOf web3-core-helpers web3-bzz -184 silly isPackageDependentOf web3-core-promievent web3-bzz -185 silly isPackageDependentOf web3-core-subscriptions web3-bzz -186 silly isPackageDependentOf web3-core-helpers web3-bzz -187 silly isPackageDependentOf web3-utils web3-bzz -188 silly isPackageDependentOf web3-core-method web3-core-helpers -189 verbose dependent web3-core-method depends on web3-core-helpers -190 silly isPackageDependentOf web3-core-method web3-core-method -191 silly isPackageDependentOf web3-core-helpers web3-core-method -192 silly isPackageDependentOf web3-core-promievent web3-core-method -193 silly isPackageDependentOf web3-core-subscriptions web3-core-method -194 silly isPackageDependentOf web3-core-helpers web3-core-method -195 silly isPackageDependentOf web3-utils web3-core-method -196 silly isPackageDependentOf web3-core-method web3-core-promievent -197 verbose dependent web3-core-method depends on web3-core-promievent -198 silly isPackageDependentOf web3-core-method web3-core-requestmanager -199 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -200 silly isPackageDependentOf web3-core-promievent web3-core-requestmanager -201 silly isPackageDependentOf web3-core-subscriptions web3-core-requestmanager -202 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -203 silly isPackageDependentOf web3-utils web3-core-requestmanager -204 silly isPackageDependentOf web3-core-method web3-core-subscriptions -205 verbose dependent web3-core-method depends on web3-core-subscriptions -206 silly isPackageDependentOf web3-core-method web3-core -207 silly isPackageDependentOf web3-core-helpers web3-core -208 silly isPackageDependentOf web3-core-promievent web3-core -209 silly isPackageDependentOf web3-core-subscriptions web3-core -210 silly isPackageDependentOf web3-core-helpers web3-core -211 silly isPackageDependentOf web3-utils web3-core -212 silly isPackageDependentOf web3-core-method web3-eth-abi -213 silly isPackageDependentOf web3-core-helpers web3-eth-abi -214 silly isPackageDependentOf web3-core-promievent web3-eth-abi -215 silly isPackageDependentOf web3-core-subscriptions web3-eth-abi -216 silly isPackageDependentOf web3-core-helpers web3-eth-abi -217 silly isPackageDependentOf web3-utils web3-eth-abi -218 silly isPackageDependentOf web3-core-method web3-eth-accounts -219 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -220 silly isPackageDependentOf web3-core-promievent web3-eth-accounts -221 silly isPackageDependentOf web3-core-subscriptions web3-eth-accounts -222 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -223 silly isPackageDependentOf web3-utils web3-eth-accounts -224 silly isPackageDependentOf web3-core-method web3-eth-contract -225 silly isPackageDependentOf web3-core-helpers web3-eth-contract -226 silly isPackageDependentOf web3-core-promievent web3-eth-contract -227 silly isPackageDependentOf web3-core-subscriptions web3-eth-contract -228 silly isPackageDependentOf web3-core-helpers web3-eth-contract -229 silly isPackageDependentOf web3-utils web3-eth-contract -230 silly isPackageDependentOf web3-core-method web3-eth-ens -231 silly isPackageDependentOf web3-core-helpers web3-eth-ens -232 silly isPackageDependentOf web3-core-promievent web3-eth-ens -233 silly isPackageDependentOf web3-core-subscriptions web3-eth-ens -234 silly isPackageDependentOf web3-core-helpers web3-eth-ens -235 silly isPackageDependentOf web3-utils web3-eth-ens -236 silly isPackageDependentOf web3-core-method web3-eth-iban -237 silly isPackageDependentOf web3-core-helpers web3-eth-iban -238 silly isPackageDependentOf web3-core-promievent web3-eth-iban -239 silly isPackageDependentOf web3-core-subscriptions web3-eth-iban -240 silly isPackageDependentOf web3-core-helpers web3-eth-iban -241 silly isPackageDependentOf web3-utils web3-eth-iban -242 verbose dependent web3-core-method depends on web3-eth-iban -243 silly isPackageDependentOf web3-core-method web3-eth-personal -244 silly isPackageDependentOf web3-core-helpers web3-eth-personal -245 silly isPackageDependentOf web3-core-promievent web3-eth-personal -246 silly isPackageDependentOf web3-core-subscriptions web3-eth-personal -247 silly isPackageDependentOf web3-core-helpers web3-eth-personal -248 silly isPackageDependentOf web3-utils web3-eth-personal -249 silly isPackageDependentOf web3-core-method web3-eth -250 silly isPackageDependentOf web3-core-helpers web3-eth -251 silly isPackageDependentOf web3-core-promievent web3-eth -252 silly isPackageDependentOf web3-core-subscriptions web3-eth -253 silly isPackageDependentOf web3-core-helpers web3-eth -254 silly isPackageDependentOf web3-utils web3-eth -255 silly isPackageDependentOf web3-core-method web3-net -256 silly isPackageDependentOf web3-core-helpers web3-net -257 silly isPackageDependentOf web3-core-promievent web3-net -258 silly isPackageDependentOf web3-core-subscriptions web3-net -259 silly isPackageDependentOf web3-core-helpers web3-net -260 silly isPackageDependentOf web3-utils web3-net -261 silly isPackageDependentOf web3-core-method web3-providers-http -262 silly isPackageDependentOf web3-core-helpers web3-providers-http -263 silly isPackageDependentOf web3-core-promievent web3-providers-http -264 silly isPackageDependentOf web3-core-subscriptions web3-providers-http -265 silly isPackageDependentOf web3-core-helpers web3-providers-http -266 silly isPackageDependentOf web3-utils web3-providers-http -267 silly isPackageDependentOf web3-core-method web3-providers-ipc -268 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -269 silly isPackageDependentOf web3-core-promievent web3-providers-ipc -270 silly isPackageDependentOf web3-core-subscriptions web3-providers-ipc -271 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -272 silly isPackageDependentOf web3-utils web3-providers-ipc -273 silly isPackageDependentOf web3-core-method web3-providers-ws -274 silly isPackageDependentOf web3-core-helpers web3-providers-ws -275 silly isPackageDependentOf web3-core-promievent web3-providers-ws -276 silly isPackageDependentOf web3-core-subscriptions web3-providers-ws -277 silly isPackageDependentOf web3-core-helpers web3-providers-ws -278 silly isPackageDependentOf web3-utils web3-providers-ws -279 silly isPackageDependentOf web3-core-method web3-shh -280 silly isPackageDependentOf web3-core-helpers web3-shh -281 silly isPackageDependentOf web3-core-promievent web3-shh -282 silly isPackageDependentOf web3-core-subscriptions web3-shh -283 silly isPackageDependentOf web3-core-helpers web3-shh -284 silly isPackageDependentOf web3-utils web3-shh -285 silly isPackageDependentOf web3-core-method web3-utils -286 verbose dependent web3-core-method depends on web3-utils -287 silly isPackageDependentOf web3-core-method web3 -288 silly isPackageDependentOf web3-core-helpers web3 -289 silly isPackageDependentOf web3-core-promievent web3 -290 silly isPackageDependentOf web3-core-subscriptions web3 -291 silly isPackageDependentOf web3-core-helpers web3 -292 silly isPackageDependentOf web3-utils web3 -293 silly isPackageDependentOf web3-core-promievent web3-bzz -294 silly isPackageDependentOf web3-core-promievent web3-core-helpers -295 silly isPackageDependentOf web3-core-promievent web3-core-method -296 silly isPackageDependentOf web3-core-promievent web3-core-promievent -297 silly isPackageDependentOf web3-core-promievent web3-core-requestmanager -298 silly isPackageDependentOf web3-core-promievent web3-core-subscriptions -299 silly isPackageDependentOf web3-core-promievent web3-core -300 silly isPackageDependentOf web3-core-promievent web3-eth-abi -301 silly isPackageDependentOf web3-core-promievent web3-eth-accounts -302 silly isPackageDependentOf web3-core-promievent web3-eth-contract -303 silly isPackageDependentOf web3-core-promievent web3-eth-ens -304 silly isPackageDependentOf web3-core-promievent web3-eth-iban -305 silly isPackageDependentOf web3-core-promievent web3-eth-personal -306 silly isPackageDependentOf web3-core-promievent web3-eth -307 silly isPackageDependentOf web3-core-promievent web3-net -308 silly isPackageDependentOf web3-core-promievent web3-providers-http -309 silly isPackageDependentOf web3-core-promievent web3-providers-ipc -310 silly isPackageDependentOf web3-core-promievent web3-providers-ws -311 silly isPackageDependentOf web3-core-promievent web3-shh -312 silly isPackageDependentOf web3-core-promievent web3-utils -313 silly isPackageDependentOf web3-core-promievent web3 -314 silly isPackageDependentOf web3-core-requestmanager web3-bzz -315 silly isPackageDependentOf web3-core-helpers web3-bzz -316 silly isPackageDependentOf web3-providers-http web3-bzz -317 silly isPackageDependentOf web3-core-helpers web3-bzz -318 silly isPackageDependentOf web3-providers-ipc web3-bzz -319 silly isPackageDependentOf web3-core-helpers web3-bzz -320 silly isPackageDependentOf web3-providers-ws web3-bzz -321 silly isPackageDependentOf web3-core-helpers web3-bzz -322 silly isPackageDependentOf web3-core-requestmanager web3-core-helpers -323 verbose dependent web3-core-requestmanager depends on web3-core-helpers -324 silly isPackageDependentOf web3-core-requestmanager web3-core-method -325 silly isPackageDependentOf web3-core-helpers web3-core-method -326 silly isPackageDependentOf web3-providers-http web3-core-method -327 silly isPackageDependentOf web3-core-helpers web3-core-method -328 silly isPackageDependentOf web3-providers-ipc web3-core-method -329 silly isPackageDependentOf web3-core-helpers web3-core-method -330 silly isPackageDependentOf web3-providers-ws web3-core-method -331 silly isPackageDependentOf web3-core-helpers web3-core-method -332 silly isPackageDependentOf web3-core-requestmanager web3-core-promievent -333 silly isPackageDependentOf web3-core-helpers web3-core-promievent -334 silly isPackageDependentOf web3-providers-http web3-core-promievent -335 silly isPackageDependentOf web3-core-helpers web3-core-promievent -336 silly isPackageDependentOf web3-providers-ipc web3-core-promievent -337 silly isPackageDependentOf web3-core-helpers web3-core-promievent -338 silly isPackageDependentOf web3-providers-ws web3-core-promievent -339 silly isPackageDependentOf web3-core-helpers web3-core-promievent -340 silly isPackageDependentOf web3-core-requestmanager web3-core-requestmanager -341 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -342 silly isPackageDependentOf web3-providers-http web3-core-requestmanager -343 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -344 silly isPackageDependentOf web3-providers-ipc web3-core-requestmanager -345 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -346 silly isPackageDependentOf web3-providers-ws web3-core-requestmanager -347 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -348 silly isPackageDependentOf web3-core-requestmanager web3-core-subscriptions -349 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -350 silly isPackageDependentOf web3-providers-http web3-core-subscriptions -351 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -352 silly isPackageDependentOf web3-providers-ipc web3-core-subscriptions -353 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -354 silly isPackageDependentOf web3-providers-ws web3-core-subscriptions -355 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -356 silly isPackageDependentOf web3-core-requestmanager web3-core -357 silly isPackageDependentOf web3-core-helpers web3-core -358 silly isPackageDependentOf web3-providers-http web3-core -359 silly isPackageDependentOf web3-core-helpers web3-core -360 silly isPackageDependentOf web3-providers-ipc web3-core -361 silly isPackageDependentOf web3-core-helpers web3-core -362 silly isPackageDependentOf web3-providers-ws web3-core -363 silly isPackageDependentOf web3-core-helpers web3-core -364 silly isPackageDependentOf web3-core-requestmanager web3-eth-abi -365 silly isPackageDependentOf web3-core-helpers web3-eth-abi -366 silly isPackageDependentOf web3-providers-http web3-eth-abi -367 silly isPackageDependentOf web3-core-helpers web3-eth-abi -368 silly isPackageDependentOf web3-providers-ipc web3-eth-abi -369 silly isPackageDependentOf web3-core-helpers web3-eth-abi -370 silly isPackageDependentOf web3-providers-ws web3-eth-abi -371 silly isPackageDependentOf web3-core-helpers web3-eth-abi -372 silly isPackageDependentOf web3-core-requestmanager web3-eth-accounts -373 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -374 silly isPackageDependentOf web3-providers-http web3-eth-accounts -375 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -376 silly isPackageDependentOf web3-providers-ipc web3-eth-accounts -377 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -378 silly isPackageDependentOf web3-providers-ws web3-eth-accounts -379 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -380 silly isPackageDependentOf web3-core-requestmanager web3-eth-contract -381 silly isPackageDependentOf web3-core-helpers web3-eth-contract -382 silly isPackageDependentOf web3-providers-http web3-eth-contract -383 silly isPackageDependentOf web3-core-helpers web3-eth-contract -384 silly isPackageDependentOf web3-providers-ipc web3-eth-contract -385 silly isPackageDependentOf web3-core-helpers web3-eth-contract -386 silly isPackageDependentOf web3-providers-ws web3-eth-contract -387 silly isPackageDependentOf web3-core-helpers web3-eth-contract -388 silly isPackageDependentOf web3-core-requestmanager web3-eth-ens -389 silly isPackageDependentOf web3-core-helpers web3-eth-ens -390 silly isPackageDependentOf web3-providers-http web3-eth-ens -391 silly isPackageDependentOf web3-core-helpers web3-eth-ens -392 silly isPackageDependentOf web3-providers-ipc web3-eth-ens -393 silly isPackageDependentOf web3-core-helpers web3-eth-ens -394 silly isPackageDependentOf web3-providers-ws web3-eth-ens -395 silly isPackageDependentOf web3-core-helpers web3-eth-ens -396 silly isPackageDependentOf web3-core-requestmanager web3-eth-iban -397 silly isPackageDependentOf web3-core-helpers web3-eth-iban -398 silly isPackageDependentOf web3-providers-http web3-eth-iban -399 silly isPackageDependentOf web3-core-helpers web3-eth-iban -400 silly isPackageDependentOf web3-providers-ipc web3-eth-iban -401 silly isPackageDependentOf web3-core-helpers web3-eth-iban -402 silly isPackageDependentOf web3-providers-ws web3-eth-iban -403 silly isPackageDependentOf web3-core-helpers web3-eth-iban -404 verbose dependent web3-core-requestmanager depends on web3-eth-iban -405 silly isPackageDependentOf web3-core-requestmanager web3-eth-personal -406 silly isPackageDependentOf web3-core-helpers web3-eth-personal -407 silly isPackageDependentOf web3-providers-http web3-eth-personal -408 silly isPackageDependentOf web3-core-helpers web3-eth-personal -409 silly isPackageDependentOf web3-providers-ipc web3-eth-personal -410 silly isPackageDependentOf web3-core-helpers web3-eth-personal -411 silly isPackageDependentOf web3-providers-ws web3-eth-personal -412 silly isPackageDependentOf web3-core-helpers web3-eth-personal -413 silly isPackageDependentOf web3-core-requestmanager web3-eth -414 silly isPackageDependentOf web3-core-helpers web3-eth -415 silly isPackageDependentOf web3-providers-http web3-eth -416 silly isPackageDependentOf web3-core-helpers web3-eth -417 silly isPackageDependentOf web3-providers-ipc web3-eth -418 silly isPackageDependentOf web3-core-helpers web3-eth -419 silly isPackageDependentOf web3-providers-ws web3-eth -420 silly isPackageDependentOf web3-core-helpers web3-eth -421 silly isPackageDependentOf web3-core-requestmanager web3-net -422 silly isPackageDependentOf web3-core-helpers web3-net -423 silly isPackageDependentOf web3-providers-http web3-net -424 silly isPackageDependentOf web3-core-helpers web3-net -425 silly isPackageDependentOf web3-providers-ipc web3-net -426 silly isPackageDependentOf web3-core-helpers web3-net -427 silly isPackageDependentOf web3-providers-ws web3-net -428 silly isPackageDependentOf web3-core-helpers web3-net -429 silly isPackageDependentOf web3-core-requestmanager web3-providers-http -430 verbose dependent web3-core-requestmanager depends on web3-providers-http -431 silly isPackageDependentOf web3-core-requestmanager web3-providers-ipc -432 verbose dependent web3-core-requestmanager depends on web3-providers-ipc -433 silly isPackageDependentOf web3-core-requestmanager web3-providers-ws -434 verbose dependent web3-core-requestmanager depends on web3-providers-ws -435 silly isPackageDependentOf web3-core-requestmanager web3-shh -436 silly isPackageDependentOf web3-core-helpers web3-shh -437 silly isPackageDependentOf web3-providers-http web3-shh -438 silly isPackageDependentOf web3-core-helpers web3-shh -439 silly isPackageDependentOf web3-providers-ipc web3-shh -440 silly isPackageDependentOf web3-core-helpers web3-shh -441 silly isPackageDependentOf web3-providers-ws web3-shh -442 silly isPackageDependentOf web3-core-helpers web3-shh -443 silly isPackageDependentOf web3-core-requestmanager web3-utils -444 silly isPackageDependentOf web3-core-helpers web3-utils -445 silly isPackageDependentOf web3-providers-http web3-utils -446 silly isPackageDependentOf web3-core-helpers web3-utils -447 silly isPackageDependentOf web3-providers-ipc web3-utils -448 silly isPackageDependentOf web3-core-helpers web3-utils -449 silly isPackageDependentOf web3-providers-ws web3-utils -450 silly isPackageDependentOf web3-core-helpers web3-utils -451 verbose dependent web3-core-requestmanager depends on web3-utils -452 silly isPackageDependentOf web3-core-requestmanager web3 -453 silly isPackageDependentOf web3-core-helpers web3 -454 silly isPackageDependentOf web3-providers-http web3 -455 silly isPackageDependentOf web3-core-helpers web3 -456 silly isPackageDependentOf web3-providers-ipc web3 -457 silly isPackageDependentOf web3-core-helpers web3 -458 silly isPackageDependentOf web3-providers-ws web3 -459 silly isPackageDependentOf web3-core-helpers web3 -460 silly isPackageDependentOf web3-core-subscriptions web3-bzz -461 silly isPackageDependentOf web3-core-subscriptions web3-core-helpers -462 verbose dependent web3-core-subscriptions depends on web3-core-helpers -463 silly isPackageDependentOf web3-core-subscriptions web3-core-method -464 silly isPackageDependentOf web3-core-subscriptions web3-core-promievent -465 silly isPackageDependentOf web3-core-helpers web3-core-promievent -466 silly isPackageDependentOf web3-core-subscriptions web3-core-requestmanager -467 silly isPackageDependentOf web3-core-subscriptions web3-core-subscriptions -468 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -469 silly isPackageDependentOf web3-core-subscriptions web3-core -470 silly isPackageDependentOf web3-core-subscriptions web3-eth-abi -471 silly isPackageDependentOf web3-core-subscriptions web3-eth-accounts -472 silly isPackageDependentOf web3-core-subscriptions web3-eth-contract -473 silly isPackageDependentOf web3-core-subscriptions web3-eth-ens -474 silly isPackageDependentOf web3-core-subscriptions web3-eth-iban -475 verbose dependent web3-core-subscriptions depends on web3-eth-iban -476 silly isPackageDependentOf web3-core-subscriptions web3-eth-personal -477 silly isPackageDependentOf web3-core-subscriptions web3-eth -478 silly isPackageDependentOf web3-core-subscriptions web3-net -479 silly isPackageDependentOf web3-core-subscriptions web3-providers-http -480 silly isPackageDependentOf web3-core-subscriptions web3-providers-ipc -481 silly isPackageDependentOf web3-core-subscriptions web3-providers-ws -482 silly isPackageDependentOf web3-core-subscriptions web3-shh -483 silly isPackageDependentOf web3-core-subscriptions web3-utils -484 silly isPackageDependentOf web3-core-helpers web3-utils -485 verbose dependent web3-core-subscriptions depends on web3-utils -486 silly isPackageDependentOf web3-core-subscriptions web3 -487 silly isPackageDependentOf web3-core web3-bzz -488 silly isPackageDependentOf web3-core-helpers web3-bzz -489 silly isPackageDependentOf web3-core-method web3-bzz -490 silly isPackageDependentOf web3-core-requestmanager web3-bzz -491 silly isPackageDependentOf web3-utils web3-bzz -492 silly isPackageDependentOf web3-core web3-core-helpers -493 verbose dependent web3-core depends on web3-core-helpers -494 silly isPackageDependentOf web3-core web3-core-method -495 verbose dependent web3-core depends on web3-core-method -496 silly isPackageDependentOf web3-core web3-core-promievent -497 silly isPackageDependentOf web3-core-helpers web3-core-promievent -498 silly isPackageDependentOf web3-core-method web3-core-promievent -499 silly isPackageDependentOf web3-core-requestmanager web3-core-promievent -500 silly isPackageDependentOf web3-utils web3-core-promievent -501 verbose dependent web3-core depends on web3-core-promievent -502 silly isPackageDependentOf web3-core web3-core-requestmanager -503 verbose dependent web3-core depends on web3-core-requestmanager -504 silly isPackageDependentOf web3-core web3-core-subscriptions -505 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -506 silly isPackageDependentOf web3-core-method web3-core-subscriptions -507 silly isPackageDependentOf web3-core-requestmanager web3-core-subscriptions -508 silly isPackageDependentOf web3-utils web3-core-subscriptions -509 verbose dependent web3-core depends on web3-core-subscriptions -510 silly isPackageDependentOf web3-core web3-core -511 silly isPackageDependentOf web3-core-helpers web3-core -512 silly isPackageDependentOf web3-core-method web3-core -513 silly isPackageDependentOf web3-core-requestmanager web3-core -514 silly isPackageDependentOf web3-utils web3-core -515 silly isPackageDependentOf web3-core web3-eth-abi -516 silly isPackageDependentOf web3-core-helpers web3-eth-abi -517 silly isPackageDependentOf web3-core-method web3-eth-abi -518 silly isPackageDependentOf web3-core-requestmanager web3-eth-abi -519 silly isPackageDependentOf web3-utils web3-eth-abi -520 silly isPackageDependentOf web3-core web3-eth-accounts -521 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -522 silly isPackageDependentOf web3-core-method web3-eth-accounts -523 silly isPackageDependentOf web3-core-requestmanager web3-eth-accounts -524 silly isPackageDependentOf web3-utils web3-eth-accounts -525 silly isPackageDependentOf web3-core web3-eth-contract -526 silly isPackageDependentOf web3-core-helpers web3-eth-contract -527 silly isPackageDependentOf web3-core-method web3-eth-contract -528 silly isPackageDependentOf web3-core-requestmanager web3-eth-contract -529 silly isPackageDependentOf web3-utils web3-eth-contract -530 silly isPackageDependentOf web3-core web3-eth-ens -531 silly isPackageDependentOf web3-core-helpers web3-eth-ens -532 silly isPackageDependentOf web3-core-method web3-eth-ens -533 silly isPackageDependentOf web3-core-requestmanager web3-eth-ens -534 silly isPackageDependentOf web3-utils web3-eth-ens -535 silly isPackageDependentOf web3-core web3-eth-iban -536 silly isPackageDependentOf web3-core-helpers web3-eth-iban -537 silly isPackageDependentOf web3-core-method web3-eth-iban -538 silly isPackageDependentOf web3-core-requestmanager web3-eth-iban -539 silly isPackageDependentOf web3-utils web3-eth-iban -540 verbose dependent web3-core depends on web3-eth-iban -541 silly isPackageDependentOf web3-core web3-eth-personal -542 silly isPackageDependentOf web3-core-helpers web3-eth-personal -543 silly isPackageDependentOf web3-core-method web3-eth-personal -544 silly isPackageDependentOf web3-core-requestmanager web3-eth-personal -545 silly isPackageDependentOf web3-utils web3-eth-personal -546 silly isPackageDependentOf web3-core web3-eth -547 silly isPackageDependentOf web3-core-helpers web3-eth -548 silly isPackageDependentOf web3-core-method web3-eth -549 silly isPackageDependentOf web3-core-requestmanager web3-eth -550 silly isPackageDependentOf web3-utils web3-eth -551 silly isPackageDependentOf web3-core web3-net -552 silly isPackageDependentOf web3-core-helpers web3-net -553 silly isPackageDependentOf web3-core-method web3-net -554 silly isPackageDependentOf web3-core-requestmanager web3-net -555 silly isPackageDependentOf web3-utils web3-net -556 silly isPackageDependentOf web3-core web3-providers-http -557 silly isPackageDependentOf web3-core-helpers web3-providers-http -558 silly isPackageDependentOf web3-core-method web3-providers-http -559 silly isPackageDependentOf web3-core-requestmanager web3-providers-http -560 silly isPackageDependentOf web3-utils web3-providers-http -561 verbose dependent web3-core depends on web3-providers-http -562 silly isPackageDependentOf web3-core web3-providers-ipc -563 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -564 silly isPackageDependentOf web3-core-method web3-providers-ipc -565 silly isPackageDependentOf web3-core-requestmanager web3-providers-ipc -566 silly isPackageDependentOf web3-utils web3-providers-ipc -567 verbose dependent web3-core depends on web3-providers-ipc -568 silly isPackageDependentOf web3-core web3-providers-ws -569 silly isPackageDependentOf web3-core-helpers web3-providers-ws -570 silly isPackageDependentOf web3-core-method web3-providers-ws -571 silly isPackageDependentOf web3-core-requestmanager web3-providers-ws -572 silly isPackageDependentOf web3-utils web3-providers-ws -573 verbose dependent web3-core depends on web3-providers-ws -574 silly isPackageDependentOf web3-core web3-shh -575 silly isPackageDependentOf web3-core-helpers web3-shh -576 silly isPackageDependentOf web3-core-method web3-shh -577 silly isPackageDependentOf web3-core-requestmanager web3-shh -578 silly isPackageDependentOf web3-utils web3-shh -579 silly isPackageDependentOf web3-core web3-utils -580 verbose dependent web3-core depends on web3-utils -581 silly isPackageDependentOf web3-core web3 -582 silly isPackageDependentOf web3-core-helpers web3 -583 silly isPackageDependentOf web3-core-method web3 -584 silly isPackageDependentOf web3-core-requestmanager web3 -585 silly isPackageDependentOf web3-utils web3 -586 silly isPackageDependentOf web3-eth-abi web3-bzz -587 silly isPackageDependentOf web3-utils web3-bzz -588 silly isPackageDependentOf web3-eth-abi web3-core-helpers -589 silly isPackageDependentOf web3-utils web3-core-helpers -590 silly isPackageDependentOf web3-eth-abi web3-core-method -591 silly isPackageDependentOf web3-utils web3-core-method -592 silly isPackageDependentOf web3-eth-abi web3-core-promievent -593 silly isPackageDependentOf web3-utils web3-core-promievent -594 silly isPackageDependentOf web3-eth-abi web3-core-requestmanager -595 silly isPackageDependentOf web3-utils web3-core-requestmanager -596 silly isPackageDependentOf web3-eth-abi web3-core-subscriptions -597 silly isPackageDependentOf web3-utils web3-core-subscriptions -598 silly isPackageDependentOf web3-eth-abi web3-core -599 silly isPackageDependentOf web3-utils web3-core -600 silly isPackageDependentOf web3-eth-abi web3-eth-abi -601 silly isPackageDependentOf web3-utils web3-eth-abi -602 silly isPackageDependentOf web3-eth-abi web3-eth-accounts -603 silly isPackageDependentOf web3-utils web3-eth-accounts -604 silly isPackageDependentOf web3-eth-abi web3-eth-contract -605 silly isPackageDependentOf web3-utils web3-eth-contract -606 silly isPackageDependentOf web3-eth-abi web3-eth-ens -607 silly isPackageDependentOf web3-utils web3-eth-ens -608 silly isPackageDependentOf web3-eth-abi web3-eth-iban -609 silly isPackageDependentOf web3-utils web3-eth-iban -610 silly isPackageDependentOf web3-eth-abi web3-eth-personal -611 silly isPackageDependentOf web3-utils web3-eth-personal -612 silly isPackageDependentOf web3-eth-abi web3-eth -613 silly isPackageDependentOf web3-utils web3-eth -614 silly isPackageDependentOf web3-eth-abi web3-net -615 silly isPackageDependentOf web3-utils web3-net -616 silly isPackageDependentOf web3-eth-abi web3-providers-http -617 silly isPackageDependentOf web3-utils web3-providers-http -618 silly isPackageDependentOf web3-eth-abi web3-providers-ipc -619 silly isPackageDependentOf web3-utils web3-providers-ipc -620 silly isPackageDependentOf web3-eth-abi web3-providers-ws -621 silly isPackageDependentOf web3-utils web3-providers-ws -622 silly isPackageDependentOf web3-eth-abi web3-shh -623 silly isPackageDependentOf web3-utils web3-shh -624 silly isPackageDependentOf web3-eth-abi web3-utils -625 verbose dependent web3-eth-abi depends on web3-utils -626 silly isPackageDependentOf web3-eth-abi web3 -627 silly isPackageDependentOf web3-utils web3 -628 silly isPackageDependentOf web3-eth-accounts web3-bzz -629 silly isPackageDependentOf web3-core web3-bzz -630 silly isPackageDependentOf web3-core-helpers web3-bzz -631 silly isPackageDependentOf web3-core-method web3-bzz -632 silly isPackageDependentOf web3-utils web3-bzz -633 silly isPackageDependentOf web3-eth-accounts web3-core-helpers -634 verbose dependent web3-eth-accounts depends on web3-core-helpers -635 silly isPackageDependentOf web3-eth-accounts web3-core-method -636 verbose dependent web3-eth-accounts depends on web3-core-method -637 silly isPackageDependentOf web3-eth-accounts web3-core-promievent -638 silly isPackageDependentOf web3-core web3-core-promievent -639 silly isPackageDependentOf web3-core-helpers web3-core-promievent -640 silly isPackageDependentOf web3-core-method web3-core-promievent -641 silly isPackageDependentOf web3-utils web3-core-promievent -642 verbose dependent web3-eth-accounts depends on web3-core-promievent -643 silly isPackageDependentOf web3-eth-accounts web3-core-requestmanager -644 silly isPackageDependentOf web3-core web3-core-requestmanager -645 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -646 silly isPackageDependentOf web3-core-method web3-core-requestmanager -647 silly isPackageDependentOf web3-utils web3-core-requestmanager -648 verbose dependent web3-eth-accounts depends on web3-core-requestmanager -649 silly isPackageDependentOf web3-eth-accounts web3-core-subscriptions -650 silly isPackageDependentOf web3-core web3-core-subscriptions -651 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -652 silly isPackageDependentOf web3-core-method web3-core-subscriptions -653 silly isPackageDependentOf web3-utils web3-core-subscriptions -654 verbose dependent web3-eth-accounts depends on web3-core-subscriptions -655 silly isPackageDependentOf web3-eth-accounts web3-core -656 verbose dependent web3-eth-accounts depends on web3-core -657 silly isPackageDependentOf web3-eth-accounts web3-eth-abi -658 silly isPackageDependentOf web3-core web3-eth-abi -659 silly isPackageDependentOf web3-core-helpers web3-eth-abi -660 silly isPackageDependentOf web3-core-method web3-eth-abi -661 silly isPackageDependentOf web3-utils web3-eth-abi -662 silly isPackageDependentOf web3-eth-accounts web3-eth-accounts -663 silly isPackageDependentOf web3-core web3-eth-accounts -664 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -665 silly isPackageDependentOf web3-core-method web3-eth-accounts -666 silly isPackageDependentOf web3-utils web3-eth-accounts -667 silly isPackageDependentOf web3-eth-accounts web3-eth-contract -668 silly isPackageDependentOf web3-core web3-eth-contract -669 silly isPackageDependentOf web3-core-helpers web3-eth-contract -670 silly isPackageDependentOf web3-core-method web3-eth-contract -671 silly isPackageDependentOf web3-utils web3-eth-contract -672 silly isPackageDependentOf web3-eth-accounts web3-eth-ens -673 silly isPackageDependentOf web3-core web3-eth-ens -674 silly isPackageDependentOf web3-core-helpers web3-eth-ens -675 silly isPackageDependentOf web3-core-method web3-eth-ens -676 silly isPackageDependentOf web3-utils web3-eth-ens -677 silly isPackageDependentOf web3-eth-accounts web3-eth-iban -678 silly isPackageDependentOf web3-core web3-eth-iban -679 silly isPackageDependentOf web3-core-helpers web3-eth-iban -680 silly isPackageDependentOf web3-core-method web3-eth-iban -681 silly isPackageDependentOf web3-utils web3-eth-iban -682 verbose dependent web3-eth-accounts depends on web3-eth-iban -683 silly isPackageDependentOf web3-eth-accounts web3-eth-personal -684 silly isPackageDependentOf web3-core web3-eth-personal -685 silly isPackageDependentOf web3-core-helpers web3-eth-personal -686 silly isPackageDependentOf web3-core-method web3-eth-personal -687 silly isPackageDependentOf web3-utils web3-eth-personal -688 silly isPackageDependentOf web3-eth-accounts web3-eth -689 silly isPackageDependentOf web3-core web3-eth -690 silly isPackageDependentOf web3-core-helpers web3-eth -691 silly isPackageDependentOf web3-core-method web3-eth -692 silly isPackageDependentOf web3-utils web3-eth -693 silly isPackageDependentOf web3-eth-accounts web3-net -694 silly isPackageDependentOf web3-core web3-net -695 silly isPackageDependentOf web3-core-helpers web3-net -696 silly isPackageDependentOf web3-core-method web3-net -697 silly isPackageDependentOf web3-utils web3-net -698 silly isPackageDependentOf web3-eth-accounts web3-providers-http -699 silly isPackageDependentOf web3-core web3-providers-http -700 silly isPackageDependentOf web3-core-helpers web3-providers-http -701 silly isPackageDependentOf web3-core-method web3-providers-http -702 silly isPackageDependentOf web3-utils web3-providers-http -703 verbose dependent web3-eth-accounts depends on web3-providers-http -704 silly isPackageDependentOf web3-eth-accounts web3-providers-ipc -705 silly isPackageDependentOf web3-core web3-providers-ipc -706 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -707 silly isPackageDependentOf web3-core-method web3-providers-ipc -708 silly isPackageDependentOf web3-utils web3-providers-ipc -709 verbose dependent web3-eth-accounts depends on web3-providers-ipc -710 silly isPackageDependentOf web3-eth-accounts web3-providers-ws -711 silly isPackageDependentOf web3-core web3-providers-ws -712 silly isPackageDependentOf web3-core-helpers web3-providers-ws -713 silly isPackageDependentOf web3-core-method web3-providers-ws -714 silly isPackageDependentOf web3-utils web3-providers-ws -715 verbose dependent web3-eth-accounts depends on web3-providers-ws -716 silly isPackageDependentOf web3-eth-accounts web3-shh -717 silly isPackageDependentOf web3-core web3-shh -718 silly isPackageDependentOf web3-core-helpers web3-shh -719 silly isPackageDependentOf web3-core-method web3-shh -720 silly isPackageDependentOf web3-utils web3-shh -721 silly isPackageDependentOf web3-eth-accounts web3-utils -722 verbose dependent web3-eth-accounts depends on web3-utils -723 silly isPackageDependentOf web3-eth-accounts web3 -724 silly isPackageDependentOf web3-core web3 -725 silly isPackageDependentOf web3-core-helpers web3 -726 silly isPackageDependentOf web3-core-method web3 -727 silly isPackageDependentOf web3-utils web3 -728 silly isPackageDependentOf web3-eth-contract web3-bzz -729 silly isPackageDependentOf web3-core web3-bzz -730 silly isPackageDependentOf web3-core-helpers web3-bzz -731 silly isPackageDependentOf web3-core-method web3-bzz -732 silly isPackageDependentOf web3-core-promievent web3-bzz -733 silly isPackageDependentOf web3-core-subscriptions web3-bzz -734 silly isPackageDependentOf web3-eth-abi web3-bzz -735 silly isPackageDependentOf web3-utils web3-bzz -736 silly isPackageDependentOf web3-eth-contract web3-core-helpers -737 verbose dependent web3-eth-contract depends on web3-core-helpers -738 silly isPackageDependentOf web3-eth-contract web3-core-method -739 verbose dependent web3-eth-contract depends on web3-core-method -740 silly isPackageDependentOf web3-eth-contract web3-core-promievent -741 verbose dependent web3-eth-contract depends on web3-core-promievent -742 silly isPackageDependentOf web3-eth-contract web3-core-requestmanager -743 silly isPackageDependentOf web3-core web3-core-requestmanager -744 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -745 silly isPackageDependentOf web3-core-method web3-core-requestmanager -746 silly isPackageDependentOf web3-core-promievent web3-core-requestmanager -747 silly isPackageDependentOf web3-core-subscriptions web3-core-requestmanager -748 silly isPackageDependentOf web3-eth-abi web3-core-requestmanager -749 silly isPackageDependentOf web3-utils web3-core-requestmanager -750 verbose dependent web3-eth-contract depends on web3-core-requestmanager -751 silly isPackageDependentOf web3-eth-contract web3-core-subscriptions -752 verbose dependent web3-eth-contract depends on web3-core-subscriptions -753 silly isPackageDependentOf web3-eth-contract web3-core -754 verbose dependent web3-eth-contract depends on web3-core -755 silly isPackageDependentOf web3-eth-contract web3-eth-abi -756 verbose dependent web3-eth-contract depends on web3-eth-abi -757 silly isPackageDependentOf web3-eth-contract web3-eth-accounts -758 silly isPackageDependentOf web3-core web3-eth-accounts -759 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -760 silly isPackageDependentOf web3-core-method web3-eth-accounts -761 silly isPackageDependentOf web3-core-promievent web3-eth-accounts -762 silly isPackageDependentOf web3-core-subscriptions web3-eth-accounts -763 silly isPackageDependentOf web3-eth-abi web3-eth-accounts -764 silly isPackageDependentOf web3-utils web3-eth-accounts -765 silly isPackageDependentOf web3-eth-contract web3-eth-contract -766 silly isPackageDependentOf web3-core web3-eth-contract -767 silly isPackageDependentOf web3-core-helpers web3-eth-contract -768 silly isPackageDependentOf web3-core-method web3-eth-contract -769 silly isPackageDependentOf web3-core-promievent web3-eth-contract -770 silly isPackageDependentOf web3-core-subscriptions web3-eth-contract -771 silly isPackageDependentOf web3-eth-abi web3-eth-contract -772 silly isPackageDependentOf web3-utils web3-eth-contract -773 silly isPackageDependentOf web3-eth-contract web3-eth-ens -774 silly isPackageDependentOf web3-core web3-eth-ens -775 silly isPackageDependentOf web3-core-helpers web3-eth-ens -776 silly isPackageDependentOf web3-core-method web3-eth-ens -777 silly isPackageDependentOf web3-core-promievent web3-eth-ens -778 silly isPackageDependentOf web3-core-subscriptions web3-eth-ens -779 silly isPackageDependentOf web3-eth-abi web3-eth-ens -780 silly isPackageDependentOf web3-utils web3-eth-ens -781 silly isPackageDependentOf web3-eth-contract web3-eth-iban -782 silly isPackageDependentOf web3-core web3-eth-iban -783 silly isPackageDependentOf web3-core-helpers web3-eth-iban -784 silly isPackageDependentOf web3-core-method web3-eth-iban -785 silly isPackageDependentOf web3-core-promievent web3-eth-iban -786 silly isPackageDependentOf web3-core-subscriptions web3-eth-iban -787 silly isPackageDependentOf web3-eth-abi web3-eth-iban -788 silly isPackageDependentOf web3-utils web3-eth-iban -789 verbose dependent web3-eth-contract depends on web3-eth-iban -790 silly isPackageDependentOf web3-eth-contract web3-eth-personal -791 silly isPackageDependentOf web3-core web3-eth-personal -792 silly isPackageDependentOf web3-core-helpers web3-eth-personal -793 silly isPackageDependentOf web3-core-method web3-eth-personal -794 silly isPackageDependentOf web3-core-promievent web3-eth-personal -795 silly isPackageDependentOf web3-core-subscriptions web3-eth-personal -796 silly isPackageDependentOf web3-eth-abi web3-eth-personal -797 silly isPackageDependentOf web3-utils web3-eth-personal -798 silly isPackageDependentOf web3-eth-contract web3-eth -799 silly isPackageDependentOf web3-core web3-eth -800 silly isPackageDependentOf web3-core-helpers web3-eth -801 silly isPackageDependentOf web3-core-method web3-eth -802 silly isPackageDependentOf web3-core-promievent web3-eth -803 silly isPackageDependentOf web3-core-subscriptions web3-eth -804 silly isPackageDependentOf web3-eth-abi web3-eth -805 silly isPackageDependentOf web3-utils web3-eth -806 silly isPackageDependentOf web3-eth-contract web3-net -807 silly isPackageDependentOf web3-core web3-net -808 silly isPackageDependentOf web3-core-helpers web3-net -809 silly isPackageDependentOf web3-core-method web3-net -810 silly isPackageDependentOf web3-core-promievent web3-net -811 silly isPackageDependentOf web3-core-subscriptions web3-net -812 silly isPackageDependentOf web3-eth-abi web3-net -813 silly isPackageDependentOf web3-utils web3-net -814 silly isPackageDependentOf web3-eth-contract web3-providers-http -815 silly isPackageDependentOf web3-core web3-providers-http -816 silly isPackageDependentOf web3-core-helpers web3-providers-http -817 silly isPackageDependentOf web3-core-method web3-providers-http -818 silly isPackageDependentOf web3-core-promievent web3-providers-http -819 silly isPackageDependentOf web3-core-subscriptions web3-providers-http -820 silly isPackageDependentOf web3-eth-abi web3-providers-http -821 silly isPackageDependentOf web3-utils web3-providers-http -822 verbose dependent web3-eth-contract depends on web3-providers-http -823 silly isPackageDependentOf web3-eth-contract web3-providers-ipc -824 silly isPackageDependentOf web3-core web3-providers-ipc -825 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -826 silly isPackageDependentOf web3-core-method web3-providers-ipc -827 silly isPackageDependentOf web3-core-promievent web3-providers-ipc -828 silly isPackageDependentOf web3-core-subscriptions web3-providers-ipc -829 silly isPackageDependentOf web3-eth-abi web3-providers-ipc -830 silly isPackageDependentOf web3-utils web3-providers-ipc -831 verbose dependent web3-eth-contract depends on web3-providers-ipc -832 silly isPackageDependentOf web3-eth-contract web3-providers-ws -833 silly isPackageDependentOf web3-core web3-providers-ws -834 silly isPackageDependentOf web3-core-helpers web3-providers-ws -835 silly isPackageDependentOf web3-core-method web3-providers-ws -836 silly isPackageDependentOf web3-core-promievent web3-providers-ws -837 silly isPackageDependentOf web3-core-subscriptions web3-providers-ws -838 silly isPackageDependentOf web3-eth-abi web3-providers-ws -839 silly isPackageDependentOf web3-utils web3-providers-ws -840 verbose dependent web3-eth-contract depends on web3-providers-ws -841 silly isPackageDependentOf web3-eth-contract web3-shh -842 silly isPackageDependentOf web3-core web3-shh -843 silly isPackageDependentOf web3-core-helpers web3-shh -844 silly isPackageDependentOf web3-core-method web3-shh -845 silly isPackageDependentOf web3-core-promievent web3-shh -846 silly isPackageDependentOf web3-core-subscriptions web3-shh -847 silly isPackageDependentOf web3-eth-abi web3-shh -848 silly isPackageDependentOf web3-utils web3-shh -849 silly isPackageDependentOf web3-eth-contract web3-utils -850 verbose dependent web3-eth-contract depends on web3-utils -851 silly isPackageDependentOf web3-eth-contract web3 -852 silly isPackageDependentOf web3-core web3 -853 silly isPackageDependentOf web3-core-helpers web3 -854 silly isPackageDependentOf web3-core-method web3 -855 silly isPackageDependentOf web3-core-promievent web3 -856 silly isPackageDependentOf web3-core-subscriptions web3 -857 silly isPackageDependentOf web3-eth-abi web3 -858 silly isPackageDependentOf web3-utils web3 -859 silly isPackageDependentOf web3-eth-ens web3-bzz -860 silly isPackageDependentOf web3-core web3-bzz -861 silly isPackageDependentOf web3-core-helpers web3-bzz -862 silly isPackageDependentOf web3-core-promievent web3-bzz -863 silly isPackageDependentOf web3-eth-abi web3-bzz -864 silly isPackageDependentOf web3-eth-contract web3-bzz -865 silly isPackageDependentOf web3-utils web3-bzz -866 silly isPackageDependentOf web3-eth-ens web3-core-helpers -867 verbose dependent web3-eth-ens depends on web3-core-helpers -868 silly isPackageDependentOf web3-eth-ens web3-core-method -869 silly isPackageDependentOf web3-core web3-core-method -870 silly isPackageDependentOf web3-core-helpers web3-core-method -871 silly isPackageDependentOf web3-core-promievent web3-core-method -872 silly isPackageDependentOf web3-eth-abi web3-core-method -873 silly isPackageDependentOf web3-eth-contract web3-core-method -874 silly isPackageDependentOf web3-utils web3-core-method -875 verbose dependent web3-eth-ens depends on web3-core-method -876 silly isPackageDependentOf web3-eth-ens web3-core-promievent -877 verbose dependent web3-eth-ens depends on web3-core-promievent -878 silly isPackageDependentOf web3-eth-ens web3-core-requestmanager -879 silly isPackageDependentOf web3-core web3-core-requestmanager -880 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -881 silly isPackageDependentOf web3-core-promievent web3-core-requestmanager -882 silly isPackageDependentOf web3-eth-abi web3-core-requestmanager -883 silly isPackageDependentOf web3-eth-contract web3-core-requestmanager -884 silly isPackageDependentOf web3-utils web3-core-requestmanager -885 verbose dependent web3-eth-ens depends on web3-core-requestmanager -886 silly isPackageDependentOf web3-eth-ens web3-core-subscriptions -887 silly isPackageDependentOf web3-core web3-core-subscriptions -888 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -889 silly isPackageDependentOf web3-core-promievent web3-core-subscriptions -890 silly isPackageDependentOf web3-eth-abi web3-core-subscriptions -891 silly isPackageDependentOf web3-eth-contract web3-core-subscriptions -892 silly isPackageDependentOf web3-utils web3-core-subscriptions -893 verbose dependent web3-eth-ens depends on web3-core-subscriptions -894 silly isPackageDependentOf web3-eth-ens web3-core -895 verbose dependent web3-eth-ens depends on web3-core -896 silly isPackageDependentOf web3-eth-ens web3-eth-abi -897 verbose dependent web3-eth-ens depends on web3-eth-abi -898 silly isPackageDependentOf web3-eth-ens web3-eth-accounts -899 silly isPackageDependentOf web3-core web3-eth-accounts -900 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -901 silly isPackageDependentOf web3-core-promievent web3-eth-accounts -902 silly isPackageDependentOf web3-eth-abi web3-eth-accounts -903 silly isPackageDependentOf web3-eth-contract web3-eth-accounts -904 silly isPackageDependentOf web3-utils web3-eth-accounts -905 silly isPackageDependentOf web3-eth-ens web3-eth-contract -906 verbose dependent web3-eth-ens depends on web3-eth-contract -907 silly isPackageDependentOf web3-eth-ens web3-eth-ens -908 silly isPackageDependentOf web3-core web3-eth-ens -909 silly isPackageDependentOf web3-core-helpers web3-eth-ens -910 silly isPackageDependentOf web3-core-promievent web3-eth-ens -911 silly isPackageDependentOf web3-eth-abi web3-eth-ens -912 silly isPackageDependentOf web3-eth-contract web3-eth-ens -913 silly isPackageDependentOf web3-utils web3-eth-ens -914 silly isPackageDependentOf web3-eth-ens web3-eth-iban -915 silly isPackageDependentOf web3-core web3-eth-iban -916 silly isPackageDependentOf web3-core-helpers web3-eth-iban -917 silly isPackageDependentOf web3-core-promievent web3-eth-iban -918 silly isPackageDependentOf web3-eth-abi web3-eth-iban -919 silly isPackageDependentOf web3-eth-contract web3-eth-iban -920 silly isPackageDependentOf web3-utils web3-eth-iban -921 verbose dependent web3-eth-ens depends on web3-eth-iban -922 silly isPackageDependentOf web3-eth-ens web3-eth-personal -923 silly isPackageDependentOf web3-core web3-eth-personal -924 silly isPackageDependentOf web3-core-helpers web3-eth-personal -925 silly isPackageDependentOf web3-core-promievent web3-eth-personal -926 silly isPackageDependentOf web3-eth-abi web3-eth-personal -927 silly isPackageDependentOf web3-eth-contract web3-eth-personal -928 silly isPackageDependentOf web3-utils web3-eth-personal -929 silly isPackageDependentOf web3-eth-ens web3-eth -930 silly isPackageDependentOf web3-core web3-eth -931 silly isPackageDependentOf web3-core-helpers web3-eth -932 silly isPackageDependentOf web3-core-promievent web3-eth -933 silly isPackageDependentOf web3-eth-abi web3-eth -934 silly isPackageDependentOf web3-eth-contract web3-eth -935 silly isPackageDependentOf web3-utils web3-eth -936 silly isPackageDependentOf web3-eth-ens web3-net -937 silly isPackageDependentOf web3-core web3-net -938 silly isPackageDependentOf web3-core-helpers web3-net -939 silly isPackageDependentOf web3-core-promievent web3-net -940 silly isPackageDependentOf web3-eth-abi web3-net -941 silly isPackageDependentOf web3-eth-contract web3-net -942 silly isPackageDependentOf web3-utils web3-net -943 silly isPackageDependentOf web3-eth-ens web3-providers-http -944 silly isPackageDependentOf web3-core web3-providers-http -945 silly isPackageDependentOf web3-core-helpers web3-providers-http -946 silly isPackageDependentOf web3-core-promievent web3-providers-http -947 silly isPackageDependentOf web3-eth-abi web3-providers-http -948 silly isPackageDependentOf web3-eth-contract web3-providers-http -949 silly isPackageDependentOf web3-utils web3-providers-http -950 verbose dependent web3-eth-ens depends on web3-providers-http -951 silly isPackageDependentOf web3-eth-ens web3-providers-ipc -952 silly isPackageDependentOf web3-core web3-providers-ipc -953 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -954 silly isPackageDependentOf web3-core-promievent web3-providers-ipc -955 silly isPackageDependentOf web3-eth-abi web3-providers-ipc -956 silly isPackageDependentOf web3-eth-contract web3-providers-ipc -957 silly isPackageDependentOf web3-utils web3-providers-ipc -958 verbose dependent web3-eth-ens depends on web3-providers-ipc -959 silly isPackageDependentOf web3-eth-ens web3-providers-ws -960 silly isPackageDependentOf web3-core web3-providers-ws -961 silly isPackageDependentOf web3-core-helpers web3-providers-ws -962 silly isPackageDependentOf web3-core-promievent web3-providers-ws -963 silly isPackageDependentOf web3-eth-abi web3-providers-ws -964 silly isPackageDependentOf web3-eth-contract web3-providers-ws -965 silly isPackageDependentOf web3-utils web3-providers-ws -966 verbose dependent web3-eth-ens depends on web3-providers-ws -967 silly isPackageDependentOf web3-eth-ens web3-shh -968 silly isPackageDependentOf web3-core web3-shh -969 silly isPackageDependentOf web3-core-helpers web3-shh -970 silly isPackageDependentOf web3-core-promievent web3-shh -971 silly isPackageDependentOf web3-eth-abi web3-shh -972 silly isPackageDependentOf web3-eth-contract web3-shh -973 silly isPackageDependentOf web3-utils web3-shh -974 silly isPackageDependentOf web3-eth-ens web3-utils -975 verbose dependent web3-eth-ens depends on web3-utils -976 silly isPackageDependentOf web3-eth-ens web3 -977 silly isPackageDependentOf web3-core web3 -978 silly isPackageDependentOf web3-core-helpers web3 -979 silly isPackageDependentOf web3-core-promievent web3 -980 silly isPackageDependentOf web3-eth-abi web3 -981 silly isPackageDependentOf web3-eth-contract web3 -982 silly isPackageDependentOf web3-utils web3 -983 silly isPackageDependentOf web3-eth-iban web3-bzz -984 silly isPackageDependentOf web3-eth-iban web3-core-helpers -985 silly isPackageDependentOf web3-eth-iban web3-core-method -986 silly isPackageDependentOf web3-eth-iban web3-core-promievent -987 silly isPackageDependentOf web3-eth-iban web3-core-requestmanager -988 silly isPackageDependentOf web3-eth-iban web3-core-subscriptions -989 silly isPackageDependentOf web3-eth-iban web3-core -990 silly isPackageDependentOf web3-eth-iban web3-eth-abi -991 silly isPackageDependentOf web3-eth-iban web3-eth-accounts -992 silly isPackageDependentOf web3-eth-iban web3-eth-contract -993 silly isPackageDependentOf web3-eth-iban web3-eth-ens -994 silly isPackageDependentOf web3-eth-iban web3-eth-iban -995 silly isPackageDependentOf web3-utils web3-eth-iban -996 silly isPackageDependentOf web3-eth-iban web3-eth-personal -997 silly isPackageDependentOf web3-eth-iban web3-eth -998 silly isPackageDependentOf web3-eth-iban web3-net -999 silly isPackageDependentOf web3-eth-iban web3-providers-http -1000 silly isPackageDependentOf web3-eth-iban web3-providers-ipc -1001 silly isPackageDependentOf web3-eth-iban web3-providers-ws -1002 silly isPackageDependentOf web3-eth-iban web3-shh -1003 silly isPackageDependentOf web3-eth-iban web3-utils -1004 verbose dependent web3-eth-iban depends on web3-utils -1005 silly isPackageDependentOf web3-eth-iban web3 -1006 silly isPackageDependentOf web3-eth-personal web3-bzz -1007 silly isPackageDependentOf web3-core web3-bzz -1008 silly isPackageDependentOf web3-core-helpers web3-bzz -1009 silly isPackageDependentOf web3-core-method web3-bzz -1010 silly isPackageDependentOf web3-net web3-bzz -1011 silly isPackageDependentOf web3-core web3-bzz -1012 silly isPackageDependentOf web3-core-method web3-bzz -1013 silly isPackageDependentOf web3-utils web3-bzz -1014 silly isPackageDependentOf web3-utils web3-bzz -1015 silly isPackageDependentOf web3-eth-personal web3-core-helpers -1016 verbose dependent web3-eth-personal depends on web3-core-helpers -1017 silly isPackageDependentOf web3-eth-personal web3-core-method -1018 verbose dependent web3-eth-personal depends on web3-core-method -1019 silly isPackageDependentOf web3-eth-personal web3-core-promievent -1020 silly isPackageDependentOf web3-core web3-core-promievent -1021 silly isPackageDependentOf web3-core-helpers web3-core-promievent -1022 silly isPackageDependentOf web3-core-method web3-core-promievent -1023 silly isPackageDependentOf web3-net web3-core-promievent -1024 silly isPackageDependentOf web3-core web3-core-promievent -1025 silly isPackageDependentOf web3-core-method web3-core-promievent -1026 silly isPackageDependentOf web3-utils web3-core-promievent -1027 silly isPackageDependentOf web3-utils web3-core-promievent -1028 verbose dependent web3-eth-personal depends on web3-core-promievent -1029 silly isPackageDependentOf web3-eth-personal web3-core-requestmanager -1030 silly isPackageDependentOf web3-core web3-core-requestmanager -1031 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -1032 silly isPackageDependentOf web3-core-method web3-core-requestmanager -1033 silly isPackageDependentOf web3-net web3-core-requestmanager -1034 silly isPackageDependentOf web3-core web3-core-requestmanager -1035 silly isPackageDependentOf web3-core-method web3-core-requestmanager -1036 silly isPackageDependentOf web3-utils web3-core-requestmanager -1037 silly isPackageDependentOf web3-utils web3-core-requestmanager -1038 verbose dependent web3-eth-personal depends on web3-core-requestmanager -1039 silly isPackageDependentOf web3-eth-personal web3-core-subscriptions -1040 silly isPackageDependentOf web3-core web3-core-subscriptions -1041 silly isPackageDependentOf web3-core-helpers web3-core-subscriptions -1042 silly isPackageDependentOf web3-core-method web3-core-subscriptions -1043 silly isPackageDependentOf web3-net web3-core-subscriptions -1044 silly isPackageDependentOf web3-core web3-core-subscriptions -1045 silly isPackageDependentOf web3-core-method web3-core-subscriptions -1046 silly isPackageDependentOf web3-utils web3-core-subscriptions -1047 silly isPackageDependentOf web3-utils web3-core-subscriptions -1048 verbose dependent web3-eth-personal depends on web3-core-subscriptions -1049 silly isPackageDependentOf web3-eth-personal web3-core -1050 verbose dependent web3-eth-personal depends on web3-core -1051 silly isPackageDependentOf web3-eth-personal web3-eth-abi -1052 silly isPackageDependentOf web3-core web3-eth-abi -1053 silly isPackageDependentOf web3-core-helpers web3-eth-abi -1054 silly isPackageDependentOf web3-core-method web3-eth-abi -1055 silly isPackageDependentOf web3-net web3-eth-abi -1056 silly isPackageDependentOf web3-core web3-eth-abi -1057 silly isPackageDependentOf web3-core-method web3-eth-abi -1058 silly isPackageDependentOf web3-utils web3-eth-abi -1059 silly isPackageDependentOf web3-utils web3-eth-abi -1060 silly isPackageDependentOf web3-eth-personal web3-eth-accounts -1061 silly isPackageDependentOf web3-core web3-eth-accounts -1062 silly isPackageDependentOf web3-core-helpers web3-eth-accounts -1063 silly isPackageDependentOf web3-core-method web3-eth-accounts -1064 silly isPackageDependentOf web3-net web3-eth-accounts -1065 silly isPackageDependentOf web3-core web3-eth-accounts -1066 silly isPackageDependentOf web3-core-method web3-eth-accounts -1067 silly isPackageDependentOf web3-utils web3-eth-accounts -1068 silly isPackageDependentOf web3-utils web3-eth-accounts -1069 silly isPackageDependentOf web3-eth-personal web3-eth-contract -1070 silly isPackageDependentOf web3-core web3-eth-contract -1071 silly isPackageDependentOf web3-core-helpers web3-eth-contract -1072 silly isPackageDependentOf web3-core-method web3-eth-contract -1073 silly isPackageDependentOf web3-net web3-eth-contract -1074 silly isPackageDependentOf web3-core web3-eth-contract -1075 silly isPackageDependentOf web3-core-method web3-eth-contract -1076 silly isPackageDependentOf web3-utils web3-eth-contract -1077 silly isPackageDependentOf web3-utils web3-eth-contract -1078 silly isPackageDependentOf web3-eth-personal web3-eth-ens -1079 silly isPackageDependentOf web3-core web3-eth-ens -1080 silly isPackageDependentOf web3-core-helpers web3-eth-ens -1081 silly isPackageDependentOf web3-core-method web3-eth-ens -1082 silly isPackageDependentOf web3-net web3-eth-ens -1083 silly isPackageDependentOf web3-core web3-eth-ens -1084 silly isPackageDependentOf web3-core-method web3-eth-ens -1085 silly isPackageDependentOf web3-utils web3-eth-ens -1086 silly isPackageDependentOf web3-utils web3-eth-ens -1087 silly isPackageDependentOf web3-eth-personal web3-eth-iban -1088 silly isPackageDependentOf web3-core web3-eth-iban -1089 silly isPackageDependentOf web3-core-helpers web3-eth-iban -1090 silly isPackageDependentOf web3-core-method web3-eth-iban -1091 silly isPackageDependentOf web3-net web3-eth-iban -1092 silly isPackageDependentOf web3-core web3-eth-iban -1093 silly isPackageDependentOf web3-core-method web3-eth-iban -1094 silly isPackageDependentOf web3-utils web3-eth-iban -1095 silly isPackageDependentOf web3-utils web3-eth-iban -1096 verbose dependent web3-eth-personal depends on web3-eth-iban -1097 silly isPackageDependentOf web3-eth-personal web3-eth-personal -1098 silly isPackageDependentOf web3-core web3-eth-personal -1099 silly isPackageDependentOf web3-core-helpers web3-eth-personal -1100 silly isPackageDependentOf web3-core-method web3-eth-personal -1101 silly isPackageDependentOf web3-net web3-eth-personal -1102 silly isPackageDependentOf web3-core web3-eth-personal -1103 silly isPackageDependentOf web3-core-method web3-eth-personal -1104 silly isPackageDependentOf web3-utils web3-eth-personal -1105 silly isPackageDependentOf web3-utils web3-eth-personal -1106 silly isPackageDependentOf web3-eth-personal web3-eth -1107 silly isPackageDependentOf web3-core web3-eth -1108 silly isPackageDependentOf web3-core-helpers web3-eth -1109 silly isPackageDependentOf web3-core-method web3-eth -1110 silly isPackageDependentOf web3-net web3-eth -1111 silly isPackageDependentOf web3-core web3-eth -1112 silly isPackageDependentOf web3-core-method web3-eth -1113 silly isPackageDependentOf web3-utils web3-eth -1114 silly isPackageDependentOf web3-utils web3-eth -1115 silly isPackageDependentOf web3-eth-personal web3-net -1116 verbose dependent web3-eth-personal depends on web3-net -1117 silly isPackageDependentOf web3-eth-personal web3-providers-http -1118 silly isPackageDependentOf web3-core web3-providers-http -1119 silly isPackageDependentOf web3-core-helpers web3-providers-http -1120 silly isPackageDependentOf web3-core-method web3-providers-http -1121 silly isPackageDependentOf web3-net web3-providers-http -1122 silly isPackageDependentOf web3-core web3-providers-http -1123 silly isPackageDependentOf web3-core-method web3-providers-http -1124 silly isPackageDependentOf web3-utils web3-providers-http -1125 silly isPackageDependentOf web3-utils web3-providers-http -1126 verbose dependent web3-eth-personal depends on web3-providers-http -1127 silly isPackageDependentOf web3-eth-personal web3-providers-ipc -1128 silly isPackageDependentOf web3-core web3-providers-ipc -1129 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -1130 silly isPackageDependentOf web3-core-method web3-providers-ipc -1131 silly isPackageDependentOf web3-net web3-providers-ipc -1132 silly isPackageDependentOf web3-core web3-providers-ipc -1133 silly isPackageDependentOf web3-core-method web3-providers-ipc -1134 silly isPackageDependentOf web3-utils web3-providers-ipc -1135 silly isPackageDependentOf web3-utils web3-providers-ipc -1136 verbose dependent web3-eth-personal depends on web3-providers-ipc -1137 silly isPackageDependentOf web3-eth-personal web3-providers-ws -1138 silly isPackageDependentOf web3-core web3-providers-ws -1139 silly isPackageDependentOf web3-core-helpers web3-providers-ws -1140 silly isPackageDependentOf web3-core-method web3-providers-ws -1141 silly isPackageDependentOf web3-net web3-providers-ws -1142 silly isPackageDependentOf web3-core web3-providers-ws -1143 silly isPackageDependentOf web3-core-method web3-providers-ws -1144 silly isPackageDependentOf web3-utils web3-providers-ws -1145 silly isPackageDependentOf web3-utils web3-providers-ws -1146 verbose dependent web3-eth-personal depends on web3-providers-ws -1147 silly isPackageDependentOf web3-eth-personal web3-shh -1148 silly isPackageDependentOf web3-core web3-shh -1149 silly isPackageDependentOf web3-core-helpers web3-shh -1150 silly isPackageDependentOf web3-core-method web3-shh -1151 silly isPackageDependentOf web3-net web3-shh -1152 silly isPackageDependentOf web3-core web3-shh -1153 silly isPackageDependentOf web3-core-method web3-shh -1154 silly isPackageDependentOf web3-utils web3-shh -1155 silly isPackageDependentOf web3-utils web3-shh -1156 silly isPackageDependentOf web3-eth-personal web3-utils -1157 verbose dependent web3-eth-personal depends on web3-utils -1158 silly isPackageDependentOf web3-eth-personal web3 -1159 silly isPackageDependentOf web3-core web3 -1160 silly isPackageDependentOf web3-core-helpers web3 -1161 silly isPackageDependentOf web3-core-method web3 -1162 silly isPackageDependentOf web3-net web3 -1163 silly isPackageDependentOf web3-core web3 -1164 silly isPackageDependentOf web3-core-method web3 -1165 silly isPackageDependentOf web3-utils web3 -1166 silly isPackageDependentOf web3-utils web3 -1167 silly isPackageDependentOf web3-eth web3-bzz -1168 silly isPackageDependentOf web3-core web3-bzz -1169 silly isPackageDependentOf web3-core-helpers web3-bzz -1170 silly isPackageDependentOf web3-core-method web3-bzz -1171 silly isPackageDependentOf web3-core-subscriptions web3-bzz -1172 silly isPackageDependentOf web3-eth-abi web3-bzz -1173 silly isPackageDependentOf web3-eth-accounts web3-bzz -1174 silly isPackageDependentOf web3-eth-contract web3-bzz -1175 silly isPackageDependentOf web3-eth-ens web3-bzz -1176 silly isPackageDependentOf web3-eth-iban web3-bzz -1177 silly isPackageDependentOf web3-eth-personal web3-bzz -1178 silly isPackageDependentOf web3-net web3-bzz -1179 silly isPackageDependentOf web3-utils web3-bzz -1180 silly isPackageDependentOf web3-eth web3-core-helpers -1181 verbose dependent web3-eth depends on web3-core-helpers -1182 silly isPackageDependentOf web3-eth web3-core-method -1183 verbose dependent web3-eth depends on web3-core-method -1184 silly isPackageDependentOf web3-eth web3-core-promievent -1185 silly isPackageDependentOf web3-core web3-core-promievent -1186 silly isPackageDependentOf web3-core-helpers web3-core-promievent -1187 silly isPackageDependentOf web3-core-method web3-core-promievent -1188 silly isPackageDependentOf web3-core-subscriptions web3-core-promievent -1189 silly isPackageDependentOf web3-eth-abi web3-core-promievent -1190 silly isPackageDependentOf web3-eth-accounts web3-core-promievent -1191 silly isPackageDependentOf web3-eth-contract web3-core-promievent -1192 silly isPackageDependentOf web3-eth-ens web3-core-promievent -1193 silly isPackageDependentOf web3-eth-iban web3-core-promievent -1194 silly isPackageDependentOf web3-eth-personal web3-core-promievent -1195 silly isPackageDependentOf web3-net web3-core-promievent -1196 silly isPackageDependentOf web3-utils web3-core-promievent -1197 verbose dependent web3-eth depends on web3-core-promievent -1198 silly isPackageDependentOf web3-eth web3-core-requestmanager -1199 silly isPackageDependentOf web3-core web3-core-requestmanager -1200 silly isPackageDependentOf web3-core-helpers web3-core-requestmanager -1201 silly isPackageDependentOf web3-core-method web3-core-requestmanager -1202 silly isPackageDependentOf web3-core-subscriptions web3-core-requestmanager -1203 silly isPackageDependentOf web3-eth-abi web3-core-requestmanager -1204 silly isPackageDependentOf web3-eth-accounts web3-core-requestmanager -1205 silly isPackageDependentOf web3-eth-contract web3-core-requestmanager -1206 silly isPackageDependentOf web3-eth-ens web3-core-requestmanager -1207 silly isPackageDependentOf web3-eth-iban web3-core-requestmanager -1208 silly isPackageDependentOf web3-eth-personal web3-core-requestmanager -1209 silly isPackageDependentOf web3-net web3-core-requestmanager -1210 silly isPackageDependentOf web3-utils web3-core-requestmanager -1211 verbose dependent web3-eth depends on web3-core-requestmanager -1212 silly isPackageDependentOf web3-eth web3-core-subscriptions -1213 verbose dependent web3-eth depends on web3-core-subscriptions -1214 silly isPackageDependentOf web3-eth web3-core -1215 verbose dependent web3-eth depends on web3-core -1216 silly isPackageDependentOf web3-eth web3-eth-abi -1217 verbose dependent web3-eth depends on web3-eth-abi -1218 silly isPackageDependentOf web3-eth web3-eth-accounts -1219 verbose dependent web3-eth depends on web3-eth-accounts -1220 silly isPackageDependentOf web3-eth web3-eth-contract -1221 verbose dependent web3-eth depends on web3-eth-contract -1222 silly isPackageDependentOf web3-eth web3-eth-ens -1223 verbose dependent web3-eth depends on web3-eth-ens -1224 silly isPackageDependentOf web3-eth web3-eth-iban -1225 verbose dependent web3-eth depends on web3-eth-iban -1226 silly isPackageDependentOf web3-eth web3-eth-personal -1227 verbose dependent web3-eth depends on web3-eth-personal -1228 silly isPackageDependentOf web3-eth web3-eth -1229 silly isPackageDependentOf web3-core web3-eth -1230 silly isPackageDependentOf web3-core-helpers web3-eth -1231 silly isPackageDependentOf web3-core-method web3-eth -1232 silly isPackageDependentOf web3-core-subscriptions web3-eth -1233 silly isPackageDependentOf web3-eth-abi web3-eth -1234 silly isPackageDependentOf web3-eth-accounts web3-eth -1235 silly isPackageDependentOf web3-eth-contract web3-eth -1236 silly isPackageDependentOf web3-eth-ens web3-eth -1237 silly isPackageDependentOf web3-eth-iban web3-eth -1238 silly isPackageDependentOf web3-eth-personal web3-eth -1239 silly isPackageDependentOf web3-net web3-eth -1240 silly isPackageDependentOf web3-utils web3-eth -1241 silly isPackageDependentOf web3-eth web3-net -1242 verbose dependent web3-eth depends on web3-net -1243 silly isPackageDependentOf web3-eth web3-providers-http -1244 silly isPackageDependentOf web3-core web3-providers-http -1245 silly isPackageDependentOf web3-core-helpers web3-providers-http -1246 silly isPackageDependentOf web3-core-method web3-providers-http -1247 silly isPackageDependentOf web3-core-subscriptions web3-providers-http -1248 silly isPackageDependentOf web3-eth-abi web3-providers-http -1249 silly isPackageDependentOf web3-eth-accounts web3-providers-http -1250 silly isPackageDependentOf web3-eth-contract web3-providers-http -1251 silly isPackageDependentOf web3-eth-ens web3-providers-http -1252 silly isPackageDependentOf web3-eth-iban web3-providers-http -1253 silly isPackageDependentOf web3-eth-personal web3-providers-http -1254 silly isPackageDependentOf web3-net web3-providers-http -1255 silly isPackageDependentOf web3-utils web3-providers-http -1256 verbose dependent web3-eth depends on web3-providers-http -1257 silly isPackageDependentOf web3-eth web3-providers-ipc -1258 silly isPackageDependentOf web3-core web3-providers-ipc -1259 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -1260 silly isPackageDependentOf web3-core-method web3-providers-ipc -1261 silly isPackageDependentOf web3-core-subscriptions web3-providers-ipc -1262 silly isPackageDependentOf web3-eth-abi web3-providers-ipc -1263 silly isPackageDependentOf web3-eth-accounts web3-providers-ipc -1264 silly isPackageDependentOf web3-eth-contract web3-providers-ipc -1265 silly isPackageDependentOf web3-eth-ens web3-providers-ipc -1266 silly isPackageDependentOf web3-eth-iban web3-providers-ipc -1267 silly isPackageDependentOf web3-eth-personal web3-providers-ipc -1268 silly isPackageDependentOf web3-net web3-providers-ipc -1269 silly isPackageDependentOf web3-utils web3-providers-ipc -1270 verbose dependent web3-eth depends on web3-providers-ipc -1271 silly isPackageDependentOf web3-eth web3-providers-ws -1272 silly isPackageDependentOf web3-core web3-providers-ws -1273 silly isPackageDependentOf web3-core-helpers web3-providers-ws -1274 silly isPackageDependentOf web3-core-method web3-providers-ws -1275 silly isPackageDependentOf web3-core-subscriptions web3-providers-ws -1276 silly isPackageDependentOf web3-eth-abi web3-providers-ws -1277 silly isPackageDependentOf web3-eth-accounts web3-providers-ws -1278 silly isPackageDependentOf web3-eth-contract web3-providers-ws -1279 silly isPackageDependentOf web3-eth-ens web3-providers-ws -1280 silly isPackageDependentOf web3-eth-iban web3-providers-ws -1281 silly isPackageDependentOf web3-eth-personal web3-providers-ws -1282 silly isPackageDependentOf web3-net web3-providers-ws -1283 silly isPackageDependentOf web3-utils web3-providers-ws -1284 verbose dependent web3-eth depends on web3-providers-ws -1285 silly isPackageDependentOf web3-eth web3-shh -1286 silly isPackageDependentOf web3-core web3-shh -1287 silly isPackageDependentOf web3-core-helpers web3-shh -1288 silly isPackageDependentOf web3-core-method web3-shh -1289 silly isPackageDependentOf web3-core-subscriptions web3-shh -1290 silly isPackageDependentOf web3-eth-abi web3-shh -1291 silly isPackageDependentOf web3-eth-accounts web3-shh -1292 silly isPackageDependentOf web3-eth-contract web3-shh -1293 silly isPackageDependentOf web3-eth-ens web3-shh -1294 silly isPackageDependentOf web3-eth-iban web3-shh -1295 silly isPackageDependentOf web3-eth-personal web3-shh -1296 silly isPackageDependentOf web3-net web3-shh -1297 silly isPackageDependentOf web3-utils web3-shh -1298 silly isPackageDependentOf web3-eth web3-utils -1299 verbose dependent web3-eth depends on web3-utils -1300 silly isPackageDependentOf web3-eth web3 -1301 silly isPackageDependentOf web3-core web3 -1302 silly isPackageDependentOf web3-core-helpers web3 -1303 silly isPackageDependentOf web3-core-method web3 -1304 silly isPackageDependentOf web3-core-subscriptions web3 -1305 silly isPackageDependentOf web3-eth-abi web3 -1306 silly isPackageDependentOf web3-eth-accounts web3 -1307 silly isPackageDependentOf web3-eth-contract web3 -1308 silly isPackageDependentOf web3-eth-ens web3 -1309 silly isPackageDependentOf web3-eth-iban web3 -1310 silly isPackageDependentOf web3-eth-personal web3 -1311 silly isPackageDependentOf web3-net web3 -1312 silly isPackageDependentOf web3-utils web3 -1313 silly isPackageDependentOf web3-net web3-bzz -1314 silly isPackageDependentOf web3-net web3-core-helpers -1315 silly isPackageDependentOf web3-core web3-core-helpers -1316 silly isPackageDependentOf web3-core-method web3-core-helpers -1317 silly isPackageDependentOf web3-utils web3-core-helpers -1318 verbose dependent web3-net depends on web3-core-helpers -1319 silly isPackageDependentOf web3-net web3-core-method -1320 verbose dependent web3-net depends on web3-core-method -1321 silly isPackageDependentOf web3-net web3-core-promievent -1322 verbose dependent web3-net depends on web3-core-promievent -1323 silly isPackageDependentOf web3-net web3-core-requestmanager -1324 verbose dependent web3-net depends on web3-core-requestmanager -1325 silly isPackageDependentOf web3-net web3-core-subscriptions -1326 verbose dependent web3-net depends on web3-core-subscriptions -1327 silly isPackageDependentOf web3-net web3-core -1328 verbose dependent web3-net depends on web3-core -1329 silly isPackageDependentOf web3-net web3-eth-abi -1330 silly isPackageDependentOf web3-net web3-eth-accounts -1331 silly isPackageDependentOf web3-net web3-eth-contract -1332 silly isPackageDependentOf web3-net web3-eth-ens -1333 silly isPackageDependentOf web3-net web3-eth-iban -1334 verbose dependent web3-net depends on web3-eth-iban -1335 silly isPackageDependentOf web3-net web3-eth-personal -1336 silly isPackageDependentOf web3-net web3-eth -1337 silly isPackageDependentOf web3-net web3-net -1338 silly isPackageDependentOf web3-core web3-net -1339 silly isPackageDependentOf web3-core-method web3-net -1340 silly isPackageDependentOf web3-utils web3-net -1341 silly isPackageDependentOf web3-net web3-providers-http -1342 verbose dependent web3-net depends on web3-providers-http -1343 silly isPackageDependentOf web3-net web3-providers-ipc -1344 verbose dependent web3-net depends on web3-providers-ipc -1345 silly isPackageDependentOf web3-net web3-providers-ws -1346 verbose dependent web3-net depends on web3-providers-ws -1347 silly isPackageDependentOf web3-net web3-shh -1348 silly isPackageDependentOf web3-net web3-utils -1349 verbose dependent web3-net depends on web3-utils -1350 silly isPackageDependentOf web3-net web3 -1351 silly isPackageDependentOf web3-providers-http web3-bzz -1352 silly isPackageDependentOf web3-providers-http web3-core-helpers -1353 verbose dependent web3-providers-http depends on web3-core-helpers -1354 silly isPackageDependentOf web3-providers-http web3-core-method -1355 silly isPackageDependentOf web3-providers-http web3-core-promievent -1356 silly isPackageDependentOf web3-providers-http web3-core-requestmanager -1357 silly isPackageDependentOf web3-providers-http web3-core-subscriptions -1358 silly isPackageDependentOf web3-providers-http web3-core -1359 silly isPackageDependentOf web3-providers-http web3-eth-abi -1360 silly isPackageDependentOf web3-providers-http web3-eth-accounts -1361 silly isPackageDependentOf web3-providers-http web3-eth-contract -1362 silly isPackageDependentOf web3-providers-http web3-eth-ens -1363 silly isPackageDependentOf web3-providers-http web3-eth-iban -1364 verbose dependent web3-providers-http depends on web3-eth-iban -1365 silly isPackageDependentOf web3-providers-http web3-eth-personal -1366 silly isPackageDependentOf web3-providers-http web3-eth -1367 silly isPackageDependentOf web3-providers-http web3-net -1368 silly isPackageDependentOf web3-providers-http web3-providers-http -1369 silly isPackageDependentOf web3-core-helpers web3-providers-http -1370 silly isPackageDependentOf web3-providers-http web3-providers-ipc -1371 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -1372 silly isPackageDependentOf web3-providers-http web3-providers-ws -1373 silly isPackageDependentOf web3-core-helpers web3-providers-ws -1374 silly isPackageDependentOf web3-providers-http web3-shh -1375 silly isPackageDependentOf web3-providers-http web3-utils -1376 verbose dependent web3-providers-http depends on web3-utils -1377 silly isPackageDependentOf web3-providers-http web3 -1378 silly isPackageDependentOf web3-providers-ipc web3-bzz -1379 silly isPackageDependentOf web3-providers-ipc web3-core-helpers -1380 verbose dependent web3-providers-ipc depends on web3-core-helpers -1381 silly isPackageDependentOf web3-providers-ipc web3-core-method -1382 silly isPackageDependentOf web3-providers-ipc web3-core-promievent -1383 silly isPackageDependentOf web3-providers-ipc web3-core-requestmanager -1384 silly isPackageDependentOf web3-providers-ipc web3-core-subscriptions -1385 silly isPackageDependentOf web3-providers-ipc web3-core -1386 silly isPackageDependentOf web3-providers-ipc web3-eth-abi -1387 silly isPackageDependentOf web3-providers-ipc web3-eth-accounts -1388 silly isPackageDependentOf web3-providers-ipc web3-eth-contract -1389 silly isPackageDependentOf web3-providers-ipc web3-eth-ens -1390 silly isPackageDependentOf web3-providers-ipc web3-eth-iban -1391 verbose dependent web3-providers-ipc depends on web3-eth-iban -1392 silly isPackageDependentOf web3-providers-ipc web3-eth-personal -1393 silly isPackageDependentOf web3-providers-ipc web3-eth -1394 silly isPackageDependentOf web3-providers-ipc web3-net -1395 silly isPackageDependentOf web3-providers-ipc web3-providers-http -1396 silly isPackageDependentOf web3-core-helpers web3-providers-http -1397 silly isPackageDependentOf web3-providers-ipc web3-providers-ipc -1398 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -1399 silly isPackageDependentOf web3-providers-ipc web3-providers-ws -1400 silly isPackageDependentOf web3-core-helpers web3-providers-ws -1401 silly isPackageDependentOf web3-providers-ipc web3-shh -1402 silly isPackageDependentOf web3-providers-ipc web3-utils -1403 verbose dependent web3-providers-ipc depends on web3-utils -1404 silly isPackageDependentOf web3-providers-ipc web3 -1405 silly isPackageDependentOf web3-providers-ws web3-bzz -1406 silly isPackageDependentOf web3-providers-ws web3-core-helpers -1407 verbose dependent web3-providers-ws depends on web3-core-helpers -1408 silly isPackageDependentOf web3-providers-ws web3-core-method -1409 silly isPackageDependentOf web3-providers-ws web3-core-promievent -1410 silly isPackageDependentOf web3-providers-ws web3-core-requestmanager -1411 silly isPackageDependentOf web3-providers-ws web3-core-subscriptions -1412 silly isPackageDependentOf web3-providers-ws web3-core -1413 silly isPackageDependentOf web3-providers-ws web3-eth-abi -1414 silly isPackageDependentOf web3-providers-ws web3-eth-accounts -1415 silly isPackageDependentOf web3-providers-ws web3-eth-contract -1416 silly isPackageDependentOf web3-providers-ws web3-eth-ens -1417 silly isPackageDependentOf web3-providers-ws web3-eth-iban -1418 verbose dependent web3-providers-ws depends on web3-eth-iban -1419 silly isPackageDependentOf web3-providers-ws web3-eth-personal -1420 silly isPackageDependentOf web3-providers-ws web3-eth -1421 silly isPackageDependentOf web3-providers-ws web3-net -1422 silly isPackageDependentOf web3-providers-ws web3-providers-http -1423 silly isPackageDependentOf web3-core-helpers web3-providers-http -1424 silly isPackageDependentOf web3-providers-ws web3-providers-ipc -1425 silly isPackageDependentOf web3-core-helpers web3-providers-ipc -1426 silly isPackageDependentOf web3-providers-ws web3-providers-ws -1427 silly isPackageDependentOf web3-core-helpers web3-providers-ws -1428 silly isPackageDependentOf web3-providers-ws web3-shh -1429 silly isPackageDependentOf web3-providers-ws web3-utils -1430 verbose dependent web3-providers-ws depends on web3-utils -1431 silly isPackageDependentOf web3-providers-ws web3 -1432 silly isPackageDependentOf web3-shh web3-bzz -1433 silly isPackageDependentOf web3-core web3-bzz -1434 silly isPackageDependentOf web3-core-method web3-bzz -1435 silly isPackageDependentOf web3-core-subscriptions web3-bzz -1436 silly isPackageDependentOf web3-net web3-bzz -1437 silly isPackageDependentOf web3-shh web3-core-helpers -1438 silly isPackageDependentOf web3-core web3-core-helpers -1439 silly isPackageDependentOf web3-core-method web3-core-helpers -1440 silly isPackageDependentOf web3-core-subscriptions web3-core-helpers -1441 silly isPackageDependentOf web3-net web3-core-helpers -1442 verbose dependent web3-shh depends on web3-core-helpers -1443 silly isPackageDependentOf web3-shh web3-core-method -1444 verbose dependent web3-shh depends on web3-core-method -1445 silly isPackageDependentOf web3-shh web3-core-promievent -1446 silly isPackageDependentOf web3-core web3-core-promievent -1447 silly isPackageDependentOf web3-core-method web3-core-promievent -1448 silly isPackageDependentOf web3-core-subscriptions web3-core-promievent -1449 silly isPackageDependentOf web3-net web3-core-promievent -1450 verbose dependent web3-shh depends on web3-core-promievent -1451 silly isPackageDependentOf web3-shh web3-core-requestmanager -1452 silly isPackageDependentOf web3-core web3-core-requestmanager -1453 silly isPackageDependentOf web3-core-method web3-core-requestmanager -1454 silly isPackageDependentOf web3-core-subscriptions web3-core-requestmanager -1455 silly isPackageDependentOf web3-net web3-core-requestmanager -1456 verbose dependent web3-shh depends on web3-core-requestmanager -1457 silly isPackageDependentOf web3-shh web3-core-subscriptions -1458 verbose dependent web3-shh depends on web3-core-subscriptions -1459 silly isPackageDependentOf web3-shh web3-core -1460 verbose dependent web3-shh depends on web3-core -1461 silly isPackageDependentOf web3-shh web3-eth-abi -1462 silly isPackageDependentOf web3-core web3-eth-abi -1463 silly isPackageDependentOf web3-core-method web3-eth-abi -1464 silly isPackageDependentOf web3-core-subscriptions web3-eth-abi -1465 silly isPackageDependentOf web3-net web3-eth-abi -1466 silly isPackageDependentOf web3-shh web3-eth-accounts -1467 silly isPackageDependentOf web3-core web3-eth-accounts -1468 silly isPackageDependentOf web3-core-method web3-eth-accounts -1469 silly isPackageDependentOf web3-core-subscriptions web3-eth-accounts -1470 silly isPackageDependentOf web3-net web3-eth-accounts -1471 silly isPackageDependentOf web3-shh web3-eth-contract -1472 silly isPackageDependentOf web3-core web3-eth-contract -1473 silly isPackageDependentOf web3-core-method web3-eth-contract -1474 silly isPackageDependentOf web3-core-subscriptions web3-eth-contract -1475 silly isPackageDependentOf web3-net web3-eth-contract -1476 silly isPackageDependentOf web3-shh web3-eth-ens -1477 silly isPackageDependentOf web3-core web3-eth-ens -1478 silly isPackageDependentOf web3-core-method web3-eth-ens -1479 silly isPackageDependentOf web3-core-subscriptions web3-eth-ens -1480 silly isPackageDependentOf web3-net web3-eth-ens -1481 silly isPackageDependentOf web3-shh web3-eth-iban -1482 silly isPackageDependentOf web3-core web3-eth-iban -1483 silly isPackageDependentOf web3-core-method web3-eth-iban -1484 silly isPackageDependentOf web3-core-subscriptions web3-eth-iban -1485 silly isPackageDependentOf web3-net web3-eth-iban -1486 verbose dependent web3-shh depends on web3-eth-iban -1487 silly isPackageDependentOf web3-shh web3-eth-personal -1488 silly isPackageDependentOf web3-core web3-eth-personal -1489 silly isPackageDependentOf web3-core-method web3-eth-personal -1490 silly isPackageDependentOf web3-core-subscriptions web3-eth-personal -1491 silly isPackageDependentOf web3-net web3-eth-personal -1492 silly isPackageDependentOf web3-shh web3-eth -1493 silly isPackageDependentOf web3-core web3-eth -1494 silly isPackageDependentOf web3-core-method web3-eth -1495 silly isPackageDependentOf web3-core-subscriptions web3-eth -1496 silly isPackageDependentOf web3-net web3-eth -1497 silly isPackageDependentOf web3-shh web3-net -1498 verbose dependent web3-shh depends on web3-net -1499 silly isPackageDependentOf web3-shh web3-providers-http -1500 silly isPackageDependentOf web3-core web3-providers-http -1501 silly isPackageDependentOf web3-core-method web3-providers-http -1502 silly isPackageDependentOf web3-core-subscriptions web3-providers-http -1503 silly isPackageDependentOf web3-net web3-providers-http -1504 verbose dependent web3-shh depends on web3-providers-http -1505 silly isPackageDependentOf web3-shh web3-providers-ipc -1506 silly isPackageDependentOf web3-core web3-providers-ipc -1507 silly isPackageDependentOf web3-core-method web3-providers-ipc -1508 silly isPackageDependentOf web3-core-subscriptions web3-providers-ipc -1509 silly isPackageDependentOf web3-net web3-providers-ipc -1510 verbose dependent web3-shh depends on web3-providers-ipc -1511 silly isPackageDependentOf web3-shh web3-providers-ws -1512 silly isPackageDependentOf web3-core web3-providers-ws -1513 silly isPackageDependentOf web3-core-method web3-providers-ws -1514 silly isPackageDependentOf web3-core-subscriptions web3-providers-ws -1515 silly isPackageDependentOf web3-net web3-providers-ws -1516 verbose dependent web3-shh depends on web3-providers-ws -1517 silly isPackageDependentOf web3-shh web3-shh -1518 silly isPackageDependentOf web3-core web3-shh -1519 silly isPackageDependentOf web3-core-method web3-shh -1520 silly isPackageDependentOf web3-core-subscriptions web3-shh -1521 silly isPackageDependentOf web3-net web3-shh -1522 silly isPackageDependentOf web3-shh web3-utils -1523 silly isPackageDependentOf web3-core web3-utils -1524 silly isPackageDependentOf web3-core-method web3-utils -1525 silly isPackageDependentOf web3-core-subscriptions web3-utils -1526 silly isPackageDependentOf web3-net web3-utils -1527 verbose dependent web3-shh depends on web3-utils -1528 silly isPackageDependentOf web3-shh web3 -1529 silly isPackageDependentOf web3-core web3 -1530 silly isPackageDependentOf web3-core-method web3 -1531 silly isPackageDependentOf web3-core-subscriptions web3 -1532 silly isPackageDependentOf web3-net web3 -1533 silly isPackageDependentOf web3-utils web3-bzz -1534 silly isPackageDependentOf web3-utils web3-core-helpers -1535 silly isPackageDependentOf web3-utils web3-core-method -1536 silly isPackageDependentOf web3-utils web3-core-promievent -1537 silly isPackageDependentOf web3-utils web3-core-requestmanager -1538 silly isPackageDependentOf web3-utils web3-core-subscriptions -1539 silly isPackageDependentOf web3-utils web3-core -1540 silly isPackageDependentOf web3-utils web3-eth-abi -1541 silly isPackageDependentOf web3-utils web3-eth-accounts -1542 silly isPackageDependentOf web3-utils web3-eth-contract -1543 silly isPackageDependentOf web3-utils web3-eth-ens -1544 silly isPackageDependentOf web3-utils web3-eth-iban -1545 silly isPackageDependentOf web3-utils web3-eth-personal -1546 silly isPackageDependentOf web3-utils web3-eth -1547 silly isPackageDependentOf web3-utils web3-net -1548 silly isPackageDependentOf web3-utils web3-providers-http -1549 silly isPackageDependentOf web3-utils web3-providers-ipc -1550 silly isPackageDependentOf web3-utils web3-providers-ws -1551 silly isPackageDependentOf web3-utils web3-shh -1552 silly isPackageDependentOf web3-utils web3-utils -1553 silly isPackageDependentOf web3-utils web3 -1554 silly isPackageDependentOf web3 web3-bzz -1555 verbose dependent web3 depends on web3-bzz -1556 silly isPackageDependentOf web3 web3-core-helpers -1557 silly isPackageDependentOf web3-bzz web3-core-helpers -1558 silly isPackageDependentOf web3-core web3-core-helpers -1559 silly isPackageDependentOf web3-eth web3-core-helpers -1560 silly isPackageDependentOf web3-eth-personal web3-core-helpers -1561 silly isPackageDependentOf web3-net web3-core-helpers -1562 silly isPackageDependentOf web3-shh web3-core-helpers -1563 silly isPackageDependentOf web3-utils web3-core-helpers -1564 verbose dependent web3 depends on web3-core-helpers -1565 silly isPackageDependentOf web3 web3-core-method -1566 silly isPackageDependentOf web3-bzz web3-core-method -1567 silly isPackageDependentOf web3-core web3-core-method -1568 silly isPackageDependentOf web3-eth web3-core-method -1569 silly isPackageDependentOf web3-eth-personal web3-core-method -1570 silly isPackageDependentOf web3-net web3-core-method -1571 silly isPackageDependentOf web3-shh web3-core-method -1572 silly isPackageDependentOf web3-utils web3-core-method -1573 verbose dependent web3 depends on web3-core-method -1574 silly isPackageDependentOf web3 web3-core-promievent -1575 silly isPackageDependentOf web3-bzz web3-core-promievent -1576 silly isPackageDependentOf web3-core web3-core-promievent -1577 silly isPackageDependentOf web3-eth web3-core-promievent -1578 silly isPackageDependentOf web3-eth-personal web3-core-promievent -1579 silly isPackageDependentOf web3-net web3-core-promievent -1580 silly isPackageDependentOf web3-shh web3-core-promievent -1581 silly isPackageDependentOf web3-utils web3-core-promievent -1582 verbose dependent web3 depends on web3-core-promievent -1583 silly isPackageDependentOf web3 web3-core-requestmanager -1584 silly isPackageDependentOf web3-bzz web3-core-requestmanager -1585 silly isPackageDependentOf web3-core web3-core-requestmanager -1586 silly isPackageDependentOf web3-eth web3-core-requestmanager -1587 silly isPackageDependentOf web3-eth-personal web3-core-requestmanager -1588 silly isPackageDependentOf web3-net web3-core-requestmanager -1589 silly isPackageDependentOf web3-shh web3-core-requestmanager -1590 silly isPackageDependentOf web3-utils web3-core-requestmanager -1591 verbose dependent web3 depends on web3-core-requestmanager -1592 silly isPackageDependentOf web3 web3-core-subscriptions -1593 silly isPackageDependentOf web3-bzz web3-core-subscriptions -1594 silly isPackageDependentOf web3-core web3-core-subscriptions -1595 silly isPackageDependentOf web3-eth web3-core-subscriptions -1596 silly isPackageDependentOf web3-eth-personal web3-core-subscriptions -1597 silly isPackageDependentOf web3-net web3-core-subscriptions -1598 silly isPackageDependentOf web3-shh web3-core-subscriptions -1599 silly isPackageDependentOf web3-utils web3-core-subscriptions -1600 verbose dependent web3 depends on web3-core-subscriptions -1601 silly isPackageDependentOf web3 web3-core -1602 verbose dependent web3 depends on web3-core -1603 silly isPackageDependentOf web3 web3-eth-abi -1604 silly isPackageDependentOf web3-bzz web3-eth-abi -1605 silly isPackageDependentOf web3-core web3-eth-abi -1606 silly isPackageDependentOf web3-eth web3-eth-abi -1607 silly isPackageDependentOf web3-eth-personal web3-eth-abi -1608 silly isPackageDependentOf web3-net web3-eth-abi -1609 silly isPackageDependentOf web3-shh web3-eth-abi -1610 silly isPackageDependentOf web3-utils web3-eth-abi -1611 verbose dependent web3 depends on web3-eth-abi -1612 silly isPackageDependentOf web3 web3-eth-accounts -1613 silly isPackageDependentOf web3-bzz web3-eth-accounts -1614 silly isPackageDependentOf web3-core web3-eth-accounts -1615 silly isPackageDependentOf web3-eth web3-eth-accounts -1616 silly isPackageDependentOf web3-eth-personal web3-eth-accounts -1617 silly isPackageDependentOf web3-net web3-eth-accounts -1618 silly isPackageDependentOf web3-shh web3-eth-accounts -1619 silly isPackageDependentOf web3-utils web3-eth-accounts -1620 verbose dependent web3 depends on web3-eth-accounts -1621 silly isPackageDependentOf web3 web3-eth-contract -1622 silly isPackageDependentOf web3-bzz web3-eth-contract -1623 silly isPackageDependentOf web3-core web3-eth-contract -1624 silly isPackageDependentOf web3-eth web3-eth-contract -1625 silly isPackageDependentOf web3-eth-personal web3-eth-contract -1626 silly isPackageDependentOf web3-net web3-eth-contract -1627 silly isPackageDependentOf web3-shh web3-eth-contract -1628 silly isPackageDependentOf web3-utils web3-eth-contract -1629 verbose dependent web3 depends on web3-eth-contract -1630 silly isPackageDependentOf web3 web3-eth-ens -1631 silly isPackageDependentOf web3-bzz web3-eth-ens -1632 silly isPackageDependentOf web3-core web3-eth-ens -1633 silly isPackageDependentOf web3-eth web3-eth-ens -1634 silly isPackageDependentOf web3-eth-personal web3-eth-ens -1635 silly isPackageDependentOf web3-net web3-eth-ens -1636 silly isPackageDependentOf web3-shh web3-eth-ens -1637 silly isPackageDependentOf web3-utils web3-eth-ens -1638 verbose dependent web3 depends on web3-eth-ens -1639 silly isPackageDependentOf web3 web3-eth-iban -1640 silly isPackageDependentOf web3-bzz web3-eth-iban -1641 silly isPackageDependentOf web3-core web3-eth-iban -1642 silly isPackageDependentOf web3-eth web3-eth-iban -1643 silly isPackageDependentOf web3-eth-personal web3-eth-iban -1644 silly isPackageDependentOf web3-net web3-eth-iban -1645 silly isPackageDependentOf web3-shh web3-eth-iban -1646 silly isPackageDependentOf web3-utils web3-eth-iban -1647 verbose dependent web3 depends on web3-eth-iban -1648 silly isPackageDependentOf web3 web3-eth-personal -1649 verbose dependent web3 depends on web3-eth-personal -1650 silly isPackageDependentOf web3 web3-eth -1651 verbose dependent web3 depends on web3-eth -1652 silly isPackageDependentOf web3 web3-net -1653 verbose dependent web3 depends on web3-net -1654 silly isPackageDependentOf web3 web3-providers-http -1655 silly isPackageDependentOf web3-bzz web3-providers-http -1656 silly isPackageDependentOf web3-core web3-providers-http -1657 silly isPackageDependentOf web3-eth web3-providers-http -1658 silly isPackageDependentOf web3-eth-personal web3-providers-http -1659 silly isPackageDependentOf web3-net web3-providers-http -1660 silly isPackageDependentOf web3-shh web3-providers-http -1661 silly isPackageDependentOf web3-utils web3-providers-http -1662 verbose dependent web3 depends on web3-providers-http -1663 silly isPackageDependentOf web3 web3-providers-ipc -1664 silly isPackageDependentOf web3-bzz web3-providers-ipc -1665 silly isPackageDependentOf web3-core web3-providers-ipc -1666 silly isPackageDependentOf web3-eth web3-providers-ipc -1667 silly isPackageDependentOf web3-eth-personal web3-providers-ipc -1668 silly isPackageDependentOf web3-net web3-providers-ipc -1669 silly isPackageDependentOf web3-shh web3-providers-ipc -1670 silly isPackageDependentOf web3-utils web3-providers-ipc -1671 verbose dependent web3 depends on web3-providers-ipc -1672 silly isPackageDependentOf web3 web3-providers-ws -1673 silly isPackageDependentOf web3-bzz web3-providers-ws -1674 silly isPackageDependentOf web3-core web3-providers-ws -1675 silly isPackageDependentOf web3-eth web3-providers-ws -1676 silly isPackageDependentOf web3-eth-personal web3-providers-ws -1677 silly isPackageDependentOf web3-net web3-providers-ws -1678 silly isPackageDependentOf web3-shh web3-providers-ws -1679 silly isPackageDependentOf web3-utils web3-providers-ws -1680 verbose dependent web3 depends on web3-providers-ws -1681 silly isPackageDependentOf web3 web3-shh -1682 verbose dependent web3 depends on web3-shh -1683 silly isPackageDependentOf web3 web3-utils -1684 verbose dependent web3 depends on web3-utils -1685 silly isPackageDependentOf web3 web3 -1686 silly isPackageDependentOf web3-bzz web3 -1687 silly isPackageDependentOf web3-core web3 -1688 silly isPackageDependentOf web3-eth web3 -1689 silly isPackageDependentOf web3-eth-personal web3 -1690 silly isPackageDependentOf web3-net web3 -1691 silly isPackageDependentOf web3-shh web3 -1692 silly isPackageDependentOf web3-utils web3 -1693 silly collectUpdates -1694 verbose has filtered update web3-bzz -1695 verbose has filtered update web3-core-helpers -1696 verbose has filtered update web3-core-method -1697 verbose has filtered update web3-core-promievent -1698 verbose has filtered update web3-core-requestmanager -1699 verbose has filtered update web3-core-subscriptions -1700 verbose has filtered update web3-core -1701 verbose has filtered update web3-eth-abi -1702 verbose has filtered update web3-eth-accounts -1703 verbose has filtered update web3-eth-contract -1704 verbose has filtered update web3-eth-ens -1705 verbose has filtered update web3-eth-iban -1706 verbose has filtered update web3-eth-personal -1707 verbose has filtered update web3-eth -1708 verbose has filtered update web3-net -1709 verbose has filtered update web3-providers-http -1710 verbose has filtered update web3-providers-ipc -1711 verbose has filtered update web3-providers-ws -1712 verbose has filtered update web3-shh -1713 verbose has filtered update web3-utils -1714 verbose has filtered update web3 -1715 silly initialize success -1716 silly execute attempt -1717 silly runScriptSync preversion web3 -1718 silly runScriptSync preversion web3-bzz -1719 silly runScriptSync version web3-bzz -1720 silly runScriptSync preversion web3-core-helpers -1721 silly runScriptSync version web3-core-helpers -1722 silly runScriptSync preversion web3-core-method -1723 silly runScriptSync version web3-core-method -1724 silly runScriptSync preversion web3-core-promievent -1725 silly runScriptSync version web3-core-promievent -1726 silly runScriptSync preversion web3-core-requestmanager -1727 silly runScriptSync version web3-core-requestmanager -1728 silly runScriptSync preversion web3-core-subscriptions -1729 silly runScriptSync version web3-core-subscriptions -1730 silly runScriptSync preversion web3-core -1731 silly runScriptSync version web3-core -1732 silly runScriptSync preversion web3-eth-abi -1733 silly runScriptSync version web3-eth-abi -1734 silly runScriptSync preversion web3-eth-accounts -1735 silly runScriptSync version web3-eth-accounts -1736 silly runScriptSync preversion web3-eth-contract -1737 silly runScriptSync version web3-eth-contract -1738 silly runScriptSync preversion web3-eth-ens -1739 silly runScriptSync version web3-eth-ens -1740 silly runScriptSync preversion web3-eth-iban -1741 silly runScriptSync version web3-eth-iban -1742 silly runScriptSync preversion web3-eth-personal -1743 silly runScriptSync version web3-eth-personal -1744 silly runScriptSync preversion web3-eth -1745 silly runScriptSync version web3-eth -1746 silly runScriptSync preversion web3-net -1747 silly runScriptSync version web3-net -1748 silly runScriptSync preversion web3-providers-http -1749 silly runScriptSync version web3-providers-http -1750 silly runScriptSync preversion web3-providers-ipc -1751 silly runScriptSync version web3-providers-ipc -1752 silly runScriptSync preversion web3-providers-ws -1753 silly runScriptSync version web3-providers-ws -1754 silly runScriptSync preversion web3-shh -1755 silly runScriptSync version web3-shh -1756 silly runScriptSync preversion web3-utils -1757 silly runScriptSync version web3-utils -1758 silly runScriptSync preversion web3 -1759 silly runScriptSync version web3 -1760 silly runScriptSync version web3 -1761 info publish Publishing packages to npm... -1762 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-bzz/scripts/prepublish.js -1763 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-bzz/scripts/prepublish.js -1764 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-helpers/scripts/prepublish.js -1765 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-helpers/scripts/prepublish.js -1766 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-method/scripts/prepublish.js -1767 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-method/scripts/prepublish.js -1768 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-promievent/scripts/prepublish.js -1769 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-promievent/scripts/prepublish.js -1770 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-requestmanager/scripts/prepublish.js -1771 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-requestmanager/scripts/prepublish.js -1772 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-subscriptions/scripts/prepublish.js -1773 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-subscriptions/scripts/prepublish.js -1774 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core/scripts/prepublish.js -1775 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core/scripts/prepublish.js -1776 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-abi/scripts/prepublish.js -1777 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-abi/scripts/prepublish.js -1778 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-accounts/scripts/prepublish.js -1779 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-accounts/scripts/prepublish.js -1780 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-contract/scripts/prepublish.js -1781 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-contract/scripts/prepublish.js -1782 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-ens/scripts/prepublish.js -1783 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-ens/scripts/prepublish.js -1784 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-iban/scripts/prepublish.js -1785 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-iban/scripts/prepublish.js -1786 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-personal/scripts/prepublish.js -1787 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-personal/scripts/prepublish.js -1788 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth/scripts/prepublish.js -1789 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth/scripts/prepublish.js -1790 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-net/scripts/prepublish.js -1791 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-net/scripts/prepublish.js -1792 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-http/scripts/prepublish.js -1793 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-http/scripts/prepublish.js -1794 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-ipc/scripts/prepublish.js -1795 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-ipc/scripts/prepublish.js -1796 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-ws/scripts/prepublish.js -1797 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-ws/scripts/prepublish.js -1798 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-shh/scripts/prepublish.js -1799 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-shh/scripts/prepublish.js -1800 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-utils/scripts/prepublish.js -1801 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3-utils/scripts/prepublish.js -1802 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3/scripts/prepublish.js -1803 verbose execScript No prepublish script found at /Users/work/Development/foundation/web3.js/packages/web3/scripts/prepublish.js -1804 verbose publishing web3-bzz -1805 silly publishTaggedInDir latest web3-bzz -1806 silly getExecOpts { cwd: -1806 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-bzz' } -1807 verbose publishing web3-core-promievent -1808 silly publishTaggedInDir latest web3-core-promievent -1809 silly getExecOpts { cwd: -1809 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core-promievent' } -1810 verbose publishing web3-utils -1811 silly publishTaggedInDir latest web3-utils -1812 silly getExecOpts { cwd: -1812 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-utils' } -1813 info published web3-utils -1814 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-utils/scripts/postpublish.js -1815 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-utils/scripts/postpublish.js -1816 info published web3-bzz -1817 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-bzz/scripts/postpublish.js -1818 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-bzz/scripts/postpublish.js -1819 info published web3-core-promievent -1820 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-promievent/scripts/postpublish.js -1821 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-promievent/scripts/postpublish.js -1822 verbose publishing web3-eth-abi -1823 silly publishTaggedInDir latest web3-eth-abi -1824 silly getExecOpts { cwd: -1824 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-abi' } -1825 verbose publishing web3-eth-iban -1826 silly publishTaggedInDir latest web3-eth-iban -1827 silly getExecOpts { cwd: -1827 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-iban' } -1828 info published web3-eth-iban -1829 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-iban/scripts/postpublish.js -1830 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-iban/scripts/postpublish.js -1831 info published web3-eth-abi -1832 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-abi/scripts/postpublish.js -1833 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-abi/scripts/postpublish.js -1834 verbose publishing web3-core-helpers -1835 silly publishTaggedInDir latest web3-core-helpers -1836 silly getExecOpts { cwd: -1836 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core-helpers' } -1837 info published web3-core-helpers -1838 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-helpers/scripts/postpublish.js -1839 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-helpers/scripts/postpublish.js -1840 verbose publishing web3-core-subscriptions -1841 silly publishTaggedInDir latest web3-core-subscriptions -1842 silly getExecOpts { cwd: -1842 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core-subscriptions' } -1843 verbose publishing web3-providers-http -1844 silly publishTaggedInDir latest web3-providers-http -1845 silly getExecOpts { cwd: -1845 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-providers-http' } -1846 verbose publishing web3-providers-ipc -1847 silly publishTaggedInDir latest web3-providers-ipc -1848 silly getExecOpts { cwd: -1848 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-providers-ipc' } -1849 verbose publishing web3-providers-ws -1850 silly publishTaggedInDir latest web3-providers-ws -1851 silly getExecOpts { cwd: -1851 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-providers-ws' } -1852 info published web3-core-subscriptions -1853 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-subscriptions/scripts/postpublish.js -1854 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-subscriptions/scripts/postpublish.js -1855 info published web3-providers-ipc -1856 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-ipc/scripts/postpublish.js -1857 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-ipc/scripts/postpublish.js -1858 info published web3-providers-http -1859 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-http/scripts/postpublish.js -1860 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-http/scripts/postpublish.js -1861 info published web3-providers-ws -1862 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-providers-ws/scripts/postpublish.js -1863 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-providers-ws/scripts/postpublish.js -1864 verbose publishing web3-core-method -1865 silly publishTaggedInDir latest web3-core-method -1866 silly getExecOpts { cwd: -1866 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core-method' } -1867 verbose publishing web3-core-requestmanager -1868 silly publishTaggedInDir latest web3-core-requestmanager -1869 silly getExecOpts { cwd: -1869 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core-requestmanager' } -1870 info published web3-core-method -1871 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-method/scripts/postpublish.js -1872 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-method/scripts/postpublish.js -1873 info published web3-core-requestmanager -1874 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core-requestmanager/scripts/postpublish.js -1875 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core-requestmanager/scripts/postpublish.js -1876 verbose publishing web3-core -1877 silly publishTaggedInDir latest web3-core -1878 silly getExecOpts { cwd: -1878 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-core' } -1879 info published web3-core -1880 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-core/scripts/postpublish.js -1881 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-core/scripts/postpublish.js -1882 verbose publishing web3-eth-accounts -1883 silly publishTaggedInDir latest web3-eth-accounts -1884 silly getExecOpts { cwd: -1884 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-accounts' } -1885 verbose publishing web3-eth-contract -1886 silly publishTaggedInDir latest web3-eth-contract -1887 silly getExecOpts { cwd: -1887 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-contract' } -1888 verbose publishing web3-net -1889 silly publishTaggedInDir latest web3-net -1890 silly getExecOpts { cwd: -1890 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-net' } -1891 info published web3-net -1892 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-net/scripts/postpublish.js -1893 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-net/scripts/postpublish.js -1894 info published web3-eth-contract -1895 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-contract/scripts/postpublish.js -1896 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-contract/scripts/postpublish.js -1897 info published web3-eth-accounts -1898 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-accounts/scripts/postpublish.js -1899 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-accounts/scripts/postpublish.js -1900 verbose publishing web3-eth-ens -1901 silly publishTaggedInDir latest web3-eth-ens -1902 silly getExecOpts { cwd: -1902 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-ens' } -1903 verbose publishing web3-eth-personal -1904 silly publishTaggedInDir latest web3-eth-personal -1905 silly getExecOpts { cwd: -1905 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth-personal' } -1906 verbose publishing web3-shh -1907 silly publishTaggedInDir latest web3-shh -1908 silly getExecOpts { cwd: -1908 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-shh' } -1909 info published web3-eth-personal -1910 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-personal/scripts/postpublish.js -1911 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-personal/scripts/postpublish.js -1912 info published web3-shh -1913 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-shh/scripts/postpublish.js -1914 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-shh/scripts/postpublish.js -1915 info published web3-eth-ens -1916 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth-ens/scripts/postpublish.js -1917 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth-ens/scripts/postpublish.js -1918 verbose publishing web3-eth -1919 silly publishTaggedInDir latest web3-eth -1920 silly getExecOpts { cwd: -1920 silly getExecOpts '/Users/work/Development/foundation/web3.js/packages/web3-eth' } -1921 info published web3-eth -1922 silly existsSync /Users/work/Development/foundation/web3.js/packages/web3-eth/scripts/postpublish.js -1923 verbose execScript No postpublish script found at /Users/work/Development/foundation/web3.js/packages/web3-eth/scripts/postpublish.js -1924 verbose publishing web3 -1925 silly publishTaggedInDir latest web3 -1926 silly getExecOpts { cwd: '/Users/work/Development/foundation/web3.js/packages/web3' } -1927 error publish Retrying failed publish: web3 -1928 verbose publish error undefined -1929 verbose publishing web3 -1930 silly publishTaggedInDir latest web3 -1931 silly getExecOpts { cwd: '/Users/work/Development/foundation/web3.js/packages/web3' } -1932 error publish Retrying failed publish: web3 -1933 verbose publish error undefined -1934 verbose publishing web3 -1935 silly publishTaggedInDir latest web3 -1936 silly getExecOpts { cwd: '/Users/work/Development/foundation/web3.js/packages/web3' } -1937 error publish Retrying failed publish: web3 -1938 verbose publish error undefined -1939 verbose publishing web3 -1940 silly publishTaggedInDir latest web3 -1941 silly getExecOpts { cwd: '/Users/work/Development/foundation/web3.js/packages/web3' } -1942 error publish Retrying failed publish: web3 -1943 verbose publish error undefined -1944 verbose publishing web3 -1945 silly publishTaggedInDir latest web3 -1946 silly getExecOpts { cwd: '/Users/work/Development/foundation/web3.js/packages/web3' } -1947 error publish Ran out of retries while publishing web3 Error: Command failed: npm publish --tag latest -1947 error publish npm notice -1947 error publish npm notice 📦 web3@1.2.1 -1947 error publish npm notice === Tarball Contents === -1947 error publish npm notice 1.4kB package.json -1947 error publish npm notice 270B README.md -1947 error publish npm notice 2.1kB src/index.js -1947 error publish npm notice === Tarball Details === -1947 error publish npm notice name: web3 -1947 error publish npm notice version: 1.2.1 -1947 error publish npm notice package size: 1.6 kB -1947 error publish npm notice unpacked size: 3.8 kB -1947 error publish npm notice shasum: 5d8158bcca47838ab8c2b784a2dee4c3ceb4179b -1947 error publish npm notice integrity: sha512-nNMzeCK0agb5i[...]GaOC2zKDFuFRw== -1947 error publish npm notice total files: 3 -1947 error publish npm notice -1947 error publish npm ERR! code EOTP -1947 error publish npm ERR! This operation requires a one-time password from your authenticator. -1947 error publish npm ERR! You can provide a one-time password by passing --otp= to the command you ran. -1947 error publish npm ERR! If you already provided a one-time password then it is likely that you either typoed -1947 error publish npm ERR! it, or it timed out. Please try again. -1947 error publish -1947 error publish npm ERR! A complete log of this run can be found in: -1947 error publish npm ERR! /Users/work/.npm/_logs/2019-08-06T09_51_25_563Z-debug.log -1947 error publish -1947 error publish at Promise.all.then.arr (/Users/work/Development/foundation/web3.js/node_modules/execa/index.js:236:11) -1947 error publish at process._tickCallback (internal/process/next_tick.js:68:7) -1948 error execute callback with error -1949 error Error: Command failed: npm publish --tag latest -1949 error npm notice -1949 error npm notice 📦 web3@1.2.1 -1949 error npm notice === Tarball Contents === -1949 error npm notice 1.4kB package.json -1949 error npm notice 270B README.md -1949 error npm notice 2.1kB src/index.js -1949 error npm notice === Tarball Details === -1949 error npm notice name: web3 -1949 error npm notice version: 1.2.1 -1949 error npm notice package size: 1.6 kB -1949 error npm notice unpacked size: 3.8 kB -1949 error npm notice shasum: 5d8158bcca47838ab8c2b784a2dee4c3ceb4179b -1949 error npm notice integrity: sha512-nNMzeCK0agb5i[...]GaOC2zKDFuFRw== -1949 error npm notice total files: 3 -1949 error npm notice -1949 error npm ERR! code EOTP -1949 error npm ERR! This operation requires a one-time password from your authenticator. -1949 error npm ERR! You can provide a one-time password by passing --otp= to the command you ran. -1949 error npm ERR! If you already provided a one-time password then it is likely that you either typoed -1949 error npm ERR! it, or it timed out. Please try again. -1949 error -1949 error npm ERR! A complete log of this run can be found in: -1949 error npm ERR! /Users/work/.npm/_logs/2019-08-06T09_51_25_563Z-debug.log -1949 error -1949 error at Promise.all.then.arr (/Users/work/Development/foundation/web3.js/node_modules/execa/index.js:236:11) diff --git a/package-lock.json b/package-lock.json index 646f880cf42..004151bb4be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -895,6 +895,15 @@ "integrity": "sha512-KoJPKjhlWBry4fk8qcIufXFOU+zcZBfkHQWKbnAMQTMoe2GDeLpjSQHS+22gv+dg7gKdTP2WCjSeCVnfj8e+Gw==", "dev": true }, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -919,9 +928,9 @@ "dev": true }, "@types/node": { - "version": "12.0.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.8.tgz", - "integrity": "sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg==", + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==", "dev": true }, "@types/underscore": { @@ -11651,6 +11660,12 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "3.7.0-dev.20191016", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191016.tgz", + "integrity": "sha512-4CUiTF5rEtPaClGD9nWpqPMICdDc54PTyrzwqpivz/h7mkWJs/xhQhOddiA5vx+D8ob9eSRIdueXQkI2oxOmfg==", + "dev": true + }, "uglify-js": { "version": "3.4.9", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", diff --git a/package.json b/package.json index 73846d56d54..d19ca4b6e99 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lint": "jshint *.js packages", "test": "mocha --grep E2E --invert; jshint *.js packages", "test:unit": "istanbul cover _mocha -- -R spec --grep E2E --invert", + "dtslint": "lerna run dtslint", "test:e2e:ganache": "./scripts/e2e.ganache.sh", "test:e2e:geth:auto": "./scripts/e2e.geth.automine.sh", "test:e2e:geth:insta": "./scripts/e2e.geth.instamine.sh", @@ -75,6 +76,8 @@ "@babel/preset-env": "^7.6.0", "@types/bignumber.js": "^4.0.2", "@types/underscore": "^1.8.0", + "@types/bn.js": "^4.11.5", + "@types/node": "^12.6.1", "bignumber.js": "^4.0.0", "bluebird": "3.3.1", "bn.js": "^4.11.8", @@ -106,7 +109,7 @@ "sandboxed-module": "^2.0.3", "underscore": "^1.9.1", "vinyl-source-stream": "^2.0.0", - "wait-port": "^0.2.6" - }, - "dependencies": {} + "wait-port": "^0.2.6", + "typescript": "next" + } } diff --git a/packages/web3-bzz/README.md b/packages/web3-bzz/README.md index b52b05fec61..766be66f0ff 100644 --- a/packages/web3-bzz/README.md +++ b/packages/web3-bzz/README.md @@ -2,7 +2,7 @@ This is a sub package of [web3.js][repo] -This is the swarm package. +This is the swarm package. Please read the [documentation][docs] for more. ## Installation @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-bzz.js` in your html file. This will expose the `Web3Personal` object on the window object. - ## Usage ```js @@ -34,8 +33,9 @@ var Web3Bzz = require('web3-bzz'); var bzz = new Web3Bzz('http://swarm-gateways.net'); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-bzz/package-lock.json b/packages/web3-bzz/package-lock.json index d97a94d54fb..d689a60ee59 100644 --- a/packages/web3-bzz/package-lock.json +++ b/packages/web3-bzz/package-lock.json @@ -4,6 +4,24 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -17,6 +35,16 @@ "defer-to-connect": "^1.0.1" } }, + "@types/node": { + "version": "10.14.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.21.tgz", + "integrity": "sha512-nuFlRdBiqbF+PJIEVxm2jLFcQWN7q7iWEJGsBV4n7v1dbI9qXB8im2pMMKMCUZe092sQb5SQft2DHfuQGK5hqQ==" + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -37,6 +65,22 @@ "uri-js": "^4.2.2" } }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -75,6 +119,11 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", @@ -124,6 +173,15 @@ "type-is": "~1.6.17" } }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", @@ -176,6 +234,11 @@ "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=" }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -215,6 +278,16 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, "chownr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", @@ -228,6 +301,19 @@ "mimic-response": "^1.0.0" } }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -244,6 +330,11 @@ "graceful-readlink": ">= 1.0.0" } }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -404,6 +495,15 @@ "object-keys": "^1.0.12" } }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -419,11 +519,48 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, "dom-walk": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + } + } + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -498,6 +635,21 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -657,6 +809,11 @@ "minipass": "^2.2.1" } }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -678,6 +835,19 @@ "assert-plus": "^1.0.0" } }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "global": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", @@ -737,6 +907,11 @@ "function-bind": "^1.1.1" } }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "has-symbol-support-x": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz", @@ -814,6 +989,15 @@ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -909,6 +1093,20 @@ "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.6.1.tgz", "integrity": "sha1-W4n3enR3Z5h39YxKB1JAk0sflcA=" }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -1046,6 +1244,14 @@ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", @@ -1177,6 +1383,21 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -1332,6 +1553,14 @@ } } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, "responselike": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", @@ -1358,6 +1587,11 @@ "commander": "~2.8.1" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, "send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -1441,6 +1675,11 @@ "simple-concat": "^1.0.0" } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -1493,6 +1732,19 @@ "is-natural-number": "^4.0.1" } }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, "swarm-js": { "version": "0.1.39", "resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.39.tgz", @@ -1627,6 +1879,46 @@ } } }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + } + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -1649,6 +1941,11 @@ "mime-types": "~2.1.24" } }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", diff --git a/packages/web3-bzz/package.json b/packages/web3-bzz/package.json index 894f1648833..264ea0f5d8b 100644 --- a/packages/web3-bzz/package.json +++ b/packages/web3-bzz/package.json @@ -7,10 +7,19 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { + "@types/node": "^10.12.18", "got": "9.6.0", "swarm-js": "0.1.39", "underscore": "1.9.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-bzz/types/index.d.ts b/packages/web3-bzz/types/index.d.ts new file mode 100644 index 00000000000..be5a890e3c6 --- /dev/null +++ b/packages/web3-bzz/types/index.d.ts @@ -0,0 +1,42 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +export class Bzz { + constructor(provider: any); + + readonly givenProvider: any; + defaultAccount: string | null; + defaultBlock: string | number; + readonly currentProvider: any; + setProvider(provider: any): boolean; + BatchRequest: new () => any; + static readonly providers: any; + + upload(data: any): Promise; + + download(bzzHash: string, localPath?: string): Promise; + + pick: Pick; +} + +export interface Pick { + file: () => Promise; + directory: () => Promise; + data: () => Promise; +} diff --git a/packages/web3-bzz/types/tests/bzz-test.ts b/packages/web3-bzz/types/tests/bzz-test.ts new file mode 100644 index 00000000000..1a18af9b6bb --- /dev/null +++ b/packages/web3-bzz/types/tests/bzz-test.ts @@ -0,0 +1,69 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file bzz-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import { Bzz } from 'web3-bzz'; + +const bzz = new Bzz('http://swarm-gateways.net'); + +// $ExpectType boolean +bzz.setProvider('test.com'); + +// $ExpectType any +bzz.currentProvider; + +// $ExpectType any +bzz.givenProvider; + +// $ExpectType string | null +bzz.defaultAccount; + +// $ExpectType string | number +bzz.defaultBlock; + +// $ExpectType boolean +bzz.setProvider('https://localhost:2100'); + +// $ExpectType any +new bzz.BatchRequest(); + +// $ExpectType Promise +bzz.upload('test file'); + +const dir = { + '/foo.txt': { type: 'text/plain', data: 'sample file' }, + '/bar.txt': { type: 'text/plain', data: 'another file' } +}; + +// $ExpectType Promise +bzz.upload(dir); +// $ExpectType Promise +bzz.upload({ + path: '/path/to/thing', + kind: 'directory', + defaultFile: '/index.html' +}); + +// $ExpectType Promise +bzz.pick.file(); + +// $ExpectType Promise +bzz.pick.directory(); + +// $ExpectType Promise +bzz.pick.data(); diff --git a/packages/web3-bzz/types/tsconfig.json b/packages/web3-bzz/types/tsconfig.json new file mode 100644 index 00000000000..bf0cfa6d681 --- /dev/null +++ b/packages/web3-bzz/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-bzz": ["."] + } + } +} diff --git a/packages/web3-bzz/types/tslint.json b/packages/web3-bzz/types/tslint.json new file mode 100644 index 00000000000..871d605704b --- /dev/null +++ b/packages/web3-bzz/types/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false + } +} diff --git a/packages/web3-core-helpers/README.md b/packages/web3-core-helpers/README.md index 0d973edff3d..d5a251ce88c 100644 --- a/packages/web3-core-helpers/README.md +++ b/packages/web3-core-helpers/README.md @@ -24,8 +24,9 @@ helpers.errors; ... ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-core-helpers/package-lock.json b/packages/web3-core-helpers/package-lock.json index d8f894cdc17..0ad01e74290 100644 --- a/packages/web3-core-helpers/package-lock.json +++ b/packages/web3-core-helpers/package-lock.json @@ -2,10 +2,349 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-core-helpers/package.json b/packages/web3-core-helpers/package.json index 263e3d58529..a2e2dc28258 100644 --- a/packages/web3-core-helpers/package.json +++ b/packages/web3-core-helpers/package.json @@ -7,10 +7,18 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "underscore": "1.9.1", "web3-eth-iban": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-core-helpers/types/index.d.ts b/packages/web3-core-helpers/types/index.d.ts new file mode 100644 index 00000000000..9a568adb1bf --- /dev/null +++ b/packages/web3-core-helpers/types/index.d.ts @@ -0,0 +1,177 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import * as net from 'net'; + +export class formatters { + static outputBigNumberFormatter(number: number): number; + + static inputSignFormatter(data: string): string; + + static inputAddressFormatter(address: string): string; + + static isPredefinedBlockNumber(blockNumber: string): boolean; + + static inputDefaultBlockNumberFormatter(blockNumber: string): string; + + static inputBlockNumberFormatter(blockNumber: string | number): string | number; + + static outputBlockFormatter(block: any): any; // TODO: Create Block interface + + static txInputFormatter(txObject: any): any; + + static inputCallFormatter(txObject: any): any; + + static inputTransactionFormatter(txObject: any): any; + + static outputTransactionFormatter(receipt: any): any; + + static outputTransactionReceiptFormatter(receipt: any): any; + + static inputLogFormatter(log: any): any; + + static outputLogFormatter(log: any): any; + + static inputPostFormatter(post: any): any; // TODO: Create Post interface + + static outputPostFormatter(post: any): any; // TODO: Create Post interface + + static outputSyncingFormatter(result: any): any; // TODO: Create SyncLog interface +} + +export class errors { + static ErrorResponse(result: Error): Error; + static InvalidNumberOfParams( + got: number, + expected: number, + method: string + ): Error; + static InvalidConnection(host: string): Error; + static InvalidProvider(): Error; + static InvalidResponse(result: Error): Error; + static ConnectionTimeout(ms: string): Error; +} + +export class WebsocketProviderBase { + constructor(host: string, options?: WebsocketProviderOptions); + + isConnecting(): boolean; + + responseCallbacks: any; + notificationCallbacks: any; + connected: boolean; + connection: any; + + addDefaultEvents(): void; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + on(type: string, callback: () => void): void; + + once(type: string, callback: () => void): void; + + removeListener(type: string, callback: () => void): void; + + removeAllListeners(type: string): void; + + reset(): void; + + disconnect(code: number, reason: string): void; +} + +export class IpcProviderBase { + constructor(path: string, net: net.Server); + + responseCallbacks: any; + notificationCallbacks: any; + connected: boolean; + connection: any; + + addDefaultEvents(): void; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + on(type: string, callback: () => void): void; + + once(type: string, callback: () => void): void; + + removeListener(type: string, callback: () => void): void; + + removeAllListeners(type: string): void; + + reset(): void; + + reconnect(): void; +} + +export class HttpProviderBase { + constructor(host: string, options?: HttpProviderOptions); + + host: string; + connected: boolean; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + disconnect(): boolean; +} + +export interface HttpProviderOptions { + keepAlive?: boolean; + timeout?: number; + headers?: HttpHeader[]; + withCredentials?: boolean; +} + +export interface HttpHeader { + name: string; + value: string; +} + +export interface WebsocketProviderOptions { + host?: string; + timeout?: number; + reconnectDelay?: number; + headers?: any; + protocol?: string; + clientConfig?: string; + requestOptions?: any; + origin?: string; +} + +export interface JsonRpcPayload { + jsonrpc: string; + method: string; + params: any[]; + id?: string | number; +} diff --git a/packages/web3-core-helpers/types/tests/errors-test.ts b/packages/web3-core-helpers/types/tests/errors-test.ts new file mode 100644 index 00000000000..1cc503fafc0 --- /dev/null +++ b/packages/web3-core-helpers/types/tests/errors-test.ts @@ -0,0 +1,38 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file errors-test.ts + * @author Josh Stevens + * @date 2019 + */ + +import { errors } from 'web3-core-helpers'; + +// $ExpectType Error +errors.ErrorResponse(new Error('hey')); + +// $ExpectType Error +errors.InvalidNumberOfParams(1, 3, 'method'); + +// $ExpectType Error +errors.InvalidConnection('https://localhost:2345432'); + +// $ExpectType Error +errors.InvalidProvider(); + +// $ExpectType Error +errors.InvalidResponse(new Error('hey')); + +// $ExpectType Error +errors.ConnectionTimeout('timeout'); diff --git a/packages/web3-core-helpers/types/tests/formatters-test.ts b/packages/web3-core-helpers/types/tests/formatters-test.ts new file mode 100644 index 00000000000..90c57c20a41 --- /dev/null +++ b/packages/web3-core-helpers/types/tests/formatters-test.ts @@ -0,0 +1,68 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file formatters-test.ts + * @author Samuel Furter + * @date 2018 + */ + +import { formatters } from 'web3-core-helpers'; + +// $ExpectType number +formatters.outputBigNumberFormatter(100); + +// $ExpectType string +formatters.inputSignFormatter('0x0'); + +// $ExpectType string +formatters.inputAddressFormatter('0x0'); + +// $ExpectType boolean +formatters.isPredefinedBlockNumber('latest'); + +// $ExpectType string | number +formatters.inputBlockNumberFormatter('0x0'); + +// $ExpectType any +formatters.outputBlockFormatter({}); + +// $ExpectType any +formatters.txInputFormatter({}); + +// $ExpectType any +formatters.inputCallFormatter({}); + +// $ExpectType any +formatters.inputTransactionFormatter({}); + +// $ExpectType any +formatters.outputTransactionFormatter({}); + +// $ExpectType any +formatters.outputTransactionReceiptFormatter({}); + +// $ExpectType any +formatters.inputLogFormatter({}); + +// $ExpectType any +formatters.outputLogFormatter({}); + +// $ExpectType any +formatters.inputPostFormatter({}); + +// $ExpectType any +formatters.outputPostFormatter({}); + +// $ExpectType any +formatters.outputSyncingFormatter({}); diff --git a/packages/web3-core-helpers/types/tsconfig.json b/packages/web3-core-helpers/types/tsconfig.json new file mode 100644 index 00000000000..fd847a8cabb --- /dev/null +++ b/packages/web3-core-helpers/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-core-helpers": ["."] + } + } +} diff --git a/packages/web3-core-helpers/types/tslint.json b/packages/web3-core-helpers/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-core-helpers/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-core-method/README.md b/packages/web3-core-method/README.md index 01c5dd4e761..ef4a8899061 100644 --- a/packages/web3-core-method/README.md +++ b/packages/web3-core-method/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-core-method.js` in your html file. This will expose the `Web3Method` object on the window object. - ## Usage ```js @@ -42,8 +41,9 @@ method.attachToObject(myCoolLib); myCoolLib.sendTransaction({...}, function(){ ... }); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-core-method/package-lock.json b/packages/web3-core-method/package-lock.json index d8f894cdc17..0ad01e74290 100644 --- a/packages/web3-core-method/package-lock.json +++ b/packages/web3-core-method/package-lock.json @@ -2,10 +2,349 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-core-method/package.json b/packages/web3-core-method/package.json index 5e2f63f9c2d..90bc0654f8e 100644 --- a/packages/web3-core-method/package.json +++ b/packages/web3-core-method/package.json @@ -7,6 +7,10 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "underscore": "1.9.1", @@ -14,5 +18,9 @@ "web3-core-promievent": "1.2.1", "web3-core-subscriptions": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-core-method/types/index.d.ts b/packages/web3-core-method/types/index.d.ts new file mode 100644 index 00000000000..2fbd3fdc937 --- /dev/null +++ b/packages/web3-core-method/types/index.d.ts @@ -0,0 +1,32 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Samuel Furter + * @date 2018 + */ + +import {JsonRpcPayload} from 'web3-core-helpers'; + +export interface Method { + name: string; + call: string; + params?: number; + inputFormatter?: Array<(() => void) | null>; + outputFormatter?: () => void; + transformPayload?: () => void; + extraFormatters?: any; + defaultBlock?: string; + defaultAccount?: string | null; +} diff --git a/packages/web3-core-method/types/tsconfig.json b/packages/web3-core-method/types/tsconfig.json new file mode 100644 index 00000000000..17889c4b6ce --- /dev/null +++ b/packages/web3-core-method/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-core-method": ["."] + } + } +} diff --git a/packages/web3-core-method/types/tslint.json b/packages/web3-core-method/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-core-method/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-core-subscriptions/package-lock.json b/packages/web3-core-subscriptions/package-lock.json index 02979441fb1..e023f352481 100644 --- a/packages/web3-core-subscriptions/package-lock.json +++ b/packages/web3-core-subscriptions/package-lock.json @@ -1,16 +1,405 @@ { - "requires": true, + "name": "web3-core-subscriptions", + "version": "1.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==", + "dev": true + }, + "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" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "dev": true, + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191016" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, "eventemitter3": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "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" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191016", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191016.tgz", + "integrity": "sha512-4CUiTF5rEtPaClGD9nWpqPMICdDc54PTyrzwqpivz/h7mkWJs/xhQhOddiA5vx+D8ob9eSRIdueXQkI2oxOmfg==", + "dev": true + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true } } } diff --git a/packages/web3-core-subscriptions/package.json b/packages/web3-core-subscriptions/package.json index 552118d2f08..44f356a8946 100644 --- a/packages/web3-core-subscriptions/package.json +++ b/packages/web3-core-subscriptions/package.json @@ -7,10 +7,18 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "eventemitter3": "3.1.2", "underscore": "1.9.1", "web3-core-helpers": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-core-subscriptions/src/subscription.js b/packages/web3-core-subscriptions/src/subscription.js index 330ee446904..8774c3cca9f 100644 --- a/packages/web3-core-subscriptions/src/subscription.js +++ b/packages/web3-core-subscriptions/src/subscription.js @@ -112,7 +112,7 @@ Subscription.prototype._formatInput = function (args) { * Should be called to format output(result) of method * * @method formatOutput - * @param {Object} + * @param result {Object} * @return {Object} */ diff --git a/packages/web3-core-subscriptions/types/index.d.ts b/packages/web3-core-subscriptions/types/index.d.ts new file mode 100644 index 00000000000..39d8135157c --- /dev/null +++ b/packages/web3-core-subscriptions/types/index.d.ts @@ -0,0 +1,78 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Samuel Furter + * @date 2019 + */ + +export class Subscription { + constructor(options: SubscriptionOptions); + + id: string; + options: SubscriptionOptions; + callback: () => void; + arguments: any; + + subscribe(callback?: (error: Error, result: T) => void): Subscription; + + unsubscribe( + callback?: (error: Error, result: boolean) => void + ): Promise; + + on(type: 'data', handler: (data: T) => void): Subscription; + + on(type: 'changed', handler: (data: T) => void): Subscription; + + on(type: 'error', handler: (data: Error) => void): Subscription; +} + +export class Subscriptions { + constructor(options: SubscriptionsOptions); + + name: string; + type: string; + subscriptions: SubscriptionsModel; + readonly requestManager: any; + + attachToObject(obj: any): void; + + setRequestManager(requestManager: any): void; + + buildCall(): () => any; +} + +export interface SubscriptionOptions { + subscription: string; + type: string; + requestManager: any; +} + +export interface SubscriptionsOptions { + name: string; + type: string; + subscriptions: SubscriptionsModel; +} + +export interface SubscriptionsModel { + [name: string]: SubscriptionModel; +} + +export interface SubscriptionModel { + subscriptionName: string; + params: number; + outputFormatter: () => void; + inputFormatter: Array<() => void>; + subscriptionHandler: () => void; +} diff --git a/packages/web3-core-subscriptions/types/tests/subscriptions.tests.ts b/packages/web3-core-subscriptions/types/tests/subscriptions.tests.ts new file mode 100644 index 00000000000..467ac5f7808 --- /dev/null +++ b/packages/web3-core-subscriptions/types/tests/subscriptions.tests.ts @@ -0,0 +1,85 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file subscriptions-tests.ts + * @author Samuel Furter + * @date 2019 + */ + +import {Subscriptions, Subscription} from 'web3-core-subscriptions'; + +const subscriptions = new Subscriptions({ + name: '', + type: '', + subscriptions: + { + test: { + subscriptionName: '', + inputFormatter: [() => {}], + outputFormatter: () => {}, + params: 0, + subscriptionHandler: () => {} + } + } +}); + +// $ExpectType string +subscriptions.name; + +// $ExpectType string +subscriptions.type; + +// $ExpectType SubscriptionsModel +subscriptions.subscriptions; + +// $ExpectType void +subscriptions.setRequestManager({}); + +// $ExpectType void +subscriptions.attachToObject({}); + +// $ExpectType () => any +subscriptions.buildCall(); + +const subscription = new Subscription({subscription: '', type: '', requestManager: null}); + +// $ExpectType string +subscription.id; + +// $ExpectType () => void +subscription.callback; + +// $ExpectType any +subscription.arguments; + +// $ExpectType SubscriptionOptions +subscription.options; + +// $ExpectType Subscription +subscription.subscribe(() => {}); + +// $ExpectType Promise +subscription.unsubscribe(() => {}); + +// $ExpectType Subscription +subscription.on('data', () => {}); + +// $ExpectType Subscription +subscription.on('changed', () => {}); + +// $ExpectType Subscription +subscription.on('error', () => {}); diff --git a/packages/web3-core-subscriptions/types/tsconfig.json b/packages/web3-core-subscriptions/types/tsconfig.json new file mode 100644 index 00000000000..4fa0faa5998 --- /dev/null +++ b/packages/web3-core-subscriptions/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-core-subscriptions": ["."] + } + } +} diff --git a/packages/web3-core-subscriptions/types/tslint.json b/packages/web3-core-subscriptions/types/tslint.json new file mode 100644 index 00000000000..2a4469808b0 --- /dev/null +++ b/packages/web3-core-subscriptions/types/tslint.json @@ -0,0 +1,12 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false, + "no-redundant-jsdoc": false + } +} diff --git a/packages/web3-core/README.md b/packages/web3-core/README.md index e559912882d..7163f00c1e5 100644 --- a/packages/web3-core/README.md +++ b/packages/web3-core/README.md @@ -13,7 +13,6 @@ Please read the [documentation][docs] for more. npm install web3-core ``` - ## Usage ```js @@ -24,7 +23,7 @@ var CoolLib = function CoolLib() { // sets _requestmanager and adds basic functions core.packageInit(this, arguments); - + }; @@ -36,8 +35,12 @@ CoolLib.extend(); ... ``` - [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js +## Types +All the typescript typings are placed in the types folder. + +[docs]: http://web3js.readthedocs.io/en/1.0/ +[repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3-core/package-lock.json b/packages/web3-core/package-lock.json new file mode 100644 index 00000000000..2da57d64a24 --- /dev/null +++ b/packages/web3-core/package-lock.json @@ -0,0 +1,358 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==" + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/packages/web3-core/package.json b/packages/web3-core/package.json index 01017fbc8d9..95d3f951a13 100644 --- a/packages/web3-core/package.json +++ b/packages/web3-core/package.json @@ -7,11 +7,21 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { + "@types/bn.js": "^4.11.4", + "@types/node": "^12.6.1", "web3-core-helpers": "1.2.1", "web3-core-method": "1.2.1", "web3-core-requestmanager": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-core/types/index.d.ts b/packages/web3-core/types/index.d.ts new file mode 100644 index 00000000000..93a98cd183a --- /dev/null +++ b/packages/web3-core/types/index.d.ts @@ -0,0 +1,371 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @author Prince Sinha + * @date 2018 + */ + +import * as net from 'net'; +import { + HttpProviderBase, + HttpProviderOptions, + IpcProviderBase, + WebsocketProviderBase, + WebsocketProviderOptions +} from 'web3-core-helpers'; +import { Method } from 'web3-core-method'; +import BN = require('bn.js'); + +export interface SignedTransaction { + messageHash?: string; + r: string; + s: string; + v: string; + rawTransaction?: string; + transactionHash?: string; +} + +export interface Extension { + property?: string, + methods: Method[] +} + +export interface Providers { + HttpProvider: new ( + host: string, + options?: HttpProviderOptions + ) => HttpProvider; + WebsocketProvider: new ( + host: string, + options?: WebsocketProviderOptions + ) => WebsocketProvider; + IpcProvider: new (path: string, net: any) => IpcProvider; +} + +export interface PromiEvent extends Promise { + once( + type: 'transactionHash', + handler: (receipt: string) => void + ): PromiEvent; + + once( + type: 'receipt', + handler: (receipt: TransactionReceipt) => void + ): PromiEvent; + + once( + type: 'confirmation', + handler: (confNumber: number, receipt: TransactionReceipt) => void + ): PromiEvent; + + once(type: 'error', handler: (error: Error) => void): PromiEvent; + + once( + type: 'error' | 'confirmation' | 'receipt' | 'transactionHash', + handler: (error: Error | TransactionReceipt | string) => void + ): PromiEvent; + + on( + type: 'transactionHash', + handler: (receipt: string) => void + ): PromiEvent; + + on( + type: 'receipt', + handler: (receipt: TransactionReceipt) => void + ): PromiEvent; + + on( + type: 'confirmation', + handler: (confNumber: number, receipt: TransactionReceipt) => void + ): PromiEvent; + + on(type: 'error', handler: (error: Error) => void): PromiEvent; + + on( + type: 'error' | 'confirmation' | 'receipt' | 'transactionHash', + handler: (error: Error | TransactionReceipt | string) => void + ): PromiEvent; +} + +export interface Transaction { + hash: string; + nonce: number; + blockHash: string | null; + blockNumber: number | null; + transactionIndex: number | null; + from: string; + to: string | null; + value: string; + gasPrice: string; + gas: number; + input: string; +} + +export interface TransactionConfig { + from?: string | number; + to?: string; + value?: number | string | BN; + gas?: number | string; + gasPrice?: number | string | BN; + data?: string; + nonce?: number; + chainId?: number; +} + +export interface RLPEncodedTransaction { + raw: string; + tx: { + nonce: string; + gasPrice: string; + gas: string; + to: string; + value: string; + input: string; + r: string; + s: string; + v: string; + hash: string; + }; +} + +export interface TransactionReceipt { + status: boolean; + transactionHash: string; + transactionIndex: number; + blockHash: string; + blockNumber: number; + from: string; + to: string; + contractAddress?: string; + cumulativeGasUsed: number; + gasUsed: number; + logs: Log[]; + logsBloom: string; + events?: { + [eventName: string]: EventLog; + }; +} + +export interface EventLog { + event: string; + address: string; + returnValues: any; + logIndex: number; + transactionIndex: number; + transactionHash: string; + blockHash: string; + blockNumber: number; + raw?: {data: string; topics: any[]}; +} + +export interface Log { + address: string; + data: string; + topics: Array; + logIndex: number; + transactionIndex: number; + transactionHash: string; + blockHash: string; + blockNumber: number; +} + +// had to move `web3-net` due to other modules in `1.x` not referencing + +export class NetworkBase { + constructor(provider: provider, net?: net.Socket | null); + + readonly givenProvider: any; + readonly currentProvider: provider; + BatchRequest: new () => BatchRequest; + static readonly providers: Providers; + + setProvider(provider: provider): boolean; + + extend(extension: Extension): any; + + getNetworkType( + callback?: (error: Error, returnValue: string) => void + ): Promise; + + getId(callback?: (error: Error, id: number) => void): Promise; + + isListening( + callback?: (error: Error, listening: boolean) => void + ): Promise; + + getPeerCount( + callback?: (error: Error, peerCount: number) => void + ): Promise; +} + +// had to move accounts from web3-eth-accounts due to other modules in 1.x not referencing + +export class AccountsBase { + constructor(provider: provider, net?: net.Socket | null); + + readonly givenProvider: any; + readonly currentProvider: provider; + BatchRequest: new () => BatchRequest; + static readonly providers: Providers; + + setProvider(provider: provider): boolean; + + extend(extension: Extension): any; + + create(entropy?: string): Account; + + privateKeyToAccount(privateKey: string): Account; + + signTransaction( + transactionConfig: TransactionConfig, + privateKey: string, + callback?: () => void + ): Promise; + + recoverTransaction(signature: string): string; + + hashMessage(message: string): string; + + sign(data: string, privateKey: string): Sign; + + recover(signatureObject: SignatureObject): string; + recover(message: string, signature: string, preFixed?: boolean): string; + recover( + message: string, + v: string, + r: string, + s: string, + preFixed?: boolean + ): string; + + encrypt(privateKey: string, password: string): EncryptedKeystoreV3Json; + + decrypt(keystoreJsonV3: EncryptedKeystoreV3Json, password: string): Account; + + wallet: WalletBase; +} + +export class WalletBase { + constructor(accounts: AccountsBase); + + length: number; + defaultKeyName: string; + + [key: number]: Account; + + create(numberOfAccounts: number, entropy?: string): WalletBase; + + add(account: string | AddAccount): AddedAccount; + + remove(account: string | number): boolean; + + clear(): WalletBase; + + encrypt(password: string): EncryptedKeystoreV3Json[]; + + decrypt( + keystoreArray: EncryptedKeystoreV3Json[], + password: string + ): WalletBase; + + save(password: string, keyName?: string): boolean; + + load(password: string, keyName?: string): WalletBase; +} + +export interface AddAccount { + address: string; + privateKey: string; +} + +export interface AddedAccount extends Account { + index: number; +} + +export interface Account { + address: string; + privateKey: string; + signTransaction: ( + transactionConfig: TransactionConfig, + callback?: (signTransaction: SignedTransaction) => void + ) => Promise; + sign: (data: string) => Sign; + encrypt: (password: string) => EncryptedKeystoreV3Json; +} + +export interface EncryptedKeystoreV3Json { + version: number; + id: string; + address: string; + crypto: { + ciphertext: string; + cipherparams: {iv: string}; + cipher: string; + kdf: string; + kdfparams: { + dklen: number; + salt: string; + n: number; + r: number; + p: number; + }; + mac: string; + }; +} + +export interface Sign extends SignedTransaction { + message: string; + signature: string; +} + +export interface SignatureObject { + messageHash: string; + r: string; + s: string; + v: string; +} + +// put all the `web3-provider` typings in here so we can get to them everywhere as this module does not exist in 1.x + +export class BatchRequest { + constructor(); + + add(method: Method): void; + + execute(): void; +} + +export class HttpProvider extends HttpProviderBase { + constructor(host: string, options?: HttpProviderOptions); +} + +export class IpcProvider extends IpcProviderBase { + constructor(path: string, net: net.Server); +} + +export class WebsocketProvider extends WebsocketProviderBase { + constructor(host: string, options?: WebsocketProviderOptions); + + isConnecting(): boolean; +} + +export type provider = + | HttpProvider + | IpcProvider + | WebsocketProvider + | string + | null; diff --git a/packages/web3-core/types/tsconfig.json b/packages/web3-core/types/tsconfig.json new file mode 100644 index 00000000000..9db422ea462 --- /dev/null +++ b/packages/web3-core/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-core": ["."] + } + } +} diff --git a/packages/web3-core/types/tslint.json b/packages/web3-core/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-core/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-eth-abi/README.md b/packages/web3-eth-abi/README.md index 0cb883cffe5..9a42822ab11 100644 --- a/packages/web3-eth-abi/README.md +++ b/packages/web3-eth-abi/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth-abi.js` in your html file. This will expose the `Web3EthAbi` object on the window object. - ## Usage ```js @@ -35,8 +34,9 @@ Web3EthAbi.encodeFunctionSignature('myMethod(uint256,string)'); > '0x24ee0097' ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-eth-abi/package-lock.json b/packages/web3-eth-abi/package-lock.json index df5ba50b07e..46eb6e58444 100644 --- a/packages/web3-eth-abi/package-lock.json +++ b/packages/web3-eth-abi/package-lock.json @@ -2,26 +2,153 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "@types/node": { "version": "10.14.9", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.9.tgz", "integrity": "sha512-NelG/dSahlXYtSoVPErrp06tYFrvzj8XLWmKA+X8x0W//4MqbUyZu++giUG/v0bjAT6/Qxa8IjodrfdACyb0Fg==" }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, "aes-js": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, "elliptic": { "version": "6.3.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", @@ -33,6 +160,21 @@ "inherits": "^2.0.1" } }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, "ethers": { "version": "4.0.0-beta.3", "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.3.tgz", @@ -50,6 +192,44 @@ "xmlhttprequest": "1.8.0" } }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "hash.js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", @@ -59,6 +239,15 @@ "minimalistic-assert": "^1.0.0" } }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -69,31 +258,176 @@ "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, "scrypt-js": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz", "integrity": "sha1-uwBAvgMEPamgEqLOqfyfhSz8h9Q=" }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, "setimmediate": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, "uuid": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "xmlhttprequest": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", diff --git a/packages/web3-eth-abi/package.json b/packages/web3-eth-abi/package.json index acc3b63e260..5c6600df154 100644 --- a/packages/web3-eth-abi/package.json +++ b/packages/web3-eth-abi/package.json @@ -7,10 +7,18 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "ethers": "4.0.0-beta.3", "underscore": "1.9.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-abi/types/index.d.ts b/packages/web3-eth-abi/types/index.d.ts new file mode 100644 index 00000000000..4343b578967 --- /dev/null +++ b/packages/web3-eth-abi/types/index.d.ts @@ -0,0 +1,42 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import { AbiInput, AbiItem } from 'web3-utils'; + +export class AbiCoder { + encodeFunctionSignature(functionName: string | AbiItem): string; + + encodeEventSignature(functionName: string | AbiItem): string; + + encodeParameter(type: any, parameter: any): string; + + encodeParameters(types: any[], paramaters: any[]): string; + + encodeFunctionCall(abiItem: AbiItem, params: string[]): string; + + decodeParameter(type: any, hex: string): { [key: string]: any }; + + decodeParameters(types: any[], hex: string): { [key: string]: any }; + + decodeLog( + inputs: AbiInput[], + hex: string, + topics: string[] + ): { [key: string]: string }; +} diff --git a/packages/web3-eth-abi/types/tests/abi-coder-test.ts b/packages/web3-eth-abi/types/tests/abi-coder-test.ts new file mode 100644 index 00000000000..0ed89e58c0a --- /dev/null +++ b/packages/web3-eth-abi/types/tests/abi-coder-test.ts @@ -0,0 +1,753 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file abi-coder-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import { AbiCoder } from 'web3-eth-abi'; + +const abiCoder = new AbiCoder(); + +// $ExpectType string +abiCoder.encodeFunctionSignature('myMethod(uint256,string)'); +// $ExpectType string +abiCoder.encodeFunctionSignature({ + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] +}); + +// $ExpectError +abiCoder.encodeFunctionSignature(345); +// $ExpectError +abiCoder.encodeFunctionSignature({}); +// $ExpectError +abiCoder.encodeFunctionSignature(true); +// $ExpectError +abiCoder.encodeFunctionSignature(['string']); +// $ExpectError +abiCoder.encodeFunctionSignature([4]); +// $ExpectError +abiCoder.encodeFunctionSignature(null); +// $ExpectError +abiCoder.encodeFunctionSignature(undefined); +// $ExpectError +abiCoder.encodeFunctionSignature('myMethod(uint256,string)', { + name: 'myMethod' +}); + +// $ExpectType string +abiCoder.encodeEventSignature('myEvent(uint256,bytes32)'); +// $ExpectType string +abiCoder.encodeFunctionSignature({ + name: 'myEvent', + type: 'event', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'bytes32', + name: 'myBytes' + } + ] +}); + +// $ExpectError +abiCoder.encodeFunctionSignature(345); +// $ExpectError +abiCoder.encodeFunctionSignature({}); +// $ExpectError +abiCoder.encodeFunctionSignature(true); +// $ExpectError +abiCoder.encodeFunctionSignature(['string']); +// $ExpectError +abiCoder.encodeFunctionSignature([4]); +// $ExpectError +abiCoder.encodeFunctionSignature(null); +// $ExpectError +abiCoder.encodeFunctionSignature(undefined); +// $ExpectError +abiCoder.encodeFunctionSignature('myEvent(uint256,bytes32)', { + name: 'myEvent' +}); + +// $ExpectType string +abiCoder.encodeParameter('uint256', '2345675643'); +// $ExpectType string +abiCoder.encodeParameter('uint256', ['0xdf3234', '0xfdfd']); +// $ExpectType string +abiCoder.encodeParameter( + { + ParentStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256', + childStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256' + } + } + }, + { + propertyOne: 42, + propertyTwo: 56, + childStruct: { + propertyOne: 45, + propertyTwo: 78 + } + } +); + +// $ExpectType string +abiCoder.encodeParameters(['uint256', 'string'], ['2345675643', 'Hello!%']); +// $ExpectType string +abiCoder.encodeParameters( + ['uint8[]', 'bytes32'], + [['34', '434'], '0x324567fff'] +); +// $ExpectType string +abiCoder.encodeParameters( + [ + 'uint8[]', + { + ParentStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256', + ChildStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256' + } + } + } + ], + [ + ['34', '434'], + { + propertyOne: '42', + propertyTwo: '56', + ChildStruct: { + propertyOne: '45', + propertyTwo: '78' + } + } + ] +); + +// $ExpectError +abiCoder.encodeParameters(345, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeParameters(true, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeParameters(null, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeParameters(undefined, ['2345675643', 'Hello!%']); + +// $ExpectType string +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + ['2345675643', 'Hello!%'] +); + +// $ExpectError +abiCoder.encodeFunctionCall([345], ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeFunctionCall(['string'], ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeFunctionCall(345, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeFunctionCall(true, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeFunctionCall(null, ['2345675643', 'Hello!%']); +// $ExpectError +abiCoder.encodeFunctionCall(undefined, ['2345675643', 'Hello!%']); + +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + // $ExpectError + 345 +); + +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + // $ExpectError + [345] +); + +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + // $ExpectError + true +); + +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + // $ExpectError + null +); + +abiCoder.encodeFunctionCall( + { + name: 'myMethod', + type: 'function', + inputs: [ + { + type: 'uint256', + name: 'myNumber' + }, + { + type: 'string', + name: 'myString' + } + ] + }, + // $ExpectError + undefined +); + +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameter( + 'uint256', + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameter( + 'uint256', + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameter( + 'uint256', + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameter( + { + ParentStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256', + childStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256' + } + } + }, + `0x000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000 + 00000000000038000000000000000000000000000000000000000000000000000000000000002d00000000000000000000000000000000000000 + 0000000000000000000000004e` +); + +// $ExpectError +abiCoder.decodeParameter('uint256', [345]); +// $ExpectError +abiCoder.decodeParameter('uint256', ['string']); +// $ExpectError +abiCoder.decodeParameter('uint256', 345); +// $ExpectError +abiCoder.decodeParameter('uint256', true); +// $ExpectError +abiCoder.decodeParameter('uint256', null); +// $ExpectError +abiCoder.decodeParameter('uint256', undefined); + +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameters( + ['string', 'uint256'], + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameters( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber' + } + ], + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectType { [key: string]: any; } +abiCoder.decodeParameters( + [ + 'uint8[]', + { + ParentStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256', + childStruct: { + propertyOne: 'uint256', + propertyTwo: 'uint256' + } + } + } + ], + '0x0000000000000000000000000000000000000000000000000000000000000010' +); + +abiCoder.decodeParameters( + // $ExpectError + 'uint256', + '0x0000000000000000000000000000000000000000000000000000000000000010' +); + +abiCoder.decodeParameters( + // $ExpectError + 453, + '0x0000000000000000000000000000000000000000000000000000000000000010' +); + +abiCoder.decodeParameters( + // $ExpectError + true, + '0x0000000000000000000000000000000000000000000000000000000000000010' +); + +abiCoder.decodeParameters( + // $ExpectError + null, + '0x0000000000000000000000000000000000000000000000000000000000000010' +); + +abiCoder.decodeParameters( + // $ExpectError + undefined, + '0x0000000000000000000000000000000000000000000000000000000000000010' +); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], 345); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], ['string']); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], [345]); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], true); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], null); +// $ExpectError +abiCoder.decodeParameters(['string', 'uint256'], undefined); + +// $ExpectType { [key: string]: string; } +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + // $ExpectError + ['string'], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + // $ExpectError + [345], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + // $ExpectError + true, + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + // $ExpectError + [undefined], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + // $ExpectError + [null], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + 345, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + [345], + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + ['string'], + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + true, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + null, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + // $ExpectError + undefined, + [ + '0x000000000000000000000000000000000000000000000000000000000000f310', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + // $ExpectError + 345 +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + // $ExpectError + [345] +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + // $ExpectError + null +); + +abiCoder.decodeLog( + [ + { + type: 'string', + name: 'myString' + }, + { + type: 'uint256', + name: 'myNumber', + indexed: true + }, + { + type: 'uint8', + name: 'mySmallNumber', + indexed: true + } + ], + `0x0000000000000000000000000000000000000000000000000000000000000020000000000000000 + 000000000000000000000000000000000000000000000000748656c6c6f2521000000000000000000 + 00000000000000000000000000000000`, + // $ExpectError + undefined +); diff --git a/packages/web3-eth-abi/types/tsconfig.json b/packages/web3-eth-abi/types/tsconfig.json new file mode 100644 index 00000000000..4e08e726c5b --- /dev/null +++ b/packages/web3-eth-abi/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-abi": ["."] + } + } +} diff --git a/packages/web3-eth-abi/types/tslint.json b/packages/web3-eth-abi/types/tslint.json new file mode 100644 index 00000000000..2b3d7bd5fb1 --- /dev/null +++ b/packages/web3-eth-abi/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "typedef-whitespace": false + } +} diff --git a/packages/web3-eth-accounts/README.md b/packages/web3-eth-accounts/README.md index 94c31e8151a..a0b6cf81ce9 100644 --- a/packages/web3-eth-accounts/README.md +++ b/packages/web3-eth-accounts/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth-accounts.js` in your html file. This will expose the `Web3EthAccounts` object on the window object. - ## Usage ```js @@ -42,8 +41,9 @@ account.create(); } ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-eth-accounts/package-lock.json b/packages/web3-eth-accounts/package-lock.json index 29a025ac480..1e4741fb9e1 100644 --- a/packages/web3-eth-accounts/package-lock.json +++ b/packages/web3-eth-accounts/package-lock.json @@ -1,12 +1,58 @@ { - "requires": true, + "name": "web3-eth-accounts", + "version": "1.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==", + "dev": true + }, + "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" + } + }, "any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", @@ -17,6 +63,12 @@ "minimalistic-assert": "^1.0.0" } }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -38,6 +90,16 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", @@ -110,6 +172,23 @@ "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -119,6 +198,33 @@ "safe-buffer": "^5.0.1" } }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -192,6 +298,16 @@ "object-keys": "^1.0.12" } }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, "des.js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", @@ -201,6 +317,12 @@ "minimalistic-assert": "^1.0.0" } }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, "diffie-hellman": { "version": "5.0.3", "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -226,6 +348,30 @@ "create-hmac": "^1.1.4" } }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "dev": true, + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, "elliptic": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", @@ -263,6 +409,24 @@ "is-symbol": "^1.0.2" } }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, "eth-lib": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", @@ -332,11 +496,42 @@ "is-callable": "^1.1.3" } }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "global": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", @@ -346,6 +541,12 @@ "process": "~0.5.1" } }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -354,6 +555,12 @@ "function-bind": "^1.1.1" } }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", @@ -387,6 +594,16 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -428,6 +645,31 @@ "has-symbols": "^1.0.0" } }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "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" + } + }, "keccak": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz", @@ -481,6 +723,30 @@ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, "nan": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", @@ -525,6 +791,24 @@ "string.prototype.trim": "^1.1.2" } }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, "pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", @@ -582,6 +866,15 @@ "safe-buffer": "^5.1.0" } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "ripemd160": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", @@ -640,6 +933,12 @@ "safe-buffer": "^5.1.2" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", @@ -664,6 +963,12 @@ "simple-concat": "^1.0.0" } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -687,16 +992,79 @@ "is-hex-prefixed": "1.0.0" } }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, "timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==", + "dev": true + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "url-set-query": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", diff --git a/packages/web3-eth-accounts/package.json b/packages/web3-eth-accounts/package.json index df892a7293e..043ce47243f 100644 --- a/packages/web3-eth-accounts/package.json +++ b/packages/web3-eth-accounts/package.json @@ -7,6 +7,10 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "any-promise": "1.3.0", @@ -20,5 +24,9 @@ "web3-core-method": "1.2.1", "web3-utils": "1.2.1", "ethereumjs-tx": "^2.1.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-accounts/types/index.d.ts b/packages/web3-eth-accounts/types/index.d.ts new file mode 100644 index 00000000000..5dde16b881c --- /dev/null +++ b/packages/web3-eth-accounts/types/index.d.ts @@ -0,0 +1,36 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import { AccountsBase, SignedTransaction, WalletBase } from 'web3-core'; + +export class Accounts extends AccountsBase {} + +export class Wallet extends WalletBase {} + +export interface Sign extends SignedTransaction { + message: string; + signature: string; +} + +export interface SignatureObject { + messageHash: string; + r: string; + s: string; + v: string; +} diff --git a/packages/web3-eth-accounts/types/tests/accounts-tests.ts b/packages/web3-eth-accounts/types/tests/accounts-tests.ts new file mode 100644 index 00000000000..81bbb4dbbd4 --- /dev/null +++ b/packages/web3-eth-accounts/types/tests/accounts-tests.ts @@ -0,0 +1,240 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file accounts-tests.ts + * @author Josh Stevens + * @date 2018 + */ +import { Accounts } from 'web3-eth-accounts'; + +const accounts = new Accounts('http://localhost:8545'); + +// $ExpectType provider +accounts.currentProvider; + +// $ExpectType any +accounts.givenProvider; + +// $ExpectType boolean +accounts.setProvider('https://localhost:2100'); + +// $ExpectType any +accounts.extend({ + property: 'test', + methods: [{ name: 'method', call: 'method' }] +}); + +// $ExpectType BatchRequest +new accounts.BatchRequest(); + +// $ExpectType Account +accounts.create(); +// $ExpectType Account +accounts.create( + '2435@#@#@±±±±!!!!678543213456764321§34567543213456785432134567' +); + +// $ExpectType Account +accounts.privateKeyToAccount( + '0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709' +); + +// $ExpectType Promise +accounts.signTransaction( + { + to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', + value: '1000000000', + gas: 2000000 + }, + '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318' +); + +// $ExpectType Promise +accounts.signTransaction( + { + to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', + value: '1000000000', + gas: 2000000 + }, + '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', + () => { + console.log('hey'); + } +); + +// $ExpectType string +accounts.recoverTransaction( + '0xf861808084aefcdfa08e7d2ee3f0b9d9ae184b2001fe0aff07603d9' +); + +// $ExpectType string +accounts.hashMessage('hello world'); + +// $ExpectType Sign +accounts.sign( + 'Some data', + '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318' +); + +// $ExpectType string +accounts.recover({ + messageHash: + '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655', + v: '0x1c', + r: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd', + s: '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029' +}); + +// $ExpectType string +accounts.recover( + 'Some data', + '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c' +); + +// $ExpectType string +accounts.recover( + 'Some data', + '0x1c', + '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd', + '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029' +); + +// $ExpectType EncryptedKeystoreV3Json +accounts.encrypt( + '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', + 'test!' +); + +// $ExpectType Account +accounts.decrypt( + { + version: 3, + id: '04e9bcbb-96fa-497b-94d1-14df4cd20af6', + address: '2c7536e3605d9c16a7a3d7b1898e529396a65c23', + crypto: { + ciphertext: + 'a1c25da3ecde4e6a24f3697251dd15d6208520efc84ad97397e906e6df24d251', + cipherparams: { iv: '2885df2b63f7ef247d753c82fa20038a' }, + cipher: 'aes-128-ctr', + kdf: 'scrypt', + kdfparams: { + dklen: 32, + salt: + '4531b3c174cc3ff32a6a7a85d6761b410db674807b2d216d022318ceee50be10', + n: 262144, + r: 8, + p: 1 + }, + mac: + 'b8b010fff37f9ae5559a352a185e86f9b9c1d7f7a9f1bd4e82a5dd35468fc7f6' + } + }, + 'test!' +); + +// $ExpectType WalletBase +accounts.wallet.create(2); + +// $ExpectType Account +accounts.wallet[0]; + +// $ExpectType WalletBase +accounts.wallet.create( + 2, + '54674321§3456764321§345674321§3453647544±±±§±±±!!!43534534534534' +); + +// $ExpectType AddedAccount +accounts.wallet.add( + '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318' +); + +// $ExpectType AddedAccount +accounts.wallet.add({ + privateKey: + '0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709', + address: '0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01' +}); + +// $ExpectType boolean +accounts.wallet.remove('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55'); + +// $ExpectType boolean +accounts.wallet.remove(3); + +// $ExpectType WalletBase +accounts.wallet.clear(); + +// $ExpectType EncryptedKeystoreV3Json[] +accounts.wallet.encrypt('test'); + +// $ExpectType WalletBase +accounts.wallet.decrypt( + [ + { + version: 3, + id: '83191a81-aaca-451f-b63d-0c5f3b849289', + address: '06f702337909c06c82b09b7a22f0a2f0855d1f68', + crypto: { + ciphertext: + '7d34deae112841fba86e3e6cf08f5398dda323a8e4d29332621534e2c4069e8d', + cipherparams: { iv: '497f4d26997a84d570778eae874b2333' }, + cipher: 'aes-128-ctr', + kdf: 'scrypt', + kdfparams: { + dklen: 32, + salt: + '208dd732a27aa4803bb760228dff18515d5313fd085bbce60594a3919ae2d88d', + n: 262144, + r: 8, + p: 1 + }, + mac: + '0062a853de302513c57bfe3108ab493733034bf3cb313326f42cf26ea2619cf9' + } + }, + { + version: 3, + id: '7d6b91fa-3611-407b-b16b-396efb28f97e', + address: 'b5d89661b59a9af0b34f58d19138baa2de48baaf', + crypto: { + ciphertext: + 'cb9712d1982ff89f571fa5dbef447f14b7e5f142232bd2a913aac833730eeb43', + cipherparams: { iv: '8cccb91cb84e435437f7282ec2ffd2db' }, + cipher: 'aes-128-ctr', + kdf: 'scrypt', + kdfparams: { + dklen: 32, + salt: + '08ba6736363c5586434cd5b895e6fe41ea7db4785bd9b901dedce77a1514e8b8', + n: 262144, + r: 8, + p: 1 + }, + mac: + 'd2eb068b37e2df55f56fa97a2bf4f55e072bef0dd703bfd917717d9dc54510f0' + } + } + ], + 'test' +); + +// $ExpectType boolean +accounts.wallet.save('test#!$'); + +// $ExpectType WalletBase +accounts.wallet.load('test#!$'); + +// $ExpectType WalletBase +accounts.wallet.load('test#!$', 'myWalletKey'); diff --git a/packages/web3-eth-accounts/types/tsconfig.json b/packages/web3-eth-accounts/types/tsconfig.json new file mode 100644 index 00000000000..8cc88bbb8cc --- /dev/null +++ b/packages/web3-eth-accounts/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-accounts": ["."] + } + } +} diff --git a/packages/web3-eth-accounts/types/tslint.json b/packages/web3-eth-accounts/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-eth-accounts/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-eth-contract/README.md b/packages/web3-eth-contract/README.md index f32b9a1ae60..11608a7d16b 100644 --- a/packages/web3-eth-contract/README.md +++ b/packages/web3-eth-contract/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth-contract.js` in your html file. This will expose the `Web3EthContract` object on the window object. - ## Usage ```js @@ -41,8 +40,12 @@ contract.methods.somFunc().send({from: ....}) }); ``` - [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js +## Types + +All the typescript typings are placed in the types folder. +[docs]: http://web3js.readthedocs.io/en/1.0/ +[repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3-eth-contract/package-lock.json b/packages/web3-eth-contract/package-lock.json index d8f894cdc17..caad0f00c6b 100644 --- a/packages/web3-eth-contract/package-lock.json +++ b/packages/web3-eth-contract/package-lock.json @@ -2,10 +2,362 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/bn.js": { + "version": "4.11.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz", + "integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==" + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-eth-contract/package.json b/packages/web3-eth-contract/package.json index 5ed08725eb7..5db279ea73e 100644 --- a/packages/web3-eth-contract/package.json +++ b/packages/web3-eth-contract/package.json @@ -7,8 +7,13 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { + "@types/bn.js": "^4.11.4", "underscore": "1.9.1", "web3-core": "1.2.1", "web3-core-helpers": "1.2.1", @@ -17,5 +22,9 @@ "web3-core-subscriptions": "1.2.1", "web3-eth-abi": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-contract/types/index.d.ts b/packages/web3-eth-contract/types/index.d.ts new file mode 100644 index 00000000000..4f5f90213a6 --- /dev/null +++ b/packages/web3-eth-contract/types/index.d.ts @@ -0,0 +1,150 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {PromiEvent, provider} from 'web3-core'; +import {AbiItem} from 'web3-utils'; + +export class Contract { + constructor( + provider: provider, + abi: AbiItem[], + address?: string, + options?: ContractOptions + ); + + private _address: string; + private _jsonInterface: AbiItem[]; + + options: Options; + + clone(): Contract; + + deploy(options: DeployOptions): ContractSendMethod; + + methods: any; + + once( + event: string, + callback: (error: Error, event: EventData) => void + ): void; + once( + event: string, + options: EventOptions, + callback: (error: Error, event: EventData) => void + ): void; + + events: any; + + getPastEvents(event: string): Promise; + getPastEvents( + event: string, + options: EventOptions, + callback: (error: Error, event: EventData) => void + ): Promise; + getPastEvents(event: string, options: EventOptions): Promise; + getPastEvents( + event: string, + callback: (error: Error, event: EventData) => void + ): Promise; +} + +export interface Options extends ContractOptions { + address: string; + jsonInterface: AbiItem[]; +} + +export interface DeployOptions { + data: string; + arguments?: any[]; +} + +export interface ContractSendMethod { + send( + options: SendOptions, + callback?: (err: Error, transactionHash: string) => void + ): PromiEvent; + + estimateGas( + options: EstimateGasOptions, + callback?: (err: Error, gas: number) => void + ): Promise; + + estimateGas(callback: (err: Error, gas: number) => void): Promise; + + estimateGas( + options: EstimateGasOptions, + callback: (err: Error, gas: number) => void + ): Promise; + + estimateGas(options: EstimateGasOptions): Promise; + + estimateGas(): Promise; + + encodeABI(): string; +} + +export interface SendOptions { + from: string; + gasPrice?: string; + gas?: number; + value?: number | string | BN; +} + +export interface EstimateGasOptions { + from?: string; + gas?: number; + value?: number | string | BN; +} + +export interface ContractOptions { + // Sender to use for contract calls + from?: string; + // Gas price to use for contract calls + gasPrice?: string; + // Gas to use for contract calls + gas?: number; + // Contract code + data?: string; +} + +export interface EventOptions { + filter?: any; + fromBlock?: number; + toBlock?: string | number; + topics?: any[]; +} + +export interface EventData { + returnValues: { + [key: string]: any; + }; + raw: { + data: string; + topics: string[]; + }; + event: string; + signature: string; + logIndex: number; + transactionIndex: number; + transactionHash: string; + blockHash: string; + blockNumber: number; + address: string; +} diff --git a/packages/web3-eth-contract/types/tests/contract-test.ts b/packages/web3-eth-contract/types/tests/contract-test.ts new file mode 100644 index 00000000000..51c2d22bdc5 --- /dev/null +++ b/packages/web3-eth-contract/types/tests/contract-test.ts @@ -0,0 +1,146 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file contract-tests.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import { Contract } from 'web3-eth-contract'; + +const contract = new Contract('http://localhost:500', []); + +// $ExpectType string +contract.options.address; + +// $ExpectType AbiItem[] +contract.options.jsonInterface; + +// $ExpectType string | undefined +contract.options.from; + +// $ExpectType number | undefined +contract.options.gas; + +// $ExpectType string | undefined +contract.options.gasPrice; + +// $ExpectType string | undefined +contract.options.data; + +// $ExpectType Contract +contract.clone(); + +// $ExpectType ContractSendMethod +contract.deploy({ + data: '0x12345...', + arguments: [123, 'My String'] +}); + +// $ExpectType void +contract.once( + 'MyEvent', + { + filter: { + myIndexedParam: [20, 23], + myOtherIndexedParam: '0x123456789...' + }, + fromBlock: 0 + }, + (error, event) => {} +); + +// $ExpectType void +contract.once('MyEvent', (error, event) => {}); + +// $ExpectType Promise +contract.getPastEvents('MyEvent'); + +// $ExpectType Promise +contract.getPastEvents('MyEvent', { + filter: { myIndexedParam: [20, 23], myOtherIndexedParam: '0x123456789...' }, + fromBlock: 0, + toBlock: 'latest' +}); + +// $ExpectType Promise +contract.getPastEvents('MyEvent', {}); + +// $ExpectType Promise +contract.getPastEvents( + 'MyEvent', + { + filter: { + myIndexedParam: [20, 23], + myOtherIndexedParam: '0x123456789...' + }, + fromBlock: 0, + toBlock: 'latest' + }, + (error, events) => {} +); + +// $ExpectType Promise +contract.getPastEvents('MyEvent', (error, events) => {}); + +// $ExpectType Promise +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .estimateGas(); + +// $ExpectType Promise +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .estimateGas({ from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe' }); + +// $ExpectType Promise +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .estimateGas((err: Error, gas: number) => {}); + +// $ExpectType string +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .encodeABI(); + +// $ExpectType PromiEvent +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .send({ from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe' }); + +// $ExpectType PromiEvent +contract + .deploy({ + data: '0x12345...', + arguments: [123, 'My String'] + }) + .send( + { from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe' }, + (err: Error, transactionHash: string) => {} + ); diff --git a/packages/web3-eth-contract/types/tsconfig.json b/packages/web3-eth-contract/types/tsconfig.json new file mode 100644 index 00000000000..906dd3fd159 --- /dev/null +++ b/packages/web3-eth-contract/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-contract": ["."] + } + } +} diff --git a/packages/web3-eth-contract/types/tslint.json b/packages/web3-eth-contract/types/tslint.json new file mode 100644 index 00000000000..30e95b7bca5 --- /dev/null +++ b/packages/web3-eth-contract/types/tslint.json @@ -0,0 +1,12 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "no-empty-interface": false, + "unified-signatures": false + } +} diff --git a/packages/web3-eth-ens/README.md b/packages/web3-eth-ens/README.md index cf4ab13fe75..e5801dc789c 100644 --- a/packages/web3-eth-ens/README.md +++ b/packages/web3-eth-ens/README.md @@ -27,17 +27,17 @@ This will expose the `EthEns` object on the window object. ## Usage ```js - var eth = new Web3Eth(web3.currentProvider); - var ens = new EthEns(eth); - - ens.getAddress('ethereum.eth').then(function (result) { - console.log(result); - }); +var eth = new Web3Eth(web3.currentProvider); +var ens = new EthEns(eth); + +ens.getAddress('ethereum.eth').then(function(result) { + console.log(result); +}); ``` +## Types +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-eth-ens/package-lock.json b/packages/web3-eth-ens/package-lock.json index f9bbe7d1488..8d54a9cb8f5 100644 --- a/packages/web3-eth-ens/package-lock.json +++ b/packages/web3-eth-ens/package-lock.json @@ -2,6 +2,148 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, "eth-ens-namehash": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", @@ -11,6 +153,44 @@ "js-sha3": "^0.5.7" } }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "idna-uts46-hx": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz", @@ -19,20 +199,179 @@ "punycode": "2.1.0" } }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, "js-sha3": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, "punycode": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=" }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-eth-ens/package.json b/packages/web3-eth-ens/package.json index f7404df6479..1f1dd8899bd 100644 --- a/packages/web3-eth-ens/package.json +++ b/packages/web3-eth-ens/package.json @@ -7,6 +7,10 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "eth-ens-namehash": "2.0.8", @@ -17,5 +21,9 @@ "web3-eth-abi": "1.2.1", "web3-eth-contract": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-ens/types/index.d.ts b/packages/web3-eth-ens/types/index.d.ts new file mode 100644 index 00000000000..02481f33400 --- /dev/null +++ b/packages/web3-eth-ens/types/index.d.ts @@ -0,0 +1,125 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Samuel Furter , Josh Stevens + * @date 2018 + */ + +import { PromiEvent, TransactionConfig } from 'web3-core'; +import { Contract } from 'web3-eth-contract'; + +export class Ens { + constructor(eth: any); + + registry: Registry; + + resolver(name: string): Promise; + + supportsInterface( + name: string, + interfaceId: string, + callback?: (error: Error, supportsInterface: boolean) => void + ): Promise; + + getAddress( + name: string, + callback?: (error: Error, address: string) => void + ): Promise; + + setAddress( + name: string, + address: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; + + getPubkey( + name: string, + callback?: (error: Error, result: { [x: string]: string }) => void + ): Promise<{ [x: string]: string }>; + + setPubkey( + name: string, + x: string, + y: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; + + getText( + name: string, + key: string, + callback?: (error: Error, ensName: string) => void + ): Promise; + + setText( + name: string, + key: string, + value: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; + + getContent( + name: string, + callback?: (error: Error, contentHash: string) => void + ): Promise; + + setContent( + name: string, + hash: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; + + getMultihash( + name: string, + callback?: (error: Error, multihash: string) => void + ): Promise; + + setMultihash( + name: string, + hash: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; + + getContenthash( + name: string, + callback?: (error: Error, contenthash: string) => void + ): Promise; + + setContenthash( + name: string, + hash: string, + sendOptions: TransactionConfig, + callback?: (error: Error, result: any) => void + ): PromiEvent; +} + +export class Registry { + constructor(ens: Ens); + + ens: Ens; + + contract: Contract | null; + + owner( + name: string, + callback?: (error: Error, address: string) => void + ): Promise; + + resolver(name: string): Promise; +} diff --git a/packages/web3-eth-ens/types/tests/ens-test.ts b/packages/web3-eth-ens/types/tests/ens-test.ts new file mode 100644 index 00000000000..7ee977658fa --- /dev/null +++ b/packages/web3-eth-ens/types/tests/ens-test.ts @@ -0,0 +1,97 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file ens-test.ts + * @author Samuel Furter , Josh Stevens + * @date 2018 + */ + +import { Ens } from 'web3-eth-ens'; + +const ens = new Ens('http://localhost:7545'); + +// $ExpectType Registry +ens.registry; + +// $ExpectType Promise +ens.resolver('name'); + +// $ExpectType Promise +ens.supportsInterface('name', 'interfaceId'); +// $ExpectType Promise +ens.supportsInterface( + 'name', + 'interfaceId', + (error: Error, supportsInterface: boolean) => {} +); + +// $ExpectType Promise +ens.getAddress('name'); +// $ExpectType Promise +ens.getAddress('name', (error: Error, address: string) => {}); + +// $ExpectType PromiEvent +ens.setAddress('name', 'address', {}); +// $ExpectType PromiEvent +ens.setAddress('name', 'address', {}, (error: Error, result: any) => {}); + +// $ExpectType Promise<{ [x: string]: string; }> +ens.getPubkey('name'); +// $ExpectType Promise<{ [x: string]: string; }> +ens.getPubkey('name', (error: Error, result: { [x: string]: string }) => {}); + +// $ExpectType PromiEvent +ens.setPubkey('name', 'x', 'y', {}); +// $ExpectType PromiEvent +ens.setPubkey('name', 'x', 'y', {}, (error: Error, result: any) => {}); + +// $ExpectType Promise +ens.getText('name', 'key'); +// $ExpectType Promise +ens.getText('name', 'key', (error: Error, ensName: string) => {}); + +// $ExpectType PromiEvent +ens.setText('name', 'key', 'value', {}); +// $ExpectType PromiEvent +ens.setText('name', 'key', 'value', {}, (error: Error, result: any) => {}); + +// $ExpectType Promise +ens.getContent('name'); +// $ExpectType Promise +ens.getContent('name', (error: Error, contentHash: string) => {}); + +// $ExpectType PromiEvent +ens.setContent('name', 'hash', {}); +// $ExpectType PromiEvent +ens.setContent('name', 'hash', {}, (error: Error, result: any) => {}); + +// $ExpectType Promise +ens.getMultihash('name'); +// $ExpectType Promise +ens.getMultihash('name', (error: Error, multihash: string) => {}); + +// $ExpectType PromiEvent +ens.setMultihash('name', 'hash', {}); +// $ExpectType PromiEvent +ens.setMultihash('name', 'hash', {}, (error: Error, result: any) => {}); + +// $ExpectType Promise +ens.getContenthash('name'); +// $ExpectType Promise +ens.getContenthash('name', (error: Error, contenthash: string) => {}); + +// $ExpectType PromiEvent +ens.setContenthash('name', 'hash', {}); +// $ExpectType PromiEvent +ens.setContenthash('name', 'hash', {}, (error: Error, result: any) => {}); diff --git a/packages/web3-eth-ens/types/tsconfig.json b/packages/web3-eth-ens/types/tsconfig.json new file mode 100644 index 00000000000..212c71253ba --- /dev/null +++ b/packages/web3-eth-ens/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-ens": ["."] + } + } +} diff --git a/packages/web3-eth-ens/types/tslint.json b/packages/web3-eth-ens/types/tslint.json new file mode 100644 index 00000000000..30e95b7bca5 --- /dev/null +++ b/packages/web3-eth-ens/types/tslint.json @@ -0,0 +1,12 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "no-empty-interface": false, + "unified-signatures": false + } +} diff --git a/packages/web3-eth-iban/README.md b/packages/web3-eth-iban/README.md index d287cfbf65c..922e72a7052 100644 --- a/packages/web3-eth-iban/README.md +++ b/packages/web3-eth-iban/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth-iban.js` in your html file. This will expose the `Web3EthIban` object on the window object. - ## Usage ```js @@ -32,12 +31,15 @@ This will expose the `Web3EthIban` object on the window object. var Web3EthIban = require('web3-eth-iban'); var iban = new Web3EthIban('XE75JRZCTTLBSYEQBGAS7GID8DKR7QY0QA3'); -iban.toAddress() -> '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B' +iban.toAddress() > '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B'; ``` - [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js +## Types + +All the typescript typings are placed in the types folder. +[docs]: http://web3js.readthedocs.io/en/1.0/ +[repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3-eth-iban/package-lock.json b/packages/web3-eth-iban/package-lock.json index 429bc93b4e5..cf6c13e3484 100644 --- a/packages/web3-eth-iban/package-lock.json +++ b/packages/web3-eth-iban/package-lock.json @@ -2,10 +2,349 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-eth-iban/package.json b/packages/web3-eth-iban/package.json index 9d6d6e1641f..40e61f1091b 100644 --- a/packages/web3-eth-iban/package.json +++ b/packages/web3-eth-iban/package.json @@ -7,9 +7,17 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "bn.js": "4.11.8", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-iban/types/index.d.ts b/packages/web3-eth-iban/types/index.d.ts new file mode 100644 index 00000000000..6890787f65a --- /dev/null +++ b/packages/web3-eth-iban/types/index.d.ts @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +export class Iban { + constructor( + iban: string + ) + + static toAddress(iban: string): string; + + static toIban(address: string): string; + + static fromAddress(address: string): Iban; + + static fromBban(bban: string): Iban; + + static createIndirect(options: IndirectOptions): Iban; + + static isValid(iban: string): boolean; + + isValid(): boolean; + + isDirect(): boolean; + + isIndirect(): boolean; + + checksum(): string; + + institution(): string; + + client(): string; + + toAddress(): string; + + toString(): string; +} + +export interface IndirectOptions { + institution: string; + identifier: string; +} diff --git a/packages/web3-eth-iban/types/tests/iban-tests.ts b/packages/web3-eth-iban/types/tests/iban-tests.ts new file mode 100644 index 00000000000..41c921d900b --- /dev/null +++ b/packages/web3-eth-iban/types/tests/iban-tests.ts @@ -0,0 +1,154 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file iban-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import { Iban, IndirectOptions } from 'web3-eth-iban'; + +const iban = 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS'; +const address = '0x45cd08334aeedd8a06265b2ae302e3597d8faa28'; + +// $ExpectType Iban +const ibanClass = new Iban(iban); + +// $ExpectType boolean +ibanClass.isDirect(); +// $ExpectType boolean +ibanClass.isIndirect(); +// $ExpectType string +ibanClass.checksum(); +// $ExpectType string +ibanClass.institution(); +// $ExpectType string +ibanClass.client(); +// $ExpectType string +ibanClass.toAddress(); +// $ExpectType string +Iban.toAddress(iban); + +// $ExpectError +Iban.toAddress(345); +// $ExpectError +Iban.toAddress({}); +// $ExpectError +Iban.toAddress(true); +// $ExpectError +Iban.toAddress(['string']); +// $ExpectError +Iban.toAddress([4]); +// $ExpectError +Iban.toAddress(null); +// $ExpectError +Iban.toAddress(undefined); + +// $ExpectType string +Iban.toIban(address); + +// $ExpectError +Iban.toIban(345); +// $ExpectError +Iban.toIban({}); +// $ExpectError +Iban.toIban(true); +// $ExpectError +Iban.toIban(['string']); +// $ExpectError +Iban.toIban([4]); +// $ExpectError +Iban.toIban(null); +// $ExpectError +Iban.toIban(undefined); + +// $ExpectType Iban +Iban.fromAddress(address); + +// $ExpectError +Iban.fromAddress(345); +// $ExpectError +Iban.fromAddress({}); +// $ExpectError +Iban.fromAddress(true); +// $ExpectError +Iban.fromAddress(['string']); +// $ExpectError +Iban.fromAddress([4]); +// $ExpectError +Iban.fromAddress(null); +// $ExpectError +Iban.fromAddress(undefined); + +// $ExpectType Iban +Iban.fromBban('ETHXREGGAVOFYORK'); + +// $ExpectError +Iban.fromBban(345); +// $ExpectError +Iban.fromBban({}); +// $ExpectError +Iban.fromBban(true); +// $ExpectError +Iban.fromBban(['string']); +// $ExpectError +Iban.fromBban([4]); +// $ExpectError +Iban.fromBban(null); +// $ExpectError +Iban.fromBban(undefined); + +const indirectOptions: IndirectOptions = { + institution: 'XREG', + identifier: 'GAVOFYORK' +}; + +// $ExpectType Iban +Iban.createIndirect(indirectOptions); + +// $ExpectError +Iban.createIndirect(345); +// $ExpectError +Iban.createIndirect('string'); +// $ExpectError +Iban.createIndirect(true); +// $ExpectError +Iban.createIndirect(['string']); +// $ExpectError +Iban.createIndirect([4]); +// $ExpectError +Iban.createIndirect(null); +// $ExpectError +Iban.createIndirect(undefined); + +// $ExpectType boolean +Iban.isValid(iban); + +// $ExpectError +Iban.isValid(345); +// $ExpectError +Iban.isValid({}); +// $ExpectError +Iban.isValid(true); +// $ExpectError +Iban.isValid(['string']); +// $ExpectError +Iban.isValid([4]); +// $ExpectError +Iban.isValid(null); +// $ExpectError +Iban.isValid(undefined); diff --git a/packages/web3-eth-iban/types/tsconfig.json b/packages/web3-eth-iban/types/tsconfig.json new file mode 100644 index 00000000000..306c438b694 --- /dev/null +++ b/packages/web3-eth-iban/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-iban": ["."] + } + } +} diff --git a/packages/web3-eth-iban/types/tslint.json b/packages/web3-eth-iban/types/tslint.json new file mode 100644 index 00000000000..dc95ea202b8 --- /dev/null +++ b/packages/web3-eth-iban/types/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false + } +} diff --git a/packages/web3-eth-personal/README.md b/packages/web3-eth-personal/README.md index f64f9688dbc..2576abe9b71 100644 --- a/packages/web3-eth-personal/README.md +++ b/packages/web3-eth-personal/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth-personal.js` in your html file. This will expose the `Web3EthPersonal` object on the window object. - ## Usage ```js @@ -34,8 +33,9 @@ var Web3EthPersonal = require('web3-eth-personal'); var personal = new Web3EthPersonal('ws://localhost:8546'); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-eth-personal/package-lock.json b/packages/web3-eth-personal/package-lock.json new file mode 100644 index 00000000000..07d69ca98ca --- /dev/null +++ b/packages/web3-eth-personal/package-lock.json @@ -0,0 +1,350 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/node": { + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==" + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/packages/web3-eth-personal/package.json b/packages/web3-eth-personal/package.json index cfe8716706a..42b4d0aaec6 100644 --- a/packages/web3-eth-personal/package.json +++ b/packages/web3-eth-personal/package.json @@ -7,12 +7,21 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { + "@types/node": "^12.6.1", "web3-core": "1.2.1", "web3-core-helpers": "1.2.1", "web3-core-method": "1.2.1", "web3-net": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts new file mode 100644 index 00000000000..5540e04053f --- /dev/null +++ b/packages/web3-eth-personal/types/index.d.ts @@ -0,0 +1,80 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Huan Zhang , + * @author Josh Stevens + * @date 2018 + */ + +import { provider, RLPEncodedTransaction, TransactionConfig } from 'web3-core'; + +export class Personal { + constructor(provider: provider); + + newAccount( + password: string, + callback?: (error: Error, address: string) => void + ): Promise; + + sign( + dataToSign: string, + address: string, + password: string, + callback?: (error: Error, signature: string) => void + ): Promise; + + ecRecover( + dataThatWasSigned: string, + signature: string, + callback?: (error: Error, address: string) => void + ): Promise; + + signTransaction( + transactionConfig: TransactionConfig, + password: string, + callback?: ( + error: Error, + RLPEncodedTransaction: RLPEncodedTransaction + ) => void + ): Promise; + + sendTransaction( + transactionConfig: TransactionConfig, + password: string, + callback?: (error: Error, transactionHash: string) => void + ): Promise; + + unlockAccount( + address: string, + password: string, + unlockDuration: number, + callback?: (error: Error) => void + ): Promise; + + lockAccount( + address: string, + callback?: (error: Error, success: boolean) => void + ): Promise; + + getAccounts( + callback?: (error: Error, accounts: string[]) => void + ): Promise; + + importRawKey( + privateKey: string, + password: string, + callback?: (error: Error, result: string) => void + ): Promise; +} diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts new file mode 100644 index 00000000000..2a46f856ea2 --- /dev/null +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -0,0 +1,136 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file personal-tests.ts + * @author Huan Zhang + * @author Samuel Furter + * @author Josh Stevens + * @date 2018 + */ + +import { RLPEncodedTransaction } from 'web3-core'; +import { Personal } from 'web3-eth-personal'; + +const personal = new Personal('http://localhost:7545'); + +// $ExpectType Promise +personal.newAccount('test password'); +// $ExpectType Promise +personal.newAccount('test password', (error: Error, address: string) => {}); + +// $ExpectType Promise +personal.sign( + 'Hello world', + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + 'test password!' +); +// $ExpectType Promise +personal.sign( + 'Hello world', + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + 'test password!', + (error: Error, signature: string) => {} +); + +// $ExpectType Promise +personal.ecRecover('Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa'); +// $ExpectType Promise +personal.ecRecover( + 'Hello world', + '0x30755ed65396facf86c53e6217c52b4daebe72aa', + (error: Error, address: string) => {} +); + +// $ExpectType Promise +personal.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password' +); +// $ExpectType Promise +personal.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password', + (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => {} +); + +// $ExpectType Promise +personal.sendTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password' +); + +// $ExpectType Promise +personal.sendTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password', + (error: Error, transactionHash: string) => {} +); + +// $ExpectType Promise +personal.unlockAccount( + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + 'test password!', + 600 +); +// $ExpectType Promise +personal.unlockAccount( + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + 'test password!', + 600, + (error: Error) => {} +); + +// $ExpectType Promise +personal.lockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); +// $ExpectType Promise +personal.lockAccount( + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + (error: Error, sucess: boolean) => {} +); + +// $ExpectType Promise +personal.getAccounts(); +// $ExpectType Promise +personal.getAccounts((error: Error, accounts: string[]) => {}); + +// $ExpectType Promise +personal.importRawKey('privateKey', 'blah2'); diff --git a/packages/web3-eth-personal/types/tsconfig.json b/packages/web3-eth-personal/types/tsconfig.json new file mode 100644 index 00000000000..8d56df7eb4f --- /dev/null +++ b/packages/web3-eth-personal/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth-personal": ["."] + } + } +} diff --git a/packages/web3-eth-personal/types/tslint.json b/packages/web3-eth-personal/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-eth-personal/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-eth/README.md b/packages/web3-eth/README.md index ac3ec3ff0f6..a62b62bdded 100644 --- a/packages/web3-eth/README.md +++ b/packages/web3-eth/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-eth.js` in your html file. This will expose the `Web3Eth` object on the window object. - ## Usage ```js @@ -34,8 +33,9 @@ var Web3Eth = require('web3-eth'); var eth = new Web3Eth('ws://localhost:8546'); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-eth/package-lock.json b/packages/web3-eth/package-lock.json index d8f894cdc17..0ad01e74290 100644 --- a/packages/web3-eth/package-lock.json +++ b/packages/web3-eth/package-lock.json @@ -2,10 +2,349 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-eth/package.json b/packages/web3-eth/package.json index 5c2f79bf40d..fbb28b74bd4 100644 --- a/packages/web3-eth/package.json +++ b/packages/web3-eth/package.json @@ -7,6 +7,10 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "underscore": "1.9.1", @@ -22,5 +26,9 @@ "web3-eth-personal": "1.2.1", "web3-net": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts new file mode 100644 index 00000000000..a15132dc9d4 --- /dev/null +++ b/packages/web3-eth/types/index.d.ts @@ -0,0 +1,402 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @author Samuel Furter + * @author Prince Sinha + * @date 2018 + */ + +import { + BatchRequest, + Extension, + Log, + PromiEvent, + provider, + Providers, + RLPEncodedTransaction, + Transaction, + TransactionConfig, + TransactionReceipt +} from 'web3-core'; +import { Subscription } from 'web3-core-subscriptions'; +import { AbiCoder } from 'web3-eth-abi'; +import { Accounts } from 'web3-eth-accounts'; +import { Contract, ContractOptions } from 'web3-eth-contract'; +import { Ens } from 'web3-eth-ens'; +import { Iban } from 'web3-eth-iban'; +import { Personal } from 'web3-eth-personal'; +import { Network } from 'web3-net'; +import { AbiItem } from 'web3-utils'; + +export class Eth { + constructor(currentProvider: provider); + + Contract: new ( + jsonInterface: AbiItem[] | AbiItem, + address?: string, + options?: ContractOptions + ) => Contract; + Iban: new (iban: string) => Iban; + personal: Personal; + accounts: Accounts; + ens: Ens; + abi: AbiCoder; + net: Network; + + readonly givenProvider: any; + defaultAccount: string | null; + defaultBlock: string | number; + readonly currentProvider: provider; + setProvider(provider: provider): boolean; + BatchRequest: new () => BatchRequest; + static readonly providers: Providers; + extend(extension: Extension): any; + + clearSubscriptions(callback: (error: Error, result: boolean) => void): void; + + subscribe( + type: 'logs', + options?: LogsOptions, + callback?: (error: Error, log: Log) => void + ): Subscription; + subscribe( + type: 'syncing', + options?: null, + callback?: (error: Error, result: Syncing) => void + ): Subscription; + subscribe( + type: 'newBlockHeaders', + options?: null, + callback?: (error: Error, blockHeader: BlockHeader) => void + ): Subscription; + subscribe( + type: 'pendingTransactions', + options?: null, + callback?: (error: Error, transactionHash: string) => void + ): Subscription; + subscribe( + type: 'pendingTransactions' | 'logs' | 'syncing' | 'newBlockHeaders', + options?: null | LogsOptions, + callback?: ( + error: Error, + item: Log | Syncing | BlockHeader | string + ) => void + ): Subscription; + + getProtocolVersion( + callback?: (error: Error, protocolVersion: string) => void + ): Promise; + + isSyncing( + callback?: (error: Error, syncing: Syncing) => void + ): Promise; + + getCoinbase( + callback?: (error: Error, coinbaseAddress: string) => void + ): Promise; + + isMining( + callback?: (error: Error, mining: boolean) => void + ): Promise; + + getHashrate( + callback?: (error: Error, hashes: number) => void + ): Promise; + + getNodeInfo( + callback?: (error: Error, version: string) => void + ): Promise; + + getChainId( + callback?: (error: Error, version: number) => void + ): Promise; + + getGasPrice( + callback?: (error: Error, gasPrice: string) => void + ): Promise; + + getAccounts( + callback?: (error: Error, accounts: string[]) => void + ): Promise; + + getBlockNumber( + callback?: (error: Error, blockNumber: number) => void + ): Promise; + + getBalance(address: string): Promise; + getBalance(address: string, defaultBlock: string | number): Promise; + getBalance( + address: string, + callback?: (error: Error, balance: string) => void + ): Promise; + getBalance( + address: string, + defaultBlock: string | number, + callback?: (error: Error, balance: string) => void + ): Promise; + + getStorageAt(address: string, position: number): Promise; + getStorageAt( + address: string, + position: number, + defaultBlock: number | string + ): Promise; + getStorageAt( + address: string, + position: number, + callback?: (error: Error, storageAt: string) => void + ): Promise; + getStorageAt( + address: string, + position: number, + defaultBlock: number | string, + callback?: (error: Error, storageAt: string) => void + ): Promise; + + getCode(address: string): Promise; + getCode(address: string, defaultBlock: string | number): Promise; + getCode( + address: string, + callback?: (error: Error, code: string) => void + ): Promise; + getCode( + address: string, + defaultBlock: string | number, + callback?: (error: Error, code: string) => void + ): Promise; + + getBlock(blockHashOrBlockNumber: string | number): Promise; + getBlock( + blockHashOrBlockNumber: string | number, + returnTransactionObjects: boolean + ): Promise; + getBlock( + blockHashOrBlockNumber: string | number, + callback?: (error: Error, block: Block) => void + ): Promise; + getBlock( + blockHashOrBlockNumber: string | number, + returnTransactionObjects: boolean, + callback?: (error: Error, block: Block) => void + ): Promise; + + getBlockTransactionCount( + blockHashOrBlockNumber: string | number, + callback?: (error: Error, numberOfTransactions: number) => void + ): Promise; + + getUncle( + blockHashOrBlockNumber: string | number, + uncleIndex: number + ): Promise; + getUncle( + blockHashOrBlockNumber: string | number, + uncleIndex: number, + returnTransactionObjects: boolean + ): Promise; + getUncle( + blockHashOrBlockNumber: string | number, + uncleIndex: number, + callback?: (error: Error, uncle: any) => void + ): Promise; + getUncle( + blockHashOrBlockNumber: string | number, + uncleIndex: number, + returnTransactionObjects: boolean, + callback?: (error: Error, uncle: any) => void + ): Promise; + + getTransaction( + transactionHash: string, + callback?: (error: Error, transaction: Transaction) => void + ): Promise; + + getPendingTransactions( + callback?: (error: Error, result: Transaction[]) => void + ): Promise; + + getTransactionFromBlock( + hashStringOrNumber: string | number, + indexNumber: number, + callback?: (error: Error, transaction: Transaction) => void + ): Promise; + + getTransactionReceipt( + hash: string, + callback?: ( + error: Error, + transactionReceipt: TransactionReceipt + ) => void + ): Promise; + + getTransactionCount(address: string): Promise; + getTransactionCount( + address: string, + defaultBlock: number | string + ): Promise; + getTransactionCount( + address: string, + callback?: (error: Error, count: number) => void + ): Promise; + getTransactionCount( + address: string, + defaultBlock: number | string, + callback?: (error: Error, count: number) => void + ): Promise; + + sendTransaction( + transactionConfig: TransactionConfig, + callback?: (error: Error, hash: string) => void + ): PromiEvent; + + sendSignedTransaction( + signedTransactionData: string, + callback?: (error: Error, hash: string) => void + ): PromiEvent; + + sign( + dataToSign: string, + address: string | number, + callback?: (error: Error, signature: string) => void + ): Promise; + + signTransaction( + transactionConfig: TransactionConfig, + callback?: ( + error: Error, + signedTransaction: RLPEncodedTransaction + ) => void + ): Promise; + signTransaction( + transactionConfig: TransactionConfig, + address: string + ): Promise; + signTransaction( + transactionConfig: TransactionConfig, + address: string, + callback: ( + error: Error, + signedTransaction: RLPEncodedTransaction + ) => void + ): Promise; + + call(transactionConfig: TransactionConfig): Promise; + call( + transactionConfig: TransactionConfig, + defaultBlock?: number | string + ): Promise; + call( + transactionConfig: TransactionConfig, + callback?: (error: Error, data: string) => void + ): Promise; + call( + transactionConfig: TransactionConfig, + defaultBlock: number | string, + callback: (error: Error, data: string) => void + ): Promise; + + estimateGas( + transactionConfig: TransactionConfig, + callback?: (error: Error, gas: number) => void + ): Promise; + + getPastLogs( + options: PastLogsOptions, + callback?: (error: Error, logs: Log[]) => void + ): Promise; + + getWork( + callback?: (error: Error, result: string[]) => void + ): Promise; + + submitWork( + data: [string, string, string], + callback?: (error: Error, result: boolean) => void + ): Promise; + + getProof( + address: string, + storageKey: string[], + blockNumber: number | string | 'latest' | 'earliest', + callback?: (error: Error, result: GetProof) => void + ): Promise; +} + +export interface Syncing { + StartingBlock: number; + CurrentBlock: number; + HighestBlock: number; + KnownStates: number; + PulledStates: number; +} + +export interface BlockHeader { + number: number; + hash: string; + parentHash: string; + nonce: string; + sha3Uncles: string; + logsBloom: string; + transactionRoot: string; + stateRoot: string; + receiptRoot: string; + miner: string; + extraData: string; + gasLimit: number; + gasUsed: number; + timestamp: number | string; +} + +export interface Block extends BlockHeader { + transactions: Transaction[] | string[]; + size: number; + difficulty: number; + totalDifficulty: number; + uncles: string[]; +} + +export interface PastLogsOptions { + fromBlock?: number | string; + toBlock?: number | string; + address?: string | string[]; + topics?: Array; +} + +export interface LogsOptions { + fromBlock?: number | string; + address?: string | string[]; + topics?: Array; +} + +export interface GetProof { + jsonrpc: string; + id: number; + result: { + address: string; + accountProof: string[]; + balance: string; + codeHash: string; + nonce: string; + storageHash: string; + storageProof: StorageProof[]; + }; +} + +export interface StorageProof { + key: string; + value: string; + proof: string[]; +} diff --git a/packages/web3-eth/types/tests/eth.tests.ts b/packages/web3-eth/types/tests/eth.tests.ts new file mode 100644 index 00000000000..d06c388c996 --- /dev/null +++ b/packages/web3-eth/types/tests/eth.tests.ts @@ -0,0 +1,619 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file eth-tests.ts + * @author Josh Stevens + * @author Prince Sinha + * @date 2018 + */ + +import { + Log, + RLPEncodedTransaction, + Transaction, + TransactionReceipt +} from 'web3-core'; +import { Block, BlockHeader, Eth, GetProof, Syncing } from 'web3-eth'; + +const eth = new Eth('http://localhost:8545'); + +// $ExpectType new (jsonInterface: AbiItem | AbiItem[], address?: string | undefined, options?: ContractOptions | undefined) => Contract +eth.Contract; + +// $ExpectType new (iban: string) => Iban +eth.Iban; + +// $ExpectType Personal +eth.personal; + +// $ExpectType Accounts +eth.accounts; + +// $ExpectType any +eth.extend({property: 'test', methods: [{name: 'method', call: 'method'}]}); + +// $ExpectType Ens +eth.ens; + +// $ExpectType AbiCoder +eth.abi; + +// $ExpectType Network +eth.net; + +// $ExpectType void +eth.clearSubscriptions(() => {}); + +// $ExpectType Subscription +eth.subscribe('logs'); + +// $ExpectType Subscription +eth.subscribe('logs', {}); +// $ExpectType Subscription +eth.subscribe('logs', {}, (error: Error, log: Log) => {}); + +// $ExpectType Subscription +eth.subscribe('syncing'); +// $ExpectType Subscription +eth.subscribe('syncing', null, (error: Error, result: Syncing) => {}); + +// $ExpectType Subscription +eth.subscribe('newBlockHeaders'); +// $ExpectType Subscription +eth.subscribe( + 'newBlockHeaders', + null, + (error: Error, blockHeader: BlockHeader) => {} +); + +// $ExpectType Subscription +eth.subscribe('pendingTransactions'); +// $ExpectType Subscription +eth.subscribe( + 'pendingTransactions', + null, + (error: Error, transactionHash: string) => {} +); + +// $ExpectType provider +eth.currentProvider; + +// $ExpectType any +eth.givenProvider; + +// $ExpectType string | null +eth.defaultAccount; + +// $ExpectType string | number +eth.defaultBlock; + +// $ExpectType boolean +eth.setProvider('https://localhost:2100'); + +// $ExpectType BatchRequest +new eth.BatchRequest(); + +// $ExpectType Promise +eth.getProtocolVersion(); +// $ExpectType Promise +eth.getProtocolVersion((error: Error, protocolVersion: string) => {}); + +// $ExpectType Promise +eth.isSyncing(); +// $ExpectType Promise +eth.isSyncing((error: Error, syncing: Syncing) => {}); + +// $ExpectType Promise +eth.getCoinbase(); +// $ExpectType Promise +eth.getCoinbase((error: Error, coinbaseAddress: string) => {}); + +// $ExpectType Promise +eth.isMining(); +// $ExpectType Promise +eth.isMining((error: Error, mining: boolean) => {}); + +// $ExpectType Promise +eth.getHashrate(); +// $ExpectType Promise +eth.getHashrate((error: Error, hashes: number) => {}); + +// $ExpectType Promise +eth.getNodeInfo(); +// $ExpectType Promise +eth.getNodeInfo((error: Error, version: string) => {}); + +// $ExpectType Promise +eth.getChainId(); +// $ExpectType Promise +eth.getChainId((error: Error, chainId: number) => {}); + +// $ExpectType Promise +eth.getGasPrice(); +// $ExpectType Promise +eth.getGasPrice((error: Error, gasPrice: string) => {}); + +// $ExpectType Promise +eth.getAccounts(); +// $ExpectType Promise +eth.getAccounts((error: Error, accounts: string[]) => {}); + +// $ExpectType Promise +eth.getBlockNumber(); +// $ExpectType Promise +eth.getBlockNumber((error: Error, blockNumber: number) => {}); + +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getBalance( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + '1000', + (error: Error, balance: string) => {} +); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getBalance( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 1000, + (error: Error, balance: string) => {} +); + +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, '1000'); +// $ExpectType Promise +eth.getStorageAt( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 2, + '1000', + (error: Error, balance: string) => {} +); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, 1000); +// $ExpectType Promise +eth.getStorageAt( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 2, + 1000, + (error: Error, balance: string) => {} +); + +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getCode( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + '1000', + (error: Error, balance: string) => {} +); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getCode( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 1000, + (error: Error, balance: string) => {} +); + +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getBlock(345); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', true); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', false); +// $ExpectType Promise +eth.getBlock(345); +// $ExpectType Promise +eth.getBlock(345, true); +// $ExpectType Promise +eth.getBlock(345, false); +// $ExpectType Promise +eth.getBlock( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, block: Block) => {} +); +// $ExpectType Promise +eth.getBlock(345, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock(345, true, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock(345, false, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + true, + (error: Error, block: Block) => {} +); +// $ExpectType Promise +eth.getBlock( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + false, + (error: Error, block: Block) => {} +); + +// $ExpectType Promise +eth.getBlockTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, numberOfTransactions: number) => {} +); +// $ExpectType Promise +eth.getBlockTransactionCount(345); +// $ExpectType Promise +eth.getBlockTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, numberOfTransactions: number) => {} +); +// $ExpectType Promise +eth.getBlockTransactionCount(345); + +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4); +// $ExpectType Promise +eth.getUncle(345, 4); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, true); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, false); +// $ExpectType Promise +eth.getUncle( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 4, + (error: Error, uncle: {}) => {} +); +// $ExpectType Promise +eth.getUncle(345, 4, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, true); +// $ExpectType Promise +eth.getUncle(345, 4, false); +// $ExpectType Promise +eth.getUncle( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 4, + true, + (error: Error, uncle: {}) => {} +); +// $ExpectType Promise +eth.getUncle( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 4, + false, + (error: Error, uncle: {}) => {} +); +// $ExpectType Promise +eth.getUncle(345, 4, true, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, false, (error: Error, uncle: {}) => {}); + +// $ExpectType Promise +eth.getTransaction('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransaction( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, transaction: Transaction) => {} +); + +// $ExpectType Promise +eth.getTransactionFromBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2); +// $ExpectType Promise +eth.getTransactionFromBlock(345, 2); +// $ExpectType Promise +eth.getTransactionFromBlock( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 2, + (error: Error, transaction: Transaction) => {} +); +// $ExpectType Promise +eth.getTransactionFromBlock( + 345, + 2, + (error: Error, transaction: Transaction) => {} +); + +// $ExpectType Promise +eth.getTransactionReceipt('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransactionReceipt( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, transactionReceipt: TransactionReceipt) => {} +); + +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, count: number) => {} +); +// $ExpectType Promise +eth.getTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + (error: Error, count: number) => {} +); +// $ExpectType Promise +eth.getTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + 1000, + (error: Error, count: number) => {} +); +// $ExpectType Promise +eth.getTransactionCount( + '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + '1000', + (error: Error, count: number) => {} +); + +const code = '603d80600c6000396000f3007c0'; + +// $ExpectType PromiEvent +eth.sendTransaction({ + from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', + data: 'code' +}); +// $ExpectType PromiEvent +eth.sendTransaction( + { + from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', + data: 'code' + }, + (error: Error, hash: string) => {} +); + +// $ExpectType PromiEvent +eth.sendSignedTransaction('0xf889808609184e72a0008227109'); +// $ExpectType PromiEvent +eth.sendSignedTransaction( + '0xf889808609184e72a0008227109', + (error: Error, hash: string) => {} +); + +// $ExpectType Promise +eth.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); +// $ExpectType Promise +eth.sign('Hello world', 3); +// $ExpectType Promise +eth.sign( + 'Hello world', + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + (error: Error, signature: string) => {} +); +// $ExpectType Promise +eth.sign('Hello world', 3, (error: Error, signature: string) => {}); + +// $ExpectType Promise +eth.signTransaction({ + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' +}); +// $ExpectType Promise +eth.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0' +); +// $ExpectType Promise +eth.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + (error: Error, signedTransaction: RLPEncodedTransaction) => {} +); +// $ExpectType Promise +eth.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + (error: Error, signedTransaction: RLPEncodedTransaction) => {} +); + +// $ExpectType Promise +eth.call({ + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' +}); +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + 100 +); +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + '100' +); +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + (error: Error, data: string) => {} +); +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + '100', + (error: Error, data: string) => {} +); +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + 100, + (error: Error, data: string) => {} +); + +// $ExpectType Promise +eth.call( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // contract address + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + 100, + (error: Error, data: string) => {} +); + +// $ExpectType Promise +eth.estimateGas({ + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' +}); +// $ExpectType Promise +eth.estimateGas( + { + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: + '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' + }, + (error: Error, gas: number) => {} +); + +// $ExpectType Promise +eth.getPastLogs({ + address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + topics: ['0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234'] +}); +// $ExpectType Promise +eth.getPastLogs( + { + address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + topics: [ + '0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234' + ] + }, + (error: Error, logs: Log[]) => {} +); + +// $ExpectType Promise +eth.getWork(); +// $ExpectType Promise +eth.getWork((error: Error, result: string[]) => {}); + +// $ExpectType Promise +eth.submitWork([ + '0x0000000000000001', + '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', + '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000' +]); + +// $ExpectType Promise +eth.submitWork( + [ + '0x0000000000000001', + '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', + '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000' + ], + (error: Error, result: boolean) => {} +); + +// $ExpectType Promise +eth.getPendingTransactions(); + +// $ExpectType Promise +eth.getPendingTransactions((error: Error, result: Transaction[]) => {}); + +// $ExpectType Promise +eth.getProof( + '0x1234567890123456789012345678901234567890', + [ + '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + 'latest' +); + +// $ExpectType Promise +eth.getProof( + '0x1234567890123456789012345678901234567890', + [ + '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + 'latest', + (error: Error, result: GetProof) => {} +); + +// $ExpectType Promise +eth.getProof( + '0x1234567890123456789012345678901234567890', + [ + '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + 10 +); + +// $ExpectType Promise +eth.getProof( + '0x1234567890123456789012345678901234567890', + [ + '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + 10, + (error: Error, result: GetProof) => {} +); diff --git a/packages/web3-eth/types/tsconfig.json b/packages/web3-eth/types/tsconfig.json new file mode 100644 index 00000000000..e9ea79fb47a --- /dev/null +++ b/packages/web3-eth/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-eth": ["."] + } + } +} diff --git a/packages/web3-eth/types/tslint.json b/packages/web3-eth/types/tslint.json new file mode 100644 index 00000000000..871d605704b --- /dev/null +++ b/packages/web3-eth/types/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false + } +} diff --git a/packages/web3-net/README.md b/packages/web3-net/README.md index a8160c25b2f..82c3726ddde 100644 --- a/packages/web3-net/README.md +++ b/packages/web3-net/README.md @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-net.js` in your html file. This will expose the `Web3Net` object on the window object. - ## Usage ```js @@ -34,8 +33,9 @@ var Web3Net = require('web3-net'); var net = new Web3Net('ws://localhost:8546'); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-net/package-lock.json b/packages/web3-net/package-lock.json new file mode 100644 index 00000000000..99220917d66 --- /dev/null +++ b/packages/web3-net/package-lock.json @@ -0,0 +1,345 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/packages/web3-net/package.json b/packages/web3-net/package.json index a6512e7025f..7649d6609f5 100644 --- a/packages/web3-net/package.json +++ b/packages/web3-net/package.json @@ -7,10 +7,18 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "web3-core": "1.2.1", "web3-core-method": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-net/types/index.d.ts b/packages/web3-net/types/index.d.ts new file mode 100644 index 00000000000..0ebdd612c06 --- /dev/null +++ b/packages/web3-net/types/index.d.ts @@ -0,0 +1,22 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import { NetworkBase } from 'web3-core'; + +export class Network extends NetworkBase {} diff --git a/packages/web3-net/types/tests/network-test.ts b/packages/web3-net/types/tests/network-test.ts new file mode 100644 index 00000000000..c745516c825 --- /dev/null +++ b/packages/web3-net/types/tests/network-test.ts @@ -0,0 +1,63 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file network-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import { Network } from 'web3-net'; + +const network = new Network('http://localhost:5000'); + +// $ExpectType provider +network.currentProvider; + +// $ExpectType any +network.givenProvider; + +// $ExpectType boolean +network.setProvider('https://localhost:2100'); + +// $ExpectType BatchRequest +new network.BatchRequest(); + +// $ExpectType any +network.extend({property: 'test', methods: [{name: 'method', call: 'method'}]}); + +// $ExpectType Promise +network.getNetworkType((error, returnValue) => { + console.log(returnValue); +}); + +// $ExpectType Promise +network.getId(); +// $ExpectType Promise +network.getId((error: Error, id: number) => { + console.log(id); +}); + +// $ExpectType Promise +network.isListening(); +// $ExpectType Promise +network.isListening((error: Error, listening: boolean) => { + console.log(listening); +}); + +// $ExpectType Promise +network.getPeerCount(); +// $ExpectType Promise +network.getPeerCount((error: Error, peerCount: number) => { + console.log(peerCount); +}); diff --git a/packages/web3-net/types/tsconfig.json b/packages/web3-net/types/tsconfig.json new file mode 100644 index 00000000000..1c940eabc19 --- /dev/null +++ b/packages/web3-net/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-net": ["."] + } + } +} diff --git a/packages/web3-net/types/tslint.json b/packages/web3-net/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-net/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-providers-http/README.md b/packages/web3-providers-http/README.md index ac46853390c..5c9a0a52087 100644 --- a/packages/web3-providers-http/README.md +++ b/packages/web3-providers-http/README.md @@ -1,8 +1,8 @@ # web3-providers-http -*This is a sub package of [web3.js][repo]* +_This is a sub package of [web3.js][repo]_ -This is a HTTP provider for [web3.js][repo]. +This is a HTTP provider for [web3.js][repo]. Please read the [documentation][docs] for more. ## Installation @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-providers-http.js` in your html file. This will expose the `Web3HttpProvider` object on the window object. - ## Usage ```js @@ -38,8 +37,9 @@ var options = { var http = new Web3HttpProvider('http://localhost:8545', options); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-providers-http/package-lock.json b/packages/web3-providers-http/package-lock.json index 598587c4f91..bdcd609f4fc 100644 --- a/packages/web3-providers-http/package-lock.json +++ b/packages/web3-providers-http/package-lock.json @@ -2,11 +2,350 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, "cookiejar": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "xhr2-cookies": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz", diff --git a/packages/web3-providers-http/package.json b/packages/web3-providers-http/package.json index 5d6542f0c95..825a53e07f1 100644 --- a/packages/web3-providers-http/package.json +++ b/packages/web3-providers-http/package.json @@ -7,9 +7,17 @@ "engines": { "node": ">=8.0.0" }, + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, + "types": "types/index.d.ts", "main": "src/index.js", "dependencies": { "web3-core-helpers": "1.2.1", "xhr2-cookies": "1.1.0" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-providers-http/types/index.d.ts b/packages/web3-providers-http/types/index.d.ts new file mode 100644 index 00000000000..ee2004771db --- /dev/null +++ b/packages/web3-providers-http/types/index.d.ts @@ -0,0 +1,43 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import { + HttpProviderBase, + HttpProviderOptions, + JsonRpcPayload +} from 'web3-core-helpers'; + +export class HttpProvider extends HttpProviderBase { + constructor(host: string, options?: HttpProviderOptions); + + host: string; + connected: boolean; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + disconnect(): boolean; +} diff --git a/packages/web3-providers-http/types/tests/web3-provider-http-tests.ts b/packages/web3-providers-http/types/tests/web3-provider-http-tests.ts new file mode 100644 index 00000000000..853c75c20a4 --- /dev/null +++ b/packages/web3-providers-http/types/tests/web3-provider-http-tests.ts @@ -0,0 +1,40 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file web3-provider-http-tests.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import { HttpProvider } from 'web3-providers'; + +const httpProvider = new HttpProvider('http://localhost:8545', { + timeout: 20000, + headers: [ + { + name: 'Access-Control-Allow-Origin', + value: '*' + } + ], + withCredentials: false +}); + +// $ExpectType void +httpProvider.send({} as any, () => {}); + +// $ExpectType boolean +httpProvider.disconnect(); diff --git a/packages/web3-providers-http/types/tsconfig.json b/packages/web3-providers-http/types/tsconfig.json new file mode 100644 index 00000000000..74e0aeeb3a8 --- /dev/null +++ b/packages/web3-providers-http/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-providers": ["."] + } + } +} diff --git a/packages/web3-providers-http/types/tslint.json b/packages/web3-providers-http/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-providers-http/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-providers-ipc/README.md b/packages/web3-providers-ipc/README.md index 03a329ea00c..3ddce3577d4 100644 --- a/packages/web3-providers-ipc/README.md +++ b/packages/web3-providers-ipc/README.md @@ -2,7 +2,7 @@ This is a sub package of [web3.js][repo] -This is a IPC provider for [web3.js][repo]. +This is a IPC provider for [web3.js][repo]. Please read the [documentation][docs] for more. ## Installation @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-providers-ipc.js` in your html file. This will expose the `Web3IpcProvider` object on the window object. - ## Usage ```js @@ -35,8 +34,9 @@ var net = require(net); var ipc = new Web3IpcProvider('/Users/me/Library/Ethereum/geth.ipc', net); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-providers-ipc/package-lock.json b/packages/web3-providers-ipc/package-lock.json index e62ca0fdaca..b7d798d8708 100644 --- a/packages/web3-providers-ipc/package-lock.json +++ b/packages/web3-providers-ipc/package-lock.json @@ -1,12 +1,284 @@ { - "requires": true, + "name": "web3-providers-ipc", + "version": "1.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==", + "dev": true + }, + "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" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "dev": true, + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191016" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, "http-https": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz", "integrity": "sha1-L5CN1fHbQGjAWM1ubUzjkskTOJs=" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "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" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, "oboe": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.4.tgz", @@ -15,10 +287,127 @@ "http-https": "^1.0.0" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191016", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191016.tgz", + "integrity": "sha512-4CUiTF5rEtPaClGD9nWpqPMICdDc54PTyrzwqpivz/h7mkWJs/xhQhOddiA5vx+D8ob9eSRIdueXQkI2oxOmfg==", + "dev": true + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true } } } diff --git a/packages/web3-providers-ipc/package.json b/packages/web3-providers-ipc/package.json index 2eeed919d53..f0338bf0e1a 100644 --- a/packages/web3-providers-ipc/package.json +++ b/packages/web3-providers-ipc/package.json @@ -7,10 +7,18 @@ "engines": { "node": ">=8.0.0" }, + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, + "types": "types/index.d.ts", "main": "src/index.js", "dependencies": { "oboe": "2.1.4", "underscore": "1.9.1", "web3-core-helpers": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-providers-ipc/types/index.d.ts b/packages/web3-providers-ipc/types/index.d.ts new file mode 100644 index 00000000000..3e61857afdc --- /dev/null +++ b/packages/web3-providers-ipc/types/index.d.ts @@ -0,0 +1,54 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import * as net from 'net'; +import { IpcProviderBase, JsonRpcPayload } from 'web3-core-helpers'; + +export class IpcProvider extends IpcProviderBase { + constructor(path: string, net: net.Server); + + responseCallbacks: any; + notificationCallbacks: any; + connected: boolean; + connection: any; + + addDefaultEvents(): void; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + on(type: string, callback: () => void): void; + + once(type: string, callback: () => void): void; + + removeListener(type: string, callback: () => void): void; + + removeAllListeners(type: string): void; + + reset(): void; + + reconnect(): void; +} diff --git a/packages/web3-providers-ipc/types/tests/web3-provider-ipc-tests.ts b/packages/web3-providers-ipc/types/tests/web3-provider-ipc-tests.ts new file mode 100644 index 00000000000..6174533c0f1 --- /dev/null +++ b/packages/web3-providers-ipc/types/tests/web3-provider-ipc-tests.ts @@ -0,0 +1,68 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file web3-provider-ipc-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import * as net from 'net'; +import { IpcProvider } from 'web3-providers'; + +const ipcProvider = new IpcProvider( + '/Users/myuser/Library/Ethereum/geth.ipc', + new net.Server() +); + +// $ExpectType any +ipcProvider.responseCallbacks; + +// $ExpectType any +ipcProvider.notificationCallbacks; + +// $ExpectType any +ipcProvider.connection; + +// $ExpectType boolean +ipcProvider.connected; + +// $ExpectType void +ipcProvider.addDefaultEvents(); + +// $ExpectType boolean +ipcProvider.supportsSubscriptions(); + +// $ExpectType void +ipcProvider.send({} as any, () => {}); + +// $ExpectType void +ipcProvider.on('type', () => {}); + +// $ExpectType void +ipcProvider.once('type', () => {}); + +// $ExpectType void +ipcProvider.removeListener('type', () => {}); + +// $ExpectType void +ipcProvider.removeAllListeners('type'); + +// $ExpectType void +ipcProvider.reset(); + +// $ExpectType void +ipcProvider.reconnect(); diff --git a/packages/web3-providers-ipc/types/tsconfig.json b/packages/web3-providers-ipc/types/tsconfig.json new file mode 100644 index 00000000000..74e0aeeb3a8 --- /dev/null +++ b/packages/web3-providers-ipc/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-providers": ["."] + } + } +} diff --git a/packages/web3-providers-ipc/types/tslint.json b/packages/web3-providers-ipc/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-providers-ipc/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-providers-ws/README.md b/packages/web3-providers-ws/README.md index 72553c48e17..4be274764be 100644 --- a/packages/web3-providers-ws/README.md +++ b/packages/web3-providers-ws/README.md @@ -2,7 +2,7 @@ This is a sub package of [web3.js][repo] -This is a websocket provider for [web3.js][repo]. +This is a websocket provider for [web3.js][repo]. Please read the [documentation][docs] for more. ## Installation @@ -24,17 +24,22 @@ npm run-script build-all Then include `dist/web3-providers-ws.js` in your html file. This will expose the `Web3WsProvider` object on the window object. - ## Usage ```js // in node.js var Web3WsProvider = require('web3-providers-ws'); -var options = { timeout: 30000, headers: {authorization: 'Basic username:password'} } // set a custom timeout at 30 seconds, and credentials (you can also add the credentials to the URL: ws://username:password@localhost:8546) +var options = { + timeout: 30000, + headers: { authorization: 'Basic username:password' } +}; // set a custom timeout at 30 seconds, and credentials (you can also add the credentials to the URL: ws://username:password@localhost:8546) var ws = new Web3WsProvider('ws://localhost:8546', options); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3-providers-ws/package-lock.json b/packages/web3-providers-ws/package-lock.json index a1777555880..50932f5ffa7 100644 --- a/packages/web3-providers-ws/package-lock.json +++ b/packages/web3-providers-ws/package-lock.json @@ -1,7 +1,113 @@ { - "requires": true, + "name": "web3-providers-ws", + "version": "1.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==", + "dev": true + }, + "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" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, "d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -19,6 +125,46 @@ "ms": "2.0.0" } }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "dev": true, + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191016" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, "es5-ext": { "version": "0.10.50", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.50.tgz", @@ -48,11 +194,137 @@ "es5-ext": "~0.10.14" } }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "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" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -68,6 +340,105 @@ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "type": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz", @@ -81,11 +452,23 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "3.7.0-dev.20191016", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191016.tgz", + "integrity": "sha512-4CUiTF5rEtPaClGD9nWpqPMICdDc54PTyrzwqpivz/h7mkWJs/xhQhOddiA5vx+D8ob9eSRIdueXQkI2oxOmfg==", + "dev": true + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "websocket": { "version": "github:web3-js/WebSocket-Node#b134a75541b5db59668df81c03e926cd5f325077", "from": "github:web3-js/WebSocket-Node#polyfill/globalThis", @@ -97,6 +480,12 @@ "yaeti": "^0.0.6" } }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, "yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", diff --git a/packages/web3-providers-ws/package.json b/packages/web3-providers-ws/package.json index f760aad1eb4..3ad67bca94e 100644 --- a/packages/web3-providers-ws/package.json +++ b/packages/web3-providers-ws/package.json @@ -1,16 +1,24 @@ { - "name": "web3-providers-ws", - "version": "1.2.1", - "description": "Module to handle web3 RPC connections over WebSockets.", - "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws", - "license": "LGPL-3.0", - "engines": { - "node": ">=8.0.0" - }, - "main": "src/index.js", - "dependencies": { - "underscore": "1.9.1", - "web3-core-helpers": "1.2.1", - "websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" - } + "name": "web3-providers-ws", + "version": "1.2.1", + "description": "Module to handle web3 RPC connections over WebSockets.", + "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws", + "license": "LGPL-3.0", + "engines": { + "node": ">=8.0.0" + }, + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, + "types": "types/index.d.ts", + "main": "src/index.js", + "dependencies": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.1", + "websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" + } } diff --git a/packages/web3-providers-ws/types/index.d.ts b/packages/web3-providers-ws/types/index.d.ts new file mode 100644 index 00000000000..0e817a886de --- /dev/null +++ b/packages/web3-providers-ws/types/index.d.ts @@ -0,0 +1,59 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import { + JsonRpcPayload, + WebsocketProviderBase, + WebsocketProviderOptions +} from 'web3-core-helpers'; + +export class WebsocketProvider extends WebsocketProviderBase { + constructor(host: string, options?: WebsocketProviderOptions); + + isConnecting(): boolean; + + responseCallbacks: any; + notificationCallbacks: any; + connected: boolean; + connection: any; + + addDefaultEvents(): void; + + supportsSubscriptions(): boolean; + + send( + payload: JsonRpcPayload, + callback: (error: Error, result: any) => void + ): void; + + on(type: string, callback: () => void): void; + + once(type: string, callback: () => void): void; + + removeListener(type: string, callback: () => void): void; + + removeAllListeners(type: string): void; + + reset(): void; + + disconnect(code: number, reason: string): void; +} diff --git a/packages/web3-providers-ws/types/tests/web3-provider-ws-tests.ts b/packages/web3-providers-ws/types/tests/web3-provider-ws-tests.ts new file mode 100644 index 00000000000..7fae3ac40bd --- /dev/null +++ b/packages/web3-providers-ws/types/tests/web3-provider-ws-tests.ts @@ -0,0 +1,78 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file web3-provider-ws-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import { WebsocketProviderOptions } from 'web3-core-helpers'; +import { WebsocketProvider } from 'web3-providers'; + +const options: WebsocketProviderOptions = { + timeout: 30000, + headers: { + authorization: 'Basic username:password' + } +}; + +const wsProvider = new WebsocketProvider('ws://localhost:8545', options); + +// $ExpectType boolean +wsProvider.isConnecting(); + +// $ExpectType boolean +wsProvider.connected; + +// $ExpectType void +wsProvider.disconnect(100, 'reason'); + +// $ExpectType any +wsProvider.responseCallbacks; + +// $ExpectType any +wsProvider.notificationCallbacks; + +// $ExpectType any +wsProvider.connection; + +// $ExpectType boolean +wsProvider.connected; + +// $ExpectType void +wsProvider.addDefaultEvents(); + +// $ExpectType boolean +wsProvider.supportsSubscriptions(); + +// $ExpectType void +wsProvider.send({} as any, () => {}); + +// $ExpectType void +wsProvider.on('type', () => {}); + +// $ExpectType void +wsProvider.once('type', () => {}); + +// $ExpectType void +wsProvider.removeListener('type', () => {}); + +// $ExpectType void +wsProvider.removeAllListeners('type'); + +// $ExpectType void +wsProvider.reset(); diff --git a/packages/web3-providers-ws/types/tsconfig.json b/packages/web3-providers-ws/types/tsconfig.json new file mode 100644 index 00000000000..74e0aeeb3a8 --- /dev/null +++ b/packages/web3-providers-ws/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-providers": ["."] + } + } +} diff --git a/packages/web3-providers-ws/types/tslint.json b/packages/web3-providers-ws/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-providers-ws/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} diff --git a/packages/web3-shh/README.md b/packages/web3-shh/README.md index 7b2bf688fc8..7958b153b1a 100644 --- a/packages/web3-shh/README.md +++ b/packages/web3-shh/README.md @@ -2,7 +2,7 @@ This is a sub package of [web3.js][repo] -This is the whisper v5 package. +This is the whisper v5 package. Please read the [documentation][docs] for more. ## Installation @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-shh.js` in your html file. This will expose the `Web3Personal` object on the window object. - ## Usage ```js @@ -34,8 +33,9 @@ var Web3Personal = require('web3-shh'); var shh = new Web3Personal('ws://localhost:8546'); ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-shh/package-lock.json b/packages/web3-shh/package-lock.json new file mode 100644 index 00000000000..99220917d66 --- /dev/null +++ b/packages/web3-shh/package-lock.json @@ -0,0 +1,345 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/packages/web3-shh/package.json b/packages/web3-shh/package.json index 4c4e6294abc..0c05a795957 100644 --- a/packages/web3-shh/package.json +++ b/packages/web3-shh/package.json @@ -7,11 +7,19 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "web3-core": "1.2.1", "web3-core-method": "1.2.1", "web3-core-subscriptions": "1.2.1", "web3-net": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-shh/types/index.d.ts b/packages/web3-shh/types/index.d.ts new file mode 100644 index 00000000000..45f7fd0a6cb --- /dev/null +++ b/packages/web3-shh/types/index.d.ts @@ -0,0 +1,194 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import * as net from 'net'; +import { BatchRequest, provider, Providers } from 'web3-core'; +import { Network } from 'web3-net'; + +export class Shh { + constructor(provider: provider, net?: net.Socket | null); + + net: Network; + + readonly givenProvider: any; + readonly currentProvider: provider; + static readonly providers: Providers; + BatchRequest: new () => BatchRequest; + + setProvider(provider: provider): boolean; + + getVersion( + callback?: (error: Error, version: string) => void + ): Promise; + + getInfo(callback?: (error: Error, info: Info) => void): Promise; + + setMaxMessageSize( + size: number, + callback?: (error: Error, result: boolean) => void + ): Promise; + + setMinPoW( + pow: number, + callback?: (error: Error, result: boolean) => void + ): Promise; + + markTrustedPeer( + enode: string, + callback?: (error: Error, result: boolean) => void + ): Promise; + + newKeyPair(callback?: (error: Error, key: string) => void): Promise; + + addPrivateKey( + privateKey: string, + callback?: (error: Error, privateKey: string) => void + ): Promise; + + deleteKeyPair( + id: string, + callback?: (error: Error, result: boolean) => void + ): Promise; + + hasKeyPair( + id: string, + callback?: (error: Error, result: boolean) => void + ): Promise; + + getPublicKey( + id: string, + callback?: (error: Error, publicKey: string) => void + ): Promise; + + getPrivateKey( + id: string, + callback?: (error: Error, privateKey: string) => void + ): Promise; + + newSymKey(callback?: (error: Error, key: string) => void): Promise; + + addSymKey( + symKey: string, + callback?: (error: Error, key: string) => void + ): Promise; + + generateSymKeyFromPassword( + password: string, + callback?: (error: Error, key: string) => void + ): Promise; + + hasSymKey( + id: string, + callback?: (error: Error, result: boolean) => void + ): Promise; + + getSymKey( + id: string, + callback?: (error: Error, key: string) => void + ): Promise; + + deleteSymKey( + id: string, + callback?: (error: Error, result: boolean) => void + ): Promise; + + post( + object: PostWithSymKey | PostWithPubKey, + callback?: (error: Error, result: string) => void + ): Promise; + + subscribe( + string: 'messages', + options: SubscriptionOptions, + callback?: ( + error: Error, + message: Notification, + subscription: any + ) => void + ): Subscribe; + + newMessageFilter( + options?: SubscriptionOptions, + callback?: (error: Error, result: string) => void + ): Promise; + + deleteMessageFilter( + id: string, + callback?: (error: Error, result: string) => void + ): Promise; + + getFilterMessages( + id: string, + callback?: (error: Error, result: string) => void + ): Promise; +} + +export interface Info { + messages: number; + maxMessageSize: number; + memory: number; + minPow: number; +} + +export interface PostBase { + sig?: string; + ttl: number; + topic: string; + payload: string; + padding?: number; + powTime?: number; + powTarget?: number; + targetPeer?: number; +} + +export interface PostWithSymKey extends PostBase { + symKeyID: string; +} + +export interface PostWithPubKey extends PostBase { + pubKey: string; +} + +export interface SubscriptionOptions { + symKeyID?: string; + privateKeyID?: string; + sig?: string; + topics?: string[]; + minPow?: number; + allowP2P?: boolean; + ttl?: number; +} + +export interface Notification { + hash: string; + sig?: string; + recipientPublicKey?: string; + timestamp: string; + ttl: number; + topic: string; + payload: string; + padding: number; + pow: number; +} + +export interface Subscribe { + on(type: 'data', handler: (data: Notification) => void): void; + + on(type: 'error', handler: (data: Error) => void): void; +} diff --git a/packages/web3-shh/types/tests/shh-test.ts b/packages/web3-shh/types/tests/shh-test.ts new file mode 100644 index 00000000000..8a457fb3978 --- /dev/null +++ b/packages/web3-shh/types/tests/shh-test.ts @@ -0,0 +1,244 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file shh-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import { Info, Notification, Shh } from 'web3-shh'; + +const shh = new Shh('https://localhost:5000'); + +// $ExpectType provider +shh.currentProvider; + +// $ExpectType any +shh.givenProvider; + +// $ExpectType boolean +shh.setProvider('https://localhost:2100'); + +// $ExpectType BatchRequest +new shh.BatchRequest(); + +// $ExpectType Promise +shh.net.getId(); +// $ExpectType Promise +shh.net.getId((error: Error, id: number) => {}); + +// $ExpectType Promise +shh.net.isListening(); +// $ExpectType Promise +shh.net.isListening((error: Error, listening: boolean) => {}); + +// $ExpectType Promise +shh.net.getPeerCount(); +// $ExpectType Promise +shh.net.getPeerCount((error: Error, peerCount: number) => {}); + +// $ExpectType Promise +shh.getVersion(); +// $ExpectType Promise +shh.getVersion((error: Error, version: string) => {}); + +// $ExpectType Promise +shh.getInfo(); +// $ExpectType Promise +shh.getInfo((error: Error, info: Info) => {}); + +// $ExpectType Promise +shh.setMaxMessageSize(1234565); +// $ExpectType Promise +shh.setMaxMessageSize(1234565, (error: Error, result: boolean) => {}); + +// $ExpectType Promise +shh.setMinPoW(0.9); +// $ExpectType Promise +shh.setMinPoW(0.9, (error: Error, result: boolean) => {}); + +// $ExpectType Promise +shh.markTrustedPeer('test'); +// $ExpectType Promise +shh.markTrustedPeer('test', (error: Error, result: boolean) => {}); + +// $ExpectType Promise +shh.newKeyPair(); +// $ExpectType Promise +shh.newKeyPair((error: Error, key: string) => {}); + +// $ExpectType Promise +shh.addPrivateKey( + '0x8bda3abeb454847b515fa9b404cede50b1cc63cfdeddd4999d074284b4c21e15' +); +// $ExpectType Promise +shh.addPrivateKey( + '0x8bda3abeb454847b515fa9b404cede50b1cc63cfdeddd4999d074284b4c21e15', + (error: Error, privateKey: string) => {} +); + +// $ExpectType Promise +shh.deleteKeyPair( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.deleteKeyPair( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, result: boolean) => {} +); + +// $ExpectType Promise +shh.hasKeyPair( + 'fe22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.hasKeyPair( + 'fe22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, result: boolean) => {} +); + +// $ExpectType Promise +shh.getPublicKey( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.getPublicKey( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, publicKey: string) => {} +); + +// $ExpectType Promise +shh.getPrivateKey( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.getPrivateKey( + '3e22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, privateKey: string) => {} +); + +// $ExpectType Promise +shh.newSymKey(); +// $ExpectType Promise +shh.newSymKey((error: Error, key: string) => {}); + +// $ExpectType Promise +shh.addSymKey( + '0x5e11b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.addSymKey( + '0x5e11b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, key: string) => {} +); + +// $ExpectType Promise +shh.generateSymKeyFromPassword('Never use this password - password!'); +// $ExpectType Promise +shh.generateSymKeyFromPassword( + 'Never use this password - password!', + (error: Error, key: string) => {} +); + +// $ExpectType Promise +shh.hasSymKey( + 'f6dcf21ed6a17bd78d8c4c63195ab997b3b65ea683705501eae82d32667adc92' +); +// $ExpectType Promise +shh.hasSymKey( + 'f6dcf21ed6a17bd78d8c4c63195ab997b3b65ea683705501eae82d32667adc92', + (error: Error, result: boolean) => {} +); + +// $ExpectType Promise +shh.getSymKey( + 'af33b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.getSymKey( + 'af33b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, key: string) => {} +); + +// $ExpectType Promise +shh.deleteSymKey( + 'bf31b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f' +); +// $ExpectType Promise +shh.deleteSymKey( + 'bf31b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + (error: Error, result: boolean) => {} +); + +// $ExpectType Promise +shh.post({ + symKeyID: 'sd3', + sig: 'sds5', + ttl: 10, + topic: '0xffaadd11', + payload: '0xffffffdddddd1122', + powTime: 3, + powTarget: 0.5 +}); +// $ExpectType Promise +shh.post( + { + symKeyID: 'sd3', + sig: 'sds5', + ttl: 10, + topic: '0xffaadd11', + payload: '0xffffffdddddd1122', + powTime: 3, + powTarget: 0.5 + }, + (error: Error, result: string) => {} +); + +// $ExpectType Subscribe +shh.subscribe('messages', { + symKeyID: + 'bf31b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + sig: + '0x04d1574d4eab8f3dde4d2dc7ed2c4d699d77cbbdd09167b8fffa099652ce4df00c4c6e0263eafe05007a46fdf0c8d32b11aeabcd3abbc7b2bc2bb967368a68e9c6', + ttl: 20, + topics: ['0xffddaa11'], + minPow: 0.8 +}); +// $ExpectType Subscribe +shh.subscribe( + 'messages', + { + symKeyID: + 'bf31b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f', + sig: + '0x04d1574d4eab8f3dde4d2dc7ed2c4d699d77cbbdd09167b8fffa099652ce4df00c4c6e0263eafe05007a46fdf0c8d32b11aeabcd3abbc7b2bc2bb967368a68e9c6', + ttl: 20, + topics: ['0xffddaa11'], + minPow: 0.8 + }, + (error: Error, message: Notification, subscription: any) => {} +); + +// $ExpectType Promise +shh.newMessageFilter(); + +// $ExpectType Promise +shh.deleteMessageFilter( + '2b47fbafb3cce24570812a82e6e93cd9e2551bbc4823f6548ff0d82d2206b326' +); + +// $ExpectType Promise +shh.getFilterMessages( + '2b47fbafb3cce24570812a82e6e93cd9e2551bbc4823f6548ff0d82d2206b326' +); diff --git a/packages/web3-shh/types/tsconfig.json b/packages/web3-shh/types/tsconfig.json new file mode 100644 index 00000000000..5129cd82394 --- /dev/null +++ b/packages/web3-shh/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-shh": ["."] + } + } +} diff --git a/packages/web3-shh/types/tslint.json b/packages/web3-shh/types/tslint.json new file mode 100644 index 00000000000..871d605704b --- /dev/null +++ b/packages/web3-shh/types/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false + } +} diff --git a/packages/web3-utils/README.md b/packages/web3-utils/README.md index 11c1b8103df..accc1924bbd 100644 --- a/packages/web3-utils/README.md +++ b/packages/web3-utils/README.md @@ -2,7 +2,7 @@ This is a sub package of [web3.js][repo] -This contains useful utility functions for Dapp developers. +This contains useful utility functions for Dapp developers. Please read the [documentation][docs] for more. ## Installation @@ -24,7 +24,6 @@ npm run-script build-all Then include `dist/web3-utils.js` in your html file. This will expose the `Web3Utils` object on the window object. - ## Usage ```js @@ -39,8 +38,9 @@ console.log(Web3Utils); } ``` +## Types + +All the typescript typings are placed in the types folder. [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js - - diff --git a/packages/web3-utils/package-lock.json b/packages/web3-utils/package-lock.json index 1f26c73a510..2afa763b103 100644 --- a/packages/web3-utils/package-lock.json +++ b/packages/web3-utils/package-lock.json @@ -2,11 +2,64 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", @@ -17,6 +70,44 @@ "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=" }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", @@ -38,11 +129,47 @@ "object-keys": "^1.0.12" } }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, "dom-walk": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, "elliptic": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", @@ -80,6 +207,21 @@ "is-symbol": "^1.0.2" } }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, "eth-lib": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", @@ -114,11 +256,39 @@ "is-callable": "^1.1.3" } }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "global": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", @@ -128,6 +298,11 @@ "process": "~0.5.1" } }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -136,6 +311,11 @@ "function-bind": "^1.1.1" } }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", @@ -160,6 +340,15 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -201,6 +390,28 @@ "has-symbols": "^1.0.0" } }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -224,6 +435,27 @@ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, "number-to-bn": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", @@ -267,6 +499,21 @@ "string.prototype.trim": "^1.1.2" } }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, "process": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", @@ -290,11 +537,24 @@ "safe-buffer": "^5.1.0" } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, "safe-buffer": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, "simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", @@ -310,6 +570,11 @@ "simple-concat": "^1.0.0" } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -333,16 +598,72 @@ "is-hex-prefixed": "1.0.0" } }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, "timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, "url-set-query": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", diff --git a/packages/web3-utils/package.json b/packages/web3-utils/package.json index a4389340440..ffa2bc41960 100644 --- a/packages/web3-utils/package.json +++ b/packages/web3-utils/package.json @@ -7,6 +7,10 @@ "engines": { "node": ">=8.0.0" }, + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "main": "src/index.js", "dependencies": { "bn.js": "4.11.8", @@ -16,5 +20,9 @@ "randombytes": "^2.1.0", "underscore": "1.9.1", "utf8": "3.0.0" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3-utils/types/index.d.ts b/packages/web3-utils/types/index.d.ts new file mode 100644 index 00000000000..afdb12d385f --- /dev/null +++ b/packages/web3-utils/types/index.d.ts @@ -0,0 +1,225 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); + +export type Unit = + | 'noether' + | 'wei' + | 'kwei' + | 'Kwei' + | 'babbage' + | 'femtoether' + | 'mwei' + | 'Mwei' + | 'lovelace' + | 'picoether' + | 'gwei' + | 'Gwei' + | 'shannon' + | 'nanoether' + | 'nano' + | 'szabo' + | 'microether' + | 'micro' + | 'finney' + | 'milliether' + | 'milli' + | 'ether' + | 'kether' + | 'grand' + | 'mether' + | 'gether' + | 'tether'; + +export type Mixed = + | string + | number + | BN + | { + type: string; + value: string; + } + | { + t: string; + v: string | BN | number; + } + | boolean; + +export type Hex = string | number; + +// utils types +export function isBN(value: string | number): boolean; +export function isBigNumber(value: BN): boolean; +export function toBN(value: number | string): BN; +export function toTwosComplement(value: number | string | BN): string; +export function isAddress(address: string, chainId?: number): boolean; +export function isHex(hex: Hex): boolean; +export function isHexStrict(hex: Hex): boolean; +export function asciiToHex(string: string, length?: number): string; +export function hexToAscii(string: string): string; +export function toAscii(string: string): string; +export function bytesToHex(bytes: number[]): string; +export function numberToHex(value: number | string | BN): string; +export function checkAddressChecksum(address: string, chainId?: number): boolean; +export function fromAscii(string: string): string; +export function fromDecimal(value: string | number): string; +export function fromUtf8(string: string): string; +export function fromWei(value: string | BN, unit?: Unit): string; +export function hexToBytes(hex: Hex): number[]; +export function hexToNumber(hex: Hex): number; +export function hexToNumberString(hex: Hex): string; +export function hexToString(hex: Hex): string; +export function hexToUtf8(string: string): string; +export function keccak256(value: string | BN): string; +export function padLeft(value: string | number, characterAmount: number, sign?: string): string; +export function leftPad(string: string | number, characterAmount: number, sign?: string): string; +export function rightPad(string: string | number, characterAmount: number, sign?: string): string; +export function padRight(string: string | number, characterAmount: number, sign?: string): string; +export function sha3(value: string | BN): string; +export function randomHex(bytesSize: number): string; +export function utf8ToHex(string: string): string; +export function stringToHex(string: string): string; +export function toChecksumAddress(address: string, chainId?: number): string; +export function toDecimal(hex: Hex): number; +export function toHex(value: number | string | BN): string; +export function toUtf8(string: string): string; +export function toWei(val: BN, unit?: Unit): BN; +export function toWei(val: string, unit?: Unit): string; +export function isBloom(bloom: string): boolean; +export function isTopic(topic: string): boolean; +export function jsonInterfaceMethodToString(abiItem: AbiItem): string; +export function soliditySha3(...val: Mixed[]): string; +export function getUnitValue(unit: Unit): string; +export function unitMap(): Units; +export function testAddress(bloom: string, address: string): boolean; +export function testTopic(bloom: string, topic: string): boolean; +export function getSignatureParameters(signature: string): {r: string; s: string; v: number}; +export function stripHexPrefix(str: string): string; + +// interfaces +export interface Utils { + isBN(value: string | number): boolean; + isBigNumber(value: BN): boolean; + toBN(value: number | string): BN; + toTwosComplement(value: number | string | BN): string; + isAddress(address: string, chainId?: number): boolean; + isHex(hex: Hex): boolean; + isHexStrict(hex: Hex): boolean; + asciiToHex(string: string, length?: number): string; + hexToAscii(string: string): string; + toAscii(string: string): string; + bytesToHex(bytes: number[]): string; + numberToHex(value: number | string | BN): string; + checkAddressChecksum(address: string, chainId?: number): boolean; + fromAscii(string: string): string; + fromDecimal(value: string | number): string; + fromUtf8(string: string): string; + fromWei(value: string | BN, unit?: Unit): string; + hexToBytes(hex: Hex): number[]; + hexToNumber(hex: Hex): number; + hexToNumberString(hex: Hex): string; + hexToString(hex: Hex): string; + hexToUtf8(string: string): string; + keccak256(value: string | BN): string; + padLeft(value: string | number, characterAmount: number, sign?: string): string; + leftPad(string: string | number, characterAmount: number, sign?: string): string; + rightPad(string: string | number, characterAmount: number, sign?: string): string; + padRight(string: string | number, characterAmount: number, sign?: string): string; + sha3(value: string | BN): string; + randomHex(bytesSize: number): string; + utf8ToHex(string: string): string; + stringToHex(string: string): string; + toChecksumAddress(address: string, chainId?: number): string; + toDecimal(hex: Hex): number; + toHex(value: number | string | BN): string; + toUtf8(string: string): string; + toWei(val: BN, unit?: Unit): BN; + toWei(val: string, unit?: Unit): string; + isBloom(bloom: string): boolean; + isTopic(topic: string): boolean; + jsonInterfaceMethodToString(abiItem: AbiItem): string; + soliditySha3(...val: Mixed[]): string; + getUnitValue(unit: Unit): string; + unitMap(): Units; + testAddress(bloom: string, address: string): boolean; + testTopic(bloom: string, topic: string): boolean; + getSignatureParameters(signature: string): {r: string; s: string; v: number}; + stripHexPrefix(str: string): string; +} + +export interface Units { + noether: string; + wei: string; + kwei: string; + Kwei: string; + babbage: string; + femtoether: string; + mwei: string; + Mwei: string; + lovelace: string; + picoether: string; + gwei: string; + Gwei: string; + shannon: string; + nanoether: string; + nano: string; + szabo: string; + microether: string; + micro: string; + finney: string; + milliether: string; + milli: string; + ether: string; + kether: string; + grand: string; + mether: string; + gether: string; + tether: string; +} + +export type AbiType = 'function' | 'constructor' | 'event' | 'fallback'; +export type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable'; + +export interface AbiItem { + anonymous?: boolean; + constant?: boolean; + inputs?: AbiInput[]; + name?: string; + outputs?: AbiOutput[]; + payable?: boolean; + stateMutability?: StateMutabilityType; + type: AbiType; +} + +export interface AbiInput { + name: string; + type: string; + indexed?: boolean; + components?: AbiInput[]; +} + +export interface AbiOutput { + name: string; + type: string; + components?: AbiOutput[]; +} diff --git a/packages/web3-utils/types/tests/ascii-to-hex-test.ts b/packages/web3-utils/types/tests/ascii-to-hex-test.ts new file mode 100644 index 00000000000..0f2f750ce85 --- /dev/null +++ b/packages/web3-utils/types/tests/ascii-to-hex-test.ts @@ -0,0 +1,47 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file ascii-to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {asciiToHex} from 'web3-utils'; + +// $ExpectType string +asciiToHex('I have 100!'); + +// $ExpectType string +asciiToHex('I have 100!', 32); + +// $ExpectError +asciiToHex(345); +// $ExpectError +asciiToHex(new BN(3)); +// $ExpectError +asciiToHex({}); +// $ExpectError +asciiToHex(true); +// $ExpectError +asciiToHex(['string']); +// $ExpectError +asciiToHex([4]); +// $ExpectError +asciiToHex(null); +// $ExpectError +asciiToHex(undefined); diff --git a/packages/web3-utils/types/tests/bytes-to-hex-test.ts b/packages/web3-utils/types/tests/bytes-to-hex-test.ts new file mode 100644 index 00000000000..af7253c352f --- /dev/null +++ b/packages/web3-utils/types/tests/bytes-to-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file bytes-to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {bytesToHex} from 'web3-utils'; + +// $ExpectType string +bytesToHex([72]); + +// $ExpectError +bytesToHex(['string']); +// $ExpectError +bytesToHex(345); +// $ExpectError +bytesToHex(new BN(3)); +// $ExpectError +bytesToHex({}); +// $ExpectError +bytesToHex(true); +// $ExpectError +bytesToHex(['string']); +// $ExpectError +bytesToHex(null); +// $ExpectError +bytesToHex(undefined); diff --git a/packages/web3-utils/types/tests/check-address-checksum-test.ts b/packages/web3-utils/types/tests/check-address-checksum-test.ts new file mode 100644 index 00000000000..0ed905dc55b --- /dev/null +++ b/packages/web3-utils/types/tests/check-address-checksum-test.ts @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file check-address-checksum-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {checkAddressChecksum} from 'web3-utils'; + +// $ExpectType boolean +checkAddressChecksum('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectType boolean +checkAddressChecksum('0xFb6916095CA1dF60bb79CE92ce3Ea74C37c5D359', 31); +// $ExpectType boolean +checkAddressChecksum('0xFb6916095CA1dF60bb79CE92ce3Ea74C37c5D359', undefined); + +// $ExpectError +checkAddressChecksum([4]); +// $ExpectError +checkAddressChecksum(['string']); +// $ExpectError +checkAddressChecksum(345); +// $ExpectError +checkAddressChecksum(new BN(3)); +// $ExpectError +checkAddressChecksum({}); +// $ExpectError +checkAddressChecksum(true); +// $ExpectError +checkAddressChecksum(null); +// $ExpectError +checkAddressChecksum(undefined); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', 'string'); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', [4]); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', new BN(3)); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', {}); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', true); +// $ExpectError +checkAddressChecksum('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', null); diff --git a/packages/web3-utils/types/tests/from-ascii-test.ts b/packages/web3-utils/types/tests/from-ascii-test.ts new file mode 100644 index 00000000000..504c6ee2698 --- /dev/null +++ b/packages/web3-utils/types/tests/from-ascii-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file from-ascii-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {fromAscii} from 'web3-utils'; + +// $ExpectType string +fromAscii('I have 100!'); + +// $ExpectError +fromAscii(345); +// $ExpectError +fromAscii(new BN(3)); +// $ExpectError +fromAscii({}); +// $ExpectError +fromAscii(true); +// $ExpectError +fromAscii(['string']); +// $ExpectError +fromAscii([4]); +// $ExpectError +fromAscii(null); +// $ExpectError +fromAscii(undefined); diff --git a/packages/web3-utils/types/tests/from-decimal-test.ts b/packages/web3-utils/types/tests/from-decimal-test.ts new file mode 100644 index 00000000000..3870aa3e701 --- /dev/null +++ b/packages/web3-utils/types/tests/from-decimal-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file from-decimal-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {fromDecimal} from 'web3-utils'; + +// $ExpectType string +fromDecimal('232'); +// $ExpectType string +fromDecimal(232); + +// $ExpectError +fromDecimal(new BN(3)); +// $ExpectError +fromDecimal(['string']); +// $ExpectError +fromDecimal([4]); +// $ExpectError +fromDecimal({}); +// $ExpectError +fromDecimal(true); +// $ExpectError +fromDecimal(null); +// $ExpectError +fromDecimal(undefined); diff --git a/packages/web3-utils/types/tests/from-utf8-test.ts b/packages/web3-utils/types/tests/from-utf8-test.ts new file mode 100644 index 00000000000..8ab06f87dd3 --- /dev/null +++ b/packages/web3-utils/types/tests/from-utf8-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file from-utf8-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {fromUtf8} from 'web3-utils'; + +// $ExpectType string +fromUtf8('I have 100£'); + +// $ExpectError +fromUtf8(232); +// $ExpectError +fromUtf8(new BN(3)); +// $ExpectError +fromUtf8(['string']); +// $ExpectError +fromUtf8([4]); +// $ExpectError +fromUtf8({}); +// $ExpectError +fromUtf8(true); +// $ExpectError +fromUtf8(null); +// $ExpectError +fromUtf8(undefined); diff --git a/packages/web3-utils/types/tests/from-wei-test.ts b/packages/web3-utils/types/tests/from-wei-test.ts new file mode 100644 index 00000000000..852616f6881 --- /dev/null +++ b/packages/web3-utils/types/tests/from-wei-test.ts @@ -0,0 +1,52 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file from-wei-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {fromWei} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType string +fromWei(bigNumber); +// $ExpectType string +fromWei('1'); +// $ExpectType string +fromWei(bigNumber, 'ether'); +// $ExpectType string +fromWei('1', 'ether'); + +// $ExpectError +fromWei(232); +// $ExpectError +fromWei(['string']); +// $ExpectError +fromWei([4]); +// $ExpectError +fromWei({}); +// $ExpectError +fromWei(true); +// $ExpectError +fromWei(null); +// $ExpectError +fromWei(undefined); +// $ExpectError +fromWei(new BN(3), 'blah'); diff --git a/packages/web3-utils/types/tests/get-signature-params-test.ts b/packages/web3-utils/types/tests/get-signature-params-test.ts new file mode 100644 index 00000000000..e1f442239c0 --- /dev/null +++ b/packages/web3-utils/types/tests/get-signature-params-test.ts @@ -0,0 +1,45 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file get-signature-params-tests.ts + * @author Aalok Singh + * @date 2018 + */ + +import BN = require('bn.js'); +import {getSignatureParameters} from 'web3-utils'; + +// $ExpectType { r: string; s: string; v: number; } +getSignatureParameters( + '0x90dc0e49b5a80eef86fcedcb863dcc727aeae5c11187c001fd3d18780ead2cc7701ba1986099a49164702f3d8b2c8dbbd45a6d1beb37d212d21fb1be4bb762a400' +); +// $ExpectError +getSignatureParameters(345); +// $ExpectError +getSignatureParameters(new BN(3)); +// $ExpectError +getSignatureParameters({}); +// $ExpectError +getSignatureParameters(true); +// $ExpectError +getSignatureParameters(['string']); +// $ExpectError +getSignatureParameters([4]); +// $ExpectError +getSignatureParameters(null); +// $ExpectError +getSignatureParameters(undefined); diff --git a/packages/web3-utils/types/tests/get-unit-value-test.ts b/packages/web3-utils/types/tests/get-unit-value-test.ts new file mode 100644 index 00000000000..27ffc9ac857 --- /dev/null +++ b/packages/web3-utils/types/tests/get-unit-value-test.ts @@ -0,0 +1,46 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file get-unit-value-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {getUnitValue} from 'web3-utils'; + +// $ExpectType string +getUnitValue('ether'); + +// $ExpectError +getUnitValue('fake'); +// $ExpectError +getUnitValue(656); +// $ExpectError +getUnitValue(new BN(3)); +// $ExpectError +getUnitValue(['string']); +// $ExpectError +getUnitValue([4]); +// $ExpectError +getUnitValue({}); +// $ExpectError +getUnitValue(true); +// $ExpectError +getUnitValue(null); +// $ExpectError +getUnitValue(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-ascii-test.ts b/packages/web3-utils/types/tests/hex-to-ascii-test.ts new file mode 100644 index 00000000000..991e44ca461 --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-ascii-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-ascii-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToAscii} from 'web3-utils'; + +// $ExpectType string +hexToAscii('0x4920686176652031303021'); + +// $ExpectError +hexToAscii(345); +// $ExpectError +hexToAscii(new BN(3)); +// $ExpectError +hexToAscii({}); +// $ExpectError +hexToAscii(true); +// $ExpectError +hexToAscii(['string']); +// $ExpectError +hexToAscii([4]); +// $ExpectError +hexToAscii(null); +// $ExpectError +hexToAscii(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-bytes-test.ts b/packages/web3-utils/types/tests/hex-to-bytes-test.ts new file mode 100644 index 00000000000..9a57e3559a8 --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-bytes-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-bytes-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToBytes} from 'web3-utils'; + +// $ExpectType number[] +hexToBytes('0x000000ea'); +// $ExpectType number[] +hexToBytes(0x000000ea); + +// $ExpectError +hexToBytes([4]); +// $ExpectError +hexToBytes(['string']); +// $ExpectError +hexToBytes(new BN(3)); +// $ExpectError +hexToBytes({}); +// $ExpectError +hexToBytes(true); +// $ExpectError +hexToBytes(null); +// $ExpectError +hexToBytes(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-number-string-test.ts b/packages/web3-utils/types/tests/hex-to-number-string-test.ts new file mode 100644 index 00000000000..10d80d03912 --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-number-string-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-number-string-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToNumberString} from 'web3-utils'; + +// $ExpectType string +hexToNumberString('0xea'); +// $ExpectType string +hexToNumberString(0xea); + +// $ExpectError +hexToNumberString(new BN(3); +// $ExpectError +hexToNumberString(['string']); +// $ExpectError +hexToNumberString([4]); +// $ExpectError +hexToNumberString({}); +// $ExpectError +hexToNumberString(true); +// $ExpectError +hexToNumberString(null); +// $ExpectError +hexToNumberString(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-number-test.ts b/packages/web3-utils/types/tests/hex-to-number-test.ts new file mode 100644 index 00000000000..597a65bfe5f --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-number-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-number-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToNumber} from 'web3-utils'; + +// $ExpectType number +hexToNumber('232'); +// $ExpectType number +hexToNumber(232); + +// $ExpectError +hexToNumber(new BN(3)); +// $ExpectError +hexToNumber(['string']); +// $ExpectError +hexToNumber([4]); +// $ExpectError +hexToNumber({}); +// $ExpectError +hexToNumber(true); +// $ExpectError +hexToNumber(null); +// $ExpectError +hexToNumber(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-string-test.ts b/packages/web3-utils/types/tests/hex-to-string-test.ts new file mode 100644 index 00000000000..000464e7968 --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-string-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-string-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToString} from 'web3-utils'; + +// $ExpectType string +hexToString('0x49206861766520313030e282ac'); +// $ExpectType string +hexToString(0x49206861766520313030e282ac); + +// $ExpectError +hexToString(new BN(3)); +// $ExpectError +hexToString(['string']); +// $ExpectError +hexToString([4]); +// $ExpectError +hexToString({}); +// $ExpectError +hexToString(true); +// $ExpectError +hexToString(null); +// $ExpectError +hexToString(undefined); diff --git a/packages/web3-utils/types/tests/hex-to-utf8-test.ts b/packages/web3-utils/types/tests/hex-to-utf8-test.ts new file mode 100644 index 00000000000..021fe0fc6f1 --- /dev/null +++ b/packages/web3-utils/types/tests/hex-to-utf8-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file hex-to-utf8-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {hexToUtf8} from 'web3-utils'; + +// $ExpectType string +hexToUtf8('0x49206861766520313030e282ac'); + +// $ExpectError +hexToUtf8(656); +// $ExpectError +hexToUtf8(new BN(3)); +// $ExpectError +hexToUtf8(['string']); +// $ExpectError +hexToUtf8([4]); +// $ExpectError +hexToUtf8({}); +// $ExpectError +hexToUtf8(true); +// $ExpectError +hexToUtf8(null); +// $ExpectError +hexToUtf8(undefined); diff --git a/packages/web3-utils/types/tests/is-address-test.ts b/packages/web3-utils/types/tests/is-address-test.ts new file mode 100644 index 00000000000..6c2847c9cfc --- /dev/null +++ b/packages/web3-utils/types/tests/is-address-test.ts @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-address-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isAddress} from 'web3-utils'; + +// $ExpectType boolean +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectType boolean +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', 30); +// $ExpectType boolean +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', undefined); + +// $ExpectError +isAddress(4); +// $ExpectError +isAddress(new BN(3)); +// $ExpectError +isAddress({}); +// $ExpectError +isAddress(true); +// $ExpectError +isAddress(['string']); +// $ExpectError +isAddress([4]); +// $ExpectError +isAddress(null); +// $ExpectError +isAddress(undefined); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', new BN(3)); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', {}); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', true); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', ['string']); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', [4]); +// $ExpectError +isAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', null); diff --git a/packages/web3-utils/types/tests/is-big-number-test.ts b/packages/web3-utils/types/tests/is-big-number-test.ts new file mode 100644 index 00000000000..99968cf8ff2 --- /dev/null +++ b/packages/web3-utils/types/tests/is-big-number-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-big-number-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isBigNumber} from 'web3-utils'; + +// $ExpectType boolean +isBigNumber(new BN(3)); + +// $ExpectError +isBigNumber(7); +// $ExpectError +isBigNumber('4325'); +// $ExpectError +isBigNumber({}); +// $ExpectError +isBigNumber(true); +// $ExpectError +isBigNumber(['string']); +// $ExpectError +isBigNumber([4]); +// $ExpectError +isBigNumber(null); +// $ExpectError +isBigNumber(undefined); diff --git a/packages/web3-utils/types/tests/is-bloom-test.ts b/packages/web3-utils/types/tests/is-bloom-test.ts new file mode 100644 index 00000000000..e0256e92fc8 --- /dev/null +++ b/packages/web3-utils/types/tests/is-bloom-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-bloom-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isBloom} from 'web3-utils'; + +// $ExpectType boolean +isBloom('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'); + +// $ExpectError +isBloom(656); +// $ExpectError +isBloom(new BN(3)); +// $ExpectError +isBloom(['string']); +// $ExpectError +isBloom([4]); +// $ExpectError +isBloom({}); +// $ExpectError +isBloom(true); +// $ExpectError +isBloom(null); +// $ExpectError +isBloom(undefined); diff --git a/packages/web3-utils/types/tests/is-bn-test.ts b/packages/web3-utils/types/tests/is-bn-test.ts new file mode 100644 index 00000000000..1a4c9d1efe7 --- /dev/null +++ b/packages/web3-utils/types/tests/is-bn-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-bn-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isBN} from 'web3-utils'; + +// $ExpectType boolean +isBN(7); +// $ExpectType boolean +isBN('4325'); + +// $ExpectError +isBN({}); +// $ExpectError +isBN(true); +// $ExpectError +isBN(new BN(3)); +// $ExpectError +isBN(['string']); +// $ExpectError +isBN([4]); +// $ExpectError +isBN(null); +// $ExpectError +isBN(undefined); diff --git a/packages/web3-utils/types/tests/is-hex-strict-test.ts b/packages/web3-utils/types/tests/is-hex-strict-test.ts new file mode 100644 index 00000000000..70c7c469f48 --- /dev/null +++ b/packages/web3-utils/types/tests/is-hex-strict-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-hex-strict-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isHexStrict} from 'web3-utils'; + +// $ExpectType boolean +isHexStrict('0xc1912'); +// $ExpectType boolean +isHexStrict(345); + +// $ExpectError +isHexStrict(new BN(3)); +// $ExpectError +isHexStrict({}); +// $ExpectError +isHexStrict(true); +// $ExpectError +isHexStrict(['string']); +// $ExpectError +isHexStrict([4]); +// $ExpectError +isHexStrict(null); +// $ExpectError +isHexStrict(undefined); diff --git a/packages/web3-utils/types/tests/is-hex-test.ts b/packages/web3-utils/types/tests/is-hex-test.ts new file mode 100644 index 00000000000..64ffa687ce9 --- /dev/null +++ b/packages/web3-utils/types/tests/is-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isHex} from 'web3-utils'; + +// $ExpectType boolean +isHex('0xc1912'); +// $ExpectType boolean +isHex(345); + +// $ExpectError +isHex(new BN(3)); +// $ExpectError +isHex({}); +// $ExpectError +isHex(true); +// $ExpectError +isHex(['string']); +// $ExpectError +isHex([4]); +// $ExpectError +isHex(null); +// $ExpectError +isHex(undefined); diff --git a/packages/web3-utils/types/tests/is-topic-test.ts b/packages/web3-utils/types/tests/is-topic-test.ts new file mode 100644 index 00000000000..bb600827c60 --- /dev/null +++ b/packages/web3-utils/types/tests/is-topic-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file is-topic-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {isTopic} from 'web3-utils'; + +// $ExpectType boolean +isTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'); + +// $ExpectError +isTopic(656); +// $ExpectError +isTopic(new BN(3)); +// $ExpectError +isTopic(['string']); +// $ExpectError +isTopic([4]); +// $ExpectError +isTopic({}); +// $ExpectError +isTopic(true); +// $ExpectError +isTopic(null); +// $ExpectError +isTopic(undefined); diff --git a/packages/web3-utils/types/tests/json-interface-method-to-string-test.ts b/packages/web3-utils/types/tests/json-interface-method-to-string-test.ts new file mode 100644 index 00000000000..649b6609c6a --- /dev/null +++ b/packages/web3-utils/types/tests/json-interface-method-to-string-test.ts @@ -0,0 +1,120 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file json-interface-method-to-string-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import {jsonInterfaceMethodToString, AbiItem} from 'web3-utils'; + +const abiItem: AbiItem = { + anonymous: false, + constant: true, + inputs: [ + { + name: 'testMe', + type: 'uint256[3]' + }, + { + name: 'inputA', + type: 'tuple', + components: [ + { + name: 'a', + type: 'uint8' + }, + { + name: 'b', + type: 'uint8' + } + ] + }, + { + name: 'inputB', + type: 'tuple[]', + components: [ + { + name: 'a1', + type: 'uint256' + }, + { + name: 'a2', + type: 'uint256' + } + ] + }, + { + name: 'inputC', + type: 'uint8', + indexed: false + } + ], + name: "testName", + outputs: [ + { + name: "test", + type: "uint256" + }, + { + name: 'outputA', + type: 'tuple', + components: [ + { + name: 'a', + type: 'uint8' + }, + { + name: 'b', + type: 'uint8' + } + ] + }, + { + name: 'outputB', + type: 'tuple[]', + components: [ + { + name: 'a1', + type: 'uint256' + }, + { + name: 'a2', + type: 'uint256' + } + ] + } + ], + payable: false, + stateMutability: "pure", + type: "function" +}; +// $ExpectType string +jsonInterfaceMethodToString(abiItem); + +// $ExpectError +jsonInterfaceMethodToString(['string']); +// $ExpectError +jsonInterfaceMethodToString(234); +// $ExpectError +jsonInterfaceMethodToString([4]); +// $ExpectError +jsonInterfaceMethodToString(true); +// $ExpectError +jsonInterfaceMethodToString(null); +// $ExpectError +jsonInterfaceMethodToString(undefined); diff --git a/packages/web3-utils/types/tests/keccak256-test.ts b/packages/web3-utils/types/tests/keccak256-test.ts new file mode 100644 index 00000000000..7f3f571e19a --- /dev/null +++ b/packages/web3-utils/types/tests/keccak256-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file keccak256-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {keccak256} from 'web3-utils'; + +// $ExpectType string +keccak256('234'); +// $ExpectType string +keccak256(new BN(3)); + +// $ExpectError +keccak256(['string']); +// $ExpectError +keccak256(234); +// $ExpectError +keccak256([4]); +// $ExpectError +keccak256({}); +// $ExpectError +keccak256(true); +// $ExpectError +keccak256(null); +// $ExpectError +keccak256(undefined); diff --git a/packages/web3-utils/types/tests/left-pad-test.ts b/packages/web3-utils/types/tests/left-pad-test.ts new file mode 100644 index 00000000000..936f198ea4c --- /dev/null +++ b/packages/web3-utils/types/tests/left-pad-test.ts @@ -0,0 +1,73 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file left-pad-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {leftPad} from 'web3-utils'; + +const bigNumber = new BN(3); +// $ExpectType string +leftPad('0x3456ff', 20); +// $ExpectType string +leftPad(0x3456ff, 20); +// $ExpectType string +leftPad('Hello', 20, 'x'); + +// $ExpectError +leftPad(bigNumber, 20); +// $ExpectError +leftPad(['string'], 20); +// $ExpectError +leftPad([4], 20); +// $ExpectError +leftPad({}, 20); +// $ExpectError +leftPad(true, 20); +// $ExpectError +leftPad(null, 20); +// $ExpectError +leftPad(undefined, 20); +// $ExpectError +leftPad('0x3456ff', bigNumber); +// $ExpectError +leftPad('0x3456ff', ['string']); +// $ExpectError +leftPad('0x3456ff', [4]); +// $ExpectError +leftPad('0x3456ff', {}); +// $ExpectError +leftPad('0x3456ff', true); +// $ExpectError +leftPad('0x3456ff', null); +// $ExpectError +leftPad('0x3456ff', undefined); +// $ExpectError +leftPad('Hello', 20, bigNumber); +// $ExpectError +leftPad('Hello', 20, ['string']); +// $ExpectError +leftPad('Hello', 20, [4]); +// $ExpectError +leftPad('Hello', 20, {}); +// $ExpectError +leftPad('Hello', 20, true); +// $ExpectError +leftPad('Hello', 20, null); diff --git a/packages/web3-utils/types/tests/number-to-hex-test.ts b/packages/web3-utils/types/tests/number-to-hex-test.ts new file mode 100644 index 00000000000..102e22f7518 --- /dev/null +++ b/packages/web3-utils/types/tests/number-to-hex-test.ts @@ -0,0 +1,46 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file number-to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {numberToHex} from 'web3-utils'; + +// $ExpectType string +numberToHex('232'); +// $ExpectType string +numberToHex(232); +// $ExpectType string +numberToHex(new BN(3)); + +// $ExpectError +numberToHex(['72']); +// $ExpectError +numberToHex([4]); +// $ExpectError +numberToHex([ 36 ]); +// $ExpectError +numberToHex({}); +// $ExpectError +numberToHex(true); +// $ExpectError +numberToHex(null); +// $ExpectError +numberToHex(undefined); diff --git a/packages/web3-utils/types/tests/pad-left-test.ts b/packages/web3-utils/types/tests/pad-left-test.ts new file mode 100644 index 00000000000..e763df68fdf --- /dev/null +++ b/packages/web3-utils/types/tests/pad-left-test.ts @@ -0,0 +1,74 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file pad-left-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {padLeft} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType string +padLeft('0x3456ff', 20); +// $ExpectType string +padLeft(0x3456ff, 20); +// $ExpectType string +padLeft('Hello', 20, 'x'); + +// $ExpectError +padLeft(bigNumber, 20); +// $ExpectError +padLeft(['string'], 20); +// $ExpectError +padLeft([4], 20); +// $ExpectError +padLeft({}, 20); +// $ExpectError +padLeft(true, 20); +// $ExpectError +padLeft(null, 20); +// $ExpectError +padLeft(undefined, 20); +// $ExpectError +padLeft('0x3456ff', bigNumber); +// $ExpectError +padLeft('0x3456ff', ['string']); +// $ExpectError +padLeft('0x3456ff', [4]); +// $ExpectError +padLeft('0x3456ff', {}); +// $ExpectError +padLeft('0x3456ff', true); +// $ExpectError +padLeft('0x3456ff', null); +// $ExpectError +padLeft('0x3456ff', undefined); +// $ExpectError +padLeft('Hello', 20, bigNumber); +// $ExpectError +padLeft('Hello', 20, ['string']); +// $ExpectError +padLeft('Hello', 20, [4]); +// $ExpectError +padLeft('Hello', 20, {}); +// $ExpectError +padLeft('Hello', 20, true); +// $ExpectError +padLeft('Hello', 20, null); diff --git a/packages/web3-utils/types/tests/pad-right-test.ts b/packages/web3-utils/types/tests/pad-right-test.ts new file mode 100644 index 00000000000..97202a820b3 --- /dev/null +++ b/packages/web3-utils/types/tests/pad-right-test.ts @@ -0,0 +1,74 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file pad-right-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {padRight} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType string +padRight('0x3456ff', 20); +// $ExpectType string +padRight(0x3456ff, 20); +// $ExpectType string +padRight('Hello', 20, 'x'); + +// $ExpectError +padRight(bigNumber, 20); +// $ExpectError +padRight(['string'], 20); +// $ExpectError +padRight([4], 20); +// $ExpectError +padRight({}, 20); +// $ExpectError +padRight(true, 20); +// $ExpectError +padRight(null, 20); +// $ExpectError +padRight(undefined, 20); +// $ExpectError +padRight('0x3456ff', bigNumber); +// $ExpectError +padRight('0x3456ff', ['string']); +// $ExpectError +padRight('0x3456ff', [4]); +// $ExpectError +padRight('0x3456ff', {}); +// $ExpectError +padRight('0x3456ff', true); +// $ExpectError +padRight('0x3456ff', null); +// $ExpectError +padRight('0x3456ff', undefined); +// $ExpectError +padRight('Hello', 20, bigNumber); +// $ExpectError +padRight('Hello', 20, ['string']); +// $ExpectError +padRight('Hello', 20, [4]); +// $ExpectError +padRight('Hello', 20, {}); +// $ExpectError +padRight('Hello', 20, true); +// $ExpectError +padRight('Hello', 20, null); diff --git a/packages/web3-utils/types/tests/random-hex-test.ts b/packages/web3-utils/types/tests/random-hex-test.ts new file mode 100644 index 00000000000..64465afb93e --- /dev/null +++ b/packages/web3-utils/types/tests/random-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file random-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {randomHex} from 'web3-utils'; + +// $ExpectType string +randomHex(32); + +// $ExpectError +randomHex('234'); +// $ExpectError +randomHex(new BN(3)); +// $ExpectError +randomHex(['string']); +// $ExpectError +randomHex([4]); +// $ExpectError +randomHex({}); +// $ExpectError +randomHex(true); +// $ExpectError +randomHex(null); +// $ExpectError +randomHex(undefined); diff --git a/packages/web3-utils/types/tests/right-pad-test.ts b/packages/web3-utils/types/tests/right-pad-test.ts new file mode 100644 index 00000000000..f81ace7dc72 --- /dev/null +++ b/packages/web3-utils/types/tests/right-pad-test.ts @@ -0,0 +1,74 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file right-pad-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {rightPad} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType string +rightPad('0x3456ff', 20); +// $ExpectType string +rightPad(0x3456ff, 20); +// $ExpectType string +rightPad('Hello', 20, 'x'); + +// $ExpectError +rightPad(bigNumber, 20); +// $ExpectError +rightPad(['string'], 20); +// $ExpectError +rightPad([4], 20); +// $ExpectError +rightPad({}, 20); +// $ExpectError +rightPad(true, 20); +// $ExpectError +rightPad(null, 20); +// $ExpectError +rightPad(undefined, 20); +// $ExpectError +rightPad('0x3456ff', bigNumber); +// $ExpectError +rightPad('0x3456ff', ['string']); +// $ExpectError +rightPad('0x3456ff', [4]); +// $ExpectError +rightPad('0x3456ff', {}); +// $ExpectError +rightPad('0x3456ff', true); +// $ExpectError +rightPad('0x3456ff', null); +// $ExpectError +rightPad('0x3456ff', undefined); +// $ExpectError +rightPad('Hello', 20, bigNumber); +// $ExpectError +rightPad('Hello', 20, ['string']); +// $ExpectError +rightPad('Hello', 20, [4]); +// $ExpectError +rightPad('Hello', 20, {}); +// $ExpectError +rightPad('Hello', 20, true); +// $ExpectError +rightPad('Hello', 20, null); diff --git a/packages/web3-utils/types/tests/sha3-test.ts b/packages/web3-utils/types/tests/sha3-test.ts new file mode 100644 index 00000000000..a92330aa5d4 --- /dev/null +++ b/packages/web3-utils/types/tests/sha3-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file sha3-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {sha3} from 'web3-utils'; + +// $ExpectType string +sha3('234'); +// $ExpectType string +sha3(new BN(3)); + +// $ExpectError +sha3(['string']); +// $ExpectError +sha3(234); +// $ExpectError +sha3([4]); +// $ExpectError +sha3({}); +// $ExpectError +sha3(true); +// $ExpectError +sha3(null); +// $ExpectError +sha3(undefined); diff --git a/packages/web3-utils/types/tests/solidity-sha3-test.ts b/packages/web3-utils/types/tests/solidity-sha3-test.ts new file mode 100644 index 00000000000..89a5b0e8f21 --- /dev/null +++ b/packages/web3-utils/types/tests/solidity-sha3-test.ts @@ -0,0 +1,52 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file solidity-sha3-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {soliditySha3} from 'web3-utils'; + +// $ExpectType string +soliditySha3('234564535', '0xfff23243', true, -10); +// $ExpectType string +soliditySha3('Hello!%'); +// $ExpectType string +soliditySha3('234'); +// $ExpectType string +soliditySha3(0xea); +// $ExpectType string +soliditySha3(new BN(3)); +// $ExpectType string +soliditySha3({type: 'uint256', value: '234'}); +// $ExpectType string +soliditySha3({t: 'uint', v: new BN('234')}); +// $ExpectType string +soliditySha3({t: 'string', v: 'Hello!%'}, {t: 'int8', v: -23}, {t: 'address', v: '0x85F43D8a49eeB85d32Cf465507DD71d507100C1d'}); +// $ExpectType string +soliditySha3('0x407D73d8a49eeb85D32Cf465507dd71d507100c1'); + +// $ExpectError +soliditySha3(['hey']); +// $ExpectError +soliditySha3([34]); +// $ExpectError +soliditySha3(null); +// $ExpectError +soliditySha3(undefined); diff --git a/packages/web3-utils/types/tests/string-to-hex-test.ts b/packages/web3-utils/types/tests/string-to-hex-test.ts new file mode 100644 index 00000000000..a8c4370d344 --- /dev/null +++ b/packages/web3-utils/types/tests/string-to-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file string-to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {stringToHex} from 'web3-utils'; + +// $ExpectType string +stringToHex('I have 100£'); + +// $ExpectError +stringToHex(232); +// $ExpectError +stringToHex(new BN(3)); +// $ExpectError +stringToHex(['string']); +// $ExpectError +stringToHex([4]); +// $ExpectError +stringToHex({}); +// $ExpectError +stringToHex(true); +// $ExpectError +stringToHex(null); +// $ExpectError +stringToHex(undefined); diff --git a/packages/web3-utils/types/tests/strip-hex-prefix-test.ts b/packages/web3-utils/types/tests/strip-hex-prefix-test.ts new file mode 100644 index 00000000000..84a54c5ab04 --- /dev/null +++ b/packages/web3-utils/types/tests/strip-hex-prefix-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file strip-hex-prefix-test.ts + * @author Alejandro Cavallero + * @date 2019 + */ + +import BN = require('bn.js'); +import {stripHexPrefix} from 'web3-utils'; + +// $ExpectType string +stripHexPrefix('0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb'); + +// $ExpectError +stripHexPrefix(123); +// $ExpectError +stripHexPrefix(new BN(3)); +// $ExpectError +stripHexPrefix(['string']); +// $ExpectError +stripHexPrefix([4]); +// $ExpectError +stripHexPrefix({}); +// $ExpectError +stripHexPrefix(true); +// $ExpectError +stripHexPrefix(null); +// $ExpectError +stripHexPrefix(undefined); diff --git a/packages/web3-utils/types/tests/test-address-test.ts b/packages/web3-utils/types/tests/test-address-test.ts new file mode 100644 index 00000000000..8c47a1c91ac --- /dev/null +++ b/packages/web3-utils/types/tests/test-address-test.ts @@ -0,0 +1,62 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file test-address-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {testAddress} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType boolean +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); + +// $ExpectError +testAddress(656, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress(bigNumber, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress(['string'], '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress([4], '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress({}, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress(true, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress(null, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress(undefined, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', 656); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', bigNumber); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', ['string']); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', [4]); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', {}); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', true); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', null); +// $ExpectError +testAddress('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', undefined); diff --git a/packages/web3-utils/types/tests/test-topic-test.ts b/packages/web3-utils/types/tests/test-topic-test.ts new file mode 100644 index 00000000000..5c306083ed8 --- /dev/null +++ b/packages/web3-utils/types/tests/test-topic-test.ts @@ -0,0 +1,62 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file test-topic-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {testTopic} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType boolean +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); + +// $ExpectError +testTopic(656, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic(bigNumber, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic(['string'], '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic([4], '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic({}, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic(true, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic(null, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic(undefined, '0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', 656); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', bigNumber); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', ['string']); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', [4]); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', {}); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', true); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', null); +// $ExpectError +testTopic('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', undefined); diff --git a/packages/web3-utils/types/tests/to-ascii-test.ts b/packages/web3-utils/types/tests/to-ascii-test.ts new file mode 100644 index 00000000000..9d086a2394a --- /dev/null +++ b/packages/web3-utils/types/tests/to-ascii-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-ascii-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toAscii} from 'web3-utils'; + +// $ExpectType string +toAscii('0x4920686176652031303021'); + +// $ExpectError +toAscii(345); +// $ExpectError +toAscii(new BN(3)); +// $ExpectError +toAscii({}); +// $ExpectError +toAscii(true); +// $ExpectError +toAscii(['string']); +// $ExpectError +toAscii([4]); +// $ExpectError +toAscii(null); +// $ExpectError +toAscii(undefined); diff --git a/packages/web3-utils/types/tests/to-bn-test.ts b/packages/web3-utils/types/tests/to-bn-test.ts new file mode 100644 index 00000000000..0df148d7333 --- /dev/null +++ b/packages/web3-utils/types/tests/to-bn-test.ts @@ -0,0 +1,41 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-bn-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import {toBN} from 'web3-utils'; + +// $ExpectType BN +toBN(4); +// $ExpectType BN +toBN('443'); + +// $ExpectError +toBN({}); +// $ExpectError +toBN(true); +// $ExpectError +toBN(['string']); +// $ExpectError +toBN([4]); +// $ExpectError +toBN(null); +// $ExpectError +toBN(undefined); diff --git a/packages/web3-utils/types/tests/to-check-sum-address-test.ts b/packages/web3-utils/types/tests/to-check-sum-address-test.ts new file mode 100644 index 00000000000..a43aa7a8f80 --- /dev/null +++ b/packages/web3-utils/types/tests/to-check-sum-address-test.ts @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-check-sum-address-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toChecksumAddress} from 'web3-utils'; + +// $ExpectType string +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51'); +// $ExpectType string +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', 31); +// $ExpectType string +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', undefined); + +// $ExpectError +toChecksumAddress([4]); +// $ExpectError +toChecksumAddress(['string']); +// $ExpectError +toChecksumAddress(345); +// $ExpectError +toChecksumAddress(new BN(3)); +// $ExpectError +toChecksumAddress({}); +// $ExpectError +toChecksumAddress(true); +// $ExpectError +toChecksumAddress(null); +// $ExpectError +toChecksumAddress(undefined); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', [4]); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', ['string']); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', new BN(3)); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', {}); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', true); +// $ExpectError +toChecksumAddress('0x8ee7f17bb3f88b01247c21ab6603880b64ae53e811f5e01138822e558cf1ab51', null); diff --git a/packages/web3-utils/types/tests/to-decimal-test.ts b/packages/web3-utils/types/tests/to-decimal-test.ts new file mode 100644 index 00000000000..77793f81165 --- /dev/null +++ b/packages/web3-utils/types/tests/to-decimal-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-decimal-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toDecimal} from 'web3-utils'; + +// $ExpectType number +toDecimal('232'); +// $ExpectType number +toDecimal(232); + +// $ExpectError +toDecimal(new BN(3)); +// $ExpectError +toDecimal(['string']); +// $ExpectError +toDecimal([4]); +// $ExpectError +toDecimal({}); +// $ExpectError +toDecimal(true); +// $ExpectError +toDecimal(null); +// $ExpectError +toDecimal(undefined); diff --git a/packages/web3-utils/types/tests/to-hex-test.ts b/packages/web3-utils/types/tests/to-hex-test.ts new file mode 100644 index 00000000000..0c2be5b9709 --- /dev/null +++ b/packages/web3-utils/types/tests/to-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toHex} from 'web3-utils'; + +// $ExpectType string +toHex('234'); +// $ExpectType string +toHex(234); +// $ExpectType string +toHex(new BN(3)); + +// $ExpectError +toHex(['string']); +// $ExpectError +toHex(true); +// $ExpectError +toHex([4]); +// $ExpectError +toHex({}); +// $ExpectError +toHex(null); +// $ExpectError +toHex(undefined); diff --git a/packages/web3-utils/types/tests/to-twos-compement-test.ts b/packages/web3-utils/types/tests/to-twos-compement-test.ts new file mode 100644 index 00000000000..1162976b26f --- /dev/null +++ b/packages/web3-utils/types/tests/to-twos-compement-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-twos-compement-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toTwosComplement} from 'web3-utils'; + +// $ExpectType string +toTwosComplement(4); +// $ExpectType string +toTwosComplement('443'); +// $ExpectType string +toTwosComplement(new BN(3)); + +// $ExpectError +toTwosComplement({}); +// $ExpectError +toTwosComplement(true); +// $ExpectError +toTwosComplement(['string']); +// $ExpectError +toTwosComplement([4]); +// $ExpectError +toTwosComplement(null); +// $ExpectError +toTwosComplement(undefined); diff --git a/packages/web3-utils/types/tests/to-utf8-test.ts b/packages/web3-utils/types/tests/to-utf8-test.ts new file mode 100644 index 00000000000..54c10748f96 --- /dev/null +++ b/packages/web3-utils/types/tests/to-utf8-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-utf8-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toUtf8} from 'web3-utils'; + +// $ExpectType string +toUtf8('0x49206861766520313030e282ac'); + +// $ExpectError +toUtf8(656); +// $ExpectError +toUtf8(new BN(3)); +// $ExpectError +toUtf8(['string']); +// $ExpectError +toUtf8([4]); +// $ExpectError +toUtf8({}); +// $ExpectError +toUtf8(true); +// $ExpectError +toUtf8(null); +// $ExpectError +toUtf8(undefined); diff --git a/packages/web3-utils/types/tests/to-wei-test.ts b/packages/web3-utils/types/tests/to-wei-test.ts new file mode 100644 index 00000000000..ee725b53c04 --- /dev/null +++ b/packages/web3-utils/types/tests/to-wei-test.ts @@ -0,0 +1,50 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file to-wei-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {toWei} from 'web3-utils'; + +const bigNumber = new BN(3); + +// $ExpectType string +toWei('1'); +// $ExpectType BN +toWei(bigNumber); +// $ExpectType string +toWei('1', 'finney'); +// $ExpectType BN +toWei(bigNumber, 'finney'); + +// $ExpectError +toWei(['string']); +// $ExpectError +toWei([4]); +// $ExpectError +toWei({}); +// $ExpectError +toWei(true); +// $ExpectError +toWei(null); +// $ExpectError +toWei(undefined); +// $ExpectError +toWei(1, 'blah'); diff --git a/packages/web3-utils/types/tests/unit-map-test.ts b/packages/web3-utils/types/tests/unit-map-test.ts new file mode 100644 index 00000000000..ab75ed97cc5 --- /dev/null +++ b/packages/web3-utils/types/tests/unit-map-test.ts @@ -0,0 +1,26 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file unit-map-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import {unitMap} from 'web3-utils'; + +// $ExpectType Units +unitMap(); diff --git a/packages/web3-utils/types/tests/utf8-to-hex-test.ts b/packages/web3-utils/types/tests/utf8-to-hex-test.ts new file mode 100644 index 00000000000..116551bc63b --- /dev/null +++ b/packages/web3-utils/types/tests/utf8-to-hex-test.ts @@ -0,0 +1,44 @@ +/* + This file is part of web3.js. + + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file utf8-to-hex-test.ts + * @author Josh Stevens + * @date 2018 + */ + +import BN = require('bn.js'); +import {utf8ToHex} from 'web3-utils'; + +// $ExpectType string +utf8ToHex('I have 100£'); + +// $ExpectError +utf8ToHex(232); +// $ExpectError +utf8ToHex(new BN(3)); +// $ExpectError +utf8ToHex(['string']); +// $ExpectError +utf8ToHex([4]); +// $ExpectError +utf8ToHex({}); +// $ExpectError +utf8ToHex(true); +// $ExpectError +utf8ToHex(null); +// $ExpectError +utf8ToHex(undefined); diff --git a/packages/web3-utils/types/tsconfig.json b/packages/web3-utils/types/tsconfig.json new file mode 100644 index 00000000000..e0200c80d27 --- /dev/null +++ b/packages/web3-utils/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3-utils": ["."] + } + } +} diff --git a/packages/web3-utils/types/tslint.json b/packages/web3-utils/types/tslint.json new file mode 100644 index 00000000000..dc95ea202b8 --- /dev/null +++ b/packages/web3-utils/types/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false + } +} diff --git a/packages/web3/README.md b/packages/web3/README.md index c2eb8d07df9..7efbf2a1860 100644 --- a/packages/web3/README.md +++ b/packages/web3/README.md @@ -11,3 +11,10 @@ Please read the main [readme](https://github.com/ethereum/web3.js) and [document ```bash npm install web3 ``` + +## Types + +All the typescript typings are placed in the types folder. + +[docs]: http://web3js.readthedocs.io/en/1.0/ +[repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3/package-lock.json b/packages/web3/package-lock.json new file mode 100644 index 00000000000..07d69ca98ca --- /dev/null +++ b/packages/web3/package-lock.json @@ -0,0 +1,350 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@types/node": { + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==" + }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==" + }, + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz", + "integrity": "sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + }, + "dtslint": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", + "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#production", + "fs-extra": "^6.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "^5.12.0", + "typescript": "^3.7.0-dev.20191015" + }, + "dependencies": { + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#d957ad0bb2f4ecb60ac04f734e0b38fbc8e70b8a", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + } + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "parsimmon": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", + "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tslint": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", + "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "requires": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.7.0-dev.20191015", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.0-dev.20191015.tgz", + "integrity": "sha512-Cpfj1n4pEUVKL+jtS0mkZodJffyMmf3Wk/UjyZMGX4fsjK5KBPJf3NUlyXij8I8p1E2CAomdS5NPFrAR+z8pKw==" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/packages/web3/package.json b/packages/web3/package.json index 3a414844353..59c75f0db7e 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -18,6 +18,10 @@ "API" ], "author": "ethereum.org", + "types": "types/index.d.ts", + "scripts": { + "dtslint": "dtslint types --onlyTestTsNext" + }, "authors": [ { "name": "Fabian Vogelsteller", @@ -45,6 +49,7 @@ } ], "dependencies": { + "@types/node": "^12.6.1", "web3-bzz": "1.2.1", "web3-core": "1.2.1", "web3-eth": "1.2.1", @@ -52,5 +57,9 @@ "web3-net": "1.2.1", "web3-shh": "1.2.1", "web3-utils": "1.2.1" + }, + "devDependencies": { + "definitelytyped-header-parser": "^1.0.1", + "dtslint": "0.4.2" } } diff --git a/packages/web3/types/index.d.ts b/packages/web3/types/index.d.ts new file mode 100644 index 00000000000..49c4a81cb44 --- /dev/null +++ b/packages/web3/types/index.d.ts @@ -0,0 +1,57 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import * as net from 'net'; +import { Bzz } from 'web3-bzz'; +import { BatchRequest, provider, Providers, Extension } from 'web3-core'; +import { Eth } from 'web3-eth'; +import { Personal } from 'web3-eth-personal'; +import { Network } from 'web3-net'; +import { Shh } from 'web3-shh'; +import { Utils } from 'web3-utils'; + +export default class Web3 { + constructor(provider: provider, net?: net.Socket); + + static modules: Modules; + readonly givenProvider: any; + defaultAccount: string | null; + defaultBlock: string | number; + readonly currentProvider: provider; + setProvider(provider: provider): boolean; + BatchRequest: new () => BatchRequest; + static readonly providers: Providers; + + utils: Utils; + eth: Eth; + shh: Shh; + bzz: Bzz; + version: string; + static readonly version: string; + static readonly utils: Utils; + extend(extension: Extension): any; +} + +export interface Modules { + Eth: new (provider: provider, net: net.Socket) => Eth; + Net: new (provider: provider, net: net.Socket) => Network; + Personal: new (provider: provider, net: net.Socket) => Personal; + Shh: new (provider: provider, net: net.Socket) => Shh; + Bzz: new (provider: provider) => Bzz; +} diff --git a/packages/web3/types/tests/web3-test.ts b/packages/web3/types/tests/web3-test.ts new file mode 100644 index 00000000000..70248de27e9 --- /dev/null +++ b/packages/web3/types/tests/web3-test.ts @@ -0,0 +1,70 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file web3-test.ts + * @author Josh Stevens , Samuel Furter + * @date 2018 + */ + +import Web3 from 'web3'; + +// $ExpectType Utils +Web3.utils; + +// $ExpectType string +Web3.version; + +// $ExpectType Modules +Web3.modules; + +// $ExpectType Providers +Web3.providers; + +const web3 = new Web3('https://localhost:5000/'); + +// $ExpectType provider +web3.currentProvider; + +// $ExpectType any +web3.extend({property: 'test', methods: [{name: 'method', call: 'method'}]}); + +// $ExpectType any +web3.givenProvider; + +// $ExpectType string | null +web3.defaultAccount; + +// $ExpectType string | number +web3.defaultBlock; + +// $ExpectType boolean +web3.setProvider('https://localhost:2100'); + +// $ExpectType BatchRequest +new web3.BatchRequest(); + +// $ExpectType Utils +web3.utils; + +// $ExpectType string +web3.version; + +// $ExpectType Eth +web3.eth; + +// $ExpectType Shh +web3.shh; + +// $ExpectType Bzz +web3.bzz; diff --git a/packages/web3/types/tsconfig.json b/packages/web3/types/tsconfig.json new file mode 100644 index 00000000000..b82402012fa --- /dev/null +++ b/packages/web3/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": false, + "baseUrl": ".", + "paths": { + "web3": ["."] + } + } +} diff --git a/packages/web3/types/tslint.json b/packages/web3/types/tslint.json new file mode 100644 index 00000000000..871d605704b --- /dev/null +++ b/packages/web3/types/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false + } +} diff --git a/scripts/ci.sh b/scripts/ci.sh index 4839ff2d12e..acccf6cdc73 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -8,12 +8,14 @@ if [ "$TEST" = "unit" ]; then npm run build npm run test:unit + npm run dtslint elif [ "$TEST" = "unit_and_e2e" ]; then npm run build npm run test:e2e:all npm run test:unit + npm run dtslint npm run coveralls fi From ba56fc693b3deb9f8fd31798988eca8aba9cb7e6 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Wed, 16 Oct 2019 16:09:09 +0100 Subject: [PATCH 5/5] fix: patch the angular `browser.js` to allow `{crypto: true, stream: true}` (#3136) --- packages/web3/angular-patch.js | 17 +++++++++++++++++ packages/web3/package.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/web3/angular-patch.js diff --git a/packages/web3/angular-patch.js b/packages/web3/angular-patch.js new file mode 100644 index 00000000000..3a76568e4cd --- /dev/null +++ b/packages/web3/angular-patch.js @@ -0,0 +1,17 @@ +const fs = require('fs'); +const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; + +// This is because we have to replace the `node:false` in the `/angular-cli-files/models/webpack-configs/browser.js` +// with `node: {crypto: true, stream: true}` to allow web3 to work with angular (as they enforce node: false.) +// as explained here - https://github.com/ethereum/web3.js/issues/2260#issuecomment-458519127 +if (fs.existsSync(f)) { + fs.readFile(f, 'utf8', function(err, data) { + if (err) { + return console.log(err); + } + var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}'); + fs.writeFile(f, result, 'utf8', function(err) { + if (err) return console.log(err); + }); + }); +} diff --git a/packages/web3/package.json b/packages/web3/package.json index 59c75f0db7e..bdbe2e3520b 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -20,7 +20,8 @@ "author": "ethereum.org", "types": "types/index.d.ts", "scripts": { - "dtslint": "dtslint types --onlyTestTsNext" + "dtslint": "dtslint types --onlyTestTsNext", + "postinstall": "node angular-patch.js" }, "authors": [ {