File tree 1 file changed +18
-0
lines changed
packages/hardhat-verify/src/internal
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import {
19
19
20
20
import { LibraryToAddress } from "./solc/artifacts" ;
21
21
import {
22
+ ABIArgumentTypeErrorType ,
22
23
isABIArgumentLengthError ,
23
24
isABIArgumentOverflowError ,
24
25
isABIArgumentTypeError ,
@@ -228,6 +229,23 @@ export async function encodeArguments(
228
229
const contractInterface = new Interface ( abi ) ;
229
230
let encodedConstructorArguments ;
230
231
try {
232
+ // Check if the constructor arguments are of the correct type.
233
+ const constructorArgType = contractInterface . deploy . inputs ?. map (
234
+ ( ci ) => ci ?. type
235
+ ) ;
236
+ constructorArguments ?. forEach ( ( item , index ) => {
237
+ if (
238
+ typeof item !== constructorArgType [ index ] &&
239
+ constructorArgType [ index ] === "string"
240
+ )
241
+ throw new ABIArgumentTypeError ( {
242
+ code : "INVALID_ARGUMENT" ,
243
+ argument : "constructor argument" ,
244
+ value : item ,
245
+ reason : `Expected type 'string', but got '${ typeof item } '` ,
246
+ } as ABIArgumentTypeErrorType ) ;
247
+ } ) ;
248
+
231
249
encodedConstructorArguments = contractInterface
232
250
. encodeDeploy ( constructorArguments )
233
251
. replace ( "0x" , "" ) ;
You can’t perform that action at this time.
0 commit comments