Merge pull request #2064 from poanetwork/add-tx-identifier-fields-to-api

feat: add fields to tx apis, small cleanups
pull/2098/head
Victor Baranov 5 years ago committed by GitHub
commit 95d9041413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 3
      apps/block_scout_web/lib/block_scout_web/etherscan.ex
  3. 4
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  4. 3
      apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex
  5. 18
      apps/block_scout_web/priv/gettext/default.pot
  6. 24
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  7. 2
      apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
  8. 5
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs
  9. 3
      apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs
  10. 5
      apps/explorer/lib/explorer/etherscan.ex
  11. 2
      apps/explorer/test/explorer/etherscan_test.exs

@ -21,6 +21,7 @@
- [#2040](https://github.com/poanetwork/blockscout/pull/2040) - Verification links to other explorers for ETH
- [#2037](https://github.com/poanetwork/blockscout/pull/2037) - add address logs search functionality
- [#2012](https://github.com/poanetwork/blockscout/pull/2012) - make all pages pagination async
- [#2064](https://github.com/poanetwork/blockscout/pull/2064) - feat: add fields to tx apis, small cleanups
### Fixes
- [#2082](https://github.com/poanetwork/blockscout/pull/2082) - dropdown styles, tooltip gap fix

@ -82,6 +82,8 @@ defmodule BlockScoutWeb.Etherscan do
"to" => "",
"value" => "5488334153118633",
"contractAddress" => "0x883103875d905c11f9ac7dacbfc16deb39655361",
"transactionHash" => "0xd65b788c610949704a5f9aac2228c7c777434dfe11c863a12306f57fcbd8cdbb",
"index" => "0",
"input" => "",
"type" => "create",
"gas" => "814937",
@ -110,6 +112,7 @@ defmodule BlockScoutWeb.Etherscan do
"blockHash" => "0x6169c5dc05d0051564ba3eae8ebfbdefda640c5f5ffc095846b8aed0b44f64ea",
"from" => "0x4e83362442b8d1bec281594cea3050c8eb01311c",
"contractAddress" => "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
"logIndex" => "0",
"to" => "0x21e21ba085289f81a86921de890eed30f1ad2375",
"value" => "10000000000000000000",
"tokenName" => "Maker",

@ -253,9 +253,7 @@ defmodule BlockScoutWeb.AddressView do
address.contracts_creation_transaction.from_address_hash
end
def from_address_hash(address) do
Logger.error(fn -> ["Found a contract with no creator: ", to_string(address)] end)
def from_address_hash(_address) do
nil
end

@ -102,6 +102,8 @@ defmodule BlockScoutWeb.API.RPC.AddressView do
"to" => "#{internal_transaction.to_address_hash}",
"value" => "#{internal_transaction.value.value}",
"contractAddress" => "#{internal_transaction.created_contract_address_hash}",
"transactionHash" => to_string(internal_transaction.transaction_hash),
"index" => to_string(internal_transaction.index),
"input" => "#{internal_transaction.input}",
"type" => "#{internal_transaction.type}",
"gas" => "#{internal_transaction.gas}",
@ -121,6 +123,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do
"from" => to_string(token_transfer.from_address_hash),
"contractAddress" => to_string(token_transfer.token_contract_address_hash),
"to" => to_string(token_transfer.to_address_hash),
"logIndex" => to_string(token_transfer.token_log_index),
"value" => get_token_value(token_transfer),
"tokenName" => token_transfer.token_name,
"tokenSymbol" => token_transfer.token_symbol,

@ -190,7 +190,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:32
#: lib/block_scout_web/templates/address/overview.html.eex:95
#: lib/block_scout_web/templates/address_validation/index.html.eex:13
#: lib/block_scout_web/views/address_view.ex:313
#: lib/block_scout_web/views/address_view.ex:311
msgid "Blocks Validated"
msgstr ""
@ -218,7 +218,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:42
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187
#: lib/block_scout_web/views/address_view.ex:309
#: lib/block_scout_web/views/address_view.ex:307
msgid "Code"
msgstr ""
@ -471,7 +471,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:308
#: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/transaction_view.ex:339
msgid "Internal Transactions"
msgstr ""
@ -498,7 +498,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_logs/index.html.eex:8
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:314
#: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/transaction_view.ex:340
msgid "Logs"
msgstr ""
@ -638,7 +638,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:58
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25
#: lib/block_scout_web/views/address_view.ex:311
#: lib/block_scout_web/views/address_view.ex:309
#: lib/block_scout_web/views/tokens/overview_view.ex:37
msgid "Read Contract"
msgstr ""
@ -814,7 +814,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:8
#: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:9
#: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/address_view.ex:304
msgid "Tokens"
msgstr ""
@ -872,7 +872,7 @@ msgstr ""
#: lib/block_scout_web/templates/block_transaction/index.html.eex:18
#: lib/block_scout_web/templates/chain/show.html.eex:108
#: lib/block_scout_web/templates/layout/_topnav.html.eex:35
#: lib/block_scout_web/views/address_view.ex:307
#: lib/block_scout_web/views/address_view.ex:305
msgid "Transactions"
msgstr ""
@ -1248,7 +1248,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:20
#: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/address_view.ex:310
msgid "Coin Balance History"
msgstr ""
@ -1497,7 +1497,7 @@ msgid "Copy Decompiled Contract Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/address_view.ex:310
#: lib/block_scout_web/views/address_view.ex:308
msgid "Decompiled Code"
msgstr ""

@ -190,7 +190,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:32
#: lib/block_scout_web/templates/address/overview.html.eex:95
#: lib/block_scout_web/templates/address_validation/index.html.eex:13
#: lib/block_scout_web/views/address_view.ex:313
#: lib/block_scout_web/views/address_view.ex:311
msgid "Blocks Validated"
msgstr ""
@ -207,8 +207,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37
#: lib/block_scout_web/templates/address/overview.html.eex:144
#: lib/block_scout_web/templates/address/overview.html.eex:152
#: lib/block_scout_web/templates/address/overview.html.eex:142
#: lib/block_scout_web/templates/address/overview.html.eex:150
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:106
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:114
msgid "Close"
@ -218,7 +218,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:42
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187
#: lib/block_scout_web/views/address_view.ex:309
#: lib/block_scout_web/views/address_view.ex:307
msgid "Code"
msgstr ""
@ -471,7 +471,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:308
#: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/transaction_view.ex:339
msgid "Internal Transactions"
msgstr ""
@ -498,7 +498,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_logs/index.html.eex:8
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:314
#: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/transaction_view.ex:340
msgid "Logs"
msgstr ""
@ -624,7 +624,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:33
#: lib/block_scout_web/templates/address/overview.html.eex:143
#: lib/block_scout_web/templates/address/overview.html.eex:141
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:35
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:105
msgid "QR Code"
@ -638,7 +638,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:58
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25
#: lib/block_scout_web/views/address_view.ex:311
#: lib/block_scout_web/views/address_view.ex:309
#: lib/block_scout_web/views/tokens/overview_view.ex:37
msgid "Read Contract"
msgstr ""
@ -814,7 +814,7 @@ msgstr ""
#: lib/block_scout_web/templates/address/_tabs.html.eex:8
#: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:9
#: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/address_view.ex:304
msgid "Tokens"
msgstr ""
@ -872,7 +872,7 @@ msgstr ""
#: lib/block_scout_web/templates/block_transaction/index.html.eex:18
#: lib/block_scout_web/templates/chain/show.html.eex:108
#: lib/block_scout_web/templates/layout/_topnav.html.eex:35
#: lib/block_scout_web/views/address_view.ex:307
#: lib/block_scout_web/views/address_view.ex:305
msgid "Transactions"
msgstr ""
@ -1248,7 +1248,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:20
#: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/address_view.ex:310
msgid "Coin Balance History"
msgstr ""
@ -1497,7 +1497,7 @@ msgid "Copy Decompiled Contract Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/address_view.ex:310
#: lib/block_scout_web/views/address_view.ex:308
msgid "Decompiled Code"
msgstr ""

@ -23,7 +23,7 @@ defmodule BlockScoutWeb.AddressControllerTest do
test "returns an address's primary name when present", %{conn: conn} do
address = insert(:address, fetched_coin_balance: 1)
address_name = insert(:address_name, address: address, primary: true, name: "POA Wallet")
insert(:address_name, address: address, primary: true, name: "POA Wallet")
start_supervised!(AddressesWithBalanceCounter)
AddressesWithBalanceCounter.consolidate()

@ -1412,6 +1412,8 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
"type" => "#{internal_transaction.type}",
"gas" => "#{internal_transaction.gas}",
"gasUsed" => "#{internal_transaction.gas_used}",
"index" => "#{internal_transaction.index}",
"transactionHash" => "#{transaction.hash}",
"isError" => "0",
"errCode" => "#{internal_transaction.error}"
}
@ -1559,6 +1561,8 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
"gas" => "#{internal_transaction.gas}",
"gasUsed" => "#{internal_transaction.gas_used}",
"isError" => "0",
"index" => "#{internal_transaction.index}",
"transactionHash" => "#{transaction.hash}",
"errCode" => "#{internal_transaction.error}"
}
]
@ -1767,6 +1771,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
"gasPrice" => to_string(transaction.gas_price.value),
"gasUsed" => to_string(transaction.gas_used),
"cumulativeGasUsed" => to_string(transaction.cumulative_gas_used),
"logIndex" => to_string(token_transfer.log_index),
"input" => to_string(transaction.input),
"confirmations" => "0"
}

@ -1,7 +1,6 @@
defmodule BlockScoutWeb.BlockTransactionControllerTest do
use BlockScoutWeb.ConnCase
alias Explorer.Chain.Block
import BlockScoutWeb.Router.Helpers, only: [block_transaction_path: 3]
describe "GET index/2" do
@ -153,7 +152,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
end
test "next_page_path exists if not on last page", %{conn: conn} do
block = %Block{number: number} = insert(:block)
block = insert(:block)
60
|> insert_list(:transaction)

@ -56,6 +56,8 @@ defmodule Explorer.Etherscan do
@internal_transaction_fields ~w(
from_address_hash
to_address_hash
transaction_hash
index
value
created_contract_address_hash
input
@ -348,7 +350,8 @@ defmodule Explorer.Etherscan do
token_name: tkn.name,
token_symbol: tkn.symbol,
token_decimals: tkn.decimals,
token_type: tkn.type
token_type: tkn.type,
token_log_index: tt.log_index
})
)

@ -631,6 +631,8 @@ defmodule Explorer.EtherscanTest do
value: internal_transaction.value,
created_contract_address_hash: internal_transaction.created_contract_address_hash,
input: internal_transaction.input,
index: internal_transaction.index,
transaction_hash: internal_transaction.transaction_hash,
type: internal_transaction.type,
gas: internal_transaction.gas,
gas_used: internal_transaction.gas_used,

Loading…
Cancel
Save