Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- S = TypeVar('S', bound='DictSerializable')
- class DictSerializable(metaclass=ABCMeta):
- @abstractmethod
- def to_dict(self) -> dict:
- "Converts the object to a dict containing only primitive types"
- @staticmethod
- @abstractmethod
- def from_dict(data: str) -> S:
- "Converts the object to a dict containing only primitive types"
- class PaymentDetails(DictSerializable):
- def __init__(self,
- node_info: Optional[Node] = None,
- fee: Optional[int] = None,
- block_hash: Optional[str] = None,
- block_number: Optional[int] = None,
- check: Optional[bool] = None,
- tx: Optional[str] = None) -> None:
- self.node_info = node_info
- self.fee = fee
- self.block_hash = block_hash
- self.block_number = block_number
- self.check = check
- self.tx = tx
- def to_dict(self) -> dict:
- d = self.__dict__
- if self.node_info:
- d['node_info'] = self.node_info.to_dict()
- return d
- @staticmethod
- def from_dict(data: dict) -> 'PaymentDetails':
- det = PaymentDetails()
- det.__dict__.update(data)
- det.__dict__['node_info'] = Node.from_dict(data['node_info'])
- return det
Advertisement
Add Comment
Please, Sign In to add comment