Catalog npm
Back to packageRELEASE DETAILS

0.0.4

npm

@0x/web3-providers-fork

Web3 module to handle requests to external providers.

Published17 Jul 2019
Direct dependencies13
Transitive dependenciesNot calculated

README

Current package documentation

web3-providers

This is a sub module of web3.js

Installation

npm install web3-providers

Usage Examples

HttpProvider

You can pass with the options object the timeout and all known HTTP headers.

import {HttpProvider} from 'web3-providers';

const options = {
    timeout: 20000,
    headers: [
        {
            name: 'Access-Control-Allow-Origin', value: '*'
        },
        ...
    ]
};

const httpProvider = new HttpProvider('http://localhost:8545', options); 

WebsocketProvider

Instead of setting a authorization header you could also define the credentials over the URL with: ws://username:password@localhost:8546

import {WebsocketProvider} from 'web3-providers';
const credentials = Buffer.from('username:password').toString('base64')
const options = { 
    timeout: 30000, 
    headers: {
        authorization: `Basic ${credentials}`
    }
};
 
const websocketProvider = new WebsocketProvider('ws://localhost:8546', options);

IpcProvider

import {IpcProvider} from 'web3-providers';
import net from 'net';

const ipcProvider = new IpcProvider('/Users/me/Library/Ethereum/geth.ipc', net);

BatchRequest

The BatchRequest provides the possibility to send JSON-RPC requests as batch. Please read the documentation for more.

import {ProviderResolver, BatchRequest} 'web3-providers';

const provider = new ProviderResolver().resolve('ws://localhost:8546');
const batchRequest = new BatchRequest(provider);

batchRequest.add(web3.eth.getBalance.request(
    '0x0000000000000000000000000000000000000000',
    'latest',
    callback
));

await batchRequest.execute();

ProviderDetector

Checks if an provider is given from the environment (Mist, MetaMask) and returns the provider.

import {ProviderDetector} from 'web3-providers';

const givenProvider = ProviderDetector.detect();

ProviderResolver

The ProviderResolver resolves an url or an given provider object to the correct provider class. Because of the resolves does web3 has internally just one provider interface and we have no direct dependency to third party providers.

import {ProviderResolver} 'web3-providers';

const socketProviderAdapter = new ProviderResolver().resolve('ws://localhost:8546');

Types

All the typescript typings are placed in the types folder.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 13

Native requirements
13 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
lodash
Environment
{
  "local_name": "lodash",
  "alias": false,
  "peer_metadata": null
}
^4.17.11runtime
url-parse
Environment
{
  "local_name": "url-parse",
  "alias": false,
  "peer_metadata": null
}
1.4.4runtime
web3-core
Environment
{
  "local_name": "web3-core",
  "alias": false,
  "peer_metadata": null
}
2.0.0-alpharuntime
websocket
Environment
{
  "local_name": "websocket",
  "alias": false,
  "peer_metadata": null
}
^1.0.28runtime
web3-utils
Environment
{
  "local_name": "web3-utils",
  "alias": false,
  "peer_metadata": null
}
2.0.0-alpharuntime
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^10.12.18runtime
xhr2-cookies
Environment
{
  "local_name": "xhr2-cookies",
  "alias": false,
  "peer_metadata": null
}
1.1.0runtime
eventemitter3
Environment
{
  "local_name": "eventemitter3",
  "alias": false,
  "peer_metadata": null
}
3.1.0runtime
@babel/runtime
Environment
{
  "local_name": "@babel/runtime",
  "alias": false,
  "peer_metadata": null
}
^7.3.1runtime
web3-core-method
Environment
{
  "local_name": "web3-core-method",
  "alias": false,
  "peer_metadata": null
}
2.0.0-alpharuntime
web3-core-helpers
Environment
{
  "local_name": "web3-core-helpers",
  "alias": false,
  "peer_metadata": null
}
2.0.0-alpharuntime
dtslint
Environment
{
  "local_name": "dtslint",
  "alias": false,
  "peer_metadata": null
}
0.4.2development
definitelytyped-header-parser
Environment
{
  "local_name": "definitelytyped-header-parser",
  "alias": false,
  "peer_metadata": null
}
^1.0.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "c5dc078e0b404c35b40c305bff2b098a017956e3",
  "tarball": "https://registry.npmjs.org/@0x/web3-providers-fork/-/web3-providers-fork-0.0.4.tgz",
  "fileCount": 9,
  "integrity": "sha512-Z0A0AAXQ2gi06DCwmhqOp4Mqtz7gK1+l2PJ+Ta3rlLHzUEa2UY26SMauOao6pqhzXz0MPapCRDpFclL/YaQg0Q==",
  "signatures": [
    {
      "sig": "MEQCIHJdRKq5ZVin75w1AEyktFy4YmrapiGcDOtMqWhkaA1LAiA8ZyXlM6shUzvxxNGs12yPNxKfwhKOunxTKFK4DBwTzA==",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 298087,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLzauCRA9TVsSAnZWagAAuPYP/3gellFsiaX3WFvn6aoF\nDl/sL8VlBgDnf4qmqMX0WdXlOJqMv9VsdAUQ6baUf0BPlc9LxkZEUAB/pZJ7\nhnlWYYj9YOeswf+MWI4Twg/cy676pmIBqsHR9hTRPdfakzH0NYavJi7YoRrd\n/iP8XIea7VjlQHXbpRuigxiT5eHeKGw+HtWLtu+7le4PVYmpBmWVQAyGK0C5\ngyaKnQ0OJXKv3wj4Edc+N3KSm95CUDW0hokI5b8s21BVIaZBEDi86E+O5Ml/\nYj81aNIqKr9qzXxuxvS6gTe7a5M0Dt8re7GKof8EkEgA4UUKrqhpXwGmylUs\ndL9YP/UjnWaRENumD/RdU4C6W4XHeaNKfRfb7IqyTkzwSW3eeHTcvV5rwMoo\nHhic3G6SuxD28fkHa3IW7giu3b4FUOOwisKXWpLWJY6jeVDCSPxQBSKPfna5\nlZEqfO1voY5DTsFNXP0AoumfhLVUH+Vz6DZ4CpGQPijXREFgmOi5Kkg+Twki\nL4eACziia0LHL6xXUivmnAmK1FdXr9gq03tM7X/3ujWRAU2QXK7KxO7ZaRGB\nCV95JMOWTXNJpz0MIaDMT2aKR35pdB+jklNQ/j6dYx7B7wS12bqbFVEqH+rS\nEZOe91d3aixIPrGdfP6pho218Mmi5dfQ5+ccr/rCDiYaeXsBRriZM07OxbUX\nBrFi\r\n=AWiv\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
ethereum/web3.js

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:32 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:54fed3d7a4ee43834ff82138dff9b2c38c4884c1957b31fdf39a87a7970a0040

Other collected versions

0.0.71 Aug0.0.623 Jul0.0.517 Jul0.0.317 Jul0.0.217 Jul0.0.117 JulView all collected versions →