()
+ return (
+
- {ellipseId(transaction.id)}
- (Inner)
-
- ) : (
-
+ {'innerId' in transaction ? (
+
+ ) : (
+
+ )}
+
)
},
},
@@ -49,7 +50,6 @@ export const assetTransactionsTableColumns: ColumnDef transaction,
cell: (c) => {
const transaction = c.getValue()
- if (transaction.type === TransactionType.Payment) return
if (transaction.type === TransactionType.AssetTransfer)
return
},
diff --git a/src/features/assets/utils/extract-transactions-for-asset.ts b/src/features/assets/utils/extract-transactions-for-asset.ts
deleted file mode 100644
index 4ab154bad..000000000
--- a/src/features/assets/utils/extract-transactions-for-asset.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Transaction, TransactionType } from '@/features/transactions/models'
-import { flattenInnerTransactions } from '@/utils/flatten-inner-transactions'
-
-export const extractTransactionsForAsset = (transaction: Transaction, assetIndex: number) => {
- const flattenedTransactions = flattenInnerTransactions(transaction)
- const results = []
-
- for (const { transaction } of flattenedTransactions) {
- if (transaction.type === TransactionType.AssetConfig && transaction.assetId === assetIndex) {
- results.push(transaction)
- }
- if (transaction.type === TransactionType.AssetTransfer && transaction.asset.id === assetIndex) {
- results.push(transaction)
- }
- if (transaction.type === TransactionType.AssetFreeze && transaction.assetId === assetIndex) {
- results.push(transaction)
- }
- }
- return results
-}
diff --git a/src/features/assets/utils/get-asset-transactions-table-sub-rows.ts b/src/features/assets/utils/get-asset-transactions-table-sub-rows.ts
new file mode 100644
index 000000000..b2ddf54b0
--- /dev/null
+++ b/src/features/assets/utils/get-asset-transactions-table-sub-rows.ts
@@ -0,0 +1,20 @@
+import { Transaction, InnerTransaction, TransactionType } from '@/features/transactions/models'
+import { flattenInnerTransactions } from '@/utils/flatten-inner-transactions'
+import { AssetId } from '../data/types'
+
+export const getAssetTransactionsTableSubRows = (assetId: AssetId, transaction: Transaction | InnerTransaction) => {
+ if (transaction.type !== TransactionType.ApplicationCall || transaction.innerTransactions.length === 0) {
+ return []
+ }
+
+ return transaction.innerTransactions.filter((innerTransaction) => {
+ const txns = flattenInnerTransactions(innerTransaction)
+ return txns.some(({ transaction }) => {
+ return (
+ (transaction.type === TransactionType.AssetTransfer && transaction.asset.id === assetId) ||
+ (transaction.type === TransactionType.AssetConfig && transaction.assetId === assetId) ||
+ (transaction.type === TransactionType.AssetFreeze && transaction.assetId === assetId)
+ )
+ })
+ })
+}
diff --git a/src/features/common/components/lazy-load-data-table/lazy-load-data-table.tsx b/src/features/common/components/lazy-load-data-table/lazy-load-data-table.tsx
index 1a6d8c4d2..e3e60b345 100644
--- a/src/features/common/components/lazy-load-data-table/lazy-load-data-table.tsx
+++ b/src/features/common/components/lazy-load-data-table/lazy-load-data-table.tsx
@@ -1,4 +1,4 @@
-import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
+import { ColumnDef, flexRender, getCoreRowModel, getExpandedRowModel, useReactTable } from '@tanstack/react-table'
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/features/common/components/table'
import { useCallback, useMemo, useState } from 'react'
import { Atom } from 'jotai'
@@ -9,9 +9,10 @@ import { Loader2 as Loader } from 'lucide-react'
interface Props {
columns: ColumnDef[]
fetchNextPage: (pageSize: number, nextPageToken?: string) => Atom>>
+ getSubRows?: (row: TData) => TData[]
}
-export function LazyLoadDataTable({ columns, fetchNextPage }: Props) {
+export function LazyLoadDataTable({ columns, fetchNextPage, getSubRows }: Props) {
const [pageSize, setPageSize] = useState(10)
const { useLoadablePage } = useMemo(
() =>
@@ -41,8 +42,13 @@ export function LazyLoadDataTable({ columns, fetchNextPage }: Pro
const table = useReactTable({
data: page?.rows ?? [],
+ state: {
+ expanded: true,
+ },
+ getSubRows: getSubRows,
columns,
getCoreRowModel: getCoreRowModel(),
+ getExpandedRowModel: getExpandedRowModel(),
manualPagination: true,
})
diff --git a/src/features/transactions/components/live-transactions-table.tsx b/src/features/transactions/components/live-transactions-table.tsx
index b19262228..ebd4a2186 100644
--- a/src/features/transactions/components/live-transactions-table.tsx
+++ b/src/features/transactions/components/live-transactions-table.tsx
@@ -1,26 +1,30 @@
-import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
+import { ColumnDef, flexRender, getCoreRowModel, getExpandedRowModel, useReactTable } from '@tanstack/react-table'
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/features/common/components/table'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../common/components/select'
import { useState } from 'react'
import { InnerTransaction, Transaction } from '@/features/transactions/models'
-import { Atom } from 'jotai'
import { TransactionResult } from '@algorandfoundation/algokit-utils/types/indexer'
-import { JotaiStore } from '@/features/common/data/types'
import { useLiveTransactions } from '../data/live-transaction'
interface Props {
columns: ColumnDef[]
- mapper: (store: JotaiStore, transactionResult: TransactionResult) => Atom>
+ filter: (transactionResult: TransactionResult) => boolean
+ getSubRows?: (row: Transaction | InnerTransaction) => InnerTransaction[]
}
-export function LiveTransactionsTable({ mapper, columns }: Props) {
+export function LiveTransactionsTable({ filter, columns, getSubRows }: Props) {
const [maxRows, setMaxRows] = useState(10)
- const transactions = useLiveTransactions(mapper, maxRows)
+ const transactions = useLiveTransactions(filter, maxRows)
const table = useReactTable({
data: transactions,
columns,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
+ getSubRows: getSubRows,
+ getExpandedRowModel: getExpandedRowModel(),
+ state: {
+ expanded: true,
+ },
})
return (
diff --git a/src/features/transactions/data/live-transaction.ts b/src/features/transactions/data/live-transaction.ts
index effa69d7e..28f790cd4 100644
--- a/src/features/transactions/data/live-transaction.ts
+++ b/src/features/transactions/data/live-transaction.ts
@@ -1,16 +1,12 @@
import { useMemo } from 'react'
-import { getTransactionResultAtom, liveTransactionIdsAtom } from '@/features/transactions/data'
+import { createTransactionAtom, getTransactionResultAtom, liveTransactionIdsAtom } from '@/features/transactions/data'
import { InnerTransaction, Transaction } from '@/features/transactions/models'
import { atomEffect } from 'jotai-effect'
-import { Atom, atom, useAtom, useAtomValue, useStore } from 'jotai'
+import { atom, useAtom, useAtomValue, useStore } from 'jotai'
import { TransactionId } from '@/features/transactions/data/types'
import { TransactionResult } from '@algorandfoundation/algokit-utils/types/indexer'
-import { JotaiStore } from '@/features/common/data/types'
-export const useLiveTransactions = (
- mapper: (store: JotaiStore, transactionResult: TransactionResult) => Atom>,
- maxRows: number
-) => {
+export const useLiveTransactions = (filter: (transactionResult: TransactionResult) => boolean, maxRows: number) => {
const store = useStore()
const { liveTransactionsAtomEffect, liveTransactionsAtom } = useMemo(() => {
@@ -33,9 +29,9 @@ export const useLiveTransactions = (
}
syncedTransactionId = liveTransactionIds[0]
- const newTransactions = (
- await Promise.all(newTransactionResults.map((transactionResult) => get(mapper(store, transactionResult))))
- ).flat()
+ const newTransactions = await Promise.all(
+ newTransactionResults.filter(filter).map(async (transactionResult) => await get(createTransactionAtom(store, transactionResult)))
+ )
if (newTransactions.length) {
set(liveTransactionsAtom, (prev) => {
return newTransactions.concat(prev).slice(0, maxRows)
@@ -48,7 +44,7 @@ export const useLiveTransactions = (
liveTransactionsAtomEffect,
liveTransactionsAtom,
}
- }, [store, mapper, maxRows])
+ }, [store, filter, maxRows])
useAtom(liveTransactionsAtomEffect)
diff --git a/src/features/transactions/mappers/app-call-transaction-mappers.ts b/src/features/transactions/mappers/app-call-transaction-mappers.ts
index 7af24872b..0e2f5e0e3 100644
--- a/src/features/transactions/mappers/app-call-transaction-mappers.ts
+++ b/src/features/transactions/mappers/app-call-transaction-mappers.ts
@@ -22,7 +22,9 @@ const mapCommonAppCallTransactionProperties = (
return {
...mapCommonTransactionProperties(transactionResult),
type: TransactionType.ApplicationCall,
- applicationId: transactionResult['application-transaction']['application-id'],
+ applicationId: transactionResult['application-transaction']['application-id']
+ ? transactionResult['application-transaction']['application-id']
+ : transactionResult['created-application-index']!,
applicationArgs: transactionResult['application-transaction']['application-args'] ?? [],
applicationAccounts: transactionResult['application-transaction'].accounts ?? [],
foreignApps: transactionResult['application-transaction']['foreign-apps'] ?? [],