diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 6d7a31f75..000000000 --- a/package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "marketplace", - "version": "2.7.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "marketplace", - "version": "2.7.0" - } - } -} diff --git a/webapp/package-lock.json b/webapp/package-lock.json index f8f611cd7..1159d1448 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -12,7 +12,6 @@ "@dcl/schemas": "^4.5.0", "@dcl/ui-env": "^1.2.0", "@ethersproject/providers": "^5.6.2", - "apollo-boost": "^0.4.7", "classnames": "^2.3.1", "connected-react-router": "^6.9.1", "date-fns": "^2.23.0", @@ -5062,10 +5061,6 @@ "version": "20.2.1", "license": "MIT" }, - "node_modules/@types/zen-observable": { - "version": "0.8.3", - "license": "MIT" - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "4.29.1", "license": "MIT", @@ -5662,21 +5657,6 @@ "@xtuc/long": "4.2.2" } }, - "node_modules/@wry/context": { - "version": "0.4.4", - "license": "MIT", - "dependencies": { - "@types/node": ">=6", - "tslib": "^1.9.3" - } - }, - "node_modules/@wry/equality": { - "version": "0.1.11", - "license": "MIT", - "dependencies": { - "tslib": "^1.9.3" - } - }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "license": "BSD-3-Clause" @@ -5896,125 +5876,6 @@ "node": ">= 8" } }, - "node_modules/apollo-boost": { - "version": "0.4.9", - "license": "MIT", - "dependencies": { - "apollo-cache": "^1.3.5", - "apollo-cache-inmemory": "^1.6.6", - "apollo-client": "^2.6.10", - "apollo-link": "^1.0.6", - "apollo-link-error": "^1.0.3", - "apollo-link-http": "^1.3.1", - "graphql-tag": "^2.4.2", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-cache": { - "version": "1.3.5", - "license": "MIT", - "dependencies": { - "apollo-utilities": "^1.3.4", - "tslib": "^1.10.0" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-cache-inmemory": { - "version": "1.6.6", - "license": "MIT", - "dependencies": { - "apollo-cache": "^1.3.5", - "apollo-utilities": "^1.3.4", - "optimism": "^0.10.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-client": { - "version": "2.6.10", - "license": "MIT", - "dependencies": { - "@types/zen-observable": "^0.8.0", - "apollo-cache": "1.3.5", - "apollo-link": "^1.0.0", - "apollo-utilities": "1.3.4", - "symbol-observable": "^1.0.2", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0", - "zen-observable": "^0.8.0" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-link": { - "version": "1.2.14", - "license": "MIT", - "dependencies": { - "apollo-utilities": "^1.3.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.9.3", - "zen-observable-ts": "^0.8.21" - }, - "peerDependencies": { - "graphql": "^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-link-error": { - "version": "1.1.13", - "license": "MIT", - "dependencies": { - "apollo-link": "^1.2.14", - "apollo-link-http-common": "^0.2.16", - "tslib": "^1.9.3" - } - }, - "node_modules/apollo-link-http": { - "version": "1.5.17", - "license": "MIT", - "dependencies": { - "apollo-link": "^1.2.14", - "apollo-link-http-common": "^0.2.16", - "tslib": "^1.9.3" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-link-http-common": { - "version": "0.2.16", - "license": "MIT", - "dependencies": { - "apollo-link": "^1.2.14", - "ts-invariant": "^0.4.0", - "tslib": "^1.9.3" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, - "node_modules/apollo-utilities": { - "version": "1.3.4", - "license": "MIT", - "dependencies": { - "@wry/equality": "^0.1.2", - "fast-json-stable-stringify": "^2.0.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - }, - "peerDependencies": { - "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" - } - }, "node_modules/aproba": { "version": "1.2.0", "license": "ISC" @@ -12267,23 +12128,6 @@ "node": ">= 6.x" } }, - "node_modules/graphql-tag": { - "version": "2.12.6", - "license": "MIT", - "dependencies": { - "tslib": "^2.1.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" - } - }, - "node_modules/graphql-tag/node_modules/tslib": { - "version": "2.3.1", - "license": "0BSD" - }, "node_modules/growly": { "version": "1.3.0", "license": "MIT", @@ -16788,13 +16632,6 @@ "node": ">=4" } }, - "node_modules/optimism": { - "version": "0.10.3", - "license": "MIT", - "dependencies": { - "@wry/context": "^0.4.0" - } - }, "node_modules/optimize-css-assets-webpack-plugin": { "version": "5.0.4", "license": "MIT", @@ -21640,13 +21477,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/symbol-observable": { - "version": "1.2.0", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/symbol-tree": { "version": "3.2.4", "license": "MIT" @@ -22208,13 +22038,6 @@ "typescript": ">=3.7.0" } }, - "node_modules/ts-invariant": { - "version": "0.4.4", - "license": "MIT", - "dependencies": { - "tslib": "^1.9.3" - } - }, "node_modules/ts-pnp": { "version": "1.2.0", "license": "MIT", @@ -24771,18 +24594,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zen-observable": { - "version": "0.8.15", - "license": "MIT" - }, - "node_modules/zen-observable-ts": { - "version": "0.8.21", - "license": "MIT", - "dependencies": { - "tslib": "^1.9.3", - "zen-observable": "^0.8.0" - } } }, "dependencies": { @@ -27960,9 +27771,6 @@ "@types/yargs-parser": { "version": "20.2.1" }, - "@types/zen-observable": { - "version": "0.8.3" - }, "@typescript-eslint/eslint-plugin": { "version": "4.29.1", "requires": { @@ -28407,19 +28215,6 @@ "@xtuc/long": "4.2.2" } }, - "@wry/context": { - "version": "0.4.4", - "requires": { - "@types/node": ">=6", - "tslib": "^1.9.3" - } - }, - "@wry/equality": { - "version": "0.1.11", - "requires": { - "tslib": "^1.9.3" - } - }, "@xtuc/ieee754": { "version": "1.2.0" }, @@ -28549,92 +28344,6 @@ "picomatch": "^2.0.4" } }, - "apollo-boost": { - "version": "0.4.9", - "requires": { - "apollo-cache": "^1.3.5", - "apollo-cache-inmemory": "^1.6.6", - "apollo-client": "^2.6.10", - "apollo-link": "^1.0.6", - "apollo-link-error": "^1.0.3", - "apollo-link-http": "^1.3.1", - "graphql-tag": "^2.4.2", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - } - }, - "apollo-cache": { - "version": "1.3.5", - "requires": { - "apollo-utilities": "^1.3.4", - "tslib": "^1.10.0" - } - }, - "apollo-cache-inmemory": { - "version": "1.6.6", - "requires": { - "apollo-cache": "^1.3.5", - "apollo-utilities": "^1.3.4", - "optimism": "^0.10.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - } - }, - "apollo-client": { - "version": "2.6.10", - "requires": { - "@types/zen-observable": "^0.8.0", - "apollo-cache": "1.3.5", - "apollo-link": "^1.0.0", - "apollo-utilities": "1.3.4", - "symbol-observable": "^1.0.2", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0", - "zen-observable": "^0.8.0" - } - }, - "apollo-link": { - "version": "1.2.14", - "requires": { - "apollo-utilities": "^1.3.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.9.3", - "zen-observable-ts": "^0.8.21" - } - }, - "apollo-link-error": { - "version": "1.1.13", - "requires": { - "apollo-link": "^1.2.14", - "apollo-link-http-common": "^0.2.16", - "tslib": "^1.9.3" - } - }, - "apollo-link-http": { - "version": "1.5.17", - "requires": { - "apollo-link": "^1.2.14", - "apollo-link-http-common": "^0.2.16", - "tslib": "^1.9.3" - } - }, - "apollo-link-http-common": { - "version": "0.2.16", - "requires": { - "apollo-link": "^1.2.14", - "ts-invariant": "^0.4.0", - "tslib": "^1.9.3" - } - }, - "apollo-utilities": { - "version": "1.3.4", - "requires": { - "@wry/equality": "^0.1.2", - "fast-json-stable-stringify": "^2.0.0", - "ts-invariant": "^0.4.0", - "tslib": "^1.10.0" - } - }, "aproba": { "version": "1.2.0" }, @@ -32915,17 +32624,6 @@ "iterall": "^1.2.2" } }, - "graphql-tag": { - "version": "2.12.6", - "requires": { - "tslib": "^2.1.0" - }, - "dependencies": { - "tslib": { - "version": "2.3.1" - } - } - }, "growly": { "version": "1.3.0", "optional": true @@ -35970,12 +35668,6 @@ } } }, - "optimism": { - "version": "0.10.3", - "requires": { - "@wry/context": "^0.4.0" - } - }, "optimize-css-assets-webpack-plugin": { "version": "5.0.4", "requires": { @@ -39255,9 +38947,6 @@ } } }, - "symbol-observable": { - "version": "1.2.0" - }, "symbol-tree": { "version": "3.2.4" }, @@ -39626,12 +39315,6 @@ "dev": true, "requires": {} }, - "ts-invariant": { - "version": "0.4.4", - "requires": { - "tslib": "^1.9.3" - } - }, "ts-pnp": { "version": "1.2.0" }, @@ -41439,16 +41122,6 @@ }, "yocto-queue": { "version": "0.1.0" - }, - "zen-observable": { - "version": "0.8.15" - }, - "zen-observable-ts": { - "version": "0.8.21", - "requires": { - "tslib": "^1.9.3", - "zen-observable": "^0.8.0" - } } } } diff --git a/webapp/package.json b/webapp/package.json index 07cd45971..9757e454f 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -6,7 +6,6 @@ "@dcl/schemas": "^4.5.0", "@dcl/ui-env": "^1.2.0", "@ethersproject/providers": "^5.6.2", - "apollo-boost": "^0.4.7", "classnames": "^2.3.1", "connected-react-router": "^6.9.1", "date-fns": "^2.23.0", diff --git a/webapp/src/components/BuyPage/BuyNFTModal/BuyNFTModal.tsx b/webapp/src/components/BuyPage/BuyNFTModal/BuyNFTModal.tsx index b3e76f781..84ae620e4 100644 --- a/webapp/src/components/BuyPage/BuyNFTModal/BuyNFTModal.tsx +++ b/webapp/src/components/BuyPage/BuyNFTModal/BuyNFTModal.tsx @@ -8,10 +8,9 @@ import { } from 'decentraland-dapps/dist/modules/authorization/types' import { hasAuthorization } from 'decentraland-dapps/dist/modules/authorization/utils' import { ChainButton } from 'decentraland-dapps/dist/containers' -import { Network, NFTCategory } from '@dcl/schemas' +import { NFTCategory } from '@dcl/schemas' import { ContractName } from 'decentraland-transactions' import { locations } from '../../../modules/routing/locations' -import { isPartner } from '../../../modules/vendor/utils' import { useFingerprint } from '../../../modules/nft/hooks' import { getContractNames } from '../../../modules/vendor' import { getContract } from '../../../modules/contract/utils' @@ -50,14 +49,10 @@ const BuyNFTModal = (props: Props) => { network: nft.network }) + // If the vendor is a partner we might need to use a different contract for authorizedAddress. See PR #680 return { address: wallet.address, - authorizedAddress: isPartner(nft.vendor) - ? getContract({ - name: contractNames.MARKETPLACE_ADAPTER, - network: Network.ETHEREUM - }).address - : order!.marketplaceAddress, + authorizedAddress: order!.marketplaceAddress, contractAddress: mana.address, contractName: ContractName.MANAToken, chainId: nft.chainId, diff --git a/webapp/src/components/SettingsPage/SettingsPage.tsx b/webapp/src/components/SettingsPage/SettingsPage.tsx index 2688ef18d..d649b9e5a 100644 --- a/webapp/src/components/SettingsPage/SettingsPage.tsx +++ b/webapp/src/components/SettingsPage/SettingsPage.tsx @@ -49,10 +49,6 @@ const SettingsPage = (props: Props) => { network: Network.MATIC }) - const marketplaceAdapter = getContract({ - name: contractNames.MARKETPLACE_ADAPTER - }) - const bids = getContract({ name: contractNames.BIDS }) @@ -153,16 +149,6 @@ const SettingsPage = (props: Props) => { type: AuthorizationType.ALLOWANCE }} /> - { const { vendor, isMap, onBrowse } = props switch (vendor) { - case VendorName.SUPER_RARE: - return - case VendorName.MAKERS_PLACE: - return - case VendorName.KNOWN_ORIGIN: - return case VendorName.DECENTRALAND: default: return diff --git a/webapp/src/components/Vendor/NFTSections/NFTSections.tsx b/webapp/src/components/Vendor/NFTSections/NFTSections.tsx index db06053a1..fb0683bd1 100644 --- a/webapp/src/components/Vendor/NFTSections/NFTSections.tsx +++ b/webapp/src/components/Vendor/NFTSections/NFTSections.tsx @@ -2,40 +2,16 @@ import React from 'react' import { VendorName } from '../../../modules/vendor/types' import { Sections } from '../../../modules/vendor/routing/types' -import { Section as KnownOriginSection } from '../../../modules/vendor/known_origin/routing/types' import { Section as DecentralandSection } from '../../../modules/vendor/decentraland/routing/types' -import { NFTSections as KnownOriginNFTSections } from '../known_origin/NFTSections' import { NFTSections as DecentralandNFTSections } from '../decentraland/NFTSections' -import { Menu } from '../../Menu' -import { MenuItem } from '../../Menu/MenuItem' import { Props } from './NFTSections.types' const NFTSections = (props: Props) => { - const { vendor, address, section, onSectionClick } = props + const { vendor, section, onSectionClick } = props // TODO: This should be on a generic path like PartnerSidebar switch (vendor) { - case VendorName.SUPER_RARE: - case VendorName.MAKERS_PLACE: - const all = Sections[vendor].ALL - return ( - - - - ) - case VendorName.KNOWN_ORIGIN: - return ( - - ) case VendorName.DECENTRALAND: default: return ( diff --git a/webapp/src/components/Vendor/NFTSections/NFTSections.types.ts b/webapp/src/components/Vendor/NFTSections/NFTSections.types.ts index a45c484c2..7c7da5618 100644 --- a/webapp/src/components/Vendor/NFTSections/NFTSections.types.ts +++ b/webapp/src/components/Vendor/NFTSections/NFTSections.types.ts @@ -2,7 +2,6 @@ import { VendorName } from '../../../modules/vendor/types' export type Props = { vendor: VendorName - address?: string section?: string onSectionClick: (section: string) => void } diff --git a/webapp/src/components/Vendor/NFTSidebar/NFTSidebar.tsx b/webapp/src/components/Vendor/NFTSidebar/NFTSidebar.tsx index d5ab88816..4691cf3fc 100644 --- a/webapp/src/components/Vendor/NFTSidebar/NFTSidebar.tsx +++ b/webapp/src/components/Vendor/NFTSidebar/NFTSidebar.tsx @@ -17,10 +17,6 @@ const NFTSidebar = (props: Props) => { ) switch (vendor) { - case VendorName.SUPER_RARE: - case VendorName.MAKERS_PLACE: - case VendorName.KNOWN_ORIGIN: - return null case VendorName.DECENTRALAND: default: return ( diff --git a/webapp/src/components/Vendor/VendorMenu/VendorMenu.tsx b/webapp/src/components/Vendor/VendorMenu/VendorMenu.tsx index 1dc4b64cb..c1075d28d 100644 --- a/webapp/src/components/Vendor/VendorMenu/VendorMenu.tsx +++ b/webapp/src/components/Vendor/VendorMenu/VendorMenu.tsx @@ -78,7 +78,6 @@ const VendorMenu = (props: Props) => { {isOpen ? ( diff --git a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.container.ts b/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.container.ts deleted file mode 100644 index 88136e902..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.container.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { connect } from 'react-redux' - -import { RootState } from '../../../../modules/reducer' -import { - getSection, - getSortBy, - getOnlyOnSale -} from '../../../../modules/routing/selectors' -import { MapStateProps } from './NFTFilters.types' -import NFTFilters from './NFTFilters' - -const mapState = (state: RootState): MapStateProps => ({ - section: getSection(state), - sortBy: getSortBy(state), - onlyOnSale: getOnlyOnSale(state) -}) - -const mapDispatch = () => ({}) - -export default connect(mapState, mapDispatch)(NFTFilters) diff --git a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.tsx b/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.tsx deleted file mode 100644 index 0a900b403..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import React, { useCallback, useState } from 'react' -import { - Button, - Header, - Dropdown, - DropdownProps, - Responsive, - Modal -} from 'decentraland-ui' -import { t } from 'decentraland-dapps/dist/modules/translation/utils' - -import { Section } from '../../../../modules/vendor/known_origin/routing/types' -import { SortBy } from '../../../../modules/routing/types' -import { PriceChangeNotice } from '../../PriceChangeNotice' -import { Props } from './NFTFilters.types' - -const NFTFilters = (props: Props) => { - const { section, onBrowse } = props - - const [showFiltersModal, setShowFiltersModal] = useState(false) - - const dropdownOptions = - section === Section.ALL || section === Section.EDITIONS - ? [ - { value: SortBy.RECENTLY_LISTED, text: t('filters.recently_listed') }, - { value: SortBy.CHEAPEST, text: t('filters.cheapest') } - ] - : section === Section.TOKENS - ? [{ value: SortBy.NEWEST, text: t('filters.newest') }] - : [] - - const sortBy = dropdownOptions.find(option => option.value === props.sortBy) - ? props.sortBy - : dropdownOptions[0].value - - const handleDropdownChange = useCallback( - (_, props: DropdownProps) => { - onBrowse({ sortBy: props.value as SortBy }) - }, - [onBrowse] - ) - - return ( -
-
-
- - - - -
setShowFiltersModal(!showFiltersModal)} - > -
{t('nft_filters.filter')}
-
-
- -
- - - - setShowFiltersModal(false)} - > - {t('nft_filters.filter')} - -
-
{t('nft_filters.order_by')}
- -
- -
-
-
- ) -} - -export default React.memo(NFTFilters) diff --git a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.types.ts b/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.types.ts deleted file mode 100644 index 0beb3f872..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTFilters/NFTFilters.types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { SortBy } from '../../../../modules/routing/types' -import { browse } from '../../../../modules/routing/actions' - -export type Props = { - section: string - sortBy?: SortBy - onlyOnSale?: boolean - onBrowse: typeof browse -} - -export type MapStateProps = Pick -export type OwnProps = Pick diff --git a/webapp/src/components/Vendor/known_origin/NFTFilters/index.ts b/webapp/src/components/Vendor/known_origin/NFTFilters/index.ts deleted file mode 100644 index 54c8abfab..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTFilters/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import NFTFilters from './NFTFilters.container' -export { NFTFilters } diff --git a/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.tsx b/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.tsx deleted file mode 100644 index 11ddb028f..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react' - -import { Section } from '../../../../modules/vendor/known_origin/routing/types' -import { Menu } from '../../../Menu' -import { MenuItem } from '../../../Menu/MenuItem' -import { Props } from './NFTSections.types' - -const NFTSections = (props: Props) => { - const { section, address, onSectionClick } = props - - const isAccountPage = address !== undefined - const currentValue = - section === Section.ALL && isAccountPage ? Section.EDITIONS : section - - return ( - - {isAccountPage ? ( - <> - - - - ) : ( - - )} - - ) -} - -export default React.memo(NFTSections) diff --git a/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.types.ts b/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.types.ts deleted file mode 100644 index d9ffdbae3..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTSections/NFTSections.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Section } from '../../../../modules/vendor/known_origin/routing/types' - -export type Props = { - section?: Section - address?: string - onSectionClick: (section: Section) => void -} diff --git a/webapp/src/components/Vendor/known_origin/NFTSections/index.ts b/webapp/src/components/Vendor/known_origin/NFTSections/index.ts deleted file mode 100644 index 7d7d318f4..000000000 --- a/webapp/src/components/Vendor/known_origin/NFTSections/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import NFTSections from './NFTSections' -export { NFTSections } diff --git a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.container.ts b/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.container.ts deleted file mode 100644 index 00d43c8cf..000000000 --- a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.container.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux' - -import { RootState } from '../../../../modules/reducer' -import { getCount } from '../../../../modules/ui/browse/selectors' -import { - getSection, - getSortBy, - getOnlyOnSale, - getSearch -} from '../../../../modules/routing/selectors' -import { MapStateProps } from './NFTFilters.types' -import NFTFilters from './NFTFilters' - -const mapState = (state: RootState): MapStateProps => ({ - count: getCount(state), - section: getSection(state), - sortBy: getSortBy(state), - search: getSearch(state), - onlyOnSale: getOnlyOnSale(state) -}) - -const mapDispatch = () => ({}) - -export default connect(mapState, mapDispatch)(NFTFilters) diff --git a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.tsx b/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.tsx deleted file mode 100644 index d51caa7ae..000000000 --- a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import React, { useCallback, useState } from 'react' -import { - Button, - Header, - Dropdown, - DropdownProps, - Responsive, - Modal -} from 'decentraland-ui' -import { t } from 'decentraland-dapps/dist/modules/translation/utils' - -import { SortBy } from '../../../../modules/routing/types' -import { MAX_QUERY_SIZE } from '../../../../modules/vendor/super_rare/api' -import { TextFilter } from '../../NFTFilters/TextFilter' -import { PriceChangeNotice } from '../../PriceChangeNotice' -import { Props } from './NFTFilters.types' - -const NFTFilters = (props: Props) => { - const { search, count, onBrowse } = props - - const [showFiltersModal, setShowFiltersModal] = useState(false) - - const dropdownOptions = [ - { value: SortBy.RECENTLY_LISTED, text: t('filters.recently_listed') }, - { value: SortBy.CHEAPEST, text: t('filters.cheapest') } - ] - - const sortBy = dropdownOptions.find(option => option.value === props.sortBy) - ? props.sortBy - : dropdownOptions[0].value - - const handleDropdownChange = useCallback( - (_, props: DropdownProps) => { - onBrowse({ sortBy: props.value as SortBy }) - }, - [onBrowse] - ) - - const handleSearch = useCallback( - (newSearch: string) => { - if (search !== newSearch) { - onBrowse({ search: newSearch }) - } - }, - [search, onBrowse] - ) - - const searchPlaceholder = - count === undefined - ? t('global.loading') + '...' - : t('nft_filters.search', { - suffix: - count < MAX_QUERY_SIZE - ? t('nft_filters.results', { - count: count.toLocaleString() - }) - : t('nft_filters.more_than_results', { - count: count.toLocaleString() - }) - }) - - return ( -
-
- - - - -
setShowFiltersModal(!showFiltersModal)} - > -
{t('nft_filters.filter')}
-
-
- -
- - - - setShowFiltersModal(false)} - > - {t('nft_filters.filter')} - -
-
{t('nft_filters.order_by')}
- -
- -
-
-
- ) -} - -export default React.memo(NFTFilters) diff --git a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.types.ts b/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.types.ts deleted file mode 100644 index 466b7204b..000000000 --- a/webapp/src/components/Vendor/makers_place/NFTFilters/NFTFilters.types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { SortBy } from '../../../../modules/routing/types' -import { browse } from '../../../../modules/routing/actions' - -export type Props = { - count?: number - section: string - sortBy?: SortBy - search: string - onlyOnSale?: boolean - onBrowse: typeof browse -} - -export type MapStateProps = Pick< - Props, - 'count' | 'section' | 'sortBy' | 'search' | 'onlyOnSale' -> -export type OwnProps = Pick diff --git a/webapp/src/components/Vendor/makers_place/NFTFilters/index.ts b/webapp/src/components/Vendor/makers_place/NFTFilters/index.ts deleted file mode 100644 index 54c8abfab..000000000 --- a/webapp/src/components/Vendor/makers_place/NFTFilters/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import NFTFilters from './NFTFilters.container' -export { NFTFilters } diff --git a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.container.ts b/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.container.ts deleted file mode 100644 index 00d43c8cf..000000000 --- a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.container.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux' - -import { RootState } from '../../../../modules/reducer' -import { getCount } from '../../../../modules/ui/browse/selectors' -import { - getSection, - getSortBy, - getOnlyOnSale, - getSearch -} from '../../../../modules/routing/selectors' -import { MapStateProps } from './NFTFilters.types' -import NFTFilters from './NFTFilters' - -const mapState = (state: RootState): MapStateProps => ({ - count: getCount(state), - section: getSection(state), - sortBy: getSortBy(state), - search: getSearch(state), - onlyOnSale: getOnlyOnSale(state) -}) - -const mapDispatch = () => ({}) - -export default connect(mapState, mapDispatch)(NFTFilters) diff --git a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.tsx b/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.tsx deleted file mode 100644 index d411e8084..000000000 --- a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.tsx +++ /dev/null @@ -1,156 +0,0 @@ -import React, { useCallback, useState } from 'react' -import { - Button, - Header, - Dropdown, - DropdownProps, - CheckboxProps, - Radio, - Responsive, - Modal -} from 'decentraland-ui' -import { t } from 'decentraland-dapps/dist/modules/translation/utils' - -import { SortBy } from '../../../../modules/routing/types' -import { MAX_QUERY_SIZE } from '../../../../modules/vendor/super_rare/api' -import { TextFilter } from '../../NFTFilters/TextFilter' -import { PriceChangeNotice } from '../../PriceChangeNotice' -import { Props } from './NFTFilters.types' - -const NFTFilters = (props: Props) => { - const { search, count, onlyOnSale, onBrowse } = props - - const [showFiltersModal, setShowFiltersModal] = useState(false) - - const dropdownOptions = [ - { value: SortBy.RECENTLY_LISTED, text: t('filters.recently_listed') }, - { value: SortBy.CHEAPEST, text: t('filters.cheapest') } - ] - - const sortBy = dropdownOptions.find(option => option.value === props.sortBy) - ? props.sortBy - : dropdownOptions[0].value - - const handleOnlyOnSaleChange = useCallback( - (_, props: CheckboxProps) => { - onBrowse({ onlyOnSale: !!props.checked }) - }, - [onBrowse] - ) - - const handleDropdownChange = useCallback( - (_, props: DropdownProps) => { - onBrowse({ sortBy: props.value as SortBy }) - }, - [onBrowse] - ) - - const handleSearch = useCallback( - (newSearch: string) => { - if (search !== newSearch) { - onBrowse({ search: newSearch }) - } - }, - [search, onBrowse] - ) - - const searchPlaceholder = - count === undefined - ? t('global.loading') + '...' - : t('nft_filters.search', { - suffix: - count < MAX_QUERY_SIZE - ? t('nft_filters.results', { - count: count.toLocaleString() - }) - : t('nft_filters.more_than_results', { - count: count.toLocaleString() - }) - }) - - return ( -
-
- - {onlyOnSale ? ( - - ) : null} - - - - - -
setShowFiltersModal(!showFiltersModal)} - > -
{t('nft_filters.filter')}
-
-
- -
- - - - setShowFiltersModal(false)} - > - {t('nft_filters.filter')} - -
- {onlyOnSale ? ( - <> -
{t('nft_filters.order_by')}
- - - ) : null} -
-
-
{t('nft_filters.on_sale')}
- -
- -
-
-
- ) -} - -export default React.memo(NFTFilters) diff --git a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.types.ts b/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.types.ts deleted file mode 100644 index 466b7204b..000000000 --- a/webapp/src/components/Vendor/super_rare/NFTFilters/NFTFilters.types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { SortBy } from '../../../../modules/routing/types' -import { browse } from '../../../../modules/routing/actions' - -export type Props = { - count?: number - section: string - sortBy?: SortBy - search: string - onlyOnSale?: boolean - onBrowse: typeof browse -} - -export type MapStateProps = Pick< - Props, - 'count' | 'section' | 'sortBy' | 'search' | 'onlyOnSale' -> -export type OwnProps = Pick diff --git a/webapp/src/components/Vendor/super_rare/NFTFilters/index.ts b/webapp/src/components/Vendor/super_rare/NFTFilters/index.ts deleted file mode 100644 index 54c8abfab..000000000 --- a/webapp/src/components/Vendor/super_rare/NFTFilters/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import NFTFilters from './NFTFilters.container' -export { NFTFilters } diff --git a/webapp/src/modules/nft/types.ts b/webapp/src/modules/nft/types.ts index 48fb0d01a..9f1a36e1c 100644 --- a/webapp/src/modules/nft/types.ts +++ b/webapp/src/modules/nft/types.ts @@ -4,9 +4,6 @@ import { NFTsFetchFilters } from '../vendor/nft/types' import { VendorName } from '../vendor/types' import { SortDirection } from '../routing/types' import { NFTData as DecentralandData } from '../vendor/decentraland/nft/types' -import { NFTData as SuperRareData } from '../vendor/super_rare/nft/types' -import { NFTData as MakersPlaceData } from '../vendor/makers_place/nft/types' -import { NFTData as KnownOriginData } from '../vendor/known_origin/nft/types' export enum NFTSortBy { NAME = 'name', @@ -17,14 +14,8 @@ export enum NFTSortBy { export type Data = V extends VendorName.DECENTRALAND ? DecentralandData - : V extends VendorName.SUPER_RARE - ? SuperRareData - : V extends VendorName.MAKERS_PLACE - ? MakersPlaceData - : V extends VendorName.KNOWN_ORIGIN - ? KnownOriginData : V extends void - ? DecentralandData | SuperRareData | MakersPlaceData | KnownOriginData + ? DecentralandData : never export type NFT = Omit< diff --git a/webapp/src/modules/routing/selectors.spec.ts b/webapp/src/modules/routing/selectors.spec.ts index 6030ff1ab..d3b7c04d4 100644 --- a/webapp/src/modules/routing/selectors.spec.ts +++ b/webapp/src/modules/routing/selectors.spec.ts @@ -93,26 +93,6 @@ describe('when getting the section', () => { }) }) - describe("when there's no section URL param and the vendor is not Decentraland", () => { - it("should return the vendor's ALL section", () => { - expect( - getSection.resultFunc('', locations.browse(), VendorName.SUPER_RARE) - ).toBe(Sections.super_rare.ALL) - }) - }) - - describe('when the section URL param does not exist in the vendor', () => { - it("should return the vendor's ALL section", () => { - expect( - getSection.resultFunc( - 'section=NOT_EXISTENT', - locations.browse(), - VendorName.SUPER_RARE - ) - ).toBe(Sections.super_rare.ALL) - }) - }) - describe('when the section URL param exists in the vendor', () => { it("should return the vendor's section", () => { expect( @@ -126,76 +106,46 @@ describe('when getting the section', () => { }) }) -describe('when getting the asset type', () => { - describe("when there's no assetType URL param and the vendor is not DECENTRALAND", () => { - it('should return NFT as the assetType', () => { - expect( - getAssetType.resultFunc('', locations.browse(), VendorName.KNOWN_ORIGIN) - ).toBe(AssetType.NFT) - }) - }) - - describe("when there's no assetType URL param and the vendor is DECENTRALAND but the location is not in browse", () => { - it('should return NFT as the assetType', () => { - expect( - getAssetType.resultFunc('', locations.lands(), VendorName.KNOWN_ORIGIN) - ).toBe(AssetType.NFT) - }) - }) - - describe("when there's no assetType URL param and the vendor is DECENTRALAND and the location is in browse", () => { - it('should return ITEM as the assetType', () => { - expect( - getAssetType.resultFunc('', locations.browse(), VendorName.DECENTRALAND) - ).toBe(AssetType.ITEM) - }) - }) - - describe("when there's assetType URL param, the assetType is not NFT or ITEM and the vendor is DECENTRALAND but the location is not in browse", () => { - it('should return NFT as the assetType', () => { - expect( - getAssetType.resultFunc( - 'assetType=something', - locations.lands(), - VendorName.DECENTRALAND - ) - ).toBe(AssetType.NFT) - }) +describe("when there's no assetType URL param and the vendor is DECENTRALAND and the location is in browse", () => { + it('should return ITEM as the assetType', () => { + expect( + getAssetType.resultFunc('', locations.browse(), VendorName.DECENTRALAND) + ).toBe(AssetType.ITEM) }) +}) - describe("when there's assetType URL param, the assetType is not NFT or ITEM and the vendor is DECENTRALAND and the location is in browse", () => { - it('should return ITEM as the assetType', () => { - expect( - getAssetType.resultFunc( - 'assetType=something', - locations.browse(), - VendorName.DECENTRALAND - ) - ).toBe(AssetType.ITEM) - }) +describe("when there's assetType URL param, the assetType is not NFT or ITEM and the vendor is DECENTRALAND but the location is not in browse", () => { + it('should return NFT as the assetType', () => { + expect( + getAssetType.resultFunc( + 'assetType=something', + locations.lands(), + VendorName.DECENTRALAND + ) + ).toBe(AssetType.NFT) }) +}) - describe("when there's assetType URL param and the assetType is NFT", () => { - it('should return NFT as the assetType', () => { - expect( - getAssetType.resultFunc( - 'assetType=nft', - locations.browse(), - VendorName.DECENTRALAND - ) - ).toBe(AssetType.NFT) - }) +describe("when there's assetType URL param, the assetType is not NFT or ITEM and the vendor is DECENTRALAND and the location is in browse", () => { + it('should return ITEM as the assetType', () => { + expect( + getAssetType.resultFunc( + 'assetType=something', + locations.browse(), + VendorName.DECENTRALAND + ) + ).toBe(AssetType.ITEM) }) +}) - describe("when there's assetType URL param and the assetType is ITEM", () => { - it('should return ITEM as the assetType', () => { - expect( - getAssetType.resultFunc( - 'assetType=item', - locations.lands(), - VendorName.KNOWN_ORIGIN - ) - ).toBe(AssetType.ITEM) - }) +describe("when there's assetType URL param and the assetType is NFT", () => { + it('should return NFT as the assetType', () => { + expect( + getAssetType.resultFunc( + 'assetType=nft', + locations.browse(), + VendorName.DECENTRALAND + ) + ).toBe(AssetType.NFT) }) }) diff --git a/webapp/src/modules/ui/nft/partner/reducer.ts b/webapp/src/modules/ui/nft/partner/reducer.ts deleted file mode 100644 index 1c25ae16b..000000000 --- a/webapp/src/modules/ui/nft/partner/reducer.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { - FetchNFTsSuccessAction, - FETCH_NFTS_SUCCESS -} from '../../../nft/actions' -import { View } from '../../types' - -export type PartnerUIState = { - [View.PARTNERS_SUPER_RARE]: string[] - [View.PARTNERS_MAKERS_PLACE]: string[] - [View.PARTNERS_KNOWN_ORIGIN]: string[] -} - -const INITIAL_STATE: PartnerUIState = { - [View.PARTNERS_SUPER_RARE]: [], - [View.PARTNERS_MAKERS_PLACE]: [], - [View.PARTNERS_KNOWN_ORIGIN]: [] -} - -type UIReducerAction = FetchNFTsSuccessAction - -export function partnerReducer( - state: PartnerUIState = INITIAL_STATE, - action: UIReducerAction -) { - switch (action.type) { - case FETCH_NFTS_SUCCESS: { - const nftIds = action.payload.nfts.map(nft => nft.id) - - switch (action.payload.options.view) { - case View.PARTNERS_SUPER_RARE: { - return { - ...state, - [View.PARTNERS_SUPER_RARE]: nftIds - } - } - case View.PARTNERS_MAKERS_PLACE: { - return { - ...state, - [View.PARTNERS_MAKERS_PLACE]: nftIds - } - } - case View.PARTNERS_KNOWN_ORIGIN: { - return { - ...state, - [View.PARTNERS_KNOWN_ORIGIN]: nftIds - } - } - default: - return state - } - } - default: - return state - } -} diff --git a/webapp/src/modules/ui/nft/partner/selectors.ts b/webapp/src/modules/ui/nft/partner/selectors.ts deleted file mode 100644 index d67fef105..000000000 --- a/webapp/src/modules/ui/nft/partner/selectors.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { createSelector } from 'reselect' -import { LoadingState } from 'decentraland-dapps/dist/modules/loading/reducer' - -import { NFTState } from '../../../nft/reducer' -import { FETCH_NFTS_REQUEST } from '../../../nft/actions' -import { NFT } from '../../../nft/types' -import { VendorName } from '../../../vendor/types' -import { - getData as getNFTData, - getLoading as getNFTLoading -} from '../../../nft/selectors' -import { getPartners as getAllPartners } from '../../../vendor/utils' -import { RootState } from '../../../reducer' -import { PartnerView } from './types' -import { PartnerUIState } from './reducer' - -export const getState = (state: RootState) => state.ui.nft.partner - -export const getPartners = createSelector< - RootState, - PartnerUIState, - NFTState['data'], - Record ->(getState, getNFTData, (partnerState, nftsById) => { - const result: Record = {} - - for (const partner of getAllPartners()) { - result[partner] = partnerState[partner as PartnerView].map( - id => nftsById[id] - ) - } - - return result -}) - -export const getPartnersLoading = createSelector< - RootState, - LoadingState, - Record ->(getNFTLoading, nftLoading => { - const result: Record = {} - - for (const partner of getAllPartners()) { - result[partner] = nftLoading.some( - action => - action.type === FETCH_NFTS_REQUEST && - action.payload.options.view === partner - ) - } - - return result -}) diff --git a/webapp/src/modules/ui/nft/partner/types.ts b/webapp/src/modules/ui/nft/partner/types.ts deleted file mode 100644 index 491d42a98..000000000 --- a/webapp/src/modules/ui/nft/partner/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { PartnerUIState } from './reducer' - -export type PartnerView = keyof PartnerUIState diff --git a/webapp/src/modules/ui/nft/reducer.ts b/webapp/src/modules/ui/nft/reducer.ts index ac4dd883c..db6bc4d6a 100644 --- a/webapp/src/modules/ui/nft/reducer.ts +++ b/webapp/src/modules/ui/nft/reducer.ts @@ -1,13 +1,10 @@ import { combineReducers } from 'redux' import { bidReducer as bid, BidUIState } from './bid/reducer' -import { partnerReducer as partner, PartnerUIState } from './partner/reducer' export type NFTUIState = { bid: BidUIState - partner: PartnerUIState } export const nftReducer = combineReducers({ - bid, - partner + bid }) diff --git a/webapp/src/modules/vendor/VendorFactory.ts b/webapp/src/modules/vendor/VendorFactory.ts index e25f75599..0a7c160e9 100644 --- a/webapp/src/modules/vendor/VendorFactory.ts +++ b/webapp/src/modules/vendor/VendorFactory.ts @@ -1,7 +1,4 @@ import { services as decentraland } from './decentraland' -import { services as superRare } from './super_rare' -import { services as makersPlace } from './makers_place' -import { services as knownOrigin } from './known_origin' import { ContractService, NFTService, @@ -21,27 +18,6 @@ export class VendorFactory { new decentraland.OrderService(), new decentraland.BidService() ) - case VendorName.SUPER_RARE: - return new Vendor( - vendor, - new superRare.ContractService(), - new superRare.NFTService(), - new superRare.OrderService() - ) - case VendorName.MAKERS_PLACE: - return new Vendor( - vendor, - new makersPlace.ContractService(), - new makersPlace.NFTService(), - new makersPlace.OrderService() - ) - case VendorName.KNOWN_ORIGIN: - return new Vendor( - vendor, - new knownOrigin.ContractService(), - new knownOrigin.NFTService(), - new knownOrigin.OrderService() - ) default: throw new Error(`Invalid vendor "${vendor}"`) } diff --git a/webapp/src/modules/vendor/api.ts b/webapp/src/modules/vendor/api.ts index 5a015740e..d833584f4 100644 --- a/webapp/src/modules/vendor/api.ts +++ b/webapp/src/modules/vendor/api.ts @@ -8,11 +8,5 @@ export function getMaxQuerySize(vendor: VendorName) { switch (vendor) { case VendorName.DECENTRALAND: return MAX_QUERY_SIZE - case VendorName.SUPER_RARE: - return MAX_QUERY_SIZE - case VendorName.MAKERS_PLACE: - return MAX_QUERY_SIZE - case VendorName.KNOWN_ORIGIN: - return MAX_QUERY_SIZE } } diff --git a/webapp/src/modules/vendor/known_origin/ContractService.ts b/webapp/src/modules/vendor/known_origin/ContractService.ts deleted file mode 100644 index e73e43325..000000000 --- a/webapp/src/modules/vendor/known_origin/ContractService.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ChainId, Network } from '@dcl/schemas' -import { - Contract, - ContractService as ContractServiceInterface -} from '../services' -import { Network as AppNetwork } from '../../contract/types' -import { TransferType } from '../types' -import { config } from '../../../config' - -const network = config.get('NETWORK')! as AppNetwork - -export enum ContractName { - DIGITAL_ASSET = 'DigitalAssset', - MARKETPLACE_ADAPTER = 'MarketplaceAdapter' -} - -const contracts = ({ - [AppNetwork.ROPSTEN]: [], - [AppNetwork.MAINNET]: [ - { - name: ContractName.DIGITAL_ASSET, - address: '0xfbeef911dc5821886e1dda71586d90ed28174b7d', - vendor: 'known_origin', - category: 'art', - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.MARKETPLACE_ADAPTER, - address: '0xf4fbd84193f9aaf9779dedbb415a806933eb1c95', - vendor: 'known_origin', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - } - ] -} as Record)[network] - -export class ContractService implements ContractServiceInterface { - contracts = contracts - - async build() {} - - getContracts() { - return this.contracts - } - - getTransferType(_address: string) { - return TransferType.SAFE_TRANSFER_FROM - } -} diff --git a/webapp/src/modules/vendor/known_origin/NFTService.ts b/webapp/src/modules/vendor/known_origin/NFTService.ts deleted file mode 100644 index cdc93de0e..000000000 --- a/webapp/src/modules/vendor/known_origin/NFTService.ts +++ /dev/null @@ -1,224 +0,0 @@ -import { ethers } from 'ethers' -import { ListingStatus, Network, Order } from '@dcl/schemas' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { ERC721__factory } from '../../../contracts' -import { NFT, NFTsFetchParams, NFTsCountParams } from '../../nft/types' -import { Account } from '../../account/types' -import { getNFTId } from '../../nft/utils' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { NFTService as NFTServiceInterface } from '../services' -import { getOriginURL } from '../utils' -import { getContractNames, VendorName } from '../types' -import { getContract } from '../../contract/utils' -import { NFTsFetchFilters } from './nft/types' -import { EditionFragment } from './edition/fragments' -import { TokenFragment } from './token/fragments' -import { editionAPI } from './edition/api' -import { tokenAPI } from './token/api' -import { MAX_QUERY_SIZE } from './api' -import { AssetType } from './types' -import { config } from '../../../config' - -type Fragment = TokenFragment | EditionFragment - -export class NFTService - implements NFTServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - private oneEthInWei: ethers.BigNumber - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - this.oneEthInWei = ethers.BigNumber.from('1000000000000000000') // 10 ** 18 - } - - async fetch(params: NFTsFetchParams, filters?: NFTsFetchFilters) { - const fragments = await this.getAPI(filters).fetch(params) - const [total, oneEthInMANA] = await Promise.all([ - this.count(params, filters), - this.getOneEthInMANA() - ]) - - const nfts: NFT[] = [] - const accounts: Account[] = [] - const orders: Order[] = [] - - for (const fragment of fragments) { - const nft = this.toNFT(fragment) - - if (fragment.type === AssetType.EDITION) { - const order = this.toOrder(fragment, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - - orders.push(order) - } - - let account = accounts.find(account => account.id === nft.owner) - if (!account) { - account = this.toAccount(nft.owner) - } - account.nftIds.push(nft.id) - - nfts.push(nft) - accounts.push(account) - } - - return [nfts, accounts, orders, total] as const - } - - async count(countParams: NFTsCountParams, filters?: NFTsFetchFilters) { - const params: NFTsFetchParams = { - ...countParams, - first: MAX_QUERY_SIZE, - skip: 0 - } - if (!filters) { - const [editionCount, tokenCount] = await Promise.all([ - tokenAPI.count(params), - editionAPI.count(params) - ]) - return editionCount + tokenCount - } else { - return this.getAPI(filters).count(params) - } - } - - async fetchOne(_contractAddress: string, tokenId: string) { - const fragment = await this.getAPI().fetchOne(tokenId) - const oneEthInMANA = await this.getOneEthInMANA() - - const nft = this.toNFT(fragment) - let order: Order | undefined - - if (fragment.type === AssetType.EDITION) { - order = this.toOrder(fragment, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - } - - return [nft, order] as const - } - - async transfer( - wallet: Wallet | null, - toAddress: string, - nft: NFT - ): Promise { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - const from = wallet.address - const to = toAddress - - const erc721 = ERC721__factory.connect( - nft.contractAddress, - await getSigner() - ) - - const transaction = await erc721.transferFrom(from, to, nft.tokenId) - - return transaction.hash - } - - toNFT(fragment: Fragment): NFT { - const tokenId = fragment.id - const { name, description, image } = fragment.metadata - - const contractNames = getContractNames() - - const contractAddress = getContract({ - name: contractNames.DIGITAL_ASSET - }).address - - return { - id: getNFTId(contractAddress, tokenId), - tokenId, - contractAddress, - activeOrderId: '', - owner: this.getOwner(fragment), - name, - image, - url: this.getDefaultURL(fragment), - data: { - description, - isEdition: true - }, - category: 'art', - vendor: VendorName.KNOWN_ORIGIN, - chainId: Number(config.get('CHAIN_ID')!), - network: Network.ETHEREUM, - issuedId: null, - itemId: null, - createdAt: 0, - updatedAt: 0, - soldAt: 0 - } - } - - toOrder( - edition: EditionFragment, - oneEthInMANA: string - ): Order & { ethPrice: string } { - const totalWei = this.marketplacePrice.addFee(edition.priceInWei) - const weiPrice = ethers.BigNumber.from(totalWei).mul(oneEthInMANA) - const price = weiPrice.div(this.oneEthInWei) - - const contractNames = getContractNames() - - const contractAddress = getContract({ - name: contractNames.DIGITAL_ASSET - }).address - const marketplaceAddress = getContract({ - name: contractNames.MARKETPLACE_ADAPTER - }).address - - return { - id: `${VendorName.KNOWN_ORIGIN}-order-${edition.id}`, - tokenId: edition.id, - contractAddress, - marketplaceAddress, - owner: edition.artistAccount, - buyer: null, - price: price.toString(), - ethPrice: edition.priceInWei.toString(), - status: ListingStatus.OPEN, - createdAt: +edition.createdTimestamp, - updatedAt: +edition.createdTimestamp, - expiresAt: Infinity, - network: Network.ETHEREUM, - chainId: Number(config.get('CHAIN_ID')!) - } - } - - toAccount(address: string): Account { - return { - id: address, - address, - nftIds: [] - } - } - - private getAPI(filters?: NFTsFetchFilters) { - return filters && filters.isToken ? tokenAPI : editionAPI - } - - private async getOneEthInMANA() { - const mana = await this.tokenConverter.marketEthToMANA(1) - return ethers.utils.parseEther(mana.toString()) - } - - private getOwner(fragment: Fragment): string { - return fragment.type === AssetType.TOKEN - ? fragment.currentOwner.id - : fragment.artistAccount - } - - private getDefaultURL(fragment: Fragment): string { - const origin = getOriginURL(VendorName.KNOWN_ORIGIN) - return `${origin}/${fragment.type}/${fragment.id}` - } -} diff --git a/webapp/src/modules/vendor/known_origin/OrderService.ts b/webapp/src/modules/vendor/known_origin/OrderService.ts deleted file mode 100644 index 3e633643d..000000000 --- a/webapp/src/modules/vendor/known_origin/OrderService.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { ethers } from 'ethers' -import { Order } from '@dcl/schemas' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { MarketplaceAdapter__factory } from '../../../contracts' -import { getContract } from '../../contract/utils' -import { NFT } from '../../nft/types' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { getContractNames, VendorName } from '../types' -import { OrderService as OrderServiceInterface } from '../services' - -export class OrderService - implements OrderServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - } - - fetchByNFT(): any { - throw new Error('Method: `fetchByNFT` is not implemented') - } - - create(): any { - throw new Error('Method: `create` is not implemented') - } - - async execute( - wallet: Wallet | null, - nft: NFT, - order: Order - ): Promise { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - - const contractNames = getContractNames() - - // Addresses - const assetMarketAddress = order.marketplaceAddress - const manaTokenAddress = getContract({ name: contractNames.MANA }).address - - // Data - const calldata = this.getCallData(wallet.address, nft) - - // Price - const manaPrice = await this.tokenConverter.contractEthToMANA( - (order as Order & { ethPrice: string }).ethPrice! - ) - const maxPrice = this.marketplacePrice.addMaxSlippage(manaPrice) - - // Contract - const marketplaceAdapter = MarketplaceAdapter__factory.connect( - getContract({ name: contractNames.MARKETPLACE_ADAPTER }).address, - await getSigner() - ) - - const transaction = await marketplaceAdapter[ - 'buy(address,bytes,uint256,address,uint256)' - ]( - assetMarketAddress, - calldata, - (order as Order & { ethPrice: string }).ethPrice!, - manaTokenAddress, - maxPrice - ) - - return transaction.hash - } - - cancel(): any { - throw new Error('Method: `cancel` is not implemented') - } - - canSell() { - return false - } - - private getCallData(to: string, nft: NFT) { - const abiCoder = ethers.utils.defaultAbiCoder - // purchaseTo - return abiCoder.encode(['address', 'uint256'], [to, nft.tokenId]) - } -} diff --git a/webapp/src/modules/vendor/known_origin/api.ts b/webapp/src/modules/vendor/known_origin/api.ts deleted file mode 100644 index b3f09bcbc..000000000 --- a/webapp/src/modules/vendor/known_origin/api.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ApolloClient } from 'apollo-client' -import { InMemoryCache } from 'apollo-cache-inmemory' -import { HttpLink } from 'apollo-link-http' -import { config } from '../../../config' - -export const API_URL = config.get('KNOWN_ORIGIN_API_URL') -export const MAX_QUERY_SIZE = 1000 - -const link = new HttpLink({ - uri: API_URL -}) - -export const client = new ApolloClient({ - link, - cache: new InMemoryCache(), - defaultOptions: { - query: { - fetchPolicy: 'no-cache' - } - } -}) diff --git a/webapp/src/modules/vendor/known_origin/edition/api.ts b/webapp/src/modules/vendor/known_origin/edition/api.ts deleted file mode 100644 index 7ada7b8d3..000000000 --- a/webapp/src/modules/vendor/known_origin/edition/api.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { gql } from 'apollo-boost' - -import { NFTsFetchParams, NFTSortBy } from '../../../nft/types' -import { client } from '../api' -import { AssetType } from '../types' -import { editionFragment, EditionFragment } from './fragments' - -class EditionAPI { - fetch = async (params: NFTsFetchParams) => { - const query = getNFTsQuery(params) - const variables = this.buildVariables(params) - - const { data } = await client.query<{ editions: EditionFragment[] }>({ - query, - variables - }) - - return this.addType(data.editions) - } - - async count(params: NFTsFetchParams) { - const countQuery = getNFTsCountQuery(params) - const variables = this.buildVariables(params) - - const { data } = await client.query<{ editions: EditionFragment[] }>({ - query: countQuery, - variables - }) - - return data.editions.length - } - - async fetchOne(id: string) { - const { data } = await client.query<{ editions: EditionFragment[] }>({ - query: EDITION_BY_ID_QUERY, - variables: { - id - } - }) - return this.addType(data.editions)[0] - } - - private addType(tokens: EditionFragment[]): EditionFragment[] { - return tokens.map(token => ({ ...token, type: AssetType.EDITION })) - } - - private buildVariables(params: NFTsFetchParams) { - return { - ...params, - address: params.address, - orderBy: this.getSort(params.orderBy) - } - } - - private getSort(sortBy?: NFTSortBy) { - switch (sortBy) { - case NFTSortBy.PRICE: - return 'priceInWei' - case NFTSortBy.CREATED_AT: - case NFTSortBy.ORDER_CREATED_AT: - return 'createdTimestamp' - default: - return undefined - } - } -} - -const EDITIONS_FILTERS = ` - $first: Int - $skip: Int - $orderBy: String - $orderDirection: String - - $address: String -` - -const EDITIONS_ARGUMENTS = ` - first: $first - skip: $skip - orderBy: $orderBy - orderDirection: $orderDirection -` - -function getNFTsCountQuery(params: NFTsFetchParams) { - return getNFTsQuery(params, true) -} - -function getNFTsQuery(params: NFTsFetchParams, isCount = false) { - let extraWhere: string[] = [] - - if (params.address) { - extraWhere.push('artistAccount: $address') - } - - // TODO: Search? - // TODO: onlyOnSale? - - return gql` - query Editions( - ${EDITIONS_FILTERS} - ) { - editions( - where: { - active: true, - offersOnly: false, - remainingSupply_gt: 0, - priceInWei_gt: 0, - ${extraWhere.join('\n')} - } - ${EDITIONS_ARGUMENTS} - ) { - ${isCount ? 'id' : '...editionFragment'} - } - } - ${isCount ? '' : editionFragment()} - ` -} - -const EDITION_BY_ID_QUERY = gql` - query EditionById($id: String) { - editions(where: { id: $id }, first: 1) { - ...editionFragment - } - } - ${editionFragment()} -` - -export const editionAPI = new EditionAPI() diff --git a/webapp/src/modules/vendor/known_origin/edition/fragments.ts b/webapp/src/modules/vendor/known_origin/edition/fragments.ts deleted file mode 100644 index acce34ce6..000000000 --- a/webapp/src/modules/vendor/known_origin/edition/fragments.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { gql } from 'apollo-boost' -import { AssetType } from '../types' - -export const editionFragment = () => gql` - fragment editionFragment on Edition { - id - createdTimestamp - artistAccount - priceInWei - totalSupply - metadata { - name - image - description - } - } -` - -export type EditionFragment = { - id: string - type: AssetType.EDITION - artistAccount: string - priceInWei: string - totalSupply: string - createdTimestamp: string - metadata: { - name: string - image: string - description: string - } -} diff --git a/webapp/src/modules/vendor/known_origin/edition/index.ts b/webapp/src/modules/vendor/known_origin/edition/index.ts deleted file mode 100644 index 3318fdbc9..000000000 --- a/webapp/src/modules/vendor/known_origin/edition/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './api' diff --git a/webapp/src/modules/vendor/known_origin/index.ts b/webapp/src/modules/vendor/known_origin/index.ts deleted file mode 100644 index cd0b07384..000000000 --- a/webapp/src/modules/vendor/known_origin/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NFTService } from './NFTService' -import { ContractService } from './ContractService' -import { OrderService } from './OrderService' - -export const VendorName = 'known_origin' - -export * from './nft' -export * from './routing' - -export * from './NFTService' -export * from './ContractService' -export * from './OrderService' -export const services = { - NFTService, - ContractService, - OrderService -} diff --git a/webapp/src/modules/vendor/known_origin/nft/index.ts b/webapp/src/modules/vendor/known_origin/nft/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/known_origin/nft/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/known_origin/nft/types.ts b/webapp/src/modules/vendor/known_origin/nft/types.ts deleted file mode 100644 index fb348da0a..000000000 --- a/webapp/src/modules/vendor/known_origin/nft/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type NFTsFetchFilters = { - isEdition: boolean - isToken: boolean -} - -export type NFTData = { - description: string - isEdition: boolean -} diff --git a/webapp/src/modules/vendor/known_origin/routing/index.ts b/webapp/src/modules/vendor/known_origin/routing/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/known_origin/routing/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/known_origin/routing/types.ts b/webapp/src/modules/vendor/known_origin/routing/types.ts deleted file mode 100644 index a620e4341..000000000 --- a/webapp/src/modules/vendor/known_origin/routing/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Section { - ALL = 'all', - EDITIONS = 'editions', - TOKENS = 'tokens' -} diff --git a/webapp/src/modules/vendor/known_origin/token/api.ts b/webapp/src/modules/vendor/known_origin/token/api.ts deleted file mode 100644 index d14897dc3..000000000 --- a/webapp/src/modules/vendor/known_origin/token/api.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { gql } from 'apollo-boost' - -import { NFTsFetchParams, NFTSortBy } from '../../../nft/types' -import { client } from '../api' -import { AssetType } from '../types' -import { tokenFragment, TokenFragment } from './fragments' - -class TokenAPI { - fetch = async (params: NFTsFetchParams) => { - const query = getNFTsQuery(params) - const variables = this.buildVariables(params) - - const { data } = await client.query<{ tokens: TokenFragment[] }>({ - query, - variables - }) - - return this.addType(data.tokens) - } - - async count(params: NFTsFetchParams) { - const countQuery = getNFTsCountQuery(params) - const variables = this.buildVariables(params) - - const { data } = await client.query<{ tokens: TokenFragment[] }>({ - query: countQuery, - variables - }) - - return data.tokens.length - } - - async fetchOne(id: string) { - const { data } = await client.query<{ tokens: TokenFragment[] }>({ - query: TOKEN_BY_ID_QUERY, - variables: { - id - } - }) - return this.addType(data.tokens)[0] - } - - private addType(tokens: TokenFragment[]): TokenFragment[] { - return tokens.map(token => ({ ...token, type: AssetType.TOKEN })) - } - - private buildVariables(params: NFTsFetchParams) { - return { - ...params, - address: params.address, - orderBy: this.getSort(params.orderBy) - } - } - - private getSort(sortBy?: NFTSortBy) { - switch (sortBy) { - case NFTSortBy.CREATED_AT: - return 'birthTimestamp' - default: - return undefined - } - } -} - -const TOKENS_FILTERS = ` - $first: Int - $skip: Int - $orderBy: String - $orderDirection: String - - $address: String -` - -const TOKENS_ARGUMENTS = ` - first: $first - skip: $skip - orderBy: $orderBy - orderDirection: $orderDirection -` - -function getNFTsCountQuery(params: NFTsFetchParams) { - return getNFTsQuery(params, true) -} - -function getNFTsQuery(params: NFTsFetchParams, isCount = false) { - let extraWhere: string[] = [] - - if (params.address) { - extraWhere.push('currentOwner: $address') - } - - // TODO: Search? - // TODO: onlyOnSale? - - return gql` - query Tokens( - ${TOKENS_FILTERS} - ) { - tokens( - where: { - ${extraWhere.join('\n')} - } - ${TOKENS_ARGUMENTS} - ) { - ${isCount ? 'id' : '...tokenFragment'} - } - } - ${isCount ? '' : tokenFragment()} - ` -} - -const TOKEN_BY_ID_QUERY = gql` - query TokenById($id: String) { - tokens(where: { id: $id }, first: 1) { - ...tokenFragment - } - } - ${tokenFragment()} -` - -export const tokenAPI = new TokenAPI() diff --git a/webapp/src/modules/vendor/known_origin/token/fragments.ts b/webapp/src/modules/vendor/known_origin/token/fragments.ts deleted file mode 100644 index 74e5a4398..000000000 --- a/webapp/src/modules/vendor/known_origin/token/fragments.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { gql } from 'apollo-boost' -import { AssetType } from '../types' - -export const tokenFragment = () => gql` - fragment tokenFragment on Token { - id - tokenId - editionNumber - currentOwner { - id - } - metadata { - name - image - description - } - } -` - -export type TokenFragment = { - id: string - type: AssetType.TOKEN - editionNumber: string - tokenId: string - currentOwner: { - id: string - } - metadata: { - name: string - image: string - description: string - } -} diff --git a/webapp/src/modules/vendor/known_origin/token/index.ts b/webapp/src/modules/vendor/known_origin/token/index.ts deleted file mode 100644 index 3318fdbc9..000000000 --- a/webapp/src/modules/vendor/known_origin/token/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './api' diff --git a/webapp/src/modules/vendor/known_origin/types.ts b/webapp/src/modules/vendor/known_origin/types.ts deleted file mode 100644 index e5ef5aea1..000000000 --- a/webapp/src/modules/vendor/known_origin/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum AssetType { - TOKEN = 'token', - EDITION = 'edition' -} diff --git a/webapp/src/modules/vendor/makers_place/ContractService.ts b/webapp/src/modules/vendor/makers_place/ContractService.ts deleted file mode 100644 index 3e8bcc3ee..000000000 --- a/webapp/src/modules/vendor/makers_place/ContractService.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ChainId, Network } from '@dcl/schemas' -import { - Contract, - ContractService as ContractServiceInterface -} from '../services' -import { Network as AppNetwork } from '../../contract/types' -import { TransferType } from '../types' -import { config } from '../../../config' - -const network = config.get('NETWORK')! as AppNetwork - -export enum ContractName { - DIGITAL_MEDIA_CORE = 'DigitalMediaCore', - DIGITAL_MEDIA_CORE_2 = 'DigitalMediaCore2', - MARKETPLACE_ADAPTER = 'MarketplaceAdapter' -} - -const contracts = ({ - [AppNetwork.ROPSTEN]: [], - [AppNetwork.MAINNET]: [ - { - name: ContractName.DIGITAL_MEDIA_CORE, - address: '0x2a46f2ffd99e19a89476e2f62270e0a35bbf0756', - vendor: 'makers_place', - category: 'art', - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.DIGITAL_MEDIA_CORE_2, - address: '0x2d9e5de7d36f3830c010a28b29b3bdf5ca73198e', - vendor: 'makers_place', - category: 'art', - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.MARKETPLACE_ADAPTER, - address: '0xf4fbd84193f9aaf9779dedbb415a806933eb1c95', - vendor: 'makers_place', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - } - ] -} as Record)[network] - -export class ContractService implements ContractServiceInterface { - contracts = contracts - - async build() {} - - getContracts() { - return this.contracts - } - - getTransferType(_address: string) { - return TransferType.SAFE_TRANSFER_FROM - } -} diff --git a/webapp/src/modules/vendor/makers_place/NFTService.ts b/webapp/src/modules/vendor/makers_place/NFTService.ts deleted file mode 100644 index de9cd1c73..000000000 --- a/webapp/src/modules/vendor/makers_place/NFTService.ts +++ /dev/null @@ -1,209 +0,0 @@ -import BN from 'bn.js' -import { ListingStatus, Network, Order } from '@dcl/schemas' -import { ethers } from 'ethers' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { ERC721__factory } from '../../../contracts' -import { NFT, NFTsFetchParams, NFTsCountParams } from '../../nft/types' -import { Account } from '../../account/types' -import { getNFTId } from '../../nft/utils' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { NFTService as NFTServiceInterface } from '../services' -import { getOriginURL } from '../utils' -import { VendorName } from '../types' -import { MakersPlaceAsset } from './types' -import { makersPlaceAPI } from './api' -import { config } from '../../../config' - -export class NFTService - implements NFTServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - private oneEthInWei: BN - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - this.oneEthInWei = new BN('1000000000000000000') // 10 ** 18 - } - - async fetch(params: NFTsFetchParams) { - const [response, oneEthInMANA] = await Promise.all([ - makersPlaceAPI.fetch(params), - this.getOneEthInMANA() - ]) - const total = response.total_items - - const remoteNFTs = response.items - - const nfts: NFT[] = [] - const accounts: Account[] = [] - const orders: Order[] = [] - - for (const asset of remoteNFTs) { - if (!this.isValid(asset)) { - continue - } - const nft = this.toNFT(asset) - - if (this.isOnSale(asset)) { - const order = this.toOrder(asset, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - - orders.push(order) - } - - let account = accounts.find(account => account.id === asset.owner) - if (!account) { - account = this.toAccount(asset.owner) - } - account.nftIds.push(nft.id) - - nfts.push(nft) - accounts.push(account) - } - - return [nfts, accounts, orders, total] as const - } - - async count(countParams: NFTsCountParams) { - const params: NFTsFetchParams = { - ...countParams, - first: 1, - skip: 0 - } - const response = await makersPlaceAPI.fetch(params) - return response.total_items - } - - async fetchOne(contractAddress: string, tokenId: string) { - const [response, oneEthInMANA] = await Promise.all([ - makersPlaceAPI.fetchOne(contractAddress, tokenId), - this.getOneEthInMANA() - ]) - - const remoteNFT = response.item - if (!this.isValid(remoteNFT)) { - throw new Error( - `Invalid asset for contract "${contractAddress}" and id "${tokenId}"` - ) - } - - const nft = this.toNFT(remoteNFT) - let order: Order | undefined - - if (this.isOnSale(remoteNFT)) { - order = this.toOrder(remoteNFT, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - } - - return [nft, order] as const - } - - async transfer( - wallet: Wallet | null, - toAddress: string, - nft: NFT - ) { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - const from = wallet.address - const to = toAddress - - const erc721 = ERC721__factory.connect( - nft.contractAddress, - await getSigner() - ) - - const transaction = await erc721.transferFrom(from, to, nft.tokenId) - return transaction.hash - } - - toNFT(asset: MakersPlaceAsset): NFT { - const tokenId = asset.token_id!.toString() - const contractAddress = asset.token_contract_address.toLowerCase() - return { - id: getNFTId(contractAddress, tokenId), - tokenId, - contractAddress, - activeOrderId: '', - owner: asset.owner, - name: asset.name, - image: asset.image_url, - url: asset.url || this.getDefaultURL(asset), - data: { - description: asset.description - }, - category: 'art', - vendor: VendorName.MAKERS_PLACE, - chainId: Number(config.get('CHAIN_ID')!), - network: Network.ETHEREUM, - issuedId: null, - itemId: null, - createdAt: 0, - updatedAt: 0, - soldAt: 0 - } - } - - toOrder( - asset: MakersPlaceAsset, - oneEthInMANA: string - ): Order & { ethPrice: string } { - const totalWei = this.marketplacePrice.addFee(asset.price_in_wei!) - const weiPrice = new BN(totalWei).mul(new BN(oneEthInMANA)) - const price = weiPrice.div(this.oneEthInWei) - - return { - id: `${VendorName.MAKERS_PLACE}-order-${asset.token_id}`, - tokenId: asset.token_id!.toString(), - contractAddress: asset.token_contract_address.toLowerCase(), - marketplaceAddress: asset.sale_contract_address!, - owner: asset.owner, - buyer: null, - price: price.toString(10), - ethPrice: asset.price_in_wei!.toString(), - status: ListingStatus.OPEN, - createdAt: +asset.sale_created_at!, - updatedAt: +asset.sale_created_at!, - expiresAt: Infinity, - network: Network.ETHEREUM, - chainId: Number(config.get('CHAIN_ID')!) - } - } - - toAccount(address: string): Account { - return { - id: address, - address, - nftIds: [] - } - } - - private async getOneEthInMANA() { - const mana = await this.tokenConverter.marketEthToMANA(1) - return ethers.utils.parseEther(mana.toString()) - } - - private isValid(asset: MakersPlaceAsset) { - // For some reason, the API *sometimes* returns null on token_ids - // We need to either skip or just throw when we found these - return asset.token_id !== null - } - - private isOnSale(asset: MakersPlaceAsset): boolean { - return ( - asset.price_in_wei !== undefined && - asset.sale_contract_address !== undefined - ) - } - - private getDefaultURL(asset: MakersPlaceAsset): string { - const origin = getOriginURL(VendorName.MAKERS_PLACE) - return `${origin}/authenticity/${asset.token_contract_address}/${asset.token_id}` - } -} diff --git a/webapp/src/modules/vendor/makers_place/OrderService.ts b/webapp/src/modules/vendor/makers_place/OrderService.ts deleted file mode 100644 index 47a5dcde4..000000000 --- a/webapp/src/modules/vendor/makers_place/OrderService.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { ethers } from 'ethers' -import { Order } from '@dcl/schemas' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { MarketplaceAdapter__factory } from '../../../contracts' -import { getContract } from '../../contract/utils' -import { NFT } from '../../nft/types' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { getContractNames, VendorName } from '../types' -import { OrderService as OrderServiceInterface } from '../services' -import { ContractService } from './ContractService' - -export class OrderService - implements OrderServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - } - - fetchByNFT(): any { - throw new Error('Method: `fetchByNFT` is not implemented') - } - - create(): any { - throw new Error('Method: `create` is not implemented') - } - - async execute( - wallet: Wallet | null, - nft: NFT, - order: Order - ): Promise { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - const contractService = new ContractService() - const contractNames = getContractNames() - - // Addresses - const assetContractAddress = nft.contractAddress - const assetMarketAddress = order.marketplaceAddress - const manaTokenAddress = getContract({ name: contractNames.MANA }).address - const from = wallet.address - - // Data - const calldata = this.getCallData(nft) - const transferType = contractService.getTransferType(nft.contractAddress) - - // Price - const manaPrice = await this.tokenConverter.contractEthToMANA( - (order as Order & { ethPrice: string }).ethPrice! - ) - const maxPrice = this.marketplacePrice.addMaxSlippage(manaPrice) - - // Contract - const marketplaceAdapter = MarketplaceAdapter__factory.connect( - getContract({ name: contractNames.MARKETPLACE_ADAPTER }).address, - await getSigner() - ) - - const transaction = await marketplaceAdapter[ - 'buy(address,uint256,address,bytes,uint256,address,uint256,uint8,address)' - ]( - assetContractAddress, - nft.tokenId, - assetMarketAddress, - calldata, - (order as Order & { ethPrice: string }).ethPrice!, - manaTokenAddress, - maxPrice, - transferType, - from - ) - - return transaction.hash - } - - cancel(): any { - throw new Error('Method: `cancel` is not implemented') - } - - canSell() { - return false - } - - private getCallData(nft: NFT) { - const abiCoder = ethers.utils.defaultAbiCoder - // purchase - return abiCoder.encode( - ['uint256', 'address'], - [nft.tokenId, nft.contractAddress] - ) - } -} diff --git a/webapp/src/modules/vendor/makers_place/api.ts b/webapp/src/modules/vendor/makers_place/api.ts deleted file mode 100644 index e288ee612..000000000 --- a/webapp/src/modules/vendor/makers_place/api.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { AxiosRequestConfig } from 'axios' -import { BaseAPI } from 'decentraland-dapps/dist/lib/api' -import { SortDirection } from '../../routing/types' -import { capitalize } from '../../../lib/text' -import { NFTsFetchParams, NFTSortBy } from '../../nft/types' -import { - Response, - FetchSuccessResponse, - FetchOneSuccessResponse, - MakersPlaceFetchParams, - MakersPlaceFetchOneParams, - MakersPlaceSort -} from './types' -import { config } from '../../../config' - -const API_URL = config.get('MAKERS_PLACE_API_URL')! - -export const MAX_QUERY_SIZE = 50 - -class MakersPlaceAPI extends BaseAPI { - constructor(url: string) { - super(url) - - if (!url) { - throw new Error(`Invalid MakersPlace API URL "${url}"`) - } - } - - async fetch(params: NFTsFetchParams): Promise { - const skip = params.skip || 0 - const page_size = Math.min(params.first, MAX_QUERY_SIZE) - const page_num = Math.ceil(skip / page_size) + 1 - - const requestParams: MakersPlaceFetchParams = { - page_num, - page_size, - on_sale: 'True', - owner_address: params.address, - q: params.search, - sort: this.getSort(params) - } - return this.request('get', '/assets/', requestParams) - } - - async fetchOne( - contractAddress: string, - tokenId: string - ): Promise { - const requestParams: MakersPlaceFetchOneParams = { - token_id: Number(tokenId), - contract_address: contractAddress - } - return this.request('get', '/asset/', requestParams) - } - - async request( - method: AxiosRequestConfig['method'], - path: string, - params: MakersPlaceFetchParams | MakersPlaceFetchOneParams - ) { - const response: Response = await super.request(method, path, params) - - if (response.status === 'failure') { - const errors = JSON.stringify(response.errors, null, 2) - throw new Error(`Error fetching MakersPlace path "${path}": ${errors}`) - } - - return response as T - } - - private getSort(params: NFTsFetchParams) { - let sort - switch (params.orderBy) { - case NFTSortBy.PRICE: - sort = 'price' - break - case NFTSortBy.ORDER_CREATED_AT: - default: - sort = 'createdAt' - break - } - - const direction = params.orderDirection || SortDirection.DESC - return (sort + capitalize(direction)) as MakersPlaceSort - } -} - -export const makersPlaceAPI = new MakersPlaceAPI(API_URL) diff --git a/webapp/src/modules/vendor/makers_place/index.ts b/webapp/src/modules/vendor/makers_place/index.ts deleted file mode 100644 index 3402910fb..000000000 --- a/webapp/src/modules/vendor/makers_place/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NFTService } from './NFTService' -import { ContractService } from './ContractService' -import { OrderService } from './OrderService' - -export const VendorName = 'makers_place' - -export * from './types' -export * from './nft' -export * from './routing' - -export * from './NFTService' -export * from './ContractService' -export * from './OrderService' -export const services = { - NFTService, - ContractService, - OrderService -} diff --git a/webapp/src/modules/vendor/makers_place/nft/index.ts b/webapp/src/modules/vendor/makers_place/nft/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/makers_place/nft/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/makers_place/nft/types.ts b/webapp/src/modules/vendor/makers_place/nft/types.ts deleted file mode 100644 index 1210f7bfc..000000000 --- a/webapp/src/modules/vendor/makers_place/nft/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type NFTsFetchFilters = {} - -export type NFTData = { - description: string -} diff --git a/webapp/src/modules/vendor/makers_place/routing/index.ts b/webapp/src/modules/vendor/makers_place/routing/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/makers_place/routing/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/makers_place/routing/types.ts b/webapp/src/modules/vendor/makers_place/routing/types.ts deleted file mode 100644 index 40dcbedde..000000000 --- a/webapp/src/modules/vendor/makers_place/routing/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum Section { - ALL = 'all' -} diff --git a/webapp/src/modules/vendor/makers_place/types.ts b/webapp/src/modules/vendor/makers_place/types.ts deleted file mode 100644 index a21af153e..000000000 --- a/webapp/src/modules/vendor/makers_place/types.ts +++ /dev/null @@ -1,61 +0,0 @@ -export type MakersPlaceSort = - | 'createdAtAsc' - | 'createdAtDesc' - | 'priceAsc' - | 'priceDesc' - | 'saleCreatedAtAsc' - | 'saleCreatedAtDesc' - -export type MakersPlaceFetchParams = { - page_num: number - page_size: number - on_sale: 'True' - sort: MakersPlaceSort - q?: string - owner_address?: string -} - -export type MakersPlaceFetchOneParams = { - token_id: number - contract_address: string -} - -export type MakersPlaceAsset = { - token_id: number | null - token_contract_address: string - name: string - description: string - total_supply: number - image_url: string - owner: string - url?: string - sale_created_at?: string - price_in_wei?: string - sale_contract_address?: string -} - -export type FetchOneSuccessResponse = { - item: MakersPlaceAsset - status: 'success' -} -export type FetchOneFailureResponse = { - status: 'failure' - errors: Record -} -export type FetchOneResponse = FetchOneSuccessResponse | FetchOneFailureResponse - -export type FetchSuccessResponse = { - items: MakersPlaceAsset[] - page_num: number - page_size: number - total_pages: number - total_items: number - status: 'success' -} -export type FetchFailureResponse = { - status: 'failure' - errors: string[] -} -export type FetchResponse = FetchSuccessResponse | FetchFailureResponse - -export type Response = FetchOneResponse | FetchResponse diff --git a/webapp/src/modules/vendor/nft/types.ts b/webapp/src/modules/vendor/nft/types.ts index f80cc321b..870742349 100644 --- a/webapp/src/modules/vendor/nft/types.ts +++ b/webapp/src/modules/vendor/nft/types.ts @@ -1,24 +1,11 @@ import { VendorName } from '../types' import * as decentraland from '../decentraland' -import * as superRare from '../super_rare' -import * as makersPlace from '../makers_place' -import * as knownOrigin from '../known_origin' export type NFTsFetchFilters< V extends VendorName | unknown = unknown > = V extends VendorName.DECENTRALAND ? decentraland.NFTsFetchFilters - : V extends VendorName.SUPER_RARE - ? superRare.NFTsFetchFilters - : V extends VendorName.MAKERS_PLACE - ? makersPlace.NFTsFetchFilters - : V extends VendorName.KNOWN_ORIGIN - ? knownOrigin.NFTsFetchFilters : V extends unknown - ? - | decentraland.NFTsFetchFilters - | superRare.NFTsFetchFilters - | makersPlace.NFTsFetchFilters - | knownOrigin.NFTsFetchFilters + ? decentraland.NFTsFetchFilters : never diff --git a/webapp/src/modules/vendor/routing/types.ts b/webapp/src/modules/vendor/routing/types.ts index d11921c62..7ffa7f0b8 100644 --- a/webapp/src/modules/vendor/routing/types.ts +++ b/webapp/src/modules/vendor/routing/types.ts @@ -1,20 +1,10 @@ import * as decentraland from '../decentraland/routing/types' -import * as superRare from '../super_rare/routing/types' -import * as makersPlace from '../makers_place/routing/types' -import * as knownOrigin from '../known_origin/routing/types' export type Sections = typeof Sections -export type Section = - | decentraland.Section - | superRare.Section - | makersPlace.Section - | knownOrigin.Section +export type Section = decentraland.Section // eslint-disable-next-line @typescript-eslint/no-redeclare -- Intentionally naming the variable the same as the type export const Sections = { - decentraland: { ...decentraland.Section }, - super_rare: { ...superRare.Section }, - makers_place: { ...makersPlace.Section }, - known_origin: { ...knownOrigin.Section } + decentraland: { ...decentraland.Section } } as const diff --git a/webapp/src/modules/vendor/super_rare/ContractService.ts b/webapp/src/modules/vendor/super_rare/ContractService.ts deleted file mode 100644 index d8f03127c..000000000 --- a/webapp/src/modules/vendor/super_rare/ContractService.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { ChainId, Network } from '@dcl/schemas' -import { config } from '../../../config' -import { Network as AppNetwork } from '../../contract/types' -import { getContract } from '../../contract/utils' -import { - Contract, - ContractService as ContractServiceInterface -} from '../services' -import { TransferType } from '../types' - -const network = config.get('NETWORK')! as AppNetwork - -export enum ContractName { - SUPER_RARE = 'SuperRare', - SUPER_RARE_V2 = 'SuperRareV2', - SUPER_RARE_MARKET = 'SuperRareMarket', - SUPER_RARE_MARKET_V2 = 'SuperRareMarketV2', - MARKETPLACE_ADAPTER = 'MarketplaceAdapter' -} - -const contracts = ({ - [AppNetwork.ROPSTEN]: [ - { - name: ContractName.MARKETPLACE_ADAPTER, - address: '0xd1e4e2880ff56cd0d5c68da9bed58bfbf0150948', - vendor: 'super_rare', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_ROPSTEN - } - ], - [AppNetwork.MAINNET]: [ - { - name: ContractName.SUPER_RARE, - address: '0x41a322b28d0ff354040e2cbc676f0320d8c8850d', - vendor: 'super_rare', - category: 'art', - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.SUPER_RARE_V2, - address: '0xb932a70a57673d89f4acffbe830e8ed7f75fb9e0', - vendor: 'super_rare', - category: 'art', - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.SUPER_RARE_MARKET, - address: '0x41a322b28d0ff354040e2cbc676f0320d8c8850d', - vendor: 'super_rare', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.SUPER_RARE_MARKET_V2, - address: '0x2947f98c42597966a0ec25e92843c09ac17fbaa7', - vendor: 'super_rare', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - }, - { - name: ContractName.MARKETPLACE_ADAPTER, - address: '0xf4fbd84193f9aaf9779dedbb415a806933eb1c95', - vendor: 'super_rare', - category: null, - network: Network.ETHEREUM, - chainId: ChainId.ETHEREUM_MAINNET - } - ] -} as Record)[network] - -export class ContractService implements ContractServiceInterface { - contracts = contracts - - async build() {} - - getContracts() { - return this.contracts - } - - getTransferType(address: string) { - const contract = getContract({ address }) - if (!contract) { - throw new Error('Invalid address: not found in contracts') - } - switch (contract.name) { - case ContractName.SUPER_RARE: - return TransferType.TRANSFER - case ContractName.SUPER_RARE_V2: - return TransferType.SAFE_TRANSFER_FROM - default: - throw new Error( - `Invalid contract name: expected "${ContractName.SUPER_RARE}" or "${ContractName.SUPER_RARE_V2}" but got "${contract.name}" instead` - ) - } - } -} diff --git a/webapp/src/modules/vendor/super_rare/NFTService.ts b/webapp/src/modules/vendor/super_rare/NFTService.ts deleted file mode 100644 index cf9498932..000000000 --- a/webapp/src/modules/vendor/super_rare/NFTService.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { ethers } from 'ethers' -import { ListingStatus, Network, Order } from '@dcl/schemas' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { ERC721__factory } from '../../../contracts' -import { NFT, NFTsFetchParams, NFTsCountParams } from '../../nft/types' -import { Account } from '../../account/types' -import { getNFTId } from '../../nft/utils' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { NFTService as NFTServiceInterface } from '../services' -import { VendorName, TransferType } from '../types' -import { ContractService } from './ContractService' -import { SuperRareAsset, SuperRareOrder, SuperRareOwner } from './types' -import { superRareAPI, MAX_QUERY_SIZE } from './api' -import { config } from '../../../config' - -export class NFTService implements NFTServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - private oneEthInWei: ethers.BigNumber - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - this.oneEthInWei = ethers.BigNumber.from('1000000000000000000') // 10 ** 18 - } - - async fetch(params: NFTsFetchParams) { - let remoteNFTs: SuperRareAsset[] - let remoteOrders: SuperRareOrder[] - - if ((params.address && !params.onlyOnSale) || !params.onlyOnSale) { - const result = await Promise.all([ - superRareAPI.fetchNFTs(params), - superRareAPI.fetchOrders(params) - ]) - remoteNFTs = result[0] - remoteOrders = result[1] - } else { - remoteOrders = await superRareAPI.fetchOrders(params) - remoteNFTs = remoteOrders.map(order => order.asset) - } - - const nfts: NFT[] = [] - const accounts: Account[] = [] - const orders: Order[] = [] - - const total = await this.count(params) - const oneEthInMANA = await this.getOneEthInMANA() - - for (const asset of remoteNFTs) { - const nft = this.toNFT(asset) - - const remoteOrder = remoteOrders.find( - order => order.asset.id === asset.id - ) - - if (remoteOrder) { - const order = this.toOrder(remoteOrder, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - - orders.push(order) - } - - let account = accounts.find(account => account.id === asset.owner.address) - if (!account) { - account = this.toAccount(asset.owner) - } - account.nftIds.push(nft.id) - - nfts.push(nft) - accounts.push(account) - } - - return [nfts, accounts, orders, total] as const - } - - async count(countParams: NFTsCountParams) { - const params: NFTsFetchParams = { - ...countParams, - first: MAX_QUERY_SIZE, - skip: 0 - } - - let remoteElements - if (params.address) { - remoteElements = await superRareAPI.fetchNFTs(params) - } else { - remoteElements = await superRareAPI.fetchOrders(params) - } - - return remoteElements.length - } - - async fetchOne(contractAddress: string, tokenId: string) { - const [remoteNFT, remoteOrder, oneEthInMANA] = await Promise.all([ - superRareAPI.fetchNFT(contractAddress, tokenId), - superRareAPI.fetchOrder(contractAddress, tokenId), - this.getOneEthInMANA() - ]) - - const nft = this.toNFT(remoteNFT) - let order: Order | undefined - - if (remoteOrder) { - order = this.toOrder(remoteOrder, oneEthInMANA.toString()) - - nft.activeOrderId = order.id - } - - return [nft, order] as const - } - - async transfer( - wallet: Wallet | null, - toAddress: string, - nft: NFT - ) { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - const from = wallet.address - const to = toAddress - - const erc721 = ERC721__factory.connect( - nft.contractAddress, - await getSigner() - ) - const transferType = new ContractService().getTransferType( - nft.contractAddress - ) - let transaction - - switch (transferType) { - case TransferType.TRANSFER: - transaction = await erc721.transfer(to, nft.tokenId) - break - case TransferType.SAFE_TRANSFER_FROM: - default: - transaction = await erc721.transferFrom(from, to, nft.tokenId) - break - } - - return transaction.hash - } - - toNFT(asset: SuperRareAsset): NFT { - return { - id: getNFTId(asset.contractAddress, asset.id.toString()), - tokenId: asset.id.toString(), - contractAddress: asset.contractAddress, - activeOrderId: '', - owner: asset.owner.address, - name: asset.name, - image: asset.image, - url: asset.url, - data: { - description: asset.description - }, - category: 'art', - vendor: VendorName.SUPER_RARE, - chainId: Number(config.get('CHAIN_ID')!), - network: Network.ETHEREUM, - issuedId: null, - itemId: null, - createdAt: 0, - updatedAt: 0, - soldAt: 0 - } - } - - toOrder( - order: SuperRareOrder, - oneEthInMANA: string - ): Order & { ethPrice: string } { - const { asset, taker } = order - - const totalWei = this.marketplacePrice.addFee(order.amountWithFee) - const weiPrice = ethers.BigNumber.from(totalWei).mul(oneEthInMANA) - const price = weiPrice.div(this.oneEthInWei) - - return { - id: `${VendorName.SUPER_RARE}-order-${asset.id}`, - tokenId: asset.id.toString(), - contractAddress: asset.contractAddress, - marketplaceAddress: order.marketContractAddress, - owner: asset.owner.address, - buyer: taker ? taker.address : null, - price: price.toString(), - ethPrice: order.amountWithFee.toString(), - status: ListingStatus.OPEN, - createdAt: +order.timestamp, - updatedAt: +order.timestamp, - expiresAt: Infinity, - chainId: Number(config.get('CHAIN_ID')!), - network: Network.ETHEREUM - } - } - - toAccount(account: SuperRareOwner): Account { - return { - id: account.address, - address: account.address, - nftIds: [] - } - } - - private async getOneEthInMANA() { - const mana = await this.tokenConverter.marketEthToMANA(1) - return ethers.utils.parseEther(mana.toString()) - } -} diff --git a/webapp/src/modules/vendor/super_rare/OrderService.ts b/webapp/src/modules/vendor/super_rare/OrderService.ts deleted file mode 100644 index c3a937686..000000000 --- a/webapp/src/modules/vendor/super_rare/OrderService.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { ethers } from 'ethers' -import { Order } from '@dcl/schemas' -import { getSigner } from 'decentraland-dapps/dist/lib/eth' -import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types' -import { MarketplaceAdapter__factory } from '../../../contracts' -import { getContract } from '../../contract/utils' -import { NFT } from '../../nft/types' -import { TokenConverter } from '../TokenConverter' -import { MarketplacePrice } from '../MarketplacePrice' -import { getContractNames, VendorName } from '../types' -import { OrderService as OrderServiceInterface } from '../services' -import { ContractService } from './ContractService' - -export class OrderService - implements OrderServiceInterface { - private tokenConverter: TokenConverter - private marketplacePrice: MarketplacePrice - - constructor() { - this.tokenConverter = new TokenConverter() - this.marketplacePrice = new MarketplacePrice() - } - - fetchByNFT(): any { - throw new Error('Method: `fetchByNFT` is not implemented') - } - - create(): any { - throw new Error('Method: `create` is not implemented') - } - - async execute( - wallet: Wallet | null, - nft: NFT, - order: Order - ): Promise { - if (!wallet) { - throw new Error('Invalid address. Wallet must be connected.') - } - const contractService = new ContractService() - - const contractNames = getContractNames() - - // Addresses - const assetContractAddress = nft.contractAddress - const assetMarketAddress = order.marketplaceAddress - const manaTokenAddress = getContract({ name: contractNames.MANA }).address - const from = wallet.address - - // Data - const calldata = this.getCallData(nft) - const transferType = contractService.getTransferType(nft.contractAddress) - - // Price - const manaPrice = await this.tokenConverter.contractEthToMANA( - (order as Order & { ethPrice: string }).ethPrice! - ) - const maxPrice = this.marketplacePrice.addMaxSlippage(manaPrice) - - // Contract - const marketplaceAdapter = MarketplaceAdapter__factory.connect( - getContract({ name: contractNames.MARKETPLACE_ADAPTER }).address, - await getSigner() - ) - - const transaction = await marketplaceAdapter[ - 'buy(address,uint256,address,bytes,uint256,address,uint256,uint8,address)' - ]( - assetContractAddress, - nft.tokenId, - assetMarketAddress, - calldata, - (order as Order & { ethPrice: string }).ethPrice!, - manaTokenAddress, - maxPrice, - transferType, - from - ) - return transaction.hash - } - - cancel(): any { - throw new Error('Method: `cancel` is not implemented') - } - - canSell() { - return false - } - - private getCallData(nft: NFT) { - const contractNames = getContractNames() - const superRare = getContract({ name: contractNames.SUPER_RARE }) - const superRareV2 = getContract({ - name: contractNames.SUPER_RARE_V2 - }) - const abiCoder = ethers.utils.defaultAbiCoder - - switch (nft.contractAddress) { - case superRare.address: - return abiCoder.encode(['uint256'], [nft.tokenId]) - case superRareV2.address: - return abiCoder.encode( - ['address', 'uint256'], - [nft.contractAddress, nft.tokenId] - ) - default: - throw new Error(`Invalid SuperRare address ${nft.contractAddress}`) - } - } -} diff --git a/webapp/src/modules/vendor/super_rare/api.ts b/webapp/src/modules/vendor/super_rare/api.ts deleted file mode 100644 index 314b3f449..000000000 --- a/webapp/src/modules/vendor/super_rare/api.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { AxiosRequestConfig } from 'axios' -import { BaseAPI } from 'decentraland-dapps/dist/lib/api' -import { config } from '../../../config' -import { NFTsFetchParams, NFTSortBy } from '../../nft/types' -import { - SuperRareOrder, - SuperRareAsset, - SuperRareFetchNFTOptions, - SuperRareFetchOrderParams -} from './types' - -const API_URL = config.get('SUPER_RARE_API_URL')! - -export const MAX_QUERY_SIZE = 100 - -class SuperRareAPI extends BaseAPI { - public API_KEY: string = '' - - constructor(url: string) { - super(url) - - if (!url) { - throw new Error(`Invalid SuperRare API URL "${url}"`) - } - - this.API_KEY = config.get('SUPER_RARE_API_KEY')! - if (!this.API_KEY) { - throw new Error(`Invalid SuperRare API KEY "${this.API_KEY}"`) - } - } - - async fetchNFTs(params: NFTsFetchParams): Promise { - return this.request( - 'get', - '/nfts/assets', - this.buildFetchManyParams(params) - ) - } - - async fetchOrders(params: NFTsFetchParams): Promise { - return this.request( - 'get', - '/nfts/orders', - this.buildFetchManyParams(params) - ) - } - - async fetchNFT( - contractAddress: string, - tokenId: string - ): Promise { - const nfts: SuperRareAsset[] = await this.request( - 'get', - '/nfts/assets', - this.buildFetchOneParams(contractAddress, tokenId) - ) - return nfts[0] - } - - async fetchOrder( - contractAddress: string, - tokenId: string - ): Promise { - const orders: SuperRareOrder[] = await this.request( - 'get', - '/nfts/orders', - this.buildFetchOneParams(contractAddress, tokenId) - ) - return orders[0] - } - - request( - method: AxiosRequestConfig['method'], - path: string, - params: SuperRareFetchOrderParams - ) { - return super.request(method, path, params, this.getHeaders()) - } - - private getHeaders() { - return { - headers: { Authorization: `Bearer ${this.API_KEY}` } - } - } - - private buildFetchOneParams( - contractAddress: string, - tokenId: string - ): SuperRareFetchNFTOptions { - return { - type: 'sell', - asset_contract_addresses: [contractAddress], - asset_ids: [Number(tokenId)] - } - } - - private buildFetchManyParams( - params: NFTsFetchParams - ): SuperRareFetchOrderParams { - const requestParams: SuperRareFetchOrderParams = { - type: 'sell', - offset: params.skip, - limit: Math.min(params.first, MAX_QUERY_SIZE), - sort: this.getSort(params.orderBy), - name: params.search, - order: params.orderDirection - } - - if (params.address) { - requestParams.owner_addresses = [params.address] - } - - return requestParams - } - - private getSort(sortBy?: NFTSortBy) { - switch (sortBy) { - case NFTSortBy.PRICE: - return 'price' - case NFTSortBy.ORDER_CREATED_AT: - return 'timestamp' - default: - return undefined - } - } -} - -export const superRareAPI = new SuperRareAPI(API_URL) diff --git a/webapp/src/modules/vendor/super_rare/index.ts b/webapp/src/modules/vendor/super_rare/index.ts deleted file mode 100644 index 4cd28274d..000000000 --- a/webapp/src/modules/vendor/super_rare/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NFTService } from './NFTService' -import { ContractService } from './ContractService' -import { OrderService } from './OrderService' - -export const VendorName = 'super_rare' - -export * from './types' -export * from './nft' -export * from './routing' - -export * from './NFTService' -export * from './ContractService' -export * from './OrderService' -export const services = { - NFTService, - ContractService, - OrderService -} diff --git a/webapp/src/modules/vendor/super_rare/nft/index.ts b/webapp/src/modules/vendor/super_rare/nft/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/super_rare/nft/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/super_rare/nft/types.ts b/webapp/src/modules/vendor/super_rare/nft/types.ts deleted file mode 100644 index 1210f7bfc..000000000 --- a/webapp/src/modules/vendor/super_rare/nft/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type NFTsFetchFilters = {} - -export type NFTData = { - description: string -} diff --git a/webapp/src/modules/vendor/super_rare/routing/index.ts b/webapp/src/modules/vendor/super_rare/routing/index.ts deleted file mode 100644 index c9f6f047d..000000000 --- a/webapp/src/modules/vendor/super_rare/routing/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types' diff --git a/webapp/src/modules/vendor/super_rare/routing/types.ts b/webapp/src/modules/vendor/super_rare/routing/types.ts deleted file mode 100644 index 40dcbedde..000000000 --- a/webapp/src/modules/vendor/super_rare/routing/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum Section { - ALL = 'all' -} diff --git a/webapp/src/modules/vendor/super_rare/types.ts b/webapp/src/modules/vendor/super_rare/types.ts deleted file mode 100644 index 4d6e2cf8d..000000000 --- a/webapp/src/modules/vendor/super_rare/types.ts +++ /dev/null @@ -1,65 +0,0 @@ -export type SuperRareOwner = { - address: string - user: { - username: string - ethereumAddress: string - superRareUrl: string - avatar: string | null - } -} - -export type SuperRareAsset = { - id: number - contractAddress: string - creator: SuperRareOwner - image: string - category: string - likeCount: number - url: string - owner: SuperRareOwner - media: string | null - name: string - metadataUri: string - description: string - viewCount: number - tags: string[] -} - -export type SuperRareOrder = { - asset: SuperRareAsset - taker: SuperRareOwner | null - maker: SuperRareOwner | null - marketContractAddress: string - timestamp: string - amount: number - amountWithFee: number -} - -export type SuperRareFetchNFTOptions = Partial<{ - type: 'sell' | 'buy' - asset_contract_addresses: string[] - creator_addresses: string[] - owner_addresses: string[] - asset_ids: number[] - categories: string[] - name: string - for_sale: boolean - offset: number - limit: number -}> - -export type SuperRareFetchOrderParams = Partial<{ - type: 'sell' | 'buy' - taker_addresses: string[] - maker_addresses: string[] - creator_addresses: string[] - owner_addresses: string[] - asset_contract_addresses: string[] - asset_ids: number[] - categories: string[] - name: string - order: 'asc' | 'desc' - sort: 'price' | 'timestamp' - offset: number - limit: number -}> diff --git a/webapp/src/modules/vendor/types.ts b/webapp/src/modules/vendor/types.ts index 5e5d0fe2a..ab6a9f165 100644 --- a/webapp/src/modules/vendor/types.ts +++ b/webapp/src/modules/vendor/types.ts @@ -1,34 +1,21 @@ import * as decentraland from './decentraland' -import * as superRare from './super_rare' -import * as makersPlace from './makers_place' -import * as knownOrigin from './known_origin' export enum VendorName { - DECENTRALAND = 'decentraland', - SUPER_RARE = 'super_rare', - MAKERS_PLACE = 'makers_place', - KNOWN_ORIGIN = 'known_origin' + DECENTRALAND = 'decentraland' } export const Disabled = {} const ContractName = { - ...decentraland.ContractName, - ...superRare.ContractName, - ...makersPlace.ContractName, - ...knownOrigin.ContractName + ...decentraland.ContractName } // eslint-disable-next-line @typescript-eslint/no-redeclare -- Intentionally naming the variable the same as the type export type ContractName = typeof ContractName -export const getContractNames = () => - ({ - ...decentraland.ContractName, - ...superRare.ContractName, - ...makersPlace.ContractName, - ...knownOrigin.ContractName - } as ContractName) +export const getContractNames = () => ({ + ...decentraland.ContractName +}) export enum TransferType { SAFE_TRANSFER_FROM = 0, diff --git a/webapp/src/modules/vendor/utils.ts b/webapp/src/modules/vendor/utils.ts index e4de13a27..52f9a47b1 100644 --- a/webapp/src/modules/vendor/utils.ts +++ b/webapp/src/modules/vendor/utils.ts @@ -49,16 +49,6 @@ export function getFilters( network } as NFTsFetchFilters } - case VendorName.KNOWN_ORIGIN: { - const currentSection = Sections[VendorName.KNOWN_ORIGIN] - - return { - isEdition: section === currentSection.EDITIONS, - isToken: section === currentSection.TOKENS - } as NFTsFetchFilters - } - case VendorName.SUPER_RARE: - case VendorName.MAKERS_PLACE: default: return {} } @@ -68,12 +58,6 @@ export function getOriginURL(vendor: VendorName) { switch (vendor) { case VendorName.DECENTRALAND: return 'https://market.decentraland.org' - case VendorName.SUPER_RARE: - return 'https://www.superrare.co' - case VendorName.MAKERS_PLACE: - return 'https://makersplace.com' - case VendorName.KNOWN_ORIGIN: - return 'https://knownorigin.io' default: throw new Error(`Base URL for ${vendor} not implemented`) } diff --git a/webapp/src/modules/wallet/sagas.ts b/webapp/src/modules/wallet/sagas.ts index a67b13e5a..90cc3f4af 100644 --- a/webapp/src/modules/wallet/sagas.ts +++ b/webapp/src/modules/wallet/sagas.ts @@ -17,7 +17,6 @@ import { } from 'decentraland-dapps/dist/modules/authorization/types' import { getContractNames } from '../vendor' import { contracts, getContract } from '../contract/utils' -import { isPartner } from '../vendor/utils' import { TRANSACTIONS_API_URL } from './utils' import { config } from '../../config' @@ -59,10 +58,6 @@ function* handleWallet( network: Network.MATIC }) - const marketplaceAdapter = getContract({ - name: contractNames.MARKETPLACE_ADAPTER - }) - const bidsEthereum = getContract({ name: contractNames.BIDS, network: Network.ETHEREUM @@ -117,15 +112,6 @@ function* handleWallet( type: AuthorizationType.ALLOWANCE }) - authorizations.push({ - address, - authorizedAddress: marketplaceAdapter.address, - contractAddress: manaEthereum.address, - contractName: ContractName.MANAToken, - chainId: manaEthereum.chainId, - type: AuthorizationType.ALLOWANCE - }) - authorizations.push({ address, authorizedAddress: bidsEthereum.address, @@ -154,18 +140,11 @@ function* handleWallet( }) for (const contract of contracts.filter(c => c.category !== null)) { + // If the contract is a partner we might need to use a different contract name. See PR #680 const marketplace = getContract({ - name: - contract.vendor && isPartner(contract.vendor) - ? contractNames.MARKETPLACE_ADAPTER - : contractNames.MARKETPLACE, + name: contractNames.MARKETPLACE, network: contract.network - })! - - // Skip SuperRare contract since it's not ERC721 compliant (lacks approveForAll) - if (contract.name === contractNames.SUPER_RARE) { - continue - } + }) authorizations.push({ address,