11import { LazyLoadDataTable } from '@/features/common/components/lazy-load-data-table'
22import { AssetId } from '../data/types'
3- import { Transaction , TransactionType } from '@/features/transactions/models'
4- import { DisplayAlgo } from '@/features/common/components/display-algo'
5- import { DisplayAssetAmount } from '@/features/common/components/display-asset-amount'
6- import { cn } from '@/features/common/utils'
7- import { TransactionLink } from '@/features/transactions/components/transaction-link'
8- import { ellipseAddress } from '@/utils/ellipse-address'
9- import { ColumnDef } from '@tanstack/react-table'
103import { useFetchNextAssetTransactionsPage } from '../data/asset-transaction-history'
4+ import { assetTransactionsTableColumns } from '../utils/asset-transactions-table-columns'
115
126type Props = {
137 assetId : AssetId
@@ -16,45 +10,5 @@ type Props = {
1610export function AssetTransactionHistory ( { assetId } : Props ) {
1711 const fetchNextPage = useFetchNextAssetTransactionsPage ( assetId )
1812
19- return < LazyLoadDataTable columns = { transactionsTableColumns } fetchNextPage = { fetchNextPage } />
13+ return < LazyLoadDataTable columns = { assetTransactionsTableColumns } fetchNextPage = { fetchNextPage } />
2014}
21-
22- const transactionsTableColumns : ColumnDef < Transaction > [ ] = [
23- {
24- header : 'Transaction Id' ,
25- accessorKey : 'id' ,
26- cell : ( c ) => {
27- const value = c . getValue < string > ( )
28- return < TransactionLink transactionId = { value } short = { true } />
29- } ,
30- } ,
31- {
32- accessorKey : 'sender' ,
33- header : 'From' ,
34- cell : ( c ) => ellipseAddress ( c . getValue < string > ( ) ) ,
35- } ,
36- {
37- header : 'To' ,
38- accessorFn : ( transaction ) => {
39- if ( transaction . type === TransactionType . Payment || transaction . type === TransactionType . AssetTransfer )
40- return ellipseAddress ( transaction . receiver )
41- if ( transaction . type === TransactionType . ApplicationCall ) return transaction . applicationId
42- if ( transaction . type === TransactionType . AssetConfig ) return transaction . assetId
43- if ( transaction . type === TransactionType . AssetFreeze ) return ellipseAddress ( transaction . address )
44- } ,
45- } ,
46- {
47- accessorKey : 'type' ,
48- header : 'Type' ,
49- } ,
50- {
51- header : 'Amount' ,
52- accessorFn : ( transaction ) => transaction ,
53- cell : ( c ) => {
54- const transaction = c . getValue < Transaction > ( )
55- if ( transaction . type === TransactionType . Payment ) return < DisplayAlgo className = { cn ( 'justify-center' ) } amount = { transaction . amount } />
56- if ( transaction . type === TransactionType . AssetTransfer )
57- return < DisplayAssetAmount amount = { transaction . amount } asset = { transaction . asset } />
58- } ,
59- } ,
60- ]
0 commit comments