21 lines
609 B
Python
21 lines
609 B
Python
from base58 import b58decode
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class OwnerId:
|
|
value: str
|
|
|
|
def __post_init__(self):
|
|
if not self.value or self.value.strip() == "":
|
|
raise ValueError(f"{self.__class__.__name__} value is not present")
|
|
|
|
def to_hash(self) -> bytes:
|
|
"""Decodes the Base58-encoded value into a byte array."""
|
|
try:
|
|
return b58decode(self.value)
|
|
except Exception as e:
|
|
raise ValueError(f"Failed to decode Base58 value: {self.value}") from e
|
|
|
|
def __str__(self) -> str:
|
|
return self.value
|