feat: Add token decimals to token transfers CSV export (#10589)

* Add token decimals to token transfers CSV export

* Fix tests

* Process review comments
pull/10443/head
Victor Baranov 3 months ago committed by GitHub
parent ebc99bfff9
commit f4540a3601
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/explorer/lib/explorer/chain/csv_export/address_token_transfer_csv_exporter.ex
  2. 9
      apps/explorer/test/explorer/chain/csv_export/address_token_transfer_csv_exporter_test.exs

@ -55,6 +55,7 @@ defmodule Explorer.Chain.CSVExport.AddressTokenTransferCsvExporter do
"ToAddress",
"TokenContractAddress",
"Type",
"TokenDecimals",
"TokenSymbol",
"TokensTransferred",
"TransactionFee",
@ -73,6 +74,7 @@ defmodule Explorer.Chain.CSVExport.AddressTokenTransferCsvExporter do
Address.checksum(token_transfer.to_address_hash),
Address.checksum(token_transfer.token_contract_address_hash),
type(token_transfer, address_hash),
token_transfer.token.decimals,
token_transfer.token.symbol,
token_transfer.amount,
fee(token_transfer.transaction),

@ -15,6 +15,7 @@ defmodule Explorer.Chain.AddressTokenTransferCsvExporterTest do
token_transfer =
insert(:token_transfer, transaction: transaction, from_address: address, block_number: transaction.block_number)
|> Repo.preload([:token, :transaction])
from_period = Timex.format!(Timex.shift(Timex.now(), minutes: -1), "%Y-%m-%d", :strftime)
to_period = Timex.format!(Timex.now(), "%Y-%m-%d", :strftime)
@ -39,6 +40,8 @@ defmodule Explorer.Chain.AddressTokenTransferCsvExporterTest do
_,
[[], type],
_,
[[], token_decimals],
_,
[[], token_symbol],
_,
[[], tokens_transferred],
@ -58,6 +61,7 @@ defmodule Explorer.Chain.AddressTokenTransferCsvExporterTest do
to_address: to_address,
token_contract_address: token_contract_address,
type: type,
token_decimals: token_decimals,
token_symbol: token_symbol,
tokens_transferred: tokens_transferred,
transaction_fee: transaction_fee,
@ -71,6 +75,11 @@ defmodule Explorer.Chain.AddressTokenTransferCsvExporterTest do
assert result.from_address == Address.checksum(token_transfer.from_address_hash)
assert result.to_address == Address.checksum(token_transfer.to_address_hash)
assert result.timestamp == to_string(transaction.block_timestamp)
assert result.token_symbol == to_string(token_transfer.token.symbol)
assert result.token_decimals == to_string(token_transfer.token.decimals)
assert result.tokens_transferred == to_string(token_transfer.amount)
assert result.status == to_string(token_transfer.transaction.status)
assert result.err_code == to_string(token_transfer.transaction.error)
assert result.type == "OUT"
end

Loading…
Cancel
Save