@bgd-labs/toolbox 0.0.23 → 0.0.25

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.mjs CHANGED
@@ -13806,6 +13806,7 @@ async function getSourceCode(params) {
13806
13806
  if (params.apiKey) payload.apikey = params.apiKey;
13807
13807
  const formattedPayload = new URLSearchParams(payload).toString();
13808
13808
  const url = `${params.apiUrl ? params.apiUrl : getExplorer(params.chainId).api}?${formattedPayload}`;
13809
+ console.log(url);
13809
13810
  const request = await fetch(url);
13810
13811
  const { status, message, result } = await request.json();
13811
13812
  if (status != "1") {
@@ -13819,6 +13820,24 @@ function parseEtherscanStyleSourceCode(sourceCode) {
13819
13820
  }
13820
13821
  return JSON.parse(sourceCode);
13821
13822
  }
13823
+ function parseBlockscoutStyleSourceCode(sourceCode) {
13824
+ const result = {
13825
+ language: "unknown",
13826
+ settings: sourceCode.CompilerSettings,
13827
+ libraries: sourceCode.CompilerSettings.libraries,
13828
+ sources: {
13829
+ [sourceCode.FileName]: { content: sourceCode.SourceCode },
13830
+ ...sourceCode.AdditionalSources.reduce(
13831
+ (acc, code) => {
13832
+ acc[code.Filename] = { content: code.SourceCode };
13833
+ return acc;
13834
+ },
13835
+ {}
13836
+ )
13837
+ }
13838
+ };
13839
+ return result;
13840
+ }
13822
13841
 
13823
13842
  // src/ecosystem/tenderly.ts
13824
13843
  import {
@@ -28446,7 +28465,7 @@ var hyperRPCSupportedNetworks = [
28446
28465
  ];
28447
28466
 
28448
28467
  // src/operations/diffCode.ts
28449
- import { createPatch, createTwoFilesPatch } from "diff";
28468
+ import { createPatch, createTwoFilesPatch, diffChars } from "diff";
28450
28469
  import { format } from "prettier/standalone";
28451
28470
  import solidityPlugin from "prettier-plugin-solidity/standalone";
28452
28471
  var prettierOptions = { parser: "solidity-parse", plugins: [solidityPlugin] };
@@ -28471,7 +28490,25 @@ async function diffCode(before, after) {
28471
28490
  ])
28472
28491
  );
28473
28492
  for (const [name, path, source] of contractsBefore) {
28474
- const indexAfter = contractsAfter.findIndex(([_name]) => _name === name);
28493
+ const matchingIndexes = contractsAfter.reduce((acc, val, i) => {
28494
+ if (val[0] === name) acc.push(i);
28495
+ return acc;
28496
+ }, []);
28497
+ let indexAfter = -1;
28498
+ if (matchingIndexes.length === 1) {
28499
+ indexAfter = matchingIndexes[0];
28500
+ } else if (matchingIndexes.length > 1) {
28501
+ let maxSimilarity = -1;
28502
+ for (const idx of matchingIndexes) {
28503
+ const afterSource = contractsAfter[idx][2];
28504
+ const diff = diffChars(source, afterSource);
28505
+ const similarity = diff.reduce((acc, part) => acc + (part.added || part.removed ? 0 : part.count || part.value.length), 0);
28506
+ if (similarity > maxSimilarity) {
28507
+ maxSimilarity = similarity;
28508
+ indexAfter = idx;
28509
+ }
28510
+ }
28511
+ }
28475
28512
  if (indexAfter === -1) {
28476
28513
  changes[name] = createPatch(path, source, "");
28477
28514
  } else {
@@ -28928,6 +28965,7 @@ export {
28928
28965
  makePayloadExecutableOnTestClient,
28929
28966
  makeProposalExecutableOnTestClient,
28930
28967
  onMevHandler,
28968
+ parseBlockscoutStyleSourceCode,
28931
28969
  parseEtherscanStyleSourceCode,
28932
28970
  parseLogs,
28933
28971
  priceUpdateDecoder,