From fece86e3056c6a27f793198333ad982812fec23f Mon Sep 17 00:00:00 2001 From: Jefferson Mantovani Date: Thu, 6 Nov 2025 10:26:51 -0300 Subject: [PATCH] refactor: add transaction timestamp --- src/blockchain/wallet.ts | 9 +++++--- .../ListingComponent/TransactionCard.vue | 23 ++++++++++++++++++- src/model/WalletTransaction.ts | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/blockchain/wallet.ts b/src/blockchain/wallet.ts index de8b318..24773f5 100644 --- a/src/blockchain/wallet.ts +++ b/src/blockchain/wallet.ts @@ -126,6 +126,7 @@ export const listAllTransactionByWalletAddress = async ( transactions.push({ token: deposit.token, blockNumber: parseInt(deposit.blockNumber), + blockTimestamp: parseInt(deposit.blockTimestamp), amount: parseFloat(formatEther(BigInt(deposit.amount))), seller: deposit.seller, buyer: "", @@ -145,6 +146,7 @@ export const listAllTransactionByWalletAddress = async ( transactions.push({ token: lock.token, blockNumber: parseInt(lock.blockNumber), + blockTimestamp: parseInt(lock.blockTimestamp), amount: parseFloat(formatEther(BigInt(lock.amount))), seller: lock.seller, buyer: lock.buyer, @@ -162,6 +164,7 @@ export const listAllTransactionByWalletAddress = async ( transactions.push({ token: undefined, // Subgraph doesn't provide token in this event, we could enhance this later blockNumber: parseInt(release.blockNumber), + blockTimestamp: parseInt(release.blockTimestamp), amount: -1, // Amount not available in this event seller: "", buyer: release.buyer, @@ -179,6 +182,7 @@ export const listAllTransactionByWalletAddress = async ( transactions.push({ token: withdrawal.token, blockNumber: parseInt(withdrawal.blockNumber), + blockTimestamp: parseInt(withdrawal.blockTimestamp), amount: parseFloat(formatEther(BigInt(withdrawal.amount))), seller: withdrawal.seller, buyer: "", @@ -310,7 +314,7 @@ const listLockTransactionByWalletAddress = async (walletAddress: Address) => { buyer: lock.buyer, lockID: BigInt(lock.lockID), seller: lock.seller, - token: lock.token, + token: undefined, // Token not available in LockAdded subgraph event amount: BigInt(lock.amount), }, // Add other necessary fields to match the original format @@ -340,7 +344,6 @@ const listLockTransactionBySellerAddress = async (sellerAddress: Address) => { buyer lockID seller - token amount blockTimestamp blockNumber @@ -380,7 +383,7 @@ const listLockTransactionBySellerAddress = async (sellerAddress: Address) => { buyer: lock.buyer, lockID: BigInt(lock.lockID), seller: lock.seller, - token: lock.token, + token: undefined, // Token not available in LockAdded subgraph event amount: BigInt(lock.amount), }, // Add other necessary fields to match the original format diff --git a/src/components/ListingComponent/TransactionCard.vue b/src/components/ListingComponent/TransactionCard.vue index c04ed2f..dfea123 100644 --- a/src/components/ListingComponent/TransactionCard.vue +++ b/src/components/ListingComponent/TransactionCard.vue @@ -29,7 +29,7 @@ const eventName = computed(() => { }); const explorerName = computed(() => { - return Networks[props.networkName].blockExplorers?.default.name; + return Networks[(props.networkName as string).toLowerCase()].blockExplorers?.default.name; }); const statusType = computed((): StatusType => { @@ -56,6 +56,21 @@ const showContinueButton = computed(() => { return eventName.value === "Reserva" && props.transaction.lockStatus === 1; }); +const formattedDate = computed(() => { + if (!props.transaction.blockTimestamp) return ""; + + const timestamp = props.transaction.blockTimestamp; + const date = new Date(timestamp * 1000); + + const day = String(date.getDate()).padStart(2, "0"); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const year = date.getFullYear(); + const hours = String(date.getHours()).padStart(2, "0"); + const minutes = String(date.getMinutes()).padStart(2, "0"); + + return `${day}/${month}/${year} ${hours}:${minutes}`; +}); + const handleExplorerClick = () => { emit("openExplorer", props.transaction.transactionHash); }; @@ -71,6 +86,12 @@ const handleExplorerClick = () => { {{ transaction.amount }} {{ selectedToken }} + + {{ formattedDate }} +
diff --git a/src/model/WalletTransaction.ts b/src/model/WalletTransaction.ts index ab0f3c7..7df2229 100644 --- a/src/model/WalletTransaction.ts +++ b/src/model/WalletTransaction.ts @@ -4,6 +4,7 @@ import type { Address } from "viem" export type WalletTransaction = { token?: Address; blockNumber: number; + blockTimestamp?: number; amount: number; seller: string; buyer: string;