Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
if (config.networkHint !== false) {
config.logger.log("Using network '" + config.network + "'." + OS.EOL);
}
// `--compile`
if (options.c || options.compile) {
return Contracts.compile(config, function(err) {
if (err) return done(err);
Require.exec(
config.with({
file: file
}),
done
);
});
}
// Just exec
Require.exec(
config.with({
file: file
}),
run: function(options, done) {
var Config = require("truffle-config");
var TruffleError = require("@truffle/error");
var Contracts = require("@truffle/workflow-compile");
var CodeUtils = require("@truffle/code-utils");
if (options._.length === 0) {
return done(new TruffleError("Please specify a contract name."));
}
var config = Config.detect(options);
Contracts.compile(config, function(err) {
if (err) return done(err);
var contractName = options._[0];
var Contract;
try {
Contract = config.resolver.require(contractName);
} catch (e) {
return done(
new TruffleError(
'Cannot find compiled contract with name "' + contractName + '"'
)
);
}
var bytecode = Contract.deployedBytecode;
var numInstructions = Contract.deployedSourceMap.split(";").length;
run: function(options, done) {
const Artifactor = require("truffle-artifactor");
const Resolver = require("truffle-resolver");
const Migrate = require("truffle-migrate");
const Contracts = require("@truffle/workflow-compile");
const { Environment } = require("truffle-environment");
const Config = require("truffle-config");
const temp = require("temp").track();
const { promisify } = require("util");
const promisifiedCopy = promisify(require("../copy"));
const conf = Config.detect(options);
Contracts.compile(conf)
.then(async () => {
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);
run: function(options, done) {
const Artifactor = require("@truffle/artifactor");
const Resolver = require("@truffle/resolver");
const Migrate = require("@truffle/migrate");
const Contracts = require("@truffle/workflow-compile");
const Provider = require("@truffle/provider");
const { Environment } = require("@truffle/environment");
const Config = require("@truffle/config");
const temp = require("temp").track();
const { promisify } = require("util");
const promisifiedCopy = promisify(require("../copy"));
const conf = Config.detect(options);
Contracts.compile(conf)
.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;
run: function(options, done) {
const Contracts = require("@truffle/workflow-compile");
const Config = require("truffle-config");
const config = Config.detect(options);
if (config.list !== undefined) {
command
.listVersions(config)
.then(() => done())
.catch(done);
} else {
Contracts.compile(config)
.then(() => done())
.catch(done);
}
},
listVersions: async function(options) {
async loadCompilation(compilationConfig: CompilationConfigObject) {
const compilationOutput = await Contracts.compile(compilationConfig);
const contracts = compilationOutput.compilations;
const compilationObjects = await Promise.all(
Object.values(contracts)
.filter(contracts => contracts["contracts"].length > 0)
.map(({ contracts }) => {
return this.setCompilation(contracts);
})
);
const compilations = await this.db.query(AddCompilation, {
compilations: compilationObjects
});
return { compilations, contracts };
}