diff --git a/webapp/src/components/Modals/SellModal/SellModal.container.ts b/webapp/src/components/Modals/SellModal/SellModal.container.ts index 7fe59e9061..10e971e768 100644 --- a/webapp/src/components/Modals/SellModal/SellModal.container.ts +++ b/webapp/src/components/Modals/SellModal/SellModal.container.ts @@ -33,7 +33,7 @@ const mapState = (state: RootState): MapStateProps => { } const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ - onCreateOrder: (nft, price, expiresAt) => dispatch(createOrderRequest(nft, price, expiresAt)), + onCreateOrder: (nft, price, expiresAt, fingerprint) => dispatch(createOrderRequest(nft, price, expiresAt, fingerprint)), onFetchAuthorizations: (authorizations: Authorization[]) => dispatch(fetchAuthorizationsRequest(authorizations)), onUpsertContracts: (contracts: Contract[]) => dispatch(upsertContracts(contracts)), onCancelOrder: (order, nft, skipRedirection = false) => dispatch(cancelOrderRequest(order, nft, skipRedirection)) diff --git a/webapp/src/components/Modals/SellModal/SellModal.tsx b/webapp/src/components/Modals/SellModal/SellModal.tsx index c5091f3537..e58e64c4e7 100644 --- a/webapp/src/components/Modals/SellModal/SellModal.tsx +++ b/webapp/src/components/Modals/SellModal/SellModal.tsx @@ -15,6 +15,7 @@ import { Button, Field, Loader, Mana, Message, ModalNavigation } from 'decentral import { useAuthorization } from '../../../lib/authorization' import { formatWeiMANA, parseMANANumber } from '../../../lib/mana' import { getAssetName, isOwnedBy } from '../../../modules/asset/utils' +import { useFingerprint } from '../../../modules/nft/hooks' import { getDefaultExpirationDate, INPUT_FORMAT } from '../../../modules/order/utils' import { locations } from '../../../modules/routing/locations' import { getContractNames, VendorFactory } from '../../../modules/vendor' @@ -104,6 +105,7 @@ const SellModal = ({ } const [isLoadingAuthorizations, isAuthorized] = useAuthorization(authorization, onFetchAuthorizations) + const [fingerprint] = useFingerprint(nft) if (!wallet) { return null @@ -125,7 +127,7 @@ const SellModal = ({ } } - const handleCreateOrder = () => onCreateOrder(nft, parseMANANumber(price), new Date(`${expiresAt} 00:00:00`).getTime()) + const handleCreateOrder = () => onCreateOrder(nft, parseMANANumber(price), new Date(`${expiresAt} 00:00:00`).getTime(), fingerprint) const isInvalidDate = new Date(`${expiresAt} 00:00:00`).getTime() < Date.now() const isInvalidPrice = parseMANANumber(price) <= 0 || parseFloat(price) !== parseMANANumber(price) diff --git a/webapp/src/components/SellPage/SellModal/SellModal.tsx b/webapp/src/components/SellPage/SellModal/SellModal.tsx index 1887863100..ad7002f816 100644 --- a/webapp/src/components/SellPage/SellModal/SellModal.tsx +++ b/webapp/src/components/SellPage/SellModal/SellModal.tsx @@ -16,6 +16,7 @@ import ERC721ABI from '../../../contracts/ERC721.json' import { parseMANANumber } from '../../../lib/mana' import { getAssetName, isOwnedBy } from '../../../modules/asset/utils' import { isStubMaticCollectionContract } from '../../../modules/contract/utils' +import { useFingerprint } from '../../../modules/nft/hooks' import { getSellItemStatus, getError } from '../../../modules/order/selectors' import { INPUT_FORMAT, getDefaultExpirationDate } from '../../../modules/order/utils' import { getContractNames } from '../../../modules/vendor' @@ -49,6 +50,7 @@ const SellModal = (props: Props) => { const isUpdate = order !== null const shouldRemoveListing = order?.tradeId const [price, setPrice] = useState(isUpdate ? ethers.utils.formatEther(order.price) : '') + const [fingerprint] = useFingerprint(nft) const [expiresAt, setExpiresAt] = useState(() => { let exp = order?.expiresAt @@ -113,7 +115,7 @@ const SellModal = (props: Props) => { ? getDecentralandContract(ContractName.OffChainMarketplace, nft.chainId) : null - const handleCreateOrder = () => onCreateOrder(nft, parseMANANumber(price), new Date(`${expiresAt} 00:00:00`).getTime()) + const handleCreateOrder = () => onCreateOrder(nft, parseMANANumber(price), new Date(`${expiresAt} 00:00:00`).getTime(), fingerprint) const handleCancelTrade = () => order && onCancelOrder(order, nft) diff --git a/webapp/src/components/SellPage/SellPage.container.ts b/webapp/src/components/SellPage/SellPage.container.ts index c9ac057eda..1a9b0ccaba 100644 --- a/webapp/src/components/SellPage/SellPage.container.ts +++ b/webapp/src/components/SellPage/SellPage.container.ts @@ -28,7 +28,7 @@ const mapState = (state: RootState): MapStateProps => ({ }) const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ - onCreateOrder: (nft, price, expiresAt) => dispatch(createOrderRequest(nft, price, expiresAt)), + onCreateOrder: (nft, price, expiresAt, fingerprint) => dispatch(createOrderRequest(nft, price, expiresAt, fingerprint)), onClearOrderErrors: () => dispatch(clearOrderErrors()), onCancelOrder: (order: Order, nft: NFT) => dispatch(cancelOrderRequest(order, nft, true)) }) diff --git a/webapp/src/modules/order/actions.ts b/webapp/src/modules/order/actions.ts index 383fe00d1e..34bc9d78f1 100644 --- a/webapp/src/modules/order/actions.ts +++ b/webapp/src/modules/order/actions.ts @@ -18,7 +18,8 @@ export const CREATE_ORDER_REQUEST = '[Request] Create Order' export const CREATE_ORDER_SUCCESS = '[Success] Create Order' export const CREATE_ORDER_FAILURE = '[Failure] Create Order' -export const createOrderRequest = (nft: NFT, price: number, expiresAt: number) => action(CREATE_ORDER_REQUEST, { nft, price, expiresAt }) +export const createOrderRequest = (nft: NFT, price: number, expiresAt: number, fingerprint?: string) => + action(CREATE_ORDER_REQUEST, { nft, price, expiresAt, fingerprint }) export const createOrderSuccess = (nft: NFT, price: number, expiresAt: number, txHash?: string) => action(CREATE_ORDER_SUCCESS, { nft, diff --git a/webapp/src/modules/order/sagas.ts b/webapp/src/modules/order/sagas.ts index 0b90751aee..f9bc16e9ce 100644 --- a/webapp/src/modules/order/sagas.ts +++ b/webapp/src/modules/order/sagas.ts @@ -88,12 +88,12 @@ export function* orderSaga(tradeService: TradeService) { } function* handleCreateOrderRequest(action: CreateOrderRequestAction) { - const { nft, price, expiresAt } = action.payload + const { nft, price, expiresAt, fingerprint } = action.payload try { const isOffchainPublicNFTOrdersEnabled: boolean = yield select(getIsOffchainPublicNFTOrdersEnabled) if (isOffchainPublicNFTOrdersEnabled) { const history: History = yield getContext('history') - const trade: TradeCreation = yield call([orderUtils, 'createPublicNFTOrderTrade'], nft, price, expiresAt) + const trade: TradeCreation = yield call([orderUtils, 'createPublicNFTOrderTrade'], nft, price, expiresAt, fingerprint) yield call([tradeService, 'addTrade'], trade) yield put(createOrderSuccess(nft, price, expiresAt)) yield put(fetchNFTRequest(nft.contractAddress, nft.tokenId)) // fetch the NFT again to get the new order with the tradeId diff --git a/webapp/src/modules/order/utils.ts b/webapp/src/modules/order/utils.ts index 0d85974a43..aa9254dac6 100644 --- a/webapp/src/modules/order/utils.ts +++ b/webapp/src/modules/order/utils.ts @@ -78,7 +78,7 @@ export function getSubgraphOrdersQuery(filters: OrderFilters) { }` } -export async function createPublicNFTOrderTrade(nft: NFT, price: number, expiresAt: number) { +export async function createPublicNFTOrderTrade(nft: NFT, price: number, expiresAt: number, fingerprint?: string) { const signer = await getSigner() const address = await signer.getAddress() const marketplaceContract = await getOffChainMarketplaceContract(nft.chainId) @@ -106,7 +106,7 @@ export async function createPublicNFTOrderTrade(nft: NFT, price: number, expires assetType: TradeAssetType.ERC721, contractAddress: nft.contractAddress, tokenId: nft.tokenId, - extra: '' + extra: fingerprint || '' } ], received: [