How to use the @0x/utils.providerUtils.startProviderEngine function in @0x/utils

To help you get started, we’ve selected a few @0x/utils 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 0xProject / 0x-monorepo / packages / dev-utils / src / web3_factory.ts View on Github external
allowUnlimitedContractSize: config.shouldAllowUnlimitedContractSize,
                    gasLimit: constants.GAS_LIMIT,
                    logger,
                    verbose: env.parseBoolean(EnvVars.VerboseGanache),
                    port: 8545,
                    network_id: 50,
                    mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
                    fork: config.fork,
                    blockTime: config.blockTime,
                    unlocked_accounts: config.unlocked_accounts,
                } as any), // TODO remove any once types are merged in DefinitelyTyped
            );
        } else {
            provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL));
        }
        providerUtils.startProviderEngine(provider);
        return provider;
    },
};
github 0xProject / 0x-monorepo / packages / migrations / src / test_contract_configs.ts View on Github external
(async () => {
    for (const rpcUrl of Object.values(networkIdToRpcUrl)) {
        const provider = new Web3ProviderEngine();
        provider.addProvider(new EmptyWalletSubprovider());
        provider.addProvider(new RPCSubprovider(rpcUrl));
        providerUtils.startProviderEngine(provider);
        await testContractConfigsAsync(provider);
    }
})().catch(err => {
    logUtils.log(err);
github 0xProject / 0x-monorepo / packages / migrations / src / cli.ts View on Github external
(async () => {
    const rpcSubprovider = new RPCSubprovider(args['rpc-url']);
    const provider = new Web3ProviderEngine();
    provider.addProvider(rpcSubprovider);
    providerUtils.startProviderEngine(provider);
    const normalizedFromAddress = (args.from as string).toLowerCase();
    const txDefaults = {
        from: normalizedFromAddress,
    };
    await runMigrationsAsync(provider, txDefaults);
    process.exit(0);
})().catch(err => {
    logUtils.log(err);
github 0xProject / 0x-monorepo / packages / migrations / src / utils / provider_factory.ts View on Github external
async getMainnetLedgerProviderAsync(): Promise {
        const provider = new Web3ProviderEngine();
        const ledgerWalletConfigs = {
            networkId: constants.MAINNET_NETWORK_ID,
            ledgerEthereumClientFactoryAsync: ledgerEthereumNodeJsClientFactoryAsync,
        };
        const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs);
        provider.addProvider(ledgerSubprovider);
        provider.addProvider(new RPCSubprovider(constants.MAINNET_RPC_URL));
        providerUtils.startProviderEngine(provider);
        return provider;
    },
};
github 0xTracker / 0x-tracker-worker / src / util / ethereum / web3.js View on Github external
const configure = ({ endpoint }) => {
  const providerEngine = new Web3ProviderEngine();

  providerEngine.addProvider(new RPCSubprovider(endpoint));
  providerUtils.startProviderEngine(providerEngine);

  wrapper = new Web3Wrapper(providerEngine);
};
github 0xTracker / 0x-event-extractor / packages / shared / src / web3.js View on Github external
const configure = ({ endpoint }) => {
  providerEngine = new Web3ProviderEngine();
  wrapper = new Web3Wrapper(providerEngine);

  providerEngine.addProvider(new RPCSubprovider(endpoint));
  providerUtils.startProviderEngine(providerEngine);
};
github 0xProject / 0x-starter-project / src / provider_engine.ts View on Github external
const determineProvider = (): Web3ProviderEngine => {
    const pe = new Web3ProviderEngine();
    pe.addProvider(mnemonicWallet);
    if (NETWORK_CONFIGS === GANACHE_CONFIGS) {
        pe.addProvider(
            new GanacheSubprovider({
                vmErrorsOnRPCResponse: false,
                network_id: GANACHE_CONFIGS.networkId,
                mnemonic: MNEMONIC,
            }),
        );
    } else {
        pe.addProvider(new RPCSubprovider(NETWORK_CONFIGS.rpcUrl));
    }
    providerUtils.startProviderEngine(pe);
    return pe;
};
github 0xProject / 0x-monorepo / packages / order-watcher / src / server.ts View on Github external
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
import { RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { providerUtils } from '@0x/utils';
import * as _ from 'lodash';

import { OrderWatcherWebSocketServer } from './order_watcher/order_watcher_web_socket_server';

const GANACHE_NETWORK_ID = 50;
const DEFAULT_RPC_URL = 'http://localhost:8545';

const provider = new Web3ProviderEngine();
const jsonRpcUrl = process.env.JSON_RPC_URL || DEFAULT_RPC_URL;
const rpcSubprovider = new RPCSubprovider(jsonRpcUrl);
provider.addProvider(rpcSubprovider);
providerUtils.startProviderEngine(provider);

const networkId = process.env.NETWORK_ID !== undefined ? _.parseInt(process.env.NETWORK_ID) : GANACHE_NETWORK_ID;

const contractAddressesString = process.env.contractAddresses;
const contractAddressesIfExists =
    contractAddressesString === undefined
        ? getContractAddressesForNetworkOrThrow(networkId)
        : JSON.parse(contractAddressesString);

const orderWatcherConfig: any = {
    isVerbose: process.env.IS_VERBOSE === 'true',
};
const orderExpirationCheckingIntervalMs = process.env.ORDER_EXPIRATION_CHECKING_INTERVAL_MS;
if (orderExpirationCheckingIntervalMs !== undefined) {
    orderWatcherConfig.orderExpirationCheckingIntervalMs = _.parseInt(orderExpirationCheckingIntervalMs);
}