From 6016cdf75b0897934d4611da3c7822064e3d301a Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Sat, 26 Jan 2019 20:31:03 +0100 Subject: [PATCH 1/4] web3 module options to include_package-core added --- docs/include_package-core.rst | 211 ++++++++++++++++++- packages/web3-core/src/AbstractWeb3Module.js | 2 +- 2 files changed, 211 insertions(+), 2 deletions(-) diff --git a/docs/include_package-core.rst b/docs/include_package-core.rst index 092fd5507e4..acb289a9356 100644 --- a/docs/include_package-core.rst +++ b/docs/include_package-core.rst @@ -1,4 +1,49 @@ +Web3 Module Options +===================== + +An Web3 module does provide several options for configuring the transaction confirmation worklfow or for defining +default values. These are the currently available option properties on a Web3 module: + +-------------- +Module Options +-------------- + +:ref:`defaultAccount ` + +:ref:`defaultBlock ` + +:ref:`defaultGas ` + +:ref:`defaultGasPrice ` + +:ref:`transactionBlockTimeout ` + +:ref:`transactionConfirmationBlocks ` + +:ref:`transactionPollingTimeout ` + +------- +Example +------- + +.. code-block:: javascript + + import Web3 from 'web3'; + + const options = { + defaultAccount: '0x0', + defaultBlock: 'latest', + defaultGas: 1, + defaultGasPrice: 0, + transactionBlockTimeout: 50, + transactionConfirmationBlocks: 24, + transactionPollingTimeout: 480 + } + + const web3 = new Web3('http://localhost:8545', options); + +------------------------------------------------------------------------------ setProvider ===================== @@ -175,7 +220,7 @@ BatchRequest new web3.BatchRequest() new web3.eth.BatchRequest() new web3.shh.BatchRequest() - new web3.bzz.BatchRequest() + ... Class to create and execute batch requests. @@ -206,3 +251,167 @@ Example batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback)); batch.add(contract.methods.balance(address).call.request({from: '0x0000000000000000000000000000000000000000'}, callback2)); batch.execute(); + +------------------------------------------------------------------------------ + +.. _web3-module-defaultblock: + +defaultBlock +===================== + +.. code-block:: javascript + + web3.defaultBlock + web3.eth.defaultBlock + web3.shh.defaultBlock + ... + +The default block which will be used for a requests. + +------- +Returns +------- + +``string|number``: The current value of the defaultBlock property. + +------------------------------------------------------------------------------ + +.. _web3-module-defaultaccount: + +defaultBlock +===================== + +.. code-block:: javascript + + web3.defaultAccount + web3.eth.defaultAccount + web3.shh.defaultAccount + ... + +The default account which will be used for a requests. + +------- +Returns +------- + +``null|string``: The current value of the defaultAccount property. + +------------------------------------------------------------------------------ + +.. _web3-module-defaultgasprice: + +defaultGasPrice +===================== + +.. code-block:: javascript + + web3.defaultGasPrice + web3.eth.defaultGasPrice + web3.shh.defaultGasPrice + ... + +The default gas price which will be used for call requests. + +------- +Returns +------- + +``string|number``: The current value of the defaultGasPrice property. + + +------------------------------------------------------------------------------ + +.. _web3-module-defaultgas: + +defaultGas +===================== + +.. code-block:: javascript + + web3.defaultGas + web3.eth.defaultGas + web3.shh.defaultGas + ... + +The default gas which will be used for call requests. + +------- +Returns +------- + +``string|number``: The current value of the defaultGas property. + +------------------------------------------------------------------------------ + +.. _web3-module-transactionblocktimeout: + +transactionBlockTimeout +===================== + +.. code-block:: javascript + + web3.transactionBlockTimeout + web3.eth.transactionBlockTimeout + web3.shh.transactionBlockTimeout + ... + +This can be used with a socket provider and defines the number of blocks until the PromiEvent +rejects with a timeout error. + + +------- +Returns +------- + +``number``: The current value of transactionBlockTimeout + +------------------------------------------------------------------------------ + +.. _web3-module-transactionconfirmationblocks: + +transactionConfirmationBlocks +===================== + +.. code-block:: javascript + + web3.transactionConfirmationBlocks + web3.eth.transactionConfirmationBlocks + web3.shh.transactionConfirmationBlocks + ... + +This defines the number of blocks it requires until a transaction will be handled as confirmed. +The PromiEvent will resolve with the desired receipt when enough confirmations happened. + + +------- +Returns +------- + +``number``: The current value of transactionConfirmationBlocks + +------------------------------------------------------------------------------ + + +.. _web3-module-transactionpollingtimeout: + +transactionPollingTimeout +===================== + +.. code-block:: javascript + + web3.transactionPollingTimeout + web3.eth.transactionPollingTimeout + web3.shh.transactionPollingTimeout + ... + +This defines the polling cycles amount when you send a transaction with the HttpProvider. +The PromiEvent rejects with a timeout error when the timeout got exceeded. (1 cycle == 1sec.). + + +------- +Returns +------- + +``number``: The current value of transactionPollingTimeout + +------------------------------------------------------------------------------ diff --git a/packages/web3-core/src/AbstractWeb3Module.js b/packages/web3-core/src/AbstractWeb3Module.js index 4221d23ab5e..0b951f6150c 100644 --- a/packages/web3-core/src/AbstractWeb3Module.js +++ b/packages/web3-core/src/AbstractWeb3Module.js @@ -70,7 +70,7 @@ export default class AbstractWeb3Module { * * @property defaultBlock * - * @returns {null|String} + * @returns {String|Number} */ get defaultBlock() { return this._defaultBlock; From 259ae558f41698c5ab974db26cf7440d9d9810ab Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Sat, 26 Jan 2019 22:21:06 +0100 Subject: [PATCH 2/4] formatting and explaination of the options improved in 'docs/include_packge-core.rst' --- docs/include_package-core.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/include_package-core.rst b/docs/include_package-core.rst index acb289a9356..098897537f9 100644 --- a/docs/include_package-core.rst +++ b/docs/include_package-core.rst @@ -2,8 +2,8 @@ Web3 Module Options ===================== -An Web3 module does provide several options for configuring the transaction confirmation worklfow or for defining -default values. These are the currently available option properties on a Web3 module: +An Web3 module does provide several options for configuring the transaction confirmation worklfow or for defining default values. +These are the currently available option properties on a Web3 module: -------------- Module Options @@ -310,7 +310,7 @@ defaultGasPrice web3.shh.defaultGasPrice ... -The default gas price which will be used for call requests. +The default gas price which will be used for a request. ------- Returns @@ -333,7 +333,7 @@ defaultGas web3.shh.defaultGas ... -The default gas which will be used for call requests. +The default gas which will be used for a request. ------- Returns From 2d8c551749b1cbc886276d612664e88894090be2 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Sat, 26 Jan 2019 22:46:35 +0000 Subject: [PATCH 3/4] fix: `signTransaction` should return ` Promise` --- packages/web3-eth-accounts/types/index.d.ts | 2 +- packages/web3-eth-accounts/types/tests/accounts-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web3-eth-accounts/types/index.d.ts b/packages/web3-eth-accounts/types/index.d.ts index e5cb1a7167b..c6a0ab44d9f 100644 --- a/packages/web3-eth-accounts/types/index.d.ts +++ b/packages/web3-eth-accounts/types/index.d.ts @@ -30,7 +30,7 @@ export class Accounts extends AbstractWeb3Module { privateKeyToAccount(privateKey: string): Account; - signTransaction(tx: Transaction, privateKey: string, callback?: () => void): SignedTransaction; + signTransaction(tx: Transaction, privateKey: string, callback?: () => void): Promise; recoverTransaction(signature: string): string; diff --git a/packages/web3-eth-accounts/types/tests/accounts-tests.ts b/packages/web3-eth-accounts/types/tests/accounts-tests.ts index ad92d0202c7..78dcd8ec07f 100644 --- a/packages/web3-eth-accounts/types/tests/accounts-tests.ts +++ b/packages/web3-eth-accounts/types/tests/accounts-tests.ts @@ -28,14 +28,14 @@ accounts.create('2435@#@#@±±±±!!!!678543213456764321§3456754321345678543213 // $ExpectType Account accounts.privateKeyToAccount('0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709'); -// $ExpectType SignedTransaction +// $ExpectType Promise accounts.signTransaction({ to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', value: '1000000000', gas: 2000000 }, '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318'); -// $ExpectType SignedTransaction +// $ExpectType Promise accounts.signTransaction({ to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', value: '1000000000', From 611c48ca50582e7d182caa4fdf2194c164ba7f5b Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Sun, 27 Jan 2019 00:49:28 +0000 Subject: [PATCH 4/4] fix: install `@types/node` so you do not need to add types > node in `tsconfig.json` --- packages/web3-bzz/package-lock.json | 13 +++++++++++++ packages/web3-bzz/package.json | 1 + packages/web3-core/package-lock.json | 13 +++++++++++++ packages/web3-core/package.json | 1 + packages/web3-providers/package-lock.json | 13 +++++++++++++ packages/web3-providers/package.json | 1 + packages/web3-utils/package-lock.json | 13 +++++++++++++ packages/web3-utils/package.json | 1 + packages/web3/package-lock.json | 13 +++++++++++++ packages/web3/package.json | 1 + 10 files changed, 70 insertions(+) create mode 100644 packages/web3-bzz/package-lock.json create mode 100644 packages/web3-core/package-lock.json create mode 100644 packages/web3-providers/package-lock.json create mode 100644 packages/web3-utils/package-lock.json create mode 100644 packages/web3/package-lock.json diff --git a/packages/web3-bzz/package-lock.json b/packages/web3-bzz/package-lock.json new file mode 100644 index 00000000000..576ccccae72 --- /dev/null +++ b/packages/web3-bzz/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "web3-bzz", + "version": "1.0.0-beta.38", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + } + } +} diff --git a/packages/web3-bzz/package.json b/packages/web3-bzz/package.json index e1ac4ebe16e..65c8460fff1 100644 --- a/packages/web3-bzz/package.json +++ b/packages/web3-bzz/package.json @@ -16,6 +16,7 @@ "dtslint": "dtslint types --onlyTestTsNext" }, "dependencies": { + "@types/node": "^10.12.18", "lodash": "^4.17.11", "swarm-js": "^0.1.39" }, diff --git a/packages/web3-core/package-lock.json b/packages/web3-core/package-lock.json new file mode 100644 index 00000000000..1364add26f8 --- /dev/null +++ b/packages/web3-core/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "web3-core", + "version": "1.0.0-beta.38", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + } + } +} diff --git a/packages/web3-core/package.json b/packages/web3-core/package.json index eab2d89a910..cc1e90cbe55 100644 --- a/packages/web3-core/package.json +++ b/packages/web3-core/package.json @@ -16,6 +16,7 @@ "dtslint": "dtslint types --onlyTestTsNext" }, "dependencies": { + "@types/node": "^10.12.18", "lodash": "^4.17.11", "web3-utils": "1.0.0-beta.38" }, diff --git a/packages/web3-providers/package-lock.json b/packages/web3-providers/package-lock.json new file mode 100644 index 00000000000..1688e611568 --- /dev/null +++ b/packages/web3-providers/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "web3-providers", + "version": "1.0.0-beta.38", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + } + } +} diff --git a/packages/web3-providers/package.json b/packages/web3-providers/package.json index cec60e07b43..d4f70e8cf66 100644 --- a/packages/web3-providers/package.json +++ b/packages/web3-providers/package.json @@ -16,6 +16,7 @@ }, "types": "types", "dependencies": { + "@types/node": "^10.12.18", "eventemitter3": "3.1.0", "lodash": "^4.17.11", "oboe": "2.1.4", diff --git a/packages/web3-utils/package-lock.json b/packages/web3-utils/package-lock.json new file mode 100644 index 00000000000..ab0c495cd3d --- /dev/null +++ b/packages/web3-utils/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "web3-utils", + "version": "1.0.0-beta.38", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + } + } +} diff --git a/packages/web3-utils/package.json b/packages/web3-utils/package.json index e224f9c135b..186dfb315c9 100644 --- a/packages/web3-utils/package.json +++ b/packages/web3-utils/package.json @@ -16,6 +16,7 @@ }, "types": "types", "dependencies": { + "@types/node": "^10.12.18", "bn.js": "4.11.8", "eth-lib": "0.2.8", "ethjs-unit": "^0.1.6", diff --git a/packages/web3/package-lock.json b/packages/web3/package-lock.json new file mode 100644 index 00000000000..c30742dc8d6 --- /dev/null +++ b/packages/web3/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "web3", + "version": "1.0.0-beta.38", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + } + } +} diff --git a/packages/web3/package.json b/packages/web3/package.json index b14d6587373..18a02dcbdad 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -56,6 +56,7 @@ }, "types": "types", "dependencies": { + "@types/node": "^10.12.18", "web3-bzz": "1.0.0-beta.38", "web3-core": "1.0.0-beta.38", "web3-core-helpers": "1.0.0-beta.38",