diff --git a/apps/explorer/lib/explorer/smart_contract/verifier.ex b/apps/explorer/lib/explorer/smart_contract/verifier.ex index 6092a39c87..86f5b40a71 100644 --- a/apps/explorer/lib/explorer/smart_contract/verifier.ex +++ b/apps/explorer/lib/explorer/smart_contract/verifier.ex @@ -13,9 +13,8 @@ defmodule Explorer.SmartContract.Verifier do alias Explorer.SmartContract.Verifier.ConstructorArguments @metadata_hash_prefix_0_4_23 "a165627a7a72305820" - @metadata_hash_prefix_0_5_10 "a265627a7a72305820" - @metadata_hash_prefix_0_5_11 "a265627a7a72315820" - @metadata_hash_prefix_0_5_16 "a365627a7a72315820" + @metadata_hash_prefix_0_5_family_1 "65627a7a723" + @metadata_hash_prefix_0_5_family_2 "5820" @metadata_hash_prefix_0_6_0 "a264697066735822" @experimental "6c6578706572696d656e74616cf5" @@ -191,165 +190,68 @@ defmodule Explorer.SmartContract.Verifier do @metadata_hash_prefix_0_4_23 <> <> <> "0029" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - # Solidity >= 0.5.9; https://github.com/ethereum/solidity/blob/aa4ee3a1559ebc0354926af962efb3fcc7dc15bd/docs/metadata.rst - @metadata_hash_prefix_0_5_10 <> - <> <> - @metadata_hash_common_suffix <> - "43" <> <> <> "0032" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_10 <> - <> <> - @metadata_hash_common_suffix <> - "7826" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_10 <> - <> <> - @metadata_hash_common_suffix <> - "7827" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_10 <> - <> <> - @metadata_hash_common_suffix <> - "7828" <> <> <> "0058" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_10 <> - <> <> - @metadata_hash_common_suffix <> - "7829" <> <> <> "0059" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - # Solidity >= 0.5.11 https://github.com/ethereum/solidity/blob/develop/Changelog.md#0511-2019-08-12 - # Metadata: Update the swarm hash to the current specification, changes bzzr0 to bzzr1 and urls to use bzz-raw:// - @metadata_hash_prefix_0_5_11 <> - <> <> - @metadata_hash_common_suffix <> - "43" <> <> <> "0032" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @experimental <> - @metadata_hash_common_suffix <> - "43" <> <> <> "0032" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @metadata_hash_common_suffix <> - "7826" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @experimental <> - @metadata_hash_common_suffix <> - "7826" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @metadata_hash_common_suffix <> - "7827" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @experimental <> - @metadata_hash_common_suffix <> - "7827" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> - <> <> - @metadata_hash_common_suffix <> - "7828" <> <> <> "0058" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> + # Solidity >= 0.5 family && experimantal + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> @experimental <> @metadata_hash_common_suffix <> - "7828" <> <> <> "0058" <> _constructor_arguments -> + "43" <> <> <> <<_::binary-size(4)>> <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_11 <> - <> <> - @metadata_hash_common_suffix <> - "7829" <> <> <> "0059" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_11 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> @experimental <> - @metadata_hash_common_suffix <> - "7829" <> <> <> "0059" <> _constructor_arguments -> + <<_::binary-size(4)>> <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_16 <> + # Solidity >= 0.5.9; https://github.com/ethereum/solidity/blob/aa4ee3a1559ebc0354926af962efb3fcc7dc15bd/docs/metadata.rst + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> @metadata_hash_common_suffix <> "43" <> <> <> "0032" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> - @experimental <> - @metadata_hash_common_suffix <> - "43" <> <> <> "0040" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_16 <> - <> <> - @metadata_hash_common_suffix <> - "7826" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_16 <> - <> <> - @experimental <> @metadata_hash_common_suffix <> "7826" <> <> <> "0057" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> @metadata_hash_common_suffix <> "7827" <> <> <> "0057" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_16 <> - <> <> - @experimental <> - @metadata_hash_common_suffix <> - "7827" <> <> <> "0057" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> @metadata_hash_common_suffix <> "7828" <> <> <> "0058" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <> <> - @experimental <> - @metadata_hash_common_suffix <> - "7828" <> <> <> "0058" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_16 <> - <> <> - @metadata_hash_common_suffix <> - "7829" <> <> <> "0059" <> _constructor_arguments -> - do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) - - @metadata_hash_prefix_0_5_16 <> - <> <> - @experimental <> @metadata_hash_common_suffix <> "7829" <> <> <> "0059" <> _constructor_arguments -> do_extract_bytecode_and_metadata_hash_output(metadata_hash, extracted, compiler_version) diff --git a/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex b/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex index ac66b14c6c..ec8b39a892 100644 --- a/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex +++ b/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex @@ -7,9 +7,8 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do alias Explorer.Chain @metadata_hash_prefix_0_4_23 "a165627a7a72305820" - @metadata_hash_prefix_0_5_10 "a265627a7a72305820" - @metadata_hash_prefix_0_5_11 "a265627a7a72315820" - @metadata_hash_prefix_0_5_16 "a365627a7a72315820" + @metadata_hash_prefix_0_5_family_1 "65627a7a723" + @metadata_hash_prefix_0_5_family_2 "5820" @metadata_hash_prefix_0_6_0 "a264697066735822" @experimental "6c6578706572696d656e74616cf5" @@ -53,227 +52,70 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do @metadata_hash_prefix_0_4_23 ) - # Solidity >= 0.5.10 https://solidity.readthedocs.io/en/v0.5.10/metadata.html - @metadata_hash_prefix_0_5_10 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_10 - ) - - @metadata_hash_prefix_0_5_10 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_10 - ) - - @metadata_hash_prefix_0_5_10 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_10 - ) - - @metadata_hash_prefix_0_5_10 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_10 - ) - - @metadata_hash_prefix_0_5_10 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_10 - ) - - # Solidity >= 0.5.11 https://github.com/ethereum/solidity/blob/develop/Changelog.md#0511-2019-08-12 - # Metadata: Update the swarm hash to the current specification, changes bzzr0 to bzzr1 and urls to use bzz-raw:// - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @experimental <> - @metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @experimental <> - @metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @experimental <> - @metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> @experimental <> - @metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_11 - ) - - @metadata_hash_prefix_0_5_11 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments -> + @metadata_hash_common_suffix <> + "43" <> <<_::binary-size(6)>> <> <<_::binary-size(4)>> <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( constructor_arguments, check_func, contract_source_code, contract_name, - @metadata_hash_prefix_0_5_11 + @metadata_hash_prefix_0_5_family_1 ) - @metadata_hash_prefix_0_5_11 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> @experimental <> - @metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments -> + <<_::binary-size(4)>> <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( constructor_arguments, check_func, contract_source_code, contract_name, - @experimental <> @metadata_hash_prefix_0_5_11 + @metadata_hash_prefix_0_5_family_1 ) - # ABIEncoder V2 - @metadata_hash_prefix_0_5_16 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_16 - ) - - @metadata_hash_prefix_0_5_16 <> + # Solidity >= 0.5.10 https://solidity.readthedocs.io/en/v0.5.10/metadata.html + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> - @experimental <> @metadata_hash_common_suffix <> "43" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( constructor_arguments, check_func, contract_source_code, contract_name, - @experimental <> @metadata_hash_prefix_0_5_16 - ) - - @metadata_hash_prefix_0_5_16 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_16 + @metadata_hash_prefix_0_5_family_1 ) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> - @experimental <> @metadata_hash_common_suffix <> "7826" <> <<_::binary-size(76)>> <> "0057" <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( constructor_arguments, check_func, contract_source_code, contract_name, - @experimental <> @metadata_hash_prefix_0_5_16 + @metadata_hash_prefix_0_5_family_1 ) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> @metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( @@ -281,45 +123,27 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do check_func, contract_source_code, contract_name, - @metadata_hash_prefix_0_5_16 + @metadata_hash_prefix_0_5_family_1 ) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> - @experimental <> - @metadata_hash_common_suffix <> "7827" <> <<_::binary-size(78)>> <> "0057" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_16 - ) - - @metadata_hash_prefix_0_5_16 <> - <<_::binary-size(64)>> <> - @metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @metadata_hash_prefix_0_5_16 - ) - - @metadata_hash_prefix_0_5_16 <> - <<_::binary-size(64)>> <> - @experimental <> @metadata_hash_common_suffix <> "7828" <> <<_::binary-size(80)>> <> "0058" <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( constructor_arguments, check_func, contract_source_code, contract_name, - @experimental <> @metadata_hash_prefix_0_5_16 + @metadata_hash_prefix_0_5_family_1 ) - @metadata_hash_prefix_0_5_16 <> + <<_::binary-size(2)>> <> + @metadata_hash_prefix_0_5_family_1 <> + <<_::binary-size(1)>> <> + @metadata_hash_prefix_0_5_family_2 <> <<_::binary-size(64)>> <> @metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments -> split_constructor_arguments_and_extract_check_func( @@ -327,19 +151,7 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do check_func, contract_source_code, contract_name, - @metadata_hash_prefix_0_5_16 - ) - - @metadata_hash_prefix_0_5_16 <> - <<_::binary-size(64)>> <> - @experimental <> - @metadata_hash_common_suffix <> "7829" <> <<_::binary-size(82)>> <> "0059" <> constructor_arguments -> - split_constructor_arguments_and_extract_check_func( - constructor_arguments, - check_func, - contract_source_code, - contract_name, - @experimental <> @metadata_hash_prefix_0_5_16 + @metadata_hash_prefix_0_5_family_1 ) # Solidity >= 0.6.0 https://github.com/ethereum/solidity/blob/develop/Changelog.md#060-2019-12-17