account_local_actions.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. from abc import (
  2. ABC,
  3. abstractmethod,
  4. )
  5. from typing import (
  6. Any,
  7. Dict,
  8. Optional,
  9. Union,
  10. )
  11. from eth_keyfile.keyfile import (
  12. KDFType,
  13. )
  14. from eth_typing import (
  15. HexStr,
  16. )
  17. from eth_utils.curried import (
  18. combomethod,
  19. )
  20. from eth_account.datastructures import (
  21. SignedMessage,
  22. SignedTransaction,
  23. )
  24. from eth_account.messages import (
  25. SignableMessage,
  26. )
  27. from eth_account.typed_transactions.set_code_transaction import (
  28. SignedAuthorization,
  29. )
  30. from eth_account.types import (
  31. Blobs,
  32. PrivateKeyType,
  33. TransactionDictType,
  34. )
  35. class AccountLocalActions(ABC):
  36. @classmethod
  37. @abstractmethod
  38. def encrypt(
  39. self,
  40. private_key: PrivateKeyType,
  41. password: str,
  42. kdf: Optional[KDFType] = None,
  43. iterations: Optional[int] = None,
  44. ) -> Dict[str, Any]:
  45. pass
  46. @combomethod
  47. @abstractmethod
  48. def unsafe_sign_hash(
  49. self,
  50. message_hash: Union[HexStr, bytes, int],
  51. private_key: PrivateKeyType,
  52. ) -> SignedMessage:
  53. pass
  54. @combomethod
  55. @abstractmethod
  56. def sign_message(
  57. self,
  58. signable_message: SignableMessage,
  59. private_key: PrivateKeyType,
  60. ) -> SignedMessage:
  61. pass
  62. @combomethod
  63. @abstractmethod
  64. def sign_transaction(
  65. self,
  66. transaction_dict: TransactionDictType,
  67. private_key: PrivateKeyType,
  68. blobs: Optional[Blobs] = None,
  69. ) -> SignedTransaction:
  70. pass
  71. @combomethod
  72. @abstractmethod
  73. def sign_typed_data(
  74. self,
  75. private_key: PrivateKeyType,
  76. domain_data: Optional[Dict[str, Any]] = None,
  77. message_types: Optional[Dict[str, Any]] = None,
  78. message_data: Optional[Dict[str, Any]] = None,
  79. full_message: Optional[Dict[str, Any]] = None,
  80. ) -> SignedMessage:
  81. pass
  82. @combomethod
  83. @abstractmethod
  84. def sign_authorization(
  85. self,
  86. private_key: PrivateKeyType,
  87. authorization: Dict[str, Any],
  88. ) -> SignedAuthorization:
  89. pass