diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-07 00:37:48 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-12 18:51:15 +0800 |
commit | 442017f93ad1fa5af7b751da7cfdda3deb0861ab (patch) | |
tree | 8794e7ea4a38d1a177f842f88d75a2df46c62aa7 /packages/deployer/src/utils | |
parent | 4dd9f29769bea90a4b687be26b086164aaff685a (diff) | |
download | dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar.gz dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar.bz2 dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar.lz dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar.xz dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.tar.zst dexon-sol-tools-442017f93ad1fa5af7b751da7cfdda3deb0861ab.zip |
Use solc.compileStandardWrapper
Diffstat (limited to 'packages/deployer/src/utils')
-rw-r--r-- | packages/deployer/src/utils/compiler.ts | 18 | ||||
-rw-r--r-- | packages/deployer/src/utils/types.ts | 7 |
2 files changed, 13 insertions, 12 deletions
diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts index d5137d394..b83be221a 100644 --- a/packages/deployer/src/utils/compiler.ts +++ b/packages/deployer/src/utils/compiler.ts @@ -10,15 +10,14 @@ import { ContractArtifact, ContractSources } from './types'; /** * Gets contract data on network or returns if an artifact does not exist. * @param artifactsDir Path to the artifacts directory. - * @param fileName Name of contract file. + * @param contractName Name of contract. * @return Contract data on network or undefined. */ export async function getContractArtifactIfExistsAsync( artifactsDir: string, - fileName: string, + contractName: string, ): Promise<ContractArtifact | void> { let contractArtifact; - const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); const currentArtifactPath = `${artifactsDir}/${contractName}.json`; try { const opts = { @@ -28,7 +27,7 @@ export async function getContractArtifactIfExistsAsync( contractArtifact = JSON.parse(contractArtifactString); return contractArtifact; } catch (err) { - logUtils.log(`Artifact for ${fileName} does not exist`); + logUtils.log(`Artifact for ${contractName} does not exist`); return undefined; } } @@ -95,8 +94,8 @@ export function parseDependencies(source: string): string[] { const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX); if (!_.isNull(dependencyMatch)) { const dependencyPath = dependencyMatch[1]; - const basenName = path.basename(dependencyPath); - dependencies.push(basenName); + const contractName = path.basename(dependencyPath, constants.SOLIDITY_FILE_EXTENSION); + dependencies.push(contractName); } } }); @@ -105,16 +104,15 @@ export function parseDependencies(source: string): string[] { /** * Callback to resolve dependencies with `solc.compile`. - * Throws error if contractSources not yet initialized. * @param contractSources Source codes of contracts. * @param importPath Path to an imported dependency. * @return Import contents object containing source code of dependency. */ export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents { - const fileName = path.basename(importPath); - const source = contractSources[fileName]; + const contractName = path.basename(importPath, constants.SOLIDITY_FILE_EXTENSION); + const source = contractSources[contractName].source; if (_.isUndefined(source)) { - throw new Error(`Contract source not found for ${fileName}`); + throw new Error(`Contract source not found for ${contractName}`); } const importContents: solc.ImportContents = { contents: source, diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index 7d131f5ce..54579c200 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -75,11 +75,14 @@ export interface UrlDeployerOptions extends BaseDeployerOptions { export type DeployerOptions = UrlDeployerOptions | ProviderDeployerOptions; export interface ContractSources { - [key: string]: string; + [key: string]: { + source: string; + absoluteFilePath: string; + }; } export interface ContractSourceData { - [key: string]: ContractSpecificSourceData; + [contractName: string]: ContractSpecificSourceData; } export interface ContractSpecificSourceData { |