Skip to content

Commit b5fc680

Browse files
committed
fix: update contracts to allow compilation from horizon package
Signed-off-by: Tomás Migone <[email protected]>
1 parent c0e83cf commit b5fc680

File tree

132 files changed

+275
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+275
-220
lines changed

packages/contracts/contracts/base/IMulticall.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity ^0.7.6 || 0.8.27;
44
pragma abicoder v2;
55

66
/**

packages/contracts/contracts/discovery/IServiceRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity ^0.7.6 || 0.8.27;
44

55
interface IServiceRegistry {
66
struct IndexerService {

packages/contracts/contracts/disputes/IDisputeManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity >=0.6.12 <0.8.0 || 0.8.27;
44
pragma abicoder v2;
55

66
interface IDisputeManager {

packages/contracts/contracts/l2/curation/IL2Curation.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity ^0.7.6 || 0.8.27;
44

55
/**
66
* @title Interface of the L2 Curation contract.

packages/contracts/contracts/l2/discovery/IL2GNS.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity ^0.7.6;
3+
pragma solidity ^0.7.6 || 0.8.27;
44

55
import { ICallhookReceiver } from "../../gateway/ICallhookReceiver.sol";
66

packages/contracts/contracts/l2/staking/L2Staking.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Staking } from "../../staking/Staking.sol";
88
import { IL2StakingBase } from "./IL2StakingBase.sol";
99
import { IL2Staking } from "./IL2Staking.sol";
1010
import { Stakes } from "../../staking/libs/Stakes.sol";
11+
import { IStakes } from "../../staking/libs/IStakes.sol";
1112
import { IL2StakingTypes } from "./IL2StakingTypes.sol";
1213

1314
/**
@@ -18,7 +19,7 @@ import { IL2StakingTypes } from "./IL2StakingTypes.sol";
1819
*/
1920
contract L2Staking is Staking, IL2StakingBase {
2021
using SafeMath for uint256;
21-
using Stakes for Stakes.Indexer;
22+
using Stakes for IStakes.Indexer;
2223

2324
/// @dev Minimum amount of tokens that can be delegated
2425
uint256 private constant MINIMUM_DELEGATION = 1e18;

packages/contracts/contracts/staking/IStaking.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity >=0.6.12 <0.8.0;
3+
pragma solidity >=0.6.12 <0.8.0 || 0.8.27;
44
pragma abicoder v2;
55

66
import { IStakingBase } from "./IStakingBase.sol";

packages/contracts/contracts/staking/IStakingBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity >=0.6.12 <0.8.0;
3+
pragma solidity >=0.6.12 <0.8.0 || 0.8.27;
44
pragma abicoder v2;
55

66
import { IStakingData } from "./IStakingData.sol";

packages/contracts/contracts/staking/IStakingData.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity >=0.6.12 <0.8.0;
3+
pragma solidity >=0.6.12 <0.8.0 || 0.8.27;
44

55
/**
66
* @title Staking Data interface

packages/contracts/contracts/staking/IStakingExtension.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3-
pragma solidity >=0.6.12 <0.8.0;
3+
pragma solidity >=0.6.12 <0.8.0 || 0.8.27;
44
pragma abicoder v2;
55

66
import { IStakingData } from "./IStakingData.sol";
7-
import { Stakes } from "./libs/Stakes.sol";
7+
import { IStakes } from "./libs/IStakes.sol";
88

99
/**
1010
* @title Interface for the StakingExtension contract
@@ -276,11 +276,11 @@ interface IStakingExtension is IStakingData {
276276

277277
/**
278278
* @notice Getter for stakes[_indexer]:
279-
* gets the stake information for an indexer as a Stakes.Indexer struct.
279+
* gets the stake information for an indexer as a IStakes.Indexer struct.
280280
* @param _indexer Indexer address for which to query the stake information
281-
* @return Stake information for the specified indexer, as a Stakes.Indexer struct
281+
* @return Stake information for the specified indexer, as a IStakes.Indexer struct
282282
*/
283-
function stakes(address _indexer) external view returns (Stakes.Indexer memory);
283+
function stakes(address _indexer) external view returns (IStakes.Indexer memory);
284284

285285
/**
286286
* @notice Getter for allocations[_allocationID]:

packages/contracts/contracts/staking/L1Staking.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
88
import { ITokenGateway } from "../arbitrum/ITokenGateway.sol";
99
import { Staking } from "./Staking.sol";
1010
import { Stakes } from "./libs/Stakes.sol";
11+
import { IStakes } from "./libs/IStakes.sol";
1112
import { IStakingData } from "./IStakingData.sol";
1213
import { L1StakingV1Storage } from "./L1StakingStorage.sol";
1314
import { IGraphToken } from "../token/IGraphToken.sol";
@@ -22,7 +23,7 @@ import { IL2StakingTypes } from "../l2/staking/IL2StakingTypes.sol";
2223
* to send an indexer's stake to L2, and to send delegation to L2 as well.
2324
*/
2425
contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase {
25-
using Stakes for Stakes.Indexer;
26+
using Stakes for IStakes.Indexer;
2627
using SafeMath for uint256;
2728

2829
/**
@@ -231,7 +232,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase {
231232
uint256 _maxSubmissionCost,
232233
uint256 _ethAmount
233234
) internal {
234-
Stakes.Indexer storage indexerStake = __stakes[_indexer];
235+
IStakes.Indexer storage indexerStake = __stakes[_indexer];
235236
require(indexerStake.tokensStaked != 0, "tokensStaked == 0");
236237
// Indexers shouldn't be trying to withdraw tokens before transferring to L2.
237238
// Allowing this would complicate our accounting so we require that they have no

packages/contracts/contracts/staking/Staking.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IStakingBase } from "./IStakingBase.sol";
1414
import { StakingV4Storage } from "./StakingStorage.sol";
1515
import { MathUtils } from "./libs/MathUtils.sol";
1616
import { Stakes } from "./libs/Stakes.sol";
17+
import { IStakes } from "./libs/IStakes.sol";
1718
import { Managed } from "../governance/Managed.sol";
1819
import { ICuration } from "../curation/ICuration.sol";
1920
import { IRewardsManager } from "../rewards/IRewardsManager.sol";
@@ -32,7 +33,7 @@ import { LibExponential } from "./libs/Exponential.sol";
3233
*/
3334
abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, Multicall {
3435
using SafeMath for uint256;
35-
using Stakes for Stakes.Indexer;
36+
using Stakes for IStakes.Indexer;
3637

3738
/// @dev 100% in parts per million
3839
uint32 internal constant MAX_PPM = 1000000;
@@ -245,7 +246,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
245246
*/
246247
function unstake(uint256 _tokens) external override notPartialPaused {
247248
address indexer = msg.sender;
248-
Stakes.Indexer storage indexerStake = __stakes[indexer];
249+
IStakes.Indexer storage indexerStake = __stakes[indexer];
249250

250251
require(indexerStake.tokensStaked > 0, "!stake");
251252

@@ -565,7 +566,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
565566
* @return Amount of tokens available to allocate including delegation
566567
*/
567568
function getIndexerCapacity(address _indexer) public view override returns (uint256) {
568-
Stakes.Indexer memory indexerStake = __stakes[_indexer];
569+
IStakes.Indexer memory indexerStake = __stakes[_indexer];
569570
uint256 tokensDelegated = __delegationPools[_indexer].tokens;
570571

571572
uint256 tokensDelegatedCap = indexerStake.tokensSecureStake().mul(uint256(__delegationRatio));

packages/contracts/contracts/staking/StakingExtension.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IStakingExtension } from "./IStakingExtension.sol";
99
import { TokenUtils } from "../utils/TokenUtils.sol";
1010
import { IGraphToken } from "../token/IGraphToken.sol";
1111
import { GraphUpgradeable } from "../upgrades/GraphUpgradeable.sol";
12+
import { IStakes } from "./libs/IStakes.sol";
1213
import { Stakes } from "./libs/Stakes.sol";
1314
import { IStakingData } from "./IStakingData.sol";
1415
import { MathUtils } from "./libs/MathUtils.sol";
@@ -22,7 +23,7 @@ import { MathUtils } from "./libs/MathUtils.sol";
2223
*/
2324
contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtension {
2425
using SafeMath for uint256;
25-
using Stakes for Stakes.Indexer;
26+
using Stakes for IStakes.Indexer;
2627

2728
/// @dev 100% in parts per million
2829
uint32 private constant MAX_PPM = 1000000;
@@ -147,7 +148,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi
147148
uint256 _reward,
148149
address _beneficiary
149150
) external override onlySlasher notPartialPaused {
150-
Stakes.Indexer storage indexerStake = __stakes[_indexer];
151+
IStakes.Indexer storage indexerStake = __stakes[_indexer];
151152

152153
// Only able to slash a non-zero number of tokens
153154
require(_tokens > 0, "!tokens");
@@ -365,11 +366,11 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi
365366

366367
/**
367368
* @notice Getter for stakes[_indexer]:
368-
* gets the stake information for an indexer as a Stakes.Indexer struct.
369+
* gets the stake information for an indexer as an IStakes.Indexer struct.
369370
* @param _indexer Indexer address for which to query the stake information
370-
* @return Stake information for the specified indexer, as a Stakes.Indexer struct
371+
* @return Stake information for the specified indexer, as an IStakes.Indexer struct
371372
*/
372-
function stakes(address _indexer) external view override returns (Stakes.Indexer memory) {
373+
function stakes(address _indexer) external view override returns (IStakes.Indexer memory) {
373374
return __stakes[_indexer];
374375
}
375376

packages/contracts/contracts/staking/StakingStorage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pragma solidity ^0.7.6;
55
import { Managed } from "../governance/Managed.sol";
66

77
import { IStakingData } from "./IStakingData.sol";
8-
import { Stakes } from "./libs/Stakes.sol";
8+
import { IStakes } from "./libs/IStakes.sol";
99

1010
/**
1111
* @title StakingV1Storage
@@ -46,7 +46,7 @@ contract StakingV1Storage is Managed {
4646
uint32 internal __alphaDenominator;
4747

4848
/// @dev Indexer stakes : indexer => Stake
49-
mapping(address => Stakes.Indexer) internal __stakes;
49+
mapping(address => IStakes.Indexer) internal __stakes;
5050

5151
/// @dev Allocations : allocationID => Allocation
5252
mapping(address => IStakingData.Allocation) internal __allocations;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
pragma solidity ^0.7.6 || 0.8.27;
4+
pragma abicoder v2;
5+
6+
interface IStakes {
7+
struct Indexer {
8+
uint256 tokensStaked; // Tokens on the indexer stake (staked by the indexer)
9+
uint256 tokensAllocated; // Tokens used in allocations
10+
uint256 tokensLocked; // Tokens locked for withdrawal subject to thawing period
11+
uint256 tokensLockedUntil; // Block when locked tokens can be withdrawn
12+
}
13+
}

packages/contracts/contracts/staking/libs/Stakes.sol

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pragma abicoder v2;
66
import "@openzeppelin/contracts/math/SafeMath.sol";
77

88
import "./MathUtils.sol";
9+
import "./IStakes.sol";
910

1011
/**
1112
* @title A collection of data structures and functions to manage the Indexer Stake state.
@@ -14,21 +15,14 @@ import "./MathUtils.sol";
1415
*/
1516
library Stakes {
1617
using SafeMath for uint256;
17-
using Stakes for Stakes.Indexer;
18-
19-
struct Indexer {
20-
uint256 tokensStaked; // Tokens on the indexer stake (staked by the indexer)
21-
uint256 tokensAllocated; // Tokens used in allocations
22-
uint256 tokensLocked; // Tokens locked for withdrawal subject to thawing period
23-
uint256 tokensLockedUntil; // Block when locked tokens can be withdrawn
24-
}
18+
using Stakes for IStakes.Indexer;
2519

2620
/**
2721
* @dev Deposit tokens to the indexer stake.
2822
* @param stake Stake data
2923
* @param _tokens Amount of tokens to deposit
3024
*/
31-
function deposit(Stakes.Indexer storage stake, uint256 _tokens) internal {
25+
function deposit(IStakes.Indexer storage stake, uint256 _tokens) internal {
3226
stake.tokensStaked = stake.tokensStaked.add(_tokens);
3327
}
3428

@@ -37,7 +31,7 @@ library Stakes {
3731
* @param stake Stake data
3832
* @param _tokens Amount of tokens to release
3933
*/
40-
function release(Stakes.Indexer storage stake, uint256 _tokens) internal {
34+
function release(IStakes.Indexer storage stake, uint256 _tokens) internal {
4135
stake.tokensStaked = stake.tokensStaked.sub(_tokens);
4236
}
4337

@@ -46,7 +40,7 @@ library Stakes {
4640
* @param stake Stake data
4741
* @param _tokens Amount of tokens to allocate
4842
*/
49-
function allocate(Stakes.Indexer storage stake, uint256 _tokens) internal {
43+
function allocate(IStakes.Indexer storage stake, uint256 _tokens) internal {
5044
stake.tokensAllocated = stake.tokensAllocated.add(_tokens);
5145
}
5246

@@ -55,7 +49,7 @@ library Stakes {
5549
* @param stake Stake data
5650
* @param _tokens Amount of tokens to unallocate
5751
*/
58-
function unallocate(Stakes.Indexer storage stake, uint256 _tokens) internal {
52+
function unallocate(IStakes.Indexer storage stake, uint256 _tokens) internal {
5953
stake.tokensAllocated = stake.tokensAllocated.sub(_tokens);
6054
}
6155

@@ -65,7 +59,7 @@ library Stakes {
6559
* @param _tokens Amount of tokens to unstake
6660
* @param _period Period in blocks that need to pass before withdrawal
6761
*/
68-
function lockTokens(Stakes.Indexer storage stake, uint256 _tokens, uint256 _period) internal {
62+
function lockTokens(IStakes.Indexer storage stake, uint256 _tokens, uint256 _period) internal {
6963
// Take into account period averaging for multiple unstake requests
7064
uint256 lockingPeriod = _period;
7165
if (stake.tokensLocked > 0) {
@@ -87,7 +81,7 @@ library Stakes {
8781
* @param stake Stake data
8882
* @param _tokens Amount of tokens to unlock
8983
*/
90-
function unlockTokens(Stakes.Indexer storage stake, uint256 _tokens) internal {
84+
function unlockTokens(IStakes.Indexer storage stake, uint256 _tokens) internal {
9185
stake.tokensLocked = stake.tokensLocked.sub(_tokens);
9286
if (stake.tokensLocked == 0) {
9387
stake.tokensLockedUntil = 0;
@@ -99,7 +93,7 @@ library Stakes {
9993
* @param stake Stake data
10094
* @return Amount of tokens being withdrawn
10195
*/
102-
function withdrawTokens(Stakes.Indexer storage stake) internal returns (uint256) {
96+
function withdrawTokens(IStakes.Indexer storage stake) internal returns (uint256) {
10397
// Calculate tokens that can be released
10498
uint256 tokensToWithdraw = stake.tokensWithdrawable();
10599

@@ -119,7 +113,7 @@ library Stakes {
119113
* @param stake Stake data
120114
* @return Token amount
121115
*/
122-
function tokensUsed(Stakes.Indexer memory stake) internal pure returns (uint256) {
116+
function tokensUsed(IStakes.Indexer memory stake) internal pure returns (uint256) {
123117
return stake.tokensAllocated.add(stake.tokensLocked);
124118
}
125119

@@ -130,7 +124,7 @@ library Stakes {
130124
* @param stake Stake data
131125
* @return Token amount
132126
*/
133-
function tokensSecureStake(Stakes.Indexer memory stake) internal pure returns (uint256) {
127+
function tokensSecureStake(IStakes.Indexer memory stake) internal pure returns (uint256) {
134128
return stake.tokensStaked.sub(stake.tokensLocked);
135129
}
136130

@@ -142,7 +136,7 @@ library Stakes {
142136
* @param stake Stake data
143137
* @return Token amount
144138
*/
145-
function tokensAvailable(Stakes.Indexer memory stake) internal pure returns (uint256) {
139+
function tokensAvailable(IStakes.Indexer memory stake) internal pure returns (uint256) {
146140
return stake.tokensAvailableWithDelegation(0);
147141
}
148142

@@ -155,7 +149,7 @@ library Stakes {
155149
* @return Token amount
156150
*/
157151
function tokensAvailableWithDelegation(
158-
Stakes.Indexer memory stake,
152+
IStakes.Indexer memory stake,
159153
uint256 _delegatedCapacity
160154
) internal pure returns (uint256) {
161155
uint256 tokensCapacity = stake.tokensStaked.add(_delegatedCapacity);
@@ -181,7 +175,7 @@ library Stakes {
181175
* @param stake Stake data
182176
* @return Token amount
183177
*/
184-
function tokensWithdrawable(Stakes.Indexer memory stake) internal view returns (uint256) {
178+
function tokensWithdrawable(IStakes.Indexer memory stake) internal view returns (uint256) {
185179
// No tokens to withdraw before locking period
186180
if (stake.tokensLockedUntil == 0 || block.number < stake.tokensLockedUntil) {
187181
return 0;

0 commit comments

Comments
 (0)