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:
Charles Bachmeier 2022-10-12 15:24:55 -07:00 committed by GitHub
parent ec686bcaa5
commit 9856c03566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 52 deletions

@ -55,7 +55,7 @@ export const ListingButton = ({ onClick, buttonText, showWarningOverride = false
(asset: WalletAsset) => asset.marketplaces === undefined || asset.marketplaces.length === 0
)
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) => {
return asset.expirationTime != null && isNaN(asset.expirationTime)

@ -1,12 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'
import type { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
import { ConsiderationInputItem } from '@opensea/seaport-js/lib/types'
import {
INVERSE_BASIS_POINTS,
OPENSEA_CROSS_CHAIN_CONDUIT,
OPENSEA_DEFAULT_FEE,
OPENSEA_FEE_ADDRESS,
} from 'nft/queries/openSea'
import { LOOKSRARE_MARKETPLACE_CONTRACT, X2Y2_TRANSFER_CONTRACT } from 'nft/queries'
import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
import { AssetRow, CollectionRow, ListingMarket, ListingRow, ListingStatus, WalletAsset } from 'nft/types'
import { approveCollection, signListing } from 'nft/utils/listNfts'
import { Dispatch } from 'react'
@ -60,9 +54,9 @@ export async function approveCollectionRow(
marketplace.name === 'OpenSea'
? OPENSEA_CROSS_CHAIN_CONDUIT
: marketplace.name === 'Rarible'
? process.env.REACT_APP_LOOKSRARE_MARKETPLACE_CONTRACT
? LOOKSRARE_MARKETPLACE_CONTRACT
: marketplace.name === 'X2Y2'
? process.env.REACT_APP_X2Y2_TRANSFER_CONTRACT
? X2Y2_TRANSFER_CONTRACT
: looksRareAddress
await approveCollection(spender ?? '', collectionAddress, signer, (newStatus: ListingStatus) =>
updateStatus({
@ -266,38 +260,3 @@ export const resetRow = (row: AssetRow, rows: AssetRow[], setRows: Dispatch<Asse
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 durationFactor =
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 {

@ -24,7 +24,7 @@ export const fetchWalletAssets = async ({
? collectionAddresses.reduce((str, collectionAddress) => str + `&assetContractAddresses=${collectionAddress}`, '')
: ''
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}`
const r = await fetch(url, {
@ -38,7 +38,7 @@ export const fetchWalletAssets = async ({
return {
...asset,
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,
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,

@ -0,0 +1 @@
export const LOOKSRARE_MARKETPLACE_CONTRACT = '0x59728544B08AB483533076417FbBB2fD0B17CE3a'

@ -1,3 +1,4 @@
export * from './constants'
export * from './createLooksRareOrder'
export * from './looksRareNonceFetcher'
export * from './looksRareRewardsFetcher'

@ -11,6 +11,7 @@ export async function PostOpenSeaSellOrder<T>(
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-API-KEY': process.env.REACT_APP_OPENSEA_API_KEY ?? '',
},
...opts,
}

@ -1,5 +1,5 @@
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_LISTINGS_API_PATH = '/v2/orders/ethereum/seaport/listings'
export const OPENSEA_DEFAULT_CROSS_CHAIN_CONDUIT_KEY =

@ -1,5 +1,7 @@
import { OrderPayload } from '../../utils/x2y2'
export const X2Y2_TRANSFER_CONTRACT = '0xf849de01b080adc3a814fabe1e2087475cf2e354'
export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => {
const body = JSON.stringify(payload)
const url = `${process.env.REACT_APP_GENIE_API_URL}/postX2Y2SellOrderWithApiKey`

@ -15,7 +15,7 @@ import {
} from 'nft/queries/openSea'
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 { ListingMarket, ListingStatus, WalletAsset } from '../types'
import { createSellOrder, encodeOrder, OfferItem, OrderPayload, signOrderData } from './x2y2'
@ -198,7 +198,7 @@ export async function signListing(
signer,
SupportedChainId.MAINNET,
makerOrder,
process.env.REACT_APP_LOOKSRARE_MARKETPLACE_CONTRACT || ''
LOOKSRARE_MARKETPLACE_CONTRACT
)
setStatus(ListingStatus.PENDING)
const payload = {