This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LIVE-1174] - Feature: Upgrade NFT architecture (#4870)
* Add nftMetadataResolver to currencyBridge Proxy * Update DropDowns for NFTs * Update NFT send flow for new NFT model * Update NFT Gallery for new NFT model * Update NFT Collections for new NFT model * Update NFT Viewer for new NFT model * Update operations for new NFT model * Add missing error translation for NFT quantity * Add LLC dependency * Fix NFT send summary showing wrong NFT * Remove all $FlowFixMe for exported memo * Update LLC dep to future v22.0.0
- Loading branch information
1 parent
a05562b
commit a08a7e5
Showing
24 changed files
with
335 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import IconOpensea from "~/renderer/icons/Opensea"; | ||
import IconRarible from "~/renderer/icons/Rarible"; | ||
import IconGlobe from "~/renderer/icons/Globe"; | ||
import { openURL } from "~/renderer/linking"; | ||
|
||
const linksPerCurrency = { | ||
ethereum: (t, links) => [ | ||
links?.opensea && { | ||
key: "opensea", | ||
id: "opensea", | ||
label: t("NFT.viewer.actions.open", { viewer: "Opensea.io" }), | ||
Icon: IconOpensea, | ||
type: "external", | ||
callback: () => openURL(links.opensea), | ||
}, | ||
links?.rarible && { | ||
key: "rarible", | ||
id: "rarible", | ||
label: t("NFT.viewer.actions.open", { viewer: "Rarible" }), | ||
Icon: IconRarible, | ||
type: "external", | ||
callback: () => openURL(links.rarible), | ||
}, | ||
{ | ||
key: "sep2", | ||
id: "sep2", | ||
type: "separator", | ||
label: "", | ||
}, | ||
links?.etherscan && { | ||
key: "etherscan", | ||
id: "etherscan", | ||
label: t("NFT.viewer.actions.open", { viewer: "Explorer" }), | ||
Icon: IconGlobe, | ||
type: "external", | ||
callback: () => openURL(links.etherscan), | ||
}, | ||
], | ||
polygon: (t, links) => [ | ||
links?.opensea && { | ||
key: "opensea", | ||
id: "opensea", | ||
label: t("NFT.viewer.actions.open", { viewer: "Opensea.io" }), | ||
Icon: IconOpensea, | ||
type: "external", | ||
callback: () => openURL(links.opensea), | ||
}, | ||
links?.rarible && { | ||
key: "rarible", | ||
id: "rarible", | ||
label: t("NFT.viewer.actions.open", { viewer: "Rarible" }), | ||
Icon: IconRarible, | ||
type: "external", | ||
callback: () => openURL(links.rarible), | ||
}, | ||
{ | ||
key: "sep2", | ||
id: "sep2", | ||
type: "separator", | ||
label: "", | ||
}, | ||
links?.polygonscan && { | ||
key: "polygonscan", | ||
id: "polygonscan", | ||
label: t("NFT.viewer.actions.open", { viewer: "Explorer" }), | ||
Icon: IconGlobe, | ||
type: "external", | ||
callback: () => openURL(links.polygonscan), | ||
}, | ||
], | ||
}; | ||
|
||
export default (currencyId, t, links) => | ||
linksPerCurrency?.[currencyId]?.(t, links).filter(x => x) || []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,33 @@ | ||
// @flow | ||
import React from "react"; | ||
import React, { useMemo, memo } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useNftMetadata } from "@ledgerhq/live-common/lib/nft/NftMetadataProvider"; | ||
import IconOpensea from "~/renderer/icons/Opensea"; | ||
import IconRarible from "~/renderer/icons/Rarible"; | ||
import IconGlobe from "~/renderer/icons/Globe"; | ||
import { openURL } from "~/renderer/linking"; | ||
import ContextMenuItem from "./ContextMenuItem"; | ||
import nftLinksFactory from "~/helpers/nftLinksFactory"; | ||
|
||
type Props = { | ||
contract: string, | ||
tokenId: string, | ||
currencyId: string, | ||
leftClick?: boolean, | ||
children: any, | ||
}; | ||
|
||
export default function NFTContextMenu({ leftClick, children, contract, tokenId }: Props) { | ||
const NFTContextMenu = ({ leftClick, children, contract, tokenId, currencyId }: Props) => { | ||
const { t } = useTranslation(); | ||
const { metadata } = useNftMetadata(contract, tokenId); | ||
|
||
const defaultLinks = { | ||
openSea: `https://opensea.io/assets/${contract}/${tokenId}`, | ||
rarible: `https://rarible.com/token/${contract}:${tokenId}`, | ||
etherscan: `https://etherscan.io/token/${contract}?a=${tokenId}`, | ||
}; | ||
|
||
const menuItems = [ | ||
{ | ||
key: "opensea", | ||
label: t("NFT.viewer.actions.open", { viewer: "Opensea.io" }), | ||
Icon: IconOpensea, | ||
type: "external", | ||
callback: () => openURL(metadata?.links?.opensea || defaultLinks.openSea), | ||
}, | ||
{ | ||
key: "rarible", | ||
label: t("NFT.viewer.actions.open", { viewer: "Rarible" }), | ||
Icon: IconRarible, | ||
type: "external", | ||
callback: () => openURL(metadata?.links?.rarible || defaultLinks.rarible), | ||
}, | ||
{ | ||
key: "sep2", | ||
type: "separator", | ||
label: "", | ||
}, | ||
{ | ||
key: "etherscan", | ||
label: t("NFT.viewer.actions.open", { viewer: "Explorer" }), | ||
Icon: IconGlobe, | ||
type: "external", | ||
callback: () => openURL(metadata?.links?.etherscan || defaultLinks.etherscan), | ||
}, | ||
]; | ||
const { status, metadata } = useNftMetadata(contract, tokenId, currencyId); | ||
const links = useMemo(() => nftLinksFactory(currencyId, t, metadata?.links), [ | ||
currencyId, | ||
metadata?.links, | ||
t, | ||
]); | ||
const menuItems = useMemo(() => (status === "loaded" ? links : []), [links, status]); | ||
|
||
return ( | ||
<ContextMenuItem leftClick={leftClick} items={menuItems}> | ||
{children} | ||
</ContextMenuItem> | ||
); | ||
} | ||
}; | ||
|
||
export default memo<Props>(NFTContextMenu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.