Skip to content

Commit

Permalink
Merge pull request #743 from oasisprotocol/csillag/consistent-filteri…
Browse files Browse the repository at this point in the history
…ng-for-token-transfer-listing

Filter token transfers consistently
  • Loading branch information
csillag authored Jul 16, 2023
2 parents a355635 + ac1734c commit 524a761
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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 524a761

Please sign in to comment.