Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit e832bdb

Browse files
authored
Merge branch '1.x' into backport/2884
2 parents b4c8112 + 2e84152 commit e832bdb

36 files changed

+737
-168
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,23 @@ Released with 1.0.0-beta.37 code base.
5353
### Added
5454

5555
- localStorage support detection added (#3031)
56+
- getNetworkType method extended with Görli testnet (#3095)
57+
- supportsSubscriptions method added to providers (#3116)
58+
- Add `eth.getChainId` method (#3113)
5659

5760
### Fixed
5861

62+
- Fix allow `0` as a valid `fromBlock` or `toBlock` filter param (#1100)
63+
- Fix randomHex returning inconsistent string lengths (#1490)
64+
- Fix make isBN minification safe (#1777)
65+
- Fix incorrect references to BigNumber in utils.fromWei and utils.toWei error messages (#2468)
66+
- Fix error incorrectly thrown when receipt.status is `null` (#2183)
67+
- Fix incorrectly populating chainId param with `net_version` when signing txs (#2378)
5968
- regeneratorRuntime error fixed (#3058)
6069
- Fix accessing event.name where event is undefined (#3014)
70+
- fixed Web3Utils toHex() for Buffer input (#3021)
71+
- Fix bubbling up tx signing errors (#2063, #3105)
72+
- HttpProvider: CORS issue with Firefox and Safari (#2978)
73+
- Ensure the immutability of the `tx` object passed to function `signTransaction` (#2190)
74+
- Gas check fixed (#2381)
75+
- Signing issues #1998, #2033, and #1074 fixed (#3125)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# web3.js - Ethereum JavaScript API
66

77
[![Join the chat at https://gitter.im/ethereum/web3.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/web3.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![npm](https://img.shields.io/npm/dm/web3.svg)](https://www.npmjs.com/package/web3) [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url]
8+
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
89

910
This is the Ethereum [JavaScript API][docs]
1011
which connects to the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec.
@@ -150,7 +151,7 @@ npm test
150151

151152

152153
### Similar libraries in other languages
153-
- Python - [Web3.py](https://github.com/pipermerriam/web3.py)
154+
- Python - [Web3.py](https://github.com/ethereum/web3.py)
154155
- Haskell - [hs-web3](https://github.com/airalab/hs-web3)
155156
- Java - [web3j](https://github.com/web3j/web3j)
156157
- Scala - [web3j-scala](https://github.com/mslinn/web3j-scala)

dist/web3.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/web3-eth-accounts.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Returns
164164
- ``s`` - ``String``: Next 32 bytes of the signature
165165
- ``v`` - ``String``: Recovery value + 27
166166
- ``rawTransaction`` - ``String``: The RLP encoded transaction, ready to be send using :ref:`web3.eth.sendSignedTransaction <eth-sendsignedtransaction>`.
167+
- ``transactionHash`` - ``String``: The transaction hash for the RLP encoded transaction.
167168

168169

169170
-------
@@ -179,11 +180,12 @@ Example
179180
}, '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
180181
.then(console.log);
181182
> {
182-
messageHash: '0x88cfbd7e51c7a40540b233cf68b62ad1df3e92462f1c6018d6d67eae0f3b08f5',
183+
messageHash: '0x31c2f03766b36f0346a850e78d4f7db2d9f4d7d54d5f272a750ba44271e370b1',
183184
v: '0x25',
184185
r: '0xc9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895',
185186
s: '0x727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68',
186187
rawTransaction: '0xf869808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a0c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895a0727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68'
188+
transactionHash: '0xde8db924885b0803d2edc335f745b2b8750c8848744905684c20b987443a9593'
187189
}
188190
189191
web3.eth.accounts.signTransaction({
@@ -201,6 +203,7 @@ Example
201203
s: '0x440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428',
202204
v: '0x25',
203205
rawTransaction: '0xf86a8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a009ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9ca0440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428'
206+
transactionHash: '0xd8f64a42b57be0d565f385378db2f6bf324ce14a594afc05de90436e9ce01f60'
204207
}
205208
206209

docs/web3-eth-contract.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ Parameters
790790

791791
1. ``options`` - ``Object`` (optional): The options used for deployment.
792792
* ``filter`` - ``Object`` (optional): Let you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
793-
* ``fromBlock`` - ``Number`` (optional): The block number from which to get events on.
793+
* ``fromBlock`` - ``Number`` (optional): The block number (greater than or equal to) from which to get events on.
794794
* ``topics`` - ``Array`` (optional): This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically.
795795
2. ``callback`` - ``Function`` (optional): This callback will be fired for each *event* as the second argument, or an error as the first argument.
796796

@@ -893,8 +893,8 @@ Parameters
893893
1. ``event`` - ``String``: The name of the event in the contract, or ``"allEvents"`` to get all events.
894894
2. ``options`` - ``Object`` (optional): The options used for deployment.
895895
* ``filter`` - ``Object`` (optional): Lets you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
896-
* ``fromBlock`` - ``Number`` (optional): The block number from which to get events on.
897-
* ``toBlock`` - ``Number`` (optional): The block number to get events up to (Defaults to ``"latest"``).
896+
* ``fromBlock`` - ``Number`` (optional): The block number (greater than or equal to) from which to get events on.
897+
* ``toBlock`` - ``Number`` (optional): The block number (less than or equal to) to get events up to (Defaults to ``"latest"``).
898898
* ``topics`` - ``Array`` (optional): This allows manually setting the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically.
899899
3. ``callback`` - ``Function`` (optional): This callback will be fired with an array of event logs as the second argument, or an error as the first argument.
900900

docs/web3-eth-net.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ getNetworkType
2525
2626
Guesses the chain the node is connected by comparing the genesis hashes.
2727

28-
.. note:: This is not a 100% accurate guess as any private network could use testnet and mainnet genesis blocks and network IDs.
28+
.. note:: It's recommended to use the :ref:`web3.eth.getChainId <eth-chainId>` method to detect the currently connected chain.
2929

3030
-------
3131
Returns

docs/web3-eth-personal.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ sign
8080
8181
web3.eth.personal.sign(dataToSign, address, password [, callback])
8282
83-
Signs data using a specific account.
83+
The sign method calculates an Ethereum specific signature with:
84+
85+
.. code-block:: javascript
86+
87+
sign(keccak256("\x19Ethereum Signed Message:\n" + dataToSign.length + dataToSign)))
88+
89+
Adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature.
90+
91+
If you have the original message and the signed message, you can discover the signing account address
92+
using :ref:`web3.eth.personal.ecRecover <eth-personal-ecRecover>` (See example below)
93+
8494

8595
.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure.
8696

@@ -119,6 +129,11 @@ Example
119129
.then(console.log);
120130
> "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
121131
132+
// recover the signing account address using original message and signed message
133+
web3.eth.personal.ecRecover("Hello world", "0x30755ed65396...etc...")
134+
.then(console.log);
135+
> "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
136+
122137
123138
------------------------------------------------------------------------------
124139

docs/web3-eth.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,3 +1467,31 @@ Example
14671467
14681468
14691469
------------------------------------------------------------------------------
1470+
1471+
.. _eth-chainId:
1472+
1473+
getChainId
1474+
==========
1475+
1476+
.. code-block:: javascript
1477+
1478+
web3.eth.getChainId([callback])
1479+
1480+
Returns the chain ID of the current connected node as described in the `EIP-695 <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-695.md>`_.
1481+
1482+
-------
1483+
Returns
1484+
-------
1485+
1486+
``Promise<Number>`` - Returns chain ID.
1487+
1488+
-------
1489+
Example
1490+
-------
1491+
1492+
.. code-block:: javascript
1493+
1494+
web3.eth.getChainId().then(console.log);
1495+
> 61
1496+
1497+
------------------------------------------------------------------------------

docs/web3-utils.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ Converts any `ether value <http://ethdocs.org/en/latest/ether.html>`_ value into
975975
Parameters
976976
----------
977977

978-
1. ``number`` - ``String|Number|BN``: The value.
978+
1. ``number`` - ``String|BN``: The value.
979979
2. ``unit`` - ``String`` (optional, defaults to ``"ether"``): The ether to convert from. Possible units are:
980980
- ``noether``: '0'
981981
- ``wei``: '1'
@@ -1009,7 +1009,7 @@ Parameters
10091009
Returns
10101010
-------
10111011

1012-
``String|BN``: If a number, or string is given it returns a number string, otherwise a `BN.js <https://github.com/indutny/bn.js/>`_ instance.
1012+
``String|BN``: If a string is given it returns a number string, otherwise a `BN.js <https://github.com/indutny/bn.js/>`_ instance.
10131013

10141014
-------
10151015
Example
@@ -1049,7 +1049,7 @@ Converts any `wei <http://ethereum.stackexchange.com/questions/253/the-ether-den
10491049
Parameters
10501050
----------
10511051

1052-
1. ``number`` - ``String|Number|BN``: The value in wei.
1052+
1. ``number`` - ``String|BN``: The value in wei.
10531053
2. ``unit`` - ``String`` (optional, defaults to ``"ether"``): The ether to convert to. Possible units are:
10541054
- ``noether``: '0'
10551055
- ``wei``: '1'
@@ -1083,7 +1083,7 @@ Parameters
10831083
Returns
10841084
-------
10851085

1086-
``String|BN``: If a number, or string is given it returns a number string, otherwise a `BN.js <https://github.com/indutny/bn.js/>`_ instance.
1086+
``String``: It always returns a string number.
10871087

10881088
-------
10891089
Example

package-lock.json

Lines changed: 19 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)