fix: issues with NFT listing (#4828)
* can approve marketplaces for listing * add consts * fix issue with expiration time * adding api key to env + changing variable * updating env name to req * removing console * use v3 endpoint * remove unussed util * uneeded null check * remove console.log Co-authored-by: Jack Short <john.short.tj@gmail.com> Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
This commit is contained in:
parent
ec686bcaa5
commit
9856c03566
@ -55,7 +55,7 @@ export const ListingButton = ({ onClick, buttonText, showWarningOverride = false
|
|||||||
(asset: WalletAsset) => asset.marketplaces === undefined || asset.marketplaces.length === 0
|
(asset: WalletAsset) => asset.marketplaces === undefined || asset.marketplaces.length === 0
|
||||||
)
|
)
|
||||||
const missingExpiration = sellAssets.some((asset) => {
|
const missingExpiration = sellAssets.some((asset) => {
|
||||||
return asset.expirationTime != null && asset.expirationTime - Date.now() < ms`60 seconds`
|
return asset.expirationTime != null && asset.expirationTime * 1000 - Date.now() < ms`60 seconds`
|
||||||
})
|
})
|
||||||
const invalidExpiration = sellAssets.some((asset) => {
|
const invalidExpiration = sellAssets.some((asset) => {
|
||||||
return asset.expirationTime != null && isNaN(asset.expirationTime)
|
return asset.expirationTime != null && isNaN(asset.expirationTime)
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
import { BigNumber } from '@ethersproject/bignumber'
|
|
||||||
import type { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
|
import type { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
|
||||||
import { ConsiderationInputItem } from '@opensea/seaport-js/lib/types'
|
import { LOOKSRARE_MARKETPLACE_CONTRACT, X2Y2_TRANSFER_CONTRACT } from 'nft/queries'
|
||||||
import {
|
import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
|
||||||
INVERSE_BASIS_POINTS,
|
|
||||||
OPENSEA_CROSS_CHAIN_CONDUIT,
|
|
||||||
OPENSEA_DEFAULT_FEE,
|
|
||||||
OPENSEA_FEE_ADDRESS,
|
|
||||||
} from 'nft/queries/openSea'
|
|
||||||
import { AssetRow, CollectionRow, ListingMarket, ListingRow, ListingStatus, WalletAsset } from 'nft/types'
|
import { AssetRow, CollectionRow, ListingMarket, ListingRow, ListingStatus, WalletAsset } from 'nft/types'
|
||||||
import { approveCollection, signListing } from 'nft/utils/listNfts'
|
import { approveCollection, signListing } from 'nft/utils/listNfts'
|
||||||
import { Dispatch } from 'react'
|
import { Dispatch } from 'react'
|
||||||
@ -60,9 +54,9 @@ export async function approveCollectionRow(
|
|||||||
marketplace.name === 'OpenSea'
|
marketplace.name === 'OpenSea'
|
||||||
? OPENSEA_CROSS_CHAIN_CONDUIT
|
? OPENSEA_CROSS_CHAIN_CONDUIT
|
||||||
: marketplace.name === 'Rarible'
|
: marketplace.name === 'Rarible'
|
||||||
? process.env.REACT_APP_LOOKSRARE_MARKETPLACE_CONTRACT
|
? LOOKSRARE_MARKETPLACE_CONTRACT
|
||||||
: marketplace.name === 'X2Y2'
|
: marketplace.name === 'X2Y2'
|
||||||
? process.env.REACT_APP_X2Y2_TRANSFER_CONTRACT
|
? X2Y2_TRANSFER_CONTRACT
|
||||||
: looksRareAddress
|
: looksRareAddress
|
||||||
await approveCollection(spender ?? '', collectionAddress, signer, (newStatus: ListingStatus) =>
|
await approveCollection(spender ?? '', collectionAddress, signer, (newStatus: ListingStatus) =>
|
||||||
updateStatus({
|
updateStatus({
|
||||||
@ -266,38 +260,3 @@ export const resetRow = (row: AssetRow, rows: AssetRow[], setRows: Dispatch<Asse
|
|||||||
setRows,
|
setRows,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createConsiderationItem = (basisPoints: string, recipient: string): ConsiderationInputItem => {
|
|
||||||
return {
|
|
||||||
amount: basisPoints,
|
|
||||||
recipient,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getConsiderationItems = (
|
|
||||||
asset: WalletAsset,
|
|
||||||
price: BigNumber,
|
|
||||||
signerAddress: string
|
|
||||||
): {
|
|
||||||
sellerFee: ConsiderationInputItem
|
|
||||||
openseaFee: ConsiderationInputItem
|
|
||||||
creatorFee?: ConsiderationInputItem
|
|
||||||
} => {
|
|
||||||
const openSeaBasisPoints = OPENSEA_DEFAULT_FEE * INVERSE_BASIS_POINTS
|
|
||||||
const creatorFeeBasisPoints = asset.creatorPercentage * INVERSE_BASIS_POINTS
|
|
||||||
const sellerBasisPoints = INVERSE_BASIS_POINTS - openSeaBasisPoints - creatorFeeBasisPoints
|
|
||||||
|
|
||||||
const openseaFee = price.mul(BigNumber.from(openSeaBasisPoints)).div(BigNumber.from(INVERSE_BASIS_POINTS)).toString()
|
|
||||||
const creatorFee = price
|
|
||||||
.mul(BigNumber.from(creatorFeeBasisPoints))
|
|
||||||
.div(BigNumber.from(INVERSE_BASIS_POINTS))
|
|
||||||
.toString()
|
|
||||||
const sellerFee = price.mul(BigNumber.from(sellerBasisPoints)).div(BigNumber.from(INVERSE_BASIS_POINTS)).toString()
|
|
||||||
|
|
||||||
return {
|
|
||||||
sellerFee: createConsiderationItem(sellerFee, signerAddress),
|
|
||||||
openseaFee: createConsiderationItem(openseaFee, OPENSEA_FEE_ADDRESS),
|
|
||||||
creatorFee:
|
|
||||||
creatorFeeBasisPoints > 0 ? createConsiderationItem(creatorFee, asset.asset_contract.payout_address) : undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -236,7 +236,7 @@ const SetDurationModal = () => {
|
|||||||
const convertDurationToExpiration = (amount: number, duration: Duration) => {
|
const convertDurationToExpiration = (amount: number, duration: Duration) => {
|
||||||
const durationFactor =
|
const durationFactor =
|
||||||
duration === Duration.hour ? 1 : duration === Duration.day ? 24 : duration === Duration.week ? 24 * 7 : 24 * 30
|
duration === Duration.hour ? 1 : duration === Duration.day ? 24 : duration === Duration.week ? 24 * 7 : 24 * 30
|
||||||
return Math.round(Date.now() + ms`1 hour` * durationFactor * amount)
|
return Math.round((Date.now() + ms`1 hour` * durationFactor * amount) / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GlobalDurationButtonProps {
|
interface GlobalDurationButtonProps {
|
||||||
|
@ -24,7 +24,7 @@ export const fetchWalletAssets = async ({
|
|||||||
? collectionAddresses.reduce((str, collectionAddress) => str + `&assetContractAddresses=${collectionAddress}`, '')
|
? collectionAddresses.reduce((str, collectionAddress) => str + `&assetContractAddresses=${collectionAddress}`, '')
|
||||||
: ''
|
: ''
|
||||||
const url = `${
|
const url = `${
|
||||||
process.env.REACT_APP_GENIE_API_URL
|
process.env.REACT_APP_GENIE_V3_API_URL
|
||||||
}/walletAssets?address=${ownerAddress}${collectionAddressesString}&limit=25&offset=${pageParam * 25}`
|
}/walletAssets?address=${ownerAddress}${collectionAddressesString}&limit=25&offset=${pageParam * 25}`
|
||||||
|
|
||||||
const r = await fetch(url, {
|
const r = await fetch(url, {
|
||||||
@ -38,7 +38,7 @@ export const fetchWalletAssets = async ({
|
|||||||
return {
|
return {
|
||||||
...asset,
|
...asset,
|
||||||
collectionIsVerified: asset.asset_contract.isVerified,
|
collectionIsVerified: asset.asset_contract.isVerified,
|
||||||
lastPrice: asset.last_sale && formatEther(asset.last_sale.total_price),
|
lastPrice: asset.last_sale.total_price && formatEther(asset.last_sale.total_price),
|
||||||
floorPrice: asset.collection?.floorPrice,
|
floorPrice: asset.collection?.floorPrice,
|
||||||
creatorPercentage: parseFloat(asset.asset_contract.dev_seller_fee_basis_points) / 10000,
|
creatorPercentage: parseFloat(asset.asset_contract.dev_seller_fee_basis_points) / 10000,
|
||||||
date_acquired: asset.last_sale ? asset.last_sale.event_timestamp : asset.asset_contract.created_date,
|
date_acquired: asset.last_sale ? asset.last_sale.event_timestamp : asset.asset_contract.created_date,
|
||||||
|
1
src/nft/queries/looksRare/constants.ts
Normal file
1
src/nft/queries/looksRare/constants.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const LOOKSRARE_MARKETPLACE_CONTRACT = '0x59728544B08AB483533076417FbBB2fD0B17CE3a'
|
@ -1,3 +1,4 @@
|
|||||||
|
export * from './constants'
|
||||||
export * from './createLooksRareOrder'
|
export * from './createLooksRareOrder'
|
||||||
export * from './looksRareNonceFetcher'
|
export * from './looksRareNonceFetcher'
|
||||||
export * from './looksRareRewardsFetcher'
|
export * from './looksRareRewardsFetcher'
|
||||||
|
@ -11,6 +11,7 @@ export async function PostOpenSeaSellOrder<T>(
|
|||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-API-KEY': process.env.REACT_APP_OPENSEA_API_KEY ?? '',
|
||||||
},
|
},
|
||||||
...opts,
|
...opts,
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const OPENSEA_BASE_API_PATH = 'https://api.opensea.io'
|
export const OPENSEA_BASE_API_PATH = 'https://api.opensea.io'
|
||||||
export const OPENSEA_FEE_ADDRESS = '0x8de9c5a032463c561423387a9648c5c7bcc5bc90'
|
export const OPENSEA_FEE_ADDRESS = '0x0000a26b00c1F0DF003000390027140000fAa719'
|
||||||
export const OPENSEA_DEFAULT_ZONE = '0x004c00500000ad104d7dbd00e3ae0a5c00560c00'
|
export const OPENSEA_DEFAULT_ZONE = '0x004c00500000ad104d7dbd00e3ae0a5c00560c00'
|
||||||
export const OPENSEA_LISTINGS_API_PATH = '/v2/orders/ethereum/seaport/listings'
|
export const OPENSEA_LISTINGS_API_PATH = '/v2/orders/ethereum/seaport/listings'
|
||||||
export const OPENSEA_DEFAULT_CROSS_CHAIN_CONDUIT_KEY =
|
export const OPENSEA_DEFAULT_CROSS_CHAIN_CONDUIT_KEY =
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { OrderPayload } from '../../utils/x2y2'
|
import { OrderPayload } from '../../utils/x2y2'
|
||||||
|
|
||||||
|
export const X2Y2_TRANSFER_CONTRACT = '0xf849de01b080adc3a814fabe1e2087475cf2e354'
|
||||||
|
|
||||||
export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => {
|
export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => {
|
||||||
const body = JSON.stringify(payload)
|
const body = JSON.stringify(payload)
|
||||||
const url = `${process.env.REACT_APP_GENIE_API_URL}/postX2Y2SellOrderWithApiKey`
|
const url = `${process.env.REACT_APP_GENIE_API_URL}/postX2Y2SellOrderWithApiKey`
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
} from 'nft/queries/openSea'
|
} from 'nft/queries/openSea'
|
||||||
|
|
||||||
import ERC721 from '../../abis/erc721.json'
|
import ERC721 from '../../abis/erc721.json'
|
||||||
import { createLooksRareOrder, newX2Y2Order, PostOpenSeaSellOrder } from '../queries'
|
import { createLooksRareOrder, LOOKSRARE_MARKETPLACE_CONTRACT, newX2Y2Order, PostOpenSeaSellOrder } from '../queries'
|
||||||
import { INVERSE_BASIS_POINTS, OPENSEA_DEFAULT_FEE, OPENSEA_FEE_ADDRESS } from '../queries/openSea'
|
import { INVERSE_BASIS_POINTS, OPENSEA_DEFAULT_FEE, OPENSEA_FEE_ADDRESS } from '../queries/openSea'
|
||||||
import { ListingMarket, ListingStatus, WalletAsset } from '../types'
|
import { ListingMarket, ListingStatus, WalletAsset } from '../types'
|
||||||
import { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
|
import { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
|
||||||
@ -198,7 +198,7 @@ export async function signListing(
|
|||||||
signer,
|
signer,
|
||||||
SupportedChainId.MAINNET,
|
SupportedChainId.MAINNET,
|
||||||
makerOrder,
|
makerOrder,
|
||||||
process.env.REACT_APP_LOOKSRARE_MARKETPLACE_CONTRACT || ''
|
LOOKSRARE_MARKETPLACE_CONTRACT
|
||||||
)
|
)
|
||||||
setStatus(ListingStatus.PENDING)
|
setStatus(ListingStatus.PENDING)
|
||||||
const payload = {
|
const payload = {
|
||||||
|
Loading…
Reference in New Issue
Block a user