refactor: add transaction timestamp

This commit is contained in:
Jefferson Mantovani 2025-11-06 10:26:51 -03:00
parent b27b07fe47
commit fece86e305
3 changed files with 29 additions and 4 deletions

View File

@ -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

View File

@ -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 = () => {
<span class="text-xl sm:text-xl leading-7 font-semibold text-gray-900">
{{ transaction.amount }} {{ selectedToken }}
</span>
<span
v-if="formattedDate"
class="text-xs sm:text-sm leading-5 font-normal text-gray-500 mt-1"
>
{{ formattedDate }}
</span>
</div>
<div class="flex flex-col items-center justify-center">
<div class="mb-2 mt-4">

View File

@ -4,6 +4,7 @@ import type { Address } from "viem"
export type WalletTransaction = {
token?: Address;
blockNumber: number;
blockTimestamp?: number;
amount: number;
seller: string;
buyer: string;