Skip to content

Commit

Permalink
Improve the code maintainability by reducing the packages (#5262)
Browse files Browse the repository at this point in the history
* 🏗️ Create web3-types package and distribute the code to relevant packages

* 🎨 Update reference of other packages

* 🚨 Fix all linter errors

* ♻️ Update the types for web3-eth

* 🎨 Update eth types accross the packages

* ✅ Fix failing unit tests

* 🎨 Fix an issue with integration test utility

* 📝 Updat docs references

* ✅ Fix integration tests for web3-eth

* ✅ Fix integration tests for web3 package

* ✏️ Fix an unused type

* 🏷️ Fix few types

* 🏷️ Updated the types for errors package

* Update CHANGELOG.md

Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>

Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>
  • Loading branch information
nazarhussain and Muhammad-Altabba authored Jul 21, 2022
1 parent 5662af6 commit b766282
Show file tree
Hide file tree
Showing 268 changed files with 1,467 additions and 1,501 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,16 @@ Released with 1.0.0-beta.37 code base.
1. Passing callbacks to functions is no longer supported, except for event listeners.
2. Method `extend` is deprecated

#### web3-common
#### web3-core

1. The function `outputBigNumberFormatter` in `web3-core-helper` renamed to `outputBigIntFormatter` under `web3-common`
1. The function `outputBigNumberFormatter` in `web3-core-helper` renamed to `outputBigIntFormatter` under `web3-core`
2. Removed `this.defaultBlock` context from `inputDefaultBlockNumberFormatter` in `web3-core-helper` and converted to additional parameter
3. Removed `this.defaultBlock` context from `inputTransactionFormatter` in `web3-core-helper` and converted to additional parameter

#### web3-utils

1. The following functions `soliditySha3` `soliditySha3Raw` `encodePacked` now includes type validation and requires type specficiation, instead of guessing the value type
2. The functions `soliditySha3` `soliditySha3Raw` `encodePacked` does not support BN and now supports `BigInt`
1. The following functions `soliditySha3` `soliditySha3Raw` `encodePacked` now includes type validation and requires type specification, instead of guessing the value type
2. The functions `soliditySha3`, `soliditySha3Raw` and `encodePacked` did not support BN; But, now supports `BigInt`
3. The functions `flattenTypes` and `jsonInterfaceMethodToString` moved to the `web3-eth-abi` package
4. The function `isAddress` now includes an optional parameter `checkChecksum` type boolean
5. `isBoolean` now accept `1`, and `0` as valid values to test. Ref: `web3-validator`
Expand Down Expand Up @@ -391,7 +391,7 @@ Released with 1.0.0-beta.37 code base.

##### web3-eth-subscribe

1. `clearSubscriptions` Instead of returning `true` , `clearSubscriptions` now returns array of subscription's ids
1. `clearSubscriptions` Instead of returning `true` , `clearSubscriptions` now returns array of subscription's ids

#### web3-eth-personal

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ yarn add web3
| Package | Version | License | Docs | Description |
| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [web3](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | :rotating_light: Entire Web3.js offering (includes all packages) |
| [web3-common](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-common) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-common) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Common data structures and interfaces |
| [web3-core](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-core) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-core) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Core functions for web3.js packages |
| [web3-eth](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-eth) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-eth) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Modules to interact with the Ethereum blockchain and smart contracts |
| [web3-eth-abi](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-eth-abi) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-eth-abi) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Functions for encoding and decoding EVM in/output |
Expand All @@ -46,6 +45,7 @@ yarn add web3
| [web3-providers-ws](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-providers-ws) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-providers-ws) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Web3.js provider for the Websocket protocol |
| [web3-utils](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-utils) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-utils) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Useful utility functions for Dapp developers |
| [web3-validator](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-validator) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-validator) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Utilities for validating objects |
| [web3-types](https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-types) | [![npm](https://img.shields.io/npm/v/web3)](https://www.npmjs.com/package/web3-types) | [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) | [![documentation](https://img.shields.io/badge/typedoc-blue)](https://web3js.readthedocs.io) | Shared useable types |

## Package.json Scripts

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/setting_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const web3 = new Web3('https://eth-mainnet.alchemyapi.io/v2/your-api-key');

The Injected provider should be in compliance with [EIP1193](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md).

Web3.js 4.x Provider specifications are defined in https://github.com/ChainSafe/web3.js/blob/4.x/packages/web3-common/src/web3_base_provider.ts for Injected Providers
Web3.js 4.x Provider specifications are defined in https://github.com/ChainSafe/web3.js/blob/4.x/packages/web3-types/src/web3_base_provider.ts for Injected Providers

### Provider Options

Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const packages = [
'web3-eth-contract',
'web3-utils',
'web3-validator',
'web3-common',
'web3-types',
'web3-core',
'web3-errors',
'web3-net',
Expand Down
302 changes: 0 additions & 302 deletions packages/web3-common/src/types.ts

This file was deleted.

Loading

0 comments on commit b766282

Please sign in to comment.