Skip to content

Commit a2fb41b

Browse files
committed
enable relayed locks in child contracts
1 parent 32dafd3 commit a2fb41b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/allocators/SimpleAllocator.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ contract SimpleAllocator is ISimpleAllocator {
3838

3939
/// @inheritdoc ISimpleAllocator
4040
function lock(Compact calldata compact_) external {
41-
bytes32 tokenHash = _checkAllocation(compact_);
41+
bytes32 tokenHash = _checkAllocation(compact_, true);
4242

4343
bytes32 digest = keccak256(
4444
abi.encodePacked(
@@ -157,12 +157,12 @@ contract SimpleAllocator is ISimpleAllocator {
157157
return keccak256(abi.encode(id_, sponsor_));
158158
}
159159

160-
function _checkAllocation(Compact memory compact_) internal view returns (bytes32) {
160+
function _checkAllocation(Compact memory compact_, bool checkSponsor_) internal view returns (bytes32) {
161161
// Check msg.sender is sponsor
162-
if (msg.sender != compact_.sponsor) {
162+
if (checkSponsor_ && msg.sender != compact_.sponsor) {
163163
revert InvalidCaller(msg.sender, compact_.sponsor);
164164
}
165-
bytes32 tokenHash = _getTokenHash(compact_.id, msg.sender);
165+
bytes32 tokenHash = _getTokenHash(compact_.id, compact_.sponsor);
166166
// Check no lock is already active for this sponsor
167167
if (
168168
_claim[tokenHash] > block.timestamp
@@ -196,10 +196,10 @@ contract SimpleAllocator is ISimpleAllocator {
196196
revert NonceAlreadyConsumed(compact_.nonce);
197197
}
198198

199-
uint256 balance = ERC6909(COMPACT_CONTRACT).balanceOf(msg.sender, compact_.id);
199+
uint256 balance = ERC6909(COMPACT_CONTRACT).balanceOf(compact_.sponsor, compact_.id);
200200
// Check balance is enough
201201
if (balance < compact_.amount) {
202-
revert InsufficientBalance(msg.sender, compact_.id, balance, compact_.amount);
202+
revert InsufficientBalance(compact_.sponsor, compact_.id, balance, compact_.amount);
203203
}
204204

205205
return tokenHash;

0 commit comments

Comments
 (0)