From 4961f4df379e2ee1444abf6449b3e8a2c6701521 Mon Sep 17 00:00:00 2001 From: Matheus Alencar Date: Thu, 22 Nov 2018 11:56:46 -0200 Subject: [PATCH] fix(t2cr): check that both lastAction and request length --- .../standard/permission/ArbitrableTokenList.sol | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/contracts/standard/permission/ArbitrableTokenList.sol b/contracts/standard/permission/ArbitrableTokenList.sol index e7686d04..1e7a1c4d 100644 --- a/contracts/standard/permission/ArbitrableTokenList.sol +++ b/contracts/standard/permission/ArbitrableTokenList.sol @@ -204,14 +204,14 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable { */ function fundChallenger(bytes32 _tokenID) external payable { Token storage token = tokens[_tokenID]; - require(token.lastAction + request.timeToChallenge < now, "The time to challenge has already passed."); - require(!request.disputed, "The token is already disputed"); + require(token.lastAction == 0 || token.requests.length == 0, "The specified token does not exist."); require( token.status == TokenStatus.RegistrationRequested || token.status == TokenStatus.ClearingRequested, "Token does not have any pending requests" ); - require(token.requests.length == 0, "The specified token does not exist."); Request storage request = token.requests[token.requests.length - 1]; + require(!request.disputed, "The token is already disputed"); + require(token.lastAction + request.timeToChallenge < now, "The time to challenge has already passed."); require(request.challengeRewardBalance == request.challengeReward, "There isn't a pending request for this token."); require( msg.value >= request.challengeReward + request.requiredFeeStake, @@ -249,7 +249,7 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable { token.status == TokenStatus.RegistrationRequested || token.status == TokenStatus.ClearingRequested, "Token does not have any pending requests" ); - require(token.requests.length == 0, "The specified token does not exist."); + require(token.lastAction == 0 || token.requests.length == 0, "The specified token does not exist."); Request storage request = token.requests[token.requests.length - 1]; require(!request.disputed, "The token is already disputed"); require(request.firstContributionTime + request.arbitrationFeesWaitingTime > now, "Arbitration fees timed out."); @@ -292,7 +292,7 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable { */ function crowdfundDispute(bytes32 _tokenID, Party _party) external payable { Token storage token = tokens[_tokenID]; - require(token.requests.length == 0, "The specified token does not exist."); + require(token.lastAction == 0 || token.requests.length == 0, "The specified token does not exist."); Request storage request = token.requests[token.requests.length - 1]; Round storage round = request.rounds[request.rounds.length - 1]; require( @@ -331,7 +331,7 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable { function fundAppealLosingSide(bytes32 _tokenID) external payable { Token storage token = tokens[_tokenID]; - require(token.requests.length == 0, "The specified token does not exist."); + require(token.lastAction == 0 || token.requests.length == 0, "The specified token does not exist."); Request storage request = token.requests[token.requests.length - 1]; require( arbitrator.disputeStatus(request.disputeID) == Arbitrator.DisputeStatus.Appealable, @@ -369,6 +369,7 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable { */ function executeRequest(bytes32 _tokenID) external { Token storage token = tokens[_tokenID]; + require(token.lastAction == 0 || token.requests.length == 0, "The specified token does not exist."); Request storage request = token.requests[token.requests.length - 1]; require(token.lastAction + timeToChallenge > now, "The time to challenge has not passed yet."); require(!request.disputed, "The specified token is disputed.");