From 42bd87903cfe26dade2a9be6140bfa672078d055 Mon Sep 17 00:00:00 2001 From: vimageDE Date: Mon, 16 Dec 2024 15:31:05 +0100 Subject: [PATCH] Check for nonce consumption during attest --- src/examples/allocator/SimpleAllocator.sol | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/examples/allocator/SimpleAllocator.sol b/src/examples/allocator/SimpleAllocator.sol index 447f6ed..6833194 100644 --- a/src/examples/allocator/SimpleAllocator.sol +++ b/src/examples/allocator/SimpleAllocator.sol @@ -115,7 +115,13 @@ contract SimpleAllocator is ISimpleAllocator { uint256 balance = ERC6909(_COMPACT_CONTRACT).balanceOf(from_, id_); // Check unlocked balance bytes32 tokenHash = _getTokenHash(id_, from_); - if (_claim[tokenHash] > block.timestamp ? (balance < amount_ + _amount[tokenHash]) : (balance < amount_)) { + + uint256 fullAmount = amount_; + if(_claim[tokenHash] > block.timestamp) { + // Lock is still active, add the locked amount if the nonce has not yet been consumed + fullAmount += ITheCompact(_COMPACT_CONTRACT).hasConsumedAllocatorNonce(_nonce[tokenHash], address(this)) ? 0 : _amount[tokenHash]; + } + if( balance < fullAmount) { revert InsufficientBalance(from_, id_); }