@bgd-labs/toolbox 0.0.29 → 0.0.31

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
@@ -32916,6 +32916,7 @@ import { decodeEventLog } from "viem";
32916
32916
  // src/seatbelt/utils.ts
32917
32917
  import {
32918
32918
  formatUnits,
32919
+ getAddress as getAddress2,
32919
32920
  getContract as getContract4,
32920
32921
  zeroAddress
32921
32922
  } from "viem";
@@ -33016,6 +33017,19 @@ async function addAssetPrice(client, address) {
33016
33017
  }
33017
33018
  return `${address} (latestAnswer: ${decimals ? prettifyNumber({ value: latestAnswer, decimals, showDecimals: true }) : latestAnswer}, description: ${description})`;
33018
33019
  }
33020
+ function getMdContractName(contracts, address) {
33021
+ const contract = contracts.find(
33022
+ (c) => c.address.toLowerCase() === address.toLowerCase()
33023
+ );
33024
+ if (!contract) return `unknown contract name at \`${getAddress2(address)}\``;
33025
+ let contractName = contract?.contract_name;
33026
+ if (contract?.token_data?.name)
33027
+ contractName += ` (${contract?.token_data?.name})`;
33028
+ if (contract.standards?.includes("eip1967") && contract.child_contracts?.[0].address) {
33029
+ return `${contractName} at \`${getAddress2(address)}\` with implementation ${getMdContractName(contracts, contract.child_contracts?.[0].address)}`;
33030
+ }
33031
+ return `${contractName} at \`${getAddress2(address)}\``;
33032
+ }
33019
33033
 
33020
33034
  // src/seatbelt/logs.ts
33021
33035
  function parseLogs({ logs, eventDb }) {
@@ -33042,8 +33056,7 @@ function enhanceLogs(client, logs) {
33042
33056
  if (["Transfer", "Approval", "Burn", "Mint", "BalanceTransfer"].includes(
33043
33057
  log.eventName
33044
33058
  )) {
33045
- const asset = await findAsset(client, log.emitter);
33046
- log.emitter = addAssetSymbol(asset, log.emitter);
33059
+ const asset = await findAsset(client, log.address);
33047
33060
  for (const key of argKeys) {
33048
33061
  if (["value", "amount", "wad"].includes(key)) {
33049
33062
  log.args[key] = prettifyNumber({
@@ -33181,6 +33194,9 @@ function checkCode(bytecode) {
33181
33194
  return { halted, delegatecall, selfDestruct: false };
33182
33195
  }
33183
33196
 
33197
+ // src/seatbelt/tenderly-report.ts
33198
+ import { zeroAddress as zeroAddress3 } from "viem";
33199
+
33184
33200
  // src/seatbelt/verified.ts
33185
33201
  import { getCode } from "viem/actions";
33186
33202
  var VerificationStatus = /* @__PURE__ */ ((VerificationStatus2) => {
@@ -33248,7 +33264,7 @@ async function getVerificationStatus({
33248
33264
  }
33249
33265
 
33250
33266
  // src/seatbelt/state.ts
33251
- import { getAddress as getAddress2, zeroAddress as zeroAddress2 } from "viem";
33267
+ import { getAddress as getAddress3, zeroAddress as zeroAddress2 } from "viem";
33252
33268
  import { readContract as readContract2 } from "viem/actions";
33253
33269
  function isChangeOfType(change, name) {
33254
33270
  return change.name === name;
@@ -33257,7 +33273,7 @@ function transformTenderlyStateDiff(stateDiff) {
33257
33273
  const formattedDiffs = stateDiff.reduce(
33258
33274
  (diffs, diff) => {
33259
33275
  if (!diff.raw?.[0]) return diffs;
33260
- const addr = getAddress2(diff.raw[0].address);
33276
+ const addr = getAddress3(diff.raw[0].address);
33261
33277
  if (!diffs[addr]) diffs[addr] = [diff];
33262
33278
  else diffs[addr].push(diff);
33263
33279
  return diffs;
@@ -33340,12 +33356,15 @@ function getObjectDiff(obj1, obj2) {
33340
33356
  function renderMarkdownStateDiffReport(changes, getContractName = (address) => `${address}`) {
33341
33357
  let report = "";
33342
33358
  for (const contract of Object.keys(changes)) {
33343
- report += `## ${getContractName(contract)}
33359
+ report += `#### ${getContractName(contract)}
33344
33360
 
33361
+ \`\`\`diff
33345
33362
  `;
33346
33363
  for (const change of changes[contract]) {
33347
33364
  report += deepDiff(change);
33348
33365
  }
33366
+ report += `\`\`\`
33367
+ `;
33349
33368
  }
33350
33369
  return report;
33351
33370
  }
@@ -33564,7 +33583,8 @@ async function renderTenderlyReport({
33564
33583
  payload,
33565
33584
  onchainLogs: { createdLog, queuedLog, executedLog },
33566
33585
  eventCache = [],
33567
- config
33586
+ config,
33587
+ getContractName = (address) => getMdContractName(sim.contracts, address)
33568
33588
  }) {
33569
33589
  const events = sim.transaction.transaction_info?.logs ? tenderly_logsToAbiLogs(sim.transaction.transaction_info?.logs) : [];
33570
33590
  events.map((e) => {
@@ -33656,13 +33676,13 @@ ${payload.actions.map(
33656
33676
 
33657
33677
  `;
33658
33678
  }
33659
- report += renderMarkdownStateDiffReport(stateDiff);
33679
+ report += renderMarkdownStateDiffReport(stateDiff, getContractName);
33660
33680
  if (verified.length) {
33661
33681
  report += "### Verification status for contracts touched in the proposal\n\n";
33662
33682
  report += "| Contract | Status |\n";
33663
33683
  report += "|---------|------------|\n";
33664
33684
  verified.map((contract) => {
33665
- report += `| ${contract.address}(${contract.name}) | ${verificationStatusToString(contract.status)} |
33685
+ report += `| ${getContractName(contract.address)}(${contract.name}) | ${verificationStatusToString(contract.status)} |
33666
33686
  `;
33667
33687
  });
33668
33688
  report += "\n";
@@ -33674,7 +33694,7 @@ ${payload.actions.map(
33674
33694
  report += "| Address | Result |\n";
33675
33695
  report += "|---------|------------|\n";
33676
33696
  selfDestruct.map((selfDestruct2) => {
33677
- report += `| ${selfDestruct2.address} | ${selfDestructStatusToString(
33697
+ report += `| ${getContractName(selfDestruct2.address)} | ${selfDestructStatusToString(
33678
33698
  selfDestruct2.state
33679
33699
  )} |
33680
33700
  `;
@@ -33682,15 +33702,18 @@ ${payload.actions.map(
33682
33702
  report += "\n";
33683
33703
  }
33684
33704
  if (logs.length) {
33685
- console.log(logs);
33686
33705
  report += "### Events emitted from the proposal\n\n";
33687
- report += "| Address | Event Name | Arguments |\n";
33688
- report += "|---------|------------|-----------|\n";
33689
- logs.map((log) => {
33690
- report += `| ${log.address} | ${log.eventName || log.topics} | ${log.args ? JSON.stringify(
33706
+ let ctr = zeroAddress3;
33707
+ logs.sort((a, b) => a.address.localeCompare(b.address)).map((log) => {
33708
+ if (log.address !== ctr) {
33709
+ report += `- ${getContractName(log.address)}
33710
+ `;
33711
+ ctr = log.address;
33712
+ }
33713
+ report += ` - \`${log.eventName || log.topics}(${log.args ? JSON.stringify(
33691
33714
  log.args,
33692
33715
  (_, v) => typeof v === "bigint" ? v.toString() : v
33693
- ) : log.data} |
33716
+ ) : log.data})\`
33694
33717
  `;
33695
33718
  });
33696
33719
  }