Skip to content

Commit c6aa09d

Browse files
abarmatdavekay100
authored andcommitted
service-registry: make the contract upgradeable
1 parent a92c27a commit c6aa09d

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

contracts/discovery/ServiceRegistry.sol

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ pragma solidity ^0.7.3;
44
pragma experimental ABIEncoderV2;
55

66
import "../governance/Managed.sol";
7+
import "../upgrades/GraphUpgradeable.sol";
78

9+
import "./ServiceRegistryStorage.sol";
810
import "./IServiceRegistry.sol";
911

1012
/**
1113
* @title ServiceRegistry contract
1214
* @dev This contract supports the service discovery process by allowing indexers to
1315
* register their service url and any other relevant information.
1416
*/
15-
contract ServiceRegistry is Managed, IServiceRegistry {
16-
// -- State --
17-
18-
mapping(address => IndexerService) public services;
19-
17+
contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IServiceRegistry {
2018
// -- Events --
2119

2220
event ServiceRegistered(address indexed indexer, string url, string geohash);
@@ -30,10 +28,9 @@ contract ServiceRegistry is Managed, IServiceRegistry {
3028
}
3129

3230
/**
33-
* @dev Contract Constructor.
34-
* @param _controller Controller address
31+
* @dev Initialize this contract.
3532
*/
36-
constructor(address _controller) {
33+
function initialize(address _controller) external onlyImpl {
3734
Managed._initialize(_controller);
3835
}
3936

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
3+
pragma solidity ^0.7.3;
4+
5+
import "../governance/Managed.sol";
6+
7+
import "./IServiceRegistry.sol";
8+
9+
contract ServiceRegistryV1Storage is Managed {
10+
// -- State --
11+
12+
mapping(address => IServiceRegistry.IndexerService) public services;
13+
}

graph.config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ contracts:
2626
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
2727
contractAddress: "${{GraphToken.address}}"
2828
ServiceRegistry:
29+
proxy: true
2930
init:
3031
controller: "${{Controller.address}}"
3132
EpochManager:

test/lib/deployment.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,16 @@ export async function deployEthereumDIDRegistry(deployer: Signer): Promise<Ether
196196
export async function deployServiceRegistry(
197197
deployer: Signer,
198198
controller: string,
199+
proxyAdmin: GraphProxyAdmin,
199200
): Promise<ServiceRegistry> {
200-
return (deployContract('ServiceRegistry', deployer, controller) as unknown) as Promise<
201-
ServiceRegistry
202-
>
201+
// Deploy
202+
return (network.deployContractWithProxy(
203+
proxyAdmin,
204+
'ServiceRegistry',
205+
[controller],
206+
deployer,
207+
false,
208+
) as unknown) as Promise<ServiceRegistry>
203209
}
204210

205211
export async function deployStaking(

test/lib/fixtures.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export class NetworkFixture {
4141
controller.address,
4242
proxyAdmin,
4343
)
44-
const serviceRegistry = await deployment.deployServiceRegistry(deployer, controller.address)
44+
const serviceRegistry = await deployment.deployServiceRegistry(
45+
deployer,
46+
controller.address,
47+
proxyAdmin,
48+
)
4549

4650
// Setup controller
4751
await controller.setContractProxy(utils.id('EpochManager'), epochManager.address)

0 commit comments

Comments
 (0)