@@ -7,7 +7,7 @@ import { COLORS, RecordLogger, anonymizeValue, createRecordLogger } from '../com
77import { tryCreateScanContractUrl } from '../common/url'
88import { DeploymentSchema } from '../common/schema'
99import { extractSolcInputFromMetadata } from './schema'
10- import { encodeContructorArguments , getContructorABIFromSource } from '../common/abi'
10+ import { encodeConstructorArguments , getConstructorABIFromSource } from '../common/abi'
1111import type {
1212 VerificationArtifact ,
1313 VerificationResult ,
@@ -100,7 +100,10 @@ export const verifyNonTarget = async (
100100 typeof contract . constructorArguments === 'string'
101101 ? contract . constructorArguments
102102 : // For decoded constructor arguments we'll need to try and encoded them using the contract source
103- encodeContructorArguments ( getContructorABIFromSource ( source . content ) , contract . constructorArguments )
103+ encodeConstructorArguments (
104+ getConstructorABIFromSource ( source . content ) ,
105+ contract . constructorArguments
106+ )
104107
105108 // Deployment metadata contains solcInput, just a bit rearranged
106109 const solcInput = extractSolcInputFromMetadata ( deployment . metadata )
@@ -254,7 +257,26 @@ export const verifyTarget = async (
254257 const licenseType = findLicenseType ( source . content )
255258
256259 // Constructor arguments need to come ABI-encoded but without the 0x
257- const constructorArguments = encodeContructorArguments ( deployment . abi , deployment . args )
260+ // Try using deployment ABI first, but fall back to source-based extraction if there's a mismatch
261+ let constructorArguments : string | undefined
262+ try {
263+ constructorArguments = encodeConstructorArguments ( deployment . abi , deployment . args )
264+ } catch ( error ) {
265+ // If encoding fails due to argument mismatch, try extracting constructor from source
266+ // This handles cases where the ABI is incomplete but source code has the full signature
267+ try {
268+ const sourceBasedAbi = getConstructorABIFromSource ( source . content )
269+ constructorArguments = encodeConstructorArguments ( sourceBasedAbi , deployment . args )
270+ } catch ( sourceError ) {
271+ // If both fail, log a warning and skip this contract
272+ logger . warn (
273+ `Skipping contract ${ contractName } in ${ fileName } on network ${ networkName } due to constructor encoding error: ${ error } . ` +
274+ `Tried fallback to source-based extraction but that also failed: ${ sourceError } `
275+ )
276+
277+ return [ ]
278+ }
279+ }
258280
259281 // Deployment metadata contains solcInput, just a bit rearranged
260282 const solcInput = extractSolcInputFromMetadata ( deployment . metadata )
0 commit comments