Skip to content

Commit d7484ed

Browse files
committed
fix: remove redundant _get function.
1 parent 6313161 commit d7484ed

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

packages/subgraph-service/contracts/libraries/Allocation.sol

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ library Allocation {
9797
* @param allocationId The allocation id
9898
*/
9999
function presentPOI(mapping(address => State) storage self, address allocationId) internal {
100-
State storage allocation = _get(self, allocationId);
100+
State storage allocation = get(self, allocationId);
101101
require(allocation.isOpen(), AllocationClosed(allocationId, allocation.closedAt));
102102
allocation.lastPOIPresentedAt = block.timestamp;
103103
}
@@ -115,7 +115,7 @@ library Allocation {
115115
address allocationId,
116116
uint256 accRewardsPerAllocatedToken
117117
) internal {
118-
State storage allocation = _get(self, allocationId);
118+
State storage allocation = get(self, allocationId);
119119
require(allocation.isOpen(), AllocationClosed(allocationId, allocation.closedAt));
120120
allocation.accRewardsPerAllocatedToken = accRewardsPerAllocatedToken;
121121
}
@@ -128,7 +128,7 @@ library Allocation {
128128
* @param allocationId The allocation id
129129
*/
130130
function clearPendingRewards(mapping(address => State) storage self, address allocationId) internal {
131-
State storage allocation = _get(self, allocationId);
131+
State storage allocation = get(self, allocationId);
132132
require(allocation.isOpen(), AllocationClosed(allocationId, allocation.closedAt));
133133
allocation.accRewardsPending = 0;
134134
}
@@ -141,7 +141,7 @@ library Allocation {
141141
* @param allocationId The allocation id
142142
*/
143143
function close(mapping(address => State) storage self, address allocationId) internal {
144-
State storage allocation = _get(self, allocationId);
144+
State storage allocation = get(self, allocationId);
145145
require(allocation.isOpen(), AllocationClosed(allocationId, allocation.closedAt));
146146
allocation.closedAt = block.timestamp;
147147
}
@@ -152,7 +152,9 @@ library Allocation {
152152
* @param allocationId The allocation id
153153
*/
154154
function get(mapping(address => State) storage self, address allocationId) internal view returns (State memory) {
155-
return _get(self, allocationId);
155+
State storage allocation = self[allocationId];
156+
require(allocation.exists(), AllocationDoesNotExist(allocationId));
157+
return allocation;
156158
}
157159

158160
/**
@@ -189,15 +191,4 @@ library Allocation {
189191
return self.exists() && self.tokens == 0;
190192
}
191193

192-
/**
193-
* @notice Get the allocation for an allocation id
194-
* @dev Reverts if the allocation does not exist
195-
* @param self The allocation list mapping
196-
* @param allocationId The allocation id
197-
*/
198-
function _get(mapping(address => State) storage self, address allocationId) private view returns (State storage) {
199-
State storage allocation = self[allocationId];
200-
require(allocation.exists(), AllocationDoesNotExist(allocationId));
201-
return allocation;
202-
}
203194
}

packages/subgraph-service/contracts/libraries/LegacyAllocation.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ library LegacyAllocation {
6464
* @param allocationId The allocation id
6565
*/
6666
function get(mapping(address => State) storage self, address allocationId) internal view returns (State memory) {
67-
return _get(self, allocationId);
67+
return get(self, allocationId);
6868
}
6969

7070
/**
@@ -89,7 +89,7 @@ library LegacyAllocation {
8989
* @param self The legacy allocation list mapping
9090
* @param allocationId The allocation id
9191
*/
92-
function _get(mapping(address => State) storage self, address allocationId) private view returns (State storage) {
92+
function get(mapping(address => State) storage self, address allocationId) private view returns (State storage) {
9393
State storage allocation = self[allocationId];
9494
require(allocation.exists(), LegacyAllocationDoesNotExist(allocationId));
9595
return allocation;

0 commit comments

Comments
 (0)