From 1f30cdb8cb30a3433378c329ac002e9187c58f3b Mon Sep 17 00:00:00 2001 From: Patrik Sletmo Date: Mon, 10 May 2021 16:25:25 +0200 Subject: [PATCH] Order token transfers after INNER JOIN (fixes #3988) --- CHANGELOG.md | 3 ++- apps/explorer/lib/explorer/etherscan.ex | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0606c2fe1c..8033df542b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Fixes - [#3946](https://github.com/blockscout/blockscout/pull/3946) - Get NFT metadata from URIs with status_code 301 -- [#3888](https://github.com/blockscout/blockscout/pull/3888) - EIP-1967 contract proxy pattern detection fix +- [#3888](https://github.com/blockscout/blockscout/pull/3888) - EIP-1967 contract proxy pattern detection fix +- [#3989](https://github.com/blockscout/blockscout/pull/3989) - Fixed bug that sometimes lead to incorrect ordering of token transfers ### Chore - [#3934](https://github.com/blockscout/blockscout/pull/3934) - Update nimble_csv package diff --git a/apps/explorer/lib/explorer/etherscan.ex b/apps/explorer/lib/explorer/etherscan.ex index eb7f743ad4..a633197074 100644 --- a/apps/explorer/lib/explorer/etherscan.ex +++ b/apps/explorer/lib/explorer/etherscan.ex @@ -461,6 +461,7 @@ defmodule Explorer.Etherscan do inner_join: t in Transaction, on: tt.transaction_hash == t.hash and tt.block_number == t.block_number and tt.block_hash == t.block_hash, inner_join: b in assoc(t, :block), + order_by: [{^options.order_by_direction, tt.block_number}, {^options.order_by_direction, tt.token_log_index}], select: %{ token_contract_address_hash: tt.token_contract_address_hash, transaction_hash: tt.transaction_hash,