From e75d3b7471af20c54cb3a54a609ad4b8beab98d4 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Fri, 30 Apr 2021 16:45:05 +0300 Subject: [PATCH] Convert decimal to integer (cherry picked from commit d6c492be9c8f4d31f71e75cd1e9221d8379fc9b2) --- apps/indexer/lib/indexer/fetcher/token_balance.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/indexer/lib/indexer/fetcher/token_balance.ex b/apps/indexer/lib/indexer/fetcher/token_balance.ex index eb75300426..473b52a6d9 100644 --- a/apps/indexer/lib/indexer/fetcher/token_balance.ex +++ b/apps/indexer/lib/indexer/fetcher/token_balance.ex @@ -145,8 +145,15 @@ defmodule Indexer.Fetcher.TokenBalance do ) do retries_count = Map.get(token_balance, :retries_count, 0) + token_id_int = + case token_id do + %Decimal{} -> Decimal.to_integer(token_id) + id_int when is_integer(id_int) -> id_int + _ -> token_id + end + {address_hash.bytes, token_contract_address_hash.bytes, block_number, token_type, - token_id && Decimal.to_integer(token_id), retries_count} + token_id_int, retries_count} end defp format_params(