@cross-nft-marketplace/auction-house-nft-components
Version:
NFT Media Rendering Components
53 lines (52 loc) • 3.32 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProofAuthenticity = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importStar(require("react"));
const media_urls_1 = require("../constants/media-urls");
const useMediaContext_1 = require("../context/useMediaContext");
const InfoContainer_1 = require("./InfoContainer");
const NFTDataContext_1 = require("../context/NFTDataContext");
const Utils_1 = require("../content-components/Utils");
const ProofLink = ({ href, children, styles, }) => ((0, jsx_runtime_1.jsx)("a", { ...styles, href: href, target: "_blank", rel: "noreferrer", children: children }));
const ProofAuthenticity = ({ className }) => {
const { nft } = (0, react_1.useContext)(NFTDataContext_1.NFTDataContext);
const { getString, getStyles, networkId, style } = (0, useMediaContext_1.useMediaContext)();
const linkStyles = getStyles("fullProofLink");
const getContent = (nft) => {
let infoURL = nft === null || nft === void 0 ? void 0 : nft.metadataUri;
const isIpfs = (infoURL === null || infoURL === void 0 ? void 0 : infoURL.includes("/ipfs/")) || (infoURL === null || infoURL === void 0 ? void 0 : infoURL.startsWith("ipfs://"));
if (infoURL) {
infoURL = (0, Utils_1.resolveURIGateways)(infoURL, style.theme.preferredIPFSGateway);
}
const infoUrlLabelText = isIpfs
? "VIEW_IPFS"
: "VIEW_METADATA";
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ProofLink, { styles: linkStyles, href: `${media_urls_1.VIEW_ETHERSCAN_URL_BASE_BY_NETWORK[networkId]}token/${nft.contract.address}?a=${nft.contractNftId}`, children: getString("ETHERSCAN_TXN") }), infoURL && ((0, jsx_runtime_1.jsx)(ProofLink, { styles: linkStyles, href: infoURL, children: getString(infoUrlLabelText) }))] }));
};
return ((0, jsx_runtime_1.jsx)(InfoContainer_1.InfoContainer, { titleString: "PROOF_AUTHENTICITY", bottomPadding: false, className: className, children: (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoProofAuthenticityContainer"), children: nft && getContent(nft) }) }));
};
exports.ProofAuthenticity = ProofAuthenticity;