Skip to content

Commit

Permalink
Remove old code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vimageDE committed Nov 19, 2024
1 parent 92e95d1 commit 631e770
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/examples/allocator/SimpleAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ contract SimpleAllocator is Ownable2Step, IAllocator {
error InsufficientBalance(address sponsor, uint256 id);
error InvalidExpiration(uint256 expires);
error InvalidLock(bytes32 digest, uint256 expiration);
// error InvalidSignature(bytes32 expectedHash, bytes32 actualHash);
// error InvalidSigner(address signer, address sponsor);

event Locked(address sponsor, uint256 id, uint256 amount, uint256 expires);

Expand All @@ -55,10 +53,7 @@ contract SimpleAllocator is Ownable2Step, IAllocator {
_MAX_WITHDRAWAL_DELAY = maxWithdrawalDelay_;
}

/// TODO: locking for a specific COMPACT struct, and not allowing multiple allocations at the same time per sponsor. Check the compact if the nonce was consumed for replay attack.
/// Locking will always lock ALL of your tokens (for a specific id)

/// @dev locks tokens for a sponsor and an id, updates previous expiration if needed.
/// @dev locks all tokens of a sponsor for an id
function lock(Compact calldata compact_) external {
// Check msg.sender is sponsor
if (msg.sender != compact_.sponsor) {
Expand Down Expand Up @@ -136,9 +131,8 @@ contract SimpleAllocator is Ownable2Step, IAllocator {
return 0x1a808f91;
}

/// @dev we trust the compact contract to check the nonce is not already consumed
function isValidSignature(bytes32 hash, bytes calldata) external view returns (bytes4 magicValue) {
// TODO: Do we trust the compact contract to check the nonce is not already consumed (replay attack)?

bytes32 tokenHash = _sponsor[hash];
if (tokenHash == bytes32(0) || _claim[tokenHash] <= block.timestamp) {
revert InvalidLock(hash, _claim[tokenHash]);
Expand All @@ -158,6 +152,7 @@ contract SimpleAllocator is Ownable2Step, IAllocator {
}

function checkCompactLocked(Compact calldata compact_) external view returns (bool locked_, uint256 expires_) {
// TODO: Check the force unlock time in the compact contract and adapt expires_ if needed
if (compact_.arbiter != _ARBITER) {
revert InvalidArbiter(compact_.arbiter);
}
Expand Down

0 comments on commit 631e770

Please sign in to comment.