|
|
@ -8,7 +8,6 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do |
|
|
|
require Logger |
|
|
|
require Logger |
|
|
|
|
|
|
|
|
|
|
|
@new_contract_name "New.sol" |
|
|
|
@new_contract_name "New.sol" |
|
|
|
@allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
@doc """ |
|
|
|
Compiles a code in the solidity command line. |
|
|
|
Compiles a code in the solidity command line. |
|
|
@ -72,13 +71,13 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do |
|
|
|
code = Keyword.fetch!(params, :code) |
|
|
|
code = Keyword.fetch!(params, :code) |
|
|
|
optimize = Keyword.fetch!(params, :optimize) |
|
|
|
optimize = Keyword.fetch!(params, :optimize) |
|
|
|
optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string() |
|
|
|
optimization_runs = params |> Keyword.get(:optimization_runs, 200) |> Integer.to_string() |
|
|
|
evm_version = Keyword.get(params, :evm_version, List.last(@allowed_evm_versions)) |
|
|
|
evm_version = Keyword.get(params, :evm_version, List.last(allowed_evm_versions())) |
|
|
|
external_libs = Keyword.get(params, :external_libs, %{}) |
|
|
|
external_libs = Keyword.get(params, :external_libs, %{}) |
|
|
|
|
|
|
|
|
|
|
|
external_libs_string = Jason.encode!(external_libs) |
|
|
|
external_libs_string = Jason.encode!(external_libs) |
|
|
|
|
|
|
|
|
|
|
|
checked_evm_version = |
|
|
|
checked_evm_version = |
|
|
|
if evm_version in @allowed_evm_versions do |
|
|
|
if evm_version in allowed_evm_versions() do |
|
|
|
evm_version |
|
|
|
evm_version |
|
|
|
else |
|
|
|
else |
|
|
|
"byzantium" |
|
|
|
"byzantium" |
|
|
@ -125,7 +124,12 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def allowed_evm_versions, do: @allowed_evm_versions |
|
|
|
def allowed_evm_versions do |
|
|
|
|
|
|
|
:explorer |
|
|
|
|
|
|
|
|> Application.get_env(:allowed_evm_versions) |
|
|
|
|
|
|
|
|> String.split(",") |
|
|
|
|
|
|
|
|> Enum.map(fn version -> String.trim(version) end) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} |
|
|
|
def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation} |
|
|
|
|
|
|
|
|
|
|
|