tokamak-network/crossTrade

Provider condition is checked twice in `claimCT` and `cancelCT`

parth-15 opened this issue · 3 comments

Describe the bug
The function claimCT and cancelCT uses modifier providerCheck to ensure that the order is not yet fulfilled. However, in the implementation, same condition is checked again which can result in loss of gas for users.

providerCheck modifier

modifier providerCheck(uint256 _saleCount) {
require(dealData[_saleCount].provider == address(0), "already sold");
_;
}

claimCT function

function claimCT(
address _from,
uint256 _amount,
uint256 _saleCount,
uint256 _chainId,
bytes32 _hash,
bool _edit
)
external
payable
nonReentrant
checkL1(_chainId)
providerCheck(_saleCount)
{
require(dealData[_saleCount].hashValue == _hash, "Hash values do not match");
require(dealData[_saleCount].provider == address(0), "already sold");

cancelCT function

function cancelCT(
address _msgSender,
uint256 _salecount,
uint256 _chainId
)
external
payable
nonReentrant
checkL1(_chainId)
providerCheck(_salecount)
{
require(dealData[_salecount].requester == _msgSender, "your not seller");
require(dealData[_salecount].provider == address(0), "already cancel");

oh thank you
but Someone else left an issue first. #42

oops. sorry for that. should I close this issue?

I'll �close it.