Skip to content

Commit

Permalink
Merge pull request #1638 from oasisprotocol/mz/tokenTransferQuery
Browse files Browse the repository at this point in the history
Use correct query param in token transfers card
  • Loading branch information
buberdds authored Dec 18, 2024
2 parents 0bf0010 + 574dbad commit 90eed80
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .changelog/1638.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use correct query param in token Transfers card
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AccountTokenTransfersCard: FC<RuntimeAccountDetailsContext> = ({ sc

const AccountTokenTransfers: FC<RuntimeAccountDetailsContext> = ({ scope, address, account }) => {
const { t } = useTranslation()
const { isLoading, isFetched, results } = useTokenTransfers(scope, { address })
const { isLoading, isFetched, results } = useTokenTransfers(scope, { rel: address })

const transfers = results.data

Expand Down
6 changes: 5 additions & 1 deletion src/app/pages/TokenDashboardPage/TokenTransfersCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export const TokenTransfersCard: FC<TokenDashboardContext> = ({ scope, address }
const TokenTransfersView: FC<TokenDashboardContext> = ({ scope, address }) => {
const { t } = useTranslation()

const { isLoading: areTransfersLoading, isFetched, results } = useTokenTransfers(scope, { address })
const {
isLoading: areTransfersLoading,
isFetched,
results,
} = useTokenTransfers(scope, { contract_address: address })

const { isLoading: isTokenLoading } = useTokenInfo(scope, address)

Expand Down
8 changes: 2 additions & 6 deletions src/app/pages/TokenDashboardPage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ export const useTokenInfo = (scope: SearchScope, address: string, enabled = true
}
}

export const useTokenTransfers = (scope: SearchScope, params: { address: string }) => {
return _useTokenTransfers(scope, { rel: params.address })
}

export const useNFTInstanceTransfers = (
scope: SearchScope,
params: { nft_id: string; contract_address: string },
) => {
return _useTokenTransfers(scope, { nft_id: params.nft_id, contract_address: params.contract_address })
return useTokenTransfers(scope, { nft_id: params.nft_id, contract_address: params.contract_address })
}

export const _useTokenTransfers = (scope: SearchScope, params: undefined | GetRuntimeEventsParams) => {
export const useTokenTransfers = (scope: SearchScope, params: undefined | GetRuntimeEventsParams) => {
if (params && Object.values(params).some(value => value === undefined || value === null)) {
throw new Error('Must set params=undefined while some values are unavailable')
}
Expand Down

0 comments on commit 90eed80

Please sign in to comment.