yarn web3 1.2.7
web3.js 1.2.7

latest releases: 4.10.0, 4.9.1-dev.9086b98.0, 4.9.1-dev.b63af9f.0...
4 years ago

Hi!

Features

Alongside some small bug fixes, this release contains two large improvements, authored by @nivida.

  • The Websocket Provider module has been rewritten and now supports an auto-reconnect option which should dramatically improve the stability of connections to remote clients like Infura. You can enable auto-reconnect by configuring the provider as below.

    const Web3 = require('web3');
    
    const options = {
      // Enable auto reconnection
      reconnect: {
          auto: true,
          delay: 5000, // ms
          maxAttempts: 5,
          onTimeout: false
      }
    };
    
    const ws = new Web3.providers.WebsocketProvider('ws://localhost:8546', options) 

    More info about configuration can be found in the docs here. (PR #3190).

  • The ENS module now allows connection to a custom registry. We've also added support for a large number of additional Registry and Resolver methods. The complete ENS API at Web3 is available in the docs here. (PR #3325).

Note about behavioral change in Geth 1.9.12

Recently in issue #3456 @Aniket-Engg drew attention to an important breaking change in Geth 1.9.12 which affects Web3 users. From their release notes:

eth_call will not default to your first account any more if you don't explicitly specify a sender. This was done to avoid the same input behaving differently in different environments.

This means that if you're:

  • calling view methods that refer to a msg.sender
  • calling estimateGas
  • calling methods with .call

... without explicitly setting a from address in your request options, you may see errors or unexpected behavior.

In Web3.js, the from address can be specified on a per-call basis or by setting the defaultAccount property

// Call
myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});

// Contract
web3.eth.Contract.defaultAccount = '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe';

// Instance
contractInstance.defaultAccount = '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe';

// All
web3.eth.defaultAccount = '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe';

Added

  • Add revert reason support to sendSignedTransaction (#3345)
  • ENS module extended with the possibility to add a custom registry (#3301)
  • Missing ENS Registry methods and Resolver.supportsInterface method added (#3325)
  • Add optional gas type to AbiItem typescript definitions (for ABIs generated by Vyper) (#3437)
  • Add auto-reconnect option for Websockets (#3092, #1085, #1391, #1558, #1852, #1646)

Changed

  • Ensure '0x' prefix is existing for Accounts.sign and Accounts.privateKeyToAccount (#3041)
  • Repository cleanup (#3443)
    • Removed old docs/_build folder
    • Removed old bower and meteor artifacts
    • Moved logo assets to own folder
    • Moved github assets to own folder
  • Remove @types/node from (non-dev) dependency tree (#3965, #3227)

Fixed

  • Add missing subscription.on('connected') TS type definition (#3319)
  • Add missing bignumber.js dependency for TS types (#3386)
  • Upgrade swarm-js to 0.1.40 to remove npm vulnerability warning (#3399)
  • Upgrade devDeps to resolve security warnings (#3464)
    • dtslint 0.4.2 => 3.4.1
    • definitelytyped-header-parser 1.0.1 => 3.9.0
  • Race-condition when subscribing to historical logs as first client request (#3389)
  • Fix crash when using Web-Workers by removing any-promise dependency (#3377 #2211 #1774)

Please don't hesitate to report any problems you see to the issues, and thanks for checking out this new release!

Don't miss a new web3 release

NewReleases is sending notifications on new releases.