Skip to content

Commit

Permalink
web3 external provider - Quicknode (#7019)
Browse files Browse the repository at this point in the history
* providers package init

* types and quick nodes provider

* readme update

* import fixes and unit tests

* lint fix

* lint fix

* added host and quicknodes provider info

* added host

* tests

* lint

* default provider and itests

* package dir rename

* web3-rpc-providers

* web3-rpc-providers in web3

* packagejson updates

* rename test file

* tests in web3 package

* e2e tests update

* lint fix

* empty provider

* empty provider test fix

* lint fix

* default provider tests update

* lint fix
  • Loading branch information
jdevcs committed May 27, 2024
1 parent 962b99f commit 22c07ad
Show file tree
Hide file tree
Showing 36 changed files with 2,338 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/web3-rpc-providers/.eslintignore
7 changes: 7 additions & 0 deletions packages/web3-rpc-providers/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
project: './tsconfig.esm.json',
tsconfigRootDir: __dirname,
},
};
Empty file.
1 change: 1 addition & 0 deletions packages/web3-rpc-providers/.npmignore
1 change: 1 addition & 0 deletions packages/web3-rpc-providers/.npmrc
1 change: 1 addition & 0 deletions packages/web3-rpc-providers/.prettierignore
1 change: 1 addition & 0 deletions packages/web3-rpc-providers/.prettierrc.json
38 changes: 38 additions & 0 deletions packages/web3-rpc-providers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- EXAMPLE
## [1.0.0]
### Added
- I've added feature XY (#1000)
### Changed
- I've cleaned up XY (#1000)
### Deprecated
- I've deprecated XY (#1000)
### Removed
- I've removed XY (#1000)
### Fixed
- I've fixed XY (#1000)
### Security
- I've improved the security in XY (#1000)
-->

## [Unreleased]
58 changes: 58 additions & 0 deletions packages/web3-rpc-providers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<p align="center">
<img src="assets/logo/web3js.jpg" width="500" alt="web3.js" />
</p>

# web3.js - Web3 Providers

![ES Version](https://img.shields.io/badge/ES-2020-yellow)
![Node Version](https://img.shields.io/badge/node-14.x-green)
[![NPM Package][npm-image]][npm-url]
[![Downloads][downloads-image]][npm-url]

This is a sub-package of [web3.js][repo].


## Installation

You can install the package either using [NPM](https://www.npmjs.com/package/web3-rpc-providers) or using [Yarn](https://yarnpkg.com/package/web3-rpc-providers)

### Using NPM

```bash
npm install web3-rpc-providers
```

### Using Yarn

```bash
yarn add web3-rpc-providers
```

## Getting Started

- :writing_hand: If you have questions [submit an issue](https://github.com/ChainSafe/web3.js/issues/new) or join us on [Discord](https://discord.gg/yjyvFRP)
![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord&logo=discord)

## Prerequisites

- :gear: [NodeJS](https://nodejs.org/) (LTS/Fermium)
- :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/)

## Package.json Scripts

| Script | Description |
| ---------------- | -------------------------------------------------- |
| clean | Uses `rimraf` to remove `dist/` |
| build | Uses `tsc` to build package and dependent packages |
| lint | Uses `eslint` to lint package |
| lint:fix | Uses `eslint` to check and fix any warnings |
| format | Uses `prettier` to format the code |
| test | Uses `jest` to run unit tests |
| test:integration | Uses `jest` to run tests under `/test/integration` |
| test:unit | Uses `jest` to run tests under `/test/unit` |

[docs]: https://docs.web3js.org/
[repo]: https://github.com/web3/web3.js/tree/4.x/tools/web3-rpc-providers
[npm-image]: https://img.shields.io/github/package-json/v/web3/web3.js/4.x?filename=tools%2Fweb3-rpc-providers%2Fpackage.json
[npm-url]: https://npmjs.org/package/web3-rpc-providers
[downloads-image]: https://img.shields.io/npm/dm/web3-rpc-providers?label=npm%20downloads
1,516 changes: 1,516 additions & 0 deletions packages/web3-rpc-providers/assets/logo/web3js.ai

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions packages/web3-rpc-providers/assets/logo/web3js.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions packages/web3-rpc-providers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "web3-rpc-providers",
"version": "0.1.0",
"description": "Web3 Providers package",
"main": "./lib/commonjs/index.js",
"module": "./lib/esm/index.js",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/commonjs/index.js"
}
},
"repository": "https://github.com/ChainSafe/web3.js",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
"engines": {
"node": ">=14",
"npm": ">=6.12.0"
},
"files": [
"lib/**/*",
"src/**/*",
"dist/**/*"
],
"scripts": {
"clean": "rimraf dist && rimraf lib",
"prebuild": "yarn clean",
"build": "concurrently --kill-others-on-fail \"yarn:build:*(!check)\"",
"build:cjs": "tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
"format": "prettier --write '**/*'",
"test": "jest --config=./test/unit/jest.config.js",
"test:coverage:unit": "jest --config=./test/unit/jest.config.js --coverage=true --coverage-reporters=text",
"test:ci": "jest --coverage=true --coverage-reporters=json --verbose",
"test:watch": "npm test -- --watch",
"test:unit": "jest --config=./test/unit/jest.config.js",
"test:integration": "jest --config=./test/integration/jest.config.js --passWithNoTests"
},
"devDependencies": {
"@types/jest": "^28.1.6",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"eslint": "^8.20.0",
"eslint-config-base-web3": "0.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"jest": "^29.7.0",
"jest-extended": "^3.0.1",
"prettier": "^2.7.1",
"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
},
"dependencies": {
"web3-providers-http": "^4.1.0",
"web3-providers-ws": "^4.0.7",
"web3-types": "^1.6.0",
"web3-utils": "^4.2.3"
}
}
25 changes: 25 additions & 0 deletions packages/web3-rpc-providers/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

import { QuickNodeProvider } from './web3_provider_quicknode.js';

export * from './types.js';
export * from './web3_provider_quicknode.js';
export * from './web3_provider.js';

// default providers
export const mainnet = new QuickNodeProvider();
44 changes: 44 additions & 0 deletions packages/web3-rpc-providers/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

export enum Transport {
HTTPS = "https",
WebSocket = "wss"
};

export enum Network {
ETH_MAINNET = "eth_mainnet",
ETH_GOERLI = "eth_goerli",
ETH_SEPOLIA = "eth_sepolia",
ETH_HOLESKY = "eth_holesky",

POLYGON_MAINNET= "polygon_mainnet",
POLYGON_MUMBAI= "polygon_mumbai",
POLYGON_AMONY= "polygon_amony",

ARBITRUM_MAINNET = "arbitrum_mainnet",
ARBITRUM_SEPOLIA = "arbitrum_sepolia",

BASE_MAINNET = "base_mainnet",
BASE_SEPOLIA = "base_sepolia",

OPTIMISM_MAINNET = "optimism_mainnet",
OPTIMISM_SEPOLIA = "optimism_sepolia",

BNB_MAINNET = "bnb_mainnet",
BNB_TESTNET = "bnb_testnet"
};
Loading

1 comment on commit 22c07ad

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 22c07ad Previous: 962b99f Ratio
processingTx 9001 ops/sec (±3.80%) 9347 ops/sec (±4.12%) 1.04
processingContractDeploy 39796 ops/sec (±6.39%) 39267 ops/sec (±7.45%) 0.99
processingContractMethodSend 19272 ops/sec (±6.93%) 20364 ops/sec (±6.85%) 1.06
processingContractMethodCall 37949 ops/sec (±6.15%) 41222 ops/sec (±6.07%) 1.09
abiEncode 42825 ops/sec (±6.83%) 46343 ops/sec (±6.97%) 1.08
abiDecode 29000 ops/sec (±8.26%) 30832 ops/sec (±8.28%) 1.06
sign 1556 ops/sec (±1.14%) 1603 ops/sec (±3.74%) 1.03
verify 361 ops/sec (±2.86%) 380 ops/sec (±0.55%) 1.05

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.