Skip to content

Commit

Permalink
fix: batch of report improvements (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Dec 10, 2023
1 parent ad24fa0 commit 403280d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/govv3/generatePayloadReport.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PublicClient } from 'viem';
import { TenderlySimulationResponse } from '../utils/tenderlyClient';
import { PayloadsController, getPayloadsController } from './payloadsController';
import { HUMAN_READABLE_PAYLOAD_STATE, PayloadsController, getPayloadsController } from './payloadsController';
import { renderCheckResult, renderUnixTime, toTxLink } from './utils/markdownUtils';
import { checkTargetsNoSelfdestruct, checkTouchedContractsNoSelfdestruct } from './checks/selfDestruct';
import { checkLogs } from './checks/logs';
Expand All @@ -19,9 +19,12 @@ export async function generateReport({ payloadId, payloadInfo, simulation, publi
// generate file header
let report = `## Payload ${payloadId} on ${publicClient.chain!.name}
- Simulation: [https://dashboard.tenderly.co/me/simulator/${
simulation.simulation.id
}](https://dashboard.tenderly.co/me/simulator/${simulation.simulation.id})
- creator: ${payload.creator}
- maximumAccessLevelRequired: ${payload.maximumAccessLevelRequired}
- state: ${payload.state}
- state: ${payload.state}(${(HUMAN_READABLE_PAYLOAD_STATE as any)[payload.state]})
- actions: ${JSON.stringify(payload.actions, (key, value) => (typeof value === 'bigint' ? value.toString() : value))}
- createdAt: [${renderUnixTime(payload.createdAt)}](${toTxLink(createdLog.transactionHash, false, publicClient)})\n`;
if (queuedLog) {
Expand All @@ -37,7 +40,9 @@ export async function generateReport({ payloadId, payloadInfo, simulation, publi
publicClient
)})\n`;
} else {
report += `- earliest execution at: ${renderUnixTime(payload.queuedAt + 60 * 60 * 24)}\n`;
report += `- earliest execution at: [${renderUnixTime(
payload.queuedAt + payload.delay
)}](https://www.epochconverter.com/countdown?q=${payload.queuedAt + payload.delay})\n`;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/govv3/generateProposalReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export async function generateProposalReport({
// generate file header
let report = `## Proposal ${proposalId}
- Simulation: [https://dashboard.tenderly.co/me/simulator/${
simulation.simulation.id
}](https://dashboard.tenderly.co/me/simulator/${simulation.simulation.id})
- state: ${HUMAN_READABLE_STATE[proposal.state as keyof typeof HUMAN_READABLE_STATE]}
- creator: ${proposal.creator}
- maximumAccessLevelRequired: ${proposal.accessLevel}
Expand Down
9 changes: 9 additions & 0 deletions src/govv3/payloadsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export enum PayloadState {
Expired,
}

export const HUMAN_READABLE_PAYLOAD_STATE = {
[PayloadState.None]: 'None',
[PayloadState.Created]: 'Created',
[PayloadState.Queued]: 'Queued',
[PayloadState.Executed]: 'Executed',
[PayloadState.Cancelled]: 'Cancelled',
[PayloadState.Expired]: 'Expired',
};

export interface PayloadsController {
controllerContract: GetContractReturnType<typeof IPayloadsControllerCore_ABI, PublicClient>;
// cache created / queued / Executed logs
Expand Down

0 comments on commit 403280d

Please sign in to comment.