Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix txlist RPC endpoint to use the token info for fee currencies #1047

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do
"confirmations" => "#{transaction.confirmations}",
"gatewayFeeRecipient" => "#{transaction.gas_fee_recipient_hash}",
"gatewayFee" => "#{transaction.gateway_fee}",
"feeCurrency" => Util.contract_name_to_symbol(transaction.fee_currency, true)
"feeCurrency" => Util.fee_currency_token_symbol(transaction.fee_currency)
}
end

Expand Down
9 changes: 3 additions & 6 deletions apps/explorer/lib/explorer/celo/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ defmodule Explorer.Celo.Util do
Map.values(@celo_token_contract_symbols)
end

def contract_name_to_symbol(name, use_celo_instead_cgld?) do
def fee_currency_token_symbol(name) do
case name do
n when n in [nil, "goldToken"] ->
if(use_celo_instead_cgld?, do: "CELO", else: "cGLD")

_ ->
@celo_token_contract_symbols[name]
n when n in [nil, "cGLD"] -> "CELO"
_ -> name
end
end
end
8 changes: 4 additions & 4 deletions apps/explorer/lib/explorer/etherscan.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Explorer.Etherscan do
alias Explorer.Etherscan.Logs
alias Explorer.{Chain, Repo}
alias Explorer.Chain.Address.{CurrentTokenBalance, TokenBalance}
alias Explorer.Chain.{Address, Block, CeloParams, Hash, InternalTransaction, Log, TokenTransfer, Transaction}
alias Explorer.Chain.{Address, Block, Hash, InternalTransaction, Log, Token, TokenTransfer, Transaction}
alias Explorer.Chain.Transaction.History.TransactionStats

@default_options %{
Expand Down Expand Up @@ -490,16 +490,16 @@ defmodule Explorer.Etherscan do
t in Transaction,
join: a in ^addresses_wrapped_subquery,
on: t.hash == a.hash,
left_join: p in CeloParams,
on: t.gas_currency_hash == p.address_value,
left_join: k in Token,
on: t.gas_currency_hash == k.contract_address_hash,
inner_join: b in Block,
on: b.number == t.block_number,
order_by: [{^options.order_by_direction, t.block_number}],
limit: ^options.page_size,
offset: ^offset(options),
select:
merge(map(t, ^@transaction_fields), %{
fee_currency: p.name,
fee_currency: k.symbol,
block_timestamp: b.timestamp,
confirmations: fragment("? - ?", ^max_block_number, t.block_number)
})
Expand Down
Loading