Skip to content

Commit

Permalink
Merge branch '1.x' into backport/2884
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Oct 15, 2019
2 parents b4c8112 + 2e84152 commit e832bdb
Show file tree
Hide file tree
Showing 36 changed files with 737 additions and 168 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,23 @@ Released with 1.0.0-beta.37 code base.
### Added

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

### Fixed

- Fix allow `0` as a valid `fromBlock` or `toBlock` filter param (#1100)
- Fix randomHex returning inconsistent string lengths (#1490)
- Fix make isBN minification safe (#1777)
- Fix incorrect references to BigNumber in utils.fromWei and utils.toWei error messages (#2468)
- Fix error incorrectly thrown when receipt.status is `null` (#2183)
- Fix incorrectly populating chainId param with `net_version` when signing txs (#2378)
- regeneratorRuntime error fixed (#3058)
- Fix accessing event.name where event is undefined (#3014)
- fixed Web3Utils toHex() for Buffer input (#3021)
- Fix bubbling up tx signing errors (#2063, #3105)
- HttpProvider: CORS issue with Firefox and Safari (#2978)
- Ensure the immutability of the `tx` object passed to function `signTransaction` (#2190)
- Gas check fixed (#2381)
- Signing issues #1998, #2033, and #1074 fixed (#3125)
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# web3.js - Ethereum JavaScript API

[![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]
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)

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


### Similar libraries in other languages
- Python - [Web3.py](https://github.com/pipermerriam/web3.py)
- 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)
Expand Down
1 change: 0 additions & 1 deletion dist/web3.min.js

This file was deleted.

5 changes: 4 additions & 1 deletion docs/web3-eth-accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Returns
- ``s`` - ``String``: Next 32 bytes of the signature
- ``v`` - ``String``: Recovery value + 27
- ``rawTransaction`` - ``String``: The RLP encoded transaction, ready to be send using :ref:`web3.eth.sendSignedTransaction <eth-sendsignedtransaction>`.
- ``transactionHash`` - ``String``: The transaction hash for the RLP encoded transaction.


-------
Expand All @@ -179,11 +180,12 @@ Example
}, '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
.then(console.log);
> {
messageHash: '0x88cfbd7e51c7a40540b233cf68b62ad1df3e92462f1c6018d6d67eae0f3b08f5',
messageHash: '0x31c2f03766b36f0346a850e78d4f7db2d9f4d7d54d5f272a750ba44271e370b1',
v: '0x25',
r: '0xc9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895',
s: '0x727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68',
rawTransaction: '0xf869808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a0c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895a0727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68'
transactionHash: '0xde8db924885b0803d2edc335f745b2b8750c8848744905684c20b987443a9593'
}
web3.eth.accounts.signTransaction({
Expand All @@ -201,6 +203,7 @@ Example
s: '0x440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428',
v: '0x25',
rawTransaction: '0xf86a8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a009ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9ca0440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428'
transactionHash: '0xd8f64a42b57be0d565f385378db2f6bf324ce14a594afc05de90436e9ce01f60'
}
Expand Down
6 changes: 3 additions & 3 deletions docs/web3-eth-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ Parameters

1. ``options`` - ``Object`` (optional): The options used for deployment.
* ``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.
* ``fromBlock`` - ``Number`` (optional): The block number from which to get events on.
* ``fromBlock`` - ``Number`` (optional): The block number (greater than or equal to) from which to get events on.
* ``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.
2. ``callback`` - ``Function`` (optional): This callback will be fired for each *event* as the second argument, or an error as the first argument.

Expand Down Expand Up @@ -893,8 +893,8 @@ Parameters
1. ``event`` - ``String``: The name of the event in the contract, or ``"allEvents"`` to get all events.
2. ``options`` - ``Object`` (optional): The options used for deployment.
* ``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.
* ``fromBlock`` - ``Number`` (optional): The block number from which to get events on.
* ``toBlock`` - ``Number`` (optional): The block number to get events up to (Defaults to ``"latest"``).
* ``fromBlock`` - ``Number`` (optional): The block number (greater than or equal to) from which to get events on.
* ``toBlock`` - ``Number`` (optional): The block number (less than or equal to) to get events up to (Defaults to ``"latest"``).
* ``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.
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.

Expand Down
2 changes: 1 addition & 1 deletion docs/web3-eth-net.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ getNetworkType
Guesses the chain the node is connected by comparing the genesis hashes.

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

-------
Returns
Expand Down
17 changes: 16 additions & 1 deletion docs/web3-eth-personal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,17 @@ sign
web3.eth.personal.sign(dataToSign, address, password [, callback])
Signs data using a specific account.
The sign method calculates an Ethereum specific signature with:

.. code-block:: javascript
sign(keccak256("\x19Ethereum Signed Message:\n" + dataToSign.length + dataToSign)))
Adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature.

If you have the original message and the signed message, you can discover the signing account address
using :ref:`web3.eth.personal.ecRecover <eth-personal-ecRecover>` (See example below)


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

Expand Down Expand Up @@ -119,6 +129,11 @@ Example
.then(console.log);
> "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
// recover the signing account address using original message and signed message
web3.eth.personal.ecRecover("Hello world", "0x30755ed65396...etc...")
.then(console.log);
> "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
------------------------------------------------------------------------------

Expand Down
28 changes: 28 additions & 0 deletions docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1467,3 +1467,31 @@ Example
------------------------------------------------------------------------------

.. _eth-chainId:

getChainId
==========

.. code-block:: javascript
web3.eth.getChainId([callback])
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>`_.

-------
Returns
-------

``Promise<Number>`` - Returns chain ID.

-------
Example
-------

.. code-block:: javascript
web3.eth.getChainId().then(console.log);
> 61
------------------------------------------------------------------------------
8 changes: 4 additions & 4 deletions docs/web3-utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ Converts any `ether value <http://ethdocs.org/en/latest/ether.html>`_ value into
Parameters
----------

1. ``number`` - ``String|Number|BN``: The value.
1. ``number`` - ``String|BN``: The value.
2. ``unit`` - ``String`` (optional, defaults to ``"ether"``): The ether to convert from. Possible units are:
- ``noether``: '0'
- ``wei``: '1'
Expand Down Expand Up @@ -1009,7 +1009,7 @@ Parameters
Returns
-------

``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.
``String|BN``: If a string is given it returns a number string, otherwise a `BN.js <https://github.com/indutny/bn.js/>`_ instance.

-------
Example
Expand Down Expand Up @@ -1049,7 +1049,7 @@ Converts any `wei <http://ethereum.stackexchange.com/questions/253/the-ether-den
Parameters
----------

1. ``number`` - ``String|Number|BN``: The value in wei.
1. ``number`` - ``String|BN``: The value in wei.
2. ``unit`` - ``String`` (optional, defaults to ``"ether"``): The ether to convert to. Possible units are:
- ``noether``: '0'
- ``wei``: '1'
Expand Down Expand Up @@ -1083,7 +1083,7 @@ Parameters
Returns
-------

``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.
``String``: It always returns a string number.

-------
Example
Expand Down
61 changes: 19 additions & 42 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions packages/web3-core-helpers/src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ var outputTransactionReceiptFormatter = function (receipt){
receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress);
}

if(typeof receipt.status !== 'undefined') {
if(typeof receipt.status !== 'undefined' && receipt.status !== null) {
receipt.status = Boolean(parseInt(receipt.status));
}

Expand Down Expand Up @@ -279,10 +279,10 @@ var inputLogFormatter = function(options) {
return utils.fromUtf8(value);
};

if (options.fromBlock)
if (options.fromBlock || options.fromBlock === 0)
options.fromBlock = inputBlockNumberFormatter(options.fromBlock);

if (options.toBlock)
if (options.toBlock || options.toBlock === 0)
options.toBlock = inputBlockNumberFormatter(options.toBlock);


Expand Down
13 changes: 11 additions & 2 deletions packages/web3-core-method/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
if (!isContractDeployment && !promiseResolved) {

if(!receipt.outOfGas &&
(!gasProvided || gasProvided !== receipt.gasUsed) &&
(!gasProvided || gasProvided !== utils.numberToHex(receipt.gasUsed)) &&
(receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) {
defer.eventEmitter.emit('receipt', receipt);
defer.resolve(receipt);
Expand Down Expand Up @@ -533,7 +533,16 @@ Method.prototype.buildCall = function() {

// If wallet was found, sign tx, and send using sendRawTransaction
if (wallet && wallet.privateKey) {
return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey).then(sendSignedTx);
return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey)
.then(sendSignedTx)
.catch(function (err) {
if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) {
defer.eventEmitter.emit('error', err);
defer.eventEmitter.removeAllListeners();
defer.eventEmitter.catch(function () {});
}
defer.reject(err);
});
}

// ETH_SIGN
Expand Down

0 comments on commit e832bdb

Please sign in to comment.