@layerzerolabs/verify-contract 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64342,13 +64342,21 @@ var source_default2 = got;
64342
64342
 
64343
64343
  // src/common/etherscan.ts
64344
64344
  var Verification = class extends EventEmitter__default.default {
64345
- constructor(props) {
64345
+ constructor(props, logger11) {
64346
64346
  super();
64347
64347
  this.props = props;
64348
+ this.logger = logger11;
64348
64349
  }
64349
64350
  async verify() {
64350
64351
  try {
64352
+ this.logger.verbose(
64353
+ `Submitting verification for ${this.props.contractName} on address ${this.props.address} to ${this.props.apiUrl}`
64354
+ );
64351
64355
  const response = await this.__submit();
64356
+ this.logger.verbose(
64357
+ `Received response for ${this.props.contractName} on address ${this.props.address} to ${this.props.apiUrl}`
64358
+ );
64359
+ this.logger.verbose(JSON.stringify(response));
64352
64360
  if (isAlreadyVerifiedResult(response.result)) {
64353
64361
  return {
64354
64362
  alreadyVerified: true
@@ -64413,7 +64421,7 @@ var Verification = class extends EventEmitter__default.default {
64413
64421
  }
64414
64422
  }
64415
64423
  };
64416
- var createVerification = (props) => new Verification(props);
64424
+ var createVerification = (props, logger11) => new Verification(props, logger11);
64417
64425
  var isPendingResult = (result) => !!(result == null ? void 0 : result.match(/Pending/gi));
64418
64426
  var isAlreadyVerifiedResult = (result) => !!(result == null ? void 0 : result.match(/already verified/gi));
64419
64427
  var isApiRateLimitedResult = (result) => !!(result == null ? void 0 : result.match(/rate/));
@@ -67876,7 +67884,6 @@ var verifyTarget = async (config, logger11) => {
67876
67884
  deploymentAbsolutePath
67877
67885
  ).filter((fileName) => fileName.endsWith(".json"));
67878
67886
  return deployedContractFileNames.flatMap((fileName) => {
67879
- var _a;
67880
67887
  logger11.info(
67881
67888
  `Inspecting deployment file ${fileName} on network ${networkName}`
67882
67889
  );
@@ -67892,68 +67899,64 @@ var verifyTarget = async (config, logger11) => {
67892
67899
  );
67893
67900
  }
67894
67901
  const deployment = deploymentParseResult.data;
67895
- const contractName = path.basename(fileName, ".json");
67902
+ path.basename(fileName, ".json");
67896
67903
  const compilationTargets = deployment.metadata.settings.compilationTarget;
67897
- const compilationTarget = Object.keys(compilationTargets).find(
67898
- (contractIdentifier) => compilationTargets[contractIdentifier] === contractName
67899
- );
67900
- if (compilationTarget == null) {
67901
- logger11.error(
67902
- COLORS.error`Could not find contract ${contractName} in the deployment file ${fileName} for network ${networkName}`
67903
- );
67904
- return [];
67905
- }
67906
- const shouldVerifyHardhatDeploy = verify(
67907
- contractName,
67908
- compilationTarget,
67909
- networkName
67910
- );
67911
- if (!shouldVerifyHardhatDeploy) {
67912
- logger11.debug(
67913
- `No contracts to verify in ${fileName} on network ${networkName}, skipping`
67914
- );
67915
- return [];
67916
- }
67917
- const source = deployment.metadata.sources[compilationTarget];
67918
- if (source == null) {
67919
- logger11.error(
67920
- COLORS.error`Could not find source for ${contractName} (${compilationTarget})`
67921
- );
67922
- return [];
67923
- }
67924
- const licenseType = findLicenseType(source.content);
67925
- const constructorArguments = encodeContructorArguments(
67926
- deployment.abi,
67927
- deployment.args
67904
+ return Object.entries(compilationTargets).flatMap(
67905
+ ([compilationTarget, contractName2]) => {
67906
+ var _a;
67907
+ const shouldVerifyHardhatDeploy = verify(
67908
+ contractName2,
67909
+ compilationTarget,
67910
+ networkName
67911
+ );
67912
+ if (!shouldVerifyHardhatDeploy) {
67913
+ logger11.debug(
67914
+ `Not verifying ${contractName2} in ${fileName} on network ${networkName}`
67915
+ );
67916
+ return [];
67917
+ }
67918
+ const source = deployment.metadata.sources[compilationTarget];
67919
+ if (source == null) {
67920
+ logger11.error(
67921
+ COLORS.error`Could not find source for ${contractName2} (${compilationTarget})`
67922
+ );
67923
+ return [];
67924
+ }
67925
+ const licenseType = findLicenseType(source.content);
67926
+ const constructorArguments = encodeContructorArguments(
67927
+ deployment.abi,
67928
+ deployment.args
67929
+ );
67930
+ const solcInput = extractSolcInputFromMetadata(deployment.metadata);
67931
+ const submitProps = {
67932
+ apiUrl: networkConfig.apiUrl,
67933
+ apiKey: networkConfig.apiKey,
67934
+ address: deployment.address,
67935
+ contractName: `${compilationTarget}:${contractName2}`,
67936
+ constructorArguments,
67937
+ licenseType,
67938
+ compilerVersion: deployment.metadata.compiler.version,
67939
+ sourceCode: JSON.stringify(solcInput),
67940
+ evmVersion: deployment.metadata.settings.evmVersion,
67941
+ optimizerRuns: (_a = deployment.metadata.settings.optimizer) == null ? void 0 : _a.runs
67942
+ };
67943
+ recordLogger({
67944
+ Contract: contractName2,
67945
+ Network: networkName,
67946
+ Address: deployment.address,
67947
+ License: submitProps.licenseType,
67948
+ Arguments: JSON.stringify(deployment.args),
67949
+ Sources: Object.keys(deployment.metadata.sources),
67950
+ "Scan URL": submitProps.apiUrl,
67951
+ "Scan API Key": submitProps.apiKey ? anonymizeValue(submitProps.apiKey) : void 0
67952
+ });
67953
+ return {
67954
+ submitProps,
67955
+ networkName,
67956
+ networkConfig
67957
+ };
67958
+ }
67928
67959
  );
67929
- const solcInput = extractSolcInputFromMetadata(deployment.metadata);
67930
- const submitProps = {
67931
- apiUrl: networkConfig.apiUrl,
67932
- apiKey: networkConfig.apiKey,
67933
- address: deployment.address,
67934
- contractName: `${compilationTarget}:${contractName}`,
67935
- constructorArguments,
67936
- licenseType,
67937
- compilerVersion: deployment.metadata.compiler.version,
67938
- sourceCode: JSON.stringify(solcInput),
67939
- evmVersion: deployment.metadata.settings.evmVersion,
67940
- optimizerRuns: (_a = deployment.metadata.settings.optimizer) == null ? void 0 : _a.runs
67941
- };
67942
- recordLogger({
67943
- Contract: contractName,
67944
- Network: networkName,
67945
- Address: deployment.address,
67946
- License: submitProps.licenseType,
67947
- Arguments: JSON.stringify(deployment.args),
67948
- Sources: Object.keys(deployment.metadata.sources),
67949
- "Scan URL": submitProps.apiUrl,
67950
- "Scan API Key": submitProps.apiKey ? anonymizeValue(submitProps.apiKey) : void 0
67951
- });
67952
- return {
67953
- submitProps,
67954
- networkName,
67955
- networkConfig
67956
- };
67957
67960
  });
67958
67961
  }
67959
67962
  );
@@ -67980,13 +67983,14 @@ var createVerifyAll = (logger11) => (artifacts) => {
67980
67983
  paletteColor`Verifying contract ${contractName} for network ${networkName} ${counter}`
67981
67984
  );
67982
67985
  try {
67983
- const verification = createVerification(submitProps);
67986
+ const verification = createVerification(submitProps, logger11);
67984
67987
  verification.on("poll", (guid) => {
67985
67988
  logger11.info(
67986
67989
  paletteColor`Polling for verification status of ${contractName} for network ${networkName} (GUID ${guid}) ${counter}`
67987
67990
  );
67988
67991
  });
67989
67992
  verification.on("retry", (error, attempt) => {
67993
+ logger11.verbose(`Received an error: ${error}`);
67990
67994
  logger11.info(
67991
67995
  paletteColor`Retrying failed verification attempt of ${contractName} for network ${networkName} (attempt ${attempt + 1}) ${counter}`
67992
67996
  );