|
|
@ -36,9 +36,9 @@ defmodule Explorer.SmartContract.Publisher do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp publish_smart_contract(address_hash, params, abi) do |
|
|
|
defp publish_smart_contract(address_hash, params, abi) do |
|
|
|
address_hash |
|
|
|
attrs = address_hash |> attributes(params, abi) |
|
|
|
|> attributes(params, abi) |
|
|
|
|
|
|
|
|> Chain.create_smart_contract() |
|
|
|
Chain.create_smart_contract(attrs, attrs.external_libraries) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp unverified_smart_contract(address_hash, params, error) do |
|
|
|
defp unverified_smart_contract(address_hash, params, error) do |
|
|
@ -64,6 +64,8 @@ defmodule Explorer.SmartContract.Publisher do |
|
|
|
nil |
|
|
|
nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prepared_external_libraries = prepare_external_libraies(params["external_libraries"]) |
|
|
|
|
|
|
|
|
|
|
|
%{ |
|
|
|
%{ |
|
|
|
address_hash: address_hash, |
|
|
|
address_hash: address_hash, |
|
|
|
name: params["name"], |
|
|
|
name: params["name"], |
|
|
@ -73,11 +75,20 @@ defmodule Explorer.SmartContract.Publisher do |
|
|
|
optimization: params["optimization"], |
|
|
|
optimization: params["optimization"], |
|
|
|
contract_source_code: params["contract_source_code"], |
|
|
|
contract_source_code: params["contract_source_code"], |
|
|
|
constructor_arguments: clean_constructor_arguments, |
|
|
|
constructor_arguments: clean_constructor_arguments, |
|
|
|
external_libaries: params["external_libraries"], |
|
|
|
external_libraries: prepared_external_libraries, |
|
|
|
abi: abi |
|
|
|
abi: abi |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defp prepare_external_libraies(nil), do: [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defp prepare_external_libraies(map) do |
|
|
|
|
|
|
|
map |
|
|
|
|
|
|
|
|> Enum.map(fn {key, value} -> |
|
|
|
|
|
|
|
%{name: key, address_hash: value} |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp add_external_libraries(params, external_libraries) do |
|
|
|
defp add_external_libraries(params, external_libraries) do |
|
|
|
clean_external_libraries = |
|
|
|
clean_external_libraries = |
|
|
|
Enum.reduce(1..5, %{}, fn number, acc -> |
|
|
|
Enum.reduce(1..5, %{}, fn number, acc -> |
|
|
|