diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2019-01-24 02:49:10 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2019-01-24 02:49:10 +0800 |
commit | 09cb3b7d5060bc8821cdbcab9639bb0a3b27d651 (patch) | |
tree | 63821d6126f9e8ca9ea866fa3ba36169d1b0f0e2 /packages/sol-tracing-utils/src/artifact_adapters | |
parent | 8566bb551b2399f5b966b2ac81c89ba96f272aaf (diff) | |
parent | ef928aff31f09b368307548bd5a512b4212a0c95 (diff) | |
download | dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar.gz dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar.bz2 dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar.lz dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar.xz dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.tar.zst dexon-0x-contracts-09cb3b7d5060bc8821cdbcab9639bb0a3b27d651.zip |
Merge branch 'development' into feat/contracts/split-packages
Diffstat (limited to 'packages/sol-tracing-utils/src/artifact_adapters')
-rw-r--r-- | packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts index d52587f2c..bfd3a504a 100644 --- a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts +++ b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts @@ -1,3 +1,4 @@ +import { FallthroughResolver, FSResolver, NPMResolver, RelativeFSResolver, URLResolver } from '@0x/sol-resolver'; import { logUtils } from '@0x/utils'; import { CompilerOptions, ContractArtifact } from 'ethereum-types'; import * as fs from 'fs'; @@ -14,6 +15,7 @@ const CONFIG_FILE = 'compiler.json'; export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { private readonly _artifactsPath: string; private readonly _sourcesPath: string; + private readonly _resolver: FallthroughResolver; /** * Instantiates a SolCompilerArtifactAdapter * @param artifactsPath Path to your artifacts directory @@ -32,6 +34,12 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { throw new Error(`contractsDir not found in ${CONFIG_FILE}`); } this._sourcesPath = (sourcesPath || config.contractsDir) as string; + this._resolver = new FallthroughResolver(); + this._resolver.appendResolver(new URLResolver()); + const packagePath = path.resolve(''); + this._resolver.appendResolver(new NPMResolver(packagePath)); + this._resolver.appendResolver(new RelativeFSResolver(this._sourcesPath)); + this._resolver.appendResolver(new FSResolver()); } public async collectContractsDataAsync(): Promise<ContractData[]> { const artifactsGlob = `${this._artifactsPath}/**/*.json`; @@ -46,10 +54,9 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { const sources: Sources = {}; const sourceCodes: SourceCodes = {}; _.map(artifact.sources, (value: { id: number }, relativeFilePath: string) => { - const filePath = path.resolve(this._sourcesPath, relativeFilePath); - const fileContent = fs.readFileSync(filePath).toString(); - sources[value.id] = filePath; - sourceCodes[value.id] = fileContent; + const source = this._resolver.resolve(relativeFilePath); + sources[value.id] = source.absolutePath; + sourceCodes[value.id] = source.source; }); const contractData = { sourceCodes, @@ -59,6 +66,10 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { runtimeBytecode: artifact.compilerOutput.evm.deployedBytecode.object, sourceMapRuntime: artifact.compilerOutput.evm.deployedBytecode.sourceMap, }; + const isInterfaceContract = contractData.bytecode === '0x' && contractData.runtimeBytecode === '0x'; + if (isInterfaceContract) { + continue; + } contractsData.push(contractData); } return contractsData; |