Skip to content

Commit

Permalink
feat: tenderly pinging (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Jan 19, 2024
1 parent 3fa38bd commit 7310c04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/govv3/checks/targetsVerified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// adjusted for viem & aave governance v3
import { Hex, PublicClient } from 'viem';
import { ProposalCheck } from './types';
import { TenderlySimulationResponse } from '../../utils/tenderlyClient';
import { TenderlySimulationResponse, tenderly } from '../../utils/tenderlyClient';
import { PayloadsController } from '../payloadsController';
import { isKnownAddress } from '../utils/checkAddress';
import { flagKnownAddress } from '../utils/markdownUtils';
Expand Down Expand Up @@ -49,6 +49,13 @@ async function checkVerificationStatuses(
const contract = getContract(sim, addr);
info.push(`- ${addr}: Contract (verified) (${contract?.contract_name}) ${flagKnownAddress(isAddrKnown)}`);
} else {
try {
if (isAddrKnown && isAddrKnown.length > 0) {
await tenderly.pingAddress(addr);
}
} catch (e) {
console.log('error pinging tenderly');
}
info.push(`- ${addr}: Contract (not verified) ${flagKnownAddress(isAddrKnown)}`);
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/utils/tenderlyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
zeroAddress,
PublicClient,
Chain,
Address,
} from 'viem';
import { EOA } from './constants';
import { logError, logInfo, logSuccess, logWarning } from './logger';
Expand Down Expand Up @@ -261,6 +262,24 @@ class Tenderly {
this.PROJECT = project;
}

/**
* Tenderly does a quite bad job with contract verification & simulation.
* When you simulate sth, touching a contract noone ever accessed via the dashboard it will not be available for state decoding.
* This method simply pings the dashboard to fetch the code from etherscan etc. so it will be available in the **next** simulation.
* @param chainId
* @param address
* @returns
*/
pingAddress = async (address: Address) => {
return fetch(`${this.TENDERLY_BASE}/search?query=${address}&quickSearch=true`, {
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
'X-Access-Key': this.ACCESS_TOKEN,
}),
});
};

trace = async (chainId: number, txHash: string): Promise<TenderlyTraceResponse> => {
const response = await fetch(`${this.TENDERLY_BASE}/public-contract/${chainId}/trace/${txHash}`, {
method: 'GET',
Expand Down

0 comments on commit 7310c04

Please sign in to comment.