pass optimization runz parameter to javascript

pull/1662/head
Ayrat Badykov 6 years ago
parent f343fdd593
commit b60ca17fff
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 3
      apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex
  2. 9
      apps/explorer/priv/compile_solc.js

@ -66,7 +66,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
compiler_version = Keyword.fetch!(params, :compiler_version)
code = Keyword.fetch!(params, :code)
optimize = Keyword.fetch!(params, :optimize)
_optimization_runs = Keyword.get(params, :optimization_runs, 200)
optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string()
evm_version = Keyword.get(params, :evm_version, List.last(@allowed_evm_versions))
external_libs = Keyword.get(params, :external_libs, %{})
@ -87,6 +87,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
code,
compiler_version,
optimize_value(optimize),
optimization_runs,
@new_contract_name,
external_libs_string,
checked_evm_version

@ -5,9 +5,10 @@ const solc = require('solc');
var sourceCode = process.argv[2];
var version = process.argv[3];
var optimize = process.argv[4];
var newContractName = process.argv[5];
var externalLibraries = JSON.parse(process.argv[6])
var evmVersion = process.argv[7]
var optimizationRuns = parseInt(process.argv[5], 10);
var newContractName = process.argv[6];
var externalLibraries = JSON.parse(process.argv[7])
var evmVersion = process.argv[8];
var compiled_code = solc.loadRemoteVersion(version, function (err, solcSnapshot) {
if (err) {
@ -24,7 +25,7 @@ var compiled_code = solc.loadRemoteVersion(version, function (err, solcSnapshot)
evmVersion: evmVersion,
optimizer: {
enabled: optimize == '1',
runs: 200
runs: optimizationRuns
},
libraries: {
[newContractName]: externalLibraries

Loading…
Cancel
Save