Skip to content

Commit

Permalink
fix: mainnet whitelisted collections (#178)
Browse files Browse the repository at this point in the history
* fixed images

* used public provider instead of our juno node for now

* fetched whitelisted collections from bridge l1 contract

* fix medias

* nft medias in transfer list

* fix: whitelist
  • Loading branch information
YohanTz authored Apr 4, 2024
1 parent ba6c6b2 commit 041e911
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 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
6 changes: 5 additions & 1 deletion apps/web/src/server/api/routers/l1Nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export const l1NftsRouter = createTRPCRouter({
const mediaFormat = media?.format === "mp4" ? "video" : "image";
const isBridgeable =
whitelistedCollections !== undefined &&
whitelistedCollections.includes(contract.address);
whitelistedCollections.find(
(whitelistedCollection) =>
whitelistedCollection.toLowerCase() ===
contract.address.toLocaleLowerCase()
) !== undefined;

return {
contractAddress: contract.address,
Expand Down

0 comments on commit 041e911

Please sign in to comment.