@@ -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 (
@@ -67,18 +67,10 @@ contract SimpleAllocator is ISimpleAllocator {
67
67
}
68
68
69
69
/// @inheritdoc IAllocator
70
- function attest (address operator_ , address from_ , address , uint256 id_ , uint256 amount_ )
71
- external
72
- view
73
- returns (bytes4 )
74
- {
70
+ function attest (address , address from_ , address , uint256 id_ , uint256 amount_ ) external view returns (bytes4 ) {
75
71
if (msg .sender != COMPACT_CONTRACT) {
76
72
revert InvalidCaller (msg .sender , COMPACT_CONTRACT);
77
73
}
78
- // For a transfer, the sponsor is the arbiter
79
- if (operator_ != from_) {
80
- revert InvalidCaller (operator_, from_);
81
- }
82
74
uint256 balance = ERC6909 (COMPACT_CONTRACT).balanceOf (from_, id_);
83
75
// Check unlocked balance
84
76
bytes32 tokenHash = _getTokenHash (id_, from_);
@@ -94,7 +86,7 @@ contract SimpleAllocator is ISimpleAllocator {
94
86
revert InsufficientBalance (from_, id_, balance, fullAmount);
95
87
}
96
88
97
- return 0x1a808f91 ;
89
+ return this .attest. selector ;
98
90
}
99
91
100
92
/// @inheritdoc IERC1271
@@ -165,12 +157,12 @@ contract SimpleAllocator is ISimpleAllocator {
165
157
return keccak256 (abi.encode (id_, sponsor_));
166
158
}
167
159
168
- function _checkAllocation (Compact memory compact_ ) internal view returns (bytes32 ) {
160
+ function _checkAllocation (Compact memory compact_ , bool checkSponsor_ ) internal view returns (bytes32 ) {
169
161
// Check msg.sender is sponsor
170
- if (msg .sender != compact_.sponsor) {
162
+ if (checkSponsor_ && msg .sender != compact_.sponsor) {
171
163
revert InvalidCaller (msg .sender , compact_.sponsor);
172
164
}
173
- bytes32 tokenHash = _getTokenHash (compact_.id, msg . sender );
165
+ bytes32 tokenHash = _getTokenHash (compact_.id, compact_.sponsor );
174
166
// Check no lock is already active for this sponsor
175
167
if (
176
168
_claim[tokenHash] > block .timestamp
@@ -204,10 +196,10 @@ contract SimpleAllocator is ISimpleAllocator {
204
196
revert NonceAlreadyConsumed (compact_.nonce);
205
197
}
206
198
207
- uint256 balance = ERC6909 (COMPACT_CONTRACT).balanceOf (msg . sender , compact_.id);
199
+ uint256 balance = ERC6909 (COMPACT_CONTRACT).balanceOf (compact_.sponsor , compact_.id);
208
200
// Check balance is enough
209
201
if (balance < compact_.amount) {
210
- revert InsufficientBalance (msg . sender , compact_.id, balance, compact_.amount);
202
+ revert InsufficientBalance (compact_.sponsor , compact_.id, balance, compact_.amount);
211
203
}
212
204
213
205
return tokenHash;
0 commit comments