Skip to content

Commit

Permalink
Merge branch '1.0' into fix/types/web3-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida authored Jan 27, 2019
2 parents 4affdb3 + 599c52e commit 2b01bf5
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 5 deletions.
211 changes: 210 additions & 1 deletion docs/include_package-core.rst
Original file line number Diff line number Diff line change
@@ -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 <web3-module-defaultaccount>`

:ref:`defaultBlock <web3-module-defaultblock>`

:ref:`defaultGas <web3-module-defaultgas>`

:ref:`defaultGasPrice <web3-module-defaultaccount>`

:ref:`transactionBlockTimeout <web3-module-transactionblocktimeout>`

:ref:`transactionConfirmationBlocks <web3-module-transactionconfirmationblocks>`

:ref:`transactionPollingTimeout <web3-module-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
=====================
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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 a request.

-------
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 a request.

-------
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

------------------------------------------------------------------------------
13 changes: 13 additions & 0 deletions packages/web3-bzz/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-bzz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dtslint": "dtslint types --onlyTestTsNext"
},
"dependencies": {
"@types/node": "^10.12.18",
"lodash": "^4.17.11",
"swarm-js": "^0.1.39"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/web3-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-core/src/AbstractWeb3Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class AbstractWeb3Module {
*
* @property defaultBlock
*
* @returns {null|String}
* @returns {String|Number}
*/
get defaultBlock() {
return this._defaultBlock;
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SignedTransaction>;

recoverTransaction(signature: string): string;

Expand Down
4 changes: 2 additions & 2 deletions packages/web3-eth-accounts/types/tests/accounts-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ accounts.create('2435@#@#@±±±±!!!!678543213456764321§3456754321345678543213
// $ExpectType Account
accounts.privateKeyToAccount('0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709');

// $ExpectType SignedTransaction
// $ExpectType Promise<SignedTransaction>
accounts.signTransaction({
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
value: '1000000000',
gas: 2000000
}, '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318');

// $ExpectType SignedTransaction
// $ExpectType Promise<SignedTransaction>
accounts.signTransaction({
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
value: '1000000000',
Expand Down
13 changes: 13 additions & 0 deletions packages/web3-providers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"types": "types",
"dependencies": {
"@types/node": "^10.12.18",
"eventemitter3": "3.1.0",
"lodash": "^4.17.11",
"oboe": "2.1.4",
Expand Down
13 changes: 13 additions & 0 deletions packages/web3-utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions packages/web3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2b01bf5

Please sign in to comment.