How to use @truffle/config - 10 common examples

To help you get started, we’ve selected a few @truffle/config 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 / testing / testrunner.js View on Github external
function TestRunner(options = {}) {
  expect.options(options, [
    "resolver",
    "provider",
    "contracts_build_directory"
  ]);

  this.config = Config.default().merge(options);

  this.logger = options.logger || console;
  this.initial_resolver = options.resolver;
  this.provider = options.provider;

  this.can_snapshot = false;
  this.first_snapshot = true;
  this.initial_snapshot = null;
  this.known_events = {};
  this.interfaceAdapter = createInterfaceAdapter({
    provider: options.provider,
    networkType: options.networks[options.network].type
  });

  // For each test
  this.currentTestStartBlock = null;
github ConsenSys / truffle-security / lib / wfc.js View on Github external
function prepareConfig(options) {
    expect.options(options, [
        'build_mythx_contracts'
    ]);

    // Use a config object to ensure we get the default sources.
    const config = Config.default().merge(options);

    config.compilersInfo = {};

    if (!config.resolver) {
        config.resolver = new Resolver(config);
    }

    return config;
}
github trufflesuite / truffle / packages / require / require.js View on Github external
file: options => {
    let source;
    const file = options.file;

    expect.options(options, ["file"]);

    options = Config.default().with(options);

    source = fs.readFileSync(options.file, { encoding: "utf8" });

    // Modified from here: https://gist.github.com/anatoliychakkaev/1599423
    const m = new Module(file);

    // Provide all the globals listed here: https://nodejs.org/api/globals.html
    const context = {
      Buffer: Buffer,
      __dirname: path.dirname(file),
      __filename: file,
      clearImmediate: clearImmediate,
      clearInterval: clearInterval,
      clearTimeout: clearTimeout,
      console: console,
      exports: exports,
github ConsenSys / truffle-security / compat / truffle-compile / index.js View on Github external
compile.with_dependencies = async function(options, callback, compileAll) {
  var self = this;

  options.logger = options.logger || console;
  options.contracts_directory = options.contracts_directory || process.cwd();

  expect.options(options, [
    "paths",
    "working_directory",
    "contracts_directory",
    "resolver",
  ]);

  var config = Config.default().merge(options);

  // Filter out of the list of files to be compiled those for which we have a JSON that
  // is newer than the last modified time of the source file.

  const staleSolFiles = [];
  let filteredRequired = [];
  for (const sourcePath of options.paths) {
    const targetJsonPath = sourcePath2BuildPath(sourcePath, options.build_mythx_contracts);
    if (compileAll || staleBuildContract(sourcePath, targetJsonPath)) {
      // Set for compilation
      filteredRequired.push(sourcePath);
    } else {
      staleSolFiles.push(sourcePath);
    }
  }
github trufflesuite / truffle / packages / solidity-loader / lib / genBuildOptions.js View on Github external
const genBuildOptions = buildOpts => {
  if (!buildOpts.network) {
    throw new Error(
      "You must specify the network name to deploy to. (network)"
    );
  }

  const truffleConfig = getTruffleConfig();

  if (!truffleConfig) {
    throw new Error("No Truffle Config file found!");
  }

  const config = TruffleConfig.load(truffleConfig, buildOpts);
  config.reset = true; // TODO make this configurable
  config.logger = Logger; // NOTE: this will be used within truffle
  return config;
};
github trufflesuite / truffle / packages / truffle-db / bin / server.js View on Github external
const { ApolloServer } = require("apollo-server");

const { TruffleDB } = require("truffle-db");
const Config = require("@truffle/config");

const port = 4444;

const config = Config.detect({
  workingDirectory: process.argv[2] || process.cwd()
});

if (!config.db.enabled) {
  console.log("Experimental truffle-db feature is disabled.");
  process.exit(0);
}

const db = new TruffleDB({
  contracts_build_directory: config.contracts_build_directory,
  contracts_directory: config.contracts_directory,
  working_directory: config.working_directory
});

const { schema, context } = db;
github trufflesuite / truffle / packages / core / lib / commands / init.js View on Github external
run: function(options, done) {
    var Config = require("@truffle/config");
    var OS = require("os");
    var UnboxCommand = require("./unbox");

    var config = Config.default().with({
      logger: console
    });

    if (options._ && options._.length > 0) {
      config.logger.log(
        "Error: `truffle init` no longer accepts a project template name as an argument."
      );
      config.logger.log();
      config.logger.log(
        " - For an empty project, use `truffle init` with no arguments" +
          OS.EOL +
          " - Or, browse the Truffle Boxes at !"
      );
      process.exit(1);
    }
github trufflesuite / truffle / packages / core / lib / commands / unbox.js View on Github external
run(options, done) {
    const Config = require("@truffle/config");
    const Box = require("@truffle/box");
    const OS = require("os");

    const config = Config.default().with({
      logger: console
    });

    let [url, destination] = normalizeInput(options._[0]);

    url = normalizeURL(url);
    destination = normalizeDestination(destination, config.working_directory);

    const unboxOptions = Object.assign({}, options, { logger: config.logger });

    Box.unbox(url, destination, unboxOptions)
      .then(({ commands }) => {
        config.logger.log(`\nUnbox successful. Sweet!${OS.EOL}`);

        const commandMessages = formatCommands(commands);
        if (commandMessages.length > 0) config.logger.log(`Commands:${OS.EOL}`);
github trufflesuite / truffle / packages / compile-solidity / legacy / index.js View on Github external
compile.with_dependencies = function(options, callback) {
  var self = this;

  options.logger = options.logger || console;
  options.contracts_directory = options.contracts_directory || process.cwd();

  expect.options(options, [
    "paths",
    "working_directory",
    "contracts_directory",
    "resolver"
  ]);

  var config = Config.default().merge(options);

  Profiler.required_sources(
    config.with({
      paths: options.paths,
      base_path: options.contracts_directory,
      resolver: options.resolver
    }),
    (err, allSources, required) => {
      if (err) return callback(err);

      var hasTargets = required.length;

      hasTargets
        ? self.display(required, options)
        : self.display(allSources, options);
github trufflesuite / truffle / packages / compile-solidity / new / index.js View on Github external
compile.all = async function(options) {
  const paths = [
    ...new Set([
      ...(await promisify(findContracts)(options.contracts_directory)),
      ...(options.files || [])
    ])
  ];

  return await compile.with_dependencies(
    Config.default()
      .merge(options)
      .merge({ paths })
  );
};

@truffle/config

Utility for interacting with truffle-config.js files

MIT
Latest version published 8 months ago

Package Health Score

55 / 100
Full package analysis