From 62e60c0897745367f6b3c107e7423a72a16b437d Mon Sep 17 00:00:00 2001 From: tyleroooo Date: Tue, 15 Oct 2024 11:54:26 -0400 Subject: [PATCH] feat: vault transactions link to mintscan (#1142) --- src/pages/portfolio/Portfolio.tsx | 1 + src/pages/vaults/VaultTransactions.tsx | 109 +++++++++++++++---------- 2 files changed, 69 insertions(+), 41 deletions(-) diff --git a/src/pages/portfolio/Portfolio.tsx b/src/pages/portfolio/Portfolio.tsx index 58eb3fe36..5126c49d2 100644 --- a/src/pages/portfolio/Portfolio.tsx +++ b/src/pages/portfolio/Portfolio.tsx @@ -120,6 +120,7 @@ const PortfolioPage = () => { element={ } diff --git a/src/pages/vaults/VaultTransactions.tsx b/src/pages/vaults/VaultTransactions.tsx index 261806e33..6a40d7c87 100644 --- a/src/pages/vaults/VaultTransactions.tsx +++ b/src/pages/vaults/VaultTransactions.tsx @@ -8,15 +8,20 @@ import { STRING_KEYS } from '@/constants/localization'; import { EMPTY_ARR } from '@/constants/objects'; import { useStringGetter } from '@/hooks/useStringGetter'; +import { useURLConfigs } from '@/hooks/useURLConfigs'; import { useLoadedVaultAccountTransfers } from '@/hooks/vaultsHooks'; import { tradeViewMixins } from '@/styles/tradeViewMixins'; import { Button } from '@/components/Button'; import { Icon, IconName } from '@/components/Icon'; +import { Link } from '@/components/Link'; import { Output, OutputType } from '@/components/Output'; import { ColumnDef, Table } from '@/components/Table'; +import { isTruthy } from '@/lib/isTruthy'; +import { truncateAddress } from '@/lib/wallet'; + export const VaultTransactionsCard = ({ className }: { className?: string }) => { const stringGetter = useStringGetter(); const [showHistory, setShowHistory] = useState(false); @@ -59,59 +64,81 @@ export const VaultTransactionsTable = ({ className, withOuterBorders, emptyString, + withTxHashLink, }: { className?: string; withOuterBorders?: boolean; emptyString?: string; + withTxHashLink?: boolean; }) => { const stringGetter = useStringGetter(); const transactions = useLoadedVaultAccountTransfers() ?? EMPTY_ARR; + const { mintscan: mintscanTxUrl } = useURLConfigs(); const columns = useMemo[]>( () => - [ - { - columnKey: 'time', - getCellValue: (row) => row.timestampMs, - label: stringGetter({ key: STRING_KEYS.TIME }), - renderCell: ({ timestampMs }) => ( -
+ ( + [ + { + columnKey: 'time', + getCellValue: (row) => row.timestampMs, + label: stringGetter({ key: STRING_KEYS.TIME }), + renderCell: ({ timestampMs }) => ( +
+ +
+ +
+
+ ), + }, + { + columnKey: 'action', + getCellValue: (row) => row.type?.name, + label: stringGetter({ key: STRING_KEYS.ACTION }), + renderCell: ({ type }) => ( -
- -
-
- ), - }, - { - columnKey: 'action', - getCellValue: (row) => row.type?.name, - label: stringGetter({ key: STRING_KEYS.ACTION }), - renderCell: ({ type }) => ( - - ), - }, - { - columnKey: 'amount', - getCellValue: (row) => row.amountUsdc, - label: stringGetter({ key: STRING_KEYS.AMOUNT }), - renderCell: ({ amountUsdc }) => , - }, - ] satisfies ColumnDef[], - [stringGetter] + ), + }, + { + columnKey: 'amount', + getCellValue: (row) => row.amountUsdc, + label: stringGetter({ key: STRING_KEYS.AMOUNT }), + renderCell: ({ amountUsdc }) => , + }, + withTxHashLink && { + columnKey: 'tx-hash', + getCellValue: (row) => row.transactionHash, + label: stringGetter({ key: STRING_KEYS.TRANSACTION }), + renderCell: ({ transactionHash }) => + transactionHash ? ( + + {truncateAddress(transactionHash, '')} + + ) : ( + '-' + ), + }, + ] satisfies Array | false | undefined> + ).filter(isTruthy), + [mintscanTxUrl, stringGetter, withTxHashLink] ); return ( <$Table