Lorenz Herzberger 00131af397
adjusted block api return format
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-01-30 17:48:17 +01:00

24 lines
727 B
Python

# Copyright © 2020 Interplanetary Database Association e.V.,
# Planetmint and IPDB software contributors.
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0
from __future__ import annotations
import json
from dataclasses import dataclass, field
@dataclass
class Block:
id: str = ""
app_hash: str = ""
height: int = 0
transactions: list[str] = field(default_factory=list)
@staticmethod
def from_tuple(block_tuple: tuple) -> Block:
return Block(block_tuple[0], block_tuple[1], block_tuple[2], block_tuple[3])
def to_dict(self) -> dict:
return {"app_hash": self.app_hash, "height": self.height, "transaction_ids": self.transactions}