ApeWorX / ape-etherscan

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

ProviderAPI implementation using Geth/parity proxy [APE-780] #81

Open antazoey opened 1 year ago

antazoey commented 1 year ago

Overview

One could implement a ProviderAPI using Etherscan's Geth/Parity proxy API: https://docs.etherscan.io/api-endpoints/geth-parity-proxy.

This is a good opportunity for a contributor to create a ProviderAPI implementation without having to make a whole new plugin!

Specification

Just an idea / psuedo-python (missing tons of things - this code wont work at all, just for demo, <3)

(ape_etherscan/provider.py)

from ape.api import ProviderAPI, BlockAPI

class EtherscanProvider(ProviderAPI):
    client_factory

    @cached_property
    def client(self) -> ProxyClient:
        ...

    def get_block(self, number):
        response = self.client.get_block(number)
        return BlockAPI.parse_obj(response)

Dependencies

Include links to any open issues that must be resolved before this feature can be implemented.