fix: advanced filter contract creation transaction (#10257)

pull/10259/head
Maxim Filonov 5 months ago committed by GitHub
parent 9448ccb7c8
commit 454edb0d2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      apps/block_scout_web/lib/block_scout_web/views/api/v2/advanced_filter_view.ex
  2. 24
      apps/explorer/lib/explorer/chain/advanced_filter.ex

@ -56,6 +56,7 @@ defmodule BlockScoutWeb.API.V2.AdvancedFilterView do
"UtcTimestamp",
"FromAddress",
"ToAddress",
"CreatedContractAddress",
"Value",
"TokenContractAddressHash",
"TokenDecimals",
@ -83,8 +84,9 @@ defmodule BlockScoutWeb.API.V2.AdvancedFilterView do
advanced_filter.type,
method_id,
advanced_filter.timestamp,
Address.checksum(advanced_filter.from_address.hash),
Address.checksum(advanced_filter.to_address.hash),
Address.checksum(advanced_filter.from_address_hash),
Address.checksum(advanced_filter.to_address_hash),
Address.checksum(advanced_filter.created_contract_address_hash),
advanced_filter.value,
if(advanced_filter.type != "coin_transfer",
do: advanced_filter.token_transfer.token.contract_address_hash,
@ -130,14 +132,21 @@ defmodule BlockScoutWeb.API.V2.AdvancedFilterView do
Helper.address_with_info(
nil,
advanced_filter.from_address,
advanced_filter.from_address.hash,
advanced_filter.from_address_hash,
false
),
to:
Helper.address_with_info(
nil,
advanced_filter.to_address,
advanced_filter.to_address.hash,
advanced_filter.to_address_hash,
false
),
created_contract:
Helper.address_with_info(
nil,
advanced_filter.created_contract_address,
advanced_filter.created_contract_address_hash,
false
),
value: advanced_filter.value,

@ -33,6 +33,14 @@ defmodule Explorer.Chain.AdvancedFilter do
type: Hash.Address
)
belongs_to(
:created_contract_address,
Address,
foreign_key: :created_contract_address_hash,
references: :hash,
type: Hash.Address
)
field(:value, :decimal, null: true)
has_one(:token_transfer, TokenTransfer, foreign_key: :transaction_hash, references: :hash, null: true)
@ -137,7 +145,11 @@ defmodule Explorer.Chain.AdvancedFilter do
input: transaction.input,
timestamp: transaction.block_timestamp,
from_address: transaction.from_address,
from_address_hash: transaction.from_address_hash,
to_address: transaction.to_address,
to_address_hash: transaction.to_address_hash,
created_contract_address: transaction.created_contract_address,
created_contract_address_hash: transaction.created_contract_address_hash,
value: transaction.value.value,
fee: transaction |> Transaction.fee(:wei) |> elem(1),
block_number: transaction.block_number,
@ -152,7 +164,11 @@ defmodule Explorer.Chain.AdvancedFilter do
input: internal_transaction.input,
timestamp: internal_transaction.transaction.block_timestamp,
from_address: internal_transaction.from_address,
from_address_hash: internal_transaction.from_address_hash,
to_address: internal_transaction.to_address,
to_address_hash: internal_transaction.to_address_hash,
created_contract_address: internal_transaction.created_contract_address,
created_contract_address_hash: internal_transaction.created_contract_address_hash,
value: internal_transaction.value.value,
fee:
internal_transaction.transaction.gas_price && internal_transaction.gas_used &&
@ -170,7 +186,11 @@ defmodule Explorer.Chain.AdvancedFilter do
input: token_transfer.transaction.input,
timestamp: token_transfer.transaction.block_timestamp,
from_address: token_transfer.from_address,
from_address_hash: token_transfer.from_address_hash,
to_address: token_transfer.to_address,
to_address_hash: token_transfer.to_address_hash,
created_contract_address: nil,
created_contract_address_hash: nil,
fee: token_transfer.transaction |> Transaction.fee(:wei) |> elem(1),
token_transfer: %TokenTransfer{
token_transfer
@ -232,7 +252,8 @@ defmodule Explorer.Chain.AdvancedFilter do
preload: [
:block,
from_address: [:names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations]
to_address: [:names, :smart_contract, :proxy_implementations],
created_contract_address: [:names, :smart_contract, :proxy_implementations]
],
order_by: [
desc: transaction.block_number,
@ -269,6 +290,7 @@ defmodule Explorer.Chain.AdvancedFilter do
preload: [
from_address: [:names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations],
created_contract_address: [:names, :smart_contract, :proxy_implementations],
transaction: transaction
],
order_by: [

Loading…
Cancel
Save