• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ape364 / aioetherscan / 11508304044

24 Oct 2024 10:16PM UTC coverage: 100.0%. Remained the same
11508304044

Pull #33

github

ape364
fix: pragma: no cover
Pull Request #33: feat: add api keys rotating

41 of 41 new or added lines in 4 files covered. (100.0%)

699 of 699 relevant lines covered (100.0%)

4.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/aioetherscan/modules/contract.py
1
from typing import Iterable
4✔
2

3
from aioetherscan.modules.base import BaseModule
4✔
4

5

6
class Contract(BaseModule):
4✔
7
    """Contracts
8

9
    https://docs.etherscan.io/api-endpoints/contracts
10
    """
11

12
    @property
4✔
13
    def _module(self) -> str:
4✔
14
        return 'contract'
4✔
15

16
    async def contract_abi(self, address: str) -> str:
4✔
17
        """Get Contract ABI for Verified Contract Source Codes"""
18
        return await self._get(action='getabi', address=address)
4✔
19

20
    async def contract_source_code(self, address: str) -> list[dict]:
4✔
21
        """Get Contract Source Code for Verified Contract Source Codes"""
22
        return await self._get(action='getsourcecode', address=address)
4✔
23

24
    async def contract_creation(self, addresses: Iterable[str]) -> list[dict]:
4✔
25
        """Get Contract Creator and Creation Tx Hash"""
26
        return await self._get(action='getcontractcreation', contractaddresses=','.join(addresses))
4✔
27

28
    async def verify_contract_source_code(
4✔
29
        self,
30
        contract_address: str,
31
        source_code: str,
32
        contract_name: str,
33
        compiler_version: str,
34
        optimization_used: bool = False,
35
        runs: int = 200,
36
        constructor_arguements: str = None,
37
        libraries: dict[str, str] = None,
38
    ) -> str:
39
        """Submits a contract source code to Etherscan for verification."""
40
        return await self._post(
4✔
41
            module='contract',
42
            action='verifysourcecode',
43
            contractaddress=contract_address,
44
            sourceCode=source_code,
45
            contractname=contract_name,
46
            compilerversion=compiler_version,
47
            optimizationUsed=1 if optimization_used else 0,
48
            runs=runs,
49
            constructorArguements=constructor_arguements,
50
            **self._parse_libraries(libraries or {}),
51
        )
52

53
    async def check_verification_status(self, guid: str) -> str:
4✔
54
        """Check Source code verification submission status"""
55
        return await self._get(action='checkverifystatus', guid=guid)
4✔
56

57
    async def verify_proxy_contract(self, address: str, expected_implementation: str = None) -> str:
4✔
58
        """Submits a proxy contract source code to Etherscan for verification."""
59
        return await self._post(
4✔
60
            module='contract',
61
            action='verifyproxycontract',
62
            address=address,
63
            expectedimplementation=expected_implementation,
64
        )
65

66
    async def check_proxy_contract_verification(self, guid: str) -> str:
4✔
67
        """Checking Proxy Contract Verification Submission Status"""
68
        return await self._get(action='checkproxyverification', guid=guid)
4✔
69

70
    @staticmethod
4✔
71
    def _parse_libraries(libraries: dict[str, str]) -> dict[str, str]:
4✔
72
        return dict(
4✔
73
            part
74
            for i, (name, address) in enumerate(libraries.items(), start=1)
75
            for part in ((f'libraryname{i}', name), (f'libraryaddress{i}', address))
76
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc