Skip to content

Commit

Permalink
nft medias in transfer list
Browse files Browse the repository at this point in the history
  • Loading branch information
YohanTz committed Apr 4, 2024
1 parent 3d93d6f commit 51170b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useEnsName } from "wagmi";

import Media from "~/app/_components/Media";
import { type Chain } from "~/app/_types";
import { type NftMedia } from "~/server/api/types";

import NftTransferItemContent from "./NftTransferItemContent";
import NftTransferStatus from "./NftTransferStatus";
Expand All @@ -17,7 +18,7 @@ interface NftTransferItemProps {
arrivalAddress: string;
arrivalChain: Chain;
arrivalTimestamp?: number;
collectionImage: string | undefined;
collectionMedia: NftMedia;
collectionName: string;
contractAddress: string;
onWithdrawSuccess: () => void;
Expand Down Expand Up @@ -49,7 +50,7 @@ export default function NftTransferItem({
arrivalAddress,
arrivalChain,
arrivalTimestamp,
collectionImage,
collectionMedia,
collectionName,
contractAddress,
onWithdrawSuccess,
Expand Down Expand Up @@ -90,7 +91,7 @@ export default function NftTransferItem({
alt="nft"
className="rounded-lg"
height={62}
media={{ format: "image", src: collectionImage }}
media={collectionMedia}
width={62}
/>
<div className="text-left">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function NftTransferList({
<NftTransferItem
arrivalAddress={bridgeRequest.arrivalAddress}
arrivalChain={bridgeRequest.arrivalChain}
collectionImage={bridgeRequest.collectionImage}
collectionMedia={bridgeRequest.collectionMedia}
collectionName={bridgeRequest.collectionName}
contractAddress={bridgeRequest.collectionSourceAddress}
key={`${bridgeRequest.statusTimestamp}-$${bridgeRequest.collectionName}}`}
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function NftTransferList({
arrivalAddress={bridgeRequest.arrivalAddress}
arrivalChain={bridgeRequest.arrivalChain}
arrivalTimestamp={bridgeRequest.arrivalTimestamp}
collectionImage={bridgeRequest.collectionImage}
collectionMedia={bridgeRequest.collectionMedia}
collectionName={bridgeRequest.collectionName}
contractAddress={bridgeRequest.collectionSourceAddress}
key={bridgeRequest.statusTimestamp}
Expand Down
11 changes: 7 additions & 4 deletions apps/web/src/server/api/routers/bridgeRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { z } from "zod";
import { type Chain } from "~/app/_types";
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";

import { type NftMedia } from "../types";

const alchemy = new Alchemy({
apiKey: process.env.ALCHEMY_API_KEY,
// network: Network.ETH_MAINNET,
Expand Down Expand Up @@ -42,7 +44,7 @@ type BridgeRequestResponse = {
arrivalAddress: string;
arrivalChain: Chain;
arrivalTimestamp?: number;
collectionImage: string | undefined;
collectionMedia: NftMedia;
collectionName: string;
collectionSourceAddress: string;
requestContent: Array<string>;
Expand Down Expand Up @@ -115,6 +117,9 @@ export const bridgeRequestRouter = createTRPCRouter({
lastBridgeRequestEvent?.label === "withdraw_available_l1" ||
lastBridgeRequestEvent?.label === "withdraw_completed_l1" ||
lastBridgeRequestEvent?.label === "withdraw_completed_l2";
const media = requestMetadata[index]?.media[0];
const mediaSrc = media?.gateway ?? media?.thumbnail ?? media?.raw;
const mediaFormat = media?.format === "mp4" ? "video" : "image";

return {
arrivalAddress: bridgeRequest.req.to,
Expand All @@ -125,9 +130,7 @@ export const bridgeRequestRouter = createTRPCRouter({
arrivalTimestamp: isArrived
? lastBridgeRequestEvent?.block_timestamp
: undefined,
collectionImage:
requestMetadata[index]?.media[0]?.raw ??
requestMetadata[index]?.media[0]?.thumbnail,
collectionMedia: { format: mediaFormat, src: mediaSrc },
collectionName: requestMetadata[index]?.contract.name ?? "",
collectionSourceAddress: bridgeRequest.req.collection_src,
requestContent: JSON.parse(
Expand Down

0 comments on commit 51170b5

Please sign in to comment.