Skip to content

Commit b94b013

Browse files
f: all external ProvisionTracker
1 parent 876709b commit b94b013

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

packages/horizon/contracts/data-service/libraries/ProvisionTracker.sol

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,6 @@ library ProvisionTracker {
2121
*/
2222
error ProvisionTrackerInsufficientTokens(uint256 tokensAvailable, uint256 tokensRequired);
2323

24-
/**
25-
* @notice Checks if a service provider has enough tokens available to lock
26-
* @param self The provision tracker mapping
27-
* @param graphStaking The HorizonStaking contract
28-
* @param serviceProvider The service provider address
29-
* @param delegationRatio A delegation ratio to limit the amount of delegation that's usable
30-
* @return true if the service provider has enough tokens available to lock, false otherwise
31-
*/
32-
function check(
33-
mapping(address => uint256) storage self,
34-
IHorizonStaking graphStaking,
35-
address serviceProvider,
36-
uint32 delegationRatio
37-
) external view returns (bool) {
38-
uint256 tokensAvailable = graphStaking.getTokensAvailable(serviceProvider, address(this), delegationRatio);
39-
return self[serviceProvider] <= tokensAvailable;
40-
}
41-
4224
/**
4325
* @notice Locks tokens for a service provider
4426
* @dev Requirements:
@@ -55,7 +37,7 @@ library ProvisionTracker {
5537
address serviceProvider,
5638
uint256 tokens,
5739
uint32 delegationRatio
58-
) internal {
40+
) external {
5941
if (tokens == 0) return;
6042

6143
uint256 tokensRequired = self[serviceProvider] + tokens;
@@ -72,9 +54,27 @@ library ProvisionTracker {
7254
* @param serviceProvider The service provider address
7355
* @param tokens The amount of tokens to release
7456
*/
75-
function release(mapping(address => uint256) storage self, address serviceProvider, uint256 tokens) internal {
57+
function release(mapping(address => uint256) storage self, address serviceProvider, uint256 tokens) external {
7658
if (tokens == 0) return;
7759
require(self[serviceProvider] >= tokens, ProvisionTrackerInsufficientTokens(self[serviceProvider], tokens));
7860
self[serviceProvider] -= tokens;
7961
}
62+
63+
/**
64+
* @notice Checks if a service provider has enough tokens available to lock
65+
* @param self The provision tracker mapping
66+
* @param graphStaking The HorizonStaking contract
67+
* @param serviceProvider The service provider address
68+
* @param delegationRatio A delegation ratio to limit the amount of delegation that's usable
69+
* @return true if the service provider has enough tokens available to lock, false otherwise
70+
*/
71+
function check(
72+
mapping(address => uint256) storage self,
73+
IHorizonStaking graphStaking,
74+
address serviceProvider,
75+
uint32 delegationRatio
76+
) external view returns (bool) {
77+
uint256 tokensAvailable = graphStaking.getTokensAvailable(serviceProvider, address(this), delegationRatio);
78+
return self[serviceProvider] <= tokensAvailable;
79+
}
8080
}

0 commit comments

Comments
 (0)