diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-02-07 19:58:46 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-02-07 19:58:46 +0800 |
commit | 64d6dae672e71f6c81b472a58cb9c443607262c9 (patch) | |
tree | 18613efe6d28ddc0f2dd95535d93043108902e2f /packages/sol-compiler/src/utils | |
parent | c20285dd3655a9685b52205229e675c797cd4418 (diff) | |
download | dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar.gz dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar.bz2 dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar.lz dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar.xz dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.tar.zst dexon-0x-contracts-64d6dae672e71f6c81b472a58cb9c443607262c9.zip |
Remove the bin_paths and fetch the solidity release list from github repo
Diffstat (limited to 'packages/sol-compiler/src/utils')
-rw-r--r-- | packages/sol-compiler/src/utils/compiler.ts | 21 | ||||
-rw-r--r-- | packages/sol-compiler/src/utils/types.ts | 4 |
2 files changed, 21 insertions, 4 deletions
diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index dffd07b1d..34aa1a3b8 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -9,11 +9,9 @@ import * as path from 'path'; import * as requireFromString from 'require-from-string'; import * as solc from 'solc'; -import { binPaths } from '../solc/bin_paths'; - import { constants } from './constants'; import { fsWrapper } from './fs_wrapper'; -import { CompilationError } from './types'; +import { BinaryPaths, CompilationError } from './types'; /** * Gets contract data on network or returns if an artifact does not exist. @@ -119,6 +117,20 @@ export function parseDependencies(contractSource: ContractSource): string[] { return dependencies; } +let solcJSReleasesCache: BinaryPaths | undefined; + +/** + * Fetches the list of available solidity compilers + */ +export async function getSolcJSReleasesAsync(): Promise<BinaryPaths> { + if (_.isUndefined(solcJSReleasesCache)) { + const versionList = await fetch('https://ethereum.github.io/solc-bin/bin/list.json'); + const versionListJSON = await versionList.json(); + solcJSReleasesCache = versionListJSON.releases; + } + return solcJSReleasesCache as BinaryPaths; +} + /** * Compiles the contracts and prints errors/warnings * @param solcVersion Version of a solc compiler @@ -319,7 +331,8 @@ function recursivelyGatherDependencySources( * @param solcVersion The compiler version. e.g. 0.5.0 */ export async function getSolcJSAsync(solcVersion: string): Promise<solc.SolcInstance> { - const fullSolcVersion = binPaths[solcVersion]; + const solcJSReleases = await getSolcJSReleasesAsync(); + const fullSolcVersion = solcJSReleases[solcVersion]; if (_.isUndefined(fullSolcVersion)) { throw new Error(`${solcVersion} is not a known compiler version`); } diff --git a/packages/sol-compiler/src/utils/types.ts b/packages/sol-compiler/src/utils/types.ts index 64328899d..f756c51bb 100644 --- a/packages/sol-compiler/src/utils/types.ts +++ b/packages/sol-compiler/src/utils/types.ts @@ -13,6 +13,10 @@ export interface ContractSourceData { [contractName: string]: ContractSpecificSourceData; } +export interface BinaryPaths { + [key: string]: string; +} + export interface ContractSpecificSourceData { solcVersionRange: string; sourceHash: Buffer; |