How to use @truffle/provider - 7 common examples

To help you get started, we’ve selected a few @truffle/provider 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 trufflesuite / truffle / packages / core / lib / networks.js View on Github external
matchesNetwork: async function(network_id, network_options, callback) {
    const provider = Provider.create(network_options);

    const first = network_id + "";
    const second = network_options.network_id + "";

    if (first === second) return callback(null, true);

    const isFirstANumber = isNaN(parseInt(network_id)) === false;
    const isSecondANumber =
      isNaN(parseInt(network_options.network_id)) === false;

    // If both network ids are numbers, then they don't match, and we should quit.
    if (isFirstANumber && isSecondANumber) return callback(null, false);

    const interfaceAdapter = new InterfaceAdapter();
    const web3 = new Web3Shim({
      provider,
github sc-forks / solidity-coverage / plugins / resources / truffle.utils.js View on Github external
function setOuterConfigKeys(config, api, id){
  try {
    config.network_id = id;
    config.port = api.port;
    config.host = api.host;
    config.provider = TruffleProvider.create(config);
  } catch (err){}
}
github trufflesuite / truffle / packages / config / configDefaults.js View on Github external
get() {
        if (!configObject.network) {
          return null;
        }

        const options = configObject.network_config;
        options.verboseRpc = configObject.verboseRpc;

        return Provider.create(options);
      },
      set() {
github microsoft / vscode-azure-blockchain-ethereum / src / debugAdapter / web3Wrapper.ts View on Github external
public getProvider() {
        if (!this._cachedProvider) {
            const web3Provider = this.eth.currentProvider;
            const truffleProviderOptions = {
                provider: () => {
                    return web3Provider;
                },
            };
            this._cachedProvider = truffleProvider.create(truffleProviderOptions);
        }

        return this._cachedProvider;
    }
github trufflesuite / truffle / packages / core / lib / networks.js View on Github external
(network_name, finished) => {
        const provider = Provider.create(options.networks[network_name]);
        BlockchainUtils.asURI(provider, (err, uri) => {
          if (err) {
            result.failed.push(network_name);
          } else {
            result.uris[network_name] = uri;
          }
          finished();
        });
      },
      error => {
github trufflesuite / truffle / packages / environment / environment.js View on Github external
detect: async function(config) {
    expect.options(config, ["networks"]);

    helpers.setUpConfig(config);
    helpers.validateNetworkConfig(config);

    const interfaceAdapter = new InterfaceAdapter({
      provider: config.provider,
      networkType: config.networks[config.network].type
    });
    const web3 = new Web3Shim({
      provider: config.provider,
      networkType: config.networks[config.network].type
    });

    await Provider.testConnection(config);
    await helpers.detectAndSetNetworkId(config, web3, interfaceAdapter);
    await helpers.setFromOnConfig(config, web3, interfaceAdapter);
  },
github trufflesuite / truffle / packages / core / lib / commands / migrate.js View on Github external
.then(async () => {
        await Provider.testConnection(conf);
        await Environment.detect(conf);

        const {
          dryRunOnly,
          dryRunAndMigrations
        } = command.determineDryRunSettings(conf, options);

        if (dryRunOnly) {
          conf.dryRun = true;
          await setupDryRunEnvironmentThenRunMigrations(conf);
        } else if (dryRunAndMigrations) {
          const currentBuild = conf.contracts_build_directory;
          conf.dryRun = true;

          await setupDryRunEnvironmentThenRunMigrations(conf);

@truffle/provider

Beefed up provider module for Truffle

MIT
Latest version published 6 months ago

Package Health Score

70 / 100
Full package analysis