evm.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """
  2. Type definitions for the Ethereum Virtual Machine (EVM).
  3. """
  4. from typing import (
  5. Literal,
  6. NewType,
  7. TypeVar,
  8. Union,
  9. )
  10. from .encoding import (
  11. HexStr,
  12. )
  13. Hash32 = NewType("Hash32", bytes)
  14. """
  15. A 32-byte hash value.
  16. """
  17. BlockNumber = NewType("BlockNumber", int)
  18. """
  19. Any integer that represents a valid block number on a chain.
  20. """
  21. BlockParams = Literal["latest", "earliest", "pending", "safe", "finalized"]
  22. """
  23. A type which specifies the block reference parameter.
  24. - ``"latest"``: The latest block.
  25. - ``"earliest"``: The earliest block.
  26. - ``"pending"``: The pending block.
  27. - ``"safe"``: The safe block.
  28. - ``"finalized"``: The finalized block.
  29. """
  30. BlockIdentifier = Union[BlockParams, BlockNumber, Hash32, HexStr, int]
  31. """
  32. A type that represents a block identifier value.
  33. - ``BlockParams``: A block reference parameter.
  34. - ``BlockNumber``: A block number integer value.
  35. - ``Hash32``: A 32-byte hash value.
  36. - ``HexStr``: A string that represents a hex value.
  37. - ``int``: An integer value.
  38. """
  39. Address = NewType("Address", bytes)
  40. """
  41. A type that contains a 32-byte canonical address.
  42. """
  43. HexAddress = NewType("HexAddress", HexStr)
  44. """
  45. A type that contains a hex encoded address. This is a 32-byte hex string with a prefix
  46. of "0x".
  47. """
  48. ChecksumAddress = NewType("ChecksumAddress", HexAddress)
  49. """
  50. A type that contains a eth_typing.evm.HexAddress that is formatted according to
  51. `ERC55 <https://github.com/ethereum/EIPs/issues/55>`_. This is a 40 character hex
  52. string with a prefix of "0x" and mixed case letters.
  53. """
  54. AnyAddress = TypeVar("AnyAddress", Address, HexAddress, ChecksumAddress)
  55. """
  56. A type that represents any type of address.
  57. """