@@ -38,7 +38,7 @@ contract SimpleAllocator is ISimpleAllocator {
38
38
39
39
/// @inheritdoc ISimpleAllocator
40
40
function lock (Compact calldata compact_ ) external {
41
- bytes32 tokenHash = _checkAllocation (compact_);
41
+ bytes32 tokenHash = _checkAllocation (compact_, true );
42
42
43
43
bytes32 digest = keccak256 (
44
44
abi.encodePacked (
@@ -157,12 +157,12 @@ contract SimpleAllocator is ISimpleAllocator {
157
157
return keccak256 (abi.encode (id_, sponsor_));
158
158
}
159
159
160
- function _checkAllocation (Compact memory compact_ ) internal view returns (bytes32 ) {
160
+ function _checkAllocation (Compact memory compact_ , bool checkSponsor_ ) internal view returns (bytes32 ) {
161
161
// Check msg.sender is sponsor
162
- if (msg .sender != compact_.sponsor) {
162
+ if (checkSponsor_ && msg .sender != compact_.sponsor) {
163
163
revert InvalidCaller (msg .sender , compact_.sponsor);
164
164
}
165
- bytes32 tokenHash = _getTokenHash (compact_.id, msg . sender );
165
+ bytes32 tokenHash = _getTokenHash (compact_.id, compact_.sponsor );
166
166
// Check no lock is already active for this sponsor
167
167
if (
168
168
_claim[tokenHash] > block .timestamp
@@ -196,10 +196,10 @@ contract SimpleAllocator is ISimpleAllocator {
196
196
revert NonceAlreadyConsumed (compact_.nonce);
197
197
}
198
198
199
- uint256 balance = ERC6909 (COMPACT_CONTRACT).balanceOf (msg . sender , compact_.id);
199
+ uint256 balance = ERC6909 (COMPACT_CONTRACT).balanceOf (compact_.sponsor , compact_.id);
200
200
// Check balance is enough
201
201
if (balance < compact_.amount) {
202
- revert InsufficientBalance (msg . sender , compact_.id, balance, compact_.amount);
202
+ revert InsufficientBalance (compact_.sponsor , compact_.id, balance, compact_.amount);
203
203
}
204
204
205
205
return tokenHash;
0 commit comments