Skip to content

Commit

Permalink
Merge pull request #66 from hats-finance/fix-37
Browse files Browse the repository at this point in the history
Fix #37
  • Loading branch information
jellegerbrandy authored Dec 4, 2023
2 parents 97c531d + 16edc28 commit fc0c464
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/HATArbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contract HATArbitrator is IHATArbitrator, Ownable {
public disputersBonds; // bonds provided by disputers
mapping(address => mapping(IHATClaimsManager => mapping(bytes32 => bool)))
public bondClaimable; // whether a given bond is reclaimable by the disputer
mapping(IHATClaimsManager => mapping(bytes32 => bool)) public claimDisputesDismissed; // claims of which disputes were dismissed
mapping(IHATClaimsManager => mapping(bytes32 => uint256)) public totalBondsOnClaim; // total amount of bonds ona given claim
mapping(IHATClaimsManager => mapping(bytes32 => Resolution)) public resolutions; // resolutions of disputes by the expert committee
mapping(IHATClaimsManager => mapping(bytes32 => uint256))
Expand Down Expand Up @@ -160,6 +161,7 @@ contract HATArbitrator is IHATArbitrator, Ownable {
onlyChallengedActiveClaim(_vault, _claimId)
onlyUnresolvedDispute(_vault, _claimId)
{
claimDisputesDismissed[_vault][_claimId] = true;
resolutions[_vault][_claimId].resolvedAt = block.timestamp;
token.safeTransfer(msg.sender, totalBondsOnClaim[_vault][_claimId]);

Expand Down Expand Up @@ -267,10 +269,14 @@ contract HATArbitrator is IHATArbitrator, Ownable {
/** @notice See {IHATArbitrator-reclaimBond}. */
function reclaimBond(IHATClaimsManager _vault, bytes32 _claimId) external {
if (!bondClaimable[msg.sender][_vault][_claimId]) {
// the bond is claimable if either
// the bond is claimable if the claim wasn't dismissed and either
// (a) it is not related to the current active claim
// (b) it is about the current active claim but the claim has already expired

if (claimDisputesDismissed[_vault][_claimId]) {
revert ClaimDisputesDismissed();
}

IHATClaimsManager.Claim memory claim = _vault.getActiveClaim();

if (
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IHATArbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface IHATArbitrator {
error AlreadyChallenged();
error CourtCannotBeZero();
error CannontChangeCourtAddress();
error ClaimDisputesDismissed();

struct Resolution {
address beneficiary;
Expand Down
34 changes: 34 additions & 0 deletions docs/dodoc/HATArbitrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ See {IHATArbitrator-challengeResolution}.
| _claimId | bytes32 | undefined |
| _evidence | string | undefined |

### claimDisputesDismissed

```solidity
function claimDisputesDismissed(contract IHATClaimsManager, bytes32) external view returns (bool)
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | contract IHATClaimsManager | undefined |
| _1 | bytes32 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bool | undefined |

### confiscateDisputers

```solidity
Expand Down Expand Up @@ -951,6 +974,17 @@ error ChallengePeriodPassed()



### ClaimDisputesDismissed

```solidity
error ClaimDisputesDismissed()
```






### ClaimExpired

```solidity
Expand Down
11 changes: 11 additions & 0 deletions docs/dodoc/interfaces/IHATArbitrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,17 @@ error ChallengePeriodPassed()



### ClaimDisputesDismissed

```solidity
error ClaimDisputesDismissed()
```






### ClaimExpired

```solidity
Expand Down
5 changes: 5 additions & 0 deletions test/hatarbitrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ contract("Registry Arbitrator", (accounts) => {
assert.equal(logs[0].args._claimId, claimId);
assert.equal(logs[0].args._approver, hatArbitrator.address);

await assertFunctionRaisesException(
hatArbitrator.reclaimBond(claimsManager.address, claimId, { from: accounts[0] }),
"ClaimDisputesDismissed"
);

claimId = await submitClaim(claimsManager, { accounts });
await token.mint(accounts[0], web3.utils.toWei("1000"));
await token.approve(hatArbitrator.address, web3.utils.toWei("1000"), { from: accounts[0] });
Expand Down

0 comments on commit fc0c464

Please sign in to comment.