Skip to content

Commit

Permalink
add nft address check as well
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas committed Mar 25, 2024
1 parent 8865ba3 commit 107e932
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/components/core/utils/validateOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ export async function validateOrderTransaction(
message: errorMsg
}
}
const contractAddress = txReceiptMined.to

console.log('datanftAddress ', dataNftAddress)
console.log('datatokenAddress ', datatokenAddress)

const erc20Address = txReceiptMined.to
const datatokenContract = new Contract(
erc20Address,
ERC20Template.abi,
await provider.getSigner()
)
const erc721Address = await datatokenContract.getERC721Address()
console.log('erc721Address ', erc721Address)
console.log('erc20Address ', erc20Address)
const orderReusedEvent = fetchEventFromTransaction(
txReceiptMined,
EVENTS.ORDER_REUSED,
Expand Down Expand Up @@ -85,7 +95,8 @@ export async function validateOrderTransaction(
if (
(userAddress.toLowerCase() !== event.args[0].toLowerCase() &&
userAddress.toLowerCase() !== event.args[1].toLowerCase()) ||
contractAddress.toLowerCase() !== datatokenAddress.toLowerCase()
erc20Address.toLowerCase() !== datatokenAddress.toLowerCase() ||
erc721Address.toLowerCase() !== dataNftAddress.toLowerCase()
) {
continue
}
Expand All @@ -97,7 +108,7 @@ export async function validateOrderTransaction(
return {
isValid: false,
message:
'Tx id used not valid, Datatoken adreess does not match or User address does not match with consumer or payer of the transaction.'
'Tx id used not valid, one of the NFT addresses, Datatoken address or the User address contract address does not match.'
}
}
const eventServiceIndex = orderEvent.args[3]
Expand Down
2 changes: 1 addition & 1 deletion src/test/integration/transactionValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('validateOrderTransaction Function with Orders', () => {
assert(!validationResult.isValid, 'Reuse order transaction should not be valid.')
assert(
validationResult.message ===
'Tx id used not valid, Datatoken adreess does not match or User address does not match with consumer or payer of the transaction.'
'Tx id used not valid, one of the NFT addresses, Datatoken address or the User address contract address does not match.'
)
})
after(async () => {
Expand Down

0 comments on commit 107e932

Please sign in to comment.