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 03:53:33 +0800
commitf0f94f199eff982ffa03c6a760235ed22a8ad68a (patch)
tree881cd08a551e4d1fb88ff31ab93b44393c36cfad /packages/sol-compiler
parentd744468479bf88c89412115860e0b8c4cf2a48c1 (diff)
downloaddexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar.gz
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar.bz2
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar.lz
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar.xz
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.tar.zst
dexon-0x-contracts-f0f94f199eff982ffa03c6a760235ed22a8ad68a.zip
move getSolcAsync to static private method
Diffstat (limited to 'packages/sol-compiler')
-rw-r--r--packages/sol-compiler/src/compiler.ts46
1 files changed, 23 insertions, 23 deletions
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index 0de8b8cad..c162d65f4 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -65,6 +65,29 @@ export class Compiler {
private readonly _artifactsDir: string;
private readonly _solcVersionIfExists: string | undefined;
private readonly _specifiedContracts: string[] | TYPE_ALL_FILES_IDENTIFIER;
+ 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 };
+ }
/**
* Instantiates a new instance of the Compiler class.
* @return An instance of the Compiler class.
@@ -200,29 +223,6 @@ 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: {