fix metadata decomdiing in smart contract verification

pull/2225/head
Ayrat Badykov 6 years ago
parent 8c62be450d
commit 4f8dceed1c
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 6
      apps/explorer/lib/explorer/smart_contract/verifier.ex
  2. 5
      apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex

@ -107,6 +107,12 @@ defmodule Explorer.SmartContract.Verifier do
|> Enum.reverse() |> Enum.reverse()
|> :binary.list_to_bin() |> :binary.list_to_bin()
# Solidity >= 0.5.9; https://github.com/ethereum/solidity/blob/aa4ee3a1559ebc0354926af962efb3fcc7dc15bd/docs/metadata.rst
"a265627a7a72305820" <> <<_::binary-size(64)>> <> "64736f6c6343" <> <<_::binary-size(6)>> <> "0032" <> _constructor_arguments ->
extracted
|> Enum.reverse()
|> :binary.list_to_bin()
<<next::binary-size(2)>> <> rest -> <<next::binary-size(2)>> <> rest ->
do_extract_bytecode([next | extracted], rest) do_extract_bytecode([next | extracted], rest)
end end

@ -21,6 +21,11 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do
constructor_arguments constructor_arguments
end end
# Solidity >= 0.5.9; https://github.com/ethereum/solidity/blob/aa4ee3a1559ebc0354926af962efb3fcc7dc15bd/docs/metadata.rst
defp extract_contrstructor_arguments("a265627a7a72305820" <> <<_::binary-size(64)>> <> "64736f6c6343" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments) do
constructor_arguments
end
defp extract_constructor_arguments(<<_::binary-size(2)>> <> rest) do defp extract_constructor_arguments(<<_::binary-size(2)>> <> rest) do
extract_constructor_arguments(rest) extract_constructor_arguments(rest)
end end

Loading…
Cancel
Save