Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tenderly pinging #97

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading