How to use web3-core-requestmanager - 9 common examples

To help you get started, we’ve selected a few web3-core-requestmanager examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github embark-framework / embark / packages / embarkjs / embarkjs-whisper / src / index.js View on Github external
__embarkWhisperNewWeb3.setProvider = function(options) {
  const self = this;
  let endpoint;
  if (options === undefined) {
    endpoint = "localhost:8546";
  } else {
    endpoint = options.server + ':' + options.port;
  }
  // TODO: take into account type
  const provider = new Web3.providers.WebsocketProvider("ws://" + endpoint, options.providerOptions);

  self.web3 = new Web3(provider);
  self.requestManager = new Manager(provider);

  self.web3.currentProvider.on('connect', () => {
    self.getWhisperVersion(function(err, version) {
      if (err) {
        console.log("whisper not available");
      } else if (version >= 5) {
        self.web3.shh.newSymKey().then((id) => {
          self.symKeyID = id;
        });
        self.web3.shh.newKeyPair().then((id) => {
          self.sig = id;
        });
      } else {
        throw new Error("version of whisper not supported");
      }
      self.whisperVersion = self.web3.version.whisper;
github embark-framework / embark / packages / embarkjs / whisper / src / index.js View on Github external
__embarkWhisperNewWeb3.setProvider = function(options) {
  const self = this;
  let endpoint;
  if (options === undefined) {
    endpoint = "localhost:8546";
  } else {
    endpoint = options.server + ':' + options.port;
  }
  // TODO: take into account type
  const provider = new Web3.providers.WebsocketProvider("ws://" + endpoint, options.providerOptions);

  self.web3 = new Web3(provider);
  self.requestManager = new Manager(provider);

  self.web3.currentProvider.on('connect', () => {
    self.getWhisperVersion(function(err, version) {
      if (err) {
        console.log("whisper not available");
      } else if (version >= 5) {
        self.web3.shh.newSymKey().then((id) => {
          self.symKeyID = id;
        });
        self.web3.shh.newKeyPair().then((id) => {
          self.sig = id;
        });
      } else {
        throw new Error("version of whisper not supported");
      }
      self.whisperVersion = self.web3.version.whisper;
github ethereum / web3.js / packages / web3-core / src / index.js View on Github external
return pkg._provider;
            },
            set: function (value) {
                return pkg.setProvider(value);
            },
            enumerable: true,
            configurable: true
        });

        // inherit from web3 umbrella package
        if (args[0] && args[0]._requestManager) {
            pkg._requestManager = new requestManager.Manager(args[0].currentProvider);

        // set requestmanager on package
        } else {
            pkg._requestManager = new requestManager.Manager();
            pkg._requestManager.setProvider(args[0], args[1]);
        }

        // add givenProvider
        pkg.givenProvider = requestManager.Manager.givenProvider;
        pkg.providers = requestManager.Manager.providers;

         pkg._provider =  pkg._requestManager.provider;

        // add SETPROVIDER function (don't overwrite if already existing)
        if (!pkg.setProvider) {
            pkg.setProvider = function (provider, net) {
                pkg._requestManager.setProvider(provider, net);
                pkg._provider = pkg._requestManager.provider;
                return true;
            };
github ethereum / web3.js / packages / web3-core / src / index.js View on Github external
pkg.givenProvider = requestManager.Manager.givenProvider;
        pkg.providers = requestManager.Manager.providers;

         pkg._provider =  pkg._requestManager.provider;

        // add SETPROVIDER function (don't overwrite if already existing)
        if (!pkg.setProvider) {
            pkg.setProvider = function (provider, net) {
                pkg._requestManager.setProvider(provider, net);
                pkg._provider = pkg._requestManager.provider;
                return true;
            };
        }

        // attach batch request creation
        pkg.BatchRequest = requestManager.BatchManager.bind(null, pkg._requestManager);

        // attach extend function
        pkg.extend = extend(pkg);
    },
    addProviders: function (pkg) {
github embark-framework / embark / packages / stack / proxy / src / proxy.js View on Github external
_createWeb3RequestManager(provider) {
    return new Web3RequestManager.Manager(provider);
  }
github MyEtherWallet / MyEtherWallet / src / wallets / web3-provider / providers / mew-cx-request-manager.js View on Github external
constructor() {
    return new Web3RequestManager(this);
  }
  send(payload, callback) {
github MyEtherWallet / MyEtherWallet / src / wallets / web3-provider / providers / pocket-request-manager.js View on Github external
} else if (host.includes('ropsten')) {
      this.query = 'ropsten';
    } else if (host.includes('kovan')) {
      this.query = 'kovan';
    } else if (host.includes('poa')) {
      this.query = 'poa';
    } else if (host.includes('goerli')) {
      this.query = 'goerli';
    }
    this.network = networks.find(o => o[this.query])[this.query];
    this.provider = new PocketProvider(
      this.network.ticker,
      this.network.netid,
      devid
    );
    return new Web3RequestManager(this);
  }
  send(payload, callback) {
github embark-framework / embark / packages / plugins / ethereum-blockchain-client / src / api.js View on Github external
constructor(embark, web3, blockchainName) {
    this.embark = embark;
    this.blockchainName = blockchainName;
    this.web3 = web3;
    this.requestManager = new Manager(web3.currentProvider);
    this.fs = embark.fs;
    this.logFile = dappPath(".embark", "contractEvents.json");
  }
github MyEtherWallet / MyEtherWallet / src / wallets / web3-provider / providers / given-provider.js View on Github external
constructor(host, options, store, eventHub) {
    this.givenProvider = Object.assign({}, host);
    const requestManager = new Web3RequestManager(host);
    options = options ? options : null;
    if (this.givenProvider.sendAsync) {
      this.givenProvider.send = this.givenProvider.sendAsync;
      delete this.givenProvider.sendAsync;
    }
    this.givenProvider.send_ = this.givenProvider.send;
    delete this.givenProvider.send;
    this.givenProvider.send = (payload, callback) => {
      const req = {
        payload,
        store,
        requestManager,
        eventHub
      };
      const middleware = new MiddleWare();
      middleware.use(ethSendTransaction);

web3-core-requestmanager

Web3 module to handle requests to external providers.

LGPL-3.0
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis

Similar packages