diff --git a/src/govv3/generateProposalReport.ts b/src/govv3/generateProposalReport.ts index b8b7533..0ffd866 100644 --- a/src/govv3/generateProposalReport.ts +++ b/src/govv3/generateProposalReport.ts @@ -6,7 +6,7 @@ import { checkLogs } from './checks/logs'; import { checkTouchedContractsVerifiedEtherscan } from './checks/targetsVerified'; import { Governance, HUMAN_READABLE_STATE } from './governance'; import { checkStateChanges } from './checks/state'; -import { getProposalMetadata } from '@bgd-labs/js-utils'; +import { getCachedIpfs } from '../ipfs/getCachedProposalMetaData'; type GenerateReportRequest = { proposalId: bigint; @@ -53,7 +53,8 @@ export async function generateProposalReport({ } report += '\n'; - const ipfsMeta = await getProposalMetadata(proposal.ipfsHash, process.env.IPFS_GATEWAY); + const ipfsMeta = await getCachedIpfs(proposal.ipfsHash); + console.log(ipfsMeta); report += `### Ipfs
diff --git a/src/govv3/simulate.ts b/src/govv3/simulate.ts index a73c331..8335838 100644 --- a/src/govv3/simulate.ts +++ b/src/govv3/simulate.ts @@ -4,6 +4,8 @@ import { getGovernance } from './governance'; import { Hex, PublicClient } from 'viem'; import { PayloadsController, getPayloadsController } from './payloadsController'; import { CHAIN_ID_CLIENT_MAP } from '@bgd-labs/js-utils'; +import { generateReport } from './generatePayloadReport'; +import { generateProposalReport } from './generateProposalReport'; /** * Reference implementation, unused @@ -17,7 +19,16 @@ export async function simulateProposal(governanceAddress: Hex, publicClient: Pub const governance = getGovernance({ address: governanceAddress, publicClient }); const logs = await governance.cacheLogs(); const proposal = await governance.getProposalAndLogs(proposalId, logs); - await governance.simulateProposalExecutionOnTenderly(proposalId, proposal); + const result = await governance.simulateProposalExecutionOnTenderly(proposalId, proposal); + console.log( + await generateProposalReport({ + simulation: result, + proposalId: proposalId, + proposalInfo: proposal, + publicClient: publicClient, + }) + ); + return; const payloads: { payload: Awaited>; simulation: TenderlySimulationResponse; @@ -25,12 +36,20 @@ export async function simulateProposal(governanceAddress: Hex, publicClient: Pub for (const payload of proposal.proposal.payloads) { const controllerContract = getPayloadsController( payload.payloadsController, - CHAIN_ID_CLIENT_MAP[Number(payload.chain) as keyof typeof CHAIN_ID_CLIENT_MAP] as PublicClient + CHAIN_ID_CLIENT_MAP[Number(payload.chain) as keyof typeof CHAIN_ID_CLIENT_MAP] ); const logs = await controllerContract.cacheLogs(); const config = await controllerContract.getPayload(payload.payloadId, logs); try { const result = await controllerContract.simulatePayloadExecutionOnTenderly(payload.payloadId, config); + console.log( + await generateReport({ + simulation: result, + payloadId: payload.payloadId, + payloadInfo: config, + publicClient: CHAIN_ID_CLIENT_MAP[Number(payload.chain) as keyof typeof CHAIN_ID_CLIENT_MAP], + }) + ); payloads.push({ payload: config, simulation: result }); } catch (e) { console.log('error simulating payload');