Fix review comments; Fix txransaction actions preload

pull/8957/head
Nikita Pozdniakov 11 months ago
parent 005b1b20ac
commit ccfadcee82
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 13
      apps/block_scout_web/lib/block_scout_web/microservice_interfaces/transaction_interpretation.ex
  2. 6
      apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex
  3. 4
      config/runtime.exs

@ -17,7 +17,7 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
@api_true api?: true
@items_limit 50
@spec interpret(any) :: {:error, :disabled | binary} | {:ok, any}
@spec interpret(Transaction.t()) :: {:error, :disabled | binary} | {:ok, any}
def interpret(transaction) do
if enabled?() do
url = interpret_url()
@ -64,7 +64,7 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
end
defp prepare_request_body(transaction) do
preloaded_transaction =
transaction =
Chain.select_repo(@api_true).preload(transaction, [
:transaction_actions,
to_address: [:names, :smart_contract],
@ -79,13 +79,12 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
%{
data: %{
to:
Helper.address_with_info(nil, preloaded_transaction.to_address, preloaded_transaction.to_address_hash, true),
to: Helper.address_with_info(nil, transaction.to_address, transaction.to_address_hash, true),
from:
Helper.address_with_info(
nil,
preloaded_transaction.from_address,
preloaded_transaction.from_address_hash,
transaction.from_address,
transaction.from_address_hash,
true
),
hash: transaction.hash,
@ -97,7 +96,7 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
tx_types: TransactionView.tx_types(transaction),
raw_input: transaction.input,
decoded_input: decoded_input_data,
token_transfers: prepare_token_transfers(preloaded_transaction, decoded_input)
token_transfers: prepare_token_transfers(transaction, decoded_input)
},
logs_data: %{items: prepare_logs(transaction)}
}

@ -720,7 +720,10 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
@spec tx_types(
Explorer.Chain.Transaction.t(),
list,
[tx_type],
tx_type
) :: [tx_type]
when tx_type:
:coin_transfer
| :contract_call
| :contract_creation
@ -728,7 +731,6 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
| :rootstock_remasc
| :token_creation
| :token_transfer
) :: list
def tx_types(tx, types \\ [], stage \\ :token_transfer)
def tx_types(%Transaction{token_transfers: token_transfers} = tx, types, :token_transfer) do

@ -133,8 +133,8 @@ config :block_scout_web, BlockScoutWeb.Chain.Address.CoinBalance,
config :block_scout_web, BlockScoutWeb.API.V2, enabled: ConfigHelper.parse_bool_env_var("API_V2_ENABLED", "true")
config :block_scout_web, BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation,
service_url: System.get_env("MICROSERVICE_TX_INTERPRETATION_URL"),
enabled: ConfigHelper.parse_bool_env_var("MICROSERVICE_TX_INTERPRETATION_ENABLED")
service_url: System.get_env("MICROSERVICE_TRANSACTION_INTERPRETATION_URL"),
enabled: ConfigHelper.parse_bool_env_var("MICROSERVICE_TRANSACTION_INTERPRETATION_ENABLED")
# Configures Ueberauth's Auth0 auth provider
config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,

Loading…
Cancel
Save