# Release: 0x.js 2.0.0 Things you need to know

**URL:** <https://forum.0xprotocol.org/t/release-0x-js-2-0-0-things-you-need-to-know/207>\
**Category:** Non-core protocol\
**Created:** [October 22, 2018, 9:51pm UTC](https://forum.0xprotocol.org/t/release-0x-js-2-0-0-things-you-need-to-know/207 "2018-10-22T21:51:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dekz](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.0xprotocol.org/dekz/32/38_2.png) [@dekz](https://forum.0xprotocol.org/u/dekz)\
**Post date:** [October 22, 2018, 9:51pm UTC](https://forum.0xprotocol.org/t/release-0x-js-2-0-0-things-you-need-to-know/207/1 "2018-10-22T21:51:21Z")

</div>

Hey everyone!

We’ve recently published [0x.js 2.0.0, order-utils 2.0.0 and web3-wrapper 3.1.0](https://github.com/0xProject/0x-monorepo/releases/tag/monorepo%408b62b35).

Below are a list of major changes, but be sure to read through the general [CHANGELOG](https://github.com/0xProject/0x-monorepo/releases/tag/monorepo%408b62b35) for the exhaustive list of changes.

### Moved to a new NPM organisation

Our packages have moved to a new NPM organisation. Where previously you would use `@0xproject` from this release onwards new versions will now be published under `@0x`.

```auto
@0x/web3-wrapper
@0x/order-utils
@0x/subproviders
@0x/types
// etc

```

### EIP712 Sign Typed Data

This had brought `eth_signTypedData` support to our packages, which means your users can now start to see the data they are signing. Currently this is supported in the latest version of Metamask 4.14.0.

 ![screen shot 2018-10-20 at 9 56 40 am](https://canada1.discourse-cdn.com/flex027/uploads/x0xproject/original/1X/93edddb0cee47012d2b9e5f6dedb89c0ce11bf7b.png)

With this release there are a few changes to the way signing behaves.

Firstly, we are introducing `MetamaskSubprovider` which is exported from 0x.js and the subproviders package. This is a compatibility wrapper for Metamask, so if your users use Metamask, you _must_ use the MetamaskSubprovider.

This removes the previous `SignerType` where you would need to supply either `SignerType.Metamask` or `SignerType.Default`.

So, if you’re used to using `web3.currentProvider` whenever an order needs to be signed, this will need to be wrapped in `MetamaskSubprovider`.

### Example - Signing with Metamask

```typescript
// If metamask, wrap in the compatibility wrapper (due to bugs in Metamask)
const provider = new MetamaskSubprovider(web3.currentProvider)
const contractWrappers = new ContractWrappers(provider, { networkId });
....
const signedOrder = await signatureUtils.ecSignOrderAsync(provider, order, makerAddress);

```

### Example - Handling multiple web3 browsers (like Coinbase Wallet)

Only the Metamask injected Web3 needs to be wrapped, other web3 browsers and wallets behave correctly.

```typescript
// If metamask, wrap in the compatibility wrapper (due to bugs in Metamask)
const provider = (web3.currentProvider as any).isMetaMask
                    ? new MetamaskSubprovider(web3.currentProvider)
                    : web3.currentProvider;
const contractWrappers = new ContractWrappers(provider, { networkId });
....
const signedOrder = await signatureUtils.ecSignOrderAsync(provider, order, makerAddress);

```

### Example - Provider Engine and multiple web3 browsers

```typescript
const providerEngine = new Web3ProviderEngine();
const signer = (web3.currentProvider as any).isMetaMask
                    ? new MetamaskSubprovider(web3.currentProvider)
                    : new SignerSubprovider(web3.currentProvider);

const rpcProvider = new RPCSubprovider(rpcURI);
// Add the signer first, all account based requests are handled by the signer
providerEngine.addProvider(signer);
// Add the data provider, all logs, data fetching are handled by the rpcProvider
providerEngine.addProvider(rpcProvider);
providerEngine.start();

const provider = providerEngine;
const web3Wrapper = new Web3Wrapper(provider);
const contractWrappers = new ContractWrappers(provider, { networkId });

```

### New ways to Sign

Since there will be intermittent support of `eth_signTypedData` from the various web3 wallets and browsers, we have provided a helper function `ecSignOrderAsync`. It will first attempt `eth_signTypedData` and then fall back to the previous `eth_sign` of the order hash. This function returns a `SignedOrder`.

```typescript
const signedOrder = await signatureUtils.ecSignOrderAsync(provider, order, makerAddress);

```

If you would like to use `eth_signTypedData` only, this can be done by using `ecSignTypedDataOrderAsync`.

```typescript
// EIP712 signTypedData ONLY
const signedOrder = await signatureUtils.ecSignTypedDataOrderAsync(provider, order, makerAddress);

```

We have renamed `ecSignOrderHashAsync` to `ecSignHashAsync` as this function can be used to sign more than just an order hash (like 0x transactions or any hash data). `SignerType` has been removed (so remember to wrap Metamask web3 in the compatibility wrapper). This uses `eth_sign` implementation and behaves as it did in previous versions.

```typescript
const signature = await signatireUtils.ecSignHashAsync(provider, hash, makerAddress);

```

### Resolving contract addresses

A new package `@0x/contract-addresses` has been published and contains a lookup for the deployed contracts on a given network. Previous functions for resolving addresses have been removed form `contract-wrappers`. Though they can be found as properties on the contract, or via a lookup.

```typescript
// Removed
contractWrappers.etherToken.getContractAddressIfExists()

// Added
import { ContractAddresses, getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
const contractAddresses = getContractAddressesForNetworkOrThrow(networkId);
contractAddresses.etherToken
// Some addresses are now properties in contract-wrappers
contractWrappers.exchange.address

```

Be sure to read through the general [CHANGELOG](https://github.com/0xProject/0x-monorepo/releases/tag/monorepo%408b62b35) for the exhaustive list of changes.

Any questions bugs or problems, reach out in this [Github issue](https://github.com/0xProject/0x-monorepo/issues/1169) or in our [Rocket chat](https://chat.0xproject.com/channel/dev).

---

<div class="post-metadata">

**Author:** ![brentoshiro](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.0xprotocol.org/brentoshiro/32/1129_2.png) [@brentoshiro](https://forum.0xprotocol.org/u/brentoshiro)\
**Post date:** [February 26, 2020, 12:13am UTC](https://forum.0xprotocol.org/t/release-0x-js-2-0-0-things-you-need-to-know/207/2 "2020-02-26T00:13:12Z")

</div>


