-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathSubgraphService.ts
60 lines (52 loc) · 3.07 KB
/
SubgraphService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
import { deployImplementation } from '@graphprotocol/horizon/ignition/modules/proxy/implementation'
import { upgradeTransparentUpgradeableProxy } from '@graphprotocol/horizon/ignition/modules/proxy/TransparentUpgradeableProxy'
import ProxyAdminArtifact from '@openzeppelin/contracts/build/contracts/ProxyAdmin.json'
import SubgraphServiceArtifact from '../../build/contracts/contracts/SubgraphService.sol/SubgraphService.json'
import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json'
export default buildModule('SubgraphService', (m) => {
const deployer = m.getAccount(0)
const governor = m.getParameter('governor')
const pauseGuardian = m.getParameter('pauseGuardian')
const controllerAddress = m.getParameter('controllerAddress')
const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress')
const subgraphServiceProxyAdminAddress = m.getParameter('subgraphServiceProxyAdminAddress')
const disputeManagerProxyAddress = m.getParameter('disputeManagerProxyAddress')
const graphTallyCollectorAddress = m.getParameter('graphTallyCollectorAddress')
const curationAddress = m.getParameter('curationAddress')
const minimumProvisionTokens = m.getParameter('minimumProvisionTokens')
const maximumDelegationRatio = m.getParameter('maximumDelegationRatio')
const stakeToFeesRatio = m.getParameter('stakeToFeesRatio')
const maxPOIStaleness = m.getParameter('maxPOIStaleness')
const curationCut = m.getParameter('curationCut')
const SubgraphServiceProxyAdmin = m.contractAt('ProxyAdmin', ProxyAdminArtifact, subgraphServiceProxyAdminAddress)
const SubgraphServiceProxy = m.contractAt('SubgraphServiceProxy', TransparentUpgradeableProxyArtifact, subgraphServiceProxyAddress)
// Deploy implementation
const SubgraphServiceImplementation = deployImplementation(m, {
name: 'SubgraphService',
constructorArgs: [controllerAddress, disputeManagerProxyAddress, graphTallyCollectorAddress, curationAddress],
})
// Upgrade implementation
const SubgraphService = upgradeTransparentUpgradeableProxy(m,
SubgraphServiceProxyAdmin,
SubgraphServiceProxy,
SubgraphServiceImplementation, {
name: 'SubgraphService',
artifact: SubgraphServiceArtifact,
initArgs: [
deployer,
minimumProvisionTokens,
maximumDelegationRatio,
stakeToFeesRatio,
],
})
const callSetPauseGuardian = m.call(SubgraphService, 'setPauseGuardian', [pauseGuardian, true])
const callSetMaxPOIStaleness = m.call(SubgraphService, 'setMaxPOIStaleness', [maxPOIStaleness])
const callSetCurationCut = m.call(SubgraphService, 'setCurationCut', [curationCut])
m.call(SubgraphService, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })
return {
SubgraphService,
SubgraphServiceImplementation,
}
})