refactor: add transaction timestamp
This commit is contained in:
parent
b27b07fe47
commit
fece86e305
@ -126,6 +126,7 @@ export const listAllTransactionByWalletAddress = async (
|
|||||||
transactions.push({
|
transactions.push({
|
||||||
token: deposit.token,
|
token: deposit.token,
|
||||||
blockNumber: parseInt(deposit.blockNumber),
|
blockNumber: parseInt(deposit.blockNumber),
|
||||||
|
blockTimestamp: parseInt(deposit.blockTimestamp),
|
||||||
amount: parseFloat(formatEther(BigInt(deposit.amount))),
|
amount: parseFloat(formatEther(BigInt(deposit.amount))),
|
||||||
seller: deposit.seller,
|
seller: deposit.seller,
|
||||||
buyer: "",
|
buyer: "",
|
||||||
@ -145,6 +146,7 @@ export const listAllTransactionByWalletAddress = async (
|
|||||||
transactions.push({
|
transactions.push({
|
||||||
token: lock.token,
|
token: lock.token,
|
||||||
blockNumber: parseInt(lock.blockNumber),
|
blockNumber: parseInt(lock.blockNumber),
|
||||||
|
blockTimestamp: parseInt(lock.blockTimestamp),
|
||||||
amount: parseFloat(formatEther(BigInt(lock.amount))),
|
amount: parseFloat(formatEther(BigInt(lock.amount))),
|
||||||
seller: lock.seller,
|
seller: lock.seller,
|
||||||
buyer: lock.buyer,
|
buyer: lock.buyer,
|
||||||
@ -162,6 +164,7 @@ export const listAllTransactionByWalletAddress = async (
|
|||||||
transactions.push({
|
transactions.push({
|
||||||
token: undefined, // Subgraph doesn't provide token in this event, we could enhance this later
|
token: undefined, // Subgraph doesn't provide token in this event, we could enhance this later
|
||||||
blockNumber: parseInt(release.blockNumber),
|
blockNumber: parseInt(release.blockNumber),
|
||||||
|
blockTimestamp: parseInt(release.blockTimestamp),
|
||||||
amount: -1, // Amount not available in this event
|
amount: -1, // Amount not available in this event
|
||||||
seller: "",
|
seller: "",
|
||||||
buyer: release.buyer,
|
buyer: release.buyer,
|
||||||
@ -179,6 +182,7 @@ export const listAllTransactionByWalletAddress = async (
|
|||||||
transactions.push({
|
transactions.push({
|
||||||
token: withdrawal.token,
|
token: withdrawal.token,
|
||||||
blockNumber: parseInt(withdrawal.blockNumber),
|
blockNumber: parseInt(withdrawal.blockNumber),
|
||||||
|
blockTimestamp: parseInt(withdrawal.blockTimestamp),
|
||||||
amount: parseFloat(formatEther(BigInt(withdrawal.amount))),
|
amount: parseFloat(formatEther(BigInt(withdrawal.amount))),
|
||||||
seller: withdrawal.seller,
|
seller: withdrawal.seller,
|
||||||
buyer: "",
|
buyer: "",
|
||||||
@ -310,7 +314,7 @@ const listLockTransactionByWalletAddress = async (walletAddress: Address) => {
|
|||||||
buyer: lock.buyer,
|
buyer: lock.buyer,
|
||||||
lockID: BigInt(lock.lockID),
|
lockID: BigInt(lock.lockID),
|
||||||
seller: lock.seller,
|
seller: lock.seller,
|
||||||
token: lock.token,
|
token: undefined, // Token not available in LockAdded subgraph event
|
||||||
amount: BigInt(lock.amount),
|
amount: BigInt(lock.amount),
|
||||||
},
|
},
|
||||||
// Add other necessary fields to match the original format
|
// Add other necessary fields to match the original format
|
||||||
@ -340,7 +344,6 @@ const listLockTransactionBySellerAddress = async (sellerAddress: Address) => {
|
|||||||
buyer
|
buyer
|
||||||
lockID
|
lockID
|
||||||
seller
|
seller
|
||||||
token
|
|
||||||
amount
|
amount
|
||||||
blockTimestamp
|
blockTimestamp
|
||||||
blockNumber
|
blockNumber
|
||||||
@ -380,7 +383,7 @@ const listLockTransactionBySellerAddress = async (sellerAddress: Address) => {
|
|||||||
buyer: lock.buyer,
|
buyer: lock.buyer,
|
||||||
lockID: BigInt(lock.lockID),
|
lockID: BigInt(lock.lockID),
|
||||||
seller: lock.seller,
|
seller: lock.seller,
|
||||||
token: lock.token,
|
token: undefined, // Token not available in LockAdded subgraph event
|
||||||
amount: BigInt(lock.amount),
|
amount: BigInt(lock.amount),
|
||||||
},
|
},
|
||||||
// Add other necessary fields to match the original format
|
// Add other necessary fields to match the original format
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const eventName = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const explorerName = 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 => {
|
const statusType = computed((): StatusType => {
|
||||||
@ -56,6 +56,21 @@ const showContinueButton = computed(() => {
|
|||||||
return eventName.value === "Reserva" && props.transaction.lockStatus === 1;
|
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 = () => {
|
const handleExplorerClick = () => {
|
||||||
emit("openExplorer", props.transaction.transactionHash);
|
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">
|
<span class="text-xl sm:text-xl leading-7 font-semibold text-gray-900">
|
||||||
{{ transaction.amount }} {{ selectedToken }}
|
{{ transaction.amount }} {{ selectedToken }}
|
||||||
</span>
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="formattedDate"
|
||||||
|
class="text-xs sm:text-sm leading-5 font-normal text-gray-500 mt-1"
|
||||||
|
>
|
||||||
|
{{ formattedDate }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col items-center justify-center">
|
<div class="flex flex-col items-center justify-center">
|
||||||
<div class="mb-2 mt-4">
|
<div class="mb-2 mt-4">
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import type { Address } from "viem"
|
|||||||
export type WalletTransaction = {
|
export type WalletTransaction = {
|
||||||
token?: Address;
|
token?: Address;
|
||||||
blockNumber: number;
|
blockNumber: number;
|
||||||
|
blockTimestamp?: number;
|
||||||
amount: number;
|
amount: number;
|
||||||
seller: string;
|
seller: string;
|
||||||
buyer: string;
|
buyer: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user