Skip to content

Commit

Permalink
fix: Check one by one
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Dec 23, 2024
1 parent 0b21e77 commit bc1ee95
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/ports/trades/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,18 @@ export async function isValidEstateTrade(trade: TradeCreation): Promise<boolean>
}

const assets = [...trade.sent, ...trade.received]
const areEstatesFingerprintsValid = await Promise.all(
assets.map(async asset => {
// Only check if the asset is an estate
if (asset.contractAddress.toLowerCase() === estateContract.address.toLowerCase()) {
return (
!isBytesEmpty(asset.extra) &&
(await isEstateFingerprintValid(estateContract.address, (asset as ERC721TradeAsset)?.tokenId, trade.chainId, asset.extra))
)
}
return true
})
)
// Checks trades one by one to prevent unnecessary checks. This should be changed when implementing bundles or the cart system.
for (const asset of assets) {
// Only check if the asset is an estate
if (asset.contractAddress.toLowerCase() === estateContract.address.toLowerCase()) {
return (
!isBytesEmpty(asset.extra) &&
(await isEstateFingerprintValid(estateContract.address, (asset as ERC721TradeAsset)?.tokenId, trade.chainId, asset.extra))
)
}
}

return areEstatesFingerprintsValid.every(Boolean)
return true
}

export async function validateTradeByType(trade: TradeCreation, client: IPgComponent): Promise<boolean> {
Expand Down

0 comments on commit bc1ee95

Please sign in to comment.