Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _getPathsToWatch(): string[] {
const contractNames = this.getContractNamesToCompile();
const spyResolver = new SpyResolver(this._resolver);
for (const contractName of contractNames) {
const contractSource = spyResolver.resolve(contractName);
// NOTE: We ignore the return value here. We don't want to compute the source tree hash.
// We just want to call a SpyResolver on each contracts and it's dependencies and
// this is a convenient way to reuse the existing code that does that.
// We can then get all the relevant paths from the `spyResolver` below.
getSourceTreeHash(spyResolver, contractSource.path);
}
const pathsToWatch = _.uniq(spyResolver.resolvedContractSources.map(cs => cs.absolutePath));
return pathsToWatch;
}
/**
private async _compileContractsAsync(contractNames: string[], shouldPersist: boolean): Promise {
// batch input contracts together based on the version of the compiler that they require.
const versionToInputs: VersionToInputs = {};
// map contract paths to data about them for later verification and persistence
const contractPathToData: ContractPathToData = {};
const solcJSReleases = await getSolcJSReleasesAsync(this._isOfflineMode);
const resolvedContractSources = [];
for (const contractName of contractNames) {
const spyResolver = new SpyResolver(this._resolver);
const contractSource = spyResolver.resolve(contractName);
const sourceTreeHashHex = getSourceTreeHash(spyResolver, contractSource.path).toString('hex');
const contractData = {
contractName: path.basename(contractName, constants.SOLIDITY_FILE_EXTENSION),
currentArtifactIfExists: await getContractArtifactIfExistsAsync(this._artifactsDir, contractName),
sourceTreeHashHex: `0x${sourceTreeHashHex}`,
};
if (!this._shouldCompile(contractData)) {
continue;
}
contractPathToData[contractSource.path] = contractData;
const solcVersion =
this._solcVersionIfExists === undefined
? semver.maxSatisfying(_.keys(solcJSReleases), parseSolidityVersionRange(contractSource.source))
: this._solcVersionIfExists;
if (solcVersion === null) {