@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.js CHANGED
@@ -123,6 +123,7 @@ __export(index_exports, {
123
123
  makePayloadExecutableOnTestClient: () => makePayloadExecutableOnTestClient,
124
124
  makeProposalExecutableOnTestClient: () => makeProposalExecutableOnTestClient,
125
125
  onMevHandler: () => onMevHandler,
126
+ parseBlockscoutStyleSourceCode: () => parseBlockscoutStyleSourceCode,
126
127
  parseEtherscanStyleSourceCode: () => parseEtherscanStyleSourceCode,
127
128
  parseLogs: () => parseLogs,
128
129
  priceUpdateDecoder: () => priceUpdateDecoder,
@@ -13936,6 +13937,7 @@ async function getSourceCode(params) {
13936
13937
  if (params.apiKey) payload.apikey = params.apiKey;
13937
13938
  const formattedPayload = new URLSearchParams(payload).toString();
13938
13939
  const url = `${params.apiUrl ? params.apiUrl : getExplorer(params.chainId).api}?${formattedPayload}`;
13940
+ console.log(url);
13939
13941
  const request = await fetch(url);
13940
13942
  const { status, message, result } = await request.json();
13941
13943
  if (status != "1") {
@@ -13949,6 +13951,24 @@ function parseEtherscanStyleSourceCode(sourceCode) {
13949
13951
  }
13950
13952
  return JSON.parse(sourceCode);
13951
13953
  }
13954
+ function parseBlockscoutStyleSourceCode(sourceCode) {
13955
+ const result = {
13956
+ language: "unknown",
13957
+ settings: sourceCode.CompilerSettings,
13958
+ libraries: sourceCode.CompilerSettings.libraries,
13959
+ sources: {
13960
+ [sourceCode.FileName]: { content: sourceCode.SourceCode },
13961
+ ...sourceCode.AdditionalSources.reduce(
13962
+ (acc, code) => {
13963
+ acc[code.Filename] = { content: code.SourceCode };
13964
+ return acc;
13965
+ },
13966
+ {}
13967
+ )
13968
+ }
13969
+ };
13970
+ return result;
13971
+ }
13952
13972
 
13953
13973
  // src/ecosystem/tenderly.ts
13954
13974
  var import_viem5 = require("viem");
@@ -28556,7 +28576,25 @@ async function diffCode(before, after) {
28556
28576
  ])
28557
28577
  );
28558
28578
  for (const [name, path, source] of contractsBefore) {
28559
- const indexAfter = contractsAfter.findIndex(([_name]) => _name === name);
28579
+ const matchingIndexes = contractsAfter.reduce((acc, val, i) => {
28580
+ if (val[0] === name) acc.push(i);
28581
+ return acc;
28582
+ }, []);
28583
+ let indexAfter = -1;
28584
+ if (matchingIndexes.length === 1) {
28585
+ indexAfter = matchingIndexes[0];
28586
+ } else if (matchingIndexes.length > 1) {
28587
+ let maxSimilarity = -1;
28588
+ for (const idx of matchingIndexes) {
28589
+ const afterSource = contractsAfter[idx][2];
28590
+ const diff = (0, import_diff.diffChars)(source, afterSource);
28591
+ const similarity = diff.reduce((acc, part) => acc + (part.added || part.removed ? 0 : part.count || part.value.length), 0);
28592
+ if (similarity > maxSimilarity) {
28593
+ maxSimilarity = similarity;
28594
+ indexAfter = idx;
28595
+ }
28596
+ }
28597
+ }
28560
28598
  if (indexAfter === -1) {
28561
28599
  changes[name] = (0, import_diff.createPatch)(path, source, "");
28562
28600
  } else {
@@ -29014,6 +29052,7 @@ function transformTenderlyStateDiff(stateDiff) {
29014
29052
  makePayloadExecutableOnTestClient,
29015
29053
  makeProposalExecutableOnTestClient,
29016
29054
  onMevHandler,
29055
+ parseBlockscoutStyleSourceCode,
29017
29056
  parseEtherscanStyleSourceCode,
29018
29057
  parseLogs,
29019
29058
  priceUpdateDecoder,