@@ -79,15 +79,11 @@ function collectFactoriesMap(obj: unknown): Record<string, ContractFactoryStatic
79
79
const factoriesMap : Record < string , ContractFactoryStatic > = { }
80
80
81
81
// For factory name 'x', use contract name 'y'
82
+ // This is necessary because DisputeManager name collision, its the name of the contract in both the contracts and subgraph-service packages
82
83
const factoryNameOverrides : Record < string , string > = {
83
84
'contracts.contracts.disputes.IDisputeManager__factory' : 'ILegacyDisputeManager' ,
84
85
}
85
86
86
- // For contract name 'x', also create an entry for alias 'y' in the factory map
87
- const factoryNameAliases : Record < string , string > = {
88
- IServiceRegistry : 'ILegacyServiceRegistry' ,
89
- }
90
-
91
87
function recurse ( value : unknown , path : string [ ] = [ ] ) {
92
88
if ( typeof value !== 'object' || value === null ) {
93
89
return
@@ -116,19 +112,6 @@ function collectFactoriesMap(obj: unknown): Record<string, ContractFactoryStatic
116
112
117
113
// Add main entry
118
114
factoriesMap [ contractName ] = factory as ContractFactoryStatic
119
-
120
- // If alias exists, add alias entry too
121
- if ( factoryNameAliases [ contractName ] ) {
122
- const aliasName = factoryNameAliases [ contractName ]
123
-
124
- if ( factoriesMap [ aliasName ] ) {
125
- console . log (
126
- `⚠️ Duplicate factory for alias "${ aliasName } " derived from "${ contractName } ". Keeping the first occurrence.` ,
127
- )
128
- } else {
129
- factoriesMap [ aliasName ] = factory as ContractFactoryStatic
130
- }
131
- }
132
115
} else if ( typeof val === 'object' && val !== null ) {
133
116
recurse ( val , currentPath )
134
117
}
@@ -143,7 +126,7 @@ function collectFactoriesMap(obj: unknown): Record<string, ContractFactoryStatic
143
126
/**
144
127
* Gets alternative names for a contract to handle interface naming conventions
145
128
* For any given value passed to it, returns `ContractName` and `IContractName`
146
- * Note that this function will apply toolshed overrides, this returns a more complete interface
129
+ * Note that this function will apply toolshed overrides if available as they are more complete interfaces
147
130
* @param {string } contractName - The original contract name
148
131
* @returns {string[] } Array of possible contract names including interface variants
149
132
* @private
@@ -160,21 +143,18 @@ function getContractNameAlternatives(contractName: string): string[] {
160
143
L2Curation : 'L2CurationToolshed' ,
161
144
PaymentsEscrow : 'PaymentsEscrowToolshed' ,
162
145
RewardsManager : 'RewardsManagerToolshed' ,
163
- ServiceRegistry : 'ServiceRegistryToolshed' ,
164
146
SubgraphService : 'SubgraphServiceToolshed' ,
147
+ ServiceRegistry : 'ServiceRegistryToolshed' ,
148
+ LegacyServiceRegistry : 'ServiceRegistryToolshed' ,
165
149
}
166
150
151
+ // override with toolshed alternative if available
167
152
if ( nameOverrides [ contractName ] ) {
168
153
contractName = nameOverrides [ contractName ]
169
154
}
170
155
171
156
const alternatives : string [ ] = [ contractName ]
172
-
173
- if ( contractName . startsWith ( 'I' ) ) {
174
- alternatives . push ( contractName . replace ( 'I' , '' ) )
175
- } else {
176
- alternatives . push ( `I${ contractName } ` )
177
- }
157
+ alternatives . push ( contractName . startsWith ( 'I' ) ? contractName . replace ( 'I' , '' ) : `I${ contractName } ` )
178
158
179
159
return alternatives
180
160
}
0 commit comments