Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build: function(options, callback) {
expect.options(options, [
"build_directory",
"working_directory",
"contracts_build_directory",
"networks"
]);
const logger = options.logger || console;
let builder = options.build;
// Duplicate build directory for legacy purposes
options.destination_directory = options.build_directory;
if (builder === null || typeof builder === "undefined") {
logger.log(
"No build configuration found. Preparing to compile contracts."
);
function prepareConfig(options) {
expect.options(options, ["contracts_build_directory"]);
expect.one(options, ["contracts_directory", "files"]);
// 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);
if (!config.artifactor) {
config.artifactor = new Artifactor(config.contracts_build_directory);
}
return config;
}
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;
}
const compile = function(sourcePath, allSources, options, callback, isStale) {
if (typeof options === "function") {
callback = options;
options = {};
}
if (options.logger === undefined) options.logger = console;
const hasTargets =
options.compilationTargets && options.compilationTargets.length;
expect.options(options, ["contracts_directory", "compilers"]);
expect.options(options.compilers, ["solc"]);
options.compilers.solc.settings.evmVersion =
options.compilers.solc.settings.evmVersion ||
options.compilers.solc.evmVersion;
options.compilers.solc.settings.optimizer =
options.compilers.solc.settings.optimizer ||
options.compilers.solc.optimizer ||
{};
// Ensure sources have operating system independent paths
// i.e., convert backslashes to forward slashes; things like C: are left intact.
const operatingSystemIndependentSources = {};
const operatingSystemIndependentTargets = {};
const originalPathMappings = {};
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({
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);
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);
compile.with_dependencies = async function(options) {
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);
const { allSources, required } = await new Promise((accept, reject) => {
Profiler.required_sources(
config.with({
paths: options.paths,
base_path: options.contracts_directory,
resolver: options.resolver
}),
(err, allSources, required) => {
const updatedFiles = async options => {
expect.options(options, ["resolver"]);
const { contracts_directory, contracts_build_directory } = options;
getFiles = async () => {
if (options.files && options.files.length !== 0) return options.files;
else return findContracts(contracts_directory);
};
let sourceFilesArtifacts = {};
let sourceFilesArtifactsUpdatedTimes = {};
try {
const sourceFiles = await getFiles();
sourceFilesArtifacts = readAndParseArtifactFiles(
sourceFiles,
contracts_build_directory
detect: async function(config) {
expect.options(config, ["networks"]);
helpers.setUpConfig(config);
helpers.validateNetworkConfig(config);
const web3 = new Web3Shim({
provider: config.provider,
networkType: config.networks[config.network].type
});
await helpers.detectAndSetNetworkId(config, web3);
await helpers.setFromOnConfig(config, web3);
},