aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler
diff options
context:
space:
mode:
authorF. Eugene Aumson <gene@aumson.org>2018-08-16 02:13:09 +0800
committerF. Eugene Aumson <gene@aumson.org>2018-08-16 02:13:09 +0800
commitc01810f0d755bdb3fa7b4b224a5a0d0493cd38a7 (patch)
tree9d980ce172ef3e0be12421ec94578971841f3b0c /packages/sol-compiler
parentc11d8054695c84a4ff3d76730813c692e0a16dc3 (diff)
downloaddexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar.gz
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar.bz2
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar.lz
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar.xz
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.tar.zst
dexon-0x-contracts-c01810f0d755bdb3fa7b4b224a5a0d0493cd38a7.zip
move getSolcAsync to static private method
Diffstat (limited to 'packages/sol-compiler')
-rw-r--r--packages/sol-compiler/src/compiler.ts49
1 files changed, 24 insertions, 25 deletions
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index cf12825c4..c62a4c0ca 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -53,30 +53,6 @@ const DEFAULT_COMPILER_SETTINGS: solc.CompilerSettings = {
};
const CONFIG_FILE = 'compiler.json';
-async function getSolcAsync(
- solcVersion: string,
-): Promise<{ solcInstance: solc.SolcInstance; fullSolcVersion: string }> {
- const fullSolcVersion = binPaths[solcVersion];
- const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion);
- let solcjs: string;
- const isCompilerAvailableLocally = fs.existsSync(compilerBinFilename);
- if (isCompilerAvailableLocally) {
- solcjs = fs.readFileSync(compilerBinFilename).toString();
- } else {
- logUtils.log(`Downloading ${fullSolcVersion}...`);
- const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`;
- const response = await fetchAsync(url);
- const SUCCESS_STATUS = 200;
- if (response.status !== SUCCESS_STATUS) {
- throw new Error(`Failed to load ${fullSolcVersion}`);
- }
- solcjs = await response.text();
- fs.writeFileSync(compilerBinFilename, solcjs);
- }
- const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
- return { solcInstance, fullSolcVersion };
-}
-
/**
* The Compiler facilitates compiling Solidity smart contracts and saves the results
* to artifact files.
@@ -210,7 +186,7 @@ export class Compiler {
}) with Solidity v${solcVersion}...`,
);
- const { solcInstance, fullSolcVersion } = await getSolcAsync(solcVersion);
+ const { solcInstance, fullSolcVersion } = await Compiler._getSolcAsync(solcVersion);
const compiled = this._compile(solcInstance, input.standardInput);
@@ -224,6 +200,29 @@ export class Compiler {
}
}
}
+ private static async _getSolcAsync(
+ solcVersion: string,
+ ): Promise<{ solcInstance: solc.SolcInstance; fullSolcVersion: string }> {
+ const fullSolcVersion = binPaths[solcVersion];
+ const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion);
+ let solcjs: string;
+ const isCompilerAvailableLocally = fs.existsSync(compilerBinFilename);
+ if (isCompilerAvailableLocally) {
+ solcjs = fs.readFileSync(compilerBinFilename).toString();
+ } else {
+ logUtils.log(`Downloading ${fullSolcVersion}...`);
+ const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`;
+ const response = await fetchAsync(url);
+ const SUCCESS_STATUS = 200;
+ if (response.status !== SUCCESS_STATUS) {
+ throw new Error(`Failed to load ${fullSolcVersion}`);
+ }
+ solcjs = await response.text();
+ fs.writeFileSync(compilerBinFilename, solcjs);
+ }
+ const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
+ return { solcInstance, fullSolcVersion };
+ }
private async _verifyAndPersistCompiledContractAsync(
contractPath: string,
contractMetadata: {