Skip to content

Commit

Permalink
Filter token transfers consistently
Browse files Browse the repository at this point in the history
We want to do the same when looking at token transfers related to an account
and token transfers related to a token.
  • Loading branch information
csillag committed Jul 15, 2023
1 parent a355635 commit c0070a5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .changelog/738.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve token transfer listing for tokens
1 change: 1 addition & 0 deletions .changelog/743.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Filter token transfers consistently
4 changes: 2 additions & 2 deletions src/app/pages/AccountDetailsPage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useAccountTransactions = (scope: SearchScope, address: string) => {
}
}

const WANTED_EVM_LOG_EVENTS: string[] = ['Transfer']
export const WANTED_EVM_LOG_EVENTS_FOR_LISTING_TRANSFERS: string[] = ['Transfer']

export const useAccountTokenTransfers = (scope: SearchScope, address: string) => {
const { network, layer } = scope
Expand All @@ -81,7 +81,7 @@ export const useAccountTokenTransfers = (scope: SearchScope, address: string) =>
const { isFetched, isLoading, data } = query

const transfers = data?.data.events.filter(
event => !!event.evm_log_name && WANTED_EVM_LOG_EVENTS.includes(event.evm_log_name),
event => !!event.evm_log_name && WANTED_EVM_LOG_EVENTS_FOR_LISTING_TRANSFERS.includes(event.evm_log_name),
)

// TODO: fix pagination messed up by client-side filtering
Expand Down
7 changes: 5 additions & 2 deletions src/app/pages/TokenDashboardPage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppErrors } from '../../../types/errors'
import { SearchScope } from '../../../types/searchScope'
import { useSearchParamsPagination } from '../../components/Table/useSearchParamsPagination'
import { NUMBER_OF_ITEMS_ON_SEPARATE_PAGE } from '../../config'
import { WANTED_EVM_LOG_EVENTS_FOR_LISTING_TRANSFERS } from '../AccountDetailsPage/hook'

export const useTokenInfo = (scope: SearchScope, address: string, enabled = true) => {
const { network, layer } = scope
Expand Down Expand Up @@ -44,7 +45,7 @@ export const useTokenTransfers = (scope: SearchScope, address: string) => {
limit: NUMBER_OF_ITEMS_ON_SEPARATE_PAGE,
offset: offset,
rel: address,
// type: 'evm.log',
type: 'evm.log',
// TODO: maybe restrict this more later.
// If the token is a payable account (usually they're not, AFAIK),
// this will also return events where tokens were transferred to or from the token account itself.
Expand All @@ -55,7 +56,9 @@ export const useTokenTransfers = (scope: SearchScope, address: string) => {

const { isFetched, isLoading, data } = query

const transfers = data?.data.events
const transfers = data?.data.events.filter(
event => !!event.evm_log_name && WANTED_EVM_LOG_EVENTS_FOR_LISTING_TRANSFERS.includes(event.evm_log_name),
)

const totalCount = data?.data.total_count
const isTotalCountClipped = data?.data.is_total_count_clipped
Expand Down

0 comments on commit c0070a5

Please sign in to comment.