File tree 2 files changed +21
-11
lines changed
2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -33,25 +33,27 @@ export function buildGlobalParameterMap(
33
33
continue ;
34
34
}
35
35
36
- for ( const [ name , param ] of Object . entries ( plugin . globalParameters ) ) {
37
- // TODO: Validate name casing
38
- // TODO: Validate default value matches with type
39
- // TODO: Validate that the name is not one of the reserved ones in parameters.ts
40
-
41
- const existingByName = globalParametersIndex . get ( name ) ;
42
-
36
+ for ( const param of plugin . globalParameters ) {
37
+ const existingByName = globalParametersIndex . get ( param . name ) ;
43
38
if ( existingByName !== undefined ) {
44
- throw new Error (
45
- `Plugin ${ plugin . id } is trying to define the global parameter ${ name } but it is already defined by plugin ${ existingByName . pluginId } ` ,
39
+ throw new HardhatError (
40
+ HardhatError . ERRORS . GENERAL . GLOBAL_PARAMETER_ALREADY_DEFINED ,
41
+ {
42
+ plugin : plugin . id ,
43
+ globalParameter : param . name ,
44
+ definedByPlugin : existingByName . pluginId ,
45
+ } ,
46
46
) ;
47
47
}
48
48
49
+ const validatedGlobalParam = buildGlobalParameterDefinition ( param ) ;
50
+
49
51
const indexEntry = {
50
52
pluginId : plugin . id ,
51
- param,
53
+ param : validatedGlobalParam ,
52
54
} ;
53
55
54
- globalParametersIndex . set ( param . name , indexEntry ) ;
56
+ globalParametersIndex . set ( validatedGlobalParam . name , indexEntry ) ;
55
57
}
56
58
}
57
59
Original file line number Diff line number Diff line change @@ -162,6 +162,14 @@ Please double check whether you have multiple versions of the same plugin instal
162
162
websiteTitle : "Invalid BigInt" ,
163
163
websiteDescription : `Given value was not a valid BigInt.` ,
164
164
} ,
165
+ GLOBAL_PARAMETER_ALREADY_DEFINED : {
166
+ number : 12 ,
167
+ messageTemplate :
168
+ "Plugin {plugin} is trying to define the global parameter {globalParameter} but it is already defined by plugin {definedByPlugin}" ,
169
+ websiteTitle : "Global parameter already defined" ,
170
+ websiteDescription :
171
+ "The global parameter is already defined by another plugin. Please ensure that global parameters are uniquely named to avoid conflicts." ,
172
+ } ,
165
173
} ,
166
174
INTERNAL : {
167
175
ASSERTION_ERROR : {
You can’t perform that action at this time.
0 commit comments