How to use the web3-provider-engine/zero function in web3-provider-engine

To help you get started, we’ve selected a few web3-provider-engine 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 OriginProtocol / origin / experimental / origin-linker-client / src / index.js View on Github external
getProvider() {
    const rpcUrl = this.web3.eth.net.currentProvider.host
    const provider = ZeroClientProvider({
      rpcUrl,
      getAccounts: this.getAccounts.bind(this),
      processTransaction: this.processTransaction.bind(this)
    })

    // Disable transaction validation, which interferes with our work.
    const hookedWallet = provider._providers[6]
    if (!hookedWallet.validateTransaction) {
      console.error('The sub provider at [6] is NOT a hooked wallet.')
    } else {
      // Pass through validate for now
      hookedWallet.validateTransaction = (_, cb) => {
        cb()
      }
    }
github OriginProtocol / origin / packages / linker-client / src / index.js View on Github external
getProvider() {
    const rpcUrl = this.web3.eth.net.currentProvider.host
    const provider = ZeroClientProvider({
      rpcUrl,
      getAccounts: this.getAccounts.bind(this),
      processTransaction: this.processTransaction.bind(this)
    })

    // Disable transaction validation, which interferes with our work.
    const hookedWallet = provider._providers[6]
    if (!hookedWallet.validateTransaction) {
      console.error('The sub provider at [6] is NOT a hooked wallet.')
    } else {
      // Pass through validate for now
      hookedWallet.validateTransaction = (_, cb) => {
        cb()
      }
    }
github OriginProtocol / origin / origin-linker-client / src / index.js View on Github external
getProvider() {
    const rpcUrl = this.web3.eth.net.currentProvider.host
    const provider = ZeroClientProvider({
      rpcUrl,
      getAccounts: this.getAccounts.bind(this),
      processTransaction: this.processTransaction.bind(this)
    })

    // Disable transaction validation, which interferes with our work.
    const hookedWallet = provider._providers[6]
    if (!hookedWallet.validateTransaction) {
      console.error('The sub provider at [6] is NOT a hooked wallet.')
    } else {
      // Pass through validate for now
      hookedWallet.validateTransaction = (_, cb) => {
        cb()
      }
    }
github Giveth / giveth-dapp / src / lib / blockchain / ZeroClientProvider.js View on Github external
export default options => {
  const engine = new ZeroClientProvider(options);

  const cleanserSubprovider = new CleanserSubProvider();
  // insert cleanserSubprovider as 1st provider
  cleanserSubprovider.setEngine(engine); // set engine b/c we monkey patch this provider. typically called in engine.start()
  engine._providers.splice(0, 0, cleanserSubprovider);

  // gasPrice
  const gasPriceProvider = new GasPriceProvider();
  gasPriceProvider.setEngine(engine); // set engine b/c we monkey patch this provider. typically called in engine.start()
  engine._providers.splice(7, 0, gasPriceProvider);

  // gasPrice
  if (REACT_APP_ENVIRONMENT === 'localhost') {
    const gasEstimateProvider = new GanacheGasEstimatorProvider();
    gasEstimateProvider.setEngine(engine); // set engine b/c we monkey patch this provider. typically called in engine.start()
    engine._providers.splice(9, 0, gasEstimateProvider);
github OriginProtocol / origin / packages / mobile-bridge / src / index.js View on Github external
getProvider() {
    const rpcUrl = this.web3.eth.net.currentProvider.host

    const provider = ZeroClientProvider({
      rpcUrl,
      getAccounts: this.getAccounts.bind(this),
      processTransaction: this.processTransaction.bind(this),
      signMessage: this.signMessage.bind(this),
      signPersonalMessage: this.signPersonalMessage.bind(this)
    })

    // Disable caching subProviders, because they interfere with the provider
    // we're returning.
    const providersToRemove = [
      'BlockCacheSubprovider',
      'InflightCacheSubprovider'
    ]
    provider._providers = provider._providers.filter(
      provider => !providersToRemove.includes(provider.constructor.name)
    )
github OriginProtocol / origin / origin-js / src / resources / wallet-linker.js View on Github external
getProvider() {
    const provider = ZeroClientProvider({
      rpcUrl:
        this.networkRpcUrl && this.linked
          ? this.networkRpcUrl
          : this.web3.currentProvider.host,
      getAccounts: this.getAccounts.bind(this),
      //signTransaction: this.signTransaction.bind(this),
      //signPersonalMessage: this.signPersonalMessage.bind(this),
      processTransaction: this.processTransaction.bind(this)
    })
    const hookedWallet = provider._providers[6]

    if (!hookedWallet.validateTransaction) {
      console.log('The sub provider at [6] is NOT a hooked wallet.')
    } else {
      //we basically make validate a passthrough for now
      hookedWallet.validateTransaction = (txParams, cb) => {
github OriginProtocol / origin-js / src / resources / wallet-linker.js View on Github external
getProvider() {
    const provider = ZeroClientProvider({
      rpcUrl:
        this.networkRpcUrl && this.linked
          ? this.networkRpcUrl
          : this.web3.currentProvider.host,
      getAccounts: this.getAccounts.bind(this),
      //signTransaction: this.signTransaction.bind(this),
      //signPersonalMessage: this.signPersonalMessage.bind(this),
      processTransaction: this.processTransaction.bind(this)
    })
    const hookedWallet = provider._providers[6]

    if (!hookedWallet.validateTransaction) {
      console.log('The sub provider at [6] is NOT a hooked wallet.')
    } else {
      //we basically make validate a passthrough for now
      hookedWallet.validateTransaction = (txParams, cb) => {