Skip to content

Commit 62eb5aa

Browse files
committed
fix: couple fixes to make integration tests pass
Signed-off-by: Tomás Migone <[email protected]>
1 parent 2bfd7e0 commit 62eb5aa

File tree

7 files changed

+23
-35
lines changed

7 files changed

+23
-35
lines changed

packages/interfaces/contracts/horizon/internal/IMulticall.sol

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/interfaces/contracts/toolshed/IHorizonStakingToolshed.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
pragma solidity ^0.7.6 || 0.8.27;
33

44
import { IHorizonStaking } from "../horizon/IHorizonStaking.sol";
5-
import { IMulticall } from "../horizon/internal/IMulticall.sol";
5+
import { IMulticall } from "../contracts/base/IMulticall.sol";
66

77
interface IHorizonStakingToolshed is IHorizonStaking, IMulticall {}

packages/interfaces/src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ export function getAbi(contractName: string): unknown[] {
7777
export function collectFactoriesMap(obj: unknown): Record<string, ContractFactoryStatic> {
7878
const factoriesMap: Record<string, ContractFactoryStatic> = {}
7979

80+
// For factory name 'x', use contract name 'y'
8081
const factoryNameOverrides: Record<string, string> = {
8182
'contracts.contracts.disputes.IDisputeManager__factory': 'ILegacyDisputeManager',
8283
}
8384

85+
// For contract name 'x', also create an entry for alias 'y' in the factory map
8486
const factoryNameAliases: Record<string, string> = {
8587
IServiceRegistry: 'ILegacyServiceRegistry',
8688
}
@@ -140,11 +142,26 @@ export function collectFactoriesMap(obj: unknown): Record<string, ContractFactor
140142
/**
141143
* Gets alternative names for a contract to handle interface naming conventions
142144
* For any given value passed to it, returns `ContractName` and `IContractName`
145+
* Note that this function will apply toolshed overrides, this returns a more complete interface
143146
* @param {string} contractName - The original contract name
144147
* @returns {string[]} Array of possible contract names including interface variants
145148
* @private
146149
*/
147150
function getContractNameAlternatives(contractName: string): string[] {
151+
const nameOverrides: Record<string, string> = {
152+
Controller: 'ControllerToolshed',
153+
EpochManager: 'EpochManagerToolshed',
154+
GNS: 'GNSToolshed',
155+
HorizonStaking: 'HorizonStakingToolshed',
156+
L2Curation: 'L2CurationToolshed',
157+
RewardsManager: 'RewardsManagerToolshed',
158+
ServiceRegistry: 'ServiceRegistryToolshed',
159+
}
160+
161+
if (nameOverrides[contractName]) {
162+
contractName = nameOverrides[contractName]
163+
}
164+
148165
const alternatives: string[] = [contractName]
149166

150167
if (contractName.startsWith('I')) {

packages/subgraph-service/tasks/test/seed.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { HorizonStakingExtension } from '@graphprotocol/horizon'
21
import {
32
encodeRegistrationData,
43
encodeStartServiceData,
@@ -14,7 +13,6 @@ task('test:seed', 'Seed the test environment, must be run after deployment').set
1413
// Get contracts
1514
const graph = hre.graph()
1615
const horizonStaking = graph.horizon.contracts.HorizonStaking
17-
const horizonStakingExtension = graph.horizon.contracts.HorizonStaking as HorizonStakingExtension
1816
const subgraphService = graph.subgraphService.contracts.SubgraphService
1917
const disputeManager = graph.subgraphService.contracts.DisputeManager
2018

@@ -47,7 +45,7 @@ task('test:seed', 'Seed the test environment, must be run after deployment').set
4745

4846
// Close allocation
4947
const poi = generatePOI()
50-
await horizonStakingExtension.connect(indexerSigner).closeAllocation(allocation.allocationID, poi)
48+
await horizonStaking.connect(indexerSigner).closeAllocation(allocation.allocationID, poi)
5149

5250
const allocationData = await horizonStaking.getAllocation(allocation.allocationID)
5351
console.log(`Allocation closed at epoch: ${allocationData.closedAtEpoch}`)

packages/toolshed/src/deployments/horizon/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers'
22

3-
import type { GraphHorizonContracts, HorizonStakingExtension } from '.'
3+
import type { GraphHorizonContracts } from '.'
44

55
/**
66
* It's important to use JSDoc in the return functions here for good developer experience as
@@ -166,7 +166,7 @@ async function collect(
166166
const [tokens, allocationID] = args
167167

168168
await GraphToken.connect(signer).approve(HorizonStaking.target, tokens)
169-
await (HorizonStaking as HorizonStakingExtension).connect(signer).collect(tokens, allocationID)
169+
await HorizonStaking.connect(signer).collect(tokens, allocationID)
170170
}
171171

172172
async function delegate(

packages/toolshed/src/deployments/horizon/address-book.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getInterface, getMergedInterface } from '@graphprotocol/interfaces'
1+
import { getInterface } from '@graphprotocol/interfaces'
22
import { Provider, Signer } from 'ethers'
33
import { Contract } from 'ethers'
44

@@ -20,18 +20,6 @@ export class GraphHorizonAddressBook extends AddressBook<number, GraphHorizonCon
2020

2121
const contracts = this._loadContracts(signerOrProvider, enableTxLogging)
2222

23-
// rewire HorizonStaking to include HorizonStakingExtension abi
24-
if (contracts.HorizonStaking) {
25-
const stakingOverride = new Contract(
26-
this.getEntry('HorizonStaking').address,
27-
getMergedInterface(['HorizonStaking', 'HorizonStakingExtension']),
28-
signerOrProvider,
29-
)
30-
contracts.HorizonStaking = enableTxLogging
31-
? wrapTransactionCalls(stakingOverride, 'HorizonStaking')
32-
: stakingOverride
33-
}
34-
3523
this._assertGraphHorizonContracts(contracts)
3624

3725
// Aliases

packages/toolshed/src/deployments/horizon/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export * from './types'
1111

1212
export function loadGraphHorizon(addressBookPath: string, chainId: number, provider: HardhatEthersProvider) {
1313
const addressBook = new GraphHorizonAddressBook(addressBookPath, chainId)
14-
const contracts = addressBook.loadContracts(provider, true)
14+
const contracts = addressBook.loadContracts(provider, false)
1515
return {
1616
addressBook: addressBook,
1717
contracts: contracts,

0 commit comments

Comments
 (0)