@bgd-labs/toolbox 0.0.28 → 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 +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +73 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -27
- package/dist/index.mjs.map +1 -1
- package/dist/node.js +73 -25
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +76 -27
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
14018
|
+
address: Address;
|
|
14019
14019
|
eventName?: string;
|
|
14020
14020
|
args?: any;
|
|
14021
14021
|
};
|
|
@@ -14030,7 +14030,7 @@ declare function parseLogs({ logs, eventDb }: ParseLogsArgs): LogType[];
|
|
|
14030
14030
|
* @param logs
|
|
14031
14031
|
* @returns
|
|
14032
14032
|
*/
|
|
14033
|
-
declare function enhanceLogs(client: Client, logs: LogType[]): Promise<
|
|
14033
|
+
declare function enhanceLogs(client: Client, logs: LogType[]): Promise<LogType[]>;
|
|
14034
14034
|
|
|
14035
14035
|
declare enum SelfdestructCheckState {
|
|
14036
14036
|
TRUSTED = 0,
|
|
@@ -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
|
}>;
|
|
@@ -14117,6 +14118,7 @@ type StreamChangedType = {
|
|
|
14117
14118
|
tokenAddress?: Address;
|
|
14118
14119
|
ratePerSecond?: string;
|
|
14119
14120
|
remainingBalance?: string;
|
|
14121
|
+
deposit?: string;
|
|
14120
14122
|
};
|
|
14121
14123
|
type InterestDataChangedType = {
|
|
14122
14124
|
optimalUsageRatio: number | string;
|
|
@@ -14129,8 +14131,12 @@ type ChangeMap = {
|
|
|
14129
14131
|
_streams: StreamChangedType;
|
|
14130
14132
|
_interestRateData: InterestDataChangedType;
|
|
14131
14133
|
assetsSources: string;
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
+
totalSupply: string;
|
|
14135
|
+
_balances: Record<string, string>;
|
|
14136
|
+
_allowances: Record<string, string>;
|
|
14137
|
+
balanceOf: Record<string, string>;
|
|
14138
|
+
allowed: Record<string, string>;
|
|
14139
|
+
balances: Record<string, string>;
|
|
14134
14140
|
};
|
|
14135
14141
|
type Change<TName extends string = string> = {
|
|
14136
14142
|
type: string;
|
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
|
-
|
|
14018
|
+
address: Address;
|
|
14019
14019
|
eventName?: string;
|
|
14020
14020
|
args?: any;
|
|
14021
14021
|
};
|
|
@@ -14030,7 +14030,7 @@ declare function parseLogs({ logs, eventDb }: ParseLogsArgs): LogType[];
|
|
|
14030
14030
|
* @param logs
|
|
14031
14031
|
* @returns
|
|
14032
14032
|
*/
|
|
14033
|
-
declare function enhanceLogs(client: Client, logs: LogType[]): Promise<
|
|
14033
|
+
declare function enhanceLogs(client: Client, logs: LogType[]): Promise<LogType[]>;
|
|
14034
14034
|
|
|
14035
14035
|
declare enum SelfdestructCheckState {
|
|
14036
14036
|
TRUSTED = 0,
|
|
@@ -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
|
}>;
|
|
@@ -14117,6 +14118,7 @@ type StreamChangedType = {
|
|
|
14117
14118
|
tokenAddress?: Address;
|
|
14118
14119
|
ratePerSecond?: string;
|
|
14119
14120
|
remainingBalance?: string;
|
|
14121
|
+
deposit?: string;
|
|
14120
14122
|
};
|
|
14121
14123
|
type InterestDataChangedType = {
|
|
14122
14124
|
optimalUsageRatio: number | string;
|
|
@@ -14129,8 +14131,12 @@ type ChangeMap = {
|
|
|
14129
14131
|
_streams: StreamChangedType;
|
|
14130
14132
|
_interestRateData: InterestDataChangedType;
|
|
14131
14133
|
assetsSources: string;
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
+
totalSupply: string;
|
|
14135
|
+
_balances: Record<string, string>;
|
|
14136
|
+
_allowances: Record<string, string>;
|
|
14137
|
+
balanceOf: Record<string, string>;
|
|
14138
|
+
allowed: Record<string, string>;
|
|
14139
|
+
balances: Record<string, string>;
|
|
14134
14140
|
};
|
|
14135
14141
|
type Change<TName extends string = string> = {
|
|
14136
14142
|
type: string;
|
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.
|
|
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({
|
|
@@ -33181,6 +33193,7 @@ function enhanceLogs(client, logs) {
|
|
|
33181
33193
|
}
|
|
33182
33194
|
return log;
|
|
33183
33195
|
}
|
|
33196
|
+
return log;
|
|
33184
33197
|
})
|
|
33185
33198
|
);
|
|
33186
33199
|
}
|
|
@@ -33273,6 +33286,9 @@ function checkCode(bytecode) {
|
|
|
33273
33286
|
return { halted, delegatecall, selfDestruct: false };
|
|
33274
33287
|
}
|
|
33275
33288
|
|
|
33289
|
+
// src/seatbelt/tenderly-report.ts
|
|
33290
|
+
var import_viem12 = require("viem");
|
|
33291
|
+
|
|
33276
33292
|
// src/seatbelt/verified.ts
|
|
33277
33293
|
var import_actions7 = require("viem/actions");
|
|
33278
33294
|
var VerificationStatus = /* @__PURE__ */ ((VerificationStatus2) => {
|
|
@@ -33432,12 +33448,15 @@ function getObjectDiff(obj1, obj2) {
|
|
|
33432
33448
|
function renderMarkdownStateDiffReport(changes, getContractName = (address) => `${address}`) {
|
|
33433
33449
|
let report = "";
|
|
33434
33450
|
for (const contract of Object.keys(changes)) {
|
|
33435
|
-
report +=
|
|
33451
|
+
report += `#### ${getContractName(contract)}
|
|
33436
33452
|
|
|
33453
|
+
\`\`\`diff
|
|
33437
33454
|
`;
|
|
33438
33455
|
for (const change of changes[contract]) {
|
|
33439
33456
|
report += deepDiff(change);
|
|
33440
33457
|
}
|
|
33458
|
+
report += `\`\`\`
|
|
33459
|
+
`;
|
|
33441
33460
|
}
|
|
33442
33461
|
return report;
|
|
33443
33462
|
}
|
|
@@ -33584,18 +33603,26 @@ async function enhanceStateDiff(client, diff) {
|
|
|
33584
33603
|
}
|
|
33585
33604
|
if (isChangeOfType(change, "_streams")) {
|
|
33586
33605
|
await formatBeforeAndAfter(change, async (data) => {
|
|
33587
|
-
if (data.tokenAddress
|
|
33606
|
+
if (data.tokenAddress) {
|
|
33588
33607
|
const assetInfo = await findAsset(client, data.tokenAddress);
|
|
33589
|
-
|
|
33590
|
-
|
|
33591
|
-
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33608
|
+
if (data.ratePerSecond)
|
|
33609
|
+
data.ratePerSecond = prettifyNumber({
|
|
33610
|
+
decimals: assetInfo.decimals,
|
|
33611
|
+
value: data.ratePerSecond,
|
|
33612
|
+
showDecimals: true
|
|
33613
|
+
});
|
|
33614
|
+
if (data.remainingBalance)
|
|
33615
|
+
data.remainingBalance = prettifyNumber({
|
|
33616
|
+
showDecimals: true,
|
|
33617
|
+
decimals: assetInfo.decimals,
|
|
33618
|
+
value: data.remainingBalance
|
|
33619
|
+
});
|
|
33620
|
+
if (data.deposit)
|
|
33621
|
+
data.deposit = prettifyNumber({
|
|
33622
|
+
showDecimals: true,
|
|
33623
|
+
decimals: assetInfo.decimals,
|
|
33624
|
+
value: data.deposit
|
|
33625
|
+
});
|
|
33599
33626
|
}
|
|
33600
33627
|
return data;
|
|
33601
33628
|
});
|
|
@@ -33605,15 +33632,31 @@ async function enhanceStateDiff(client, diff) {
|
|
|
33605
33632
|
return addAssetPrice(client, data);
|
|
33606
33633
|
});
|
|
33607
33634
|
}
|
|
33608
|
-
if (
|
|
33635
|
+
if (change.type === "mapping (address => uint256)" || isChangeOfType(change, "totalSupply")) {
|
|
33609
33636
|
await formatBeforeAndAfter(change, async (data) => {
|
|
33610
33637
|
const asset = await findAsset(client, key);
|
|
33611
|
-
if (asset)
|
|
33638
|
+
if (asset) {
|
|
33612
33639
|
return prettifyNumber({
|
|
33613
33640
|
decimals: asset.decimals,
|
|
33614
33641
|
value: data,
|
|
33615
33642
|
showDecimals: true
|
|
33616
33643
|
});
|
|
33644
|
+
}
|
|
33645
|
+
return data;
|
|
33646
|
+
});
|
|
33647
|
+
}
|
|
33648
|
+
if (isChangeOfType(change, "_allowances") || isChangeOfType(change, "allowed")) {
|
|
33649
|
+
await formatBeforeAndAfter(change, async (data) => {
|
|
33650
|
+
const asset = await findAsset(client, key);
|
|
33651
|
+
if (asset && typeof data === "object") {
|
|
33652
|
+
Object.keys(data).forEach((key2) => {
|
|
33653
|
+
data[key2] = prettifyNumber({
|
|
33654
|
+
decimals: asset.decimals,
|
|
33655
|
+
value: data[key2],
|
|
33656
|
+
showDecimals: true
|
|
33657
|
+
});
|
|
33658
|
+
});
|
|
33659
|
+
}
|
|
33617
33660
|
return data;
|
|
33618
33661
|
});
|
|
33619
33662
|
}
|
|
@@ -33632,7 +33675,8 @@ async function renderTenderlyReport({
|
|
|
33632
33675
|
payload,
|
|
33633
33676
|
onchainLogs: { createdLog, queuedLog, executedLog },
|
|
33634
33677
|
eventCache = [],
|
|
33635
|
-
config
|
|
33678
|
+
config,
|
|
33679
|
+
getContractName = (address) => getMdContractName(sim.contracts, address)
|
|
33636
33680
|
}) {
|
|
33637
33681
|
const events = sim.transaction.transaction_info?.logs ? tenderly_logsToAbiLogs(sim.transaction.transaction_info?.logs) : [];
|
|
33638
33682
|
events.map((e) => {
|
|
@@ -33724,13 +33768,13 @@ ${payload.actions.map(
|
|
|
33724
33768
|
|
|
33725
33769
|
`;
|
|
33726
33770
|
}
|
|
33727
|
-
report += renderMarkdownStateDiffReport(stateDiff);
|
|
33771
|
+
report += renderMarkdownStateDiffReport(stateDiff, getContractName);
|
|
33728
33772
|
if (verified.length) {
|
|
33729
33773
|
report += "### Verification status for contracts touched in the proposal\n\n";
|
|
33730
33774
|
report += "| Contract | Status |\n";
|
|
33731
33775
|
report += "|---------|------------|\n";
|
|
33732
33776
|
verified.map((contract) => {
|
|
33733
|
-
report += `| ${contract.address}(${contract.name}) | ${verificationStatusToString(contract.status)} |
|
|
33777
|
+
report += `| ${getContractName(contract.address)}(${contract.name}) | ${verificationStatusToString(contract.status)} |
|
|
33734
33778
|
`;
|
|
33735
33779
|
});
|
|
33736
33780
|
report += "\n";
|
|
@@ -33742,7 +33786,7 @@ ${payload.actions.map(
|
|
|
33742
33786
|
report += "| Address | Result |\n";
|
|
33743
33787
|
report += "|---------|------------|\n";
|
|
33744
33788
|
selfDestruct.map((selfDestruct2) => {
|
|
33745
|
-
report += `| ${selfDestruct2.address} | ${selfDestructStatusToString(
|
|
33789
|
+
report += `| ${getContractName(selfDestruct2.address)} | ${selfDestructStatusToString(
|
|
33746
33790
|
selfDestruct2.state
|
|
33747
33791
|
)} |
|
|
33748
33792
|
`;
|
|
@@ -33751,13 +33795,17 @@ ${payload.actions.map(
|
|
|
33751
33795
|
}
|
|
33752
33796
|
if (logs.length) {
|
|
33753
33797
|
report += "### Events emitted from the proposal\n\n";
|
|
33754
|
-
|
|
33755
|
-
|
|
33756
|
-
|
|
33757
|
-
|
|
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(
|
|
33758
33806
|
log.args,
|
|
33759
33807
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
33760
|
-
) : log.data}
|
|
33808
|
+
) : log.data})\`
|
|
33761
33809
|
`;
|
|
33762
33810
|
});
|
|
33763
33811
|
}
|