ApeWorX / ape-etherscan

Etherscan explorer plugin using EVM-based networks for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
26 stars 25 forks source link

feat: add support for unverified uniswap v3 pools [APE-1616] #109

Closed salparadi closed 9 months ago

salparadi commented 11 months ago

What I did

Allowed unverified Uniswap v3 contracts that are designated as "similar code" to pull a generic Uniswap v3 ABI instead of failing.

How I did it

Created a new Client for the proxy endpoint. Specifically to pass in a tx_hash. I recognize there are other data pieces you would want to pass in to proxy actions, but for this use case this seemed simplest.

Created a new GetTransactionByHashResponse dataclass

Created a new get_transaction_by_hash function which returns GetTransactionByHashResponse

Adjusted the ape_etherscan/explorer/get_contract_type function to run a check if the abi is not properly returned by the getsourcecode endpoint (the response is not JSON).

If it is not valid JSON, meaning it is a string saying Contract source code not verified, get the contract creation data, which gives us the transaction hash of the contract creation.

call the proxy/eth_getTransactionByHash endpoint using the new Proxy Client and retrieve the transaction information

Check the to field from the transaction against the known Uniswap V3: Positions NFT address, which is the to address of all Uniswap v3 pool initializations.

Load the generic Uniswap v3 ABI constant from ape_etherscan/utils

Continue the get_contract_type logic.

How to verify it

Load an ape console and try to get an unverified Uniswap v3 contract. Example:

contract = Contract('0x86E69D1AE728c9Cd229F07bBf34E01bF27258354')

It should have no errors and the contract should be available.

Checklist

github-actions[bot] commented 10 months ago

This pull request is considered stale because it has been open 30 days with no activity. Remove stale label, add a comment, or make a new commit, otherwise this PR will be closed in 5 days.

github-actions[bot] commented 9 months ago

This pull request is considered stale because it has been open 30 days with no activity. Remove stale label, add a comment, or make a new commit, otherwise this PR will be closed in 5 days.

github-actions[bot] commented 9 months ago

This PR was closed because it has been inactive for 35 days.