@ -75,30 +75,8 @@ defmodule Explorer.Chain.SmartContractTest do
string_implementation_address_hash = to_string ( implementation_smart_contract . address_hash )
expect ( EthereumJSONRPC.Mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
mock_empty_logic_storage_pointer_request ( )
|> mock_empty_beacon_storage_pointer_request ( )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
@ -296,82 +274,15 @@ defmodule Explorer.Chain.SmartContractTest do
end
def get_eip1967_implementation_zero_addresses do
EthereumJSONRPC.Mox
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
mock_empty_logic_storage_pointer_request ( )
|> mock_empty_beacon_storage_pointer_request ( )
|> mock_empty_oz_storage_pointer_request ( )
|> mock_empty_eip_1822_storage_pointer_request ( )
end
def get_eip1967_implementation_non_zero_address do
expect ( EthereumJSONRPC.Mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
mock_empty_logic_storage_pointer_request ( )
|> mock_empty_beacon_storage_pointer_request ( )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
@ -400,42 +311,9 @@ defmodule Explorer.Chain.SmartContractTest do
_options ->
{ :error , " error " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> mock_empty_beacon_storage_pointer_request ( )
|> mock_empty_oz_storage_pointer_request ( )
|> mock_empty_eip_1822_storage_pointer_request ( )
end
def assert_empty_implementation ( address_hash ) do
@ -893,6 +771,23 @@ defmodule Explorer.Chain.SmartContractTest do
end
defp expect_address_in_response ( string_implementation_address_hash ) do
mock_empty_logic_storage_pointer_request ( )
|> mock_empty_beacon_storage_pointer_request ( )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3 " ,
" latest "
]
} ,
_options ->
{ :ok , string_implementation_address_hash }
end )
end
defp mock_empty_logic_storage_pointer_request do
expect ( EthereumJSONRPC.Mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
@ -905,29 +800,50 @@ defmodule Explorer.Chain.SmartContractTest do
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
end
defp mock_empty_beacon_storage_pointer_request ( mox ) do
expect ( mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
|> expect ( :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3 " ,
" latest "
]
} ,
_options ->
{ :ok , string_implementation_address_hash }
end
defp mock_empty_eip_1822_storage_pointer_request ( mox ) do
expect ( mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
end
defp mock_empty_oz_storage_pointer_request ( mox ) do
expect ( mox , :json_rpc , fn %{
id : 0 ,
method : " eth_getStorageAt " ,
params : [
_ ,
" 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3 " ,
" latest "
]
} ,
_options ->
{ :ok , " 0x0000000000000000000000000000000000000000000000000000000000000000 " }
end )
end
end