@bgd-labs/toolbox 0.0.29 → 0.0.30

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.d.mts CHANGED
@@ -14015,7 +14015,7 @@ declare function genericIndexer<T extends {} = {}>(args: GenericIndexerArgs<T>):
14015
14015
  type LogType = {
14016
14016
  topics: [Hex];
14017
14017
  data: Hex;
14018
- emitter: Address;
14018
+ address: Address;
14019
14019
  eventName?: string;
14020
14020
  args?: any;
14021
14021
  };
@@ -14069,8 +14069,9 @@ type RenderTenderlyReportParams = {
14069
14069
  config: {
14070
14070
  etherscanApiKey: string;
14071
14071
  };
14072
+ getContractName: (address: Address) => string;
14072
14073
  };
14073
- declare function renderTenderlyReport({ client, sim, payloadId, payload, onchainLogs: { createdLog, queuedLog, executedLog }, eventCache, config, }: RenderTenderlyReportParams): Promise<{
14074
+ declare function renderTenderlyReport({ client, sim, payloadId, payload, onchainLogs: { createdLog, queuedLog, executedLog }, eventCache, config, getContractName, }: RenderTenderlyReportParams): Promise<{
14074
14075
  report: string;
14075
14076
  eventCache: AbiEvent[];
14076
14077
  }>;
package/dist/index.d.ts CHANGED
@@ -14015,7 +14015,7 @@ declare function genericIndexer<T extends {} = {}>(args: GenericIndexerArgs<T>):
14015
14015
  type LogType = {
14016
14016
  topics: [Hex];
14017
14017
  data: Hex;
14018
- emitter: Address;
14018
+ address: Address;
14019
14019
  eventName?: string;
14020
14020
  args?: any;
14021
14021
  };
@@ -14069,8 +14069,9 @@ type RenderTenderlyReportParams = {
14069
14069
  config: {
14070
14070
  etherscanApiKey: string;
14071
14071
  };
14072
+ getContractName: (address: Address) => string;
14072
14073
  };
14073
- declare function renderTenderlyReport({ client, sim, payloadId, payload, onchainLogs: { createdLog, queuedLog, executedLog }, eventCache, config, }: RenderTenderlyReportParams): Promise<{
14074
+ declare function renderTenderlyReport({ client, sim, payloadId, payload, onchainLogs: { createdLog, queuedLog, executedLog }, eventCache, config, getContractName, }: RenderTenderlyReportParams): Promise<{
14074
14075
  report: string;
14075
14076
  eventCache: AbiEvent[];
14076
14077
  }>;
package/dist/index.js CHANGED
@@ -33109,6 +33109,19 @@ async function addAssetPrice(client, address) {
33109
33109
  }
33110
33110
  return `${address} (latestAnswer: ${decimals ? prettifyNumber({ value: latestAnswer, decimals, showDecimals: true }) : latestAnswer}, description: ${description})`;
33111
33111
  }
33112
+ function getMdContractName(contracts, address) {
33113
+ const contract = contracts.find(
33114
+ (c) => c.address.toLowerCase() === address.toLowerCase()
33115
+ );
33116
+ if (!contract) return `unknown contract name at \`${(0, import_viem9.getAddress)(address)}\``;
33117
+ let contractName = contract?.contract_name;
33118
+ if (contract?.token_data?.name)
33119
+ contractName += ` (${contract?.token_data?.name})`;
33120
+ if (contract.standards?.includes("eip1967") && contract.child_contracts?.[0].address) {
33121
+ return `${contractName} at \`${(0, import_viem9.getAddress)(address)}\` with implementation ${getMdContractName(contracts, contract.child_contracts?.[0].address)}`;
33122
+ }
33123
+ return `${contractName} at \`${(0, import_viem9.getAddress)(address)}\``;
33124
+ }
33112
33125
 
33113
33126
  // src/seatbelt/logs.ts
33114
33127
  function parseLogs({ logs, eventDb }) {
@@ -33135,8 +33148,7 @@ function enhanceLogs(client, logs) {
33135
33148
  if (["Transfer", "Approval", "Burn", "Mint", "BalanceTransfer"].includes(
33136
33149
  log.eventName
33137
33150
  )) {
33138
- const asset = await findAsset(client, log.emitter);
33139
- log.emitter = addAssetSymbol(asset, log.emitter);
33151
+ const asset = await findAsset(client, log.address);
33140
33152
  for (const key of argKeys) {
33141
33153
  if (["value", "amount", "wad"].includes(key)) {
33142
33154
  log.args[key] = prettifyNumber({
@@ -33274,6 +33286,9 @@ function checkCode(bytecode) {
33274
33286
  return { halted, delegatecall, selfDestruct: false };
33275
33287
  }
33276
33288
 
33289
+ // src/seatbelt/tenderly-report.ts
33290
+ var import_viem12 = require("viem");
33291
+
33277
33292
  // src/seatbelt/verified.ts
33278
33293
  var import_actions7 = require("viem/actions");
33279
33294
  var VerificationStatus = /* @__PURE__ */ ((VerificationStatus2) => {
@@ -33433,12 +33448,15 @@ function getObjectDiff(obj1, obj2) {
33433
33448
  function renderMarkdownStateDiffReport(changes, getContractName = (address) => `${address}`) {
33434
33449
  let report = "";
33435
33450
  for (const contract of Object.keys(changes)) {
33436
- report += `## ${getContractName(contract)}
33451
+ report += `#### ${getContractName(contract)}
33437
33452
 
33453
+ \`\`\`diff
33438
33454
  `;
33439
33455
  for (const change of changes[contract]) {
33440
33456
  report += deepDiff(change);
33441
33457
  }
33458
+ report += `\`\`\`
33459
+ `;
33442
33460
  }
33443
33461
  return report;
33444
33462
  }
@@ -33657,7 +33675,8 @@ async function renderTenderlyReport({
33657
33675
  payload,
33658
33676
  onchainLogs: { createdLog, queuedLog, executedLog },
33659
33677
  eventCache = [],
33660
- config
33678
+ config,
33679
+ getContractName = (address) => getMdContractName(sim.contracts, address)
33661
33680
  }) {
33662
33681
  const events = sim.transaction.transaction_info?.logs ? tenderly_logsToAbiLogs(sim.transaction.transaction_info?.logs) : [];
33663
33682
  events.map((e) => {
@@ -33749,13 +33768,13 @@ ${payload.actions.map(
33749
33768
 
33750
33769
  `;
33751
33770
  }
33752
- report += renderMarkdownStateDiffReport(stateDiff);
33771
+ report += renderMarkdownStateDiffReport(stateDiff, getContractName);
33753
33772
  if (verified.length) {
33754
33773
  report += "### Verification status for contracts touched in the proposal\n\n";
33755
33774
  report += "| Contract | Status |\n";
33756
33775
  report += "|---------|------------|\n";
33757
33776
  verified.map((contract) => {
33758
- report += `| ${contract.address}(${contract.name}) | ${verificationStatusToString(contract.status)} |
33777
+ report += `| ${getContractName(contract.address)}(${contract.name}) | ${verificationStatusToString(contract.status)} |
33759
33778
  `;
33760
33779
  });
33761
33780
  report += "\n";
@@ -33767,7 +33786,7 @@ ${payload.actions.map(
33767
33786
  report += "| Address | Result |\n";
33768
33787
  report += "|---------|------------|\n";
33769
33788
  selfDestruct.map((selfDestruct2) => {
33770
- report += `| ${selfDestruct2.address} | ${selfDestructStatusToString(
33789
+ report += `| ${getContractName(selfDestruct2.address)} | ${selfDestructStatusToString(
33771
33790
  selfDestruct2.state
33772
33791
  )} |
33773
33792
  `;
@@ -33775,15 +33794,18 @@ ${payload.actions.map(
33775
33794
  report += "\n";
33776
33795
  }
33777
33796
  if (logs.length) {
33778
- console.log(logs);
33779
33797
  report += "### Events emitted from the proposal\n\n";
33780
- report += "| Address | Event Name | Arguments |\n";
33781
- report += "|---------|------------|-----------|\n";
33782
- logs.map((log) => {
33783
- report += `| ${log.address} | ${log.eventName || log.topics} | ${log.args ? JSON.stringify(
33798
+ let ctr = import_viem12.zeroAddress;
33799
+ logs.sort((a, b) => a.address.localeCompare(b.address)).map((log) => {
33800
+ if (log.address !== ctr) {
33801
+ report += `- ${getContractName(log.address)}
33802
+ `;
33803
+ ctr = log.address;
33804
+ }
33805
+ report += ` - \`${log.eventName || log.topics}(${log.args ? JSON.stringify(
33784
33806
  log.args,
33785
33807
  (_, v) => typeof v === "bigint" ? v.toString() : v
33786
- ) : log.data} |
33808
+ ) : log.data})\`
33787
33809
  `;
33788
33810
  });
33789
33811
  }